Skip to content

Commit 0dd37b1

Browse files
andy-shevlag-linaro
authored andcommitted
leds: pca955x: Get rid of custom led_init_default_state_get()
LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 43ee1e3 commit 0dd37b1

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

drivers/leds/leds-pca955x.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ struct pca955x_led {
130130
struct led_classdev led_cdev;
131131
int led_num; /* 0 .. 15 potentially */
132132
u32 type;
133-
int default_state;
133+
enum led_default_state default_state;
134134
struct fwnode_handle *fwnode;
135135
};
136136

@@ -437,7 +437,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
437437
return ERR_PTR(-ENOMEM);
438438

439439
device_for_each_child_node(&client->dev, child) {
440-
const char *state;
441440
u32 reg;
442441
int res;
443442

@@ -448,19 +447,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
448447
led = &pdata->leds[reg];
449448
led->type = PCA955X_TYPE_LED;
450449
led->fwnode = child;
451-
fwnode_property_read_u32(child, "type", &led->type);
450+
led->default_state = led_init_default_state_get(child);
452451

453-
if (!fwnode_property_read_string(child, "default-state",
454-
&state)) {
455-
if (!strcmp(state, "keep"))
456-
led->default_state = LEDS_GPIO_DEFSTATE_KEEP;
457-
else if (!strcmp(state, "on"))
458-
led->default_state = LEDS_GPIO_DEFSTATE_ON;
459-
else
460-
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
461-
} else {
462-
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
463-
}
452+
fwnode_property_read_u32(child, "type", &led->type);
464453
}
465454

466455
pdata->num_leds = chip->bits;
@@ -572,13 +561,11 @@ static int pca955x_probe(struct i2c_client *client)
572561
led->brightness_set_blocking = pca955x_led_set;
573562
led->brightness_get = pca955x_led_get;
574563

575-
if (pdata->leds[i].default_state ==
576-
LEDS_GPIO_DEFSTATE_OFF) {
564+
if (pdata->leds[i].default_state == LEDS_DEFSTATE_OFF) {
577565
err = pca955x_led_set(led, LED_OFF);
578566
if (err)
579567
return err;
580-
} else if (pdata->leds[i].default_state ==
581-
LEDS_GPIO_DEFSTATE_ON) {
568+
} else if (pdata->leds[i].default_state == LEDS_DEFSTATE_ON) {
582569
err = pca955x_led_set(led, LED_FULL);
583570
if (err)
584571
return err;
@@ -617,8 +604,7 @@ static int pca955x_probe(struct i2c_client *client)
617604
* brightness to see if it's using PWM1. If so, PWM1
618605
* should not be written below.
619606
*/
620-
if (pdata->leds[i].default_state ==
621-
LEDS_GPIO_DEFSTATE_KEEP) {
607+
if (pdata->leds[i].default_state == LEDS_DEFSTATE_KEEP) {
622608
if (led->brightness != LED_FULL &&
623609
led->brightness != LED_OFF &&
624610
led->brightness != LED_HALF)

0 commit comments

Comments
 (0)