Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp249862lqk; Thu, 14 Mar 2024 01:51:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdZ61VlbawVhPloI0/qGK9N8qXrQCzzYid3h6051Mrhkz7zSTVyI73a8zezwbr+iX/B+BvdCY/LSVqGOXu8hVD8K6dlt7tDpVdpWnPfg== X-Google-Smtp-Source: AGHT+IHA3tVYBvzZcuVgUnASi9jxgCYhm2ARfPv7B9AH4Bqs2R/IAzk8sWS7e1uNURX4uVgFlyoq X-Received: by 2002:a05:6358:5304:b0:17b:f2ae:e561 with SMTP id n4-20020a056358530400b0017bf2aee561mr1135049rwf.30.1710406294894; Thu, 14 Mar 2024 01:51:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710406294; cv=pass; d=google.com; s=arc-20160816; b=LDs/aKUa3JvFdAvmC9gfVgYYo0JajzpiHl2S6KUiKbI5B3KUF47S0IwVW07mYEahWU zrfN1WgIXYz/ALPGqr8lxEv5SOHeWzhmh/tyqGItW9ho36MCtvPdORQrP5kb3pv2FFsx wPdJww1Kl20grZFUQHjPTNzvi3yBpgQ/Meo2rv9mEZW0J2rsx38M0HTBFLzs8MlTvPkR RacCINKUBUg0fuJ9o2UjpVxfi/Rlp5OEjno5TlWECEHKgbXdYILAArHAAu/YN5txYUC+ w5+R4mBr22tHt4r0Klj49xlZj8AstNQe3uNAT9kuRr+DIyHHv9fu4qRO8fV4JOnoPoXT bLOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=gPoYxl99hZw4r2GrN+UX1NkBh/kze2TFpy26yv3N7sw=; fh=h2yyXLE6AzHKzye/anu0e2rwg/0TTd6ncPwPbEf4c3s=; b=LrPZPpFCw6/KZRTt6hBws1PCIceGxd8RCtHPVU5U4BUAhC6hkbzl+6wk1WwHiwUTor i6z2yArHuWDqjgJCxYvOQx7YcH4KgL5xyyuXNGuXUKwdaV9RhV2/R2hBqIg4C0BUwXYS hR+95qukUSqs2hvduWXi6cPitr0ZlT3/+wIBcmelsuvRx6qIuQzAcNLH73PmK/29u9gt ohxYyWA8Bv+xdpigLgTO6AmM4L5XpJHGw42lYU65atajY34V3ZaiC1FZXCKHYBgM3Euh vJnLF66GYu4Une4xxAiQ0eSgKEcomI0Etc5uTR+fueyOe2Qzq4Qhys5K2HADwuAjDz6m 7T2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=Tdql683r; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-102993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u21-20020a632355000000b005dc080c3e7csi166733pgm.86.2024.03.14.01.51.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 01:51:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=Tdql683r; arc=pass (i=1 spf=pass spfdomain=salutedevices.com dkim=pass dkdomain=salutedevices.com dmarc=pass fromdomain=salutedevices.com); spf=pass (google.com: domain of linux-kernel+bounces-102993-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102993-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 471F6B247CB for ; Thu, 14 Mar 2024 08:47:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 243036CDD0; Thu, 14 Mar 2024 08:46:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="Tdql683r" Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78C986BFAA; Thu, 14 Mar 2024 08:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710405980; cv=none; b=famOxHg/KdlzBpe097vsGjDz88yiWMVph8sMqoNOicnQiD4xa0f1DZ8dVI0ZbR/7M9pmpv8xA0uk/d4cbLtFv4+YgvcXRSJ4wUpFxkcz1id8SgvcV9lAeJxjwZjH0C8g4HlbYSgcLKXQDyXVbiU9pywq/qo9DZ9UyIT8Fx9fsEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710405980; c=relaxed/simple; bh=pBPynPtz/V7v/h5wuWtgu0O4YV1eNNCWoKb2hnz3ZPk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iRs7D0U+TEZOXjYjJNTxXP3CZWsOY6SSZjzzRAb72kz0kTsvan9oBb/ToaQmu0V7hQPOCMNw+FQi2ctzU//e1drjq9Lntq8G266GGWfb3wqnfmY6nc7JsIt8TN7thpvNujSgicTJOzz7BIL8CZI44U6jpPZH3y1LQgEh+joKa8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=Tdql683r; arc=none smtp.client-ip=37.18.73.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 2FF53100015; Thu, 14 Mar 2024 11:46:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 2FF53100015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1710405974; bh=gPoYxl99hZw4r2GrN+UX1NkBh/kze2TFpy26yv3N7sw=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Tdql683rDRQPyaaVzvScBzF1FKUiwIDrXPJQTk8TzT7Oi7TN/yI4VBXOwDoOKS2Rl i2oz7eZ1XIDsI35xJ4W8ueWToYVbm8sRMlvb6FDxrdbHHi87I79K849W6u+RKp6TK+ mVeSr26kA6FA5U3AgtixE6GrYmKrQZF6c6Q/Cb1OMOctvfeA/Y04VOmBiRtnu19Nyg rfeDOFgqRNzZEcPKy6Ru8G4wySuLTNSqWJwii87NqmQSDyn+d4KatUnwbrLYp11Zud dmnclthsgKTT1i8LHiBgNc3/a82emgQcU+NExGC8y+T7elKiRSrGAE8mjYd3kD4vZv dn2rcynvvfx/g== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 14 Mar 2024 11:46:14 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 14 Mar 2024 11:46:13 +0300 From: George Stark To: , , , , , , , , , , , , , , , , CC: , , , , George Stark , Nikita Travkin Subject: [PATCH v6 2/9] leds: aw2013: use devm API to cleanup module's resources Date: Thu, 14 Mar 2024 11:45:24 +0300 Message-ID: <20240314084531.1935545-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240314084531.1935545-1-gnstark@salutedevices.com> References: <20240314084531.1935545-1-gnstark@salutedevices.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 183875 [Feb 29 2024] 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}, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/02/29 19:21:00 #23899999 X-KSMG-AntiVirus-Status: Clean, skipped In this driver LEDs are registered using devm_led_classdev_register() so they are automatically unregistered after module's remove() is done. led_classdev_unregister() calls module's led_set_brightness() to turn off the LEDs and that callback uses resources which were destroyed already in module's remove() so use devm API instead of remove(). Signed-off-by: George Stark Tested-by: Nikita Travkin --- drivers/leds/leds-aw2013.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 17235a5e576a..6475eadcb0df 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -320,6 +320,11 @@ static int aw2013_probe_dt(struct aw2013 *chip) return 0; } +static void aw2013_chip_disable_action(void *data) +{ + aw2013_chip_disable(data); +} + static const struct regmap_config aw2013_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -336,7 +341,10 @@ static int aw2013_probe(struct i2c_client *client) if (!chip) return -ENOMEM; - mutex_init(&chip->mutex); + ret = devm_mutex_init(&client->dev, &chip->mutex); + if (ret) + return ret; + mutex_lock(&chip->mutex); chip->client = client; @@ -384,6 +392,10 @@ static int aw2013_probe(struct i2c_client *client) goto error_reg; } + ret = devm_add_action(&client->dev, aw2013_chip_disable_action, chip); + if (ret) + goto error_reg; + ret = aw2013_probe_dt(chip); if (ret < 0) goto error_reg; @@ -406,19 +418,9 @@ static int aw2013_probe(struct i2c_client *client) error: mutex_unlock(&chip->mutex); - mutex_destroy(&chip->mutex); return ret; } -static void aw2013_remove(struct i2c_client *client) -{ - struct aw2013 *chip = i2c_get_clientdata(client); - - aw2013_chip_disable(chip); - - mutex_destroy(&chip->mutex); -} - static const struct of_device_id aw2013_match_table[] = { { .compatible = "awinic,aw2013", }, { /* sentinel */ }, @@ -432,7 +434,6 @@ static struct i2c_driver aw2013_driver = { .of_match_table = aw2013_match_table, }, .probe = aw2013_probe, - .remove = aw2013_remove, }; module_i2c_driver(aw2013_driver); -- 2.25.1