mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 13:34:30 +00:00
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 <andriy.shevchenko@linux.intel.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230103131256.33894-9-andriy.shevchenko@linux.intel.com
This commit is contained in:
parent
43ee1e3fba
commit
0dd37b1cf5
@ -130,7 +130,7 @@ struct pca955x_led {
|
|||||||
struct led_classdev led_cdev;
|
struct led_classdev led_cdev;
|
||||||
int led_num; /* 0 .. 15 potentially */
|
int led_num; /* 0 .. 15 potentially */
|
||||||
u32 type;
|
u32 type;
|
||||||
int default_state;
|
enum led_default_state default_state;
|
||||||
struct fwnode_handle *fwnode;
|
struct fwnode_handle *fwnode;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -437,7 +437,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
|
|||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
device_for_each_child_node(&client->dev, child) {
|
device_for_each_child_node(&client->dev, child) {
|
||||||
const char *state;
|
|
||||||
u32 reg;
|
u32 reg;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
@ -448,19 +447,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
|
|||||||
led = &pdata->leds[reg];
|
led = &pdata->leds[reg];
|
||||||
led->type = PCA955X_TYPE_LED;
|
led->type = PCA955X_TYPE_LED;
|
||||||
led->fwnode = child;
|
led->fwnode = child;
|
||||||
fwnode_property_read_u32(child, "type", &led->type);
|
led->default_state = led_init_default_state_get(child);
|
||||||
|
|
||||||
if (!fwnode_property_read_string(child, "default-state",
|
fwnode_property_read_u32(child, "type", &led->type);
|
||||||
&state)) {
|
|
||||||
if (!strcmp(state, "keep"))
|
|
||||||
led->default_state = LEDS_GPIO_DEFSTATE_KEEP;
|
|
||||||
else if (!strcmp(state, "on"))
|
|
||||||
led->default_state = LEDS_GPIO_DEFSTATE_ON;
|
|
||||||
else
|
|
||||||
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
|
|
||||||
} else {
|
|
||||||
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata->num_leds = chip->bits;
|
pdata->num_leds = chip->bits;
|
||||||
@ -572,13 +561,11 @@ static int pca955x_probe(struct i2c_client *client)
|
|||||||
led->brightness_set_blocking = pca955x_led_set;
|
led->brightness_set_blocking = pca955x_led_set;
|
||||||
led->brightness_get = pca955x_led_get;
|
led->brightness_get = pca955x_led_get;
|
||||||
|
|
||||||
if (pdata->leds[i].default_state ==
|
if (pdata->leds[i].default_state == LEDS_DEFSTATE_OFF) {
|
||||||
LEDS_GPIO_DEFSTATE_OFF) {
|
|
||||||
err = pca955x_led_set(led, LED_OFF);
|
err = pca955x_led_set(led, LED_OFF);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
} else if (pdata->leds[i].default_state ==
|
} else if (pdata->leds[i].default_state == LEDS_DEFSTATE_ON) {
|
||||||
LEDS_GPIO_DEFSTATE_ON) {
|
|
||||||
err = pca955x_led_set(led, LED_FULL);
|
err = pca955x_led_set(led, LED_FULL);
|
||||||
if (err)
|
if (err)
|
||||||
return 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
|
* brightness to see if it's using PWM1. If so, PWM1
|
||||||
* should not be written below.
|
* should not be written below.
|
||||||
*/
|
*/
|
||||||
if (pdata->leds[i].default_state ==
|
if (pdata->leds[i].default_state == LEDS_DEFSTATE_KEEP) {
|
||||||
LEDS_GPIO_DEFSTATE_KEEP) {
|
|
||||||
if (led->brightness != LED_FULL &&
|
if (led->brightness != LED_FULL &&
|
||||||
led->brightness != LED_OFF &&
|
led->brightness != LED_OFF &&
|
||||||
led->brightness != LED_HALF)
|
led->brightness != LED_HALF)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user