From patchwork Thu Dec 14 08:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396550dys; Thu, 14 Dec 2023 00:30:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk/NRKJ8ShAXkjCgNseCFo6qTA/bQc3Oh5P5OkP1FSffRXmOj2e4+RqmmiOk9+L942gSyU X-Received: by 2002:a17:902:780f:b0:1cf:747e:89c6 with SMTP id p15-20020a170902780f00b001cf747e89c6mr4185737pll.26.1702542656375; Thu, 14 Dec 2023 00:30:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542656; cv=none; d=google.com; s=arc-20160816; b=eWgLazPx9bVOChZx4gqqB58yMTsi/TIZH9e1GhPn7Q4DRh1mcqCKOodxxbeLzjxEDC knGCCSvS6vvY5RPUfQOLawCIreadSfMSthMUVFnoXa4WKavPwVLH1iN0ls3+qm4YXOD6 m2KnUVUocL9YguzqMO4nl9pLqVtNvbJSCtcwm+Akfb3judMixiZOJMtRG8S7xcVysAp8 jJgycrSEGFN2itC9vxH7iieYYEZCoAE/tArsbIfsEPva5i+SmUe0aCKnroAjkb3Ain7b r+eB+51h+uJNPe69VwPSsHgg/M/1D33MsrQcXN92b742+uZxPvIOeNEX4u8+OMq9PbVv k59Q== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=2AuAiO3OInmf7JfFcpOZ0isTbjfNOkeR9WOJsIXMUT4=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=diexigxBIf9Y6SFl1yDKvhP2Fzxrw5nEpi1TED6jaoa3qCpzLQzaSZNHhBWDfBGbE1 E5ZIpkKGejxegIYTszzNhiQI0uo3+ygWPojY6rDMrublWsY4y5CgrU4rXXBL1f4amySv wta0VxzMwOQyzJ0UmPgv4ao+gDR4/kBoFhPLAp6rzAexvIITbANXCQPeJyUyqLgDhdZ4 fY/bR9tZaGDVPOZQsYK/EnELtXCs43M0d/NCCX9unXasaLORXxE7LV2BcA7P4sV67Y4h kBF5x8Cj6Erd53GPLUcPoeC+l1pVG3cBHx5LFWT+4g52Xd3OuenrIeprS+slQCiOATn1 YFCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ljq/CCEV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j9-20020a17090276c900b001cfc4d8eddfsi10843027plt.602.2023.12.14.00.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:30:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="ljq/CCEV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id D46E4803BE91; Thu, 14 Dec 2023 00:30:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235605AbjLNIaE (ORCPT + 99 others); Thu, 14 Dec 2023 03:30:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234397AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F220109; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 87FC112004A; Thu, 14 Dec 2023 11:29:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 87FC112004A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542588; bh=2AuAiO3OInmf7JfFcpOZ0isTbjfNOkeR9WOJsIXMUT4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ljq/CCEVuNjhV7bgoZQGMQ4PMbvPTMeiSJYgJC/dm9Wk9QLHXlyBd7qvuhHbiFrQd DLs44yN9pBRG4VXDmfHNZ+SABRlchRc4Wto1XhbjvM1wbH+1f+A1xecDErATgNsH8Q eqS1061mPOhwf2RkfW7bPWv5i1ldIJwErrihHvTwSkyG1/uWnq+uzJ6TSmytAKmusv nVYlGC2ZXBglFXIRg/u/6Yzx3SRO3ezkbF3oHuUWGlMmmsKmufdg/YYAh6mNGzG6vD hGjw1DIRWHV7XnO33DR3wFZk0O9ei8sQxJWLXXkYEGHAHSNXPav2nhEqtRsQtL8DXq cu2I7XT5KhQ+g== Received: from smtp.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; Thu, 14 Dec 2023 11:29:48 +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; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 05/11] leds: aw200xx: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 11:29:34 +0300 Message-ID: <20231214082940.2718303-1-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2, 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/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245368545651692 X-GMAIL-MSGID: 1785245368545651692 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 --- drivers/leds/leds-aw200xx.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-aw200xx.c b/drivers/leds/leds-aw200xx.c index 1d3943f86f7f..eed1e65c1c0e 100644 --- a/drivers/leds/leds-aw200xx.c +++ b/drivers/leds/leds-aw200xx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -530,6 +531,16 @@ static const struct regmap_config aw200xx_regmap_config = { .disable_locking = true, }; +static void aw200xx_chip_reset_action(void *data) +{ + aw200xx_chip_reset(data); +} + +static void aw200xx_disable_action(void *data) +{ + aw200xx_disable(data); +} + static int aw200xx_probe(struct i2c_client *client) { const struct aw200xx_chipdef *cdef; @@ -568,11 +579,17 @@ static int aw200xx_probe(struct i2c_client *client) aw200xx_enable(chip); + ret = devm_add_action(&client->dev, aw200xx_disable_action, chip); + if (ret) + return ret; + ret = aw200xx_chip_check(chip); if (ret) return ret; - mutex_init(&chip->mutex); + ret = devm_mutex_init(&client->dev, &chip->mutex); + if (ret) + return ret; /* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */ mutex_lock(&chip->mutex); @@ -581,6 +598,10 @@ static int aw200xx_probe(struct i2c_client *client) if (ret) goto out_unlock; + ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip); + if (ret) + goto out_unlock; + ret = aw200xx_probe_fw(&client->dev, chip); if (ret) goto out_unlock; @@ -595,15 +616,6 @@ static int aw200xx_probe(struct i2c_client *client) return ret; } -static void aw200xx_remove(struct i2c_client *client) -{ - struct aw200xx *chip = i2c_get_clientdata(client); - - aw200xx_chip_reset(chip); - aw200xx_disable(chip); - mutex_destroy(&chip->mutex); -} - static const struct aw200xx_chipdef aw20036_cdef = { .channels = 36, .display_size_rows_max = 3, @@ -652,7 +664,6 @@ static struct i2c_driver aw200xx_driver = { .of_match_table = aw200xx_match_table, }, .probe_new = aw200xx_probe, - .remove = aw200xx_remove, .id_table = aw200xx_id, }; module_i2c_driver(aw200xx_driver); From patchwork Thu Dec 14 08:29:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396366dys; Thu, 14 Dec 2023 00:30:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG87xBkTAyDyiOuzc/bfeWxCuw/Wft6GSPmZBgyPdighlmgz8TaKDTGtpePjUd9IOj2XHd8 X-Received: by 2002:a05:6a21:120a:b0:18f:9c4:d344 with SMTP id oe10-20020a056a21120a00b0018f09c4d344mr10179361pzb.52.1702542635086; Thu, 14 Dec 2023 00:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542635; cv=none; d=google.com; s=arc-20160816; b=VyEk9uNNvoLqayGGRDezWzlIH6YFO2E2RaRjUnFR3VOHKOga1wgmcMAvzTwTCDhGZE fw2yZZtmjeSHkmD0YKV02BQ69/gN95cStON2gBLYNYQc0ZuWKUAJZAb4JwbP4jts/4W/ +1RlxEGxbpiRMNc0IzBDE7Px3y6csY0dMDh6aiZTWgZGs+l8ntRQOpmFO1XS0XRERQ2o 36ZdPY7Phibb9KDGe8IgnEb6Nx56robpOOddU1t6cKe+LAxCSuSd5aJb1pZuSPNp4Dd3 4THm097vpfXoj1VCR5ahyrfOaN5AYIhdDsDerUauaQJpZQNl6OpCFUO2gAo+qix3f+Dp jJXw== 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=E+93qW99+MbE6qv9QYbuPHDD4qbYVZKtaw4xnbuw8OI=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=Sz0nPt4Hb3355X/ndKHbi5q9bks0G9Fx/xW+CqGkQVgK+/vYpMBg1Gb1JeMqW2pDK3 DfzwOjS9jn/lRlo8kwLdC/4XMyQvVAITSuOXUirNH86AJtj6lnfXhd1ni593ihBgFyET en+ChC1XgfNziL2/uVa4iUIlDkFNoY7/vS71244L/Rc/RKZAou/Im0kqOs9SWwLbdRAr Nk6FTYr3m9W5SaOMeeCrAIJHfGDQveofdyFCTTKH424fojTi+uKUmedxEvd8lt3FiU5H uXVtHsXQfIHLZlhzAJ7Wojl/J8qQeg+cuRdXVq1kIJI47lTGEz4hzOwWjGp4OqD7OOlP C88Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="Bhs/9SCd"; 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=salutedevices.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q5-20020a655245000000b005bd3ca6c394si11133265pgp.43.2023.12.14.00.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:30:35 -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=@salutedevices.com header.s=mail header.b="Bhs/9SCd"; 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=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 196EE82EC558; Thu, 14 Dec 2023 00:30:28 -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 S234472AbjLNI3v (ORCPT + 99 others); Thu, 14 Dec 2023 03:29:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E89C106; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id BB789100057; Thu, 14 Dec 2023 11:29:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru BB789100057 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542588; bh=E+93qW99+MbE6qv9QYbuPHDD4qbYVZKtaw4xnbuw8OI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Bhs/9SCdZOPnb6ZrePaoj9pFpw9ksXOTSMXxCqjx+eAhIoHoyRIFQcc/TWfXggTV6 HGUzGj5cPOghTjwfo42EkRqu+Nj/toNqIkXEmuEOmorEdVpa7Sc+UNiEdSOiLuzT5l 2KWnPubXjT5V8pcBNrSdV6YlXcIKDNcJutq/4csr7SyQmGF+i12kj1prXnZ3dGhLKh /8ZP29DerkVi0mb7N6mNrp3J2wGWRaqwxhZ8WFfqISIQH4c/sEGSgpzEvCExf53GUW Q87kpMNCk42a3gwoo22fOibcgLEFHm0XMOSl2jrFohxVpWVOHNbahKhtHmegcQiw1w nWw+vUJa2GJiA== Received: from smtp.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; Thu, 14 Dec 2023 11:29:48 +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; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 06/11] leds: lp3952: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 11:29:35 +0300 Message-ID: <20231214082940.2718303-2-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;127.0.0.199:7.1.2;smtp.sberdevices.ru:5.0.1,7.1.1;100.64.160.123: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: 2023/12/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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]); Thu, 14 Dec 2023 00:30:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245346406845250 X-GMAIL-MSGID: 1785245346406845250 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, }; From patchwork Thu Dec 14 08:29:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396619dys; Thu, 14 Dec 2023 00:31:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFx0oJgij+wQ4/sMvFazLk4ef2UBH342OYpAZrG2UVoiZbUQLAhZdTG+yQb7mvJgTrOFac9 X-Received: by 2002:a17:903:2b10:b0:1d1:e0b6:1ac8 with SMTP id mc16-20020a1709032b1000b001d1e0b61ac8mr6244905plb.57.1702542664045; Thu, 14 Dec 2023 00:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542664; cv=none; d=google.com; s=arc-20160816; b=u46C5G222FPEDsLkTR/v6hf88YOI6LQy+4bY7R5tbe26egYxcaslD7Rxy10Fu8ChS4 hbqB2F9UrM1WtyRQLtFfeRwYDITu6c7odP9caCb0ERoqDU2rygz9pNfMfN96xNfMCs3S ATu4RCqZ1T1RtXdB8xF/pSHGkYRBpdxrPNRhNwuMjv3ivmguM/4KehuSiT/E8fr147yX 98ZXgGf174UgiYgB/tKxFrZNtcYjHQ/PmTPOR8iyEBkp7cOZQsXCzBzLEeJjaNgsEB4s X6fOKC3aM2B0ZYojQlhTYzVSVLC/xDjSsT09INuqvK19aogfNWwipQAt2Tajf3UVYbgF WDpg== 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=EC3dQnKKfurosn6pqq8G2JOlIq4yy+2qbil19wlXj5E=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=roxBC/6YqUMGPf52Dqan7+XRIl3RnV4zKQx8bsPVRSeIRWi87ovaEi3tMlVq3lcd7O P2ic9pMdf5mFd+nIaHclV8aoVSgS9enGJvey7V2vEZi66/j32Uyxb6RhYreGAK8Kt4mk ZsJS0CNfqLyU64WA//Rzr0YHf9o1zPJ1aVCFoJAc2RWvq9rAd5IME4S6nLXa7v/BwhD9 OZNcubEjLlx/js2UJ0AaKLIwHLlbyZTtEnqI7ydGJpJQ3ej4Bs5Z2ONgYQ3ynmE/z2bz dhzWsk1cnAJgxzfetwp/aZtFZO9BKCHJA0HHzvOrh5zNPoBq9JjnO9QBHjdihrp8kGAr h1sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=gdVw80ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f1-20020a170902860100b001d337b8c098si4158318plo.597.2023.12.14.00.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:31:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=gdVw80ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 457CC8093426; Thu, 14 Dec 2023 00:30:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235576AbjLNIaA (ORCPT + 99 others); Thu, 14 Dec 2023 03:30:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234438AbjLNI3u (ORCPT ); Thu, 14 Dec 2023 03:29:50 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F72210A; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 0956112004B; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 0956112004B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=EC3dQnKKfurosn6pqq8G2JOlIq4yy+2qbil19wlXj5E=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=gdVw80aeGthMYYbOU9ufGil3wyDr3Am5CBNr+L1WeNhbQiTu9WyJPN+MlgK5YuEXQ FGUBbAXfpLOyOZVRuLrZuyJ2pC7QwMviKjnGFkH28SXl2mJ6aQnkB6zzP3q+BXIuyd rAc65Ingyh9oMYyueKW65J1+0T25qfZaWzz5SaJmDWHXLCQ5LAa39GMObuChgbnO/u tpir/fqILMgF1Y+wl9gpzLbEOa7iNrLllwMEu/SRasvOvaVmv02Kb+Qshqj1PI3Opg ibrBPH7l/09HyrypNAUxtDX9aCaahDKkgQM6cyXuC1sc1hPy7qqIqSz4XuWf5vKQcV yKGjXWmbbwF8g== Received: from smtp.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; Thu, 14 Dec 2023 11:29:48 +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; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 07/11] leds: lm3532: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 11:29:36 +0300 Message-ID: <20231214082940.2718303-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, www.ti.com:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;127.0.0.199:7.1.2;salutedevices.com:7.1.1;100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2023/12/14 08:01:00 X-KSMG-LinksScanning: Clean, bases: 2023/12/14 08:01:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245376444347072 X-GMAIL-MSGID: 1785245376444347072 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 --- drivers/leds/leds-lm3532.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 13662a4aa1f2..713900947e35 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -3,6 +3,7 @@ // Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/ // https://www.ti.com/lit/ds/symlink/lm3532.pdf +#include #include #include #include @@ -542,6 +543,13 @@ static int lm3532_parse_als(struct lm3532_data *priv) return ret; } +static void gpio_set_low_action(void *data) +{ + struct lm3532_data *priv = (struct lm3532_data *)data; + + gpiod_direction_output(priv->enable_gpio, 0); +} + static int lm3532_parse_node(struct lm3532_data *priv) { struct fwnode_handle *child = NULL; @@ -556,6 +564,12 @@ static int lm3532_parse_node(struct lm3532_data *priv) if (IS_ERR(priv->enable_gpio)) priv->enable_gpio = NULL; + if (priv->enable_gpio) { + ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv); + if (ret) + return ret; + } + priv->regulator = devm_regulator_get(&priv->client->dev, "vin"); if (IS_ERR(priv->regulator)) priv->regulator = NULL; @@ -691,7 +705,10 @@ static int lm3532_probe(struct i2c_client *client) return ret; } - mutex_init(&drvdata->lock); + ret = devm_mutex_init(&client->dev, &drvdata->lock); + if (ret) + return ret; + i2c_set_clientdata(client, drvdata); ret = lm3532_parse_node(drvdata); @@ -703,16 +720,6 @@ static int lm3532_probe(struct i2c_client *client) return ret; } -static void lm3532_remove(struct i2c_client *client) -{ - struct lm3532_data *drvdata = i2c_get_clientdata(client); - - mutex_destroy(&drvdata->lock); - - if (drvdata->enable_gpio) - gpiod_direction_output(drvdata->enable_gpio, 0); -} - static const struct of_device_id of_lm3532_leds_match[] = { { .compatible = "ti,lm3532", }, {}, @@ -727,7 +734,6 @@ MODULE_DEVICE_TABLE(i2c, lm3532_id); static struct i2c_driver lm3532_i2c_driver = { .probe = lm3532_probe, - .remove = lm3532_remove, .id_table = lm3532_id, .driver = { .name = LM3532_NAME, From patchwork Thu Dec 14 08:29:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396597dys; Thu, 14 Dec 2023 00:31:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGM1xlpIjII+6yodHnN315QGepR8IlFKT0VFiEgWiwDnMlVPy75xWZc302J0SaZPBLtjGAH X-Received: by 2002:a05:6870:c093:b0:1fb:75a:6d23 with SMTP id c19-20020a056870c09300b001fb075a6d23mr10841083oad.74.1702542659924; Thu, 14 Dec 2023 00:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542659; cv=none; d=google.com; s=arc-20160816; b=Mkk7SCpJu6yjOciXqGwGDdNeL6rNrdvJsCW+ZrFDTJtSCwneSHCkRywzYDldv2Q90x Fjl5gblgBKolKue3BN7gvwF37gUuukTx/fKfgeMv1a8MRMTwCYrilcCT39i3zT9cjJsC u6+uLelMfkAN8UIobUGVkyjmXc5AJSDdshChlTUwo4IGaVlDSWFlsqp/OtLTwSyVrf/f jfhKCiQM6AL9ie+jzqB6Mb0PmAllH3V7+++gs3UmCW0Nssuj62Yv4nTvJynhEbOLnB9M seBqu4HmJhkQdjUL+F1A9cobrWXQDCMmScHfq2jSgmBgomJAmREvsf/NnUWUr2JpnYT/ IkQQ== 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=k3WMJ0GNwuGRczuP2LxdxutooPucV6JPLeqyGQDEPIA=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=SY0yF2JaPVJwXji7MJgGI0raSvtk98J6D/XQu3kTmZxJ7eSQMWkqiAFKdWCYPBs7HB qoSZSwWwVybzmIkyTjtr2neRBIjr3AyNd0Sdj/x+Z63QAI9auGibhkBxyOtNbzwvAa3+ DthRsyBn6vD0Nqj78/pchlIrrbBWx6i8DWoWuHSQAaJ8tCWNoLrHBegE6EVK6HlBuS1A AZBSyojP2Nt2QG4jWDvCRyv+7dDvgTcjW6liHClJe7yL8J6AHbQGw9PkLxO6Qid3JSp1 DKTrT+zsog6WigOwKI6YZWQyQLrP05556y7L14jncsudlkKhWKoB35H2wxT3Q7uSunfN 6SsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=of1Tn4MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q5-20020a655245000000b005bd3ca6c394si11133784pgp.43.2023.12.14.00.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=of1Tn4MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 1F5AC808A427; Thu, 14 Dec 2023 00:30:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbjLNIaH (ORCPT + 99 others); Thu, 14 Dec 2023 03:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234383AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E3E0BD; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 3922312004C; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 3922312004C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=k3WMJ0GNwuGRczuP2LxdxutooPucV6JPLeqyGQDEPIA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=of1Tn4MRm5JWSFtRnnpDpM398sl1bI3loVSFhziq0an1Mqfcp58dJ8NWZ3hV9x8TG ttbTHk6KPFMrlpdvRaSJGr9Esy179EGMKnpANrgkKDqn57Cpt0YSowxKnapmgy3qFN 5kXd5YF12alRwLC8xE7auXPFz1I+uEEsqt8x3Tk/pRevSHfhVr8EJyoMeeZIKwpd0D R7+EuFWggZUxYrUC1GszOPHbdCq53M5alfHXiyKCu9Rag/osUYHalxhY5nVIk5AhPb CShMmbVYiUzNkB4NNyVu9/i2tkoG8VeCzsvshqWp9bmL0Aj2Up13qUEhHGYTDmouAg PzrmOJzcC6yCQ== Received: from smtp.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; Thu, 14 Dec 2023 11:29:49 +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; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 08/11] leds: nic78bx: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 11:29:37 +0300 Message-ID: <20231214082940.2718303-4-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2, 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/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245372201756300 X-GMAIL-MSGID: 1785245372201756300 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 --- drivers/leds/leds-nic78bx.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-nic78bx.c b/drivers/leds/leds-nic78bx.c index f196f52eec1e..f3049fa14f04 100644 --- a/drivers/leds/leds-nic78bx.c +++ b/drivers/leds/leds-nic78bx.c @@ -118,6 +118,15 @@ static struct nic78bx_led nic78bx_leds[] = { } }; +static void lock_led_reg_action(void *data) +{ + struct nic78bx_led_data *led_data = (struct nic78bx_led_data *)data; + + /* Lock LED register */ + outb(NIC78BX_LOCK_VALUE, + led_data->io_base + NIC78BX_LOCK_REG_OFFSET); +} + static int nic78bx_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -152,6 +161,10 @@ static int nic78bx_probe(struct platform_device *pdev) led_data->io_base = io_rc->start; spin_lock_init(&led_data->lock); + ret = devm_add_action(dev, lock_led_reg_action, led_data); + if (ret) + return ret; + for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++) { nic78bx_leds[i].data = led_data; @@ -167,17 +180,6 @@ static int nic78bx_probe(struct platform_device *pdev) return ret; } -static int nic78bx_remove(struct platform_device *pdev) -{ - struct nic78bx_led_data *led_data = platform_get_drvdata(pdev); - - /* Lock LED register */ - outb(NIC78BX_LOCK_VALUE, - led_data->io_base + NIC78BX_LOCK_REG_OFFSET); - - return 0; -} - static const struct acpi_device_id led_device_ids[] = { {"NIC78B3", 0}, {"", 0}, @@ -186,7 +188,6 @@ MODULE_DEVICE_TABLE(acpi, led_device_ids); static struct platform_driver led_driver = { .probe = nic78bx_probe, - .remove = nic78bx_remove, .driver = { .name = KBUILD_MODNAME, .acpi_match_table = ACPI_PTR(led_device_ids), From patchwork Thu Dec 14 08:29:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396412dys; Thu, 14 Dec 2023 00:30:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFetIoTnj9azWV9GMclAMz1VeWZTkBYpMQY0BTjI6pTNsRNNCEdZtvdWYUDv5H/k0eq1plG X-Received: by 2002:a05:6808:1818:b0:3b2:e520:dfab with SMTP id bh24-20020a056808181800b003b2e520dfabmr11737307oib.44.1702542640984; Thu, 14 Dec 2023 00:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542640; cv=none; d=google.com; s=arc-20160816; b=sNsOlXvw1dVrBSDWaXKim7aKDIsAMwJH7rIRoUZCh7Y+zMBonle4bqbxw7aP9cly4o WrXejyQfXSDV62I6cu2hQo3ehtLJ/7X8mbXEye2HxYAp++heMjfFSKHJN1GaC5tJp/qI qO1/I5Q2XkIdRFkRUXcebCWZthEJCNzrbwJ+hLcWu7+9j/oyvxXRG1OAfSF6RUsTEL06 phkFfc6WgezH+Y2kK7qCicPBzfARCaS3owiegVNeMf51F3zbTebWNXSpcvu3XTyj1ehe e5BTMrCcvFcOdTbpbOH7cnV5VWZpjTWONinsA7GM6J5GVKHKjxyb9097gQyomiQEeYRC tDlQ== 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=nTXR4WBFZR+kxSlC13nocgtwFZu8ItCajWxM9cqi5i0=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=vBuyTJgkaToALKpDYo9LuEGtw2fBifEVAwf3KEf07K1p35R1fkIT9OlFNYd6ItJi9L 4Hc1oj+CKyC7ER7/2rM7oMrrR1IObjp5eXFX3HKpRBtx+ww92WuojVFuC8MzFhsRXCEG p5G2vdIuT89lDMTDaTyatl+3Yu28YqONRV8FViQVeUJKdDh3yX7O7sauAtCE8NHU8GC3 SXbnhYquOnvP4keQ0hAJzDlEp12luPBVxpleAox03Nt982MPHIYVtu5IFzeCzAta6Wn8 ven5kH0SrpqoYgP6epAlbZCTFA92UyTbD4ZfAK1ryNG+ompqsFrZ8mn9ofCfzNXwpPtM 0dRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=gz0oo78M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id it24-20020a056a00459800b006ce707e00d3si10935057pfb.241.2023.12.14.00.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:30:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=gz0oo78M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 0F5D180792C4; Thu, 14 Dec 2023 00:30:21 -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 S229731AbjLNIaL (ORCPT + 99 others); Thu, 14 Dec 2023 03:30:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234396AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6001310C; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 6F005100058; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 6F005100058 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=nTXR4WBFZR+kxSlC13nocgtwFZu8ItCajWxM9cqi5i0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=gz0oo78MnPVya0XjJUuUYRfcxmotx57qbGoHTE+FqCwNj5xNRNyxjmZFZH/zqAe/7 How0VxbyJPWxBPE0IBX+MfWueNLfarF2DO3mBrHx1BlItuKJfGk3XR4h85Hm+jeVFe 83vTskqz3P2WhITedrqzNBF7kx5P91ys/vn54GyVlCSz8oocBP8ELy6MggMvJjsF3l yykQwWh2IAQNs0YWqfAi0ehNTEC2eQnO620a5/+cr19/PfjOVXRSzMQRLwh577PhfK VQT5p4jnl9LoMfkC27yy3MQ5H45hqL+Hu0fB5eLh+mAtWhuZ4AM1DWDZnXmqePyegc er+A0UiJtmitA== Received: from smtp.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; Thu, 14 Dec 2023 11:29:49 +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; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 09/11] leds: mlxreg: use devm_mutex_init for mutex initializtion Date: Thu, 14 Dec 2023 11:29:38 +0300 Message-ID: <20231214082940.2718303-5-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;127.0.0.199:7.1.2;smtp.sberdevices.ru:5.0.1,7.1.1;100.64.160.123: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: 2023/12/14 06:13:00 #22683038 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]); Thu, 14 Dec 2023 00:30:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245352240331463 X-GMAIL-MSGID: 1785245352240331463 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 mutex which was destroyed already in module's remove() so use devm API instead. Signed-off-by: George Stark --- drivers/leds/leds-mlxreg.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c index b7855c93bd72..64a78eff05c7 100644 --- a/drivers/leds/leds-mlxreg.c +++ b/drivers/leds/leds-mlxreg.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -258,6 +259,7 @@ static int mlxreg_led_probe(struct platform_device *pdev) { struct mlxreg_core_platform_data *led_pdata; struct mlxreg_led_priv_data *priv; + int err; led_pdata = dev_get_platdata(&pdev->dev); if (!led_pdata) { @@ -269,28 +271,21 @@ static int mlxreg_led_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - mutex_init(&priv->access_lock); + err = devm_mutex_init(&pdev->dev, &priv->access_lock); + if (err) + return err; + priv->pdev = pdev; priv->pdata = led_pdata; return mlxreg_led_config(priv); } -static int mlxreg_led_remove(struct platform_device *pdev) -{ - struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev); - - mutex_destroy(&priv->access_lock); - - return 0; -} - static struct platform_driver mlxreg_led_driver = { .driver = { .name = "leds-mlxreg", }, .probe = mlxreg_led_probe, - .remove = mlxreg_led_remove, }; module_platform_driver(mlxreg_led_driver); From patchwork Thu Dec 14 08:29:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178571 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396664dys; Thu, 14 Dec 2023 00:31:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0rk9/WX+QEexnK+44/5MZXFMZzLDnXEEpvIZKf3Pq+Sg36QiO7m5PbuwvkF8gV4jfQwlc X-Received: by 2002:a05:6a20:7f94:b0:191:2dc7:573b with SMTP id d20-20020a056a207f9400b001912dc7573bmr4544947pzj.43.1702542669006; Thu, 14 Dec 2023 00:31:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542668; cv=none; d=google.com; s=arc-20160816; b=aUiGzmWskpgm56MwibWfvyEbbecaHRwOLNT3E7p1YFN0dK8eNJzjaLxSOH3IGqJpPl R6Wai4uCJRJNB+IQg0o5P2Yl2oC+3mJlsH7Z3fW+RtC9e8sTctWWn0Lcjuc9Vnkr9fpm rexYfgboyJSdIEtG8dEBcdpUMQVTVgnnemZikgl0J7pT2xlKJ7TvlU7T/iZOxO9bOB+t 5BThpJPxSMHDtMq8oMMNzPDRRQIuYs594e1odTMY2UarEjeW+/zrKSpLPFf8JIPJkFri ITIIWBhc/mo64Rk5prB9t3cNlmHdlM/HDBXFF2h/SHYN1dithyy1TZzCmNalrKNN4T0T ikxA== 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=xznPFmv1qOhKYzpKJQ6sCA6HIF+5JBU12dpwjRIA9xM=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=YWX8rXC3WX0U/vZNWm4k6wRHrjYCxfmPX5Rq1x5xy7sHSnCiztRq6w57Xnv67hqk/m PWOQmTrH2dvCRpkM/qKhD3qTxNiGxGnuRmNFrhtJIM2H997OBq3aIF+CmcRZOE34LV14 J3/rOOppUEvA5NXPuvOkpG6eyCC/qBBtMaFRz1AllERTip60AbeUM1GrNy6LqeL3vv64 ep0dfFRsblWzo3sQRuIfqHzpq516+pZOEdJdGymUOt29sucoIxNHYKW2A0DcaNWHNN4M u9lPX2UAdDh9IgHeIDA0QOPBef7y12gEiWmILxQeGdZ316rI3XiRPKs5RvH/RQ88TBES 6Z4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=Ba6X46CW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id it6-20020a17090afb0600b0028657eb6c12si3850772pjb.170.2023.12.14.00.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:31:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=Ba6X46CW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id D55268079AE6; Thu, 14 Dec 2023 00:30:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234523AbjLNI3x (ORCPT + 99 others); Thu, 14 Dec 2023 03:29:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234418AbjLNI3u (ORCPT ); Thu, 14 Dec 2023 03:29:50 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F116107; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id AE3BF12004D; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru AE3BF12004D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=xznPFmv1qOhKYzpKJQ6sCA6HIF+5JBU12dpwjRIA9xM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Ba6X46CWNSkRrqod4DLgwOQ09p/7HbUS139el4p3GaCQUlsVX0Twzg9zWVtFmIKjB WiqXYGMY1IbA/E8nuWOqLdNKM0NX7FKqkg8PAJf8corybIVuWU5smDrdWxQHCPy2R+ S9YG2iAZOg8QNLGWApRMUC61PhkhDNoGLDwqSCFwywTvNfVDy0r6iAdAlvp01Vyz1e YXsn4hyZkaae/LM+2wU71c/WwicqDGOcAy51nCrOdQ9RhOiUSYwYGU+fr2GHQkFVkG qX/pYo96RY+kdkZjn9cl5YXkrwdDxgCitIjh/3zFenXRUUCvwsVmDyAg0XPrUrALnR ti+jrhOPH8hLw== Received: from smtp.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; Thu, 14 Dec 2023 11:29:49 +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; Thu, 14 Dec 2023 11:29:49 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 10/11] leds: an30259a: use devm_mutext_init for mutext initialization Date: Thu, 14 Dec 2023 11:29:39 +0300 Message-ID: <20231214082940.2718303-6-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;www.alliedelec.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2023/12/14 08:01:00 X-KSMG-LinksScanning: Clean, bases: 2023/12/14 08:01:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:09 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245381843658962 X-GMAIL-MSGID: 1785245381843658962 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 mutex which was destroyed already in module's remove() so use devm API instead. Signed-off-by: George Stark --- drivers/leds/leds-an30259a.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index 24b1041213c2..8f62c012c81a 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -7,6 +7,7 @@ // Datasheet: // https://www.alliedelec.com/m/d/a9d2b3ee87c2d1a535a41dd747b1c247.pdf +#include #include #include #include @@ -283,7 +284,10 @@ static int an30259a_probe(struct i2c_client *client) if (err < 0) return err; - mutex_init(&chip->mutex); + err = devm_mutex_init(&client->dev, &chip->mutex); + if (err) + return err; + chip->client = client; i2c_set_clientdata(client, chip); @@ -317,17 +321,9 @@ static int an30259a_probe(struct i2c_client *client) return 0; exit: - mutex_destroy(&chip->mutex); return err; } -static void an30259a_remove(struct i2c_client *client) -{ - struct an30259a *chip = i2c_get_clientdata(client); - - mutex_destroy(&chip->mutex); -} - static const struct of_device_id an30259a_match_table[] = { { .compatible = "panasonic,an30259a", }, { /* sentinel */ }, @@ -347,7 +343,6 @@ static struct i2c_driver an30259a_driver = { .of_match_table = of_match_ptr(an30259a_match_table), }, .probe = an30259a_probe, - .remove = an30259a_remove, .id_table = an30259a_id, }; From patchwork Thu Dec 14 08:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8396592dys; Thu, 14 Dec 2023 00:30:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDKmoWZ14kUoLAnx38DYuvM9Aa56VaDKLSOghnwVZNLQ2st/4AI3g9XtVhSd4YBLmYKs2g X-Received: by 2002:a05:6358:711:b0:16e:783a:eb69 with SMTP id e17-20020a056358071100b0016e783aeb69mr7376433rwj.0.1702542659688; Thu, 14 Dec 2023 00:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542659; cv=none; d=google.com; s=arc-20160816; b=BtGJh9Wwe46GMHFIdZWiEI87n5cl2J5MCtdfflrmvOHY/CmNSDq/9c+4jmmUM9yZ2Z LY8W5jd7jUVh68COSHdXEGmVuXFbrATyDcvuoqHGhvZ8j0xKKkWRydt1EWPu51aAZK2e amQ6SrZEPB/tGQqrGEbbx+rPGJQwM5WGpCLW69lzulOPENUWkKqgQcTLKxUUrJw6sZI7 qyYf4rfYTDklaplroQUdre8HM/6DHaaulJ8B0ptr9j7OcCKjAFHuHDBbogfwlbjdK3rZ gwVcT/1bVNXDEMY5V84ODAJs834vhBirvTNWXHba32lmc/SiBDY0pZcX1j85FTjFL0JR DVMw== 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=IipliOBxVO1mB0P9vxh3aTZrhIFdLT6fPsP0SLsHsZA=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=PCuoSX7rpnIaZWav8TAA8SRb6AlTQnvZQSvaytmj3kTG4GZrJUBY4gXnwpH2DreF2+ gVsMAhIwgABvWHYL8Czbnnd1SHbN2Ci/suD3eXss+PN7KCm0ARloqcM5Qjs0Pmgr/HAy gqItMnk3D0aOx0A7NsbyfvJN/f/5BR2QdY6Rh2QPdjF3XnXnQDQn2LtGUK7vc0ypycn3 IGCrQ6Qb4re3okKkJfoCO53TePnnBgMGsLw3ko8aV8ucuuE4zk9hd09mozpmb0wFGKHQ FBqBHGs2t6sEo3Bd+LyGZRy1ed1brqa6xSJCUAMZSf7UCPQeQwvNjmeO3oGjYRjLCH5f HSBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=jqjhhqiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l2-20020a17090aec0200b0028b029b48b1si1128071pjy.70.2023.12.14.00.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=jqjhhqiB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 927BA807E91F; Thu, 14 Dec 2023 00:30:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234564AbjLNI3z (ORCPT + 99 others); Thu, 14 Dec 2023 03:29:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFAD10B; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id DF64012004E; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru DF64012004E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=IipliOBxVO1mB0P9vxh3aTZrhIFdLT6fPsP0SLsHsZA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=jqjhhqiB/+anaFc34B+FJmzHIV8CpFNjoCkCIDLydqBcwljVDX7AlrUWRGw8C9iAk c/hrdk2fWtox+w01FdHzNqiZWln97DcN3LsgkgmRshr8SM+YgZrMdp33yi1aLlOXsl 9z/wSTD7oPG6nFov1jtJE9vcGDjNiybCu/SH1g1g/vSi7355/84FxUmJbJlXvF1sTf pNiL+2zzyDVvhe/e8r26JKgMoot3PSQvbHNpv8RNwrlso9rMM/SgzvWHH8qmDC/vFK 8zjF6wj7e8a8qd0Uy/PzcGXn+zcLZujMsb+SDd3+URo1yTrM3f1GmmoABZO/2XwSY3 tKKmkI8uTUniA== Received: from smtp.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; Thu, 14 Dec 2023 11:29:49 +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; Thu, 14 Dec 2023 11:29:49 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 11/11] leds: powernv: use LED_RETAIN_AT_SHUTDOWN flag for leds Date: Thu, 14 Dec 2023 11:29:40 +0300 Message-ID: <20231214082940.2718303-7-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 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: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 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: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2, 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/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785245371921815194 X-GMAIL-MSGID: 1785245371921815194 This driver wants to keep its LEDs state after module is removed and implemented it in its own way. LED subsystem supports dedicated flag LED_RETAIN_AT_SHUTDOWN for the same purpose so use the flag instead of custom implementation. Signed-off-by: George Stark --- drivers/leds/leds-powernv.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-powernv.c b/drivers/leds/leds-powernv.c index 743e2cdd0891..018ec933ac10 100644 --- a/drivers/leds/leds-powernv.c +++ b/drivers/leds/leds-powernv.c @@ -30,15 +30,6 @@ static const struct led_type_map led_type_map[] = { }; struct powernv_led_common { - /* - * By default unload path resets all the LEDs. But on PowerNV - * platform we want to retain LED state across reboot as these - * are controlled by firmware. Also service processor can modify - * the LEDs independent of OS. Hence avoid resetting LEDs in - * unload path. - */ - bool led_disabled; - /* Max supported LED type */ __be64 max_led_type; @@ -178,10 +169,6 @@ static int powernv_brightness_set(struct led_classdev *led_cdev, struct powernv_led_common *powernv_led_common = powernv_led->common; int rc; - /* Do not modify LED in unload path */ - if (powernv_led_common->led_disabled) - return 0; - mutex_lock(&powernv_led_common->lock); rc = powernv_led_set(powernv_led, value); mutex_unlock(&powernv_led_common->lock); @@ -225,6 +212,14 @@ static int powernv_led_create(struct device *dev, powernv_led->cdev.brightness_set_blocking = powernv_brightness_set; powernv_led->cdev.brightness_get = powernv_brightness_get; + /* + * By default unload path resets all the LEDs. But on PowerNV + * platform we want to retain LED state across reboot as these + * are controlled by firmware. Also service processor can modify + * the LEDs independent of OS. Hence avoid resetting LEDs in + * unload path. + */ + powernv_led->cdev.flags = LED_RETAIN_AT_SHUTDOWN; powernv_led->cdev.brightness = LED_OFF; powernv_led->cdev.max_brightness = LED_FULL; @@ -313,9 +308,7 @@ static int powernv_led_remove(struct platform_device *pdev) { struct powernv_led_common *powernv_led_common; - /* Disable LED operation */ powernv_led_common = platform_get_drvdata(pdev); - powernv_led_common->led_disabled = true; /* Destroy lock */ mutex_destroy(&powernv_led_common->lock);