From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42BC3C3DA7D for ; Tue, 3 Jan 2023 13:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237721AbjACNMw (ORCPT ); Tue, 3 Jan 2023 08:12:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237662AbjACNMh (ORCPT ); Tue, 3 Jan 2023 08:12:37 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10429FD3E; Tue, 3 Jan 2023 05:12:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751557; x=1704287557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b85nclneF9BX61RtcZxdbpTMJV7DSQfjZ+m4p4X2wC0=; b=And5CoS5AYO+F1LcLzpVB1+b6JPQ9qKguZD102C7kdEMHGTNk3g+RmKh 34ZrnkRi88Dw+qBYXi5TfADU44h4cmT/ySKDxRVdAU/miISoamFS+STkU mgRqfUBOu3M5BI8OUcE4EStmS64hhaiEWyPslf5ZKJ4kQudQvUEq9j028 UCRGVPVlfzgJOGjA6tMkbKYRgNwnaPUAtLVb3FXxWFjF3mQPtQVvk5SE4 yfp0gS9lnbi0tRIFvtuOMqn1xk9u/1f8Duea5tLWY+Pg9p2UMGc8vElAY fnTdTY61mKMyA3c2B9YrZ8nl3PFZaYRE8LASk86VLN7FgADN2G0eX31jr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887924" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887924" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397926" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397926" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 79000F4; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 01/11] leds: add missing includes and forward declarations in leds.h Date: Tue, 3 Jan 2023 15:12:46 +0200 Message-Id: <20230103131256.33894-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add missing includes and forward declarations to leds.h. While at it, replace headers by forward declarations and vise versa. Signed-off-by: Andy Shevchenko --- include/linux/leds.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/leds.h b/include/linux/leds.h index ba4861ec73d3..499aea1e59b9 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -10,17 +10,21 @@ =20 #include #include -#include -#include #include #include #include #include +#include #include =20 -struct device; -struct led_pattern; +struct attribute_group; struct device_node; +struct fwnode_handle; +struct gpio_desc; +struct kernfs_node; +struct led_pattern; +struct platform_device; + /* * LED Core */ @@ -508,7 +512,6 @@ struct led_properties { const char *label; }; =20 -struct gpio_desc; typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state, unsigned long *delay_on, unsigned long *delay_off); --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F145CC3DA7D for ; Tue, 3 Jan 2023 13:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237717AbjACNMo (ORCPT ); Tue, 3 Jan 2023 08:12:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237656AbjACNMg (ORCPT ); Tue, 3 Jan 2023 08:12:36 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFAD8EE37; Tue, 3 Jan 2023 05:12:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751556; x=1704287556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NEeFuL7s2HGlJGPjMrfp/6jwPjBk7uYpbdHP2kx39AA=; b=N74I6rDUI5LY4crRUGj9Iw/6qTocz4VKc5ogvmNc/Hr4AU7ArIHGxlnt kFnPQ6i/q48IrbAq4rul2XqQlX2K8GptalEIOZVC4eSBTWxxoX3l9LPxA yCL3wfdc7iwnphLOBnCg9i3ACyoLjZ0aTWhuRBjZr6B8x8TCmrKqOvWaW yWXcCLqJZPjsTD+/od2Es9fdfcUfqu3TTAZWOihJMgvasNwQe6tqzO+0I p+YujOSlXFquA/REbNRHPIrt3lPVvWObr1yFLw3l9pr+GSQKGD3Bijdpw p+KB5AU1a8ON3jj370R38G/H1mu9IbC+f/AyPou16ki0jc4SB+XtaMHeF Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887894" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887894" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397925" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397925" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 85BF21CA; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 02/11] leds: Move led_init_default_state_get() to the global header Date: Tue, 3 Jan 2023 15:12:47 +0200 Message-Id: <20230103131256.33894-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There are users inside and outside LED framework that have implemented a local copy of led_init_default_state_get(). In order to deduplicate that, as the first step move the declaration from LED header to the global one. Signed-off-by: Andy Shevchenko --- drivers/leds/leds.h | 1 - include/linux/leds.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index aa64757a4d89..345062ccabda 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h @@ -27,7 +27,6 @@ ssize_t led_trigger_read(struct file *filp, struct kobjec= t *kobj, ssize_t led_trigger_write(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count); -enum led_default_state led_init_default_state_get(struct fwnode_handle *fw= node); =20 extern struct rw_semaphore leds_list_lock; extern struct list_head leds_list; diff --git a/include/linux/leds.h b/include/linux/leds.h index 499aea1e59b9..b96feacc73f8 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -67,6 +67,8 @@ struct led_init_data { bool devname_mandatory; }; =20 +enum led_default_state led_init_default_state_get(struct fwnode_handle *fw= node); + struct led_hw_trigger_type { int dummy; }; --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B6CCC54EBD for ; Tue, 3 Jan 2023 13:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237704AbjACNMl (ORCPT ); Tue, 3 Jan 2023 08:12:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233197AbjACNMf (ORCPT ); Tue, 3 Jan 2023 08:12:35 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9438FFAF4; Tue, 3 Jan 2023 05:12:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751554; x=1704287554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2vu7l/6K0nvkzNmUjyptRlngyguT+RoN4sYZnyNxAgU=; b=Swr37CLj2gh1BsOP9p5cf1C484uGxngOH57/mgOpKpilAQKS1YFXs1Bs 0ObO9JcQVrQRJ7JKS+4171kNy05X0JDL6792qxriiEZGg/9yvhmoZ7//J bFu2jKsyTO3/3CDdERqxQIN7SKRC4usiB9o7ODkvKMp/Ia2C9mT1+8mmp Ja6b64A8xZRAX/MeVIWhnp72MgmcFGXu3mERgV1YGRFDaYE8fPWCMV3Ct kbIqFhHm6WnmQhjyzBb6PZ8sjYS9yUMJIFPfOlqjihlTxN6b2os6O9s4L /RgfcYO363IPmYwW1Y1erlNI6MFWWytRD5vdL5FzqkJ67hudyLCkmeLsy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320367246" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="320367246" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="654781131" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654781131" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2023 05:12:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 91CA1220; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:48 +0200 Message-Id: <20230103131256.33894-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-an30259a.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index e072ee5409f7..89df267853a9 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -55,10 +55,6 @@ =20 #define AN30259A_NAME "an30259a" =20 -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct an30259a; =20 struct an30259a_led { @@ -66,7 +62,7 @@ struct an30259a_led { struct fwnode_handle *fwnode; struct led_classdev cdev; u32 num; - u32 default_state; + enum led_default_state default_state; bool sloping; }; =20 @@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client, struct device_node *np =3D dev_of_node(&client->dev), *child; int count, ret; int i =3D 0; - const char *str; struct an30259a_led *led; =20 count =3D of_get_available_child_count(np); @@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client, led->num =3D source; led->chip =3D chip; led->fwnode =3D of_fwnode_handle(child); - - if (!of_property_read_string(child, "default-state", &str)) { - if (!strcmp(str, "on")) - led->default_state =3D STATE_ON; - else if (!strcmp(str, "keep")) - led->default_state =3D STATE_KEEP; - else - led->default_state =3D STATE_OFF; - } + led->default_state =3D led_init_default_state_get(led->fwnode); =20 i++; } @@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an3025= 9a_led *led) int led_on, err; =20 switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->cdev.brightness =3D LED_FULL; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: err =3D regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on); if (err) break; --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6382C46467 for ; Tue, 3 Jan 2023 13:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237719AbjACNMr (ORCPT ); Tue, 3 Jan 2023 08:12:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237660AbjACNMh (ORCPT ); Tue, 3 Jan 2023 08:12:37 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B04D2FAFD; Tue, 3 Jan 2023 05:12:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751556; x=1704287556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fLglo+upgf8/JpSJNXXF1To0jqbOVKWrlAOKnDglss8=; b=UMfWs+faQ2yM3oIhVCeufdqzQA7CpsYpDrtbXyI2x09eh5xZ6gUUHIex Nqm/tiCW+YkdkYLQDOIANhJw2Wc5xI6BOfVt+9RTeFUAyiodh8YjyQFvr hQ8/L+Wq6eUPIrgyjsAQIBhajpvwtBMMmu96iG/Ol4Tundnvv1Y+wJUln Ij3J2EiD+CJlbuJ49Cd+xY+EaIeogBhPbaiL53vopUdoioKP5+Xi9Bje4 r2m9YXKfiso7nLI4qfjwaWPFUZRIRKSm70gbheVmEWO4uDENf4gvc8IIl Vt6urdkrswn7KhTcbB4Sb5hG/hoDMIMCpBiQGiBoM4mxuxxb4PwPdf8YP A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887912" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887912" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397924" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397924" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9B761252; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 04/11] leds: bcm6328: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:49 +0200 Message-Id: <20230103131256.33894-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli --- drivers/leds/leds-bcm6328.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 2d4d87957a30..246f1296ab09 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct devic= e_node *nc, u32 reg, { struct led_init_data init_data =3D {}; struct bcm6328_led *led; - const char *state; + enum led_default_state state; + unsigned long val, shift; + void __iomem *mode; int rc; =20 led =3D devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); @@ -346,31 +348,29 @@ static int bcm6328_led(struct device *dev, struct dev= ice_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low =3D true; =20 - if (!of_property_read_string(nc, "default-state", &state)) { - if (!strcmp(state, "on")) { + init_data.fwnode =3D of_fwnode_handle(nc); + + state =3D led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness =3D LED_FULL; + break; + case LEDS_DEFSTATE_KEEP: + shift =3D bcm6328_pin2shift(led->pin); + if (shift / 16) + mode =3D mem + BCM6328_REG_MODE_HI; + else + mode =3D mem + BCM6328_REG_MODE_LO; + + val =3D bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16); + val &=3D BCM6328_LED_MODE_MASK; + if ((led->active_low && val =3D=3D BCM6328_LED_MODE_OFF) || + (!led->active_low && val =3D=3D BCM6328_LED_MODE_ON)) led->cdev.brightness =3D LED_FULL; - } else if (!strcmp(state, "keep")) { - void __iomem *mode; - unsigned long val, shift; - - shift =3D bcm6328_pin2shift(led->pin); - if (shift / 16) - mode =3D mem + BCM6328_REG_MODE_HI; - else - mode =3D mem + BCM6328_REG_MODE_LO; - - val =3D bcm6328_led_read(mode) >> - BCM6328_LED_SHIFT(shift % 16); - val &=3D BCM6328_LED_MODE_MASK; - if ((led->active_low && val =3D=3D BCM6328_LED_MODE_OFF) || - (!led->active_low && val =3D=3D BCM6328_LED_MODE_ON)) - led->cdev.brightness =3D LED_FULL; - else - led->cdev.brightness =3D LED_OFF; - } else { + else led->cdev.brightness =3D LED_OFF; - } - } else { + break; + default: led->cdev.brightness =3D LED_OFF; } =20 @@ -378,7 +378,6 @@ static int bcm6328_led(struct device *dev, struct devic= e_node *nc, u32 reg, =20 led->cdev.brightness_set =3D bcm6328_led_set; led->cdev.blink_set =3D bcm6328_blink_set; - init_data.fwnode =3D of_fwnode_handle(nc); =20 rc =3D devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC3F6C3DA7D for ; Tue, 3 Jan 2023 13:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233200AbjACNNs (ORCPT ); Tue, 3 Jan 2023 08:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237731AbjACNNM (ORCPT ); Tue, 3 Jan 2023 08:13:12 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299E011149; Tue, 3 Jan 2023 05:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751564; x=1704287564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7p6zWbQRFO6BWGKdmzxHibs27PU9es81+rcbWbLCG20=; b=j722cG7A2lXzw/ka6jI1UYD83qpkWlRMTyb/+mfQJwHTjYrJiRIt1ngc mB+xPxgwjsgNCrNpXXUcY2kgrXbVG5olZbG2VhkQ8EiUqNR2prKGlkKmI Z21JqNnLBGOys8YQG+4TApLmTOSjlML1vZIOrfcD/Qtf6kB+dSx3oiM8F HJm6L/YUTkc6A6bmEDZg+ivX9aKIFHOJYxsRdzh5YbemjJ6ZxfIgnHzEH Rzqixq7bv9Pm5xxfKPGL1mnmkWM7dfgawQch8EqQlImC33+54tqqCb3o+ VWE/PCRSGjZdRnmfYQsv3ZvcAiJCVMdpjDwOmXDtYl2fvkcgq8GZMDa1a Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887977" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887977" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397941" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397941" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A5E0C2AA; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 05/11] leds: bcm6358: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:50 +0200 Message-Id: <20230103131256.33894-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli --- drivers/leds/leds-bcm6358.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 9d2e487fa08a..86e51d44a5a7 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -96,7 +96,8 @@ static int bcm6358_led(struct device *dev, struct device_= node *nc, u32 reg, { struct led_init_data init_data =3D {}; struct bcm6358_led *led; - const char *state; + enum led_default_state state; + unsigned long val; int rc; =20 led =3D devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); @@ -110,29 +111,28 @@ static int bcm6358_led(struct device *dev, struct dev= ice_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low =3D true; =20 - if (!of_property_read_string(nc, "default-state", &state)) { - if (!strcmp(state, "on")) { + init_data.fwnode =3D of_fwnode_handle(nc); + + state =3D led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness =3D LED_FULL; + break; + case LEDS_DEFSTATE_KEEP: + val =3D bcm6358_led_read(led->mem + BCM6358_REG_MODE); + val &=3D BIT(led->pin); + if ((led->active_low && !val) || (!led->active_low && val)) led->cdev.brightness =3D LED_FULL; - } else if (!strcmp(state, "keep")) { - unsigned long val; - val =3D bcm6358_led_read(led->mem + BCM6358_REG_MODE); - val &=3D BIT(led->pin); - if ((led->active_low && !val) || - (!led->active_low && val)) - led->cdev.brightness =3D LED_FULL; - else - led->cdev.brightness =3D LED_OFF; - } else { + else led->cdev.brightness =3D LED_OFF; - } - } else { + break; + default: led->cdev.brightness =3D LED_OFF; } =20 bcm6358_led_set(&led->cdev, led->cdev.brightness); =20 led->cdev.brightness_set =3D bcm6358_led_set; - init_data.fwnode =3D of_fwnode_handle(nc); =20 rc =3D devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0) --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B7A0C3DA7D for ; Tue, 3 Jan 2023 13:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237798AbjACNNk (ORCPT ); Tue, 3 Jan 2023 08:13:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237730AbjACNNM (ORCPT ); Tue, 3 Jan 2023 08:13:12 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2994F10FCA; Tue, 3 Jan 2023 05:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751564; x=1704287564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YAyO0NuKkjE8s2MjpGiLsRbRFZd9cli0OG3nOsmD+I=; b=MuDNEBmli6TnNdQW14WCV4+aEE0WA9x1pYBpWmgz0R5onaKmxBMsocwg OBU1ChFtkiedbTFmseOiVEFfQqDAdJlf3T4hUYLxhTbr0wnmwk5inLsXz nzn6KVgxSUihqkrl+cgAYzMqShvJL2whKOAZLiy4bHqypjUbeui8e/jX7 1Vhgz5p/nyAL+3WUurV5er3JBFeKf+6/QepwI09K/ng9bq0dGo8CmYsxE cTqMdkvfOKNHkC8tMyndnpPeJrymrkHJ/Lazx1YSuzfoRYj3zJ4NrCbwJ RTTFl7TinoHYOsBD8ZI0HQbTCgDTF4ttawY9RFeiPV9TlL8jJDqSY0Upa A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887989" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887989" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397942" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397942" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B095E2AD; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH v4 06/11] leds: mt6323: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:51 +0200 Message-Id: <20230103131256.33894-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/leds-mt6323.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index f59e0e8bda8b..17ee88043f52 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -339,23 +339,23 @@ static int mt6323_led_set_dt_default(struct led_class= dev *cdev, struct device_node *np) { struct mt6323_led *led =3D container_of(cdev, struct mt6323_led, cdev); - const char *state; + enum led_default_state state; int ret =3D 0; =20 - state =3D of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - ret =3D mt6323_get_led_hw_brightness(cdev); - if (ret < 0) - return ret; - led->current_brightness =3D ret; - ret =3D 0; - } else if (!strcmp(state, "on")) { - ret =3D - mt6323_led_set_brightness(cdev, cdev->max_brightness); - } else { - ret =3D mt6323_led_set_brightness(cdev, LED_OFF); - } + state =3D led_init_default_state_get(of_fwnode_handle(np)); + switch (state) { + case LEDS_DEFSTATE_ON: + ret =3D mt6323_led_set_brightness(cdev, cdev->max_brightness); + break; + case LEDS_DEFSTATE_KEEP: + ret =3D mt6323_get_led_hw_brightness(cdev); + if (ret < 0) + return ret; + led->current_brightness =3D ret; + ret =3D 0; + break; + default: + ret =3D mt6323_led_set_brightness(cdev, LED_OFF); } =20 return ret; --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1AA2C4708E for ; Tue, 3 Jan 2023 13:13:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237695AbjACNN0 (ORCPT ); Tue, 3 Jan 2023 08:13:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233200AbjACNMz (ORCPT ); Tue, 3 Jan 2023 08:12:55 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F3410B7E; Tue, 3 Jan 2023 05:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751560; x=1704287560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1oxY1AfVW3M6ZngxBRWmFDZ/ISoe8vMKVfgIGcibtG0=; b=J3Zg0oMPF8Dh9wen9AtdQFSIJRFg1555mmPhiN8JXyZcRjJhA5IpkMER eYuwUixM31ezy9FqsUP0Qc17vL1OkcAXVkEmUrahag1jXHC8VQ/duit6h Mvch/ly/vCDY6D6Vne/7vzZ89bHCIpkWOVnK3sh1Yt+YtOl0JtV2Wofyc XXxSLRZkIbOwnyXtZoG+tXO7Pqmz7VW/qDArmTucOe6qXye/u6qmLeqQ5 vBfO/sf6wX8nFf2F+GplfCJa5SUnwVWjpoJzFmGweg3xZ/kLgg88IEnQw 36YnhUVHbv0m5QdVe8LFUO4pKrhnoCdJaWlcmU1M7zrSTPWKae/9GZna9 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887947" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887947" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397945" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397945" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BC69F3B3; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , AngeloGioacchino Del Regno Subject: [PATCH v4 07/11] leds: mt6360: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:52 +0200 Message-Id: <20230103131256.33894-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/flash/leds-mt6360.c | 38 +++++--------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6= 360.c index e1066a52d2d2..1af6c5898343 100644 --- a/drivers/leds/flash/leds-mt6360.c +++ b/drivers/leds/flash/leds-mt6360.c @@ -71,10 +71,6 @@ enum { #define MT6360_STRBTO_STEPUS 32000 #define MT6360_STRBTO_MAXUS 2432000 =20 -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct mt6360_led { union { struct led_classdev isnk; @@ -84,7 +80,7 @@ struct mt6360_led { struct v4l2_flash *v4l2_flash; struct mt6360_priv *priv; u32 led_no; - u32 default_state; + enum led_default_state default_state; }; =20 struct mt6360_priv { @@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt63= 60_led *led) level =3D LED_OFF; =20 switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->isnk.brightness =3D led->isnk.max_brightness; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: led->isnk.brightness =3D min(level, led->isnk.max_brightness); break; default: @@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6= 360_led *led) level =3D LED_OFF; =20 switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: flash->led_cdev.brightness =3D flash->led_cdev.max_brightness; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: flash->led_cdev.brightness =3D min(level, flash->led_cdev.max_brightness); break; @@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_= led *led, return 0; } =20 -static int mt6360_init_common_properties(struct mt6360_led *led, - struct led_init_data *init_data) -{ - const char *const states[] =3D { "off", "keep", "on" }; - const char *str; - int ret; - - if (!fwnode_property_read_string(init_data->fwnode, - "default-state", &str)) { - ret =3D match_string(states, ARRAY_SIZE(states), str); - if (ret < 0) - ret =3D STATE_OFF; - - led->default_state =3D ret; - } - - return 0; -} - static void mt6360_v4l2_flash_release(struct mt6360_priv *priv) { int i; @@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pd= ev) =20 led->led_no =3D reg; led->priv =3D priv; - - ret =3D mt6360_init_common_properties(led, &init_data); - if (ret) - goto out_flash_release; + led->default_state =3D led_init_default_state_get(child); =20 if (reg =3D=3D MT6360_VIRTUAL_MULTICOLOR || reg <=3D MT6360_LED_ISNKML) --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECBFC3DA7D for ; Tue, 3 Jan 2023 13:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237748AbjACNNR (ORCPT ); Tue, 3 Jan 2023 08:13:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237714AbjACNMn (ORCPT ); Tue, 3 Jan 2023 08:12:43 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD0110B75; Tue, 3 Jan 2023 05:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751560; x=1704287560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aeuQDv8IZ9zZxqvE4KXWp0tWzJlo3lpo6FSE4G48zc0=; b=lgTpR+DI1OObEwgOSMAcdLqjnYhm9oEJsBoB+kbi0mtRvPtmy4fUWDSX 3ICagxFiyE/iAXtuMeJJPVfwKJxe+6wKLmquV4Aik28JrlTWG2wHwgVWy PFBXda83fzC6x6gSu1Oxz/fVaKtia/zuz6E0NbQSsN3R3N5Rvl4vt7r8t ItSR/I8L3sF+PFUZg6IXWO6zKwWw7vKV3xQr+6yM/gEaR7OiyzjsRgMgN 16GNrd1GIwCmUkuiuHh/EF3JcnQRZveGEhasHmThjo2B8iQMKnn9KOL8D u2YKRIPiDK4CX2lfMAqmp5I46OiBFmNL2NyDksvOMw7vp4h1o1KsrvwqA A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320367289" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="320367289" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="654781149" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654781149" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C7B4719E; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 08/11] leds: pca955x: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:53 +0200 Message-Id: <20230103131256.33894-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-pca955x.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 33ec4543fb4f..1edd092e7894 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -130,7 +130,7 @@ struct pca955x_led { struct led_classdev led_cdev; int led_num; /* 0 .. 15 potentially */ u32 type; - int default_state; + enum led_default_state default_state; struct fwnode_handle *fwnode; }; =20 @@ -437,7 +437,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca= 955x_chipdef *chip) return ERR_PTR(-ENOMEM); =20 device_for_each_child_node(&client->dev, child) { - const char *state; u32 reg; int res; =20 @@ -448,19 +447,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pc= a955x_chipdef *chip) led =3D &pdata->leds[reg]; led->type =3D PCA955X_TYPE_LED; led->fwnode =3D child; - fwnode_property_read_u32(child, "type", &led->type); + led->default_state =3D led_init_default_state_get(child); =20 - if (!fwnode_property_read_string(child, "default-state", - &state)) { - if (!strcmp(state, "keep")) - led->default_state =3D LEDS_GPIO_DEFSTATE_KEEP; - else if (!strcmp(state, "on")) - led->default_state =3D LEDS_GPIO_DEFSTATE_ON; - else - led->default_state =3D LEDS_GPIO_DEFSTATE_OFF; - } else { - led->default_state =3D LEDS_GPIO_DEFSTATE_OFF; - } + fwnode_property_read_u32(child, "type", &led->type); } =20 pdata->num_leds =3D chip->bits; @@ -572,13 +561,11 @@ static int pca955x_probe(struct i2c_client *client) led->brightness_set_blocking =3D pca955x_led_set; led->brightness_get =3D pca955x_led_get; =20 - if (pdata->leds[i].default_state =3D=3D - LEDS_GPIO_DEFSTATE_OFF) { + if (pdata->leds[i].default_state =3D=3D LEDS_DEFSTATE_OFF) { err =3D pca955x_led_set(led, LED_OFF); if (err) return err; - } else if (pdata->leds[i].default_state =3D=3D - LEDS_GPIO_DEFSTATE_ON) { + } else if (pdata->leds[i].default_state =3D=3D LEDS_DEFSTATE_ON) { err =3D pca955x_led_set(led, LED_FULL); if (err) return err; @@ -617,8 +604,7 @@ static int pca955x_probe(struct i2c_client *client) * brightness to see if it's using PWM1. If so, PWM1 * should not be written below. */ - if (pdata->leds[i].default_state =3D=3D - LEDS_GPIO_DEFSTATE_KEEP) { + if (pdata->leds[i].default_state =3D=3D LEDS_DEFSTATE_KEEP) { if (led->brightness !=3D LED_FULL && led->brightness !=3D LED_OFF && led->brightness !=3D LED_HALF) --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF43DC46467 for ; Tue, 3 Jan 2023 13:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237740AbjACNNO (ORCPT ); Tue, 3 Jan 2023 08:13:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237676AbjACNMn (ORCPT ); Tue, 3 Jan 2023 08:12:43 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DACD10B70; Tue, 3 Jan 2023 05:12:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751560; x=1704287560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hvI26OhQ+1E3Y1b+RrDqvUOiyVnslqAALa2RhHdwGbY=; b=m2K9HbaXlAohLwUKkPBF8jj3ww+UpveJ7AB21Q5apwPCGrvhNPPqL5FV Zq2lES0nJIYwFPlnNCfoJYoGTzyZnYCwUJxqt3ObNKBy/cDnOvYpVXr5t xUplS96h3LU07X5+gGnSEB8P/fTuy3v0oh36zCFf9B4CDXjprJTe+v79V Nzn+K2eSa6bEI9gA3grxxE9vN7p37GGmGPcLLpdCSWe/hcHu/ZXALoawE 06a+PXvtCOhfaR+y/E68aRdEMvWxWNwBXAIXuhNXIuccP0tMvk+1ibkWU KDRHgCYYXBa4kkrTavlHe8fUnYc5RO9XrofVjuH9bIoxpFVQWCMx2OyIk w==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320367274" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="320367274" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="654781148" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654781148" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D30BE3FD; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 09/11] leds: pm8058: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:54 +0200 Message-Id: <20230103131256.33894-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-pm8058.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index fb2ab72c0c40..b9233f14b646 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev) struct device_node *np; int ret; struct regmap *map; - const char *state; enum led_brightness maxbright; + enum led_default_state state; =20 led =3D devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); if (!led) @@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *p= dev) maxbright =3D 15; /* 4 bits */ led->cdev.max_brightness =3D maxbright; =20 - state =3D of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - led->cdev.brightness =3D pm8058_led_get(&led->cdev); - } else if (!strcmp(state, "on")) { - led->cdev.brightness =3D maxbright; - pm8058_led_set(&led->cdev, maxbright); - } else { - led->cdev.brightness =3D LED_OFF; - pm8058_led_set(&led->cdev, LED_OFF); - } + init_data.fwnode =3D of_fwnode_handle(np); + + state =3D led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness =3D maxbright; + pm8058_led_set(&led->cdev, maxbright); + break; + case LEDS_DEFSTATE_KEEP: + led->cdev.brightness =3D pm8058_led_get(&led->cdev); + break; + default: + led->cdev.brightness =3D LED_OFF; + pm8058_led_set(&led->cdev, LED_OFF); } =20 if (led->ledtype =3D=3D PM8058_LED_TYPE_KEYPAD || led->ledtype =3D=3D PM8058_LED_TYPE_FLASH) led->cdev.flags =3D LED_CORE_SUSPENDRESUME; =20 - init_data.fwnode =3D of_fwnode_handle(np); - ret =3D devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (ret) dev_err(dev, "Failed to register LED for %pOF\n", np); --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44FDEC46467 for ; Tue, 3 Jan 2023 13:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237674AbjACNNV (ORCPT ); Tue, 3 Jan 2023 08:13:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233191AbjACNNI (ORCPT ); Tue, 3 Jan 2023 08:13:08 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1FF10FC9; Tue, 3 Jan 2023 05:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751560; x=1704287560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jvEYSO7lW++ymJ0bBLH7ZRL0Q9IiAhclprxNUtYU6Os=; b=TEbDYR+oV1uojHKgWUEqXAOt51pjF6ap4o8qCwFTaGCpZj/n6Bj+MH27 hf1syD06MQ0/o1O5xxBM5k2ALNkN7stv4inr2rLFalJtmzFUxkuTW+wc5 uOblp9lFvznKO9HZAoAHn0/ukQAGKJFS30TlRrsbS8Lf4NsCje7s7JFJD UIgYo2RvtwZ+ICCTbg13D2rk+BedEFYYfnHlIWxP6JZAz3oqNsbMgCF3Y 0bG9oyde7cuG+7qfxW8hIgWxwvewXqGZULqR4yv2eNGLpJBndOGmhIVLF xjAUDk6ce+5nfr9/MaHr47LYZtSInnRuG9ikWQio39JRfa+05KVW78SE0 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887965" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887965" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397946" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397946" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E24663BC; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 10/11] leds: syscon: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:55 +0200 Message-Id: <20230103131256.33894-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-syscon.c | 49 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index 7eddb8ecb44e..e38abb5e60c1 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev) struct device *parent; struct regmap *map; struct syscon_led *sled; - const char *state; + enum led_default_state state; + u32 value; int ret; =20 parent =3D dev->parent; @@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pde= v) if (of_property_read_u32(np, "mask", &sled->mask)) return -EINVAL; =20 - state =3D of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - u32 val; - - ret =3D regmap_read(map, sled->offset, &val); - if (ret < 0) - return ret; - sled->state =3D !!(val & sled->mask); - } else if (!strcmp(state, "on")) { - sled->state =3D true; - ret =3D regmap_update_bits(map, sled->offset, - sled->mask, - sled->mask); - if (ret < 0) - return ret; - } else { - sled->state =3D false; - ret =3D regmap_update_bits(map, sled->offset, - sled->mask, 0); - if (ret < 0) - return ret; - } + init_data.fwnode =3D of_fwnode_handle(np); + + state =3D led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + ret =3D regmap_update_bits(map, sled->offset, sled->mask, sled->mask); + if (ret < 0) + return ret; + sled->state =3D true; + break; + case LEDS_DEFSTATE_KEEP: + ret =3D regmap_read(map, sled->offset, &value); + if (ret < 0) + return ret; + sled->state =3D !!(value & sled->mask); + break; + default: + ret =3D regmap_update_bits(map, sled->offset, sled->mask, 0); + if (ret < 0) + return ret; + sled->state =3D false; } sled->cdev.brightness_set =3D syscon_led_set; =20 - init_data.fwnode =3D of_fwnode_handle(np); - ret =3D devm_led_classdev_register_ext(dev, &sled->cdev, &init_data); if (ret < 0) return ret; --=20 2.35.1 From nobody Thu Nov 14 09:07:53 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C94FC3DA7D for ; Tue, 3 Jan 2023 13:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237071AbjACNNy (ORCPT ); Tue, 3 Jan 2023 08:13:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237739AbjACNNN (ORCPT ); Tue, 3 Jan 2023 08:13:13 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645191114B; Tue, 3 Jan 2023 05:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751564; x=1704287564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WhGrjx6LzV2jk/LAfomo4zdb3Tdn1LBofxlORU1JDv0=; b=VEnh19VivwIMpe6hZMkoOBw+iPBVlOXfiQ8M2op6En9nltN6BPgVw4DI euIIJ/CmmnoVs1VUTkGT23dCqyadrpucX4OVJo91Bq0U1ze1AuxWYtt/u YykK1JW4P56mF2200zI2XHNZjnZq/axm7A1ehZUOVEMfEymHqeu8w5b1G orEgufqr5hm6ZKBsruoPzz4QS1CNrA3KiE52/zyI0sHoo2qIzR4n2G7cG Jh0LYNkVZfcyZzPZmdmMzYzc+gPX1kC8QTGHv/D3eT6GA8cgWn0Ns4lHk ucw/nJyo6mFCXcxjLVC6wzj2Lp00hMMpZ8kZH4dWwQyCMn50H5DvA0ta/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322888002" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322888002" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397947" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397947" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EDD04458; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 11/11] net: dsa: hellcreek: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:56 +0200 Message-Id: <20230103131256.33894-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko Reviewed-by: Kurt Kanzenbach --- drivers/net/dsa/hirschmann/hellcreek_ptp.c | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek_ptp.c b/drivers/net/dsa/h= irschmann/hellcreek_ptp.c index b28baab6d56a..793b2c296314 100644 --- a/drivers/net/dsa/hirschmann/hellcreek_ptp.c +++ b/drivers/net/dsa/hirschmann/hellcreek_ptp.c @@ -297,7 +297,8 @@ static enum led_brightness hellcreek_led_is_gm_get(stru= ct led_classdev *ldev) static int hellcreek_led_setup(struct hellcreek *hellcreek) { struct device_node *leds, *led =3D NULL; - const char *label, *state; + enum led_default_state state; + const char *label; int ret =3D -EINVAL; =20 of_node_get(hellcreek->dev->of_node); @@ -318,16 +319,17 @@ static int hellcreek_led_setup(struct hellcreek *hell= creek) ret =3D of_property_read_string(led, "label", &label); hellcreek->led_sync_good.name =3D ret ? "sync_good" : label; =20 - ret =3D of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_sync_good.brightness =3D 1; - else if (!strcmp(state, "off")) - hellcreek->led_sync_good.brightness =3D 0; - else if (!strcmp(state, "keep")) - hellcreek->led_sync_good.brightness =3D - hellcreek_get_brightness(hellcreek, - STATUS_OUT_SYNC_GOOD); + state =3D led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_sync_good.brightness =3D 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_sync_good.brightness =3D + hellcreek_get_brightness(hellcreek, STATUS_OUT_SYNC_GOOD); + break; + default: + hellcreek->led_sync_good.brightness =3D 0; } =20 hellcreek->led_sync_good.max_brightness =3D 1; @@ -344,16 +346,17 @@ static int hellcreek_led_setup(struct hellcreek *hell= creek) ret =3D of_property_read_string(led, "label", &label); hellcreek->led_is_gm.name =3D ret ? "is_gm" : label; =20 - ret =3D of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_is_gm.brightness =3D 1; - else if (!strcmp(state, "off")) - hellcreek->led_is_gm.brightness =3D 0; - else if (!strcmp(state, "keep")) - hellcreek->led_is_gm.brightness =3D - hellcreek_get_brightness(hellcreek, - STATUS_OUT_IS_GM); + state =3D led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_is_gm.brightness =3D 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_is_gm.brightness =3D + hellcreek_get_brightness(hellcreek, STATUS_OUT_IS_GM); + break; + default: + hellcreek->led_is_gm.brightness =3D 0; } =20 hellcreek->led_is_gm.max_brightness =3D 1; --=20 2.35.1