From patchwork Fri Feb 18 17:33:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 543961 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 06269C433EF for ; Fri, 18 Feb 2022 17:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238628AbiBRRdj (ORCPT ); Fri, 18 Feb 2022 12:33:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238630AbiBRRdi (ORCPT ); Fri, 18 Feb 2022 12:33:38 -0500 Received: from smtp.smtpout.orange.fr (smtp01.smtpout.orange.fr [80.12.242.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BCB12B5BBF for ; Fri, 18 Feb 2022 09:33:20 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id L789nW7orFTgbL789niAWH; Fri, 18 Feb 2022 18:33:19 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 18 Feb 2022 18:33:19 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Hans de Goede , Krzysztof Kozlowski , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Sebastian Reichel Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-pm@vger.kernel.org Subject: [PATCH] power: supply: max17042_battery: Use devm_delayed_work_autocancel() Date: Fri, 18 Feb 2022 18:33:15 +0100 Message-Id: <670ef51366f96035f49852cd17325af10ffa07ea.1645205558.git.christophe.jaillet@wanadoo.fr> 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_delayed_work_autocancel() instead of hand-writing it. This saves a few lines of code. Signed-off-by: Christophe JAILLET --- drivers/power/supply/max17042_battery.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 87128cf0d577..ab031bbfbe78 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -9,6 +9,7 @@ // This driver is based on max17040_battery.c #include +#include #include #include #include @@ -1030,13 +1031,6 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = { .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, }; -static void max17042_stop_work(void *data) -{ - struct max17042_chip *chip = data; - - cancel_work_sync(&chip->work); -} - static int max17042_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1142,8 +1136,8 @@ static int max17042_probe(struct i2c_client *client, regmap_read(chip->regmap, MAX17042_STATUS, &val); if (val & STATUS_POR_BIT) { - INIT_WORK(&chip->work, max17042_init_worker); - ret = devm_add_action(&client->dev, max17042_stop_work, chip); + ret = devm_work_autocancel(&client->dev, &chip->work, + max17042_init_worker); if (ret) return ret; schedule_work(&chip->work);