Release 4.11 drivers/power/supply/power_supply_leds.c
/*
* LEDs triggers for power supply class
*
* Copyright © 2007 Anton Vorontsov <cbou@mail.ru>
* Copyright © 2004 Szabolcs Gyurko
* Copyright © 2003 Ian Molton <spyro@f2s.com>
*
* Modified: 2004, Oct Szabolcs Gyurko
*
* You may use this code as per GPL version 2
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/power_supply.h>
#include <linux/slab.h>
#include "power_supply.h"
/* Battery specific LEDs triggers. */
static void power_supply_update_bat_leds(struct power_supply *psy)
{
union power_supply_propval status;
unsigned long delay_on = 0;
unsigned long delay_off = 0;
if (power_supply_get_property(psy, POWER_SUPPLY_PROP_STATUS, &status))
return;
dev_dbg(&psy->dev, "%s %d\n", __func__, status.intval);
switch (status.intval) {
case POWER_SUPPLY_STATUS_FULL:
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;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 140 | 75.27% | 1 | 20.00% |
Vasily Khoruzhick | 43 | 23.12% | 1 | 20.00% |
Krzysztof Kozlowski | 2 | 1.08% | 2 | 40.00% |
Harvey Harrison | 1 | 0.54% | 1 | 20.00% |
Total | 186 | 100.00% | 5 | 100.00% |
static int power_supply_create_bat_triggers(struct power_supply *psy)
{
psy->charging_full_trig_name = kasprintf(GFP_KERNEL,
"%s-charging-or-full", psy->desc->name);
if (!psy->charging_full_trig_name)
goto charging_full_failed;
psy->charging_trig_name = kasprintf(GFP_KERNEL,
"%s-charging", psy->desc->name);
if (!psy->charging_trig_name)
goto charging_failed;
psy->full_trig_name = kasprintf(GFP_KERNEL, "%s-full", psy->desc->name);
if (!psy->full_trig_name)
goto full_failed;
psy->charging_blink_full_solid_trig_name = kasprintf(GFP_KERNEL,
"%s-charging-blink-full-solid", psy->desc->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);
return 0;
charging_blink_full_solid_failed:
kfree(psy->full_trig_name);
full_failed:
kfree(psy->charging_trig_name);
charging_failed:
kfree(psy->charging_full_trig_name);
charging_full_failed:
return -ENOMEM;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 130 | 64.04% | 1 | 20.00% |
Vasily Khoruzhick | 46 | 22.66% | 1 | 20.00% |
Akinobu Mita | 15 | 7.39% | 1 | 20.00% |
Krzysztof Kozlowski | 8 | 3.94% | 1 | 20.00% |
Viresh Kumar | 4 | 1.97% | 1 | 20.00% |
Total | 203 | 100.00% | 5 | 100.00% |
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);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 53 | 79.10% | 1 | 50.00% |
Vasily Khoruzhick | 14 | 20.90% | 1 | 50.00% |
Total | 67 | 100.00% | 2 | 100.00% |
/* Generated power specific LEDs triggers. */
static void power_supply_update_gen_leds(struct power_supply *psy)
{
union power_supply_propval online;
if (power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE, &online))
return;
dev_dbg(&psy->dev, "%s %d\n", __func__, online.intval);
if (online.intval)
led_trigger_event(psy->online_trig, LED_FULL);
else
led_trigger_event(psy->online_trig, LED_OFF);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 66 | 95.65% | 1 | 25.00% |
Krzysztof Kozlowski | 2 | 2.90% | 2 | 50.00% |
Harvey Harrison | 1 | 1.45% | 1 | 25.00% |
Total | 69 | 100.00% | 4 | 100.00% |
static int power_supply_create_gen_triggers(struct power_supply *psy)
{
psy->online_trig_name = kasprintf(GFP_KERNEL, "%s-online",
psy->desc->name);
if (!psy->online_trig_name)
return -ENOMEM;
led_trigger_register_simple(psy->online_trig_name, &psy->online_trig);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 42 | 77.78% | 1 | 25.00% |
Viresh Kumar | 5 | 9.26% | 1 | 25.00% |
Akinobu Mita | 5 | 9.26% | 1 | 25.00% |
Krzysztof Kozlowski | 2 | 3.70% | 1 | 25.00% |
Total | 54 | 100.00% | 4 | 100.00% |
static void power_supply_remove_gen_triggers(struct power_supply *psy)
{
led_trigger_unregister_simple(psy->online_trig);
kfree(psy->online_trig_name);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
/* Choice what triggers to create&update. */
void power_supply_update_leds(struct power_supply *psy)
{
if (psy->desc->type == POWER_SUPPLY_TYPE_BATTERY)
power_supply_update_bat_leds(psy);
else
power_supply_update_gen_leds(psy);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 29 | 93.55% | 1 | 50.00% |
Krzysztof Kozlowski | 2 | 6.45% | 1 | 50.00% |
Total | 31 | 100.00% | 2 | 100.00% |
int power_supply_create_triggers(struct power_supply *psy)
{
if (psy->desc->type == POWER_SUPPLY_TYPE_BATTERY)
return power_supply_create_bat_triggers(psy);
return power_supply_create_gen_triggers(psy);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 30 | 93.75% | 1 | 50.00% |
Krzysztof Kozlowski | 2 | 6.25% | 1 | 50.00% |
Total | 32 | 100.00% | 2 | 100.00% |
void power_supply_remove_triggers(struct power_supply *psy)
{
if (psy->desc->type == POWER_SUPPLY_TYPE_BATTERY)
power_supply_remove_bat_triggers(psy);
else
power_supply_remove_gen_triggers(psy);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 29 | 93.55% | 1 | 50.00% |
Krzysztof Kozlowski | 2 | 6.45% | 1 | 50.00% |
Total | 31 | 100.00% | 2 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Vorontsov | 551 | 76.85% | 1 | 10.00% |
Vasily Khoruzhick | 103 | 14.37% | 1 | 10.00% |
Akinobu Mita | 23 | 3.21% | 1 | 10.00% |
Krzysztof Kozlowski | 20 | 2.79% | 2 | 20.00% |
Viresh Kumar | 9 | 1.26% | 1 | 10.00% |
Adrian Bunk | 3 | 0.42% | 1 | 10.00% |
Paul Gortmaker | 3 | 0.42% | 1 | 10.00% |
Tejun Heo | 3 | 0.42% | 1 | 10.00% |
Harvey Harrison | 2 | 0.28% | 1 | 10.00% |
Total | 717 | 100.00% | 10 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.