linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Gene Chen <gene_chen@richtek.com>,
	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 <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
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	[thread overview]
Message-ID: <20230103131256.33894-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com>

LED core provides a helper to parse default state from firmware node.
Use it instead of custom implementation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 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 @@
 
 #define AN30259A_NAME "an30259a"
 
-#define STATE_OFF 0
-#define STATE_KEEP 1
-#define STATE_ON 2
-
 struct an30259a;
 
 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;
 };
 
@@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client,
 	struct device_node *np = dev_of_node(&client->dev), *child;
 	int count, ret;
 	int i = 0;
-	const char *str;
 	struct an30259a_led *led;
 
 	count = of_get_available_child_count(np);
@@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client,
 		led->num = source;
 		led->chip = chip;
 		led->fwnode = of_fwnode_handle(child);
-
-		if (!of_property_read_string(child, "default-state", &str)) {
-			if (!strcmp(str, "on"))
-				led->default_state = STATE_ON;
-			else if (!strcmp(str, "keep"))
-				led->default_state = STATE_KEEP;
-			else
-				led->default_state = STATE_OFF;
-		}
+		led->default_state = led_init_default_state_get(led->fwnode);
 
 		i++;
 	}
@@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an30259a_led *led)
 	int led_on, err;
 
 	switch (led->default_state) {
-	case STATE_ON:
+	case LEDS_DEFSTATE_ON:
 		led->cdev.brightness = LED_FULL;
 		break;
-	case STATE_KEEP:
+	case LEDS_DEFSTATE_KEEP:
 		err = regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on);
 		if (err)
 			break;
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-01-03 16:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 13:12 [PATCH v4 00/11] leds: deduplicate led_init_default_state_get() Andy Shevchenko
2023-01-03 13:12 ` [PATCH v4 01/11] leds: add missing includes and forward declarations in leds.h Andy Shevchenko
2023-01-19 16:16   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 02/11] leds: Move led_init_default_state_get() to the global header Andy Shevchenko
2023-01-19 16:17   ` Lee Jones
2023-01-03 13:12 ` Andy Shevchenko [this message]
2023-01-19 16:17   ` [PATCH v4 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Lee Jones
2023-01-03 13:12 ` [PATCH v4 04/11] leds: bcm6328: " Andy Shevchenko
2023-01-19 16:19   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 05/11] leds: bcm6358: " Andy Shevchenko
2023-01-19 16:20   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 06/11] leds: mt6323: " Andy Shevchenko
2023-01-19 16:21   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 07/11] leds: mt6360: " Andy Shevchenko
2023-01-19 16:22   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 08/11] leds: pca955x: " Andy Shevchenko
2023-01-19 16:23   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 09/11] leds: pm8058: " Andy Shevchenko
2023-01-19 16:23   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 10/11] leds: syscon: " Andy Shevchenko
2023-01-19 16:24   ` Lee Jones
2023-01-03 13:12 ` [PATCH v4 11/11] net: dsa: hellcreek: " Andy Shevchenko
2023-03-06 15:54   ` Andy Shevchenko
2023-03-06 17:46     ` Jakub Kicinski
2023-03-06 17:47     ` Kurt Kanzenbach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230103131256.33894-4-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gene_chen@richtek.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).