leds: sc27xx-blt: Use generic support for composing LED names
Switch to using generic LED support for composing LED class device name. Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Reviewed-by: Baolin Wang <baolin.wang@linaro.org> Acked-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
parent
0f0f25797a
commit
5fdf85a091
|
@ -6,7 +6,6 @@
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <uapi/linux/uleds.h>
|
|
||||||
|
|
||||||
/* PMIC global control register definition */
|
/* PMIC global control register definition */
|
||||||
#define SC27XX_MODULE_EN0 0xc08
|
#define SC27XX_MODULE_EN0 0xc08
|
||||||
|
@ -46,7 +45,7 @@
|
||||||
#define SC27XX_DELTA_T_MAX (SC27XX_LEDS_STEP * 255)
|
#define SC27XX_DELTA_T_MAX (SC27XX_LEDS_STEP * 255)
|
||||||
|
|
||||||
struct sc27xx_led {
|
struct sc27xx_led {
|
||||||
char name[LED_MAX_NAME_SIZE];
|
struct fwnode_handle *fwnode;
|
||||||
struct led_classdev ldev;
|
struct led_classdev ldev;
|
||||||
struct sc27xx_led_priv *priv;
|
struct sc27xx_led_priv *priv;
|
||||||
u8 line;
|
u8 line;
|
||||||
|
@ -249,19 +248,24 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv)
|
||||||
|
|
||||||
for (i = 0; i < SC27XX_LEDS_MAX; i++) {
|
for (i = 0; i < SC27XX_LEDS_MAX; i++) {
|
||||||
struct sc27xx_led *led = &priv->leds[i];
|
struct sc27xx_led *led = &priv->leds[i];
|
||||||
|
struct led_init_data init_data = {};
|
||||||
|
|
||||||
if (!led->active)
|
if (!led->active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
led->line = i;
|
led->line = i;
|
||||||
led->priv = priv;
|
led->priv = priv;
|
||||||
led->ldev.name = led->name;
|
|
||||||
led->ldev.brightness_set_blocking = sc27xx_led_set;
|
led->ldev.brightness_set_blocking = sc27xx_led_set;
|
||||||
led->ldev.pattern_set = sc27xx_led_pattern_set;
|
led->ldev.pattern_set = sc27xx_led_pattern_set;
|
||||||
led->ldev.pattern_clear = sc27xx_led_pattern_clear;
|
led->ldev.pattern_clear = sc27xx_led_pattern_clear;
|
||||||
led->ldev.default_trigger = "pattern";
|
led->ldev.default_trigger = "pattern";
|
||||||
|
|
||||||
err = devm_led_classdev_register(dev, &led->ldev);
|
init_data.fwnode = led->fwnode;
|
||||||
|
init_data.devicename = "sc27xx";
|
||||||
|
init_data.default_label = ":";
|
||||||
|
|
||||||
|
err = devm_led_classdev_register_ext(dev, &led->ldev,
|
||||||
|
&init_data);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +278,6 @@ static int sc27xx_led_probe(struct platform_device *pdev)
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct device_node *np = dev->of_node, *child;
|
struct device_node *np = dev->of_node, *child;
|
||||||
struct sc27xx_led_priv *priv;
|
struct sc27xx_led_priv *priv;
|
||||||
const char *str;
|
|
||||||
u32 base, count, reg;
|
u32 base, count, reg;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -316,15 +319,8 @@ static int sc27xx_led_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->leds[reg].fwnode = of_fwnode_handle(child);
|
||||||
priv->leds[reg].active = true;
|
priv->leds[reg].active = true;
|
||||||
|
|
||||||
err = of_property_read_string(child, "label", &str);
|
|
||||||
if (err)
|
|
||||||
snprintf(priv->leds[reg].name, LED_MAX_NAME_SIZE,
|
|
||||||
"sc27xx::");
|
|
||||||
else
|
|
||||||
snprintf(priv->leds[reg].name, LED_MAX_NAME_SIZE,
|
|
||||||
"sc27xx:%s", str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sc27xx_led_register(dev, priv);
|
err = sc27xx_led_register(dev, priv);
|
||||||
|
|
Loading…
Reference in New Issue