aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-triggers.c
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-04-18 23:46:33 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:33 -0400
commiteb202621f8c0fb264a35e1b35fc00bdb3114a897 (patch)
tree1cefe4e7cd9b620744550b35014ab52dc812e14a /drivers/leds/led-triggers.c
parent28a33cbc24e4256c143dce96c7d93bf423229f92 (diff)
led-triggers: rename *trigger to *trig for unified naming scheme
No functional change. Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/led-triggers.c')
-rw-r--r--drivers/leds/led-triggers.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 46b4c766335d..b449ed8d8712 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -99,7 +99,7 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
99EXPORT_SYMBOL_GPL(led_trigger_show); 99EXPORT_SYMBOL_GPL(led_trigger_show);
100 100
101/* Caller must ensure led_cdev->trigger_lock held */ 101/* Caller must ensure led_cdev->trigger_lock held */
102void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger) 102void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
103{ 103{
104 unsigned long flags; 104 unsigned long flags;
105 105
@@ -114,13 +114,13 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
114 led_cdev->trigger = NULL; 114 led_cdev->trigger = NULL;
115 led_brightness_set(led_cdev, LED_OFF); 115 led_brightness_set(led_cdev, LED_OFF);
116 } 116 }
117 if (trigger) { 117 if (trig) {
118 write_lock_irqsave(&trigger->leddev_list_lock, flags); 118 write_lock_irqsave(&trig->leddev_list_lock, flags);
119 list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs); 119 list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
120 write_unlock_irqrestore(&trigger->leddev_list_lock, flags); 120 write_unlock_irqrestore(&trig->leddev_list_lock, flags);
121 led_cdev->trigger = trigger; 121 led_cdev->trigger = trig;
122 if (trigger->activate) 122 if (trig->activate)
123 trigger->activate(led_cdev); 123 trig->activate(led_cdev);
124 } 124 }
125} 125}
126EXPORT_SYMBOL_GPL(led_trigger_set); 126EXPORT_SYMBOL_GPL(led_trigger_set);
@@ -153,24 +153,24 @@ EXPORT_SYMBOL_GPL(led_trigger_set_default);
153 153
154/* LED Trigger Interface */ 154/* LED Trigger Interface */
155 155
156int led_trigger_register(struct led_trigger *trigger) 156int led_trigger_register(struct led_trigger *trig)
157{ 157{
158 struct led_classdev *led_cdev; 158 struct led_classdev *led_cdev;
159 struct led_trigger *trig; 159 struct led_trigger *_trig;
160 160
161 rwlock_init(&trigger->leddev_list_lock); 161 rwlock_init(&trig->leddev_list_lock);
162 INIT_LIST_HEAD(&trigger->led_cdevs); 162 INIT_LIST_HEAD(&trig->led_cdevs);
163 163
164 down_write(&triggers_list_lock); 164 down_write(&triggers_list_lock);
165 /* Make sure the trigger's name isn't already in use */ 165 /* Make sure the trigger's name isn't already in use */
166 list_for_each_entry(trig, &trigger_list, next_trig) { 166 list_for_each_entry(_trig, &trigger_list, next_trig) {
167 if (!strcmp(trig->name, trigger->name)) { 167 if (!strcmp(_trig->name, trig->name)) {
168 up_write(&triggers_list_lock); 168 up_write(&triggers_list_lock);
169 return -EEXIST; 169 return -EEXIST;
170 } 170 }
171 } 171 }
172 /* Add to the list of led triggers */ 172 /* Add to the list of led triggers */
173 list_add_tail(&trigger->next_trig, &trigger_list); 173 list_add_tail(&trig->next_trig, &trigger_list);
174 up_write(&triggers_list_lock); 174 up_write(&triggers_list_lock);
175 175
176 /* Register with any LEDs that have this as a default trigger */ 176 /* Register with any LEDs that have this as a default trigger */
@@ -178,8 +178,8 @@ int led_trigger_register(struct led_trigger *trigger)
178 list_for_each_entry(led_cdev, &leds_list, node) { 178 list_for_each_entry(led_cdev, &leds_list, node) {
179 down_write(&led_cdev->trigger_lock); 179 down_write(&led_cdev->trigger_lock);
180 if (!led_cdev->trigger && led_cdev->default_trigger && 180 if (!led_cdev->trigger && led_cdev->default_trigger &&
181 !strcmp(led_cdev->default_trigger, trigger->name)) 181 !strcmp(led_cdev->default_trigger, trig->name))
182 led_trigger_set(led_cdev, trigger); 182 led_trigger_set(led_cdev, trig);
183 up_write(&led_cdev->trigger_lock); 183 up_write(&led_cdev->trigger_lock);
184 } 184 }
185 up_read(&leds_list_lock); 185 up_read(&leds_list_lock);
@@ -188,20 +188,20 @@ int led_trigger_register(struct led_trigger *trigger)
188} 188}
189EXPORT_SYMBOL_GPL(led_trigger_register); 189EXPORT_SYMBOL_GPL(led_trigger_register);
190 190
191void led_trigger_unregister(struct led_trigger *trigger) 191void led_trigger_unregister(struct led_trigger *trig)
192{ 192{
193 struct led_classdev *led_cdev; 193 struct led_classdev *led_cdev;
194 194
195 /* Remove from the list of led triggers */ 195 /* Remove from the list of led triggers */
196 down_write(&triggers_list_lock); 196 down_write(&triggers_list_lock);
197 list_del(&trigger->next_trig); 197 list_del(&trig->next_trig);
198 up_write(&triggers_list_lock); 198 up_write(&triggers_list_lock);
199 199
200 /* Remove anyone actively using this trigger */ 200 /* Remove anyone actively using this trigger */
201 down_read(&leds_list_lock); 201 down_read(&leds_list_lock);
202 list_for_each_entry(led_cdev, &leds_list, node) { 202 list_for_each_entry(led_cdev, &leds_list, node) {
203 down_write(&led_cdev->trigger_lock); 203 down_write(&led_cdev->trigger_lock);
204 if (led_cdev->trigger == trigger) 204 if (led_cdev->trigger == trig)
205 led_trigger_set(led_cdev, NULL); 205 led_trigger_set(led_cdev, NULL);
206 up_write(&led_cdev->trigger_lock); 206 up_write(&led_cdev->trigger_lock);
207 } 207 }
@@ -211,58 +211,58 @@ EXPORT_SYMBOL_GPL(led_trigger_unregister);
211 211
212/* Simple LED Tigger Interface */ 212/* Simple LED Tigger Interface */
213 213
214void led_trigger_event(struct led_trigger *trigger, 214void led_trigger_event(struct led_trigger *trig,
215 enum led_brightness brightness) 215 enum led_brightness brightness)
216{ 216{
217 struct list_head *entry; 217 struct list_head *entry;
218 218
219 if (!trigger) 219 if (!trig)
220 return; 220 return;
221 221
222 read_lock(&trigger->leddev_list_lock); 222 read_lock(&trig->leddev_list_lock);
223 list_for_each(entry, &trigger->led_cdevs) { 223 list_for_each(entry, &trig->led_cdevs) {
224 struct led_classdev *led_cdev; 224 struct led_classdev *led_cdev;
225 225
226 led_cdev = list_entry(entry, struct led_classdev, trig_list); 226 led_cdev = list_entry(entry, struct led_classdev, trig_list);
227 led_set_brightness(led_cdev, brightness); 227 led_set_brightness(led_cdev, brightness);
228 } 228 }
229 read_unlock(&trigger->leddev_list_lock); 229 read_unlock(&trig->leddev_list_lock);
230} 230}
231EXPORT_SYMBOL_GPL(led_trigger_event); 231EXPORT_SYMBOL_GPL(led_trigger_event);
232 232
233void led_trigger_blink(struct led_trigger *trigger, 233void led_trigger_blink(struct led_trigger *trig,
234 unsigned long *delay_on, 234 unsigned long *delay_on,
235 unsigned long *delay_off) 235 unsigned long *delay_off)
236{ 236{
237 struct list_head *entry; 237 struct list_head *entry;
238 238
239 if (!trigger) 239 if (!trig)
240 return; 240 return;
241 241
242 read_lock(&trigger->leddev_list_lock); 242 read_lock(&trig->leddev_list_lock);
243 list_for_each(entry, &trigger->led_cdevs) { 243 list_for_each(entry, &trig->led_cdevs) {
244 struct led_classdev *led_cdev; 244 struct led_classdev *led_cdev;
245 245
246 led_cdev = list_entry(entry, struct led_classdev, trig_list); 246 led_cdev = list_entry(entry, struct led_classdev, trig_list);
247 led_blink_set(led_cdev, delay_on, delay_off); 247 led_blink_set(led_cdev, delay_on, delay_off);
248 } 248 }
249 read_unlock(&trigger->leddev_list_lock); 249 read_unlock(&trig->leddev_list_lock);
250} 250}
251EXPORT_SYMBOL_GPL(led_trigger_blink); 251EXPORT_SYMBOL_GPL(led_trigger_blink);
252 252
253void led_trigger_register_simple(const char *name, struct led_trigger **tp) 253void led_trigger_register_simple(const char *name, struct led_trigger **tp)
254{ 254{
255 struct led_trigger *trigger; 255 struct led_trigger *trig;
256 int err; 256 int err;
257 257
258 trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); 258 trig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
259 259
260 if (trigger) { 260 if (trig) {
261 trigger->name = name; 261 trig->name = name;
262 err = led_trigger_register(trigger); 262 err = led_trigger_register(trig);
263 if (err < 0) { 263 if (err < 0) {
264 kfree(trigger); 264 kfree(trig);
265 trigger = NULL; 265 trig = NULL;
266 printk(KERN_WARNING "LED trigger %s failed to register" 266 printk(KERN_WARNING "LED trigger %s failed to register"
267 " (%d)\n", name, err); 267 " (%d)\n", name, err);
268 } 268 }
@@ -270,15 +270,15 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp)
270 printk(KERN_WARNING "LED trigger %s failed to register" 270 printk(KERN_WARNING "LED trigger %s failed to register"
271 " (no memory)\n", name); 271 " (no memory)\n", name);
272 272
273 *tp = trigger; 273 *tp = trig;
274} 274}
275EXPORT_SYMBOL_GPL(led_trigger_register_simple); 275EXPORT_SYMBOL_GPL(led_trigger_register_simple);
276 276
277void led_trigger_unregister_simple(struct led_trigger *trigger) 277void led_trigger_unregister_simple(struct led_trigger *trig)
278{ 278{
279 if (trigger) 279 if (trig)
280 led_trigger_unregister(trigger); 280 led_trigger_unregister(trig);
281 kfree(trigger); 281 kfree(trig);
282} 282}
283EXPORT_SYMBOL_GPL(led_trigger_unregister_simple); 283EXPORT_SYMBOL_GPL(led_trigger_unregister_simple);
284 284