2012-06-13 20:34:40

by Shuah Khan

[permalink] [raw]
Subject: [PATCH] leds: Rename led_brightness_set() to led_set_brightness()

Rename leds external interface led_brightness_set() to led_set_brightness().
This is the second phase of the change to reduce confusion between the
leds internal and external interfaces that set brightness. With this change,
now the external interface is led_set_brightness(). The first phase renamed
the internal interface led_set_brightness() to __led_set_brightness().
There are no changes to the interface implementations.

Signed-off-by: Shuah Khan <[email protected]>
---
drivers/leds/led-class.c | 2 +-
drivers/leds/led-core.c | 4 ++--
drivers/leds/led-triggers.c | 2 +-
drivers/leds/ledtrig-oneshot.c | 2 +-
drivers/leds/ledtrig-timer.c | 2 +-
include/linux/leds.h | 4 ++--
net/mac80211/led.c | 2 +-
7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index cb0a6eb..c599095 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -222,7 +222,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
#endif

/* Stop blinking */
- led_brightness_set(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, LED_OFF);

device_unregister(led_cdev->dev);

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 176961b..8a09c5f 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -103,7 +103,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
}
EXPORT_SYMBOL(led_blink_set_oneshot);

-void led_brightness_set(struct led_classdev *led_cdev,
+void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
/* stop and clear soft-blink timer */
@@ -113,4 +113,4 @@ void led_brightness_set(struct led_classdev *led_cdev,

__led_set_brightness(led_cdev, brightness);
}
-EXPORT_SYMBOL(led_brightness_set);
+EXPORT_SYMBOL(led_set_brightness);
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index f8b14dd..57721f2 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -112,7 +112,7 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev);
led_cdev->trigger = NULL;
- led_brightness_set(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, LED_OFF);
}
if (trig) {
write_lock_irqsave(&trig->leddev_list_lock, flags);
diff --git a/drivers/leds/ledtrig-oneshot.c b/drivers/leds/ledtrig-oneshot.c
index 5cbab41..2c029aa 100644
--- a/drivers/leds/ledtrig-oneshot.c
+++ b/drivers/leds/ledtrig-oneshot.c
@@ -177,7 +177,7 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
}

/* Stop blinking */
- led_brightness_set(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, LED_OFF);
}

static struct led_trigger oneshot_led_trigger = {
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 9010f7a..f774d05 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -104,7 +104,7 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev)
}

/* Stop blinking */
- led_brightness_set(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, LED_OFF);
}

static struct led_trigger timer_led_trigger = {
diff --git a/include/linux/leds.h b/include/linux/leds.h
index dd93a22..3aade1d 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -124,7 +124,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
unsigned long *delay_off,
int invert);
/**
- * led_brightness_set - set LED brightness
+ * led_set_brightness - set LED brightness
* @led_cdev: the LED to set
* @brightness: the brightness to set it to
*
@@ -132,7 +132,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
* software blink timer that implements blinking when the
* hardware doesn't.
*/
-extern void led_brightness_set(struct led_classdev *led_cdev,
+extern void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness);

