Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp973269pxb; Wed, 6 Apr 2022 05:44:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQehxa/vw7/4AfEZyX9iTSbKdIX6P/FZ0EI3YlGTMjxrHflhE0VYvjaImLR7rnap8vIeV2 X-Received: by 2002:a17:90b:3802:b0:1c6:905c:af2e with SMTP id mq2-20020a17090b380200b001c6905caf2emr9651369pjb.236.1649249097410; Wed, 06 Apr 2022 05:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249097; cv=none; d=google.com; s=arc-20160816; b=NZIb+Rq2a3H7Lwmno4kPhwEsh2EoTpvU2HuVD5YAp5ksl9oLbil5m7BIOvGh63iQnn HjMvWrQ/uVKmOzba5qd8itTH+enc/BnOmJzuqMjoanHTybTE11pY1vZvCyIPsGSL3Ixt EZYFlxW1Puq+nD52pmPIzAXpRKeTptvoJJN12L8Z61wQzkESaNiD54BKESS3waHB/vuF 5u55LnAVeGDoPS9bWibK5MzEoPlvEoKLKl+W4NojNQwfMBwxvlpgm0wkP4mnYTR3n42J IAdAEjOh4W8EzrrmmjqCWGdZkcMTRidNM9dGvHtMe7wXf5+sR1cOo4rq2d1cZrUUkRGl YhEw== 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=HPlccEi93F3gLHQT4O1XNvBMDWZYkMEUWvGBqswBRPXRlXnUea4QdMk399xNy9wpk3 uSfxadfdil79GHa1scfdv7Qd39DKpQNO+65crrI/W/0t0LrdGvFFuXrzVvU0T+KKg9al ej/HuqSOPZ5OyoYnQUiulIYbLRVK5ge8n8Bu6ljfpV5fEgo1YfEOiYLSx9tbQf6SAZWV OAgPDPa5NM7X7pJ01zTAeZ5fk9AcMfkVgdZLx+QxRaHhzhsLjcH/JWG0HJ5Nz0deUsNZ Z9VeOGGl/ywEB7VK4tBVAhAt86Wx3Qva9lV4zEAkmune+LBuVdwLqq665fOLVEcsOtZS ltiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s3N6DI+J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g17-20020a056a0023d100b004fa3f687674si16403391pfc.256.2022.04.06.05.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:44:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s3N6DI+J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAA9A25E8D1; Wed, 6 Apr 2022 02:21:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345373AbiDEVC5 (ORCPT + 99 others); Tue, 5 Apr 2022 17:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349135AbiDEJtM (ORCPT ); Tue, 5 Apr 2022 05:49:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F56CF; Tue, 5 Apr 2022 02:41:14 -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 D534661673; Tue, 5 Apr 2022 09:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDA60C385A4; Tue, 5 Apr 2022 09:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151673; bh=9n0s1PVnFShGn2pmObyGWleDrpp43npEIx1yGJvstUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3N6DI+J+nPUi7QncrOKYDrkkKNlUgLiv9K0NefbTh/ZgGdSUO4OxPtGUE/6WxVBi pnWYObaRPJB4WMgtz1g0PoZipzHh/+Ea1H9M3TunF9HwCwobX5Q+edupm8TTfVVZ6E 8WLdknoMmWDzNU8UAfAb77DQDrECRgDLRwOTRfZU= 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.15 493/913] power: supply: sbs-charger: Dont cancel work that is not initialized Date: Tue, 5 Apr 2022 09:25:55 +0200 Message-Id: <20220405070354.632314836@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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