Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5779944rdb; Wed, 13 Dec 2023 21:42:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCrZYudiMYezkZNrwmr3kug8f2UPmhNrJmHgf8VwPvP0m/VtTIgtIbyhBO/F/TNjysdHr8 X-Received: by 2002:a17:902:ebcd:b0:1d0:c906:f5e0 with SMTP id p13-20020a170902ebcd00b001d0c906f5e0mr10729514plg.72.1702532552313; Wed, 13 Dec 2023 21:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702532552; cv=none; d=google.com; s=arc-20160816; b=JLU9JRyv3/YF44Z5w3FHJTrXNmeiYuKk0Rndd6H0OfmtvfFYkaKdvH+xpW976XUt5t 6XB2v5Lssc3TlALvcDqLvtD+IMIWhUl+iCGa6GsXYIIlXR+rWEtjvNZoCROvUutYK1mD 1sR8Y223aqk+ro0MsNW0ySbeXCr/lwdi5BACYmi66hYsiHjmFVJi3QV5XQahTsXNllmX c1iHU2bAcH0tOxD+qmGVEL0iD3G8IB3rNuchkZiT6SvNFyTRMArXtWt4/KDrlx+y2IZB wtwWH98D/7pG0SYaMBNwBYW/1H+DQZIaW+yWTc6BGKnvb6SXz23T+i1SqYoAQQ8DBTGu 6TMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version:dkim-signature; bh=DCanRE6ZU9hMtgBrifgjCOGzWGlpmu1PwPR7u8AbMrI=; fh=+xeVCWlaTvw6Pej5Qwi/CsS+K8hmqOxZCTC/5jRbdXM=; b=ngojPGJvfILsjDmtnqppCjtmPCyrLoWwGpTlRIpd4T3gdvB1yDqGY84FCQjTmZ/9l6 kL0qEGjWXUT66atElC7TpRH5nG00mGNegwzjx9hwBi+kFT9yCErrc2S2nBhp/tKdiLK4 bXrjejX9soK5ImJu7BK3eosG3G1lIxF3vrBaNZnYRtCar93GGzQfBYfil8s1S9LZqsd8 niaJQtLyjx4jJjX5Su8ie1OksEdyPhxUoXKO3mjCh7S68te5WcxWCfB6H1VCvSxnvb+K vWECIDIpvE4sIb52v1erte4gDVqLVcVPSiI+8BpQjzaZlaEqGbq4Q7DhI8fc55pGZO8M 9cOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=oxrcgcg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id p6-20020a170902e74600b001d344a3f786si3233000plf.457.2023.12.13.21.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 21:42:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@trvn.ru header.s=mail header.b=oxrcgcg5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=trvn.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C1C31807F955; Wed, 13 Dec 2023 21:42:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443178AbjLNFmF (ORCPT + 99 others); Thu, 14 Dec 2023 00:42:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjLNFmB (ORCPT ); Thu, 14 Dec 2023 00:42:01 -0500 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE310AC; Wed, 13 Dec 2023 21:42:06 -0800 (PST) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 51B15408EF; Thu, 14 Dec 2023 10:42:02 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1702532522; bh=cR6tyKPKN7gk3TnmXe4ERX1lFG8NrlKVwL/KAde86sM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oxrcgcg5FIrv/i0f5jrMIsUIaotfs1kKA+N3YsSNhycbKOL/vYxbPldu/fLCz6k2A dSIoswfhUFPKJ6tfpBEm44rtWZNjlai1hfv0rZ+1S1uW5nylDcSrFlEG+m7q6qjqYW qWjsrN9xv/7HyoI3GkZ9hJRSfUBOnoHD1/uX0NU7qNQN9/QEPo3CcGBLJU0U34vxVZ PD9eEBrl2Jv8SgkQkLyygMPQR/OuVRT0fbSmAsLHGhujMp76e5pn22VSBr5f/4z80a 61xWQHXr316ZJbGUsimwOTRv8uBncW0oBm8WNPXQTCGaziLLlmxWJei0UxNf1JsjTU 6I9V8pyTcSARA== MIME-Version: 1.0 Date: Thu, 14 Dec 2023 10:42:01 +0500 From: Nikita Travkin To: George Stark Cc: andy.shevchenko@gmail.com, pavel@ucw.cz, lee@kernel.org, vadimp@nvidia.com, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, hdegoede@redhat.com, mazziesaccount@gmail.com, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, nikitos.tr@gmail.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kernel@salutedevices.com Subject: Re: [PATCH v3 04/11] leds: aw2013: use devm API to cleanup module's resources In-Reply-To: <20231213223020.2713164-5-gnstark@salutedevices.com> References: <20231213223020.2713164-1-gnstark@salutedevices.com> <20231213223020.2713164-5-gnstark@salutedevices.com> Message-ID: X-Sender: nikita@trvn.ru Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 21:42:30 -0800 (PST) George Stark писал(а) 14.12.2023 03:30: > 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(). > > Signed-off-by: George Stark Thanks for noticing and fixing this! Perhaps this patch needs a Fixes tag too, like 1/11? Tested-by: Nikita Travkin Btw, seems like (5..11)/11 never arrived to the lists... Nikita > --- > drivers/leds/leds-aw2013.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c > index c2bc0782c0cd..863aeb02f278 100644 > --- a/drivers/leds/leds-aw2013.c > +++ b/drivers/leds/leds-aw2013.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0+ > // Driver for Awinic AW2013 3-channel LED driver > > +#include > #include > #include > #include > @@ -318,6 +319,11 @@ static int aw2013_probe_dt(struct aw2013 *chip) > return 0; > } > > +static void aw2013_chip_disable_action(void *data) > +{ > + aw2013_chip_disable(data); > +} > + > static const struct regmap_config aw2013_regmap_config = { > .reg_bits = 8, > .val_bits = 8, > @@ -334,7 +340,10 @@ static int aw2013_probe(struct i2c_client *client) > if (!chip) > return -ENOMEM; > > - mutex_init(&chip->mutex); > + ret = devm_mutex_init(&client->dev, &chip->mutex); > + if (ret) > + return ret; > + > mutex_lock(&chip->mutex); > > chip->client = client; > @@ -378,6 +387,10 @@ static int aw2013_probe(struct i2c_client *client) > goto error_reg; > } > > + ret = devm_add_action(&client->dev, aw2013_chip_disable_action, chip); > + if (ret) > + goto error_reg; > + > ret = aw2013_probe_dt(chip); > if (ret < 0) > goto error_reg; > @@ -398,19 +411,9 @@ static int aw2013_probe(struct i2c_client *client) > > error: > mutex_unlock(&chip->mutex); > - mutex_destroy(&chip->mutex); > return ret; > } > > -static void aw2013_remove(struct i2c_client *client) > -{ > - struct aw2013 *chip = i2c_get_clientdata(client); > - > - aw2013_chip_disable(chip); > - > - mutex_destroy(&chip->mutex); > -} > - > static const struct of_device_id aw2013_match_table[] = { > { .compatible = "awinic,aw2013", }, > { /* sentinel */ }, > @@ -424,7 +427,6 @@ static struct i2c_driver aw2013_driver = { > .of_match_table = of_match_ptr(aw2013_match_table), > }, > .probe = aw2013_probe, > - .remove = aw2013_remove, > }; > > module_i2c_driver(aw2013_driver);