From patchwork Thu Sep 17 22:32:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0280FC43465 for ; Thu, 17 Sep 2020 22:37:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4294208DB for ; Thu, 17 Sep 2020 22:37:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="YmZAuXUK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbgIQWg7 (ORCPT ); Thu, 17 Sep 2020 18:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgIQWd4 (ORCPT ); Thu, 17 Sep 2020 18:33:56 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA921C06174A; Thu, 17 Sep 2020 15:33:55 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 498E0140A75; Fri, 18 Sep 2020 00:33:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382033; bh=LCbu6+SF9pg2hwGFGY/TLzTM7tBJKXuL6iP8UeZY++4=; h=From:To:Date; b=YmZAuXUKMg7enG6rXX50aOCM1XrH1jMnzkFvoedfXL+fdcbzAsxTvcrZDahguyEOl 0RIG1YDSm2WhxYWXS6HbOK+M3Njjad5XOjN1qeKWbZ07EihTYSVs41YK7wmy/dV/di Jv/O2SViFPZOWk5vZdTIX8LQLzhLHlkVXRDD0u9M= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Rod Whitby Subject: [PATCH leds v2 03/50] leds: fsg: compile if COMPILE_TEST=y Date: Fri, 18 Sep 2020 00:32:51 +0200 Message-Id: <20200917223338.14164-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org This driver can be compiled on other platforms with small change if COMPILE_TEST=y. Signed-off-by: Marek Behún Cc: Pavel Machek Cc: Dan Murphy Cc: Rod Whitby --- drivers/leds/Kconfig | 2 +- drivers/leds/leds-fsg.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a008170e73cd8..7f3d16d4f0652 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -290,7 +290,7 @@ config LEDS_NET48XX config LEDS_FSG tristate "LED Support for the Freecom FSG-3" depends on LEDS_CLASS - depends on MACH_FSG + depends on MACH_FSG || COMPILE_TEST help This option enables support for the LEDs on the Freecom FSG-3. diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c index bc6b420637d61..1ffb34baee341 100644 --- a/drivers/leds/leds-fsg.c +++ b/drivers/leds/leds-fsg.c @@ -16,7 +16,13 @@ #include #include #include + +#if IS_ENABLED(MACH_FSG) #include +#else +/* for COMPILE_TEST */ +#define IXP4XX_EXP_BUS_BASE(x) (0x12345678 + (x)) +#endif #define FSG_LED_WLAN_BIT 0 #define FSG_LED_WAN_BIT 1 From patchwork Thu Sep 17 22:32:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09614C43465 for ; Thu, 17 Sep 2020 22:36:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3395208DB for ; Thu, 17 Sep 2020 22:36:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="o+GnToks" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726862AbgIQWgj (ORCPT ); Thu, 17 Sep 2020 18:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgIQWeA (ORCPT ); Thu, 17 Sep 2020 18:34:00 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A5EC06174A; Thu, 17 Sep 2020 15:33:56 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id AD65B140A7D; Fri, 18 Sep 2020 00:33:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382034; bh=jJvOc2XdLe1mhBOZdhONqVvFbjD8Z3fnX62K60JuT7Y=; h=From:To:Date; b=o+GnToks2H1CpY3tK8E7CP00lpn7vNtxiarRbi07022j9IqelYpblTpnGh+GNwAP6 +WxQwI+JqV3pIAFYdWAITa3b2rkjaHNUaFnUCu630kwhwcS642qHQ/6vyTdBx772dJ KHx89Oz+8Wdh+4IE0L35c26evRSTp+0MONGgvOdE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Sakari Ailus , Bartosz Golaszewski , Sean Wang , Matthias Brugger , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Orson Zhai , Baolin Wang , Chunyan Zhang , Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Lee Jones , Liam Girdwood , Mark Brown Subject: [PATCH leds v2 05/50] leds: various: guard of_match_table member value with of_match_ptr Date: Fri, 18 Sep 2020 00:32:53 +0200 Message-Id: <20200917223338.14164-6-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Change .of_match_table = xxx, to .of_match_table = of_match_ptr(xxx), in various drivers. This should be standard even for drivers that depend on OF. Signed-off-by: Marek Behún Cc: Sakari Ailus Cc: Bartosz Golaszewski Cc: Sean Wang Cc: Matthias Brugger Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Orson Zhai Cc: Baolin Wang Cc: Chunyan Zhang Cc: Thierry Reding Cc: "Uwe Kleine-König" Cc: Lee Jones Cc: Liam Girdwood Cc: Mark Brown --- drivers/leds/leds-aat1290.c | 2 +- drivers/leds/leds-as3645a.c | 2 +- drivers/leds/leds-bcm6328.c | 2 +- drivers/leds/leds-bcm6358.c | 2 +- drivers/leds/leds-cpcap.c | 2 +- drivers/leds/leds-cr0014114.c | 2 +- drivers/leds/leds-el15203000.c | 2 +- drivers/leds/leds-gpio.c | 2 +- drivers/leds/leds-is31fl32xx.c | 2 +- drivers/leds/leds-ktd2692.c | 2 +- drivers/leds/leds-lm3532.c | 2 +- drivers/leds/leds-lm3601x.c | 2 +- drivers/leds/leds-lm3692x.c | 2 +- drivers/leds/leds-lm3697.c | 2 +- drivers/leds/leds-lp50xx.c | 2 +- drivers/leds/leds-lp8860.c | 2 +- drivers/leds/leds-max77650.c | 2 +- drivers/leds/leds-max77693.c | 2 +- drivers/leds/leds-mt6323.c | 2 +- drivers/leds/leds-netxbig.c | 2 +- drivers/leds/leds-pca955x.c | 2 +- drivers/leds/leds-pca963x.c | 2 +- drivers/leds/leds-pm8058.c | 2 +- drivers/leds/leds-powernv.c | 2 +- drivers/leds/leds-pwm.c | 2 +- drivers/leds/leds-sc27xx-bltc.c | 2 +- drivers/leds/leds-sgm3140.c | 2 +- drivers/leds/leds-spi-byte.c | 2 +- drivers/leds/leds-syscon.c | 2 +- drivers/leds/leds-turris-omnia.c | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c index 5a0fe7b7b8bc7..c78a29ab8e9fb 100644 --- a/drivers/leds/leds-aat1290.c +++ b/drivers/leds/leds-aat1290.c @@ -545,7 +545,7 @@ static struct platform_driver aat1290_led_driver = { .remove = aat1290_led_remove, .driver = { .name = "aat1290", - .of_match_table = aat1290_led_dt_match, + .of_match_table = of_match_ptr(aat1290_led_dt_match), }, }; diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c index e8922fa033796..50b12e440d88d 100644 --- a/drivers/leds/leds-as3645a.c +++ b/drivers/leds/leds-as3645a.c @@ -757,7 +757,7 @@ MODULE_DEVICE_TABLE(of, as3645a_of_table); static struct i2c_driver as3645a_i2c_driver = { .driver = { - .of_match_table = as3645a_of_table, + .of_match_table = of_match_ptr(as3645a_of_table), .name = AS_NAME, }, .probe_new = as3645a_probe, diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index bad7efb751120..65a3857efa4ed 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -477,7 +477,7 @@ static struct platform_driver bcm6328_leds_driver = { .probe = bcm6328_leds_probe, .driver = { .name = "leds-bcm6328", - .of_match_table = bcm6328_leds_of_match, + .of_match_table = of_match_ptr(bcm6328_leds_of_match), }, }; diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 94fefd456ba07..44fd1ba4be57e 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -220,7 +220,7 @@ static struct platform_driver bcm6358_leds_driver = { .probe = bcm6358_leds_probe, .driver = { .name = "leds-bcm6358", - .of_match_table = bcm6358_leds_of_match, + .of_match_table = of_match_ptr(bcm6358_leds_of_match), }, }; diff --git a/drivers/leds/leds-cpcap.c b/drivers/leds/leds-cpcap.c index 7d41ce8c9bb1e..263e4bbf3fda5 100644 --- a/drivers/leds/leds-cpcap.c +++ b/drivers/leds/leds-cpcap.c @@ -216,7 +216,7 @@ static struct platform_driver cpcap_led_driver = { .probe = cpcap_led_probe, .driver = { .name = "cpcap-led", - .of_match_table = cpcap_led_of_match, + .of_match_table = of_match_ptr(cpcap_led_of_match), }, }; module_platform_driver(cpcap_led_driver); diff --git a/drivers/leds/leds-cr0014114.c b/drivers/leds/leds-cr0014114.c index 2da448ae718e9..a2f5638eda5f7 100644 --- a/drivers/leds/leds-cr0014114.c +++ b/drivers/leds/leds-cr0014114.c @@ -291,7 +291,7 @@ static struct spi_driver cr0014114_driver = { .remove = cr0014114_remove, .driver = { .name = KBUILD_MODNAME, - .of_match_table = cr0014114_dt_ids, + .of_match_table = of_match_ptr(cr0014114_dt_ids), }, }; diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index 298b13e4807a8..bcd13a7fc9d02 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -345,7 +345,7 @@ static struct spi_driver el15203000_driver = { .remove = el15203000_remove, .driver = { .name = KBUILD_MODNAME, - .of_match_table = el15203000_dt_ids, + .of_match_table = of_match_ptr(el15203000_dt_ids), }, }; diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index cf84096d88cec..aa740267eb232 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -311,7 +311,7 @@ static struct platform_driver gpio_led_driver = { .shutdown = gpio_led_shutdown, .driver = { .name = "leds-gpio", - .of_match_table = of_gpio_leds_match, + .of_match_table = of_match_ptr(of_gpio_leds_match), }, }; diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index acf51e17e8df6..408eb5fad4cb0 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -485,7 +485,7 @@ MODULE_DEVICE_TABLE(i2c, is31fl32xx_id); static struct i2c_driver is31fl32xx_driver = { .driver = { .name = "is31fl32xx", - .of_match_table = of_is31fl32xx_match, + .of_match_table = of_match_ptr(of_is31fl32xx_match), }, .probe = is31fl32xx_probe, .remove = is31fl32xx_remove, diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c index 670efee9b1317..63917db8cac39 100644 --- a/drivers/leds/leds-ktd2692.c +++ b/drivers/leds/leds-ktd2692.c @@ -402,7 +402,7 @@ MODULE_DEVICE_TABLE(of, ktd2692_match); static struct platform_driver ktd2692_driver = { .driver = { .name = "ktd2692", - .of_match_table = ktd2692_match, + .of_match_table = of_match_ptr(ktd2692_match), }, .probe = ktd2692_probe, .remove = ktd2692_remove, diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 946ad67eaecb7..3670cc64eee7b 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -752,7 +752,7 @@ static struct i2c_driver lm3532_i2c_driver = { .id_table = lm3532_id, .driver = { .name = LM3532_NAME, - .of_match_table = of_lm3532_leds_match, + .of_match_table = of_match_ptr(of_lm3532_leds_match), }, }; module_i2c_driver(lm3532_i2c_driver); diff --git a/drivers/leds/leds-lm3601x.c b/drivers/leds/leds-lm3601x.c index d0e1d4814042e..e12b9fbac4c1a 100644 --- a/drivers/leds/leds-lm3601x.c +++ b/drivers/leds/leds-lm3601x.c @@ -468,7 +468,7 @@ MODULE_DEVICE_TABLE(of, of_lm3601x_leds_match); static struct i2c_driver lm3601x_i2c_driver = { .driver = { .name = "lm3601x", - .of_match_table = of_lm3601x_leds_match, + .of_match_table = of_match_ptr(of_lm3601x_leds_match), }, .probe_new = lm3601x_probe, .remove = lm3601x_remove, diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index 1d7ea1b76a125..ba535ee8fd252 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -525,7 +525,7 @@ MODULE_DEVICE_TABLE(of, of_lm3692x_leds_match); static struct i2c_driver lm3692x_driver = { .driver = { .name = "lm3692x", - .of_match_table = of_lm3692x_leds_match, + .of_match_table = of_match_ptr(of_lm3692x_leds_match), }, .probe = lm3692x_probe, .remove = lm3692x_remove, diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 024983088d599..5d14f3d2220af 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -379,7 +379,7 @@ MODULE_DEVICE_TABLE(of, of_lm3697_leds_match); static struct i2c_driver lm3697_driver = { .driver = { .name = "lm3697", - .of_match_table = of_lm3697_leds_match, + .of_match_table = of_match_ptr(of_lm3697_leds_match), }, .probe = lm3697_probe, .remove = lm3697_remove, diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c index 47144a37cb945..1f8be335084d5 100644 --- a/drivers/leds/leds-lp50xx.c +++ b/drivers/leds/leds-lp50xx.c @@ -621,7 +621,7 @@ MODULE_DEVICE_TABLE(of, of_lp50xx_leds_match); static struct i2c_driver lp50xx_driver = { .driver = { .name = "lp50xx", - .of_match_table = of_lp50xx_leds_match, + .of_match_table = of_match_ptr(of_lp50xx_leds_match), }, .probe = lp50xx_probe, .remove = lp50xx_remove, diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index ac2f5d6272dc0..6eb323212da3c 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -484,7 +484,7 @@ MODULE_DEVICE_TABLE(of, of_lp8860_leds_match); static struct i2c_driver lp8860_driver = { .driver = { .name = "lp8860", - .of_match_table = of_lp8860_leds_match, + .of_match_table = of_match_ptr(of_lp8860_leds_match), }, .probe = lp8860_probe, .remove = lp8860_remove, diff --git a/drivers/leds/leds-max77650.c b/drivers/leds/leds-max77650.c index a0d4b725c9178..56a37d4b7df63 100644 --- a/drivers/leds/leds-max77650.c +++ b/drivers/leds/leds-max77650.c @@ -144,7 +144,7 @@ MODULE_DEVICE_TABLE(of, max77650_led_of_match); static struct platform_driver max77650_led_driver = { .driver = { .name = "max77650-led", - .of_match_table = max77650_led_of_match, + .of_match_table = of_match_ptr(max77650_led_of_match), }, .probe = max77650_led_probe, }; diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c index fec56090c2ba3..1d8e2ffe7ad46 100644 --- a/drivers/leds/leds-max77693.c +++ b/drivers/leds/leds-max77693.c @@ -1047,7 +1047,7 @@ static struct platform_driver max77693_led_driver = { .remove = max77693_led_remove, .driver = { .name = "max77693-led", - .of_match_table = max77693_led_dt_match, + .of_match_table = of_match_ptr(max77693_led_dt_match), }, }; diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 7b240771e45bb..80b57a39445cb 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -482,7 +482,7 @@ static struct platform_driver mt6323_led_driver = { .remove = mt6323_led_remove, .driver = { .name = "mt6323-led", - .of_match_table = mt6323_led_dt_match, + .of_match_table = of_match_ptr(mt6323_led_dt_match), }, }; diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index ceceeb6a0e966..7f3313e321fa6 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -617,7 +617,7 @@ static struct platform_driver netxbig_led_driver = { .probe = netxbig_led_probe, .driver = { .name = "leds-netxbig", - .of_match_table = of_netxbig_leds_match, + .of_match_table = of_match_ptr(of_netxbig_leds_match), }, }; diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 7087ca4592fc9..7da2b88a89197 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -579,7 +579,7 @@ static int pca955x_probe(struct i2c_client *client, static struct i2c_driver pca955x_driver = { .driver = { .name = "leds-pca955x", - .of_match_table = of_pca955x_match, + .of_match_table = of_match_ptr(of_pca955x_match), }, .probe = pca955x_probe, .id_table = pca955x_id, diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index d288acbc99c7c..d3969c7914656 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -473,7 +473,7 @@ static int pca963x_remove(struct i2c_client *client) static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", - .of_match_table = of_pca963x_match, + .of_match_table = of_match_ptr(of_pca963x_match), }, .probe = pca963x_probe, .remove = pca963x_remove, diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index 7869ccdf70ce6..d9e8ea80cd167 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -173,7 +173,7 @@ static struct platform_driver pm8058_led_driver = { .probe = pm8058_led_probe, .driver = { .name = "pm8058-leds", - .of_match_table = pm8058_leds_id_table, + .of_match_table = of_match_ptr(pm8058_leds_id_table), }, }; module_platform_driver(pm8058_led_driver); diff --git a/drivers/leds/leds-powernv.c b/drivers/leds/leds-powernv.c index cd43d5dff7f48..d803726300ff4 100644 --- a/drivers/leds/leds-powernv.c +++ b/drivers/leds/leds-powernv.c @@ -338,7 +338,7 @@ static struct platform_driver powernv_led_driver = { .remove = powernv_led_remove, .driver = { .name = "powernv-led-driver", - .of_match_table = powernv_led_match, + .of_match_table = of_match_ptr(powernv_led_match), }, }; diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index e35a97c1d8285..02c9c7a32251e 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -190,7 +190,7 @@ static struct platform_driver led_pwm_driver = { .probe = led_pwm_probe, .driver = { .name = "leds_pwm", - .of_match_table = of_pwm_leds_match, + .of_match_table = of_match_ptr(of_pwm_leds_match), }, }; diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c index 0ede87420bfc7..3401ad389c8d9 100644 --- a/drivers/leds/leds-sc27xx-bltc.c +++ b/drivers/leds/leds-sc27xx-bltc.c @@ -347,7 +347,7 @@ MODULE_DEVICE_TABLE(of, sc27xx_led_of_match); static struct platform_driver sc27xx_led_driver = { .driver = { .name = "sprd-bltc", - .of_match_table = sc27xx_led_of_match, + .of_match_table = of_match_ptr(sc27xx_led_of_match), }, .probe = sc27xx_led_probe, .remove = sc27xx_led_remove, diff --git a/drivers/leds/leds-sgm3140.c b/drivers/leds/leds-sgm3140.c index f4f831570f11c..92ce22024d91b 100644 --- a/drivers/leds/leds-sgm3140.c +++ b/drivers/leds/leds-sgm3140.c @@ -300,7 +300,7 @@ static struct platform_driver sgm3140_driver = { .remove = sgm3140_remove, .driver = { .name = "sgm3140", - .of_match_table = sgm3140_dt_match, + .of_match_table = of_match_ptr(sgm3140_dt_match), }, }; diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c index 9632eb84f8de1..21ec02c4f8dac 100644 --- a/drivers/leds/leds-spi-byte.c +++ b/drivers/leds/leds-spi-byte.c @@ -144,7 +144,7 @@ static struct spi_driver spi_byte_driver = { .remove = spi_byte_remove, .driver = { .name = KBUILD_MODNAME, - .of_match_table = spi_byte_dt_ids, + .of_match_table = of_match_ptr(spi_byte_dt_ids), }, }; diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index b58f3cafe16f4..b56a5c82bf759 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -134,7 +134,7 @@ static struct platform_driver syscon_led_driver = { .probe = syscon_led_probe, .driver = { .name = "leds-syscon", - .of_match_table = of_syscon_leds_match, + .of_match_table = of_match_ptr(of_syscon_leds_match), .suppress_bind_attrs = true, }, }; diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index bb23d8e166144..2a69d2085a225 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -284,7 +284,7 @@ static struct i2c_driver omnia_leds_driver = { .id_table = omnia_id, .driver = { .name = "leds-turris-omnia", - .of_match_table = of_omnia_leds_match, + .of_match_table = of_match_ptr(of_omnia_leds_match), }, }; From patchwork Thu Sep 17 22:32:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC718C43463 for ; Thu, 17 Sep 2020 22:37:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FC34208DB for ; Thu, 17 Sep 2020 22:37:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="VBvCHPmM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726022AbgIQWg6 (ORCPT ); Thu, 17 Sep 2020 18:36:58 -0400 Received: from lists.nic.cz ([217.31.204.67]:35542 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgIQWd7 (ORCPT ); Thu, 17 Sep 2020 18:33:59 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D01EE140A94; Fri, 18 Sep 2020 00:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=5wo607a85PZ8EGCxuDc4OP1bAfnLn3jrieSehirzD8s=; h=From:To:Date; b=VBvCHPmMP1qIPa4bt2pFY6SsW5rtR7R4Y9gmaph+JqZZH1gr+VaNZRT2UXf0PvyKy BVsoFiWzNFAOHN9sPpeGJtI0t3mXAjwkDMm9FvdLSzQlTiKEKJeCMmJdO1iExCOvgo 4yz0IxMDDbOfm9QxBMW9HWOu9ct8nWTTnD4W+gHE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Nikita Travkin , Milo Kim Subject: [PATCH leds v2 09/50] leds: various: fix OF node leaks Date: Fri, 18 Sep 2020 00:32:57 +0200 Message-Id: <20200917223338.14164-10-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Fix OF node leaks by calling of_node_put in for_each_available_child_of_node when the cycle breaks or returns. Signed-off-by: Marek Behún Cc: Nikita Travkin Cc: Milo Kim Cc: Dan Murphy --- drivers/leds/leds-aw2013.c | 4 +++- drivers/leds/leds-lp55xx-common.c | 8 ++++++-- drivers/leds/leds-turris-omnia.c | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 9df7de042bca2..927c5ba32592f 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -305,8 +305,10 @@ static int aw2013_probe_dt(struct aw2013 *chip) ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } i++; } diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 50f7f5b874636..81de1346bf5d6 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -614,8 +614,10 @@ static int lp55xx_parse_multi_led(struct device_node *np, for_each_available_child_of_node(np, child) { ret = lp55xx_parse_multi_led_child(child, cfg, child_number, num_colors); - if (ret) + if (ret) { + of_node_put(child); return ret; + } num_colors++; } @@ -681,8 +683,10 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, for_each_available_child_of_node(np, child) { ret = lp55xx_parse_logical_led(child, cfg, i); - if (ret) + if (ret) { + of_node_put(child); return ERR_PTR(-EINVAL); + } i++; } diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index b2add494af14d..c276969137d7f 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -236,8 +236,10 @@ static int omnia_leds_probe(struct i2c_client *client, led = &leds->leds[0]; for_each_available_child_of_node(np, child) { ret = omnia_led_register(client, led, child); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } led += ret; } From patchwork Thu Sep 17 22:32:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C9EEC43465 for ; Thu, 17 Sep 2020 22:36:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0065D208DB for ; Thu, 17 Sep 2020 22:36:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="T+/lW1EV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbgIQWgc (ORCPT ); Thu, 17 Sep 2020 18:36:32 -0400 Received: from lists.nic.cz ([217.31.204.67]:35560 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgIQWeB (ORCPT ); Thu, 17 Sep 2020 18:34:01 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 09959140A98; Fri, 18 Sep 2020 00:33:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=7qde80XtutzOvUvTVeYWoRsA/xkLB2RT3E7wnLFkILw=; h=From:To:Date; b=T+/lW1EVLKq0DFU1fzPi7x3lBMM8wFOUC5M5e6126NQ2P+sCFZp+2wrMc6v498jNf Yn2UuJnoLkcHQk9k5CxMHP2jnzUsE2zKxCAuXmhtOqmRWB+X9gIYWI52w0uF5eMfXa JSeHrTaEbdlHA4HTPnt7SK/In6no8d6rh/9MMXV0= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Kevin Cernekee , Jaedon Shin Subject: [PATCH leds v2 10/50] leds: bcm6328, bcm6358: use devres LED registering function Date: Fri, 18 Sep 2020 00:32:58 +0200 Message-Id: <20200917223338.14164-11-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org These two drivers do not provide remove method and use devres for allocation of other resources, yet they use led_classdev_register instead of the devres variant, devm_led_classdev_register. Fix this. Signed-off-by: Marek Behún Cc: Álvaro Fernández Rojas Cc: Kevin Cernekee Cc: Jaedon Shin --- drivers/leds/leds-bcm6328.c | 2 +- drivers/leds/leds-bcm6358.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index c73097758e353..b3cf84a3eb150 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -383,7 +383,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set; - rc = led_classdev_register(dev, &led->cdev); + rc = devm_led_classdev_register(dev, &led->cdev); if (rc < 0) return rc; diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 289dfc412eda4..99dbf62aa6222 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -137,7 +137,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, led->cdev.brightness_set = bcm6358_led_set; - rc = led_classdev_register(dev, &led->cdev); + rc = devm_led_classdev_register(dev, &led->cdev); if (rc < 0) return rc; From patchwork Thu Sep 17 22:32:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9498AC43467 for ; Thu, 17 Sep 2020 22:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 581312087D for ; Thu, 17 Sep 2020 22:36:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="TQyVEyQ9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbgIQWgi (ORCPT ); Thu, 17 Sep 2020 18:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgIQWeA (ORCPT ); Thu, 17 Sep 2020 18:34:00 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4147EC061788; Thu, 17 Sep 2020 15:33:57 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 2BC7A140A99; Fri, 18 Sep 2020 00:33:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=+88acRR0+nXsF9fnBxrJpJncykP+3DoAY9pr6KLSxqU=; h=From:To:Date; b=TQyVEyQ9xHjvjhDvc2Wf8JKCLVxe937HqxfmLUM6f6LSxIkbUML6PAA66/f/KcNGH YbXh5Vi7qUYN/TdUj7E2qvlOSEUYOm4eY9Zwrv6E900ag5O7R9yhT9oYmijFAL7wvV NYz0g3zhIfHoMM7ANpnFxzw+Td2TNQasmw277RDo= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Kevin Cernekee , Jaedon Shin Subject: [PATCH leds v2 11/50] leds: bcm6328, bcm6358: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:32:59 +0200 Message-Id: <20200917223338.14164-12-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Signed-off-by: Marek Behún Cc: Álvaro Fernández Rojas Cc: Kevin Cernekee Cc: Jaedon Shin --- drivers/leds/leds-bcm6328.c | 5 +++-- drivers/leds/leds-bcm6358.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index b3cf84a3eb150..c72b0842e8151 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -328,6 +328,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, void __iomem *mem, spinlock_t *lock, unsigned long *blink_leds, unsigned long *blink_delay) { + struct led_init_data init_data = {}; struct bcm6328_led *led; const char *state; int rc; @@ -345,7 +346,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name; led->cdev.default_trigger = of_get_property(nc, "linux,default-trigger", NULL); @@ -382,8 +382,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set; + init_data.fwnode = of_fwnode_handle(nc); - rc = devm_led_classdev_register(dev, &led->cdev); + rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) return rc; diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 99dbf62aa6222..49f703c59ecdc 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -94,6 +94,7 @@ static void bcm6358_led_set(struct led_classdev *led_cdev, static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, void __iomem *mem, spinlock_t *lock) { + struct led_init_data init_data = {}; struct bcm6358_led *led; const char *state; int rc; @@ -109,7 +110,6 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name; led->cdev.default_trigger = of_get_property(nc, "linux,default-trigger", NULL); @@ -136,8 +136,9 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, bcm6358_led_set(&led->cdev, led->cdev.brightness); led->cdev.brightness_set = bcm6358_led_set; + init_data.fwnode = of_fwnode_handle(nc); - rc = devm_led_classdev_register(dev, &led->cdev); + rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) return rc; From patchwork Thu Sep 17 22:33:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25B3BC43463 for ; Thu, 17 Sep 2020 22:36:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCF7D208DB for ; Thu, 17 Sep 2020 22:36:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="jYpu6+dE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbgIQWgx (ORCPT ); Thu, 17 Sep 2020 18:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgIQWeA (ORCPT ); Thu, 17 Sep 2020 18:34:00 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504AAC06178A; Thu, 17 Sep 2020 15:33:57 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 5B61C140A9E; Fri, 18 Sep 2020 00:33:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=D0iTJlV5xHof5NzeaqX6wLD0t/Lb+Guor4EBE5NWa3o=; h=From:To:Date; b=jYpu6+dE39GSbHwLxbH8DTSztaLu1PshH4N1Q6WVg6OmiqUsLXxhyUQVSHZgn20+k wtk66lzx7u2WKw2QGaA9uCSezz8EL/uQU24zl69x5pfjQTesBCMKMq0NVYw2EcbN0t kY9zQrX3EXyYUoyg8VwYXAc7MWjwVmZxY1ChHKQc= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Kevin Cernekee , Jaedon Shin Subject: [PATCH leds v2 12/50] leds: bcm6328: cosmetic: use reverse christmas tree Date: Fri, 18 Sep 2020 00:33:00 +0200 Message-Id: <20200917223338.14164-13-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Only a cosmetic change: use reverse christmas tree variables declaration. Signed-off-by: Marek Behún Cc: Álvaro Fernández Rojas Cc: Kevin Cernekee Cc: Jaedon Shin --- drivers/leds/leds-bcm6328.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index c72b0842e8151..38bf820372528 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -109,8 +109,8 @@ static unsigned long bcm6328_pin2shift(unsigned long pin) static void bcm6328_led_mode(struct bcm6328_led *led, unsigned long value) { - void __iomem *mode; unsigned long val, shift; + void __iomem *mode; shift = bcm6328_pin2shift(led->pin); if (shift / 16) @@ -255,8 +255,8 @@ static int bcm6328_blink_set(struct led_classdev *led_cdev, static int bcm6328_hwled(struct device *dev, struct device_node *nc, u32 reg, void __iomem *mem, spinlock_t *lock) { - int i, cnt; unsigned long flags, val; + int i, cnt; spin_lock_irqsave(lock, flags); val = bcm6328_led_read(mem + BCM6328_REG_HWDIS); @@ -271,8 +271,8 @@ static int bcm6328_hwled(struct device *dev, struct device_node *nc, u32 reg, cnt = of_property_count_elems_of_size(nc, "brcm,link-signal-sources", sizeof(u32)); for (i = 0; i < cnt; i++) { - u32 sel; void __iomem *addr; + u32 sel; if (reg < 4) addr = mem + BCM6328_REG_LNKACTSEL_LO; @@ -298,8 +298,8 @@ static int bcm6328_hwled(struct device *dev, struct device_node *nc, u32 reg, "brcm,activity-signal-sources", sizeof(u32)); for (i = 0; i < cnt; i++) { - u32 sel; void __iomem *addr; + u32 sel; if (reg < 4) addr = mem + BCM6328_REG_LNKACTSEL_LO; @@ -395,12 +395,11 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, static int bcm6328_leds_probe(struct platform_device *pdev) { + unsigned long val, *blink_leds, *blink_delay; struct device *dev = &pdev->dev; - struct device_node *np = dev_of_node(&pdev->dev); - struct device_node *child; + struct device_node *np, *child; void __iomem *mem; spinlock_t *lock; /* memory lock */ - unsigned long val, *blink_leds, *blink_delay; mem = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mem)) @@ -426,6 +425,8 @@ static int bcm6328_leds_probe(struct platform_device *pdev) bcm6328_led_write(mem + BCM6328_REG_LNKACTSEL_HI, 0); bcm6328_led_write(mem + BCM6328_REG_LNKACTSEL_LO, 0); + np = dev_of_node(dev); + val = bcm6328_led_read(mem + BCM6328_REG_INIT); val &= ~(BCM6328_INIT_MASK); if (of_property_read_bool(np, "brcm,serial-leds")) @@ -441,8 +442,8 @@ static int bcm6328_leds_probe(struct platform_device *pdev) bcm6328_led_write(mem + BCM6328_REG_INIT, val); for_each_available_child_of_node(np, child) { - int rc; u32 reg; + int rc; if (of_property_read_u32(child, "reg", ®)) continue; From patchwork Thu Sep 17 22:33:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A32EFC43464 for ; Thu, 17 Sep 2020 22:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6912F2087D for ; Thu, 17 Sep 2020 22:34:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="pEXzLZri" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgIQWeD (ORCPT ); Thu, 17 Sep 2020 18:34:03 -0400 Received: from mail.nic.cz ([217.31.204.67]:35610 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIQWeC (ORCPT ); Thu, 17 Sep 2020 18:34:02 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id AEFE3140AAB; Fri, 18 Sep 2020 00:33:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=wpYWIMFLHHEQHY3szNAZh0Xlv5s2DPdwZfaOXl2xbtY=; h=From:To:Date; b=pEXzLZridMTS9MO6S1TGAIiEovytcB8dr3+gIuKJX9bER3qLnUTY3q3fbYs0KIt/x uW5o05gkXp9niUsrOLEPvN3Gi96S1Za6T10Ex6Ll44vIWkwLe8iZ7mngwE1tlghIrI /W0MY7PMwOrKKsTI4K1TH/jCdbyY7/THJwp4XsGM= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 14/50] leds: lm3697: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:02 +0200 Message-Id: <20200917223338.14164-15-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Previously if the `label` DT property was not present, the code composed name for the LED in the form "parent_name::" For backwards compatibility we therefore set init_data->default_label = ":"; so that the LED will not get a different name if `label` property is not present. Signed-off-by: Marek Behún Cc: Dan Murphy --- drivers/leds/leds-lm3697.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 5d14f3d2220af..479776ac36c35 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -194,7 +194,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) { struct fwnode_handle *child = NULL; struct lm3697_led *led; - const char *name; int control_bank; size_t i = 0; int ret = -EINVAL; @@ -214,6 +213,8 @@ static int lm3697_probe_dt(struct lm3697 *priv) priv->regulator = NULL; device_for_each_child_node(priv->dev, child) { + struct led_init_data init_data = {}; + ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(&priv->client->dev, "reg property missing\n"); @@ -271,20 +272,17 @@ static int lm3697_probe_dt(struct lm3697 *priv) fwnode_property_read_string(child, "linux,default-trigger", &led->led_dev.default_trigger); - ret = fwnode_property_read_string(child, "label", &name); - if (ret) - snprintf(led->label, sizeof(led->label), - "%s::", priv->client->name); - else - snprintf(led->label, sizeof(led->label), - "%s:%s", priv->client->name, name); + init_data.fwnode = child; + init_data.devicename = priv->client->name; + /* for backwards compatibility if `label` is not present */ + init_data.default_label = ":"; led->priv = priv; - led->led_dev.name = led->label; led->led_dev.max_brightness = led->lmu_data.max_brightness; led->led_dev.brightness_set_blocking = lm3697_brightness_set; - ret = devm_led_classdev_register(priv->dev, &led->led_dev); + ret = devm_led_classdev_register_ext(priv->dev, &led->led_dev, + &init_data); if (ret) { dev_err(&priv->client->dev, "led register err: %d\n", ret); From patchwork Thu Sep 17 22:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 581C5C43464 for ; Thu, 17 Sep 2020 22:36:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 161E2208DB for ; Thu, 17 Sep 2020 22:36:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="HiSTP7PU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbgIQWgV (ORCPT ); Thu, 17 Sep 2020 18:36:21 -0400 Received: from mail.nic.cz ([217.31.204.67]:35700 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgIQWeG (ORCPT ); Thu, 17 Sep 2020 18:34:06 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 76DF1140ACC; Fri, 18 Sep 2020 00:33:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382036; bh=PudSrnQk2VQk9kM5P052llxhBfC5x3nuZfzy/vHQrmc=; h=From:To:Date; b=HiSTP7PUT/v+iEyqEwlSY7RGTJklU+oCT1bd+noE1ERUHbqKjQMlZDxmvc6fpqhcg QFTdm7MJ8yiys+nk7+nC9EZtEvS+Um/0qQywi8M0VecyIq0NwD29lWFFZq5QSc8Tba 8oSaM6I+8FW8Ga2ufQTV3k4dp9zSRCQqdsGFdbK4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Wang , John Crispin , Ryder Lee Subject: [PATCH leds v2 18/50] leds: mt6323: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:06 +0200 Message-Id: <20200917223338.14164-19-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Since init_data is passed with fwnode handle, we do not need to set the of_node member of the newly created LED classdev. Signed-off-by: Marek Behún Cc: Sean Wang Cc: John Crispin Cc: Ryder Lee --- drivers/leds/leds-mt6323.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 2c46b75030358..f6c71fd691bb8 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -342,7 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, const char *state; int ret = 0; - led->cdev.name = of_get_property(np, "label", NULL) ? : np->name; led->cdev.default_trigger = of_get_property(np, "linux,default-trigger", NULL); @@ -402,6 +401,8 @@ static int mt6323_led_probe(struct platform_device *pdev) } for_each_available_child_of_node(np, child) { + struct led_init_data init_data = {}; + ret = of_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to read led 'reg' property\n"); @@ -437,13 +438,15 @@ static int mt6323_led_probe(struct platform_device *pdev) goto put_child_node; } - ret = devm_led_classdev_register(dev, &leds->led[reg]->cdev); + init_data.fwnode = of_fwnode_handle(child); + + ret = devm_led_classdev_register_ext(dev, &leds->led[reg]->cdev, + &init_data); if (ret) { dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); goto put_child_node; } - leds->led[reg]->cdev.dev->of_node = child; } return 0; From patchwork Thu Sep 17 22:33:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2942EC43466 for ; Thu, 17 Sep 2020 22:36:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1303214D8 for ; Thu, 17 Sep 2020 22:36:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="Zn9ENpkQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726265AbgIQWgN (ORCPT ); Thu, 17 Sep 2020 18:36:13 -0400 Received: from lists.nic.cz ([217.31.204.67]:35704 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgIQWeH (ORCPT ); Thu, 17 Sep 2020 18:34:07 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id A89F6140ADF; Fri, 18 Sep 2020 00:33:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382036; bh=K/Gkdy4QgBWvqCoLfNLDWzOzbRHVEkEYHbPEn4pgyvw=; h=From:To:Date; b=Zn9ENpkQU3V4FPbbpJ7sbhOx3ktVzX+jXnBukocPPEacMTEo6k4It12Y73Kv42Sbo dqI5jBjck9WNDFc2l+oLCqrIlwGBH7KKBaCgm54cbQr3rnOqq25I3AtJR9syL90XM6 kv7S35jbndXhiG8mwyAdntlLvMGvl1rLHPJ/6Dvk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Wang , John Crispin , Ryder Lee Subject: [PATCH leds v2 19/50] leds: mt6323: cosmetic change: use helper variable Date: Fri, 18 Sep 2020 00:33:07 +0200 Message-Id: <20200917223338.14164-20-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Use helper variable dev instead of always writing &pdev->dev. Signed-off-by: Marek Behún Cc: Sean Wang Cc: John Crispin Cc: Ryder Lee --- drivers/leds/leds-mt6323.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index f6c71fd691bb8..5119dcc0aef24 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -368,9 +368,9 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, static int mt6323_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev_of_node(&pdev->dev); + struct device_node *np = dev_of_node(dev); struct device_node *child; - struct mt6397_chip *hw = dev_get_drvdata(pdev->dev.parent); + struct mt6397_chip *hw = dev_get_drvdata(dev->parent); struct mt6323_leds *leds; struct mt6323_led *led; int ret; @@ -443,8 +443,7 @@ static int mt6323_led_probe(struct platform_device *pdev) ret = devm_led_classdev_register_ext(dev, &leds->led[reg]->cdev, &init_data); if (ret) { - dev_err(&pdev->dev, "Failed to register LED: %d\n", - ret); + dev_err(dev, "Failed to register LED: %d\n", ret); goto put_child_node; } } From patchwork Thu Sep 17 22:33:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255396 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB6DDC43465 for ; Thu, 17 Sep 2020 22:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B524A20707 for ; Thu, 17 Sep 2020 22:35:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="iwY4iYXt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726390AbgIQWeM (ORCPT ); Thu, 17 Sep 2020 18:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5410C061351; Thu, 17 Sep 2020 15:33:58 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id DCC33140B01; Fri, 18 Sep 2020 00:33:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382037; bh=B7cn78RkSXn32ihMhDkeA5HTyA02Mxx1cSSRI4SAV7I=; h=From:To:Date; b=iwY4iYXt3Rcin1C/gHjbZG+W5bnkJw3nkeSVeZv7Jj65xJ1p1vmZTpC73BWV+vwSk fpJxkev2kqlgB5l2sURP58EWWyakbpvqc3At/7t4Hi3hH7eA9UtvGU4mb9s/dSGq/W 6Ti1oqJ0CnB5sYKwZyJXoZqHE1SidwOqu8Qj/7zU= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Linus Walleij , Bjorn Andersson Subject: [PATCH leds v2 20/50] leds: pm8058: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:08 +0200 Message-Id: <20200917223338.14164-21-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Signed-off-by: Marek Behún Cc: Linus Walleij Cc: Bjorn Andersson Acked-by: Linus Walleij --- drivers/leds/leds-pm8058.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index dcd7d8c3d6b44..e085bf9ffc1de 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -87,6 +87,7 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled) static int pm8058_led_probe(struct platform_device *pdev) { + struct led_init_data init_data = {}; struct pm8058_led *led; struct device_node *np = dev_of_node(&pdev->dev); int ret; @@ -113,8 +114,6 @@ static int pm8058_led_probe(struct platform_device *pdev) return -EINVAL; } - /* Use label else node name */ - led->cdev.name = of_get_property(np, "label", NULL) ? : np->name; led->cdev.default_trigger = of_get_property(np, "linux,default-trigger", NULL); led->cdev.brightness_set = pm8058_led_set; @@ -142,10 +141,12 @@ static int pm8058_led_probe(struct platform_device *pdev) led->ledtype == PM8058_LED_TYPE_FLASH) led->cdev.flags = LED_CORE_SUSPENDRESUME; - ret = devm_led_classdev_register(&pdev->dev, &led->cdev); + init_data.fwnode = of_fwnode_handle(np); + + ret = devm_led_classdev_register_ext(&pdev->dev, &led->cdev, + &init_data); if (ret) { - dev_err(&pdev->dev, "unable to register led \"%s\"\n", - led->cdev.name); + dev_err(&pdev->dev, "Failed to register LED for %pOF\n", np); return ret; } From patchwork Thu Sep 17 22:33:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B86EAC43465 for ; Thu, 17 Sep 2020 22:34:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74A142087D for ; Thu, 17 Sep 2020 22:34:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="TjMBLYd9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgIQWeM (ORCPT ); Thu, 17 Sep 2020 18:34:12 -0400 Received: from mail.nic.cz ([217.31.204.67]:35812 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbgIQWeJ (ORCPT ); Thu, 17 Sep 2020 18:34:09 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 7772A140A77; Fri, 18 Sep 2020 00:33:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382037; bh=NfiKEaEUAJO2bf4FPxglihEBwosP24Qc7Px6/FPjqjo=; h=From:To:Date; b=TjMBLYd9ZwxWUxikfygf7/XJq3tMys5NcxULPRx90XroUUj4XPZeGvopUF+Vzlmxx /TaoiaFUjBm4IDDXQeidcUyioZMVRZixmqF/0ExR8IUhiJtFQbV38FoBHfdlxXhvoa XyAETDA/JN3b3ge7g/oHFpfwAqd/BxQ74hV5NdQA= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Linus Walleij , Bjorn Andersson Subject: [PATCH leds v2 23/50] leds: pm8058: cosmetic: use reverse christmas tree Date: Fri, 18 Sep 2020 00:33:11 +0200 Message-Id: <20200917223338.14164-24-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Only a cosmetic change: use reverse christmas tree variables declaration. Signed-off-by: Marek Behún Cc: Linus Walleij Cc: Bjorn Andersson --- drivers/leds/leds-pm8058.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index 193780a8c0522..80db7e2de420c 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -29,9 +29,9 @@ static void pm8058_led_set(struct led_classdev *cled, enum led_brightness value) { struct pm8058_led *led; - int ret = 0; unsigned int mask = 0; unsigned int val = 0; + int ret = 0; led = container_of(cled, struct pm8058_led, cdev); switch (led->ledtype) { @@ -56,8 +56,8 @@ static void pm8058_led_set(struct led_classdev *cled, static enum led_brightness pm8058_led_get(struct led_classdev *cled) { struct pm8058_led *led; - int ret; unsigned int val; + int ret; led = container_of(cled, struct pm8058_led, cdev); @@ -89,12 +89,12 @@ static int pm8058_led_probe(struct platform_device *pdev) { struct led_init_data init_data = {}; struct device *dev = &pdev->dev; + enum led_brightness maxbright; struct pm8058_led *led; struct device_node *np; - int ret; struct regmap *map; const char *state; - enum led_brightness maxbright; + int ret; led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); if (!led) From patchwork Thu Sep 17 22:33:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26EE0C43464 for ; Thu, 17 Sep 2020 22:36:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC75E2087D for ; Thu, 17 Sep 2020 22:36:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="R+sHPlJA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726371AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from mail.nic.cz ([217.31.204.67]:35844 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgIQWeK (ORCPT ); Thu, 17 Sep 2020 18:34:10 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id CAA7B1419EC; Fri, 18 Sep 2020 00:33:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382038; bh=cx9F8NaidXU5h1KRThFffrTQvZ02a78OAICQ4c2mFEw=; h=From:To:Date; b=R+sHPlJAXHH1vOAIuONwkAbuH2cwxUx2xOI7DVScw0TVIZ8CGQbhGhbt4vMQafBHd K+SnS7vm1p/8funo8hOsjOMqYsfjpsRU1JKnj9aZWXJN/AxY8FowbgTDSe220dtTkf 06BS8bwioj44DCXFtUC4YOo4GT9qMlaKMX3R8XrY= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , "H . Nikolaus Schaller" Subject: [PATCH leds v2 25/50] leds: is31fl319x: compute aggregated max current separately Date: Fri, 18 Sep 2020 00:33:13 +0200 Message-Id: <20200917223338.14164-26-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Parse `led-max-current` property of child nodes and compute aggregated value in a separate function. The controller cannot set this value separately for every LED, so there is no need to store this value for every LED. Signed-off-by: Marek Behún Cc: H. Nikolaus Schaller --- drivers/leds/leds-is31fl319x.c | 61 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 4161b9dd7e488..ba1a5da5521b5 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -71,7 +71,6 @@ struct is31fl319x_chip { struct is31fl319x_led { struct is31fl319x_chip *chip; struct led_classdev cdev; - u32 max_microamp; bool configured; } leds[IS31FL319X_MAX_LEDS]; }; @@ -171,6 +170,35 @@ static int is31fl319x_brightness_set(struct led_classdev *cdev, return ret; } +static int is31fl319x_parse_max_current(struct device *dev, u32 *aggregated) +{ + struct device_node *np; + u32 value; + int ret; + + *aggregated = IS31FL319X_CURRENT_MAX; + + for_each_available_child_of_node(dev_of_node(dev), np) { + value = IS31FL319X_CURRENT_DEFAULT; + ret = of_property_read_u32(np, "led-max-microamp", &value); + if (!ret) + value = min(value, IS31FL319X_CURRENT_MAX); + + if (value < IS31FL319X_CURRENT_MIN) { + dev_err(dev, + "Value of led-max-microamp too low for %pOF\n", + np); + of_node_put(np); + return -EINVAL; + } + + if (value < *aggregated) + *aggregated = value; + } + + return 0; +} + static int is31fl319x_parse_child_dt(const struct device *dev, const struct device_node *child, struct is31fl319x_led *led) @@ -186,16 +214,6 @@ static int is31fl319x_parse_child_dt(const struct device *dev, if (ret < 0 && ret != -EINVAL) /* is optional */ return ret; - led->max_microamp = IS31FL319X_CURRENT_DEFAULT; - ret = of_property_read_u32(child, "led-max-microamp", - &led->max_microamp); - if (!ret) { - if (led->max_microamp < IS31FL319X_CURRENT_MIN) - return -EINVAL; /* not supported */ - led->max_microamp = min(led->max_microamp, - IS31FL319X_CURRENT_MAX); - } - return 0; } @@ -339,11 +357,20 @@ static int is31fl319x_probe(struct i2c_client *client, struct device *dev = &client->dev; int err; int i = 0; - u32 aggregated_led_microamp = IS31FL319X_CURRENT_MAX; + u32 aggregated_led_microamp; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -EIO; + /* + * Kernel conventions require per-LED led-max-microamp property. + * But the chip does not allow to limit individual LEDs. + * So we take minimum from all subnodes for safety of hardware. + */ + err = is31fl319x_parse_max_current(dev, &aggregated_led_microamp); + if (err) + return err; + is31 = devm_kzalloc(&client->dev, sizeof(*is31), GFP_KERNEL); if (!is31) return -ENOMEM; @@ -379,16 +406,6 @@ static int is31fl319x_probe(struct i2c_client *client, goto free_mutex; } - /* - * Kernel conventions require per-LED led-max-microamp property. - * But the chip does not allow to limit individual LEDs. - * So we take minimum from all subnodes for safety of hardware. - */ - for (i = 0; i < is31->cdef->num_leds; i++) - if (is31->leds[i].configured && - is31->leds[i].max_microamp < aggregated_led_microamp) - aggregated_led_microamp = is31->leds[i].max_microamp; - regmap_write(is31->regmap, IS31FL319X_CONFIG2, is31fl319x_microamp_to_cs(dev, aggregated_led_microamp) | is31fl319x_db_to_gain(is31->audio_gain_db)); From patchwork Thu Sep 17 22:33:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EBA1C43467 for ; Thu, 17 Sep 2020 22:34:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37E5A208DB for ; Thu, 17 Sep 2020 22:34:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="iRVnNu4F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726366AbgIQWeK (ORCPT ); Thu, 17 Sep 2020 18:34:10 -0400 Received: from mail.nic.cz ([217.31.204.67]:35842 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbgIQWeJ (ORCPT ); Thu, 17 Sep 2020 18:34:09 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 0652E1419F6; Fri, 18 Sep 2020 00:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382038; bh=eVEEs+3FCmghmvPcW79AsOl6NcLqYrjCH2wd/yFtugk=; h=From:To:Date; b=iRVnNu4FDoqE0CN7TvkhuJw1xfSAhDSIcSZ6JJL2P68v51XuZoRhkY6i6kCg9L7rC gtYL0FabWl5QX+KNoVRuR4zfYfXC7MFRprlWfyeMDevRA4gXBnfZL6+EPtG55WFjmA lGWtPwSA7cscnLRexk9K3x3N78/tqXD4cOspLdd0= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , "H . Nikolaus Schaller" , Grant Feng Subject: [PATCH leds v2 26/50] leds: is31fl319x: don't store shutdown gpio descriptor Date: Fri, 18 Sep 2020 00:33:14 +0200 Message-Id: <20200917223338.14164-27-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Since the shutdown gpio descriptor is only accessed in device probe method there is no need to store it in the private structure. Signed-off-by: Marek Behún Cc: H. Nikolaus Schaller Cc: Grant Feng --- drivers/leds/leds-is31fl319x.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index ba1a5da5521b5..595112958617e 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -63,7 +63,6 @@ struct is31fl319x_chip { const struct is31fl319x_chipdef *cdef; struct i2c_client *client; - struct gpio_desc *shutdown_gpio; struct regmap *regmap; struct mutex lock; u32 audio_gain_db; @@ -227,15 +226,6 @@ static int is31fl319x_parse_dt(struct device *dev, if (!np) return -ENODEV; - is31->shutdown_gpio = devm_gpiod_get_optional(dev, - "shutdown", - GPIOD_OUT_HIGH); - if (IS_ERR(is31->shutdown_gpio)) { - ret = PTR_ERR(is31->shutdown_gpio); - dev_err(dev, "Failed to get shutdown gpio: %d\n", ret); - return ret; - } - is31->cdef = device_get_match_data(dev); count = of_get_available_child_count(np); @@ -355,6 +345,7 @@ static int is31fl319x_probe(struct i2c_client *client, { struct is31fl319x_chip *is31; struct device *dev = &client->dev; + struct gpio_desc *shutdown_gpio; int err; int i = 0; u32 aggregated_led_microamp; @@ -375,18 +366,26 @@ static int is31fl319x_probe(struct i2c_client *client, if (!is31) return -ENOMEM; + shutdown_gpio = gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); + if (IS_ERR(shutdown_gpio)) { + err = PTR_ERR(shutdown_gpio); + dev_err(dev, "Failed to get shutdown gpio: %d\n", err); + return err; + } + + if (shutdown_gpio) { + gpiod_direction_output(shutdown_gpio, 0); + mdelay(5); + gpiod_direction_output(shutdown_gpio, 1); + gpiod_put(shutdown_gpio); + } + mutex_init(&is31->lock); err = is31fl319x_parse_dt(&client->dev, is31); if (err) goto free_mutex; - if (is31->shutdown_gpio) { - gpiod_direction_output(is31->shutdown_gpio, 0); - mdelay(5); - gpiod_direction_output(is31->shutdown_gpio, 1); - } - is31->client = client; is31->regmap = devm_regmap_init_i2c(client, ®map_config); if (IS_ERR(is31->regmap)) { From patchwork Thu Sep 17 22:33:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73520C43466 for ; Thu, 17 Sep 2020 22:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 339A32137B for ; Thu, 17 Sep 2020 22:36:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="LrvDsyzI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726792AbgIQWgE (ORCPT ); Thu, 17 Sep 2020 18:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10697C061353; Thu, 17 Sep 2020 15:34:00 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 5E9ED142047; Fri, 18 Sep 2020 00:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382038; bh=kO27Fg+MT9zBd6Q8cGBkhOm5D9hO6342LpulPUFWOrU=; h=From:To:Date; b=LrvDsyzICRwXELJouQWHAIZXygws0xakvJ1Ff2KVswHb5exzPdpycx3OmUhD+/vJI 7qJXYNHa+QQ3B4/FsaEaaWANsB63UiYYh7q1F3JfiyIFib3H8UonUPMcUfsjDetWJ+ hAf+sbokYYuv72YfaQ4+DNWQOj8Xwa4F/Bx2aANA= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , "H . Nikolaus Schaller" , Grant Feng Subject: [PATCH leds v2 28/50] leds: is31fl319x: refactor to register LEDs while parsing DT Date: Fri, 18 Sep 2020 00:33:16 +0200 Message-Id: <20200917223338.14164-29-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Refactor the code so that LEDs are registered while device tree is being parsed. Signed-off-by: Marek Behún Cc: H. Nikolaus Schaller Cc: Grant Feng --- drivers/leds/leds-is31fl319x.c | 174 ++++++++++++++------------------- 1 file changed, 76 insertions(+), 98 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 8e3e02d959989..1dae319b03d60 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -209,86 +209,6 @@ static u32 is31fl319x_parse_audio_gain(struct device *dev) return result;; } -static int is31fl319x_parse_child_dt(const struct device *dev, - const struct device_node *child, - struct is31fl319x_led *led) -{ - struct led_classdev *cdev = &led->cdev; - int ret; - - if (of_property_read_string(child, "label", &cdev->name)) - cdev->name = child->name; - - ret = of_property_read_string(child, "linux,default-trigger", - &cdev->default_trigger); - if (ret < 0 && ret != -EINVAL) /* is optional */ - return ret; - - return 0; -} - -static int is31fl319x_parse_dt(struct device *dev, - struct is31fl319x_chip *is31) -{ - struct device_node *np = dev_of_node(dev), *child; - int count; - int ret; - - if (!np) - return -ENODEV; - - is31->cdef = device_get_match_data(dev); - - count = of_get_available_child_count(np); - - dev_dbg(dev, "probing with %d leds defined in DT\n", count); - - if (!count || count > is31->cdef->num_leds) { - dev_err(dev, "Number of leds defined must be between 1 and %u\n", - is31->cdef->num_leds); - return -ENODEV; - } - - for_each_available_child_of_node(np, child) { - struct is31fl319x_led *led; - u32 reg; - - ret = of_property_read_u32(child, "reg", ®); - if (ret) { - dev_err(dev, "Failed to read led 'reg' property\n"); - goto put_child_node; - } - - if (reg < 1 || reg > is31->cdef->num_leds) { - dev_err(dev, "invalid led reg %u\n", reg); - ret = -EINVAL; - goto put_child_node; - } - - led = &is31->leds[reg - 1]; - - if (led->configured) { - dev_err(dev, "led %u is already configured\n", reg); - ret = -EINVAL; - goto put_child_node; - } - - ret = is31fl319x_parse_child_dt(dev, child, led); - if (ret) { - dev_err(dev, "led %u DT parsing failed\n", reg); - goto put_child_node; - } - - led->configured = true; - } - - return 0; - -put_child_node: - of_node_put(child); - return ret; -} - static bool is31fl319x_readable_reg(struct device *dev, unsigned int reg) { /* we have no readable registers */ return false; @@ -345,6 +265,78 @@ static inline int is31fl319x_db_to_gain(u32 dezibel) return dezibel / IS31FL319X_AUDIO_GAIN_DB_STEP; } +static int is31fl319x_led_register(struct device *dev, + struct is31fl319x_chip *is31, + struct device_node *np) +{ + struct is31fl319x_led *led; + u32 reg; + int ret; + + ret = of_property_read_u32(np, "reg", ®); + if (ret) { + dev_err(dev, "Cannot read reg property of %pOF\n", np); + return ret; + } + + if (reg < 1 || reg > is31->cdef->num_leds) { + dev_err(dev, "Node %pOF has invalid reg property\n", np); + return -EINVAL; + } + + led = &is31->leds[reg - 1]; + + if (led->configured) { + dev_err(dev, "Node %pOF 'reg' conflicts with another LED\n", + np); + return -EEXIST; + } + + if (of_property_read_string(np, "label", &led->cdev.name)) + led->cdev.name = np->name; + + ret = of_property_read_string(np, "linux,default-trigger", + &led->cdev.default_trigger); + if (ret < 0 && ret != -EINVAL) /* is optional */ + return ret; + + led->configured = true; + led->chip = is31; + led->cdev.brightness_set_blocking = is31fl319x_brightness_set; + + ret = devm_led_classdev_register(dev, &led->cdev); + if (ret) + dev_err(dev, "Failed to register LED for node %pOF\n", np); + + return ret; +} + +static int is31fl319x_parse_and_register(struct device *dev, + struct is31fl319x_chip *is31) +{ + struct device_node *np = dev_of_node(dev), *child; + int ret, count; + + count = of_get_available_child_count(np); + if (count < 1 || count > is31->cdef->num_leds) { + dev_err(dev, "Between 1 and %u LEDs have to be defined\n", + is31->cdef->num_leds); + return -ENODEV; + } + + dev_dbg(dev, "probing with %d leds defined in DT\n", count); + + for_each_available_child_of_node(np, child) { + ret = is31fl319x_led_register(dev, is31, child); + if (ret) { + of_node_put(child); + return ret; + } + } + + return 0; +} + static int is31fl319x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -353,7 +345,6 @@ static int is31fl319x_probe(struct i2c_client *client, struct gpio_desc *shutdown_gpio; u32 audio_gain_db; int err; - int i = 0; u32 aggregated_led_microamp; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) @@ -388,11 +379,8 @@ static int is31fl319x_probe(struct i2c_client *client, mutex_init(&is31->lock); - err = is31fl319x_parse_dt(&client->dev, is31); - if (err) - goto free_mutex; - is31->client = client; + is31->cdef = device_get_match_data(dev); is31->regmap = devm_regmap_init_i2c(client, ®map_config); if (IS_ERR(is31->regmap)) { dev_err(&client->dev, "failed to allocate register map\n"); @@ -417,19 +405,9 @@ static int is31fl319x_probe(struct i2c_client *client, is31fl319x_microamp_to_cs(dev, aggregated_led_microamp) | is31fl319x_db_to_gain(audio_gain_db)); - for (i = 0; i < is31->cdef->num_leds; i++) { - struct is31fl319x_led *led = &is31->leds[i]; - - if (!led->configured) - continue; - - led->chip = is31; - led->cdev.brightness_set_blocking = is31fl319x_brightness_set; - - err = devm_led_classdev_register(&client->dev, &led->cdev); - if (err < 0) - goto free_mutex; - } + err = is31fl319x_parse_and_register(dev, is31); + if (err) + goto free_mutex; return 0; From patchwork Thu Sep 17 22:33:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2764C43464 for ; Thu, 17 Sep 2020 22:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E35D20795 for ; Thu, 17 Sep 2020 22:35:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="G7EVmvmi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbgIQWfo (ORCPT ); Thu, 17 Sep 2020 18:35:44 -0400 Received: from lists.nic.cz ([217.31.204.67]:35872 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id B76B514204D; Fri, 18 Sep 2020 00:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382038; bh=dpwUnrGSiVS9NDLxxq/du+zF4OLpRLtNHtt1AMGrQdI=; h=From:To:Date; b=G7EVmvmi9kmJYu6Jj6WoQP2l8Vyd5eEwAXFnmMllcqVxtYhaKZB2hr+k3uVCJ4fKa fGKvIPwu8FZW4P7mQlYS+Lcr15AaKksILdyMS9s/p35h8fHSq29j+mLU2N7nPneojT KQsPJqEwOr00VIfAAUkQnlbetWPpa8T9vURHeYhk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , "H . Nikolaus Schaller" , Grant Feng Subject: [PATCH leds v2 30/50] leds: is31fl319x: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:18 +0200 Message-Id: <20200917223338.14164-31-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Signed-off-by: Marek Behún Cc: H. Nikolaus Schaller Cc: Grant Feng --- drivers/leds/leds-is31fl319x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index 15bdbc6378d93..ef5b3e08c7313 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -269,6 +269,7 @@ static int is31fl319x_led_register(struct device *dev, struct is31fl319x_chip *is31, struct device_node *np) { + struct led_init_data init_data = {}; struct is31fl319x_led *led; u32 reg; int ret; @@ -292,9 +293,6 @@ static int is31fl319x_led_register(struct device *dev, return -EEXIST; } - if (of_property_read_string(np, "label", &led->cdev.name)) - led->cdev.name = np->name; - ret = of_property_read_string(np, "linux,default-trigger", &led->cdev.default_trigger); if (ret < 0 && ret != -EINVAL) /* is optional */ @@ -303,8 +301,9 @@ static int is31fl319x_led_register(struct device *dev, led->configured = true; led->chip = is31; led->cdev.brightness_set_blocking = is31fl319x_brightness_set; + init_data.fwnode = of_fwnode_handle(np); - ret = devm_led_classdev_register(dev, &led->cdev); + ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (ret) dev_err(dev, "Failed to register LED for node %pOF\n", np); From patchwork Thu Sep 17 22:33:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E274C43468 for ; Thu, 17 Sep 2020 22:35:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1101820795 for ; Thu, 17 Sep 2020 22:35:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="iQhyU+Il" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbgIQWff (ORCPT ); Thu, 17 Sep 2020 18:35:35 -0400 Received: from lists.nic.cz ([217.31.204.67]:35966 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgIQWeM (ORCPT ); Thu, 17 Sep 2020 18:34:12 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D716114204F; Fri, 18 Sep 2020 00:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382039; bh=eylOQwNosH/+MyVb6B6nwrcWha3E/L2/PYtCFaINitQ=; h=From:To:Date; b=iQhyU+IlP4KS61v6ki2GZPU4Ua1sXoO++IO2lnECdkJKXYkd9ICBqGySB25JmM9hh F7UxZ+kQlqGUlCQ6WbGTGFQbHi4IZkpopxQCIHzI4B5rhDU1Ktz69jOaY+z0W5ooh3 7HWE0P/tluLzpVfnxuvbCaFrJNDtBhXLEWobnkbs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 31/50] leds: lm36274: use devres LED registering function Date: Fri, 18 Sep 2020 00:33:19 +0200 Message-Id: <20200917223338.14164-32-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using devres version of LED registering function we can remove the .remove method from this driver. Signed-off-by: Marek Behún Cc: Dan Murphy --- drivers/leds/leds-lm36274.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index bfeee03a0053c..1390c71267cc2 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -147,16 +147,8 @@ static int lm36274_probe(struct platform_device *pdev) return ret; } - return led_classdev_register(lm36274_data->dev, &lm36274_data->led_dev); -} - -static int lm36274_remove(struct platform_device *pdev) -{ - struct lm36274 *lm36274_data = platform_get_drvdata(pdev); - - led_classdev_unregister(&lm36274_data->led_dev); - - return 0; + return devm_led_classdev_register(lm36274_data->dev, + &lm36274_data->led_dev); } static const struct of_device_id of_lm36274_leds_match[] = { @@ -167,7 +159,6 @@ MODULE_DEVICE_TABLE(of, of_lm36274_leds_match); static struct platform_driver lm36274_driver = { .probe = lm36274_probe, - .remove = lm36274_remove, .driver = { .name = "lm36274-leds", }, From patchwork Thu Sep 17 22:33:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E8BAC43464 for ; Thu, 17 Sep 2020 22:35:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ABE220707 for ; Thu, 17 Sep 2020 22:35:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="CJaG9OSZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbgIQWfn (ORCPT ); Thu, 17 Sep 2020 18:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21777C061354; Thu, 17 Sep 2020 15:34:01 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 0F905142046; Fri, 18 Sep 2020 00:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382039; bh=BrXxpF33S6iDCQ9susD23iGATwDHo589X9GgVYywr1A=; h=From:To:Date; b=CJaG9OSZSvwDjsdIDahEfpg4G7OVdYAl5fGXlXnIl2UD/05cOAz60MUP4h8xaaOjP FmGovM5k8DclYYbf89IUI1u2O6l8+z/aEgfX71qjp3lru3wXY1DPOWsPu2OnmrZL4M N0h8+G6ix/lhzkx3UdCkmzPOoNwm9F0EQSAsa3To= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 32/50] leds: lm36274: cosmetic: rename lm36274_data to chip Date: Fri, 18 Sep 2020 00:33:20 +0200 Message-Id: <20200917223338.14164-33-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Rename this variable so that it is easier to read and easier to write in 80 columns. Signed-off-by: Marek Behún Cc: Dan Murphy --- drivers/leds/leds-lm36274.c | 73 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index 1390c71267cc2..2569659836e8f 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -48,30 +48,29 @@ static int lm36274_brightness_set(struct led_classdev *led_cdev, return ti_lmu_common_set_brightness(&led->lmu_data, brt_val); } -static int lm36274_init(struct lm36274 *lm36274_data) +static int lm36274_init(struct lm36274 *chip) { int enable_val = 0; int i; - for (i = 0; i < lm36274_data->num_leds; i++) - enable_val |= (1 << lm36274_data->led_sources[i]); + for (i = 0; i < chip->num_leds; i++) + enable_val |= (1 << chip->led_sources[i]); if (!enable_val) { - dev_err(lm36274_data->dev, "No LEDs were enabled\n"); + dev_err(chip->dev, "No LEDs were enabled\n"); return -EINVAL; } enable_val |= LM36274_BL_EN; - return regmap_write(lm36274_data->regmap, LM36274_REG_BL_EN, - enable_val); + return regmap_write(chip->regmap, LM36274_REG_BL_EN, enable_val); } -static int lm36274_parse_dt(struct lm36274 *lm36274_data) +static int lm36274_parse_dt(struct lm36274 *chip) { struct fwnode_handle *child = NULL; char label[LED_MAX_NAME_SIZE]; - struct device *dev = &lm36274_data->pdev->dev; + struct device *dev = &chip->pdev->dev; const char *name; int child_cnt; int ret = -EINVAL; @@ -84,37 +83,37 @@ static int lm36274_parse_dt(struct lm36274 *lm36274_data) device_for_each_child_node(dev, child) { ret = fwnode_property_read_string(child, "label", &name); if (ret) - snprintf(label, sizeof(label), - "%s::", lm36274_data->pdev->name); + snprintf(label, sizeof(label), "%s::", + chip->pdev->name); else - snprintf(label, sizeof(label), - "%s:%s", lm36274_data->pdev->name, name); + snprintf(label, sizeof(label), "%s:%s", chip->pdev->name, + name); - lm36274_data->num_leds = fwnode_property_count_u32(child, "led-sources"); - if (lm36274_data->num_leds <= 0) + chip->num_leds = fwnode_property_count_u32(child, "led-sources"); + if (chip->num_leds <= 0) return -ENODEV; ret = fwnode_property_read_u32_array(child, "led-sources", - lm36274_data->led_sources, - lm36274_data->num_leds); + chip->led_sources, + chip->num_leds); if (ret) { dev_err(dev, "led-sources property missing\n"); return ret; } fwnode_property_read_string(child, "linux,default-trigger", - &lm36274_data->led_dev.default_trigger); + &chip->led_dev.default_trigger); } - lm36274_data->lmu_data.regmap = lm36274_data->regmap; - lm36274_data->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT; - lm36274_data->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB; - lm36274_data->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB; + chip->lmu_data.regmap = chip->regmap; + chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT; + chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB; + chip->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB; - lm36274_data->led_dev.name = label; - lm36274_data->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT; - lm36274_data->led_dev.brightness_set_blocking = lm36274_brightness_set; + chip->led_dev.name = label; + chip->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT; + chip->led_dev.brightness_set_blocking = lm36274_brightness_set; return 0; } @@ -122,33 +121,31 @@ static int lm36274_parse_dt(struct lm36274 *lm36274_data) static int lm36274_probe(struct platform_device *pdev) { struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent); - struct lm36274 *lm36274_data; + struct lm36274 *chip; int ret; - lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data), - GFP_KERNEL); - if (!lm36274_data) + chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) return -ENOMEM; - lm36274_data->pdev = pdev; - lm36274_data->dev = lmu->dev; - lm36274_data->regmap = lmu->regmap; - platform_set_drvdata(pdev, lm36274_data); + chip->pdev = pdev; + chip->dev = lmu->dev; + chip->regmap = lmu->regmap; + platform_set_drvdata(pdev, chip); - ret = lm36274_parse_dt(lm36274_data); + ret = lm36274_parse_dt(chip); if (ret) { - dev_err(lm36274_data->dev, "Failed to parse DT node\n"); + dev_err(chip->dev, "Failed to parse DT node\n"); return ret; } - ret = lm36274_init(lm36274_data); + ret = lm36274_init(chip); if (ret) { - dev_err(lm36274_data->dev, "Failed to init the device\n"); + dev_err(chip->dev, "Failed to init the device\n"); return ret; } - return devm_led_classdev_register(lm36274_data->dev, - &lm36274_data->led_dev); + return devm_led_classdev_register(chip->dev, &chip->led_dev); } static const struct of_device_id of_lm36274_leds_match[] = { From patchwork Thu Sep 17 22:33:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25340C43463 for ; Thu, 17 Sep 2020 22:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E30B3214D8 for ; Thu, 17 Sep 2020 22:35:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="Ouxv4n/t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726198AbgIQWeM (ORCPT ); Thu, 17 Sep 2020 18:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgIQWeL (ORCPT ); Thu, 17 Sep 2020 18:34:11 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C74EC061355; Thu, 17 Sep 2020 15:34:01 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 6BE38140A99; Fri, 18 Sep 2020 00:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382039; bh=Wotn7e2cgVkVaUKncYL5Az1W3C0Cc2Am3nyHbP1RV1U=; h=From:To:Date; b=Ouxv4n/tyYy+vN7SHRoHInayco5+mwhXXnMZFwAFsVmzeqm3MukX3mFhaJD8fLUnj BBfZkV4fjUhuJDIUMO8/hmJfrJOMrpOU0tqdMTW9nvYr2+u2ooPi9YZVimiAKvs5Cv zLPZhuy4YBLRMhFuh9KGXB7zCOEvYebEH8+Huc1Y= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 34/50] leds: lm36274: use struct led_init_data when registering Date: Fri, 18 Sep 2020 00:33:22 +0200 Message-Id: <20200917223338.14164-35-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using struct led_init_data when registering we do not need to parse `label` DT property. Moreover `label` is deprecated and if it is not present but `color` and `function` are, LED core will compose a name from these properties instead. Previously if the `label` DT property was not present, the code composed name for the LED in the form "parent_name::" For backwards compatibility we therefore set init_data->default_label = ":"; so that the LED will not get a different name if `label` property is not present, nor are `color` and `function`. Signed-off-by: Marek Behún Cc: Dan Murphy --- drivers/leds/leds-lm36274.c | 43 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index 4282b7392f2b5..294edcc054bea 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -66,12 +66,11 @@ static int lm36274_init(struct lm36274 *chip) return regmap_write(chip->regmap, LM36274_REG_BL_EN, enable_val); } -static int lm36274_parse_dt(struct lm36274 *chip) +static int lm36274_parse_dt(struct lm36274 *chip, + struct led_init_data *init_data) { - struct fwnode_handle *child = NULL; - char label[LED_MAX_NAME_SIZE]; struct device *dev = &chip->pdev->dev; - const char *name; + struct fwnode_handle *child; int ret; /* There should only be 1 node */ @@ -80,43 +79,45 @@ static int lm36274_parse_dt(struct lm36274 *chip) child = device_get_next_child_node(dev, NULL); - ret = fwnode_property_read_string(child, "label", &name); - if (ret) - snprintf(label, sizeof(label), "%s::", chip->pdev->name); - else - snprintf(label, sizeof(label), "%s:%s", chip->pdev->name, name); + init_data->fwnode = child; + init_data->devicename = chip->pdev->name; + /* for backwards compatibility when `label` property is not present */ + init_data->default_label = ":"; chip->num_leds = fwnode_property_count_u32(child, "led-sources"); - if (chip->num_leds <= 0) - return -ENODEV; + if (chip->num_leds <= 0) { + ret = -ENODEV; + goto err; + } ret = fwnode_property_read_u32_array(child, "led-sources", chip->led_sources, chip->num_leds); if (ret) { dev_err(dev, "led-sources property missing\n"); - return ret; + goto err; } fwnode_property_read_string(child, "linux,default-trigger", &chip->led_dev.default_trigger); - fwnode_handle_put(child); - chip->lmu_data.regmap = chip->regmap; chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT; chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB; chip->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB; - chip->led_dev.name = label; chip->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT; chip->led_dev.brightness_set_blocking = lm36274_brightness_set; return 0; +err: + fwnode_handle_put(child); + return ret; } static int lm36274_probe(struct platform_device *pdev) { struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent); + struct led_init_data init_data = {}; struct lm36274 *chip; int ret; @@ -129,7 +130,7 @@ static int lm36274_probe(struct platform_device *pdev) chip->regmap = lmu->regmap; platform_set_drvdata(pdev, chip); - ret = lm36274_parse_dt(chip); + ret = lm36274_parse_dt(chip, &init_data); if (ret) { dev_err(chip->dev, "Failed to parse DT node\n"); return ret; @@ -141,7 +142,15 @@ static int lm36274_probe(struct platform_device *pdev) return ret; } - return devm_led_classdev_register(chip->dev, &chip->led_dev); + ret = devm_led_classdev_register_ext(chip->dev, &chip->led_dev, + &init_data); + if (ret) + dev_err(chip->dev, "Failed to register LED for node %pfw\n", + init_data.fwnode); + + fwnode_handle_put(init_data.fwnode); + + return ret; } static const struct of_device_id of_lm36274_leds_match[] = { From patchwork Thu Sep 17 22:33:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 176E6C43463 for ; Thu, 17 Sep 2020 22:35:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1CE4214D8 for ; Thu, 17 Sep 2020 22:35:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="WyufPwDE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgIQWfR (ORCPT ); Thu, 17 Sep 2020 18:35:17 -0400 Received: from mail.nic.cz ([217.31.204.67]:36162 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgIQWeN (ORCPT ); Thu, 17 Sep 2020 18:34:13 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id BEBBA142057; Fri, 18 Sep 2020 00:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382039; bh=r26L0sWbFofPCK5+uBb+ErS6T+5q3senbfA1NrJl0WA=; h=From:To:Date; b=WyufPwDEgDkCFWxv20zn7pofIKA0QKGszWLW5eamCBLQKlpm+lSvW8E1dqkiSRLRw E/LV7r+cW8SakWeX55LBvqMKynu93PJQTvOEvE4ECZfD2GhWnGFsYkjQJ9TMEkT9QP Av3Y6cTGg83/7m8QsbxyzQihngDokMnpZ56ZD/YE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 36/50] leds: ns2: use devres LED registering function Date: Fri, 18 Sep 2020 00:33:24 +0200 Message-Id: <20200917223338.14164-37-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org By using devres version of LED registering function we can remove the .remove method from this driver. The probe method also gets simpler. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 22d38c83b6dca..1a7ef66464b5d 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -227,16 +227,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - ret = led_classdev_register(&pdev->dev, &led_dat->cdev); - if (ret < 0) - return ret; - - return 0; -} - -static void delete_ns2_led(struct ns2_led_data *led_dat) -{ - led_classdev_unregister(&led_dat->cdev); + return devm_led_classdev_register(&pdev->dev, &led_dat->cdev); } #ifdef CONFIG_OF_GPIO @@ -380,11 +371,8 @@ static int ns2_led_probe(struct platform_device *pdev) for (i = 0; i < priv->num_leds; i++) { ret = create_ns2_led(pdev, &priv->leds_data[i], &pdata->leds[i]); - if (ret < 0) { - for (i = i - 1; i >= 0; i--) - delete_ns2_led(&priv->leds_data[i]); + if (ret < 0) return ret; - } } platform_set_drvdata(pdev, priv); @@ -392,22 +380,8 @@ static int ns2_led_probe(struct platform_device *pdev) return 0; } -static int ns2_led_remove(struct platform_device *pdev) -{ - int i; - struct ns2_led_priv *priv; - - priv = platform_get_drvdata(pdev); - - for (i = 0; i < priv->num_leds; i++) - delete_ns2_led(&priv->leds_data[i]); - - return 0; -} - static struct platform_driver ns2_led_driver = { .probe = ns2_led_probe, - .remove = ns2_led_remove, .driver = { .name = "leds-ns2", .of_match_table = of_match_ptr(of_ns2_leds_match), From patchwork Thu Sep 17 22:33:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F02B3C43463 for ; Thu, 17 Sep 2020 22:35:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5588208DB for ; Thu, 17 Sep 2020 22:35:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="NPcxlibo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726305AbgIQWfL (ORCPT ); Thu, 17 Sep 2020 18:35:11 -0400 Received: from lists.nic.cz ([217.31.204.67]:35542 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726304AbgIQWeO (ORCPT ); Thu, 17 Sep 2020 18:34:14 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 674F714205C; Fri, 18 Sep 2020 00:34:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382040; bh=8soMub3ZeY/I7d2RuEFY0nhJleKrPzEpa9mQS1vUimA=; h=From:To:Date; b=NPcxlibo9s7NcnHGBoW8uWy14DqZsOYDs2hkoFeBuwm48xm+e/xPpIMgLidFfHF8Z ScEfT2ovF0j/X3jiUnt14OsayEb/jai/6jxbtisrP970ckUpcUkEBkm5qlzxScjseh g9bF/cw1BsGVHXfJU6Y8F+Yk5XjQdNlVaCf5qFI4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 39/50] leds: ns2: move parsing of one LED into separate function Date: Fri, 18 Sep 2020 00:33:27 +0200 Message-Id: <20200917223338.14164-40-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Move parsing of DT properties of one LED into separate function. This saves indentation level and is nicer to read. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 120 ++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 0e9c2f49b6350..46d4f7e963c04 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -230,6 +230,57 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, return devm_led_classdev_register(&pdev->dev, &led_dat->cdev); } +static int ns2_leds_parse_one(struct device *dev, struct device_node *np, + struct ns2_led *led) +{ + struct ns2_led_modval *modval; + int nmodes, ret, i; + + ret = of_property_read_string(np, "label", &led->name); + if (ret) + led->name = np->name; + + led->cmd = gpiod_get_from_of_node(np, "cmd-gpio", 0, GPIOD_ASIS, + led->name); + if (IS_ERR(led->cmd)) + return PTR_ERR(led->cmd); + + led->slow = gpiod_get_from_of_node(np, "slow-gpio", 0, GPIOD_ASIS, + led->name); + if (IS_ERR(led->slow)) + return PTR_ERR(led->slow); + + of_property_read_string(np, "linux,default-trigger", + &led->default_trigger); + + ret = of_property_count_u32_elems(np, "modes-map"); + if (ret < 0 || ret % 3) { + dev_err(dev, "Missing or malformed modes-map for %pOF\n", np); + return -EINVAL; + } + + nmodes = ret / 3; + modval = devm_kcalloc(dev, nmodes, sizeof(*modval), GFP_KERNEL); + if (!modval) + return -ENOMEM; + + for (i = 0; i < nmodes; i++) { + u32 val; + + of_property_read_u32_index(np, "modes-map", 3 * i, &val); + modval[i].mode = val; + of_property_read_u32_index(np, "modes-map", 3 * i + 1, &val); + modval[i].cmd_level = val; + of_property_read_u32_index(np, "modes-map", 3 * i + 2, &val); + modval[i].slow_level = val; + } + + led->num_modes = nmodes; + led->modval = modval; + + return 0; +} + /* * Translate OpenFirmware node properties into platform_data. */ @@ -252,78 +303,17 @@ ns2_leds_parse_of(struct device *dev, struct ns2_led_of *ofdata) led = leds; for_each_available_child_of_node(np, child) { - const char *string; - int i, num_modes; - struct ns2_led_modval *modval; - struct gpio_desc *gd; - - ret = of_property_read_string(child, "label", &string); - led->name = (ret == 0) ? string : child->name; - - gd = gpiod_get_from_of_node(child, "cmd-gpio", 0, - GPIOD_ASIS, led->name); - if (IS_ERR(gd)) { - ret = PTR_ERR(gd); - goto err_node_put; - } - led->cmd = gd; - gd = gpiod_get_from_of_node(child, "slow-gpio", 0, - GPIOD_ASIS, led->name); - if (IS_ERR(gd)) { - ret = PTR_ERR(gd); - goto err_node_put; - } - led->slow = gd; - - ret = of_property_read_string(child, "linux,default-trigger", - &string); - if (ret == 0) - led->default_trigger = string; - - ret = of_property_count_u32_elems(child, "modes-map"); - if (ret < 0 || ret % 3) { - dev_err(dev, - "Missing or malformed modes-map property\n"); - ret = -EINVAL; - goto err_node_put; - } - - num_modes = ret / 3; - modval = devm_kcalloc(dev, - num_modes, - sizeof(struct ns2_led_modval), - GFP_KERNEL); - if (!modval) { - ret = -ENOMEM; - goto err_node_put; - } - - for (i = 0; i < num_modes; i++) { - of_property_read_u32_index(child, - "modes-map", 3 * i, - (u32 *) &modval[i].mode); - of_property_read_u32_index(child, - "modes-map", 3 * i + 1, - (u32 *) &modval[i].cmd_level); - of_property_read_u32_index(child, - "modes-map", 3 * i + 2, - (u32 *) &modval[i].slow_level); + ret = ns2_leds_parse_one(dev, child, led++); + if (ret < 0) { + of_node_put(child); + return ret; } - - led->num_modes = num_modes; - led->modval = modval; - - led++; } ofdata->leds = leds; ofdata->num_leds = num_leds; return 0; - -err_node_put: - of_node_put(child); - return ret; } static const struct of_device_id of_ns2_leds_match[] = { From patchwork Thu Sep 17 22:33:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 562DCC43464 for ; Thu, 17 Sep 2020 22:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18E882087D for ; Thu, 17 Sep 2020 22:35:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="wBbttyCD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726333AbgIQWfC (ORCPT ); Thu, 17 Sep 2020 18:35:02 -0400 Received: from mail.nic.cz ([217.31.204.67]:36256 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbgIQWeQ (ORCPT ); Thu, 17 Sep 2020 18:34:16 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 1E94E14205E; Fri, 18 Sep 2020 00:34:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382041; bh=jZ8ZKbCaBfpOTI42umXMwjZ8PS6Z/JhU+RtfKD5P5nA=; h=From:To:Date; b=wBbttyCDphE/Gi2vKHzPd6S9NX3XrNgyZXCoQ3E8dgMUWQBjULofqPvCjpV+EvDs8 Fbi7BFBUpTHXHIve5a2mkeSSvOgVzFMveu/TMAQ4i9ql5/B/9rYjTDASd/BMWxvB5F bRoD0QZ0XtovbPi7ELc0Xh2em7/uowQLxykqV6oQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 42/50] leds: ns2: cosmetic variable rename Date: Fri, 18 Sep 2020 00:33:30 +0200 Message-Id: <20200917223338.14164-43-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Rename variable led_dat to led in various functions. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 103 ++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 56 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 6dba6208433ca..dde476420a733 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -62,21 +62,20 @@ struct ns2_led { struct ns2_led_modval *modval; }; -static int ns2_led_get_mode(struct ns2_led *led_dat, - enum ns2_led_modes *mode) +static int ns2_led_get_mode(struct ns2_led *led, enum ns2_led_modes *mode) { int i; int ret = -EINVAL; int cmd_level; int slow_level; - cmd_level = gpiod_get_value_cansleep(led_dat->cmd); - slow_level = gpiod_get_value_cansleep(led_dat->slow); + cmd_level = gpiod_get_value_cansleep(led->cmd); + slow_level = gpiod_get_value_cansleep(led->slow); - for (i = 0; i < led_dat->num_modes; i++) { - if (cmd_level == led_dat->modval[i].cmd_level && - slow_level == led_dat->modval[i].slow_level) { - *mode = led_dat->modval[i].mode; + for (i = 0; i < led->num_modes; i++) { + if (cmd_level == led->modval[i].cmd_level && + slow_level == led->modval[i].slow_level) { + *mode = led->modval[i].mode; ret = 0; break; } @@ -85,15 +84,14 @@ static int ns2_led_get_mode(struct ns2_led *led_dat, return ret; } -static void ns2_led_set_mode(struct ns2_led *led_dat, - enum ns2_led_modes mode) +static void ns2_led_set_mode(struct ns2_led *led, enum ns2_led_modes mode) { int i; bool found = false; unsigned long flags; - for (i = 0; i < led_dat->num_modes; i++) - if (mode == led_dat->modval[i].mode) { + for (i = 0; i < led->num_modes; i++) + if (mode == led->modval[i].mode) { found = true; break; } @@ -101,38 +99,35 @@ static void ns2_led_set_mode(struct ns2_led *led_dat, if (!found) return; - write_lock_irqsave(&led_dat->rw_lock, flags); + write_lock_irqsave(&led->rw_lock, flags); - if (!led_dat->can_sleep) { - gpiod_set_value(led_dat->cmd, - led_dat->modval[i].cmd_level); - gpiod_set_value(led_dat->slow, - led_dat->modval[i].slow_level); + if (!led->can_sleep) { + gpiod_set_value(led->cmd, led->modval[i].cmd_level); + gpiod_set_value(led->slow, led->modval[i].slow_level); goto exit_unlock; } - gpiod_set_value_cansleep(led_dat->cmd, led_dat->modval[i].cmd_level); - gpiod_set_value_cansleep(led_dat->slow, led_dat->modval[i].slow_level); + gpiod_set_value_cansleep(led->cmd, led->modval[i].cmd_level); + gpiod_set_value_cansleep(led->slow, led->modval[i].slow_level); exit_unlock: - write_unlock_irqrestore(&led_dat->rw_lock, flags); + write_unlock_irqrestore(&led->rw_lock, flags); } static void ns2_led_set(struct led_classdev *led_cdev, enum led_brightness value) { - struct ns2_led *led_dat = - container_of(led_cdev, struct ns2_led, cdev); + struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); enum ns2_led_modes mode; if (value == LED_OFF) mode = NS_V2_LED_OFF; - else if (led_dat->sata) + else if (led->sata) mode = NS_V2_LED_SATA; else mode = NS_V2_LED_ON; - ns2_led_set_mode(led_dat, mode); + ns2_led_set_mode(led, mode); } static int ns2_led_set_blocking(struct led_classdev *led_cdev, @@ -147,8 +142,7 @@ static ssize_t ns2_led_sata_store(struct device *dev, const char *buff, size_t count) { struct led_classdev *led_cdev = dev_get_drvdata(dev); - struct ns2_led *led_dat = - container_of(led_cdev, struct ns2_led, cdev); + struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); int ret; unsigned long enable; @@ -158,18 +152,18 @@ static ssize_t ns2_led_sata_store(struct device *dev, enable = !!enable; - if (led_dat->sata == enable) + if (led->sata == enable) goto exit; - led_dat->sata = enable; + led->sata = enable; if (!led_get_brightness(led_cdev)) goto exit; if (enable) - ns2_led_set_mode(led_dat, NS_V2_LED_SATA); + ns2_led_set_mode(led, NS_V2_LED_SATA); else - ns2_led_set_mode(led_dat, NS_V2_LED_ON); + ns2_led_set_mode(led, NS_V2_LED_ON); exit: return count; @@ -179,10 +173,9 @@ static ssize_t ns2_led_sata_show(struct device *dev, struct device_attribute *attr, char *buf) { struct led_classdev *led_cdev = dev_get_drvdata(dev); - struct ns2_led *led_dat = - container_of(led_cdev, struct ns2_led, cdev); + struct ns2_led *led = container_of(led_cdev, struct ns2_led, cdev); - return sprintf(buf, "%d\n", led_dat->sata); + return sprintf(buf, "%d\n", led->sata); } static DEVICE_ATTR(sata, 0644, ns2_led_sata_show, ns2_led_sata_store); @@ -194,40 +187,38 @@ static struct attribute *ns2_led_attrs[] = { ATTRIBUTE_GROUPS(ns2_led); static int -create_ns2_led(struct platform_device *pdev, struct ns2_led *led_dat, +create_ns2_led(struct platform_device *pdev, struct ns2_led *led, const struct ns2_led_of_one *template) { int ret; enum ns2_led_modes mode; - rwlock_init(&led_dat->rw_lock); - - led_dat->cdev.name = template->name; - led_dat->cdev.default_trigger = template->default_trigger; - led_dat->cdev.blink_set = NULL; - led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; - led_dat->cdev.groups = ns2_led_groups; - led_dat->cmd = template->cmd; - led_dat->slow = template->slow; - led_dat->can_sleep = gpiod_cansleep(led_dat->cmd) | - gpiod_cansleep(led_dat->slow); - if (led_dat->can_sleep) - led_dat->cdev.brightness_set_blocking = ns2_led_set_blocking; + rwlock_init(&led->rw_lock); + + led->cdev.name = template->name; + led->cdev.default_trigger = template->default_trigger; + led->cdev.blink_set = NULL; + led->cdev.flags |= LED_CORE_SUSPENDRESUME; + led->cdev.groups = ns2_led_groups; + led->cmd = template->cmd; + led->slow = template->slow; + led->can_sleep = gpiod_cansleep(led->cmd) | gpiod_cansleep(led->slow); + if (led->can_sleep) + led->cdev.brightness_set_blocking = ns2_led_set_blocking; else - led_dat->cdev.brightness_set = ns2_led_set; - led_dat->modval = template->modval; - led_dat->num_modes = template->num_modes; + led->cdev.brightness_set = ns2_led_set; + led->modval = template->modval; + led->num_modes = template->num_modes; - ret = ns2_led_get_mode(led_dat, &mode); + ret = ns2_led_get_mode(led, &mode); if (ret < 0) return ret; /* Set LED initial state. */ - led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; - led_dat->cdev.brightness = - (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; + led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; + led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - return devm_led_classdev_register(&pdev->dev, &led_dat->cdev); + return devm_led_classdev_register(&pdev->dev, &led->cdev); } static int ns2_leds_parse_one(struct device *dev, struct device_node *np, From patchwork Thu Sep 17 22:33:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87E1DC43464 for ; Thu, 17 Sep 2020 22:34:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 528882087D for ; Thu, 17 Sep 2020 22:34:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="EuhGpqLf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbgIQWeu (ORCPT ); Thu, 17 Sep 2020 18:34:50 -0400 Received: from mail.nic.cz ([217.31.204.67]:35812 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIQWeR (ORCPT ); Thu, 17 Sep 2020 18:34:17 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 50D15142064; Fri, 18 Sep 2020 00:34:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382041; bh=FAMJe7ITJwHvd1FSQ0yZOsBfv9QEw/KPWeoHMgngVTg=; h=From:To:Date; b=EuhGpqLf8WvukoxqnkqlVo7N7F+M0/SnvrfyARgExn6P4fsR05N2cL92GWPjUVw4g BnD++AoZBUpMENF2CahaNhM/OP/ftITLDpqi1avAeY+foN9CIrqF9o7rVwrtsjhTxB QjpqnV2A6TbiPZ1rgdlAdxdJ37Z9YRTQQsYea/BE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 43/50] leds: ns2: cosmetic change Date: Fri, 18 Sep 2020 00:33:31 +0200 Message-Id: <20200917223338.14164-44-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Return directly instead of setting result and breaking. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index dde476420a733..912db40c51183 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -65,7 +65,6 @@ struct ns2_led { static int ns2_led_get_mode(struct ns2_led *led, enum ns2_led_modes *mode) { int i; - int ret = -EINVAL; int cmd_level; int slow_level; @@ -76,12 +75,11 @@ static int ns2_led_get_mode(struct ns2_led *led, enum ns2_led_modes *mode) if (cmd_level == led->modval[i].cmd_level && slow_level == led->modval[i].slow_level) { *mode = led->modval[i].mode; - ret = 0; - break; + return 0; } } - return ret; + return -EINVAL; } static void ns2_led_set_mode(struct ns2_led *led, enum ns2_led_modes mode) From patchwork Thu Sep 17 22:33:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBEE3C43464 for ; Thu, 17 Sep 2020 22:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A61AD2087D for ; Thu, 17 Sep 2020 22:34:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="tmtTVYUa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbgIQWeo (ORCPT ); Thu, 17 Sep 2020 18:34:44 -0400 Received: from mail.nic.cz ([217.31.204.67]:35842 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbgIQWeS (ORCPT ); Thu, 17 Sep 2020 18:34:18 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 88985142066; Fri, 18 Sep 2020 00:34:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382041; bh=KyoQbN7zEtG1uv+Pu41Y0V6Z7eh7NxeLV28us6kXmE8=; h=From:To:Date; b=tmtTVYUaZxj57qHSwsrDrCOHMwRCTfX6m4ST8tOxjUYS8FNAqPlKj97GPxK+WxHSF 44alVESairypb+d5e1dSTnrJVYKkRKp4c08WGUiLPvlu2jOtpNkAmiOdPEVH55YcK1 1F6H74x3SSJ8VoRGaKk8qOBNB4ufuYsUmbHeo8bE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 44/50] leds: ns2: cosmetic change: use helper variable Date: Fri, 18 Sep 2020 00:33:32 +0200 Message-Id: <20200917223338.14164-45-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Use helper variable dev instead of always writing &pdev->dev. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 912db40c51183..801b7f851be7a 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -185,7 +185,7 @@ static struct attribute *ns2_led_attrs[] = { ATTRIBUTE_GROUPS(ns2_led); static int -create_ns2_led(struct platform_device *pdev, struct ns2_led *led, +create_ns2_led(struct device *dev, struct ns2_led *led, const struct ns2_led_of_one *template) { int ret; @@ -216,7 +216,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led *led, led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - return devm_led_classdev_register(&pdev->dev, &led->cdev); + return devm_led_classdev_register(dev, &led->cdev); } static int ns2_leds_parse_one(struct device *dev, struct device_node *np, @@ -313,28 +313,27 @@ MODULE_DEVICE_TABLE(of, of_ns2_leds_match); static int ns2_led_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct ns2_led_of *ofdata; struct ns2_led *leds; int i; int ret; - ofdata = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_of), - GFP_KERNEL); + ofdata = devm_kzalloc(dev, sizeof(struct ns2_led_of), GFP_KERNEL); if (!ofdata) return -ENOMEM; - ret = ns2_leds_parse_of(&pdev->dev, ofdata); + ret = ns2_leds_parse_of(dev, ofdata); if (ret) return ret; - leds = devm_kzalloc(&pdev->dev, array_size(sizeof(*leds), - ofdata->num_leds), + leds = devm_kzalloc(dev, array_size(sizeof(*leds), ofdata->num_leds), GFP_KERNEL); if (!leds) return -ENOMEM; for (i = 0; i < ofdata->num_leds; i++) { - ret = create_ns2_led(pdev, &leds[i], &ofdata->leds[i]); + ret = create_ns2_led(dev, &leds[i], &ofdata->leds[i]); if (ret < 0) return ret; } From patchwork Thu Sep 17 22:33:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD838C43464 for ; Thu, 17 Sep 2020 22:34:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 764EF208DB for ; Thu, 17 Sep 2020 22:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="Wp5Vk+SL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbgIQWef (ORCPT ); Thu, 17 Sep 2020 18:34:35 -0400 Received: from lists.nic.cz ([217.31.204.67]:35722 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726347AbgIQWeT (ORCPT ); Thu, 17 Sep 2020 18:34:19 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id C2314142068; Fri, 18 Sep 2020 00:34:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382041; bh=bWBxtm/Bkw8TBL9pw+a5KOewdNkZWECN0cSyuzsW+vs=; h=From:To:Date; b=Wp5Vk+SLjrRyG5OiBklZYz/Z1LkDEJYnVM7evRHBzpabPfATpT9B3S3UWKyGnIhce hwpKBuVJDlt3aaAJswHy+M2YaG3D+18K56oWIexcMFM3TzUniPslbhp8x3Zgvc0wrl 4yoTPAYm4Td+8m9nC4pzmdCKXfHBAe03I/7LzbRg= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= , Simon Guinot , Simon Guinot , Vincent Donnefort , Thomas Petazzoni , Linus Walleij Subject: [PATCH leds v2 45/50] leds: ns2: register LED immediately after parsing DT properties Date: Fri, 18 Sep 2020 00:33:33 +0200 Message-Id: <20200917223338.14164-46-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Register each LED immediately after parsing OF properties. This simplifies the driver. Signed-off-by: Marek Behún Cc: Simon Guinot Cc: Simon Guinot Cc: Vincent Donnefort Cc: Thomas Petazzoni Cc: Linus Walleij --- drivers/leds/leds-ns2.c | 143 +++++++++++----------------------------- 1 file changed, 40 insertions(+), 103 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 801b7f851be7a..9d9c9ff4dce61 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -30,20 +30,6 @@ struct ns2_led_modval { int slow_level; }; -struct ns2_led_of_one { - const char *name; - const char *default_trigger; - struct gpio_desc *cmd; - struct gpio_desc *slow; - int num_modes; - struct ns2_led_modval *modval; -}; - -struct ns2_led_of { - int num_leds; - struct ns2_led_of_one *leds; -}; - /* * The Network Space v2 dual-GPIO LED is wired to a CPLD. Three different LED * modes are available: off, on and SATA activity blinking. The LED modes are @@ -184,63 +170,29 @@ static struct attribute *ns2_led_attrs[] = { }; ATTRIBUTE_GROUPS(ns2_led); -static int -create_ns2_led(struct device *dev, struct ns2_led *led, - const struct ns2_led_of_one *template) -{ - int ret; - enum ns2_led_modes mode; - - rwlock_init(&led->rw_lock); - - led->cdev.name = template->name; - led->cdev.default_trigger = template->default_trigger; - led->cdev.blink_set = NULL; - led->cdev.flags |= LED_CORE_SUSPENDRESUME; - led->cdev.groups = ns2_led_groups; - led->cmd = template->cmd; - led->slow = template->slow; - led->can_sleep = gpiod_cansleep(led->cmd) | gpiod_cansleep(led->slow); - if (led->can_sleep) - led->cdev.brightness_set_blocking = ns2_led_set_blocking; - else - led->cdev.brightness_set = ns2_led_set; - led->modval = template->modval; - led->num_modes = template->num_modes; - - ret = ns2_led_get_mode(led, &mode); - if (ret < 0) - return ret; - - /* Set LED initial state. */ - led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; - led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - - return devm_led_classdev_register(dev, &led->cdev); -} - -static int ns2_leds_parse_one(struct device *dev, struct device_node *np, - struct ns2_led_of_one *led) +static int ns2_led_register(struct device *dev, struct device_node *np, + struct ns2_led *led) { struct ns2_led_modval *modval; + enum ns2_led_modes mode; int nmodes, ret, i; - ret = of_property_read_string(np, "label", &led->name); + ret = of_property_read_string(np, "label", &led->cdev.name); if (ret) - led->name = np->name; + led->cdev.name = np->name; led->cmd = devm_gpiod_get_from_of_node(dev, np, "cmd-gpio", 0, - GPIOD_ASIS, led->name); + GPIOD_ASIS, np->name); if (IS_ERR(led->cmd)) return PTR_ERR(led->cmd); led->slow = devm_gpiod_get_from_of_node(dev, np, "slow-gpio", 0, - GPIOD_ASIS, led->name); + GPIOD_ASIS, np->name); if (IS_ERR(led->slow)) return PTR_ERR(led->slow); of_property_read_string(np, "linux,default-trigger", - &led->default_trigger); + &led->cdev.default_trigger); ret = of_property_count_u32_elems(np, "modes-map"); if (ret < 0 || ret % 3) { @@ -264,45 +216,32 @@ static int ns2_leds_parse_one(struct device *dev, struct device_node *np, modval[i].slow_level = val; } + rwlock_init(&led->rw_lock); + + led->cdev.blink_set = NULL; + led->cdev.flags |= LED_CORE_SUSPENDRESUME; + led->cdev.groups = ns2_led_groups; + led->can_sleep = gpiod_cansleep(led->cmd) || gpiod_cansleep(led->slow); + if (led->can_sleep) + led->cdev.brightness_set_blocking = ns2_led_set_blocking; + else + led->cdev.brightness_set = ns2_led_set; led->num_modes = nmodes; led->modval = modval; - return 0; -} - -/* - * Translate OpenFirmware node properties into platform_data. - */ -static int -ns2_leds_parse_of(struct device *dev, struct ns2_led_of *ofdata) -{ - struct device_node *np = dev_of_node(dev); - struct device_node *child; - struct ns2_led_of_one *led, *leds; - int ret, num_leds = 0; - - num_leds = of_get_available_child_count(np); - if (!num_leds) - return -ENODEV; - - leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led), - GFP_KERNEL); - if (!leds) - return -ENOMEM; + ret = ns2_led_get_mode(led, &mode); + if (ret < 0) + return ret; - led = leds; - for_each_available_child_of_node(np, child) { - ret = ns2_leds_parse_one(dev, child, led++); - if (ret < 0) { - of_node_put(child); - return ret; - } - } + /* Set LED initial state. */ + led->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; + led->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; - ofdata->leds = leds; - ofdata->num_leds = num_leds; + ret = devm_led_classdev_register(dev, &led->cdev); + if (ret) + dev_err(dev, "Failed to register LED for node %pOF\n", np); - return 0; + return ret; } static const struct of_device_id of_ns2_leds_match[] = { @@ -314,28 +253,26 @@ MODULE_DEVICE_TABLE(of, of_ns2_leds_match); static int ns2_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ns2_led_of *ofdata; + struct device_node *np, *child; struct ns2_led *leds; - int i; + int count; int ret; - ofdata = devm_kzalloc(dev, sizeof(struct ns2_led_of), GFP_KERNEL); - if (!ofdata) - return -ENOMEM; - - ret = ns2_leds_parse_of(dev, ofdata); - if (ret) - return ret; + np = dev_of_node(dev); + count = of_get_available_child_count(np); + if (!count) + return -ENODEV; - leds = devm_kzalloc(dev, array_size(sizeof(*leds), ofdata->num_leds), - GFP_KERNEL); + leds = devm_kzalloc(dev, array_size(sizeof(*leds), count), GFP_KERNEL); if (!leds) return -ENOMEM; - for (i = 0; i < ofdata->num_leds; i++) { - ret = create_ns2_led(dev, &leds[i], &ofdata->leds[i]); - if (ret < 0) + for_each_available_child_of_node(np, child) { + ret = ns2_led_register(dev, child, leds++); + if (ret) { + of_node_put(child); return ret; + } } return 0; From patchwork Thu Sep 17 22:33:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 255404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C19D2C43463 for ; Thu, 17 Sep 2020 22:34:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DC302087D for ; Thu, 17 Sep 2020 22:34:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="c/V296vk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbgIQWeb (ORCPT ); Thu, 17 Sep 2020 18:34:31 -0400 Received: from mail.nic.cz ([217.31.204.67]:35844 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726361AbgIQWeU (ORCPT ); Thu, 17 Sep 2020 18:34:20 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D6290140A7F; Fri, 18 Sep 2020 00:34:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382043; bh=pLtMtdFnbEp3DRRyAAdbeWVG6uj58PfNKrN6auAX6Fw=; h=From:To:Date; b=c/V296vkWb1laKWprTexBfzbyCva+6NbrciQZcpgIv33Z+7/lMx6wuPHEUpeMJo5S GRhUcg2n258k6YQevqoMtwH5fCNc+TFy8Y2yUNTqQhX/r92ebFELppAjQ4OL3t1lXC TEsJDGW3y3T9vySg6OkM7JuykDX1UJ/FrZCLhdeM= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?utf-8?q?On?= =?utf-8?q?d=C5=99ej_Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH leds v2 50/50] leds: parse linux, default-trigger DT property in LED core Date: Fri, 18 Sep 2020 00:33:38 +0200 Message-Id: <20200917223338.14164-51-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Do parsing of `linux,default-trigger` DT property to LED core. Currently it is done in many different drivers and the code is repeated. This patch removes the parsing from 21 drivers: an30259a, aw2013, bcm6328, bcm6358, cr0014114, el15203000, gpio, is31fl319x, is31fl32xx, lm3532, lm36274, lm3692x, lm3697, lp8860, lt3593, max77650, mt6323, ns2, pm8058, tlc591xx and turris-omnia. There are still 11 drivers that parse this property on their own because they do not pass the led_init_data structure to the registering function. I will try to refactor those in the future. Signed-off-by: Marek Behún --- drivers/leds/led-class.c | 5 +++++ drivers/leds/leds-an30259a.c | 3 --- drivers/leds/leds-aw2013.c | 3 --- drivers/leds/leds-bcm6328.c | 4 ---- drivers/leds/leds-bcm6358.c | 4 ---- drivers/leds/leds-cr0014114.c | 3 --- drivers/leds/leds-el15203000.c | 3 --- drivers/leds/leds-gpio.c | 3 --- drivers/leds/leds-is31fl319x.c | 5 ----- drivers/leds/leds-is31fl32xx.c | 3 --- drivers/leds/leds-lm3532.c | 3 --- drivers/leds/leds-lm36274.c | 3 --- drivers/leds/leds-lm3692x.c | 3 --- drivers/leds/leds-lm3697.c | 3 --- drivers/leds/leds-lp8860.c | 4 ---- drivers/leds/leds-lt3593.c | 3 --- drivers/leds/leds-max77650.c | 3 --- drivers/leds/leds-mt6323.c | 4 ---- drivers/leds/leds-ns2.c | 3 --- drivers/leds/leds-pm8058.c | 2 -- drivers/leds/leds-tlc591xx.c | 3 --- drivers/leds/leds-turris-omnia.c | 2 -- 22 files changed, 5 insertions(+), 67 deletions(-) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index cc3929f858b68..131ca83f5fb38 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -354,6 +354,11 @@ int led_classdev_register_ext(struct device *parent, ret = led_compose_name(parent, init_data, composed_name); if (ret < 0) return ret; + + if (init_data->fwnode) + fwnode_property_read_string(init_data->fwnode, + "linux,default-trigger", + &led_cdev->default_trigger); } else { proposed_name = led_cdev->name; } diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index 9749f1cc3e15f..a0df1fb28774d 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -238,9 +238,6 @@ static int an30259a_dt_init(struct i2c_client *client, led->default_state = STATE_OFF; } - of_property_read_string(child, "linux,default-trigger", - &led->cdev.default_trigger); - i++; } diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 927c5ba32592f..80d937454aeef 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -297,9 +297,6 @@ static int aw2013_probe_dt(struct aw2013 *chip) "DT property led-max-microamp is missing\n"); } - of_property_read_string(child, "linux,default-trigger", - &led->cdev.default_trigger); - led->cdev.brightness_set_blocking = aw2013_brightness_set; led->cdev.blink_set = aw2013_blink_set; diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 38bf820372528..f89ca2143b95d 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -346,10 +346,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - led->cdev.default_trigger = of_get_property(nc, - "linux,default-trigger", - NULL); - if (!of_property_read_string(nc, "default-state", &state)) { if (!strcmp(state, "on")) { led->cdev.brightness = LED_FULL; diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 71c49d5fa811f..aabf68d276216 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -110,10 +110,6 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - led->cdev.default_trigger = of_get_property(nc, - "linux,default-trigger", - NULL); - if (!of_property_read_string(nc, "default-state", &state)) { if (!strcmp(state, "on")) { led->cdev.brightness = LED_FULL; diff --git a/drivers/leds/leds-cr0014114.c b/drivers/leds/leds-cr0014114.c index a2f5638eda5f7..e0be7603d4791 100644 --- a/drivers/leds/leds-cr0014114.c +++ b/drivers/leds/leds-cr0014114.c @@ -188,9 +188,6 @@ static int cr0014114_probe_dt(struct cr0014114 *priv) device_for_each_child_node(priv->dev, child) { led = &priv->leds[i]; - fwnode_property_read_string(child, "linux,default-trigger", - &led->ldev.default_trigger); - led->priv = priv; led->ldev.max_brightness = CR_MAX_BRIGHTNESS; led->ldev.brightness_set_blocking = cr0014114_set_sync; diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index bcd13a7fc9d02..f8a56ebd87060 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -263,9 +263,6 @@ static int el15203000_probe_dt(struct el15203000 *priv) return -EINVAL; } - fwnode_property_read_string(child, "linux,default-trigger", - &led->ldev.default_trigger); - led->priv = priv; led->ldev.max_brightness = LED_ON; led->ldev.brightness_set_blocking = el15203000_set_blocking; diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index aa740267eb232..09fd6b1e8fc38 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -160,9 +160,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) led_dat->gpiod = led.gpiod; - fwnode_property_read_string(child, "linux,default-trigger", - &led.default_trigger); - if (!fwnode_property_read_string(child, "default-state", &state)) { if (!strcmp(state, "keep")) diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c index ef5b3e08c7313..23616dded8284 100644 --- a/drivers/leds/leds-is31fl319x.c +++ b/drivers/leds/leds-is31fl319x.c @@ -293,11 +293,6 @@ static int is31fl319x_led_register(struct device *dev, return -EEXIST; } - ret = of_property_read_string(np, "linux,default-trigger", - &led->cdev.default_trigger); - if (ret < 0 && ret != -EINVAL) /* is optional */ - return ret; - led->configured = true; led->chip = is31; led->cdev.brightness_set_blocking = is31fl319x_brightness_set; diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index 279f52931a177..d21b333a17e8e 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -341,9 +341,6 @@ static int is31fl32xx_parse_child_dt(const struct device *dev, } led_data->channel = reg; - of_property_read_string(child, "linux,default-trigger", - &cdev->default_trigger); - cdev->brightness_set_blocking = is31fl32xx_brightness_set; return 0; diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 3670cc64eee7b..610168dc7ad77 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -643,9 +643,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) goto child_out; } - fwnode_property_read_string(child, "linux,default-trigger", - &led->led_dev.default_trigger); - ret = fwnode_property_read_string(child, "label", &name); if (ret) snprintf(led->label, sizeof(led->label), diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index b61c97ed26603..b49b85207fd8a 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -97,9 +97,6 @@ static int lm36274_parse_dt(struct lm36274 *chip, goto err; } - fwnode_property_read_string(child, "linux,default-trigger", - &chip->led_dev.default_trigger); - return 0; err: fwnode_handle_put(child); diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index ba535ee8fd252..27327bf6ea025 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -433,9 +433,6 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) return -ENODEV; } - fwnode_property_read_string(child, "linux,default-trigger", - &led->led_dev.default_trigger); - ret = fwnode_property_read_u32(child, "reg", &led->led_enable); if (ret) { dev_err(&led->client->dev, "reg DT property missing\n"); diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 0c5c29730c407..50338ae0b7857 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -268,9 +268,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) if (ret) dev_warn(dev, "runtime-ramp properties missing\n"); - fwnode_property_read_string(child, "linux,default-trigger", - &led->led_dev.default_trigger); - init_data.fwnode = child; init_data.devicename = priv->client->name; /* for backwards compatibility if `label` is not present */ diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index b69ed81d52ab4..f9b8abaac6b73 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -392,10 +392,6 @@ static int lp8860_probe(struct i2c_client *client, if (!child_node) return -EINVAL; - led->led_dev.default_trigger = of_get_property(child_node, - "linux,default-trigger", - NULL); - led->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(led->enable_gpio)) { diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 061f02e3995ae..68e06434ac087 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -86,9 +86,6 @@ static int lt3593_led_probe(struct platform_device *pdev) child = device_get_next_child_node(dev, NULL); - fwnode_property_read_string(child, "linux,default-trigger", - &led_data->cdev.default_trigger); - if (!fwnode_property_read_string(child, "default-state", &tmp)) { if (!strcmp(tmp, "on")) state = LEDS_GPIO_DEFSTATE_ON; diff --git a/drivers/leds/leds-max77650.c b/drivers/leds/leds-max77650.c index bed620fc1b82e..169686a205000 100644 --- a/drivers/leds/leds-max77650.c +++ b/drivers/leds/leds-max77650.c @@ -100,9 +100,6 @@ static int max77650_led_probe(struct platform_device *pdev) led->cdev.brightness_set_blocking = max77650_led_brightness_set; led->cdev.max_brightness = MAX77650_LED_MAX_BRIGHTNESS; - fwnode_property_read_string(child, "linux,default-trigger", - &led->cdev.default_trigger); - init_data.fwnode = child; init_data.devicename = "max77650"; /* for backwards compatibility if `label` is not present */ diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 5119dcc0aef24..b46661b4c36b2 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -342,10 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, const char *state; int ret = 0; - led->cdev.default_trigger = of_get_property(np, - "linux,default-trigger", - NULL); - state = of_get_property(np, "default-state", NULL); if (state) { if (!strcmp(state, "keep")) { diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index b021e94d512c9..d033c4e08d45b 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -189,9 +189,6 @@ static int ns2_led_register(struct device *dev, struct device_node *np, if (IS_ERR(led->slow)) return PTR_ERR(led->slow); - of_property_read_string(np, "linux,default-trigger", - &led->cdev.default_trigger); - ret = of_property_count_u32_elems(np, "modes-map"); if (ret < 0 || ret % 3) { dev_err(dev, "Missing or malformed modes-map for %pOF\n", np); diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index 80db7e2de420c..bcb0a214f6eff 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -117,8 +117,6 @@ static int pm8058_led_probe(struct platform_device *pdev) return -EINVAL; } - led->cdev.default_trigger = - of_get_property(np, "linux,default-trigger", NULL); led->cdev.brightness_set = pm8058_led_set; led->cdev.brightness_get = pm8058_led_get; if (led->ledtype == PM8058_LED_TYPE_COMMON) diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c index 5e84a0c7aacbd..f24271337bd84 100644 --- a/drivers/leds/leds-tlc591xx.c +++ b/drivers/leds/leds-tlc591xx.c @@ -199,9 +199,6 @@ tlc591xx_probe(struct i2c_client *client, led = &priv->leds[reg]; led->active = true; - led->ldev.default_trigger = - of_get_property(child, "linux,default-trigger", NULL); - led->priv = priv; led->led_no = reg; led->ldev.brightness_set_blocking = tlc591xx_brightness_set; diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index c276969137d7f..ad941dd1484fa 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -121,8 +121,6 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, cdev->max_brightness = 255; cdev->brightness_set_blocking = omnia_led_brightness_set_blocking; - of_property_read_string(np, "linux,default-trigger", &cdev->default_trigger); - /* put the LED into software mode */ ret = i2c_smbus_write_byte_data(client, CMD_LED_MODE, CMD_LED_MODE_LED(led->reg) |