12 #include <linux/kernel.h>
15 #include <linux/slab.h>
21 #include <linux/module.h>
41 #define to_wm831x_status(led_cdev) \
42 container_of(led_cdev, struct wm831x_status, cdev)
67 spin_unlock_irqrestore(&led->
value_lock, flags);
74 static void wm831x_status_set(
struct led_classdev *led_cdev,
85 spin_unlock_irqrestore(&led->
value_lock, flags);
88 static int wm831x_status_blink_set(
struct led_classdev *led_cdev,
89 unsigned long *delay_on,
90 unsigned long *delay_off)
97 if (*delay_on == 0 && *delay_off == 0) {
127 switch (*delay_off / *delay_on) {
155 spin_unlock_irqrestore(&led->
value_lock, flags);
160 static const char *led_src_texts[] = {
177 for (i = 0; i <
ARRAY_SIZE(led_src_texts); i++)
179 ret +=
sprintf(&buf[ret],
"[%s] ", led_src_texts[i]);
181 ret +=
sprintf(&buf[ret],
"%s ", led_src_texts[i]);
185 ret +=
sprintf(&buf[ret],
"\n");
192 const char *buf,
size_t size)
200 name[
sizeof(
name) - 1] =
'\0';
201 strncpy(name, buf,
sizeof(name) - 1);
204 if (len && name[len - 1] ==
'\n')
205 name[len - 1] =
'\0';
207 for (i = 0; i <
ARRAY_SIZE(led_src_texts); i++) {
208 if (!
strcmp(name, led_src_texts[i])) {
221 static DEVICE_ATTR(
src, 0644, wm831x_status_src_show, wm831x_status_src_store);
249 if (wm831x->
dev->platform_data)
250 chip_pdata = wm831x->
dev->platform_data;
255 if (chip_pdata && chip_pdata->
status[
id])
281 drvdata->
src =
pdata.default_src - 1;
285 drvdata->
cdev.default_trigger =
pdata.default_trigger;
286 drvdata->
cdev.brightness_set = wm831x_status_set;
287 drvdata->
cdev.blink_set = wm831x_status_blink_set;
291 dev_err(&pdev->
dev,
"Failed to register LED: %d\n", ret);
298 "No source control for LED: %d\n", ret);
320 .name =
"wm831x-status",
323 .probe = wm831x_status_probe,
324 .remove = wm831x_status_remove,