Commit c49d6cab authored by Marek Behún's avatar Marek Behún Committed by Pavel Machek

leds: parse linux,default-trigger DT property in LED core

Do the 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 23 drivers:
  an30259a, aw2013, bcm6328, bcm6358, cr0014114, el15203000, gpio,
  is31fl32xx, lm3532, lm36274, lm3692x, lm3697, lp50xx, lp8860, lt3593,
  max77650, mt6323, ns2, pm8058, pwm, syscon, tlc591xx and turris-omnia.

There is one driver in drivers/input which parses this property on it's
own. I shall send a separate patch there after this is applied.

There are still 8 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: default avatarMarek Behún <marek.behun@nic.cz>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent 00663196
...@@ -354,6 +354,11 @@ int led_classdev_register_ext(struct device *parent, ...@@ -354,6 +354,11 @@ int led_classdev_register_ext(struct device *parent,
ret = led_compose_name(parent, init_data, composed_name); ret = led_compose_name(parent, init_data, composed_name);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (init_data->fwnode)
fwnode_property_read_string(init_data->fwnode,
"linux,default-trigger",
&led_cdev->default_trigger);
} else { } else {
proposed_name = led_cdev->name; proposed_name = led_cdev->name;
} }
......
...@@ -238,9 +238,6 @@ static int an30259a_dt_init(struct i2c_client *client, ...@@ -238,9 +238,6 @@ static int an30259a_dt_init(struct i2c_client *client,
led->default_state = STATE_OFF; led->default_state = STATE_OFF;
} }
of_property_read_string(child, "linux,default-trigger",
&led->cdev.default_trigger);
i++; i++;
} }
......
...@@ -297,9 +297,6 @@ static int aw2013_probe_dt(struct aw2013 *chip) ...@@ -297,9 +297,6 @@ static int aw2013_probe_dt(struct aw2013 *chip)
"DT property led-max-microamp is missing\n"); "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.brightness_set_blocking = aw2013_brightness_set;
led->cdev.blink_set = aw2013_blink_set; led->cdev.blink_set = aw2013_blink_set;
......
...@@ -346,10 +346,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -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")) if (of_property_read_bool(nc, "active-low"))
led->active_low = true; 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 (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) { if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
......
...@@ -110,10 +110,6 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -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")) if (of_property_read_bool(nc, "active-low"))
led->active_low = true; 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 (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) { if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
......
...@@ -188,9 +188,6 @@ static int cr0014114_probe_dt(struct cr0014114 *priv) ...@@ -188,9 +188,6 @@ static int cr0014114_probe_dt(struct cr0014114 *priv)
device_for_each_child_node(priv->dev, child) { device_for_each_child_node(priv->dev, child) {
led = &priv->leds[i]; led = &priv->leds[i];
fwnode_property_read_string(child, "linux,default-trigger",
&led->ldev.default_trigger);
led->priv = priv; led->priv = priv;
led->ldev.max_brightness = CR_MAX_BRIGHTNESS; led->ldev.max_brightness = CR_MAX_BRIGHTNESS;
led->ldev.brightness_set_blocking = cr0014114_set_sync; led->ldev.brightness_set_blocking = cr0014114_set_sync;
......
...@@ -263,9 +263,6 @@ static int el15203000_probe_dt(struct el15203000 *priv) ...@@ -263,9 +263,6 @@ static int el15203000_probe_dt(struct el15203000 *priv)
return -EINVAL; return -EINVAL;
} }
fwnode_property_read_string(child, "linux,default-trigger",
&led->ldev.default_trigger);
led->priv = priv; led->priv = priv;
led->ldev.max_brightness = LED_ON; led->ldev.max_brightness = LED_ON;
led->ldev.brightness_set_blocking = el15203000_set_blocking; led->ldev.brightness_set_blocking = el15203000_set_blocking;
......
...@@ -160,9 +160,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) ...@@ -160,9 +160,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
led_dat->gpiod = led.gpiod; led_dat->gpiod = led.gpiod;
fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger);
if (!fwnode_property_read_string(child, "default-state", if (!fwnode_property_read_string(child, "default-state",
&state)) { &state)) {
if (!strcmp(state, "keep")) if (!strcmp(state, "keep"))
......
...@@ -341,9 +341,6 @@ static int is31fl32xx_parse_child_dt(const struct device *dev, ...@@ -341,9 +341,6 @@ static int is31fl32xx_parse_child_dt(const struct device *dev,
} }
led_data->channel = reg; led_data->channel = reg;
of_property_read_string(child, "linux,default-trigger",
&cdev->default_trigger);
cdev->brightness_set_blocking = is31fl32xx_brightness_set; cdev->brightness_set_blocking = is31fl32xx_brightness_set;
return 0; return 0;
......
...@@ -640,9 +640,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) ...@@ -640,9 +640,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
goto child_out; goto child_out;
} }
fwnode_property_read_string(child, "linux,default-trigger",
&led->led_dev.default_trigger);
led->priv = priv; led->priv = priv;
led->led_dev.brightness_set_blocking = lm3532_brightness_set; led->led_dev.brightness_set_blocking = lm3532_brightness_set;
......
...@@ -97,9 +97,6 @@ static int lm36274_parse_dt(struct lm36274 *chip, ...@@ -97,9 +97,6 @@ static int lm36274_parse_dt(struct lm36274 *chip,
goto err; goto err;
} }
fwnode_property_read_string(child, "linux,default-trigger",
&chip->led_dev.default_trigger);
return 0; return 0;
err: err:
fwnode_handle_put(child); fwnode_handle_put(child);
......
...@@ -433,9 +433,6 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) ...@@ -433,9 +433,6 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
return -ENODEV; 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); ret = fwnode_property_read_u32(child, "reg", &led->led_enable);
if (ret) { if (ret) {
dev_err(&led->client->dev, "reg DT property missing\n"); dev_err(&led->client->dev, "reg DT property missing\n");
......
...@@ -268,9 +268,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) ...@@ -268,9 +268,6 @@ static int lm3697_probe_dt(struct lm3697 *priv)
if (ret) if (ret)
dev_warn(dev, "runtime-ramp properties missing\n"); 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.fwnode = child;
init_data.devicename = priv->client->name; init_data.devicename = priv->client->name;
/* for backwards compatibility if `label` is not present */ /* for backwards compatibility if `label` is not present */
......
...@@ -508,9 +508,6 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ...@@ -508,9 +508,6 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
led_cdev = &led->mc_cdev.led_cdev; led_cdev = &led->mc_cdev.led_cdev;
led_cdev->brightness_set_blocking = lp50xx_brightness_set; led_cdev->brightness_set_blocking = lp50xx_brightness_set;
fwnode_property_read_string(child, "linux,default-trigger",
&led_cdev->default_trigger);
ret = devm_led_classdev_multicolor_register_ext(&priv->client->dev, ret = devm_led_classdev_multicolor_register_ext(&priv->client->dev,
&led->mc_cdev, &led->mc_cdev,
&init_data); &init_data);
......
...@@ -392,10 +392,6 @@ static int lp8860_probe(struct i2c_client *client, ...@@ -392,10 +392,6 @@ static int lp8860_probe(struct i2c_client *client,
if (!child_node) if (!child_node)
return -EINVAL; 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, led->enable_gpio = devm_gpiod_get_optional(&client->dev,
"enable", GPIOD_OUT_LOW); "enable", GPIOD_OUT_LOW);
if (IS_ERR(led->enable_gpio)) { if (IS_ERR(led->enable_gpio)) {
......
...@@ -86,9 +86,6 @@ static int lt3593_led_probe(struct platform_device *pdev) ...@@ -86,9 +86,6 @@ static int lt3593_led_probe(struct platform_device *pdev)
child = device_get_next_child_node(dev, NULL); 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 (!fwnode_property_read_string(child, "default-state", &tmp)) {
if (!strcmp(tmp, "on")) if (!strcmp(tmp, "on"))
state = LEDS_GPIO_DEFSTATE_ON; state = LEDS_GPIO_DEFSTATE_ON;
......
...@@ -100,9 +100,6 @@ static int max77650_led_probe(struct platform_device *pdev) ...@@ -100,9 +100,6 @@ static int max77650_led_probe(struct platform_device *pdev)
led->cdev.brightness_set_blocking = max77650_led_brightness_set; led->cdev.brightness_set_blocking = max77650_led_brightness_set;
led->cdev.max_brightness = MAX77650_LED_MAX_BRIGHTNESS; 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.fwnode = child;
init_data.devicename = "max77650"; init_data.devicename = "max77650";
/* for backwards compatibility if `label` is not present */ /* for backwards compatibility if `label` is not present */
......
...@@ -342,10 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, ...@@ -342,10 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
const char *state; const char *state;
int ret = 0; int ret = 0;
led->cdev.default_trigger = of_get_property(np,
"linux,default-trigger",
NULL);
state = of_get_property(np, "default-state", NULL); state = of_get_property(np, "default-state", NULL);
if (state) { if (state) {
if (!strcmp(state, "keep")) { if (!strcmp(state, "keep")) {
......
...@@ -185,9 +185,6 @@ static int ns2_led_register(struct device *dev, struct device_node *np, ...@@ -185,9 +185,6 @@ static int ns2_led_register(struct device *dev, struct device_node *np,
if (IS_ERR(led->slow)) if (IS_ERR(led->slow))
return PTR_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"); ret = of_property_count_u32_elems(np, "modes-map");
if (ret < 0 || ret % 3) { if (ret < 0 || ret % 3) {
dev_err(dev, "Missing or malformed modes-map for %pOF\n", np); dev_err(dev, "Missing or malformed modes-map for %pOF\n", np);
......
...@@ -117,8 +117,6 @@ static int pm8058_led_probe(struct platform_device *pdev) ...@@ -117,8 +117,6 @@ static int pm8058_led_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
led->cdev.default_trigger =
of_get_property(np, "linux,default-trigger", NULL);
led->cdev.brightness_set = pm8058_led_set; led->cdev.brightness_set = pm8058_led_set;
led->cdev.brightness_get = pm8058_led_get; led->cdev.brightness_get = pm8058_led_get;
if (led->ledtype == PM8058_LED_TYPE_COMMON) if (led->ledtype == PM8058_LED_TYPE_COMMON)
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
struct led_pwm { struct led_pwm {
const char *name; const char *name;
const char *default_trigger;
u8 active_low; u8 active_low;
unsigned int max_brightness; unsigned int max_brightness;
}; };
...@@ -70,7 +69,6 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, ...@@ -70,7 +69,6 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
led_data->active_low = led->active_low; led_data->active_low = led->active_low;
led_data->cdev.name = led->name; led_data->cdev.name = led->name;
led_data->cdev.default_trigger = led->default_trigger;
led_data->cdev.brightness = LED_OFF; led_data->cdev.brightness = LED_OFF;
led_data->cdev.max_brightness = led->max_brightness; led_data->cdev.max_brightness = led->max_brightness;
led_data->cdev.flags = LED_CORE_SUSPENDRESUME; led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
...@@ -124,9 +122,6 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) ...@@ -124,9 +122,6 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
return -EINVAL; return -EINVAL;
} }
fwnode_property_read_string(fwnode, "linux,default-trigger",
&led.default_trigger);
led.active_low = fwnode_property_read_bool(fwnode, led.active_low = fwnode_property_read_bool(fwnode,
"active-low"); "active-low");
fwnode_property_read_u32(fwnode, "max-brightness", fwnode_property_read_u32(fwnode, "max-brightness",
......
...@@ -85,8 +85,6 @@ static int syscon_led_probe(struct platform_device *pdev) ...@@ -85,8 +85,6 @@ static int syscon_led_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
if (of_property_read_u32(np, "mask", &sled->mask)) if (of_property_read_u32(np, "mask", &sled->mask))
return -EINVAL; return -EINVAL;
sled->cdev.default_trigger =
of_get_property(np, "linux,default-trigger", NULL);
state = of_get_property(np, "default-state", NULL); state = of_get_property(np, "default-state", NULL);
if (state) { if (state) {
......
...@@ -199,9 +199,6 @@ tlc591xx_probe(struct i2c_client *client, ...@@ -199,9 +199,6 @@ tlc591xx_probe(struct i2c_client *client,
led = &priv->leds[reg]; led = &priv->leds[reg];
led->active = true; led->active = true;
led->ldev.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
led->priv = priv; led->priv = priv;
led->led_no = reg; led->led_no = reg;
led->ldev.brightness_set_blocking = tlc591xx_brightness_set; led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
......
...@@ -121,8 +121,6 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, ...@@ -121,8 +121,6 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
cdev->max_brightness = 255; cdev->max_brightness = 255;
cdev->brightness_set_blocking = omnia_led_brightness_set_blocking; 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 */ /* put the LED into software mode */
ret = i2c_smbus_write_byte_data(client, CMD_LED_MODE, ret = i2c_smbus_write_byte_data(client, CMD_LED_MODE,
CMD_LED_MODE_LED(led->reg) | CMD_LED_MODE_LED(led->reg) |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment