linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: Simplify memory allocation
@ 2022-02-05 16:40 Christophe JAILLET
  2022-02-11 18:50 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-02-05 16:40 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pm

Use devm_bitmap_zalloc() instead of hand writing it.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/power_supply_hwmon.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
index bffe6d84c429..a48aa4afb828 100644
--- a/drivers/power/supply/power_supply_hwmon.c
+++ b/drivers/power/supply/power_supply_hwmon.c
@@ -324,11 +324,6 @@ static const struct hwmon_chip_info power_supply_hwmon_chip_info = {
 	.info = power_supply_hwmon_info,
 };
 
-static void power_supply_hwmon_bitmap_free(void *data)
-{
-	bitmap_free(data);
-}
-
 int power_supply_add_hwmon_sysfs(struct power_supply *psy)
 {
 	const struct power_supply_desc *desc = psy->desc;
@@ -349,18 +344,14 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
 	}
 
 	psyhw->psy = psy;
-	psyhw->props = bitmap_zalloc(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG + 1,
-				     GFP_KERNEL);
+	psyhw->props = devm_bitmap_zalloc(dev,
+					  POWER_SUPPLY_PROP_TIME_TO_FULL_AVG + 1,
+					  GFP_KERNEL);
 	if (!psyhw->props) {
 		ret = -ENOMEM;
 		goto error;
 	}
 
-	ret = devm_add_action_or_reset(dev, power_supply_hwmon_bitmap_free,
-			      psyhw->props);
-	if (ret)
-		goto error;
-
 	for (i = 0; i < desc->num_properties; i++) {
 		const enum power_supply_property prop = desc->properties[i];
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: supply: Simplify memory allocation
  2022-02-05 16:40 [PATCH] power: supply: Simplify memory allocation Christophe JAILLET
@ 2022-02-11 18:50 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2022-02-11 18:50 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: linux-kernel, kernel-janitors, linux-pm

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

Hi,

On Sat, Feb 05, 2022 at 05:40:57PM +0100, Christophe JAILLET wrote:
> Use devm_bitmap_zalloc() instead of hand writing it.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/power_supply_hwmon.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c
> index bffe6d84c429..a48aa4afb828 100644
> --- a/drivers/power/supply/power_supply_hwmon.c
> +++ b/drivers/power/supply/power_supply_hwmon.c
> @@ -324,11 +324,6 @@ static const struct hwmon_chip_info power_supply_hwmon_chip_info = {
>  	.info = power_supply_hwmon_info,
>  };
>  
> -static void power_supply_hwmon_bitmap_free(void *data)
> -{
> -	bitmap_free(data);
> -}
> -
>  int power_supply_add_hwmon_sysfs(struct power_supply *psy)
>  {
>  	const struct power_supply_desc *desc = psy->desc;
> @@ -349,18 +344,14 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
>  	}
>  
>  	psyhw->psy = psy;
> -	psyhw->props = bitmap_zalloc(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG + 1,
> -				     GFP_KERNEL);
> +	psyhw->props = devm_bitmap_zalloc(dev,
> +					  POWER_SUPPLY_PROP_TIME_TO_FULL_AVG + 1,
> +					  GFP_KERNEL);
>  	if (!psyhw->props) {
>  		ret = -ENOMEM;
>  		goto error;
>  	}
>  
> -	ret = devm_add_action_or_reset(dev, power_supply_hwmon_bitmap_free,
> -			      psyhw->props);
> -	if (ret)
> -		goto error;
> -
>  	for (i = 0; i < desc->num_properties; i++) {
>  		const enum power_supply_property prop = desc->properties[i];
>  
> -- 
> 2.32.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-11 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 16:40 [PATCH] power: supply: Simplify memory allocation Christophe JAILLET
2022-02-11 18:50 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).