Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2888380rdb; Mon, 4 Dec 2023 10:07:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEloEH7mC+qdqrTbKU8d7xMvvO5kRu0wPlp0Xn/vc3L9O37uGeuxngelTVX2jS+bBwBLNKp X-Received: by 2002:a17:902:a982:b0:1d0:6ffd:f21f with SMTP id bh2-20020a170902a98200b001d06ffdf21fmr1680813plb.117.1701713258818; Mon, 04 Dec 2023 10:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713258; cv=none; d=google.com; s=arc-20160816; b=Vr67NNMbm7sRWz8GdHgXmfzDG/r+gD7SRVyZIMgvrTBPT9eOkjT4oebv5d7iAN9Q8K X4TU5athatwibxKT/5n0FXRpSLBIK7ySBfnu3yvt8N0sBnE0yIhHPwqasbHqLcenccTM jhlEyESxrCfJCajbt6lecQDhEnFn5E+Pwm5AnZZ96kEDfGVzvqG8so+jV7u+2luvpUQP ELq3qdniDaQxErUpdCwGGirvIxxZfM/knDl4WkZqKCESrdNqPv1VuKf1DWHTsMHtwdym Qqm2P0Fs/bFPSgGdrqL7202cHSB+2gtggDTkQGK+tq6bwNI6lP8OS6fVCYM07lCxmkFH 00LA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=aevEy7ZXFtoB1it3KHBxLYqLuMYAMZ1UYECEx9o+AXQ=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=qey/zEDyWRvQp4AKPxdHkBZxebxMtSWR2Xup/uLPrmZOtC20ZZhwD9/elFqJcYdaXb 1wrvdYbOAidmpQXF9Wy+a1O9FuAkRPYzkB5GW4ebb24lqC+afquDcTXZm6eXLZ0q1sLH sERTzjR+gCiiU7zGtdFcFoJeMA1oWUpRvppMaR6Q5E+hLIExK3phKs1xwLv6xqTM9wbU lD/TBh6/UtK2EL1LljTMkM4BT60tHGcKfJgG35H0YHHzAVkaHXV5+go7As17acyC4HJ+ nCzBWU/1WtE++weRiqJFV/VsBxTCKvZQMpR5teYCHtc1NgqrzNSL9GihCQxMumqkfv/Q /pSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=IspV7GNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l10-20020a170903244a00b001cf69216445si8420469pls.392.2023.12.04.10.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=IspV7GNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8D7B280AC5BD; Mon, 4 Dec 2023 10:07:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231922AbjLDSH1 (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8FE130; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 70C8F100011; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 70C8F100011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713235; bh=aevEy7ZXFtoB1it3KHBxLYqLuMYAMZ1UYECEx9o+AXQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=IspV7GNP+VQ3nE1DeeJh+fzKkDMRBaVNiYt1Pa6frUHtzwZZzvaOmBZdONZMT3weO QFBxVXgwfRvPYu9QjORr3ZRs38fubObXfdmFXtnwOIZ3bisyAZCfb87O0tYUdtKCGu F5nJXkaI8vLsisUJqLasgAtLMAUfynaqQxwAQftmP/A/mHhlUNU3ZpQfzTJKTa1gpg 7pWGSAZyKUGX7o7ZV8BbcrofYCgTW3XyTJrQ+PS8x54UGr8FBgF3vBlr2kl94djzBw S/9NLBsrmM6Op0U+n340Swl9cRmokuWSRWDOsEZbb29C/3eP5i7R2V51DTy99Hm+Jj qugDfLwyWEO6A== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:15 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 05/10] leds: lp3952: use devm API to cleanup module's resources Date: Mon, 4 Dec 2023 21:05:58 +0300 Message-ID: <20231204180603.470421-6-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/04 11:06:00 #22624476 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:07:37 -0800 (PST) In this driver LEDs are registered using devm_led_classdev_register() so they are automatically unregistered after module's remove() is done. led_classdev_unregister() calls module's led_set_brightness() to turn off the LEDs and that callback uses resources which were destroyed already in module's remove() so use devm API instead of remove(). Also drop explicit turning LEDs off from remove() due to they will be off anyway by led_classdev_unregister(). Signed-off-by: George Stark --- drivers/leds/leds-lp3952.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-lp3952.c b/drivers/leds/leds-lp3952.c index 3bd55652a706..fc0e02a9768f 100644 --- a/drivers/leds/leds-lp3952.c +++ b/drivers/leds/leds-lp3952.c @@ -207,6 +207,13 @@ static const struct regmap_config lp3952_regmap = { .cache_type = REGCACHE_RBTREE, }; +static void gpio_set_low_action(void *data) +{ + struct lp3952_led_array *priv = (struct lp3952_led_array *)data; + + gpiod_set_value(priv->enable_gpio, 0); +} + static int lp3952_probe(struct i2c_client *client) { int status; @@ -226,6 +233,10 @@ static int lp3952_probe(struct i2c_client *client) return status; } + status = devm_add_action(&client->dev, gpio_set_low_action, priv); + if (status) + return status; + priv->regmap = devm_regmap_init_i2c(client, &lp3952_regmap); if (IS_ERR(priv->regmap)) { int err = PTR_ERR(priv->regmap); @@ -254,15 +265,6 @@ static int lp3952_probe(struct i2c_client *client) return 0; } -static void lp3952_remove(struct i2c_client *client) -{ - struct lp3952_led_array *priv; - - priv = i2c_get_clientdata(client); - lp3952_on_off(priv, LP3952_LED_ALL, false); - gpiod_set_value(priv->enable_gpio, 0); -} - static const struct i2c_device_id lp3952_id[] = { {LP3952_NAME, 0}, {} @@ -274,7 +276,6 @@ static struct i2c_driver lp3952_i2c_driver = { .name = LP3952_NAME, }, .probe = lp3952_probe, - .remove = lp3952_remove, .id_table = lp3952_id, }; -- 2.38.4