Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp695505pxb; Tue, 5 Apr 2022 19:08:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+rDWcAa4Ktz3+Y2+fqave1P3kYfN7wU7Un9K3iMzvR7iNU9CLF6PCOIjyO+k+7ESkFXsk X-Received: by 2002:a17:906:a44c:b0:6e7:ed8b:5126 with SMTP id cb12-20020a170906a44c00b006e7ed8b5126mr6214664ejb.75.1649210885895; Tue, 05 Apr 2022 19:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210885; cv=none; d=google.com; s=arc-20160816; b=hy4oDNOnPBRRd9P4d9pna1j4+psiGMz9w4Vuw5crL6qhADeAVqtpjGHEVYPZvWs8// W9u07q0JRuZW4Ly/Dp1pCFVvmYWhNjBRocv64BVWBqvHtebW+QfxwFe52whP4kmPTli7 Y4bRvt7JZo9KwLRGyajZMEQ/Ieoo5zGymwKmlRWMT7AFaoKSMPGH850QBbyIukQ6EQlk iZOZXE1EpY1Yj7Td2MBqQta3jyNVDmStrhioq9WUW68h1PyloSK0py7lv51YLoWXgqCO suPAnUfo3BF/3fykIJK7JQuEbcb8Tp9yZjkznOs1RXuU+24N0RpXNsZOAhHaOmTwCrKu v3NA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5+vJ6X0g/dPmF8EWHaaIvBBw7Z3zYT+QEMl7impWKXI=; b=jJfBF6SehdVqJSvk5r11hn8UxHGJ7spaDPo/47Qtul3cTK6Bwo6jopQiGwo0ZECCbD aOegajIHRNQSPoIZjRBonOvAdbMTHQoO+bSpc+1grxhCQ/53Ndd5qtdsNjKl7qh/h0t/ AiJMbmuDjwsgeRZIqnSkTdGdlR0K1NLf9WsFMPBIJpxqxYnEXOfev1hml7aQ60LwPmQI hVRHYFpmuEy9vELOddTkQCngSwfCF4Z6tLFDwK7P+dXZBt74bcf9N4RSCG8PSO7t/vKZ IifDa2kOWvu3US9Jb1WDgm4PMy5ZKNBSpmsmRJ+mWu8Dtq0WRoXeLk3tdCQ14KztxOCZ f2sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Du952JaC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 18-20020a170906301200b006e75bf28b29si7734785ejz.974.2022.04.05.19.07.36; Tue, 05 Apr 2022 19:08:05 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Du952JaC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237283AbiDEJEL (ORCPT + 99 others); Tue, 5 Apr 2022 05:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237478AbiDEISD (ORCPT ); Tue, 5 Apr 2022 04:18:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B504B53F2; Tue, 5 Apr 2022 01:06:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C016617EF; Tue, 5 Apr 2022 08:06:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E9BDC385A1; Tue, 5 Apr 2022 08:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145983; bh=9n0s1PVnFShGn2pmObyGWleDrpp43npEIx1yGJvstUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Du952JaCwqdfaPwo72AxWllgpGDk8C3erEaCoKQxQB1LGFpQjd/EcTpVhJ11hPmkD 8EdtYjsvH+XmV7sfp6BlhaJ1WOMq+PIuJfVXAxP4yxX7DDzCDHyA1YELmEL/HeHBzW 7tZtIruWUIfEfJcPnQrQC3JUBhTlbhfa+EnDOQVs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.17 0601/1126] power: supply: sbs-charger: Dont cancel work that is not initialized Date: Tue, 5 Apr 2022 09:22:28 +0200 Message-Id: <20220405070425.275097515@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 From: Christophe JAILLET [ Upstream commit de85193cff0d94d030a53656d8fcc41794807bef ] This driver can use an interrupt or polling in order get the charger's status. When using polling, a delayed work is used. However, the remove() function unconditionally call cancel_delayed_work_sync(), even if the delayed work is not used and is not initialized. In order to fix it, use devm_delayed_work_autocancel() and remove the now useless remove() function. Fixes: feb583e37f8a ("power: supply: add sbs-charger driver") Signed-off-by: Christophe JAILLET Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/sbs-charger.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/sbs-charger.c b/drivers/power/supply/sbs-charger.c index 6fa65d118ec1..b08f7d0c4181 100644 --- a/drivers/power/supply/sbs-charger.c +++ b/drivers/power/supply/sbs-charger.c @@ -18,6 +18,7 @@ #include #include #include +#include #define SBS_CHARGER_REG_SPEC_INFO 0x11 #define SBS_CHARGER_REG_STATUS 0x13 @@ -209,7 +210,12 @@ static int sbs_probe(struct i2c_client *client, if (ret) return dev_err_probe(&client->dev, ret, "Failed to request irq\n"); } else { - INIT_DELAYED_WORK(&chip->work, sbs_delayed_work); + ret = devm_delayed_work_autocancel(&client->dev, &chip->work, + sbs_delayed_work); + if (ret) + return dev_err_probe(&client->dev, ret, + "Failed to init work for polling\n"); + schedule_delayed_work(&chip->work, msecs_to_jiffies(SBS_CHARGER_POLL_TIME)); } @@ -220,15 +226,6 @@ static int sbs_probe(struct i2c_client *client, return 0; } -static int sbs_remove(struct i2c_client *client) -{ - struct sbs_info *chip = i2c_get_clientdata(client); - - cancel_delayed_work_sync(&chip->work); - - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id sbs_dt_ids[] = { { .compatible = "sbs,sbs-charger" }, @@ -245,7 +242,6 @@ MODULE_DEVICE_TABLE(i2c, sbs_id); static struct i2c_driver sbs_driver = { .probe = sbs_probe, - .remove = sbs_remove, .id_table = sbs_id, .driver = { .name = "sbs-charger", -- 2.34.1