From patchwork Sat Feb 5 16:40:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 540526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5138BC433FE for ; Sat, 5 Feb 2022 16:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380354AbiBEQlK (ORCPT ); Sat, 5 Feb 2022 11:41:10 -0500 Received: from smtp08.smtpout.orange.fr ([80.12.242.130]:57585 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353071AbiBEQlK (ORCPT ); Sat, 5 Feb 2022 11:41:10 -0500 Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id GO7YngGexxHdTGO7YnEdz2; Sat, 05 Feb 2022 17:41:09 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 05 Feb 2022 17:41:09 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Sebastian Reichel Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-pm@vger.kernel.org Subject: [PATCH] power: supply: Simplify memory allocation Date: Sat, 5 Feb 2022 17:40:57 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use devm_bitmap_zalloc() instead of hand writing it. Signed-off-by: Christophe JAILLET --- 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];