led-triggers: rename *trigger to *trig for unified naming scheme

No functional change.

Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
This commit is contained in:
Bryan Wu 2012-04-19 11:46:33 +08:00
parent 28a33cbc24
commit eb202621f8

View File

@ -99,7 +99,7 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
EXPORT_SYMBOL_GPL(led_trigger_show); EXPORT_SYMBOL_GPL(led_trigger_show);
/* Caller must ensure led_cdev->trigger_lock held */ /* Caller must ensure led_cdev->trigger_lock held */
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger) void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
{ {
unsigned long flags; unsigned long flags;
@ -114,13 +114,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
led_cdev->trigger = NULL; led_cdev->trigger = NULL;
led_brightness_set(led_cdev, LED_OFF); led_brightness_set(led_cdev, LED_OFF);
} }
if (trigger) { if (trig) {
write_lock_irqsave(&trigger->leddev_list_lock, flags); write_lock_irqsave(&trig->leddev_list_lock, flags);
list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs); list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
write_unlock_irqrestore(&trigger->leddev_list_lock, flags); write_unlock_irqrestore(&trig->leddev_list_lock, flags);
led_cdev->trigger = trigger; led_cdev->trigger = trig;
if (trigger->activate) if (trig->activate)
trigger->activate(led_cdev); trig->activate(led_cdev);
} }
} }
EXPORT_SYMBOL_GPL(led_trigger_set); EXPORT_SYMBOL_GPL(led_trigger_set);
@ -153,24 +153,24 @@ EXPORT_SYMBOL_GPL(led_trigger_set_default);
/* LED Trigger Interface */ /* LED Trigger Interface */
int led_trigger_register(struct led_trigger *trigger) int led_trigger_register(struct led_trigger *trig)
{ {
struct led_classdev *led_cdev; struct led_classdev *led_cdev;
struct led_trigger *trig; struct led_trigger *_trig;
rwlock_init(&trigger->leddev_list_lock); rwlock_init(&trig->leddev_list_lock);
INIT_LIST_HEAD(&trigger->led_cdevs); INIT_LIST_HEAD(&trig->led_cdevs);
down_write(&triggers_list_lock); down_write(&triggers_list_lock);
/* Make sure the trigger's name isn't already in use */ /* Make sure the trigger's name isn't already in use */
list_for_each_entry(trig, &trigger_list, next_trig) { list_for_each_entry(_trig, &trigger_list, next_trig) {
if (!strcmp(trig->name, trigger->name)) { if (!strcmp(_trig->name, trig->name)) {
up_write(&triggers_list_lock); up_write(&triggers_list_lock);
return -EEXIST; return -EEXIST;
} }
} }
/* Add to the list of led triggers */ /* Add to the list of led triggers */
list_add_tail(&trigger->next_trig, &trigger_list); list_add_tail(&trig->next_trig, &trigger_list);
up_write(&triggers_list_lock); up_write(&triggers_list_lock);
/* Register with any LEDs that have this as a default trigger */ /* Register with any LEDs that have this as a default trigger */
@ -178,8 +178,8 @@ int led_trigger_register(struct led_trigger *trigger)
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, trigger->name)) !strcmp(led_cdev->default_trigger, trig->name))
led_trigger_set(led_cdev, trigger); 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);
@ -188,20 +188,20 @@ int led_trigger_register(struct led_trigger *trigger)
} }
EXPORT_SYMBOL_GPL(led_trigger_register); EXPORT_SYMBOL_GPL(led_trigger_register);
void led_trigger_unregister(struct led_trigger *trigger) void led_trigger_unregister(struct led_trigger *trig)
{ {
struct led_classdev *led_cdev; struct led_classdev *led_cdev;
/* Remove from the list of led triggers */ /* Remove from the list of led triggers */
down_write(&triggers_list_lock); down_write(&triggers_list_lock);
list_del(&trigger->next_trig); list_del(&trig->next_trig);
up_write(&triggers_list_lock); up_write(&triggers_list_lock);
/* Remove anyone actively using this trigger */ /* Remove anyone actively using this trigger */
down_read(&leds_list_lock); down_read(&leds_list_lock);
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 == trigger) if (led_cdev->trigger == trig)
led_trigger_set(led_cdev, NULL); led_trigger_set(led_cdev, NULL);
up_write(&led_cdev->trigger_lock); up_write(&led_cdev->trigger_lock);
} }
@ -211,58 +211,58 @@ EXPORT_SYMBOL_GPL(led_trigger_unregister);
/* Simple LED Tigger Interface */ /* Simple LED Tigger Interface */
void led_trigger_event(struct led_trigger *trigger, void led_trigger_event(struct led_trigger *trig,
enum led_brightness brightness) enum led_brightness brightness)
{ {
struct list_head *entry; struct list_head *entry;
if (!trigger) if (!trig)
return; return;
read_lock(&trigger->leddev_list_lock); read_lock(&trig->leddev_list_lock);
list_for_each(entry, &trigger->led_cdevs) { list_for_each(entry, &trig->led_cdevs) {
struct led_classdev *led_cdev; struct led_classdev *led_cdev;
led_cdev = list_entry(entry, struct led_classdev, trig_list); led_cdev = list_entry(entry, struct led_classdev, trig_list);
led_set_brightness(led_cdev, brightness); led_set_brightness(led_cdev, brightness);
} }
read_unlock(&trigger->leddev_list_lock); read_unlock(&trig->leddev_list_lock);
} }
EXPORT_SYMBOL_GPL(led_trigger_event); EXPORT_SYMBOL_GPL(led_trigger_event);
void led_trigger_blink(struct led_trigger *trigger, void led_trigger_blink(struct led_trigger *trig,
unsigned long *delay_on, unsigned long *delay_on,
unsigned long *delay_off) unsigned long *delay_off)
{ {
struct list_head *entry; struct list_head *entry;
if (!trigger) if (!trig)
return; return;
read_lock(&trigger->leddev_list_lock); read_lock(&trig->leddev_list_lock);
list_for_each(entry, &trigger->led_cdevs) { list_for_each(entry, &trig->led_cdevs) {
struct led_classdev *led_cdev; struct led_classdev *led_cdev;
led_cdev = list_entry(entry, struct led_classdev, trig_list); led_cdev = list_entry(entry, struct led_classdev, trig_list);
led_blink_set(led_cdev, delay_on, delay_off); led_blink_set(led_cdev, delay_on, delay_off);
} }
read_unlock(&trigger->leddev_list_lock); read_unlock(&trig->leddev_list_lock);
} }
EXPORT_SYMBOL_GPL(led_trigger_blink); EXPORT_SYMBOL_GPL(led_trigger_blink);
void led_trigger_register_simple(const char *name, struct led_trigger **tp) void led_trigger_register_simple(const char *name, struct led_trigger **tp)
{ {
struct led_trigger *trigger; struct led_trigger *trig;
int err; int err;
trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); trig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
if (trigger) { if (trig) {
trigger->name = name; trig->name = name;
err = led_trigger_register(trigger); err = led_trigger_register(trig);
if (err < 0) { if (err < 0) {
kfree(trigger); kfree(trig);
trigger = NULL; trig = NULL;
printk(KERN_WARNING "LED trigger %s failed to register" printk(KERN_WARNING "LED trigger %s failed to register"
" (%d)\n", name, err); " (%d)\n", name, err);
} }
@ -270,15 +270,15 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp)
printk(KERN_WARNING "LED trigger %s failed to register" printk(KERN_WARNING "LED trigger %s failed to register"
" (no memory)\n", name); " (no memory)\n", name);
*tp = trigger; *tp = trig;
} }
EXPORT_SYMBOL_GPL(led_trigger_register_simple); EXPORT_SYMBOL_GPL(led_trigger_register_simple);
void led_trigger_unregister_simple(struct led_trigger *trigger) void led_trigger_unregister_simple(struct led_trigger *trig)
{ {
if (trigger) if (trig)
led_trigger_unregister(trigger); led_trigger_unregister(trig);
kfree(trigger); kfree(trig);
} }
EXPORT_SYMBOL_GPL(led_trigger_unregister_simple); EXPORT_SYMBOL_GPL(led_trigger_unregister_simple);