From patchwork Mon Dec 4 18:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 173497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2940278vqy; Mon, 4 Dec 2023 10:07:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwQx8lfI/3X7OuPK5OkBlZ4zgiy0SZwsSUTqDwpoZnUrDfUBWXfD6hvXgiz+JsOKKyswpp X-Received: by 2002:a05:6a00:2d11:b0:6ce:689d:e002 with SMTP id fa17-20020a056a002d1100b006ce689de002mr143797pfb.42.1701713253856; Mon, 04 Dec 2023 10:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713253; cv=none; d=google.com; s=arc-20160816; b=oyf8Kso9eFf/n/uU2ZdTEVlsvZX7n6tAKM7ye+VgVWgjyKV7unNE02oKJIzmPY8XEb jeEr8XZZFewQjegIV/NPsxzY63W/e5HaTnjULsoqFNKXQd8R6EHwypgg6to1nb706rTR fIgZr23kArAH/MGE+24zAaWt0gHG3eFuIdHKLvIlI5dnlHUzmdcvgypAOj6420XLd2+Q DFLreFO5VIdpu9cB77yA/XjFx3teoWqSixZm5PsfkiBDpEuCIDeqUiRgOpjFqBgadRx/ /0f+ZbOBLlR2dOpI0qJPwWZeA2ByLiXkYUDxSRn20zuInxpKgFFoCOHQ+kjQHoHfyfwj xMxw== 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=C1kd2llJNcGGgAraxX7oH4BfSAuepfS4aqwkW0KOQ7M=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=kdcWVHURjSkAEpBEb/ERvZbRGjve+JvcRVOLM6d9xp6WJ5WUXK7RgoeCnviw4onPam hBONYfl88gOLNchbggObb6x+itkk+Ba+2qOEeWXcnyy4s45GhBQwB6lJvWm0eQLkvCtn f3ycsPQ+OZST2cXisIv7HxQDWs3W4bzWg5mSI1vzwaIw/h1lZDnnqyEFRwXTX1yAPHS+ KnojM2jXzfrxoH5BvfPTuCdNINxCnfONCPnJEXXHls26MRZ6lj6vnbvlSctkGd1ILPmL 9lFCWdKjDHotrwOiVejrBieMojrj7eRjqVEfG5QXOUu2ebxVPm5abdvZj0aL7NBR1LeB wYPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=JMFIIEw+; 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 cm3-20020a056a020a0300b0057755b2f032si1902441pgb.542.2023.12.04.10.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:33 -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=JMFIIEw+; 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 0C36480AC5A8; Mon, 4 Dec 2023 10:07:33 -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 S231803AbjLDSHW (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231783AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68886FA; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id B7D4610000A; Mon, 4 Dec 2023 21:07:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru B7D4610000A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713234; bh=C1kd2llJNcGGgAraxX7oH4BfSAuepfS4aqwkW0KOQ7M=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=JMFIIEw+TJjmTZaUN2hwxIHFsYUAKZELyeJ7UiXtfsZsEkB9YNKyGrv8u/3IuFsZ9 bZrWfC857T2TXB2I0K/DzVOWPR7BRbDwfryP1rrll4TFBsXiwNcP+lADCmDOWittk/ L+cWaFO7Nl4L8x2di8RLkOv+n3yybtqNQgv/gqmcv7LreFSu8i2Bp/LTuKuMxO0KaI WGRNqhOCwXFAGujYvFY3nyP5pzCcBga70Org1s2OtNXM2wbXqIDtT8CjKUrYhFuhCD ZEopm8HY/eWEi9hELx5HgO/SW+s2CPEwIC84ryMu5wrcO3sBXH+m6xG6o5AxSlj84p zLb3c0DjmwJdg== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:14 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:14 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 01/10] devm-helpers: introduce devm_mutex_init Date: Mon, 4 Dec 2023 21:05:54 +0300 Message-ID: <20231204180603.470421-2-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/04 11:06:00 #22624476 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:07:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784375676703290860 X-GMAIL-MSGID: 1784375676703290860 Using of devm API leads to 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() is extended so introduce devm_mutex_init(). Signed-off-by: George Stark --- include/linux/devm-helpers.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/devm-helpers.h b/include/linux/devm-helpers.h index 74891802200d..2f56e476776f 100644 --- a/include/linux/devm-helpers.h +++ b/include/linux/devm-helpers.h @@ -76,4 +76,22 @@ static inline int devm_work_autocancel(struct device *dev, return devm_add_action(dev, devm_work_drop, w); } +static inline void devm_mutex_release(void *res) +{ + mutex_destroy(res); +} + +/** + * devm_mutex_init - Resource-managed mutex initialization + * @dev: Device which lifetime work is bound to + * @lock: Pointer to a mutex + * + * Initialize mutex which is automatically destroyed when driver is detached. + */ +static inline int devm_mutex_init(struct device *dev, struct mutex *lock) +{ + mutex_init(lock); + return devm_add_action_or_reset(dev, devm_mutex_release, lock); +} + #endif From patchwork Mon Dec 4 18:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 173496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2940224vqy; Mon, 4 Dec 2023 10:07:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfMQjT9sFT06kvCGqDle9J2vsF0foXpj5diKPgfgNuUTf1nBC3CZg4xdwt39xAkuOuCEyT X-Received: by 2002:a17:902:ba93:b0:1d0:6ffd:f234 with SMTP id k19-20020a170902ba9300b001d06ffdf234mr1609886pls.138.1701713250232; Mon, 04 Dec 2023 10:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713250; cv=none; d=google.com; s=arc-20160816; b=VqqIib2RnMt564XSH+WwSu/bfxXCPBScdtEzQ8V39CLO8+s8EUQKw2qQCvOVO4u7N8 viK0GMM8MFv+oPhi1trdQAGzYlk0pGXW6UDIHHumZb0s94TK4Nk2Uep1X08edWEAJhYL HTzXdA4+wF5HPR6zVCdw6424Iy1No/tndh3/ABZN6CRhJ/vYLbxLhtJLJ5rxm4+EwjJS A1kSv3CT+AxkFBzBx3gASzNx1U1PLtyI4rOyQshbujdhrf8c1RteEPXqwqI8TY4tDCJZ VmNKwXTdkdxSukEIG4Jp5JFgCEN96KwHcyAz2ziG25+TRa58Xtso8smFJrFaY4GnHPdQ Syuw== 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=d8YylvO0HU+4GQf+TTFQ6STuqvCB6UYaTCNR2JumiPA=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=pyZxksoktejO5ZtBUWJvEnBYdlR/x6DUt7mu/WDA6bBpb8p6yETD/wKyo7SFMYft8N WQJS9/TxP26Cn5LaQFUhPkuUMtZzXqM+8uj1kOF/Tx3QjnXzWx5Z2MYwPl3H/Q03K4IZ r/ugcrB8Hd2ZxX35CPwGIK6oi1EwzB41nHILFG8EN9zTf+xyRoO9XD53QtXC9o8W6Nbo CSiuuG8JiB2GSCuq/E7MnPZDfhJLA7Kc6nYOMgvNZBie5B2zKVi3WktFOrsEKFEFqRHX dwMKWkCdEq1wHWwvL3zDyDqVh4H+Sk9nhU4Hv0m4k9PLiNJQuKSs4VgzIYeyxsXa6vYz xpjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=b4Oum7vj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b15-20020a170902650f00b001cfb4bd0e36si5994088plk.341.2023.12.04.10.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=b4Oum7vj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2E43180ABFEB; Mon, 4 Dec 2023 10:07:29 -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 S231645AbjLDSHQ (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DC9109; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id E09ED10000C; Mon, 4 Dec 2023 21:07:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru E09ED10000C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713234; bh=d8YylvO0HU+4GQf+TTFQ6STuqvCB6UYaTCNR2JumiPA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=b4Oum7vjao8QFZ4tE78SOvrwMO/aOqJsA2M1wdA9lpv/7TjEOD7kdaiYWFSmKhDGX W68K4Ng3qvkEdcCy3/RD6ubyV05jBnAS/qxoOcnIbJiKDol0byE7VpOQtAbEQ0IRzx ElWkA7MZkVeTPmJV9kp/rYqd/az+8zU70vHrUucxTGbYzr8L42jYPzpPcgtNlod77E Mnan6JsNC8ZXiu9VzL9+fWBbnA69TWVJyO2MYyq20YKlmw2qdxn9gUGG4ZSR2GaWDk Et68R647fEWjtzWT8GJ4UGd4cgb6ZPvuTKQ5UbHGhJUdB/5VLFuh8OimkqlANlu7hU NhgHVafzVX2WQ== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:14 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:14 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 02/10] leds: aw2013: unlock mutex before destroying it Date: Mon, 4 Dec 2023 21:05:55 +0300 Message-ID: <20231204180603.470421-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/04 11:06:00 #22624476 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:07:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784375673149967156 X-GMAIL-MSGID: 1784375673149967156 In the probe() callback in case of error mutex is destroyed being locked which is not allowed so unlock the mute before destroying. 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 Mon Dec 4 18:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 173498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2940301vqy; Mon, 4 Dec 2023 10:07:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUGq24IP8JN3icAKxeRT2XZn1Hi/y0lsdGugzLDGLdZB2WJKqBRl31G//247CTj3d3UAj2 X-Received: by 2002:a05:6a00:2448:b0:6ce:2731:47b2 with SMTP id d8-20020a056a00244800b006ce273147b2mr127100pfj.18.1701713255015; Mon, 04 Dec 2023 10:07:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713254; cv=none; d=google.com; s=arc-20160816; b=t8Qb6UTGGLZImSM9qHjlEiut1QFSZETje0QgD3yRkxwZrT5KHXvdRuZDA0hWWrzawE u/4clcJmJ8M2DgKUyfUg4w7Ipu99tylyp8wb73AI6Mq6x4xK0LLRiPTfeY2pevvDnl9u OALMr67skrq5/qWZQPt8jNHcR28aVG/ZJI2SyYfngR+SAxDtPwhqNOpJVJUhdgxBirQ/ 9VuOV6Sk0pfuZuWwvZZ3fK3PrH/KAF4LN2JG/r9dHzX/vfnF4hPIh9JOsU2szV0xb6u8 VK3nv8ZrdC57ObmNOq0tbeNsj9YbTRn51yLe7JJITk7qDKdn7g8PicXioqL3Y8Z3MBfY RlDg== 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=qL7h6jprywDr6fISYueZDzA2bOo7TS7aT4PRmSDkI2I=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=vJJNjLFTdc4+VmlTFqKK6XyGxCgX21D8Qax5gq0wSpqxnrlT2WGgfAf/FH7gQSnwjh 3G+ofRAgbz6BQaFmNfac5Ho4ZWDpdgu7w2z7bsHd3WgiTjJokoEfvZt/e+Gr8pceoQUp kUjJkNLKfeDMm9hCVb4sbMC4I5ekAApja8wMDL0jEofQLRnIHB3gfT2zBrRLJf4DdVYW +BrSEnoUW+Ej6Eozl7y6BSk2dSved71UG2qJ1cWHEzxl0tuAtHsdgNuDdOOs1FfUpGB1 7+8hR5dQU6qGPVenRnpYxOMlwCDVBAnPpishz8Lfy1zOMfnxjE1rT4ZLa8n5+UVwyT/F Ir8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=AXHUIPIp; 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 k16-20020a056a00135000b006ce45456a1dsi2857885pfu.184.2023.12.04.10.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:34 -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=AXHUIPIp; 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 7838B80C61A2; Mon, 4 Dec 2023 10:07:32 -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 S231683AbjLDSHU (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B7FA119; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 1573310000D; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 1573310000D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713235; bh=qL7h6jprywDr6fISYueZDzA2bOo7TS7aT4PRmSDkI2I=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=AXHUIPIpepj4mQIREeF1kPC+nP2Aeg9UgKbAaF+a/4Og621TFJQudDk4CAmH1u+xr GqcDgMerISDiO4q8KtuHwNhymJ9MyfcKFAxc8c2XCIYw699xRp+PWBeYWVKQZoOSKE Rh4MdF5tAjhSiMKlAteb8s2h9f7uoFFepa2HjfoAHr5PnsvTA0/3ML6ZMoPfhGDi0V rjfGtTevCdAkowz7R0zBmygiQCGMEYbYRdKL7xsU5Kty0rYH7Q5ss9uWAgejTZHyUz P7T6DS9QgKBBFH1Wb7GMLfED2orgtYZ8yh6XrKEKt+tICBCt0BBqRyqMXx5HXo1Inx 5i/pIBi4Oky2g== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:14 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:14 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 03/10] leds: aw2013: use devm API to cleanup module's resources Date: Mon, 4 Dec 2023 21:05:56 +0300 Message-ID: <20231204180603.470421-4-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/04 11:06:00 #22624476 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-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]); Mon, 04 Dec 2023 10:07:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784375678130439535 X-GMAIL-MSGID: 1784375678130439535 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-aw2013.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index c2bc0782c0cd..1a8acf303548 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,13 @@ static int aw2013_probe_dt(struct aw2013 *chip) return 0; } +static void aw2013_chip_disable_action(void *data) +{ + struct aw2013 *chip = (struct aw2013 *)data; + + aw2013_chip_disable(chip); +} + static const struct regmap_config aw2013_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -334,7 +342,9 @@ static int aw2013_probe(struct i2c_client *client) if (!chip) return -ENOMEM; - mutex_init(&chip->mutex); + if (devm_mutex_init(&client->dev, &chip->mutex)) + return -ENOMEM; + mutex_lock(&chip->mutex); chip->client = client; @@ -378,6 +388,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 +412,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 +428,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 Mon Dec 4 18:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 173499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2940338vqy; Mon, 4 Dec 2023 10:07:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCchlF1mV+GUM6i52n9nIUGNdtd7n+iY91Rbtyz7+fVPSL1tVAb+NemXQA+DlGhPqlepvL X-Received: by 2002:a05:6a00:806:b0:6ce:2e2b:17e3 with SMTP id m6-20020a056a00080600b006ce2e2b17e3mr6159494pfk.7.1701713257281; Mon, 04 Dec 2023 10:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713257; cv=none; d=google.com; s=arc-20160816; b=B3lAHi1v9cLFmfnEQYIwg3VSDd2Rb1w7Pxrynz4V4FgrWdFRA+TZF4IDfBoKaC0GZD B8Vk1F/ojVz5XCiKxZ+G15ZzcWQmGJevW177xDovW3V/FkAAry4cuiiQPQvt6dvyoHWA pp8jq/QfAj8Tc93j4yxa9nD2tPE2lXVeov0wLsy3guM60XFv3Z+f2ijjv+pWDsDCH9oC eDzrfvKXWsBouPZtsWbHKozq7b4UUMnMYQ0Nd4svakdd9KwP4lcZf4l3ZDj1tv2pq0r/ uleogNL8oX1DSSS3Ziy9Ho/1ZAd3ycjg5pAfsXKIZx5U5w7W7gFKFL6vrPZNnUuNn4yE Jsmg== 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=Ti5QsKGkbG/5u0LYCNy7EDAXvqFHDiHlufLQ88xPdok=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=AD7KrtxF+pkb9jBbkjA4S2fVX1rXx/W97yW6l6WtzY7PhIRrMsz7PiT6Toc6GjBQk6 2LXES2NBCybIjuqDna/KN+pN93JtgQAvRlsv4IOAn6Q/Dcwpa3nhLz0CakgxBmqwvyOT NzQe6VzGx8bLGsDPakh8wC8Vv09seiDcVO9RRVHOwhIAUoKggQZfP+hYwZotdtFDh8F9 ZaCCsEjjovtKZisVN3yhK+aNNdBrflTf2FkZYr3mD5oFaWIKVOscuTqu8Pzd9ybXiaLa jl94SUDnp/uTU48iYV0tNvXE9UEL7erRQKY5I2XCA1chYdRS72P/ByyaZO/6m4Ht/cAP o5dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=c8AQZM1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id di3-20020a056a00480300b006c0035ff9dasi3092308pfb.198.2023.12.04.10.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=c8AQZM1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 8D5D28069A23; Mon, 4 Dec 2023 10:07:34 -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 S232802AbjLDSHZ (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7D04124; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 42CBE12001E; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 42CBE12001E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713235; bh=Ti5QsKGkbG/5u0LYCNy7EDAXvqFHDiHlufLQ88xPdok=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=c8AQZM1dR6KcoM2v6wzY34v4GR+14PIdcgDZYDY6IVyfhdFzasji1RW/KIiShlG2K m1FbNmltCo0Q2k+BbA0D4rCd3z9rHlV0khsv+bG1bbLMgEvD+Jq3oyaTgFFsOSZMlJ xU1lsUlGXzNizIs7GcYfjYeVfvQMDIbm2dJeTIRc/csAZcOJLOr+9h3ei1rAkctW7F SIhJ2dGl1o1bZnMeLPyC87W83rQQAIqb1BxEvNQvJq+fLold0Wy0msjOSOtab6FsaC DzKu8mnW9PeKyDcZMifdwDTQKeUCO57eRwI7MhVbOHkzdboG8orhfMFv+0/s5TsaGz gNXjcONSoH+yA== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:14 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 04/10] leds: aw200xx: use devm API to cleanup module's resources Date: Mon, 4 Dec 2023 21:05:57 +0300 Message-ID: <20231204180603.470421-5-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;100.64.160.123:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1;salutedevices.com:7.1.1;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/04 11:06:00 #22624476 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 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]); Mon, 04 Dec 2023 10:07:34 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784375680614045758 X-GMAIL-MSGID: 1784375680614045758 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 | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-aw200xx.c b/drivers/leds/leds-aw200xx.c index 1d3943f86f7f..b1a097c7c879 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,20 @@ static const struct regmap_config aw200xx_regmap_config = { .disable_locking = true, }; +static void aw200xx_chip_reset_action(void *data) +{ + const struct aw200xx *chip = (struct aw200xx *)data; + + aw200xx_chip_reset(chip); +} + +static void aw200xx_disable_action(void *data) +{ + const struct aw200xx *chip = (struct aw200xx *)data; + + aw200xx_disable(chip); +} + static int aw200xx_probe(struct i2c_client *client) { const struct aw200xx_chipdef *cdef; @@ -568,11 +583,16 @@ 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); + if (devm_mutex_init(&client->dev, &chip->mutex)) + return -ENOMEM; /* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */ mutex_lock(&chip->mutex); @@ -581,6 +601,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 +619,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 +667,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 Mon Dec 4 18:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 173500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2940348vqy; Mon, 4 Dec 2023 10:07:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEb+7rxtaBvvUlOQm8xsPXfnG8RjotstxZSW0w0uN5K0POCTcP8XN8ICGYdN9CdGjPea4wb X-Received: by 2002:a05:6a00:856:b0:6ce:2732:28c with SMTP id q22-20020a056a00085600b006ce2732028cmr2267316pfk.59.1701713258008; Mon, 04 Dec 2023 10:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701713257; cv=none; d=google.com; s=arc-20160816; b=JQY6OJCvKLHD6pjGbhlpFSxoVqPe1/ZIlIpDTdSiySQ3ma2BfH3DAXz7vaO/xTQSml 8a8dKmHviTdm/kJjo8Rt7DwsF9jeGnUjHL7/NwR3o2ffhnvjhPPtWiBHihtJLc5qn93z w1R1dVU7/uSoJoAbC91mzakJmRZKLlTszuUqsi0+TYss+qjrn6AVaObYH77p5Szema6C wuyon+A3OrHxEptmgWtPhN4uFXlPXWhy4KsCadwiDy48CLDDqCWbj3BYKEVjmB2/D6Lv B2ZWNhULPFgIqJEunDHDpXWSs4cp88Se9V6JHR4z1eZY3lmsfxMeT58164PNQeoCHfuH xBfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=aevEy7ZXFtoB1it3KHBxLYqLuMYAMZ1UYECEx9o+AXQ=; fh=pRi79UjbBxWuX+YtUUQtxvW+xSh0P2pNtOkO2EuISps=; b=qey/zEDyWRvQp4AKPxdHkBZxebxMtSWR2Xup/uLPrmZOtC20ZZhwD9/elFqJcYdaXb 1wrvdYbOAidmpQXF9Wy+a1O9FuAkRPYzkB5GW4ebb24lqC+afquDcTXZm6eXLZ0q1sLH sERTzjR+gCiiU7zGtdFcFoJeMA1oWUpRvppMaR6Q5E+hLIExK3phKs1xwLv6xqTM9wbU lD/TBh6/UtK2EL1LljTMkM4BT60tHGcKfJgG35H0YHHzAVkaHXV5+go7As17acyC4HJ+ nCzBWU/1WtE++weRiqJFV/VsBxTCKvZQMpR5teYCHtc1NgqrzNSL9GihCQxMumqkfv/Q /pSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=IspV7GNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b4-20020a6541c4000000b00557531eafb0si7935100pgq.559.2023.12.04.10.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:07:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=IspV7GNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C76D080AC5BB; Mon, 4 Dec 2023 10:07:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231922AbjLDSH1 (ORCPT + 99 others); Mon, 4 Dec 2023 13:07:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbjLDSHM (ORCPT ); Mon, 4 Dec 2023 13:07:12 -0500 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8FE130; Mon, 4 Dec 2023 10:07:16 -0800 (PST) Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 70C8F100011; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 70C8F100011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1701713235; bh=aevEy7ZXFtoB1it3KHBxLYqLuMYAMZ1UYECEx9o+AXQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=IspV7GNP+VQ3nE1DeeJh+fzKkDMRBaVNiYt1Pa6frUHtzwZZzvaOmBZdONZMT3weO QFBxVXgwfRvPYu9QjORr3ZRs38fubObXfdmFXtnwOIZ3bisyAZCfb87O0tYUdtKCGu F5nJXkaI8vLsisUJqLasgAtLMAUfynaqQxwAQftmP/A/mHhlUNU3ZpQfzTJKTa1gpg 7pWGSAZyKUGX7o7ZV8BbcrofYCgTW3XyTJrQ+PS8x54UGr8FBgF3vBlr2kl94djzBw S/9NLBsrmM6Op0U+n340Swl9cRmokuWSRWDOsEZbb29C/3eP5i7R2V51DTy99Hm+Jj qugDfLwyWEO6A== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Mon, 4 Dec 2023 21:07:15 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 4 Dec 2023 21:07:15 +0300 From: George Stark To: , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v2 05/10] leds: lp3952: use devm API to cleanup module's resources Date: Mon, 4 Dec 2023 21:05:58 +0300 Message-ID: <20231204180603.470421-6-gnstark@salutedevices.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204180603.470421-1-gnstark@salutedevices.com> References: <20231204180603.470421-1-gnstark@salutedevices.com> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 181831 [Dec 04 2023] X-KSMG-AntiSpam-Version: 6.0.0.2 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 5 0.3.5 98d108ddd984cca1d7e65e595eac546a62b0144b, {Tracking_from_domain_doesnt_match_to}, salutedevices.com:7.1.1;100.64.160.123:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;p-i-exch-sc-m01.sberdevices.ru:7.1.1,5.0.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/04 11:06:00 #22624476 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:07:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784375681544180976 X-GMAIL-MSGID: 1784375681544180976 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, };