From patchwork Thu Dec 14 17:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8718981dys; Thu, 14 Dec 2023 09:36:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFR2jSRkruCXVFl1eE3eFu1RGUn1j6xiKR2Zr1gN5fLbEADQ/0xpixAxJsTgIctM6WS2Kp1 X-Received: by 2002:a05:6a00:2d83:b0:6ce:7ef2:40b2 with SMTP id fb3-20020a056a002d8300b006ce7ef240b2mr6758199pfb.24.1702575397014; Thu, 14 Dec 2023 09:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575397; cv=none; d=google.com; s=arc-20160816; b=e5UkL8GQFqDUHL519Thjk9iZKIekqG/vQubyuXJ3s1c6Dfm0EST007KcS5abCJJzk4 51jN2W33OS+Fg6G1T8cm/C0AqFsE9MIWozMMS3lxodSofs0sBLg4UtXZJvcJIzlQofDF OLtK9/oWGAR5w9kNbeWAoAoANUPGc8oT3meUOw5yn0ttzLOYQbcjW4fm3ZVbZYKyTVfL zYStpEY8+humECjTsh/Lu3PzXZOY+scPi/uZfmHgFEU30iI/VPcBXTKsjoOAYjCtkczd t/uy7IqcqouVlW/WO5wchdIp0CUpJXzVGbT/X6s8GeFxWRhVZpnC1yk5Z4KN07btfoNO I6ZQ== 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=XoyXME9o9D+O65UPeU/S5jya+2cUqz9UKPsZ2HnPzAg=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=zyrdNymlTK2J2HPz43CHdtHD3lOUkrO1pRWZ44ug2lZMr8eaeGCetQNEki7hGY3bYx OyNKtj4pDGOPy00Efvc51L1wvvh7mVBe/5AL9ao7soyONLi4snOMFZsWFy+VRQQqjdHz KZDdeOC+Owni1TmJsRICU/6BWGmOK7cBDkrYaCDl8sTMLiOM38B/Kn1H3J5vxmh0bInH HZ7uLP/asVgNgR8LskS0p5jfmY2Mr5SVcts3Vm5aMjg8UV9Yfmk7ryiOGThUz8+nClO5 3XgVgVRCgNoLjxl079yLhtOWKWWyVzZIGV+TKQ6tRjHD7fCOYQrGOq+nZ6b584MbLdZ1 zYzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=vCi4bvZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id y9-20020a63e249000000b005b9377ee20csi11641156pgj.701.2023.12.14.09.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:36:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=vCi4bvZE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 60B1087943B1; Thu, 14 Dec 2023 09:36:33 -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 S229464AbjLNRgY (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E8C10A; Thu, 14 Dec 2023 09:36:26 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 95ED0120019; Thu, 14 Dec 2023 20:36:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 95ED0120019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575384; bh=XoyXME9o9D+O65UPeU/S5jya+2cUqz9UKPsZ2HnPzAg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=vCi4bvZErRg01jC4xd0W/QPeuBrD/SimUzflI8WLiQp1BlY8YmmVD4QKXLIepve4/ kCuMnWkHmp/Dtuw7Uxwh5dhnZnMi8lhrow5CS9hN7OiYgIpXyPLztLlvAXK2un6Yae bMVVOFoQKY+N3IVSatOh0V3F8gE0fzJgv/Zh15rci/f5va/0vcwoC/b2S6zkS9Lx/c tkd0qyFX+KtE43nttyiBCb6GRnEKFf71OPyky6Ekxuu2mcj3LzA6plBKzDpuDGyy1X CPArSuUcixpoRcT3Nyhqs/KWvMQd6CspMpGt4x0gMOk2cdSgWra8sUXLc1kN6iC2Tc 9JYLV54Ou8f3w== 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 20:36:24 +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 20:36:24 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 01/10] leds: aw2013: unlock mutex before destroying it Date: Thu, 14 Dec 2023 20:36:05 +0300 Message-ID: <20231214173614.2820929-2-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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=ham 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 09:36:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279699811359977 X-GMAIL-MSGID: 1785279699811359977 In the probe() callback in case of error mutex is destroyed being locked which is not allowed so unlock the mutex before destroying. Fixes: 59ea3c9faf32 ("leds: add aw2013 driver") Signed-off-by: George Stark Reviewed-by: Andy Shevchenko --- drivers/leds/leds-aw2013.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 59765640b70f..c2bc0782c0cd 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -397,6 +397,7 @@ static int aw2013_probe(struct i2c_client *client) regulator_disable(chip->vcc_regulator); error: + mutex_unlock(&chip->mutex); mutex_destroy(&chip->mutex); return ret; } From patchwork Thu Dec 14 17:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178840 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719165dys; Thu, 14 Dec 2023 09:36:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFo96E3LbjN/KE4o0jxaJLH/9o97HzTr7r6ZcTh1GVM30m95/8F18UI8TlGYs2RBHpR+mvU X-Received: by 2002:a05:6a00:178e:b0:6cb:4361:773c with SMTP id s14-20020a056a00178e00b006cb4361773cmr12309032pfg.5.1702575414212; Thu, 14 Dec 2023 09:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575414; cv=none; d=google.com; s=arc-20160816; b=wpiEy17UUebpIK7PUzm1pobTRxiimnbjyvSdTNL3PgCSDhhuB9vb14P7msuj8YnF+1 b2SeFjZs9mBTdgTLTgPGXNAejTj8vj1EH7b7AXVndQY+86l4EH8TwkUadDeHUg2aG42R CUFyoX53mdzkHJEpeLlms+RrrXEg7z4KJTnN/erVKtDYLyyMCNPlRH5fRzLbfODswNaP cVGMtJycrr6sG4EOxH1x9Kj4j/nf1QdYnN6PAQuPr7KVt6QtzMHEkls+jVCgz+Q7V4Dp daDnaCOOVn28b4cVCuV23qMrClK5iTboy/gIbVVxG7QSmp2fliiPnCa+8XxSTopnlLtP g1hw== 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=iVWYFD6b0apij0HQWfsa8gAqaTMVMRAzNodGO05e/bE=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=ODk9Bul2wx04jl75DOMKOcfqXAorRtJjmFLKweGd1dJK/TZHNsNcLYYKzTVcheA+Ts e5gRgw/sKSEeeJhYwrwnWecrey/J50MLFA/7FTfaUyRSnz6X/mJrLaDcjhY1BSRurpX5 y+immOFogL601z/NyjKGFP0NN2XoQVxYtWhqrHiaM3TxpccdQtWQe6nLVX3uyhHeWLtO 4b6PBrUhjSQdEMBCf4zYWFJwb7X6xAvN2np983sdECnxMfc48TtA38QgkxK81sKxQwFI 8PEiQ3r+FjNMQDisMM9+R5XNbYkoV4zxLviZYLK+YqzZCURUAq8FyBt+sOwtL4R6SLgr Jyiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=lsJ1+DAj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fc6-20020a056a002e0600b006cdf20980fasi11702487pfb.80.2023.12.14.09.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:36:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=lsJ1+DAj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id E5F81826A049; Thu, 14 Dec 2023 09:36:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444082AbjLNRg0 (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DB9F10E; Thu, 14 Dec 2023 09:36:26 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id C789912001A; Thu, 14 Dec 2023 20:36:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru C789912001A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575384; bh=iVWYFD6b0apij0HQWfsa8gAqaTMVMRAzNodGO05e/bE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=lsJ1+DAjunouTieLbR0DMDE+qCUpL/VIvCKfDxmTxqgWwou1vJgPy5TEMeDUyMY17 rijdruXZjHnokHnmFWKFPBzB5LV7P9oCurhzZ60Nw+yqqWZ9C3tHRZa3LwDAEph44k NY66cZDjQ9h5WfXg5HKOC49axRfnSvsxqWOHfx0Qe1f8r4KR7md8DNONqyH0Wpo586 kdife/rVHy03q5wePcq0d2cJW9uhDVv4BTI5LBVJqOyTt3kHl5W0FJu0urgWbnS4AG Bbx+vxkXBg3cxz3LUaQrntRGI2zqyHxqFJxvqJCXm9pJsWU1qVfjr9owIxDGketVPZ bVNnhzOsyoIlg== 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 20:36:24 +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 20:36:24 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 02/10] locking: introduce devm_mutex_init Date: Thu, 14 Dec 2023 20:36:06 +0300 Message-ID: <20231214173614.2820929-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 09:36:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279717476540752 X-GMAIL-MSGID: 1785279717476540752 Using of devm API leads to a certain order of releasing resources. So all dependent resources which are not devm-wrapped should be deleted with respect to devm-release order. Mutex is one of such objects that often is bound to other resources and has no own devm wrapping. Since mutex_destroy() actually does nothing in non-debug builds frequently calling mutex_destroy() is just ignored which is safe for now but wrong formally and can lead to a problem if mutex_destroy() will be extended so introduce devm_mutex_init() Signed-off-by: George Stark Reviewed-by: christophe.leroy@csgroup.eu --- include/linux/mutex.h | 23 +++++++++++++++++++++++ kernel/locking/mutex-debug.c | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index a33aa9eb9fc3..ebd03ff1ef66 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -21,6 +21,8 @@ #include #include +struct device; + #ifdef CONFIG_DEBUG_LOCK_ALLOC # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ , .dep_map = { \ @@ -127,6 +129,20 @@ extern void __mutex_init(struct mutex *lock, const char *name, */ extern bool mutex_is_locked(struct mutex *lock); +#ifdef CONFIG_DEBUG_MUTEXES + +int devm_mutex_init(struct device *dev, struct mutex *lock); + +#else + +static inline int devm_mutex_init(struct device *dev, struct mutex *lock) +{ + mutex_init(lock); + return 0; +} + +#endif + #else /* !CONFIG_PREEMPT_RT */ /* * Preempt-RT variant based on rtmutexes. @@ -169,6 +185,13 @@ do { \ \ __mutex_init((mutex), #mutex, &__key); \ } while (0) + +static inline int devm_mutex_init(struct device *dev, struct mutex *lock) +{ + mutex_init(lock); + return 0; +} + #endif /* CONFIG_PREEMPT_RT */ /* diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c index bc8abb8549d2..c9efab1a8026 100644 --- a/kernel/locking/mutex-debug.c +++ b/kernel/locking/mutex-debug.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "mutex.h" @@ -104,3 +105,24 @@ void mutex_destroy(struct mutex *lock) } EXPORT_SYMBOL_GPL(mutex_destroy); + +static void devm_mutex_release(void *res) +{ + mutex_destroy(res); +} + +/** + * devm_mutex_init - Resource-managed mutex initialization + * @dev: Device which lifetime mutex is bound to + * @lock: Pointer to a mutex + * + * Initialize mutex which is automatically destroyed when the driver is detached. + * + * Returns: 0 on success or a negative error code on failure. + */ +int devm_mutex_init(struct device *dev, struct mutex *lock) +{ + mutex_init(lock); + return devm_add_action_or_reset(dev, devm_mutex_release, lock); +} +EXPORT_SYMBOL_GPL(devm_mutex_init); From patchwork Thu Dec 14 17:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719702dys; Thu, 14 Dec 2023 09:37:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEn01u42AeW0Rjk0fL2HCRaF4kypDs963liF4Zv002NTqbjDNjA1/Aw1NUK5wO61kIH/VA6 X-Received: by 2002:a17:902:eb88:b0:1d0:265:6a2c with SMTP id q8-20020a170902eb8800b001d002656a2cmr12093983plg.11.1702575466854; Thu, 14 Dec 2023 09:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575466; cv=none; d=google.com; s=arc-20160816; b=jBfijjr698Q+kldK6ta1ihkel0+YHq+HEVDij6TFcV/gFAQxlGYzgy2TVNlvCAi973 Z3i2lZG6vYZ1sOPljlxA0kQ9a1dsgY3p1eW+DPk+tv9a6yzG/qMKxDewLRNrkEP1fOxD 9eczpoh2FPQG1H9Qkad/0Ct0MDfHkB7b5HXbiecPX/4xZspPKjn/rPbDkntu0ipJuQOc oVj/2ADyQbzRRb2maVn8LIvZP5ccIEIuGu2UBeJvLWLOQ21vIGOg/e3QDj34iRPhd3MZ ic6RbCAVtaY/QSMFF3VS3kfRJB33CjiA74w4FDGWNwRmGvafdg7qzvDnCfVjjeNqNk/p +eNw== 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=h+tOY1bGBGofUvQs5Gx6JcaxFJQ0t9mJrPXrCf8ZZ+M=; fh=g7I1tLF9YKsgNWexoTTno9J1w1m/O++VeeqY3UqMZxo=; b=ymjQyKZz5mGk4T5iA0SX10vwAEdwjMSpBmxurvpGdTQTG9AYsxDlzrjZ4heoql9vNV frwOR3p/97jLIgM4wKq9Y7G4TDo1JEXJGMu4HqZFCS75h5FcWSp1R1KBSB78xiGKHurS KzGobhvUmv6N794eReu/xDAtrQXIK3cmc9OuuIbIrZkmioNdU/yv6/LOp9lADSq5v527 XU/mqlFNnZB1OZ09j6ppjRi17Tcfotb74yFD6bFI6CLp3nXow4SqHQJuHwOutw/SYCsJ c6JVoLAaF3r44vHp5nRL2hiNz1RLuJXuJnILl8tSpcXy+Lna47zpo6Bwd1ezqL4naf34 h5oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="vf3iDbz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id x19-20020a1709027c1300b001d33a8a3df6si4616534pll.506.2023.12.14.09.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b="vf3iDbz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 13A7C8077518; Thu, 14 Dec 2023 09:36:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444134AbjLNRg3 (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7530E114; Thu, 14 Dec 2023 09:36:26 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 070AC100011; Thu, 14 Dec 2023 20:36:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 070AC100011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575385; bh=h+tOY1bGBGofUvQs5Gx6JcaxFJQ0t9mJrPXrCf8ZZ+M=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=vf3iDbz/Hf5f3AZLMQGgmqCE267TVwZ5mAyGWJkbUScHS2C9LWP2mYXmQ9KA7oimr c1jEhhaxuIcA1z8eIdcFFNnkvvt5dzlAeSYQfq+Z21rwCo4DYP4UCZsvMEJwyjQq8b ukn/3ecALO6VdMbpwhC1EFYHUABJdY3eL6JyWe9I3daJH3gIl73KqumZBEvzkI9ShM qCgHDHYrscJwWl1duKceuqhnh1Wx/TAzVuzAx5A6h/c50mK3b2Il1bYzV3kWCO/y3w kX3/2lH+FG8R8Wzdfkl48OgkJ/rZomGDC+8M+ermO16IVYRkUtIgngGeZpAxbJKDS8 7NlzSPonW0i/A== 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 20:36:24 +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 20:36:24 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark , Nikita Travkin Subject: [PATCH v4 03/10] leds: aw2013: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 20:36:07 +0300 Message-ID: <20231214173614.2820929-4-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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}, smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com: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 X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 10:50:00 #22693095 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 14 Dec 2023 09:36:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279772701215831 X-GMAIL-MSGID: 1785279772701215831 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 Tested-by: Nikita Travkin --- 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); From patchwork Thu Dec 14 17:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719151dys; Thu, 14 Dec 2023 09:36:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEATkCEOlDI5GCO/zs8s2UWokrLtOIiF+16LqZZXQyUJ7SowzsU9T2YT2tclIrMEz5iQXcQ X-Received: by 2002:a05:6358:787:b0:16d:e923:573 with SMTP id n7-20020a056358078700b0016de9230573mr7568902rwj.15.1702575413219; Thu, 14 Dec 2023 09:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575413; cv=none; d=google.com; s=arc-20160816; b=fjvG28WpZkRfx77te4wQoSFe9rYUQNyTDSQyiSwPerI4x7uHcIfSzqJA8ctw3dMBqt F9Ap8iFfW8lg6BwjDN6GKsNeG2lkDGQRvMepS7uS3WvFkx0bc0OihOmBV4MI4L0Ac//v OADSUYp3QPJ9wricHhlqUvC+ysmKK6psuSP3BsOo3DW9AmXKP2503APl+GB0yfnGR49z /I/8R5cylmmn/DfQ8ZY63BIMEB+Jo2186HCHu74XKZYf+1A1ylI6V+yKwkG2thBY4KPa fS5S2Ior/9efXOzkyeRE8FgwoYjkJdMKMNOh5ct37yqTiA3xxrL8zhXIRTkf2gDBQM7B GqBw== 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=2AuAiO3OInmf7JfFcpOZ0isTbjfNOkeR9WOJsIXMUT4=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=h3/wMShkFvdegAa33ISILPUVpi6LH8zUVxnfKT0/1LBqA8Psvt+Rzcnh+CdA0+3ONP JEG9esQ0yZjXUaJOJaQomjwJFE7ZyX8AaBx+NCO3DfX+uFfcIdQoUjExo4aY7cNlnjcy HPcMyr27XUhlR3IR4jGSizVfVC56NkqAR+1xYVuO0MDxcUfuf/y8Xsbx9zZGakl+Wiez 9vCdNVTNba6b8ex3I60aeAsEMbf6o144ExmZtH0HeAk4SeKAzDhg+6M1K4JHC6oWo6u9 hvuEGurIUKm5iASMaY3G4JEPLAlELZRtDWtETp6LB4p0F+CIpaFaKA67IXSeG8QGvPTs gjZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=N3qm0OX4; 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 bz39-20020a056a02062700b005c67e10f240si12078890pgb.312.2023.12.14.09.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:36:53 -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=N3qm0OX4; 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 2FA688184A9A; Thu, 14 Dec 2023 09:36:49 -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 S232071AbjLNRgh (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4772121; Thu, 14 Dec 2023 09:36:26 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 4C0C212001B; Thu, 14 Dec 2023 20:36:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 4C0C212001B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575385; bh=2AuAiO3OInmf7JfFcpOZ0isTbjfNOkeR9WOJsIXMUT4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=N3qm0OX4jYf+qO+Up6Xf2I5g/M1zd2Colz3sB7rLYfos4v0EVovY2chsoiL+6683H aF4KszR1nUgXCqyRmO/bwV/+SFNnt8KjB3LGeWk7xfaBf64H/Lhf/HLItiKPqPIcbt pR4k2v6bGfPMuCXZCibc8tC7YutZ8i6ztxPHixzA9LBxvwxQvHIYrcsu/HvXLu2ulv wCAozndBC2ocvH/dr/fwHq1e8N63sU9sxuNUCc6qZhDuOwSYSvXA3DT9t+WEZjO8dQ I/TFtyeHs5B+Cp6WdQK+7z9QBhqLoWnIJDvUo8TXsTWERCTBBrM82Z0VOD8YGRv/Yk HTCVSWSr/K14Q== 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 20:36:25 +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 20:36:24 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 04/10] leds: aw200xx: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 20:36:08 +0300 Message-ID: <20231214173614.2820929-5-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 09:36:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279716404840650 X-GMAIL-MSGID: 1785279716404840650 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 17:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719117dys; Thu, 14 Dec 2023 09:36:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEk9iVgZrIjInd3wgibUC17p6Z+r56zZ05KLpF6Btx7P/7Fub0BX2UcoVlnrESnC47Tw+Nt X-Received: by 2002:a05:6e02:219d:b0:35d:66dd:ca6b with SMTP id j29-20020a056e02219d00b0035d66ddca6bmr15721547ila.7.1702575409323; Thu, 14 Dec 2023 09:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575409; cv=none; d=google.com; s=arc-20160816; b=e8xOpa8/VvJ04iO57e0aNXilypxc7Zct0zM1C4+b9WkUEy4dgXRFL/PcmSCJL/zFE/ mAvpru4PvEqnPmD/uKskNv//p3puxsDq56pzpSDAn30HvwFUDkM9FyQodKaOgrsM5d+i M1nR/gEcMENPIRZaL7O0Z1fYtTrnHuw6jbRli2PlGHxbHrb7pAEaKkD6EfWuHi3vPK2I CZifNt1qSrC3MKBsvHCrx8IM2eUK2YdicndLYrhRZva4yAHVMH6z89GQ25HUQUTCzscf JcpfrORCOb7zd8nMQ/0RMi/D+tWqe7ppIR+3u3bGe3LptxVeqVBiIKU6/AaXUUrLcshB DbXA== 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=AjSDy97zoxnNgKclgYT3/VD4ni/QXDdeBeCJI0VTKnF2VjJqOXO+RdjyqrJScQOCQL MXA5c7xSe0zGfZsDEXefJF4XSvsMioAzGfDw1ObppFYQESX1u3GFDvnmIeBn9GjvoP0A DlCPScqbuOOnXeBM0hzgK9o/2YyU4+5g8xAO7idhweZ6kw3efYxlsKfDTagiV3tO3oZI u53zYd+7depapWRjdSIQ8I7KDkKdBQ6crRzSVdoA9neVX1XPrLnhgqu0nr+VMtiHddOk eT1rtoFCoGb07yqvhycQ3rM0GW6yf0NRY67OOg0y0ZFkEDDzJVcgmRbKpc+QuQkifz67 Q6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=MMmWEM3+; 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 bq13-20020a056a02044d00b005c200b11ba3si12539739pgb.888.2023.12.14.09.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:36:49 -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=MMmWEM3+; 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 E05D2887B743; Thu, 14 Dec 2023 09:36:45 -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 S229532AbjLNRgc (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE14F12D; Thu, 14 Dec 2023 09:36:26 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 7EC7512001C; Thu, 14 Dec 2023 20:36:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 7EC7512001C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575385; bh=E+93qW99+MbE6qv9QYbuPHDD4qbYVZKtaw4xnbuw8OI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=MMmWEM3+ikA+w0TW+lYBUXezYUYlNgkI+4AIQg2LRMw9fGZeaxMX66VrZVOMazUTc sd4Ezd6d3UQWd4/raOOjzPXBR/O3D6RsyCptX8QW5AyBQtRbKdABgXaAjPnmK1D/vC iw+OrSrRYnVQbR6GBXsI30EjPoAISDeUF6n5q4LNbWV/VmLT5sB1PhrD5MbnDJPpGH ccqJPKvjJR+SmwNUrFZWA6E3ZNQsH+J3Ui76g+Ufw1aeCsfHeuxxERFw+Z27uJcTed 4lcHtpVvxV5FispeMY/CIlcz+tGFtIrGHPzxGl9lCLuquH1VJrfhPP+oeSLJL80Att QlCIYCX3pj4xA== 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 20:36:25 +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 20:36:25 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 05/10] leds: lp3952: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 20:36:09 +0300 Message-ID: <20231214173614.2820929-6-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 09:36:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279712314999394 X-GMAIL-MSGID: 1785279712314999394 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 17:36:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719363dys; Thu, 14 Dec 2023 09:37:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI1A72HK+inRlOuC6qddfNBfpnpIoZXCACGRGscPJjnLjmET9XjIKyIICBPHAVrupR924R X-Received: by 2002:a05:6359:d08:b0:170:17eb:9c52 with SMTP id gp8-20020a0563590d0800b0017017eb9c52mr9911333rwb.51.1702575434097; Thu, 14 Dec 2023 09:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575434; cv=none; d=google.com; s=arc-20160816; b=KA116OFWPtO5F/qLiriS0sVYthOy744o5JcasiJqCpiCX92rZOzdKq/94r49oTNtUE 5Z8t0ROprTkkJd/3tKlZF5HXNPzJluQCfkiitd7tK8zGOlmC+p3/jpNGT4kigGr6hmec uUDi7sUPjtFdNX+bs2Y7zu0pspUceQeM5Rr9nj31eBaQCthJneptx3cI3Ec3Xe/3JdW2 y9aoPDFQ8VnWEEZOtJTNjH2xL0hiKo7IcAPXEkmn08d2ZhZPCQL1saOVokzJWaxoozTW 80D+GN4pcmxDIaGNo2DmvW9QNP6e/E1E5PA+62GIe1QjnbvWVcrusD83gFBIOtOX/aJv iH5g== 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=yLOEngll5HlIjnFJCPpPxyMDlLc+DdkDlA+l2EIX4Q6smrpOOWwqSEmp/etE3cDnPX 2A7ju8Xei+aYllOtx45ouiD4Oj5a+zIRaXfupGJBFFR8GYolPuCmNlHCv7IwVZWV/T/o TCvRFSu5t9QcfUiZKrEJ9F7roF848J1wjZK9oBL6OI5itPztaOh/gajDP2adzEnHUY3A HIUDRJ28BuULh4D3KU/y0x2Wbg+1TdZFKBsMOw2nt+W40Uq7hkSmwb4+Hf3rBKFcBi5a 8cCXEqBigWvPxNjSp4ShBZH8VQDXJjt12WVmwN2DMHYcPbdvV4i4l68F1bfjjFYVC60y VCbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=G4PwqNGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r9-20020a63ec49000000b005c658c16acdsi6730703pgj.196.2023.12.14.09.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=G4PwqNGZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 1814D826AC4C; Thu, 14 Dec 2023 09:37:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444241AbjLNRg5 (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235540AbjLNRgX (ORCPT ); Thu, 14 Dec 2023 12:36:23 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4038212F; Thu, 14 Dec 2023 09:36:29 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id BDB3112001D; Thu, 14 Dec 2023 20:36:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru BDB3112001D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575385; bh=EC3dQnKKfurosn6pqq8G2JOlIq4yy+2qbil19wlXj5E=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=G4PwqNGZSJIaHMLsMt8lN89HV60oNIGdkIpRYP3hyKR+uqCIJBwMqtGcLf5Cdg8qn MX9PLkcgRsEHbld2kt2wZan57KWwPDBXb5wgtfvzsaXjt+84g8THHtHK7ohFmPOQ1y HWSn6NabwFrCg1A9C/ap6rLbNiMTwGRlOGP1KbyUb+zCunl1rmjQW6TpCsrCljOfly 2aAfqrXiPZExmclBEKW4Wed/pyUVf4P/CyH6fyzVYpsppTBwDxd+HK14ry9Ag+1w6X vM8SU6RFyKB/5J2d5dSZFZMow8UikCKZMJJGwpQ6DRYQ8cvahAxpvIGsWTnVnieYTn K6gRi8Qri+h8g== 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 20:36:25 +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 20:36:25 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 06/10] leds: lm3532: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 20:36:10 +0300 Message-ID: <20231214173614.2820929-7-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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}, salutedevices.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;100.64.160.123:7.1.2;www.ti.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, bases: 2023/12/14 14:24:00 X-KSMG-LinksScanning: Clean, bases: 2023/12/14 14:25:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 10:50:00 #22693095 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 09:37:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279738105323035 X-GMAIL-MSGID: 1785279738105323035 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 17:36:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719313dys; Thu, 14 Dec 2023 09:37:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWzqIkPqZvZ5T36tKxVL5UpGjYME6zWmCQtyM3DlFBwBQNug+/7EknxBMvX7MKNZqKKvfl X-Received: by 2002:a17:90b:810:b0:28a:eb24:f466 with SMTP id bk16-20020a17090b081000b0028aeb24f466mr1391215pjb.79.1702575429194; Thu, 14 Dec 2023 09:37:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575429; cv=none; d=google.com; s=arc-20160816; b=nKBjVggZFnx5hFoSyjNrW12c2do7m2wpp75WFyOPa98wxv4+7OTx7d6f8Os8Fz8kOt od3QTrFd8zTnL5yOyd/D1g5NrGVz0PiWUfy06Kpy3zGQ98LVX807gyfzaSPeEpmI/3D+ U2W1vYjYTrKotUCa0BB5ck9EaOhG57TFxkXv//AutrcsOSdQqrvRFCkJXwY6ycL4eGa6 AmZYlLYLfG8D8F1FIt8Hct/gqUd3TwOC2QbwYfjd7qRHPOSjmBcGUFx9M+4Svkl9/6tS jwHI7UMeS5jEF4RlhfzR8q2onCyxLRKEUNyvLLbSGm/OLhZWi+R9YDOH7GsTiKG33yPe djKQ== 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=adcHYfsuYivmeXSR9zqJpc740gvbvy5DN5O+ai0Fcqe8yvkCsATdcgSlHRfn4iNRcy HtKS08TSfzjQMJlTwB0K0iTllEHwz6CVViifsl7wcDKzqEC43vm7j5Lbi8/IPfb3d0ua F7ZMqiqFw8tg9L7HSrUvCXfbiWnPwZeqXoO0n0Y90Ur01OdM4mAxavFsJWMTqLh0PXBc AfPeFCYoY+q7b14xo7DdRS9QsY4cBuNAcYiU1rrIt510kgE6hDiFoEEHuJXv+LGZhFb/ x+021tVnEL1IxtIBIRIus4DIo12zZtOVsZmCYBLOeqUGgcRdEUCLVOd8fPInvKwxNt3F KU9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=o4PVSh0a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h14-20020a17090a470e00b002878ffafeb3si11663242pjg.113.2023.12.14.09.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=o4PVSh0a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D92BA826AC4B; Thu, 14 Dec 2023 09:37:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444238AbjLNRgq (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235450AbjLNRgX (ORCPT ); Thu, 14 Dec 2023 12:36:23 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 441E7132; Thu, 14 Dec 2023 09:36:29 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id EEC3A12001E; Thu, 14 Dec 2023 20:36:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru EEC3A12001E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575385; bh=k3WMJ0GNwuGRczuP2LxdxutooPucV6JPLeqyGQDEPIA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=o4PVSh0a2zgp2DaGeInM7daHcqicls01cPeXE8aE6Ms6f52DMAt8ZQiWho05YOyaI kjcXnU24UMVevOlFWDY+qDps3W3bdbk9SwHjjg0L/2ghAUIzrZyR4stKkdvlreFN85 7B4xg+GBckWhUmhdlCDgpn0fr8MVe2nJCptXc2hho4tNOsxUkBxc0iCJXlOEz/pEHS ho/FuaUTz+zI7l1DiApIVydpaCILJD0TrC/mN2Bvqt3BhYDzEJXV7dwJpQasMnOB0j RnRnOF33H+rh8lCfr/PqJboNgzzGUCU8u8O0cElS+Z7LkSVXPcsldDb4zMAH/fjNOh 51D/Z/+OlCB7Q== 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 20:36:25 +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 20:36:25 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 07/10] leds: nic78bx: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 20:36:11 +0300 Message-ID: <20231214173614.2820929-8-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 09:37:06 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279733674055213 X-GMAIL-MSGID: 1785279733674055213 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 17:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719276dys; Thu, 14 Dec 2023 09:37:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAnwasnou/M9SQp4wqTB0ClurUx4b46S6c3XC/9DMvVkjvL0jytTY1owu+/E/my/+O+FGR X-Received: by 2002:a17:902:a3cc:b0:1d3:5009:4c4 with SMTP id q12-20020a170902a3cc00b001d3500904c4mr1616870plb.44.1702575426057; Thu, 14 Dec 2023 09:37:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575426; cv=none; d=google.com; s=arc-20160816; b=FVj+ZbpCLn7cSGH5Jxgv0jsUCsq/CgdLcO3fUyzSus+VzAHpU/h0TXv0CR2qxaY6YE KdNN27tKRanIXKfq+JldSAO6Mo8Bp7/7YLQQLJQyfSXi83hJxjxEFyM331zBoI8qOEQ8 3IkrKRBWosF1C1H5uHanUiUha5gT4qSmT4G46JxbIlp0wHwWo+qynG77RCZqJoXVH/Ft kftOqXRy5/onxq3CFBJVxODYsXi5f38OCWv3vFNK35jzXkx6M9rKWvHNHxdNyu319FN9 gbpatx+FrPYDQ7gVhpzBSJOCWZRfeVkjChFjsQQ9XDJLHe4ijvVVx5evo5GkSjYM0Vbs kFcw== 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=t6rDqDB9u0FZbr3nUUEjfJSg9g6NxzK45ibQN3lVZZYkczlGtw47IobdNrkIVLwqzW vmy87ijdIjI29SNFOvXM5qLiqqoIG43uro8tSH3sDnSRHDMmigUMaFQI1E8etqP8z5EM 3Lsm/l7bCzScMYOf5/3xk5ff+3a/zXtV3PNsJvrxaVR71qRFGe2W0909ybRp7mecWkap conpVa/jmohmKUOLYTljfbiGidza0OnFiHJ9Zo6WSgLuwqc0J3o1L8JSWIdteB8ns4tR haeP5iN5vnd1fVltDs06hafKyjxMQuj1mmmPqi5lKuaflylNcmjrNBuCjECyKDmmHmhm IHkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=G2Btu04+; 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 k9-20020a170902c40900b001d0baf665b3si12063059plk.358.2023.12.14.09.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:06 -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=G2Btu04+; 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 83BF48184AAA; Thu, 14 Dec 2023 09:37:00 -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 S229532AbjLNRgt (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235514AbjLNRgX (ORCPT ); Thu, 14 Dec 2023 12:36:23 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42BE2131; Thu, 14 Dec 2023 09:36:29 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 2D8CE12001F; Thu, 14 Dec 2023 20:36:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 2D8CE12001F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575386; bh=nTXR4WBFZR+kxSlC13nocgtwFZu8ItCajWxM9cqi5i0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=G2Btu04+yak/8X6fT3WuNA96d147W5JSc/bjvRnU3To5MiV3hU85t8rXnzP1CDGJc Nqi8RAragqLnWBD4xThH4DPHRJeqjq58CKKSzgix9X4rgOi6cVOuHKI5XgBWdGQAZD OG+zH2ofCmV/bRXj7tb2mVyDD+mwAj/ljsNBXZIAQ3/dzl+vQDOSuMBk7FkfrY9HbY 5joVO1jvu2Kcjc8zbRWhmeyTqGx/Mdrp9Doa6r0FjTpQ0ke64J+vKkcl4lIXeOEBPn J2StXK9G5d/jG+k3NjZgO3V4NLF2RXBdffOgoFSKMlTT6+khG/VfmDFw0U3LqNxEFW leNh/hF5COznw== 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 20:36:25 +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 20:36:25 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 08/10] leds: mlxreg: use devm_mutex_init for mutex initializtion Date: Thu, 14 Dec 2023 20:36:12 +0300 Message-ID: <20231214173614.2820929-9-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 09:37:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279729841584989 X-GMAIL-MSGID: 1785279729841584989 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 17:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719582dys; Thu, 14 Dec 2023 09:37:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxB25Lje5ZZq5YEd1AtCjJkfvst4XLmkU4fgGmNrCRPmbxbKF12Qai1GnMIxgJajYN83wE X-Received: by 2002:a05:6358:91a4:b0:170:d105:e788 with SMTP id j36-20020a05635891a400b00170d105e788mr6061285rwa.23.1702575453855; Thu, 14 Dec 2023 09:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575453; cv=none; d=google.com; s=arc-20160816; b=H1Ao8TO4HOJjDMNduY8J7mBeMhJjGFkPITqTQ9Jij6wsczbcXNnriHVQxJ243PahAq zoj5TT34fbQ2tOAIXMR7ZczS3eImD0UAacBBhpg9pUkIZjD1OSz+cyzTZHi7sMFLkuuA 5akeBRj5m9btt3BlAG/0QlhMjTjJEhZD6QZGful+6hdP1ZHzgiB8T4mWM0fA7TK8lBJ6 kX24c5Bb5ajaQDqk6naXcbd4YZsEWd4004SfUHpkhD1m4sIhBLGhXUryrvrvuEFW/KG8 ei+Ghay0JOeCLOdyddWTeeBJ5Jo8NwYMJ88ZC2JNe5D8KK6ip34O0R/ah/V/CJ1YhUL2 s0OQ== 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=W29oxY3C2CIROECZ+npkfK/oqXOwvnm09983pZELq+Wch92uocDuZh5oM5ggaDW7St +3jSHsQ7BY8CEnJTwJWt5yGZRRNVNk6Kg/9WmMosOQfkJim7aXN8VjXuDumnTyaI1YWX 6J9R3E3kKQLRCV707JVMG8VXMoKn/KhePgzDQ0DY7NExZerMgkGBpNIPANK5VEkg8IoU mhlX6YrnuoCTusVnlBMKQjf6oDf2hDMC0EPM4bICObsNBP4Zx+GcddvQ5MfsdPUh2Fcr 0FpSE/0joej3njetsuQcHiTQL7Uy7B5n/cQlduJiZK7L4kz69DDzX4zP3TZBoSN1QtuE q6fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=qfz3GIWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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. [23.128.96.31]) by mx.google.com with ESMTPS id c20-20020a056a000ad400b006d0b39dfc2bsi4169208pfl.195.2023.12.14.09.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=qfz3GIWD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 A3830826EE01; Thu, 14 Dec 2023 09:36:57 -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 S1572888AbjLNRgn (ORCPT + 99 others); Thu, 14 Dec 2023 12:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbjLNRgV (ORCPT ); Thu, 14 Dec 2023 12:36:21 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF302122; Thu, 14 Dec 2023 09:36:27 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 6457510002D; Thu, 14 Dec 2023 20:36:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 6457510002D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575386; bh=xznPFmv1qOhKYzpKJQ6sCA6HIF+5JBU12dpwjRIA9xM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=qfz3GIWDZjqRCdeQPfdv3Xf3RXqyZq/uez32t4h876S/yBIx0ZF5P1z2XPEJd0jQR aTmLQWmicsGeKZU2oGJjKqoECzXOhdQbYXAuFWXDSZ+D2NzMlRDasw2OkXkUhujOEb i4MVVHUVpmygjDBQy8KmgiYQ6i85UC8P5oMrVzJcBJ53z4Nk8BGkf6EtXryo6LV1tm JbTsWmS3I0EprtkK9G7ImPV5jZwHDT9f70U8f0aXGJBktLt8Jlc1pr47RJ41jlV5OA 4O9iNf5hLubIStbhzl/2w/7jPK6W9gktH+Wr62oRvLKfacYkL8eQemJaTBhPwTSwVh 7ed0Aj6rnd8KQ== 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 20:36:26 +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 20:36:25 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 09/10] leds: an30259a: use devm_mutext_init for mutext initialization Date: Thu, 14 Dec 2023 20:36:13 +0300 Message-ID: <20231214173614.2820929-10-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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}, smtp.sberdevices.ru:5.0.1,7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;salutedevices.com:7.1.1;www.alliedelec.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 14:24:00 X-KSMG-LinksScanning: Clean, bases: 2023/12/14 14:25:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 10:50:00 #22693095 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 09:36:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279759201752555 X-GMAIL-MSGID: 1785279759201752555 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 17:36:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 178844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8719443dys; Thu, 14 Dec 2023 09:37:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdTHTgT41RYHL43/S/IG9GTeQUPKcaeN0lYx2H2H/0Vrj2E84SPneHcP6eVnpYZcdlJdSC X-Received: by 2002:a05:6a21:789d:b0:18f:df5f:d9f3 with SMTP id bf29-20020a056a21789d00b0018fdf5fd9f3mr13769782pzc.91.1702575441149; Thu, 14 Dec 2023 09:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702575441; cv=none; d=google.com; s=arc-20160816; b=CIX7xo4OhAmI4gJUnZUUlomMiaKZjyxcYQSKinN8ZR+khgSN9CKBN/KCjCQWlud4ul 1fb4ClHzsr42r3zKt1sGZsI5hDqVRXSCfsy4a9UuMgxS+vI4xDwKj54uoIDOx7FHT1He QXhps2vzXuVjnGUOBVtZJjw09IrJRKVxsRFF9nBk6a8AcFafx15gy/zr/GNJh5F+ISto hPk22D2eXjzVWXlTYM5DdJfmIVDB2YFXEf3L7+gZitQXZFy9HiQfTFvtlgqRHgkFFz/R xEEAs42Vs9jdzI3Jp/sbj/a5YStAXzhJhCqnzMYIdWzMvA6w8fDGzYxIm6EcMrw5JDnR Hk5A== 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=ITmbSABiIrFp+ZXDegPF2murY4nZlqMKTRB3CqYTFb1+Qx5jP9oA0PbSLl7fOczaoE OhsLpbIai6dP/ePMfO1xlbXCG4xZ+Dvl7mIYbDWj/vlEkS9rKFVI+1II8JFIM9rJg2xJ IICSlQtSmDMIMyxplSTVf28d7/UreAyly1OA76q+IVNZKSKBkJn/PLoYyiHCcpeq1fwT J/r9x4+3nJbZqoqOMvlYIylDqWkOU7CmcBrq1H56KVzM7XeCDoptw3n4GtIABnFUSv52 KCYJUA/aSjJJxCw3TKnmTi8Ro+y3icd6bQfoXuh5XOkDTs2B6ZU684Tn4xjbs1BuVW7J famw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=ogWeDn6x; 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 a17-20020a056a000c9100b006cdd1393a2fsi11846591pfv.96.2023.12.14.09.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 09:37:21 -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=ogWeDn6x; 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 B1D2180E06AF; Thu, 14 Dec 2023 09:37:11 -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 S1572966AbjLNRhA (ORCPT + 99 others); Thu, 14 Dec 2023 12:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235526AbjLNRgX (ORCPT ); Thu, 14 Dec 2023 12:36:23 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF0D133; Thu, 14 Dec 2023 09:36:29 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id B1302120020; Thu, 14 Dec 2023 20:36:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru B1302120020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702575386; bh=IipliOBxVO1mB0P9vxh3aTZrhIFdLT6fPsP0SLsHsZA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=ogWeDn6x5Jc6Am38+/f3ozPM/OnYdYI1EQ4Z/NZQ1rrQld2H+yUlwlfE0t1Ls1IHn jSXRRda4eritSb7OIENH3IwFBCWe9MxMVnDSqdMBDBeh63I22arzTmcOPal4zMzqBn N18Pzd+nrGZ5G5fXso7721xybvU0M4xEhGeMXUvqibwY0NB9S7lygfMyaMcqEevK5/ JfAzsR+Z7LSXw+MDQ0yIEJ9pHiWnGqSgqGBAt0fRmsYyxEUQpSDzPD6rgDZStnqu33 ejI6wuLvzAPvJPjMVgy5xLtjfTmyRXHolzZ4kqyJUEjjLindDKlcxqAMjdC1bEx6B6 B+Bofz6+b10Hw== 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 20:36:26 +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 20:36:26 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v4 10/10] leds: powernv: use LED_RETAIN_AT_SHUTDOWN flag for leds Date: Thu, 14 Dec 2023 20:36:14 +0300 Message-ID: <20231214173614.2820929-11-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214173614.2820929-1-gnstark@salutedevices.com> References: <20231214173614.2820929-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) 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: 182125 [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;smtp.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;127.0.0.199: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 10:50:00 #22693095 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 09:37:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785279745892266776 X-GMAIL-MSGID: 1785279745892266776 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);