Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5839387rdb; Thu, 14 Dec 2023 00:31:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvieuU2Fqoni0ZM8TOiAngXNIeW8pBe34hGSsRf5j6YU1W0PhlgLutAC2dzd3xoBRv4g+V X-Received: by 2002:a05:6870:2107:b0:203:196e:d602 with SMTP id f7-20020a056870210700b00203196ed602mr3419724oae.75.1702542682782; Thu, 14 Dec 2023 00:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702542682; cv=none; d=google.com; s=arc-20160816; b=dJ27b89oEd/9C14kSmgQivo/Twzhf8O4ObAaFidu/0/ch/qQ1J50eS7a328vz1ALL0 rIUKOA+ifMVPEoGnW1/LJKAiBH7FDyJO4NXJDptyhI6Im+s+VlitHlpK/eV5ZQ+tpjr8 mSjtVjseO5mmCbE3m3l2HnMYbIj0If8myktYR9J+4WIaUkKlP0g66+F43M42HHWLXCkw MTyPIDdxF01omMqgHQZTILeWpkviXAlQEwG2fN6u/dEOx0b2+jQoxqZ7DXSnhZwoacae wBxit27YzjTSX1Gdj9aez2H053keNW6oYUVASnvf59k1MUKH0e8nPfOS3DNKhZhbKgFm dqDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=k3WMJ0GNwuGRczuP2LxdxutooPucV6JPLeqyGQDEPIA=; fh=VGV6ajQ72e9w8REvYqgUr7SYaKNgFpS3GtVmljO5VrE=; b=SY0yF2JaPVJwXji7MJgGI0raSvtk98J6D/XQu3kTmZxJ7eSQMWkqiAFKdWCYPBs7HB qoSZSwWwVybzmIkyTjtr2neRBIjr3AyNd0Sdj/x+Z63QAI9auGibhkBxyOtNbzwvAa3+ DthRsyBn6vD0Nqj78/pchlIrrbBWx6i8DWoWuHSQAaJ8tCWNoLrHBegE6EVK6HlBuS1A AZBSyojP2Nt2QG4jWDvCRyv+7dDvgTcjW6liHClJe7yL8J6AHbQGw9PkLxO6Qid3JSp1 DKTrT+zsog6WigOwKI6YZWQyQLrP05556y7L14jncsudlkKhWKoB35H2wxT3Q7uSunfN 6SsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=of1Tn4MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s13-20020a65690d000000b005c1cc53612dsi10804117pgq.500.2023.12.14.00.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 00:31:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=of1Tn4MR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 981978088A73; Thu, 14 Dec 2023 00:30:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbjLNIaH (ORCPT + 99 others); Thu, 14 Dec 2023 03:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234383AbjLNI3s (ORCPT ); Thu, 14 Dec 2023 03:29:48 -0500 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E3E0BD; Thu, 14 Dec 2023 00:29:51 -0800 (PST) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 3922312004C; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 3922312004C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1702542589; bh=k3WMJ0GNwuGRczuP2LxdxutooPucV6JPLeqyGQDEPIA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=of1Tn4MRm5JWSFtRnnpDpM398sl1bI3loVSFhziq0an1Mqfcp58dJ8NWZ3hV9x8TG ttbTHk6KPFMrlpdvRaSJGr9Esy179EGMKnpANrgkKDqn57Cpt0YSowxKnapmgy3qFN 5kXd5YF12alRwLC8xE7auXPFz1I+uEEsqt8x3Tk/pRevSHfhVr8EJyoMeeZIKwpd0D R7+EuFWggZUxYrUC1GszOPHbdCq53M5alfHXiyKCu9Rag/osUYHalxhY5nVIk5AhPb CShMmbVYiUzNkB4NNyVu9/i2tkoG8VeCzsvshqWp9bmL0Aj2Up13qUEhHGYTDmouAg PzrmOJzcC6yCQ== Received: from smtp.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Thu, 14 Dec 2023 11:29:49 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 14 Dec 2023 11:29:48 +0300 From: George Stark To: , , , , , , , , , , , , , , CC: , , , , George Stark Subject: [PATCH v3 08/11] leds: nic78bx: use devm API to cleanup module's resources Date: Thu, 14 Dec 2023 11:29:37 +0300 Message-ID: <20231214082940.2718303-4-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214082940.2718303-1-gnstark@salutedevices.com> References: <20231214082940.2718303-1-gnstark@salutedevices.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 182104 [Dec 14 2023] X-KSMG-AntiSpam-Version: 6.1.0.3 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1;salutedevices.com:7.1.1;100.64.160.123:7.1.2, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/12/14 06:13:00 #22683038 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 00:30:30 -0800 (PST) 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), -- 2.25.1