blob: a8786f4b345315bda9c2ece778a4add57a41394b [file] [log] [blame]
Richard Purdiec3bc9952006-03-31 02:31:05 -08001/*
2 * LED Triggers Core
3 *
Richard Purdief8a7c6f2007-07-08 23:19:31 +01004 * Copyright 2005-2007 Openedhand Ltd.
Richard Purdiec3bc9952006-03-31 02:31:05 -08005 *
6 * Author: Richard Purdie <rpurdie@openedhand.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
Paul Gortmaker50237862016-08-15 16:54:48 -040014#include <linux/export.h>
Richard Purdiec3bc9952006-03-31 02:31:05 -080015#include <linux/kernel.h>
Richard Purdiec3bc9952006-03-31 02:31:05 -080016#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <linux/device.h>
Richard Purdiec3bc9952006-03-31 02:31:05 -080019#include <linux/timer.h>
Richard Purdiedc472062007-11-10 13:29:04 +000020#include <linux/rwsem.h>
Richard Purdiec3bc9952006-03-31 02:31:05 -080021#include <linux/leds.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090022#include <linux/slab.h>
Richard Purdiec3bc9952006-03-31 02:31:05 -080023#include "leds.h"
24
25/*
26 * Nests outside led_cdev->trigger_lock
27 */
Richard Purdiedc472062007-11-10 13:29:04 +000028static DECLARE_RWSEM(triggers_list_lock);
Ezequiel Garciaba93cdc2016-04-28 19:03:38 -030029LIST_HEAD(trigger_list);
Richard Purdiec3bc9952006-03-31 02:31:05 -080030
Németh Márton4d404fd2008-03-09 20:59:57 +000031 /* Used by LED Class */
32
Richard Purdief8a7c6f2007-07-08 23:19:31 +010033ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
34 const char *buf, size_t count)
Richard Purdiec3bc9952006-03-31 02:31:05 -080035{
Richard Purdief8a7c6f2007-07-08 23:19:31 +010036 struct led_classdev *led_cdev = dev_get_drvdata(dev);
Richard Purdiec3bc9952006-03-31 02:31:05 -080037 struct led_trigger *trig;
Jacek Anaszewskiacd899e2014-09-22 08:21:04 -070038 int ret = count;
39
40 mutex_lock(&led_cdev->led_access);
41
42 if (led_sysfs_is_disabled(led_cdev)) {
43 ret = -EBUSY;
44 goto unlock;
45 }
Richard Purdiec3bc9952006-03-31 02:31:05 -080046
Heiner Kallweit7296c332016-03-08 23:08:36 +010047 if (sysfs_streq(buf, "none")) {
Németh Márton0013b232008-03-09 20:54:37 +000048 led_trigger_remove(led_cdev);
Jacek Anaszewskiacd899e2014-09-22 08:21:04 -070049 goto unlock;
Richard Purdiec3bc9952006-03-31 02:31:05 -080050 }
51
Richard Purdiedc472062007-11-10 13:29:04 +000052 down_read(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080053 list_for_each_entry(trig, &trigger_list, next_trig) {
Heiner Kallweit7296c332016-03-08 23:08:36 +010054 if (sysfs_streq(buf, trig->name)) {
Richard Purdiedc472062007-11-10 13:29:04 +000055 down_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080056 led_trigger_set(led_cdev, trig);
Richard Purdiedc472062007-11-10 13:29:04 +000057 up_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080058
Richard Purdiedc472062007-11-10 13:29:04 +000059 up_read(&triggers_list_lock);
Jacek Anaszewskiacd899e2014-09-22 08:21:04 -070060 goto unlock;
Richard Purdiec3bc9952006-03-31 02:31:05 -080061 }
62 }
Heiner Kallweita3eac762016-07-01 23:08:54 +020063 /* we come here only if buf matches no trigger */
64 ret = -EINVAL;
Richard Purdiedc472062007-11-10 13:29:04 +000065 up_read(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080066
Jacek Anaszewskiacd899e2014-09-22 08:21:04 -070067unlock:
68 mutex_unlock(&led_cdev->led_access);
69 return ret;
Richard Purdiec3bc9952006-03-31 02:31:05 -080070}
Németh Márton4d404fd2008-03-09 20:59:57 +000071EXPORT_SYMBOL_GPL(led_trigger_store);
Richard Purdiec3bc9952006-03-31 02:31:05 -080072
Richard Purdief8a7c6f2007-07-08 23:19:31 +010073ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
74 char *buf)
Richard Purdiec3bc9952006-03-31 02:31:05 -080075{
Richard Purdief8a7c6f2007-07-08 23:19:31 +010076 struct led_classdev *led_cdev = dev_get_drvdata(dev);
Richard Purdiec3bc9952006-03-31 02:31:05 -080077 struct led_trigger *trig;
78 int len = 0;
79
Richard Purdiedc472062007-11-10 13:29:04 +000080 down_read(&triggers_list_lock);
81 down_read(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080082
83 if (!led_cdev->trigger)
Nathan Sullivan3b9b9532016-08-15 17:20:14 -050084 len += scnprintf(buf+len, PAGE_SIZE - len, "[none] ");
Richard Purdiec3bc9952006-03-31 02:31:05 -080085 else
Nathan Sullivan3b9b9532016-08-15 17:20:14 -050086 len += scnprintf(buf+len, PAGE_SIZE - len, "none ");
Richard Purdiec3bc9952006-03-31 02:31:05 -080087
88 list_for_each_entry(trig, &trigger_list, next_trig) {
89 if (led_cdev->trigger && !strcmp(led_cdev->trigger->name,
90 trig->name))
Nathan Sullivan3b9b9532016-08-15 17:20:14 -050091 len += scnprintf(buf+len, PAGE_SIZE - len, "[%s] ",
92 trig->name);
Richard Purdiec3bc9952006-03-31 02:31:05 -080093 else
Nathan Sullivan3b9b9532016-08-15 17:20:14 -050094 len += scnprintf(buf+len, PAGE_SIZE - len, "%s ",
95 trig->name);
Richard Purdiec3bc9952006-03-31 02:31:05 -080096 }
Richard Purdiedc472062007-11-10 13:29:04 +000097 up_read(&led_cdev->trigger_lock);
98 up_read(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -080099
Nathan Sullivan3b9b9532016-08-15 17:20:14 -0500100 len += scnprintf(len+buf, PAGE_SIZE - len, "\n");
Richard Purdiec3bc9952006-03-31 02:31:05 -0800101 return len;
102}
Németh Márton4d404fd2008-03-09 20:59:57 +0000103EXPORT_SYMBOL_GPL(led_trigger_show);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800104
105/* Caller must ensure led_cdev->trigger_lock held */
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200106int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
Richard Purdiec3bc9952006-03-31 02:31:05 -0800107{
108 unsigned long flags;
Colin Cross52c47742012-08-27 09:31:49 +0800109 char *event = NULL;
110 char *envp[2];
111 const char *name;
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200112 int ret;
Colin Cross52c47742012-08-27 09:31:49 +0800113
Jacek Anaszewskifbfa1972016-09-18 20:24:29 +0200114 if (!led_cdev->trigger && !trig)
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200115 return 0;
Jacek Anaszewskifbfa1972016-09-18 20:24:29 +0200116
Colin Cross52c47742012-08-27 09:31:49 +0800117 name = trig ? trig->name : "none";
118 event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800119
120 /* Remove any existing trigger */
121 if (led_cdev->trigger) {
122 write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
123 list_del(&led_cdev->trig_list);
Németh Márton4d404fd2008-03-09 20:59:57 +0000124 write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock,
125 flags);
Fabio Baltierid23a22a2012-08-15 21:44:34 +0800126 cancel_work_sync(&led_cdev->set_brightness_work);
127 led_stop_software_blink(led_cdev);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800128 if (led_cdev->trigger->deactivate)
129 led_cdev->trigger->deactivate(led_cdev);
Dmitry Baryshkovfe3025b2008-07-16 22:51:14 +0100130 led_cdev->trigger = NULL;
Shuah Khan19cd67e2012-06-14 04:34:30 +0800131 led_set_brightness(led_cdev, LED_OFF);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800132 }
Bryan Wueb202622012-04-19 11:46:33 +0800133 if (trig) {
134 write_lock_irqsave(&trig->leddev_list_lock, flags);
135 list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
136 write_unlock_irqrestore(&trig->leddev_list_lock, flags);
137 led_cdev->trigger = trig;
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200138
Bryan Wueb202622012-04-19 11:46:33 +0800139 if (trig->activate)
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200140 ret = trig->activate(led_cdev);
141 else
142 ret = 0;
143
144 if (ret)
145 goto err_activate;
Richard Purdiec3bc9952006-03-31 02:31:05 -0800146 }
Colin Cross52c47742012-08-27 09:31:49 +0800147
148 if (event) {
149 envp[0] = event;
150 envp[1] = NULL;
Jacek Anaszewski6f3bad92016-09-19 12:44:50 +0200151 if (kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp))
152 dev_err(led_cdev->dev,
153 "%s: Error sending uevent\n", __func__);
Colin Cross52c47742012-08-27 09:31:49 +0800154 kfree(event);
155 }
Uwe Kleine-König2282e1252018-07-02 22:05:21 +0200156
157 return 0;
158
159err_activate:
160 led_cdev->trigger = NULL;
161 write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
162 list_del(&led_cdev->trig_list);
163 write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
164 led_set_brightness(led_cdev, LED_OFF);
165
166 return ret;
Richard Purdiec3bc9952006-03-31 02:31:05 -0800167}
Németh Márton4d404fd2008-03-09 20:59:57 +0000168EXPORT_SYMBOL_GPL(led_trigger_set);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800169
Németh Márton0013b232008-03-09 20:54:37 +0000170void led_trigger_remove(struct led_classdev *led_cdev)
171{
172 down_write(&led_cdev->trigger_lock);
173 led_trigger_set(led_cdev, NULL);
174 up_write(&led_cdev->trigger_lock);
175}
Németh Márton4d404fd2008-03-09 20:59:57 +0000176EXPORT_SYMBOL_GPL(led_trigger_remove);
Németh Márton0013b232008-03-09 20:54:37 +0000177
Richard Purdiec3bc9952006-03-31 02:31:05 -0800178void led_trigger_set_default(struct led_classdev *led_cdev)
179{
180 struct led_trigger *trig;
181
182 if (!led_cdev->default_trigger)
183 return;
184
Richard Purdiedc472062007-11-10 13:29:04 +0000185 down_read(&triggers_list_lock);
186 down_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800187 list_for_each_entry(trig, &trigger_list, next_trig) {
188 if (!strcmp(led_cdev->default_trigger, trig->name))
189 led_trigger_set(led_cdev, trig);
190 }
Richard Purdiedc472062007-11-10 13:29:04 +0000191 up_write(&led_cdev->trigger_lock);
192 up_read(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800193}
Németh Márton4d404fd2008-03-09 20:59:57 +0000194EXPORT_SYMBOL_GPL(led_trigger_set_default);
195
Fabio Baltieria8df7b12012-11-04 01:54:34 -0800196void led_trigger_rename_static(const char *name, struct led_trigger *trig)
197{
198 /* new name must be on a temporary string to prevent races */
199 BUG_ON(name == trig->name);
200
201 down_write(&triggers_list_lock);
202 /* this assumes that trig->name was originaly allocated to
203 * non constant storage */
204 strcpy((char *)trig->name, name);
205 up_write(&triggers_list_lock);
206}
207EXPORT_SYMBOL_GPL(led_trigger_rename_static);
208
Németh Márton4d404fd2008-03-09 20:59:57 +0000209/* LED Trigger Interface */
Richard Purdiec3bc9952006-03-31 02:31:05 -0800210
Bryan Wueb202622012-04-19 11:46:33 +0800211int led_trigger_register(struct led_trigger *trig)
Richard Purdiec3bc9952006-03-31 02:31:05 -0800212{
213 struct led_classdev *led_cdev;
Bryan Wueb202622012-04-19 11:46:33 +0800214 struct led_trigger *_trig;
Richard Purdiec3bc9952006-03-31 02:31:05 -0800215
Bryan Wueb202622012-04-19 11:46:33 +0800216 rwlock_init(&trig->leddev_list_lock);
217 INIT_LIST_HEAD(&trig->led_cdevs);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800218
Richard Purdiedc472062007-11-10 13:29:04 +0000219 down_write(&triggers_list_lock);
Adam Nielsen700c6ea2009-02-18 08:18:04 +1000220 /* Make sure the trigger's name isn't already in use */
Bryan Wueb202622012-04-19 11:46:33 +0800221 list_for_each_entry(_trig, &trigger_list, next_trig) {
222 if (!strcmp(_trig->name, trig->name)) {
Adam Nielsen700c6ea2009-02-18 08:18:04 +1000223 up_write(&triggers_list_lock);
224 return -EEXIST;
225 }
226 }
227 /* Add to the list of led triggers */
Bryan Wueb202622012-04-19 11:46:33 +0800228 list_add_tail(&trig->next_trig, &trigger_list);
Richard Purdiedc472062007-11-10 13:29:04 +0000229 up_write(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800230
231 /* Register with any LEDs that have this as a default trigger */
Richard Purdie72f8da32007-12-31 23:09:44 +0000232 down_read(&leds_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800233 list_for_each_entry(led_cdev, &leds_list, node) {
Richard Purdiedc472062007-11-10 13:29:04 +0000234 down_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800235 if (!led_cdev->trigger && led_cdev->default_trigger &&
Bryan Wueb202622012-04-19 11:46:33 +0800236 !strcmp(led_cdev->default_trigger, trig->name))
237 led_trigger_set(led_cdev, trig);
Richard Purdiedc472062007-11-10 13:29:04 +0000238 up_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800239 }
Richard Purdie72f8da32007-12-31 23:09:44 +0000240 up_read(&leds_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800241
242 return 0;
243}
Németh Márton4d404fd2008-03-09 20:59:57 +0000244EXPORT_SYMBOL_GPL(led_trigger_register);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800245
Bryan Wueb202622012-04-19 11:46:33 +0800246void led_trigger_unregister(struct led_trigger *trig)
Richard Purdiec3bc9952006-03-31 02:31:05 -0800247{
248 struct led_classdev *led_cdev;
249
Sasha Levin14f57162014-04-04 10:01:13 -0700250 if (list_empty_careful(&trig->next_trig))
251 return;
252
Richard Purdiec3bc9952006-03-31 02:31:05 -0800253 /* Remove from the list of led triggers */
Richard Purdiedc472062007-11-10 13:29:04 +0000254 down_write(&triggers_list_lock);
Sasha Levin14f57162014-04-04 10:01:13 -0700255 list_del_init(&trig->next_trig);
Richard Purdiedc472062007-11-10 13:29:04 +0000256 up_write(&triggers_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800257
258 /* Remove anyone actively using this trigger */
Richard Purdie72f8da32007-12-31 23:09:44 +0000259 down_read(&leds_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800260 list_for_each_entry(led_cdev, &leds_list, node) {
Richard Purdiedc472062007-11-10 13:29:04 +0000261 down_write(&led_cdev->trigger_lock);
Bryan Wueb202622012-04-19 11:46:33 +0800262 if (led_cdev->trigger == trig)
Richard Purdiec3bc9952006-03-31 02:31:05 -0800263 led_trigger_set(led_cdev, NULL);
Richard Purdiedc472062007-11-10 13:29:04 +0000264 up_write(&led_cdev->trigger_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800265 }
Richard Purdie72f8da32007-12-31 23:09:44 +0000266 up_read(&leds_list_lock);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800267}
Németh Márton4d404fd2008-03-09 20:59:57 +0000268EXPORT_SYMBOL_GPL(led_trigger_unregister);
269
Heiner Kallweit9534cc32016-01-02 01:36:41 +0100270static void devm_led_trigger_release(struct device *dev, void *res)
271{
272 led_trigger_unregister(*(struct led_trigger **)res);
273}
274
275int devm_led_trigger_register(struct device *dev,
276 struct led_trigger *trig)
277{
278 struct led_trigger **dr;
279 int rc;
280
281 dr = devres_alloc(devm_led_trigger_release, sizeof(*dr),
282 GFP_KERNEL);
283 if (!dr)
284 return -ENOMEM;
285
286 *dr = trig;
287
288 rc = led_trigger_register(trig);
289 if (rc)
290 devres_free(dr);
291 else
292 devres_add(dev, dr);
293
294 return rc;
295}
296EXPORT_SYMBOL_GPL(devm_led_trigger_register);
297
Németh Márton4d404fd2008-03-09 20:59:57 +0000298/* Simple LED Tigger Interface */
299
Bryan Wueb202622012-04-19 11:46:33 +0800300void led_trigger_event(struct led_trigger *trig,
Németh Márton4d404fd2008-03-09 20:59:57 +0000301 enum led_brightness brightness)
302{
ZHAO Gang11e043b2013-12-28 07:00:26 -0800303 struct led_classdev *led_cdev;
Németh Márton4d404fd2008-03-09 20:59:57 +0000304
Bryan Wueb202622012-04-19 11:46:33 +0800305 if (!trig)
Németh Márton4d404fd2008-03-09 20:59:57 +0000306 return;
307
Bryan Wueb202622012-04-19 11:46:33 +0800308 read_lock(&trig->leddev_list_lock);
ZHAO Gang11e043b2013-12-28 07:00:26 -0800309 list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list)
Fabio Baltierid23a22a2012-08-15 21:44:34 +0800310 led_set_brightness(led_cdev, brightness);
Bryan Wueb202622012-04-19 11:46:33 +0800311 read_unlock(&trig->leddev_list_lock);
Németh Márton4d404fd2008-03-09 20:59:57 +0000312}
313EXPORT_SYMBOL_GPL(led_trigger_event);
314
Bryan Wu20c0e6b2012-06-15 22:15:27 +0800315static void led_trigger_blink_setup(struct led_trigger *trig,
Fabio Baltieri5bb629c2012-05-27 07:19:22 +0800316 unsigned long *delay_on,
317 unsigned long *delay_off,
318 int oneshot,
319 int invert)
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000320{
ZHAO Gang11e043b2013-12-28 07:00:26 -0800321 struct led_classdev *led_cdev;
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000322
Bryan Wueb202622012-04-19 11:46:33 +0800323 if (!trig)
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000324 return;
325
Bryan Wueb202622012-04-19 11:46:33 +0800326 read_lock(&trig->leddev_list_lock);
ZHAO Gang11e043b2013-12-28 07:00:26 -0800327 list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) {
Fabio Baltieri5bb629c2012-05-27 07:19:22 +0800328 if (oneshot)
329 led_blink_set_oneshot(led_cdev, delay_on, delay_off,
330 invert);
331 else
332 led_blink_set(led_cdev, delay_on, delay_off);
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000333 }
Bryan Wueb202622012-04-19 11:46:33 +0800334 read_unlock(&trig->leddev_list_lock);
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000335}
Fabio Baltieri5bb629c2012-05-27 07:19:22 +0800336
337void led_trigger_blink(struct led_trigger *trig,
338 unsigned long *delay_on,
339 unsigned long *delay_off)
340{
341 led_trigger_blink_setup(trig, delay_on, delay_off, 0, 0);
342}
Vasily Khoruzhick0b9536c2011-01-07 16:28:16 +0000343EXPORT_SYMBOL_GPL(led_trigger_blink);
344
Fabio Baltieri5bb629c2012-05-27 07:19:22 +0800345void led_trigger_blink_oneshot(struct led_trigger *trig,
346 unsigned long *delay_on,
347 unsigned long *delay_off,
348 int invert)
349{
350 led_trigger_blink_setup(trig, delay_on, delay_off, 1, invert);
351}
352EXPORT_SYMBOL_GPL(led_trigger_blink_oneshot);
353
Németh Márton4d404fd2008-03-09 20:59:57 +0000354void led_trigger_register_simple(const char *name, struct led_trigger **tp)
355{
Bryan Wueb202622012-04-19 11:46:33 +0800356 struct led_trigger *trig;
Németh Márton4d404fd2008-03-09 20:59:57 +0000357 int err;
358
Bryan Wueb202622012-04-19 11:46:33 +0800359 trig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
Németh Márton4d404fd2008-03-09 20:59:57 +0000360
Bryan Wueb202622012-04-19 11:46:33 +0800361 if (trig) {
362 trig->name = name;
363 err = led_trigger_register(trig);
Masakazu Mokunocba4c2a2011-10-31 17:11:59 -0700364 if (err < 0) {
Bryan Wueb202622012-04-19 11:46:33 +0800365 kfree(trig);
366 trig = NULL;
Sachin Kamat09f5fe72012-11-25 13:00:44 +0530367 pr_warn("LED trigger %s failed to register (%d)\n",
368 name, err);
Masakazu Mokunocba4c2a2011-10-31 17:11:59 -0700369 }
Sachin Kamat09f5fe72012-11-25 13:00:44 +0530370 } else {
371 pr_warn("LED trigger %s failed to register (no memory)\n",
372 name);
373 }
Bryan Wueb202622012-04-19 11:46:33 +0800374 *tp = trig;
Németh Márton4d404fd2008-03-09 20:59:57 +0000375}
376EXPORT_SYMBOL_GPL(led_trigger_register_simple);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800377
Bryan Wueb202622012-04-19 11:46:33 +0800378void led_trigger_unregister_simple(struct led_trigger *trig)
Richard Purdiec3bc9952006-03-31 02:31:05 -0800379{
Bryan Wueb202622012-04-19 11:46:33 +0800380 if (trig)
381 led_trigger_unregister(trig);
382 kfree(trig);
Richard Purdiec3bc9952006-03-31 02:31:05 -0800383}
Richard Purdiec3bc9952006-03-31 02:31:05 -0800384EXPORT_SYMBOL_GPL(led_trigger_unregister_simple);