From patchwork Fri Feb 18 17:37:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12751684 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 51C21C433EF for ; Fri, 18 Feb 2022 17:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238658AbiBRRiA (ORCPT ); Fri, 18 Feb 2022 12:38:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238665AbiBRRh6 (ORCPT ); Fri, 18 Feb 2022 12:37:58 -0500 Received: from smtp.smtpout.orange.fr (smtp01.smtpout.orange.fr [80.12.242.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869FB27CD2 for ; Fri, 18 Feb 2022 09:37:41 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id L7CNnW9vTFTgbL7CNniBOp; Fri, 18 Feb 2022 18:37:40 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 18 Feb 2022 18:37:40 +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 V2] power: supply: max17042_battery: Use devm_work_autocancel() Date: Fri, 18 Feb 2022 18:37:37 +0100 Message-Id: <670ea51361f96035f49852c617325af10ffa07ea.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_work_autocancel() instead of hand-writing it. This saves a few lines of code. Signed-off-by: Christophe JAILLET Reviewed-by: Hans de Goede Reviewed-by: Krzysztof Kozlowski --- V2: s/devm_delayed_work_autocancel/devm_work_autocancel/ 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);