LEDs for 4.21-rc1
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQUwxxKyE5l/npt8ARiEGxRG/Sl2wUCXB0GiQAKCRBiEGxRG/Sl 2+u5AP0ZgpiZuCMlnqaZ8tTBad4+87qOCHjVcau+npbky8/+7wEA4+c4M0n1vmMy HRkgNn5d0N+iDYwyQ4T/4g1IN/eoIQk= =n/42 -----END PGP SIGNATURE----- Merge tag 'leds-for-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds Pull LED updates from Jacek Anaszewski: "There are several few-liners, where most of them are fixes and improvments. One thing standing out is ground preparation for inititializing trigger parameters via Device Tree. We introduce LED_INIT_DEFAULT_TRIGGER flag for that purpose and set it when default trigger is matched. It indicates that trigger should parse DT properties to retrieve the initialization data when set as default one" * tag 'leds-for-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: led: triggers: Initialize LED_INIT_DEFAULT_TRIGGER if trigger is brought after class led: triggers: Add LED_INIT_DEFAULT_TRIGGER flag led: triggers: Break the for loop after default trigger is found leds: pwm: Use OF variant of LED registering function leds: pwm: Simplify with resource-managed devm_led_classdev_register() leds: gpio: Drop unneeded manual of_node assignment leds: 88pm860x: Use of_node_name_eq for node name comparisons leds: powernv: add of_node_put()
This commit is contained in:
commit
4e4390ad06
|
@ -200,8 +200,11 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
|
||||||
down_read(&triggers_list_lock);
|
down_read(&triggers_list_lock);
|
||||||
down_write(&led_cdev->trigger_lock);
|
down_write(&led_cdev->trigger_lock);
|
||||||
list_for_each_entry(trig, &trigger_list, next_trig) {
|
list_for_each_entry(trig, &trigger_list, next_trig) {
|
||||||
if (!strcmp(led_cdev->default_trigger, trig->name))
|
if (!strcmp(led_cdev->default_trigger, trig->name)) {
|
||||||
|
led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER;
|
||||||
led_trigger_set(led_cdev, trig);
|
led_trigger_set(led_cdev, trig);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
up_write(&led_cdev->trigger_lock);
|
up_write(&led_cdev->trigger_lock);
|
||||||
up_read(&triggers_list_lock);
|
up_read(&triggers_list_lock);
|
||||||
|
@ -248,8 +251,10 @@ int led_trigger_register(struct led_trigger *trig)
|
||||||
list_for_each_entry(led_cdev, &leds_list, node) {
|
list_for_each_entry(led_cdev, &leds_list, node) {
|
||||||
down_write(&led_cdev->trigger_lock);
|
down_write(&led_cdev->trigger_lock);
|
||||||
if (!led_cdev->trigger && led_cdev->default_trigger &&
|
if (!led_cdev->trigger && led_cdev->default_trigger &&
|
||||||
!strcmp(led_cdev->default_trigger, trig->name))
|
!strcmp(led_cdev->default_trigger, trig->name)) {
|
||||||
|
led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER;
|
||||||
led_trigger_set(led_cdev, trig);
|
led_trigger_set(led_cdev, trig);
|
||||||
|
}
|
||||||
up_write(&led_cdev->trigger_lock);
|
up_write(&led_cdev->trigger_lock);
|
||||||
}
|
}
|
||||||
up_read(&leds_list_lock);
|
up_read(&leds_list_lock);
|
||||||
|
|
|
@ -130,7 +130,7 @@ static int pm860x_led_dt_init(struct platform_device *pdev,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
for_each_child_of_node(nproot, np) {
|
for_each_child_of_node(nproot, np) {
|
||||||
if (!of_node_cmp(np->name, data->name)) {
|
if (of_node_name_eq(np, data->name)) {
|
||||||
of_property_read_u32(np, "marvell,88pm860x-iset",
|
of_property_read_u32(np, "marvell,88pm860x-iset",
|
||||||
&iset);
|
&iset);
|
||||||
data->iset = PM8606_LED_CURRENT(iset);
|
data->iset = PM8606_LED_CURRENT(iset);
|
||||||
|
|
|
@ -190,7 +190,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
|
||||||
fwnode_handle_put(child);
|
fwnode_handle_put(child);
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
led_dat->cdev.dev->of_node = np;
|
|
||||||
priv->num_leds++;
|
priv->num_leds++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,6 +285,7 @@ static int powernv_led_probe(struct platform_device *pdev)
|
||||||
struct device_node *led_node;
|
struct device_node *led_node;
|
||||||
struct powernv_led_common *powernv_led_common;
|
struct powernv_led_common *powernv_led_common;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
int rc;
|
||||||
|
|
||||||
led_node = of_find_node_by_path("/ibm,opal/leds");
|
led_node = of_find_node_by_path("/ibm,opal/leds");
|
||||||
if (!led_node) {
|
if (!led_node) {
|
||||||
|
@ -295,15 +296,20 @@ static int powernv_led_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common),
|
powernv_led_common = devm_kzalloc(dev, sizeof(*powernv_led_common),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!powernv_led_common)
|
if (!powernv_led_common) {
|
||||||
return -ENOMEM;
|
rc = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_init(&powernv_led_common->lock);
|
mutex_init(&powernv_led_common->lock);
|
||||||
powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX);
|
powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX);
|
||||||
|
|
||||||
platform_set_drvdata(pdev, powernv_led_common);
|
platform_set_drvdata(pdev, powernv_led_common);
|
||||||
|
|
||||||
return powernv_led_classdev(pdev, led_node, powernv_led_common);
|
rc = powernv_led_classdev(pdev, led_node, powernv_led_common);
|
||||||
|
out:
|
||||||
|
of_node_put(led_node);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Platform driver remove */
|
/* Platform driver remove */
|
||||||
|
|
|
@ -74,12 +74,6 @@ static inline size_t sizeof_pwm_leds_priv(int num_leds)
|
||||||
(sizeof(struct led_pwm_data) * num_leds);
|
(sizeof(struct led_pwm_data) * num_leds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void led_pwm_cleanup(struct led_pwm_priv *priv)
|
|
||||||
{
|
|
||||||
while (priv->num_leds--)
|
|
||||||
led_classdev_unregister(&priv->leds[priv->num_leds].cdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
||||||
struct led_pwm *led, struct device_node *child)
|
struct led_pwm *led, struct device_node *child)
|
||||||
{
|
{
|
||||||
|
@ -120,7 +114,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
|
||||||
if (!led_data->period && (led->pwm_period_ns > 0))
|
if (!led_data->period && (led->pwm_period_ns > 0))
|
||||||
led_data->period = led->pwm_period_ns;
|
led_data->period = led->pwm_period_ns;
|
||||||
|
|
||||||
ret = led_classdev_register(dev, &led_data->cdev);
|
ret = devm_of_led_classdev_register(dev, child, &led_data->cdev);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
priv->num_leds++;
|
priv->num_leds++;
|
||||||
led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
|
led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
|
||||||
|
@ -191,25 +185,14 @@ static int led_pwm_probe(struct platform_device *pdev)
|
||||||
ret = led_pwm_create_of(&pdev->dev, priv);
|
ret = led_pwm_create_of(&pdev->dev, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret)
|
||||||
led_pwm_cleanup(priv);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, priv);
|
platform_set_drvdata(pdev, priv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int led_pwm_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct led_pwm_priv *priv = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
led_pwm_cleanup(priv);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id of_pwm_leds_match[] = {
|
static const struct of_device_id of_pwm_leds_match[] = {
|
||||||
{ .compatible = "pwm-leds", },
|
{ .compatible = "pwm-leds", },
|
||||||
{},
|
{},
|
||||||
|
@ -218,7 +201,6 @@ MODULE_DEVICE_TABLE(of, of_pwm_leds_match);
|
||||||
|
|
||||||
static struct platform_driver led_pwm_driver = {
|
static struct platform_driver led_pwm_driver = {
|
||||||
.probe = led_pwm_probe,
|
.probe = led_pwm_probe,
|
||||||
.remove = led_pwm_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "leds_pwm",
|
.name = "leds_pwm",
|
||||||
.of_match_table = of_pwm_leds_match,
|
.of_match_table = of_pwm_leds_match,
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct led_classdev {
|
||||||
#define LED_PANIC_INDICATOR BIT(20)
|
#define LED_PANIC_INDICATOR BIT(20)
|
||||||
#define LED_BRIGHT_HW_CHANGED BIT(21)
|
#define LED_BRIGHT_HW_CHANGED BIT(21)
|
||||||
#define LED_RETAIN_AT_SHUTDOWN BIT(22)
|
#define LED_RETAIN_AT_SHUTDOWN BIT(22)
|
||||||
|
#define LED_INIT_DEFAULT_TRIGGER BIT(23)
|
||||||
|
|
||||||
/* set_brightness_work / blink_timer flags, atomic, private. */
|
/* set_brightness_work / blink_timer flags, atomic, private. */
|
||||||
unsigned long work_flags;
|
unsigned long work_flags;
|
||||||
|
|
Loading…
Reference in New Issue