Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5270338pxb; Sun, 13 Feb 2022 14:35:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxd9g+khd28ETWetAFDYgiejWfSNaJANF06uVIvOOrA6QekcQj13HghUBgLX5Ld4Gk3S0SE X-Received: by 2002:a63:565e:: with SMTP id g30mr9389978pgm.267.1644791701016; Sun, 13 Feb 2022 14:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644791701; cv=none; d=google.com; s=arc-20160816; b=xv4WkSeoKCQVtnvvgj4nqNUJGGU+fzIqsgxoxqH9XxakCOwVoprQ1dxE/7bkM1IPTe NyHnqzoPp8vtAFYeX9/odd8W1GZ9d1FJ6rZuLngru2lJFY2/hMtNMOt8YMScX2m9O7Ms jju8XJaKos1Oa0H+gC5kHIRHSPS1W/EylEh1C8bbs/dlHiDXoUkPARZ/byyDSLlcxfwW tGqkHTXBSWEhKCIKt+2E2u7b2Fzwps3ZSe/XL/huhUdLs1oNkUIGM8cQSCoDjcg2U7XQ iCsb5hyROD/H11UwqUd6UU1QnrgvIcyK2uRWMgl9xsOhOxxHhwKblNmqt0xdDCYaNyuu f+fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cIVYIKnkiMZwCq4mM5IbR1xFMg/lJMnWJTr4sw1B3/s=; b=EaGgo1Gr4mZuWtGgdw4oORwqE3AaDJv2kL3qnzdMQLIyWefC7xsrBRQiqJLJqVsbQb toa6M1/BojNaSNvwaiEF8la/MIu3M6I0sZ8C2dIcAdD5DkhEI6WaXO0JPXtICS928S+b gKr/ZG8ic5QsRM4wUZOCA3HBANYYDeIJ3rxVcQmPliAHQiopjbnrTqrFCZSt0JNNWLKE K195lbMBCHfRgTc5hyAvJIW1jshyTYEcD9bmpb38VQh9Xl8cJIOOBO7LsqELh1I/IJ0a OlrTt8V7uGziYaMcmh5fiDs6VoNi3Jl84DavnUSyo0yjqYqVBKByGMX+xs4yMz5bmkKO 90Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8si9808307pjv.158.2022.02.13.14.34.45; Sun, 13 Feb 2022 14:35:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238047AbiBMTtH (ORCPT + 99 others); Sun, 13 Feb 2022 14:49:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231842AbiBMTtE (ORCPT ); Sun, 13 Feb 2022 14:49:04 -0500 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC33339695 for ; Sun, 13 Feb 2022 11:48:57 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id JKrendyPyuvBOJKrenOULd; Sun, 13 Feb 2022 20:48:56 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 13 Feb 2022 20:48:56 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Iwona Winiarska , Jean Delvare , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-hwmon@vger.kernel.org Subject: [PATCH] hwmon: peci: Use devm_delayed_work_autocancel() to simplify code Date: Sun, 13 Feb 2022 20:48:53 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_delayed_work_autocancel() instead of hand writing it. This is less verbose and saves a few lines of code. devm_delayed_work_autocancel() uses devm_add_action() instead of devm_add_action_or_reset(). This is fine, because if the underlying memory allocation fails, no work has been scheduled yet. So there is nothing to undo. Signed-off-by: Christophe JAILLET --- drivers/hwmon/peci/dimmtemp.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/peci/dimmtemp.c b/drivers/hwmon/peci/dimmtemp.c index c8222354c005..96b9919db357 100644 --- a/drivers/hwmon/peci/dimmtemp.c +++ b/drivers/hwmon/peci/dimmtemp.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -378,13 +379,6 @@ static void create_dimm_temp_info_delayed(struct work_struct *work) dev_err(priv->dev, "Failed to populate DIMM temp info\n"); } -static void remove_delayed_work(void *_priv) -{ - struct peci_dimmtemp *priv = _priv; - - cancel_delayed_work_sync(&priv->detect_work); -} - static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id) { struct device *dev = &adev->dev; @@ -415,9 +409,8 @@ static int peci_dimmtemp_probe(struct auxiliary_device *adev, const struct auxil "Unexpected PECI revision %#x, some features may be unavailable\n", peci_dev->info.peci_revision); - INIT_DELAYED_WORK(&priv->detect_work, create_dimm_temp_info_delayed); - - ret = devm_add_action_or_reset(priv->dev, remove_delayed_work, priv); + ret = devm_delayed_work_autocancel(priv->dev, &priv->detect_work, + create_dimm_temp_info_delayed); if (ret) return ret; -- 2.32.0