Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp299025lqi; Wed, 6 Mar 2024 18:43:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvQe6EFDR8Gnxfw+v4UKPp/JeTdUkziJVMRy82v8caU6AWru63kZtMG/2J6X9qznc4U8bddw/T8gIfP0I52I0xfK4G4n3j8e0ODQfPSg== X-Google-Smtp-Source: AGHT+IH4D98VeKjAacBCUU6gkYihDG6rSk3GkS1HN3Mu3oWZ5fL/I9a1eYh5cFsf36SGns9FgyUA X-Received: by 2002:a05:6358:2926:b0:176:d5b7:344a with SMTP id y38-20020a056358292600b00176d5b7344amr7708959rwb.29.1709779394047; Wed, 06 Mar 2024 18:43:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709779394; cv=pass; d=google.com; s=arc-20160816; b=G3X9wFu210szd48F9aYxipn7SSlEUlGTrwjIq6vPPR5qUxTP053pWiC+uCbDKxQF7F p6PKzaeO81CKvYtPV2G48FUOb6ALs6UQdK9X9mGDhHXFGYLUIqnt6YWIZE83bqrFIBG/ UsQ0T7G1a61Xs0ZAm/h/9oNDWh86KltdJa1iahBmTNzWcMx0YBUlbJgc/d4xXBoORNz1 iwMYHSuYzo1Gui0FyZNB2eRM9aeP+YZz4QUf8LDV+4aN0hDR9KRjBwDhA79mtXt8pmbf EjRzPx7ShFyKXKKol68T3JVZmxqHSrpzauXSi1ocRHgV/cokOfx6VDle4PJkb88t/n08 k98g== 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=Bkl04M4Q9dlulAekKlywy7D7nTpH9wfEkBOjS7/HBXY=; b=VbvBW4TWO8lPFmPbucpi2uUoWKsf4GpcfGJUkwmFK+3ysns3PtZ1gjAqUlskb7Gzgm QshJrRAM4IFLkJgYOcqfakSDoS3sLb56V2kROkPrMysihUVQrb78bgJOQPQ8f6gtktD/ qzZR08Oss6nzWNNSm+7nE3H8vVjua+1JlIktROjFi1s9Azlad5wHzXLRAfw0bWjWlOhx EKFODenZAWb37kmQTy2KNS44gE/c+MnzBSv4gJ3zfNabm5pdP25b78tp3XT850my+oAt 74WyLse8mM5R/9tu9C+bvkdAGXNw82Or/D1pGGF7eT64nnXbMmbR0i0sqtTJ3HqKKFIv IqbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=vtfXGAQ3; 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-94874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h24-20020a63f918000000b005dc50696f28si13112724pgi.725.2024.03.06.18.43.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 18:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=vtfXGAQ3; 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-94874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=salutedevices.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 592DF285976 for ; Thu, 7 Mar 2024 02:42:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EAB01CA8E; Thu, 7 Mar 2024 02:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="vtfXGAQ3" Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 680A51C27; Thu, 7 Mar 2024 02:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.89.224.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709779256; cv=none; b=sblV196yRZPBhH9io5UffXl40dDASbzMaQIt+ipCamRcbRD1ah2ez8Cnfh2Xa4XRhvjzh004gl5IdKIYJo3l3S6KBXt3z26BSBGtW7L+41tnzcbYUh5OrwMT6wU4R4xJpToyQaDQmUIFvEqRFwXTQJerXLES5X/XkHakBnilObg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709779256; c=relaxed/simple; bh=pBPynPtz/V7v/h5wuWtgu0O4YV1eNNCWoKb2hnz3ZPk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EzQey0ss4I0LpIHvME1vLo5hpTmvUy9BGR4A/hZC0rCGLXl3LwpyFYLyFBQ0ekg23pKo/PSv2yN5XuRzTULb+gnba604MUAwY3BiKWEwPNj+x4Acbg36rmYSz1DW2oOFyjwH7zzEkq30rbsECM+2PeUgUMzkP1MDR6Bbb/AbiiM= 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=vtfXGAQ3; arc=none smtp.client-ip=45.89.224.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 8256F120021; Thu, 7 Mar 2024 05:40:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 8256F120021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1709779245; bh=gPoYxl99hZw4r2GrN+UX1NkBh/kze2TFpy26yv3N7sw=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=vtfXGAQ3hrwUHgW0YKhiJaXoT8leKfVpXR+Z3J1UJpafb3gPvsfB2Q0EuFQv6s5CE J1Le5Xzzo28siZ9fEQw6OVf68dJGh3VPcW3EL3Fc1cBqmOXXWRMjCDGlV9xm8Jp47S 3y83p1ybkSzi8v9OcgWezZV2Ixtv1HS7RJ2k3qiJebWNQw7eOnHmt4MlGY/U8DTYjK i4uN592ubjzBdlUqWG5ZUn3j9ygjelCpyO7riXWDt5tSlsgn6aUIWCq0OhiUjGeJwP gf/gEUgA5tH6zeFPHgXX8pr3l4D8BBGVFwmN89U9/etGjQ2DcZNS/hyG8BlB8AxI3t 9btS69O0ZR7GQ== 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, 7 Mar 2024 05:40:45 +0300 (MSK) Received: from localhost.localdomain (100.125.24.169) 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, 7 Mar 2024 05:40:44 +0300 From: George Stark To: , , , , , , , , , , , , , , , CC: , , , , George Stark , Nikita Travkin Subject: [PATCH v5 03/10] leds: aw2013: use devm API to cleanup module's resources Date: Thu, 7 Mar 2024 05:40:27 +0300 Message-ID: <20240307024034.1548605-4-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240307024034.1548605-1-gnstark@salutedevices.com> References: <20240307024034.1548605-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-a-m1.sberdevices.ru (172.24.196.116) 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: 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.125.24.169 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