LKML Archive on lore.kernel.org help / color / mirror / Atom feed
* [RFC PATCH 0/2] LEDs: power_supply: Add ability to blink via simple trigger @ 2011-01-07 16:28 Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 1/2] LEDs: " Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full Vasily Khoruzhick 0 siblings, 2 replies; 6+ messages in thread From: Vasily Khoruzhick @ 2011-01-07 16:28 UTC (permalink / raw) To: linux-kernel, Richard Purdie, Anton Vorontsov, Arnaud Patard (Rtp), anarsoul LEDs blinking API is now available, so it's possible to add ability to blink via simple trigger and add blinking support to power supply LEDs. It can be usefull if there's only one LED available, but you want to indicate if battery is charging or fully charged. Anton, if it's possible, I'd like these patches to be merged via your battery-2.6 tree, because cross-tree dependencies is evil. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH 1/2] LEDs: Add ability to blink via simple trigger 2011-01-07 16:28 [RFC PATCH 0/2] LEDs: power_supply: Add ability to blink via simple trigger Vasily Khoruzhick @ 2011-01-07 16:28 ` Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full Vasily Khoruzhick 1 sibling, 0 replies; 6+ messages in thread From: Vasily Khoruzhick @ 2011-01-07 16:28 UTC (permalink / raw) To: linux-kernel, Richard Purdie, Anton Vorontsov, Arnaud Patard (Rtp), anarsoul As blink API is now available, it's possible to add ability to blink via simple trigger. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> --- drivers/leds/led-triggers.c | 20 ++++++++++++++++++++ include/linux/leds.h | 3 +++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index c41eb61..45f92ec 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -231,6 +231,26 @@ void led_trigger_event(struct led_trigger *trigger, } EXPORT_SYMBOL_GPL(led_trigger_event); +void led_trigger_blink(struct led_trigger *trigger, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct list_head *entry; + + if (!trigger) + return; + + read_lock(&trigger->leddev_list_lock); + list_for_each(entry, &trigger->led_cdevs) { + struct led_classdev *led_cdev; + + led_cdev = list_entry(entry, struct led_classdev, trig_list); + led_blink_set(led_cdev, delay_on, delay_off); + } + read_unlock(&trigger->leddev_list_lock); +} +EXPORT_SYMBOL_GPL(led_trigger_blink); + void led_trigger_register_simple(const char *name, struct led_trigger **tp) { struct led_trigger *trigger; diff --git a/include/linux/leds.h b/include/linux/leds.h index 0f19df9..a1591e8 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -145,6 +145,9 @@ extern void led_trigger_register_simple(const char *name, extern void led_trigger_unregister_simple(struct led_trigger *trigger); extern void led_trigger_event(struct led_trigger *trigger, enum led_brightness event); +extern void led_trigger_blink(struct led_trigger *trigger, + unsigned long *delay_on, + unsigned long *delay_off); #else -- 1.7.3.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full 2011-01-07 16:28 [RFC PATCH 0/2] LEDs: power_supply: Add ability to blink via simple trigger Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 1/2] LEDs: " Vasily Khoruzhick @ 2011-01-07 16:28 ` Vasily Khoruzhick 2011-01-14 16:18 ` Anton Vorontsov 2011-01-31 13:33 ` Anton Vorontsov 1 sibling, 2 replies; 6+ messages in thread From: Vasily Khoruzhick @ 2011-01-07 16:28 UTC (permalink / raw) To: linux-kernel, Richard Purdie, Anton Vorontsov, Arnaud Patard (Rtp), anarsoul Add new trigger to power_supply LEDs. It will blink when battery is charging, and stay solid when battery is charged. It's usefull to indicate battery state when there's only one LED available. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> --- drivers/power/power_supply_leds.c | 18 ++++++++++++++++++ include/linux/power_supply.h | 2 ++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c index 031a554..b640bbf 100644 --- a/drivers/power/power_supply_leds.c +++ b/drivers/power/power_supply_leds.c @@ -21,6 +21,7 @@ static void power_supply_update_bat_leds(struct power_supply *psy) { union power_supply_propval status; + unsigned long delay_on = 0, delay_off = 0; if (psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &status)) return; @@ -32,16 +33,22 @@ static void power_supply_update_bat_leds(struct power_supply *psy) led_trigger_event(psy->charging_full_trig, LED_FULL); led_trigger_event(psy->charging_trig, LED_OFF); led_trigger_event(psy->full_trig, LED_FULL); + led_trigger_event(psy->charging_blink_full_solid_trig, + LED_FULL); break; case POWER_SUPPLY_STATUS_CHARGING: led_trigger_event(psy->charging_full_trig, LED_FULL); led_trigger_event(psy->charging_trig, LED_FULL); led_trigger_event(psy->full_trig, LED_OFF); + led_trigger_blink(psy->charging_blink_full_solid_trig, + &delay_on, &delay_off); break; default: led_trigger_event(psy->charging_full_trig, LED_OFF); led_trigger_event(psy->charging_trig, LED_OFF); led_trigger_event(psy->full_trig, LED_OFF); + led_trigger_event(psy->charging_blink_full_solid_trig, + LED_OFF); break; } } @@ -64,15 +71,24 @@ static int power_supply_create_bat_triggers(struct power_supply *psy) if (!psy->full_trig_name) goto full_failed; + psy->charging_blink_full_solid_trig_name = kasprintf(GFP_KERNEL, + "%s-charging-blink-full-solid", psy->name); + if (!psy->charging_blink_full_solid_trig_name) + goto charging_blink_full_solid_failed; + led_trigger_register_simple(psy->charging_full_trig_name, &psy->charging_full_trig); led_trigger_register_simple(psy->charging_trig_name, &psy->charging_trig); led_trigger_register_simple(psy->full_trig_name, &psy->full_trig); + led_trigger_register_simple(psy->charging_blink_full_solid_trig_name, + &psy->charging_blink_full_solid_trig); goto success; +charging_blink_full_solid_failed: + kfree(psy->full_trig_name); full_failed: kfree(psy->charging_trig_name); charging_failed: @@ -88,6 +104,8 @@ static void power_supply_remove_bat_triggers(struct power_supply *psy) led_trigger_unregister_simple(psy->charging_full_trig); led_trigger_unregister_simple(psy->charging_trig); led_trigger_unregister_simple(psy->full_trig); + led_trigger_unregister_simple(psy->charging_blink_full_solid_trig); + kfree(psy->charging_blink_full_solid_trig_name); kfree(psy->full_trig_name); kfree(psy->charging_trig_name); kfree(psy->charging_full_trig_name); diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 7d73256..32a1e50 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -173,6 +173,8 @@ struct power_supply { char *full_trig_name; struct led_trigger *online_trig; char *online_trig_name; + struct led_trigger *charging_blink_full_solid_trig; + char *charging_blink_full_solid_trig_name; #endif }; -- 1.7.3.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full 2011-01-07 16:28 ` [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full Vasily Khoruzhick @ 2011-01-14 16:18 ` Anton Vorontsov 2011-01-14 16:37 ` Vasily Khoruzhick 2011-01-31 13:33 ` Anton Vorontsov 1 sibling, 1 reply; 6+ messages in thread From: Anton Vorontsov @ 2011-01-14 16:18 UTC (permalink / raw) To: Vasily Khoruzhick; +Cc: linux-kernel, Richard Purdie, Arnaud Patard (Rtp) On Fri, Jan 07, 2011 at 06:28:17PM +0200, Vasily Khoruzhick wrote: > Add new trigger to power_supply LEDs. It will blink when > battery is charging, and stay solid when battery is charged. > It's usefull to indicate battery state when there's only one > LED available. > > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Strange, I got neither 0/2 nor 1/2. Anyway, I'm fine with this particular patch, but to take 1/2 via battery-2.6.git I need Richard's Acked-by tag. A note wrt the new LEDs API... > --- > drivers/power/power_supply_leds.c | 18 ++++++++++++++++++ > include/linux/power_supply.h | 2 ++ > 2 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c > index 031a554..b640bbf 100644 > --- a/drivers/power/power_supply_leds.c > +++ b/drivers/power/power_supply_leds.c > @@ -21,6 +21,7 @@ > static void power_supply_update_bat_leds(struct power_supply *psy) > { > union power_supply_propval status; > + unsigned long delay_on = 0, delay_off = 0; [...] > + led_trigger_blink(psy->charging_blink_full_solid_trig, > + &delay_on, &delay_off); I think it's better to allow passing NULL to led_trigger_blink() and thus avoid delay_{on,off} dummy variables. Thanks, -- Anton Vorontsov Email: cbouatmailru@gmail.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full 2011-01-14 16:18 ` Anton Vorontsov @ 2011-01-14 16:37 ` Vasily Khoruzhick 0 siblings, 0 replies; 6+ messages in thread From: Vasily Khoruzhick @ 2011-01-14 16:37 UTC (permalink / raw) To: Anton Vorontsov; +Cc: linux-kernel, Richard Purdie, Arnaud Patard (Rtp) On Friday 14 January 2011 18:18:51 Anton Vorontsov wrote: > Strange, I got neither 0/2 nor 1/2. Hmm, patches are definitely on ML, here's link to 1st patch on patchwork: https://patchwork.kernel.org/patch/464481/ However, if you want, I can forward copy of 0/2 and 1/2 to you directly, but check your 'spam' folder first ;) > Anyway, I'm fine with this particular patch, but to take 1/2 via > battery-2.6.git I need Richard's Acked-by tag. Ok > > + led_trigger_blink(psy->charging_blink_full_solid_trig, > > + &delay_on, &delay_off); > > I think it's better to allow passing NULL to led_trigger_blink() > and thus avoid delay_{on,off} dummy variables. It mimics led_blink_set function, and I prefer to keep it this way (just to keep consistency), or change led_blink_set behavior. Regards Vasily ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full 2011-01-07 16:28 ` [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full Vasily Khoruzhick 2011-01-14 16:18 ` Anton Vorontsov @ 2011-01-31 13:33 ` Anton Vorontsov 1 sibling, 0 replies; 6+ messages in thread From: Anton Vorontsov @ 2011-01-31 13:33 UTC (permalink / raw) To: Vasily Khoruzhick Cc: linux-kernel, Richard Purdie, Arnaud Patard (Rtp), Andrew Morton On Fri, Jan 07, 2011 at 06:28:17PM +0200, Vasily Khoruzhick wrote: > Add new trigger to power_supply LEDs. It will blink when > battery is charging, and stay solid when battery is charged. > It's usefull to indicate battery state when there's only one > LED available. > > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> > --- Appled both patches to battery-2.6.git, thanks! > drivers/power/power_supply_leds.c | 18 ++++++++++++++++++ > include/linux/power_supply.h | 2 ++ > 2 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c > index 031a554..b640bbf 100644 > --- a/drivers/power/power_supply_leds.c > +++ b/drivers/power/power_supply_leds.c > @@ -21,6 +21,7 @@ > static void power_supply_update_bat_leds(struct power_supply *psy) > { > union power_supply_propval status; > + unsigned long delay_on = 0, delay_off = 0; Changed this to unsigned long delay_on = 0; unsigned long delay_off = 0; Thanks! -- Anton Vorontsov Email: cbouatmailru@gmail.com ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-31 13:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-01-07 16:28 [RFC PATCH 0/2] LEDs: power_supply: Add ability to blink via simple trigger Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 1/2] LEDs: " Vasily Khoruzhick 2011-01-07 16:28 ` [RFC PATCH 2/2] power_supply: Add new LED trigger charging-blink-solid-full Vasily Khoruzhick 2011-01-14 16:18 ` Anton Vorontsov 2011-01-14 16:37 ` Vasily Khoruzhick 2011-01-31 13:33 ` Anton Vorontsov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).