/*
diff --git a/net/mac80211/led.c b/net/mac80211/led.c
index 1bf7903..bcffa69 100644
--- a/net/mac80211/led.c
+++ b/net/mac80211/led.c
@@ -276,7 +276,7 @@ static void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)

read_lock(&tpt_trig->trig.leddev_list_lock);
list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
- led_brightness_set(led_cdev, LED_OFF);
+ led_set_brightness(led_cdev, LED_OFF);
read_unlock(&tpt_trig->trig.leddev_list_lock);
}

--
1.7.9.5



2012-06-14 14:52:35

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] leds: Rename led_brightness_set() to led_set_brightness()

On Wed, 2012-06-13 at 14:34 -0600, Shuah Khan wrote:
> Rename leds external interface led_brightness_set() to led_set_brightness().
> This is the second phase of the change to reduce confusion between the
> leds internal and external interfaces that set brightness. With this change,
> now the external interface is led_set_brightness(). The first phase renamed
> the internal interface led_set_brightness() to __led_set_brightness().
> There are no changes to the interface implementations.
>
> Signed-off-by: Shuah Khan <[email protected]>

Bryan,

Just in case you didn't see this patch. cc'ing linux-leds

-- Shuah

> ---
> drivers/leds/led-class.c | 2 +-
> drivers/leds/led-core.c | 4 ++--
> drivers/leds/led-triggers.c | 2 +-
> drivers/leds/ledtrig-oneshot.c | 2 +-
> drivers/leds/ledtrig-timer.c | 2 +-
> include/linux/leds.h | 4 ++--
> net/mac80211/led.c | 2 +-
> 7 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index cb0a6eb..c599095 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -222,7 +222,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
> #endif
>
> /* Stop blinking */
> - led_brightness_set(led_cdev, LED_OFF);
> + led_set_brightness(led_cdev, LED_OFF);
>
> device_unregister(led_cdev->dev);
>
> diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
> index 176961b..8a09c5f 100644
> --- a/drivers/leds/led-core.c
> +++ b/drivers/leds/led-core.c
> @@ -103,7 +103,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
> }
> EXPORT_SYMBOL(led_blink_set_oneshot);
>
> -void led_brightness_set(struct led_classdev *led_cdev,
> +void led_set_brightness(struct led_classdev *led_cdev,
> enum led_brightness brightness)
> {
> /* stop and clear soft-blink timer */
> @@ -113,4 +113,4 @@ void led_brightness_set(struct led_classdev *led_cdev,
>
> __led_set_brightness(led_cdev, brightness);
> }
> -EXPORT_SYMBOL(led_brightness_set);
> +EXPORT_SYMBOL(led_set_brightness);
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index f8b14dd..57721f2 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -112,7 +112,7 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
> if (led_cdev->trigger->deactivate)
> led_cdev->trigger->deactivate(led_cdev);
> led_cdev->trigger = NULL;
> - led_brightness_set(led_cdev, LED_OFF);
> + led_set_brightness(led_cdev, LED_OFF);
> }
> if (trig) {
> write_lock_irqsave(&trig->leddev_list_lock, flags);
> diff --git a/drivers/leds/ledtrig-oneshot.c b/drivers/leds/ledtrig-oneshot.c
> index 5cbab41..2c029aa 100644
> --- a/drivers/leds/ledtrig-oneshot.c
> +++ b/drivers/leds/ledtrig-oneshot.c
> @@ -177,7 +177,7 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
> }
>
> /* Stop blinking */
> - led_brightness_set(led_cdev, LED_OFF);
> + led_set_brightness(led_cdev, LED_OFF);
> }
>
> static struct led_trigger oneshot_led_trigger = {
> diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
> index 9010f7a..f774d05 100644
> --- a/drivers/leds/ledtrig-timer.c
> +++ b/drivers/leds/ledtrig-timer.c
> @@ -104,7 +104,7 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev)
> }
>
> /* Stop blinking */
> - led_brightness_set(led_cdev, LED_OFF);
> + led_set_brightness(led_cdev, LED_OFF);
> }
>
> static struct led_trigger timer_led_trigger = {
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index dd93a22..3aade1d 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -124,7 +124,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
> unsigned long *delay_off,
> int invert);
> /**
> - * led_brightness_set - set LED brightness
> + * led_set_brightness - set LED brightness
> * @led_cdev: the LED to set
> * @brightness: the brightness to set it to
> *
> @@ -132,7 +132,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
> * software blink timer that implements blinking when the
> * hardware doesn't.
> */
> -extern void led_brightness_set(struct led_classdev *led_cdev,
> +extern void led_set_brightness(struct led_classdev *led_cdev,
> enum led_brightness brightness);
>
> /*
> diff --git a/net/mac80211/led.c b/net/mac80211/led.c
> index 1bf7903..bcffa69 100644
> --- a/net/mac80211/led.c
> +++ b/net/mac80211/led.c
> @@ -276,7 +276,7 @@ static void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
>
> read_lock(&tpt_trig->trig.leddev_list_lock);
> list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
> - led_brightness_set(led_cdev, LED_OFF);
> + led_set_brightness(led_cdev, LED_OFF);
> read_unlock(&tpt_trig->trig.leddev_list_lock);
> }
>

2012-06-14 18:31:37

by Fabio Baltieri

[permalink] [raw]
Subject: [PATCH v2] leds: use led_set_brightness in led_trigger_event

Fix led_trigger_event() to use led_set_brightness() instead of
__led_set_brightness(), so that any pending blink timer is stopped before
setting the new brightness value. Without this fix LED status may be
overridden by a pending timer.

This allows a trigger to use a mix of led_trigger_event(),
led_trigger_blink() and led_trigger_blink_oneshot() without races.

(applied over: leds: Rename led_brightness_set() to led_set_brightness())

Signed-off-by: Fabio Baltieri <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Bryan Wu <[email protected]>
---

Hi Shuah,

thanks for the renaming, looks much more clear now, so that's my
led_trigger_event patch which applies on top of your latest patch - which
should still be needed if I didn't lost anything.

Fabio

drivers/leds/led-triggers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 57721f2..de1c59d 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -224,7 +224,7 @@ void led_trigger_event(struct led_trigger *trig,
struct led_classdev *led_cdev;

led_cdev = list_entry(entry, struct led_classdev, trig_list);
- __led_set_brightness(led_cdev, brightness);
+ led_set_brightness(led_cdev, brightness);
}
read_unlock(&trig->leddev_list_lock);
}
--
1.7.11.rc1.9.gf623ca1.dirty

2012-06-15 04:15:04

by Bryan Wu

[permalink] [raw]
Subject: Re: [PATCH v2] leds: use led_set_brightness in led_trigger_event

On Fri, Jun 15, 2012 at 2:33 AM, Fabio Baltieri
<[email protected]> wrote:
> Fix led_trigger_event() to use led_set_brightness() instead of
> __led_set_brightness(), so that any pending blink timer is stopped before
> setting the new brightness value. ?Without this fix LED status may be
> overridden by a pending timer.
>
> This allows a trigger to use a mix of led_trigger_event(),
> led_trigger_blink() and led_trigger_blink_oneshot() without races.
>
> (applied over: leds: Rename led_brightness_set() to led_set_brightness())
>
> Signed-off-by: Fabio Baltieri <[email protected]>
> Cc: Shuah Khan <[email protected]>
> Cc: Bryan Wu <[email protected]>

Thanks, applied to for-next branch on top of Shuah's renaming patch.

-Bryan

> ---
>
> Hi Shuah,
>
> thanks for the renaming, looks much more clear now, so that's my
> led_trigger_event patch which applies on top of your latest patch - which
> should still be needed if I didn't lost anything.
>
> Fabio
>
> ?drivers/leds/led-triggers.c | 2 +-
> ?1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index 57721f2..de1c59d 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -224,7 +224,7 @@ void led_trigger_event(struct led_trigger *trig,
> ? ? ? ? ? ? ? ?struct led_classdev *led_cdev;
>
> ? ? ? ? ? ? ? ?led_cdev = list_entry(entry, struct led_classdev, trig_list);
> - ? ? ? ? ? ? ? __led_set_brightness(led_cdev, brightness);
> + ? ? ? ? ? ? ? led_set_brightness(led_cdev, brightness);
> ? ? ? ?}
> ? ? ? ?read_unlock(&trig->leddev_list_lock);
> ?}
> --
> 1.7.11.rc1.9.gf623ca1.dirty
>



--
Bryan Wu <[email protected]>
Kernel Developer ? ?+86.186-168-78255 Mobile
Canonical Ltd. ? ? ?http://www.canonical.com
Ubuntu - Linux for human beings | http://www.ubuntu.com

2012-06-15 12:21:09

by Bryan Wu

[permalink] [raw]
Subject: Re: [PATCH] leds: Rename led_brightness_set() to led_set_brightness()

On Thu, Jun 14, 2012 at 10:52 PM, Shuah Khan <[email protected]> wrote:
> On Wed, 2012-06-13 at 14:34 -0600, Shuah Khan wrote:
>> Rename leds external interface led_brightness_set() to led_set_brightness().
>> This is the second phase of the change to reduce confusion between the
>> leds internal and external interfaces that set brightness. With this change,
>> now the external interface is led_set_brightness(). The first phase renamed
>> the internal interface led_set_brightness() to __led_set_brightness().
>> There are no changes to the interface implementations.
>>
>> Signed-off-by: Shuah Khan <[email protected]>
>
> Bryan,
>
> Just in case you didn't see this patch. cc'ing linux-leds
>

I found I missed this patch and cause building failure in linux-next.
applied to my for-next.

Thanks,
-Bryan

>
>> ---
>> ?drivers/leds/led-class.c ? ? ? | ? ?2 +-
>> ?drivers/leds/led-core.c ? ? ? ?| ? ?4 ++--
>> ?drivers/leds/led-triggers.c ? ?| ? ?2 +-
>> ?drivers/leds/ledtrig-oneshot.c | ? ?2 +-
>> ?drivers/leds/ledtrig-timer.c ? | ? ?2 +-
>> ?include/linux/leds.h ? ? ? ? ? | ? ?4 ++--
>> ?net/mac80211/led.c ? ? ? ? ? ? | ? ?2 +-
>> ?7 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
>> index cb0a6eb..c599095 100644
>> --- a/drivers/leds/led-class.c
>> +++ b/drivers/leds/led-class.c
>> @@ -222,7 +222,7 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
>> ?#endif
>>
>> ? ? ? /* Stop blinking */
>> - ? ? led_brightness_set(led_cdev, LED_OFF);
>> + ? ? led_set_brightness(led_cdev, LED_OFF);
>>
>> ? ? ? device_unregister(led_cdev->dev);
>>
>> diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
>> index 176961b..8a09c5f 100644
>> --- a/drivers/leds/led-core.c
>> +++ b/drivers/leds/led-core.c
>> @@ -103,7 +103,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
>> ?}
>> ?EXPORT_SYMBOL(led_blink_set_oneshot);
>>
>> -void led_brightness_set(struct led_classdev *led_cdev,
>> +void led_set_brightness(struct led_classdev *led_cdev,
>> ? ? ? ? ? ? ? ? ? ? ? enum led_brightness brightness)
>> ?{
>> ? ? ? /* stop and clear soft-blink timer */
>> @@ -113,4 +113,4 @@ void led_brightness_set(struct led_classdev *led_cdev,
>>
>> ? ? ? __led_set_brightness(led_cdev, brightness);
>> ?}
>> -EXPORT_SYMBOL(led_brightness_set);
>> +EXPORT_SYMBOL(led_set_brightness);
>> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
>> index f8b14dd..57721f2 100644
>> --- a/drivers/leds/led-triggers.c
>> +++ b/drivers/leds/led-triggers.c
>> @@ -112,7 +112,7 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
>> ? ? ? ? ? ? ? if (led_cdev->trigger->deactivate)
>> ? ? ? ? ? ? ? ? ? ? ? led_cdev->trigger->deactivate(led_cdev);
>> ? ? ? ? ? ? ? led_cdev->trigger = NULL;
>> - ? ? ? ? ? ? led_brightness_set(led_cdev, LED_OFF);
>> + ? ? ? ? ? ? led_set_brightness(led_cdev, LED_OFF);
>> ? ? ? }
>> ? ? ? if (trig) {
>> ? ? ? ? ? ? ? write_lock_irqsave(&trig->leddev_list_lock, flags);
>> diff --git a/drivers/leds/ledtrig-oneshot.c b/drivers/leds/ledtrig-oneshot.c
>> index 5cbab41..2c029aa 100644
>> --- a/drivers/leds/ledtrig-oneshot.c
>> +++ b/drivers/leds/ledtrig-oneshot.c
>> @@ -177,7 +177,7 @@ static void oneshot_trig_deactivate(struct led_classdev *led_cdev)
>> ? ? ? }
>>
>> ? ? ? /* Stop blinking */
>> - ? ? led_brightness_set(led_cdev, LED_OFF);
>> + ? ? led_set_brightness(led_cdev, LED_OFF);
>> ?}
>>
>> ?static struct led_trigger oneshot_led_trigger = {
>> diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
>> index 9010f7a..f774d05 100644
>> --- a/drivers/leds/ledtrig-timer.c
>> +++ b/drivers/leds/ledtrig-timer.c
>> @@ -104,7 +104,7 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev)
>> ? ? ? }
>>
>> ? ? ? /* Stop blinking */
>> - ? ? led_brightness_set(led_cdev, LED_OFF);
>> + ? ? led_set_brightness(led_cdev, LED_OFF);
>> ?}
>>
>> ?static struct led_trigger timer_led_trigger = {
>> diff --git a/include/linux/leds.h b/include/linux/leds.h
>> index dd93a22..3aade1d 100644
>> --- a/include/linux/leds.h
>> +++ b/include/linux/leds.h
>> @@ -124,7 +124,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned long *delay_off,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int invert);
>> ?/**
>> - * led_brightness_set - set LED brightness
>> + * led_set_brightness - set LED brightness
>> ? * @led_cdev: the LED to set
>> ? * @brightness: the brightness to set it to
>> ? *
>> @@ -132,7 +132,7 @@ extern void led_blink_set_oneshot(struct led_classdev *led_cdev,
>> ? * software blink timer that implements blinking when the
>> ? * hardware doesn't.
>> ? */
>> -extern void led_brightness_set(struct led_classdev *led_cdev,
>> +extern void led_set_brightness(struct led_classdev *led_cdev,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?enum led_brightness brightness);
>>
>> ?/*
>> diff --git a/net/mac80211/led.c b/net/mac80211/led.c
>> index 1bf7903..bcffa69 100644
>> --- a/net/mac80211/led.c
>> +++ b/net/mac80211/led.c
>> @@ -276,7 +276,7 @@ static void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
>>
>> ? ? ? read_lock(&tpt_trig->trig.leddev_list_lock);
>> ? ? ? list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
>> - ? ? ? ? ? ? led_brightness_set(led_cdev, LED_OFF);
>> + ? ? ? ? ? ? led_set_brightness(led_cdev, LED_OFF);
>> ? ? ? read_unlock(&tpt_trig->trig.leddev_list_lock);
>> ?}
>>
>
>



--
Bryan Wu <[email protected]>
Kernel Developer ? ?+86.186-168-78255 Mobile
Canonical Ltd. ? ? ?http://www.canonical.com
Ubuntu - Linux for human beings | http://www.ubuntu.com