Received: by 2002:ab2:7988:0:b0:1f4:b336:87c4 with SMTP id g8csp92384lqj; Thu, 11 Apr 2024 10:40:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlTx4saRqTPwZEBsQBUkcWCDmpqEeFzsZVPoa45p7+TIqmAgEqiZQ+ZQp3UfmdCVJw86NTFcOYGipJs+RMY+nq4u4+Io+KxSivuA0JLg== X-Google-Smtp-Source: AGHT+IEBjAm05YZ7cSX2JOVlmbaO8/2UPLRq3NlaLMhwbz6H3QrlItoi8OxlMttOekJLb4fDj/h+ X-Received: by 2002:a05:6a00:3a15:b0:6e8:f57d:f1ec with SMTP id fj21-20020a056a003a1500b006e8f57df1ecmr412278pfb.17.1712857249106; Thu, 11 Apr 2024 10:40:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712857248; cv=pass; d=google.com; s=arc-20160816; b=p5mofnlC3C4gCCbYsoJO9qps+u4i2yjr8LaaWzumzNEIw88aB9narFYON+tVKZV9O6 9BipJAlf8R6zZasyuMRJC+0/XxMKfw1gvBJV2AnZVG6XCYAx7Q4pMU50Ki6HRc9IPx1T FauIhecSBJTKqp0zmuAaDGpl4OE4Fvqak0e4EQkbjvLdFO29LK39rH0o5RMCmG39fg8c 6A2WGputNxNQ0zuKd2fjRppiwWBA7R2eVeQ7Mmwom85nqBQ7JJv4FU1j7Nxt53rFzZi2 dXhYhsrufekqjwjmdP2lEKqyI4impYfPx0deM0dCVAWZhR+BJQTVeiWif/XSbUWUPp9D KWLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=kUQZvb5TQE+27CS7ipmNtMTScgT6hB7NkwHTRSUgx7w=; fh=9sVthC6q9PuvRjSj9stlrgRT7lDZZs1srs1YomjZFss=; b=UUGvYCv/OgGW4qdLJhDhBB+1lt7qT5qaYdzLqhtyYMMrScz3+TnTWCeUslgHcCGIjv u8PsqIKIdBEXNfktzNIEbp2twi/ysELBYKy2NNCEAg8vcxOjPO1WEIBmTYGwXGR1IN+p kIoDNGzhiEkjj9lAiSn8G0vxCHhjXfvxYc5gBKO+WmDQF5mOjLOUfjHYDiuWV2vNjMPF oX8RH6CfBRVTKmkKIXj6UoR8nHQNfcC+bX5w4qSUyzjVRs9YwFTwY9pYtmRuTEux5/xL GcKQLL4nnGH4xzqpW/W9KFiKh9AC9aaMwzdFLWr5/NUPWPRjVouQIe8y2GXorfTFucoL k48Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=AD+fX3ha; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-141290-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bs187-20020a6328c4000000b005f4083340f8si1583010pgb.704.2024.04.11.10.40.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 10:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141290-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=AD+fX3ha; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-141290-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A72942855F9 for ; Thu, 11 Apr 2024 17:40:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14951159907; Thu, 11 Apr 2024 16:10:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="AD+fX3ha" Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF7E4153561; Thu, 11 Apr 2024 16:10:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.89.224.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712851847; cv=none; b=aNHJ678kExYT/FJ60zdknPpfd62+UhnycOXh8Gf6Z8wfP/uF6ydn4f5YEB8YCpn21+gAAfa+1dHZCnEQScG9KF7QdnWRc2fx5FZMZBHXe2SxU1ktjOopa1j0rhBt51KzZi0tCeotqs+5kd9fBH7c+CIg30aWhUepBCGrIxxwlfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712851847; c=relaxed/simple; bh=km5tfIIVGKNwKDNZhdPYWzBEl6TL/6iXUWcTA0Hj06k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EGfeSOxS9FDmIoaf0dFMahcW4mgdLuU33SZBvoNPbce3eiinrPk2YqCNp//AkgBlmXRYVFXVzFCyrBUjhpsz8u7mEvcNOCnNlFOm6UaIj8gI1b3caYneeyxNmNWOwVMjTjPsdhakcG1+grMMuizargFcfm37jkB70NIFHhIhYjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=AD+fX3ha; arc=none smtp.client-ip=45.89.224.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 48389120065; Thu, 11 Apr 2024 19:10:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 48389120065 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1712851840; bh=kUQZvb5TQE+27CS7ipmNtMTScgT6hB7NkwHTRSUgx7w=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=AD+fX3haf7F3WNQBbLGxP1iw8WAcKHF39XraYjM14TI6LI+9fEJOo/lwaabVKVJAb T9LztFt+iJe3BUhSedAnJYzKBtqdE+Zo01u8GSTdAxB5vYtQlhwia7PQNa2Wnc2Fkc 4oPIya4fs4Mpq5udvnj1P5cKUp7LCdKHro+a66qkyUd2kZqLMv2uvCPv97J865Kkit k4sy1cSxB+QUcFd7TeXmttsvmaLEu3s3GIKGTLLXWC78gTU6JORNoLHchHAjD9cDb9 QuvHVtHLO/sLGl45uSw0n2FAxfVCLa6aeEfwKTX3bD9Wjij65c4a6vf6kvVY57X205 lbm3KDtrzvY+Q== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 11 Apr 2024 19:10:40 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 11 Apr 2024 19:10:39 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , George Stark , Nikita Travkin Subject: [PATCH v8 2/8] leds: aw2013: use devm API to cleanup module's resources Date: Thu, 11 Apr 2024 19:10:26 +0300 Message-ID: <20240411161032.609544-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240411161032.609544-1-gnstark@salutedevices.com> References: <20240411161032.609544-1-gnstark@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184677 [Apr 11 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 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: 16 0.3.16 6e64c33514fcbd07e515710c86ba61de7f56194e, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;salutedevices.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.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: 2024/04/11 15:00:00 #24747318 X-KSMG-AntiVirus-Status: Clean, skipped 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 Reviewed-by: Andy Shevchenko Tested-by: Nikita Travkin --- drivers/leds/leds-aw2013.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 17235a5e576a..6475eadcb0df 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -320,6 +320,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, @@ -336,7 +341,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; @@ -384,6 +392,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; @@ -406,19 +418,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 */ }, @@ -432,7 +434,6 @@ static struct i2c_driver aw2013_driver = { .of_match_table = aw2013_match_table, }, .probe = aw2013_probe, - .remove = aw2013_remove, }; module_i2c_driver(aw2013_driver); -- 2.25.1