Skip to content

Commit

Permalink
leds: lm3697: use struct led_init_data when registering
Browse files Browse the repository at this point in the history
By using struct led_init_data when registering we do not need to parse
`label` DT property nor `linux,default-trigger` property.

Previously if the `label` DT property was not present, the code composed
name for the LED in the form
  "parent_name::"
For backwards compatibility we therefore set
  init_data->default_label = ":";
so that the LED will not get a different name if `label` property is not
present.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Dan Murphy <dmurphy@ti.com>
  • Loading branch information
elkablo authored and intel-lab-lkp committed Sep 16, 2020
1 parent 62bf0ab commit 7ce949f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions drivers/leds/leds-lm3697.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ static int lm3697_probe_dt(struct lm3697 *priv)
{
struct fwnode_handle *child = NULL;
struct lm3697_led *led;
const char *name;
int control_bank;
size_t i = 0;
int ret = -EINVAL;
Expand All @@ -214,6 +213,8 @@ static int lm3697_probe_dt(struct lm3697 *priv)
priv->regulator = NULL;

device_for_each_child_node(priv->dev, child) {
struct led_init_data init_data = {};

ret = fwnode_property_read_u32(child, "reg", &control_bank);
if (ret) {
dev_err(&priv->client->dev, "reg property missing\n");
Expand Down Expand Up @@ -268,19 +269,12 @@ static int lm3697_probe_dt(struct lm3697 *priv)
if (ret)
dev_warn(&priv->client->dev, "runtime-ramp properties missing\n");

fwnode_property_read_string(child, "linux,default-trigger",
&led->led_dev.default_trigger);

ret = fwnode_property_read_string(child, "label", &name);
if (ret)
snprintf(led->label, sizeof(led->label),
"%s::", priv->client->name);
else
snprintf(led->label, sizeof(led->label),
"%s:%s", priv->client->name, name);
init_data.fwnode = child;
init_data.devicename = priv->client->name;
/* for backwards compatibility if `label` is not present */
init_data.default_label = ":";

led->priv = priv;
led->led_dev.name = led->label;
led->led_dev.max_brightness = led->lmu_data.max_brightness;
led->led_dev.brightness_set_blocking = lm3697_brightness_set;

Expand Down

0 comments on commit 7ce949f

Please sign in to comment.