25 #include <linux/kernel.h>
28 #include <linux/slab.h>
31 #include <linux/module.h>
77 static int ns2_led_get_mode(
struct ns2_led_data *led_dat,
90 for (i = 0; i <
ARRAY_SIZE(ns2_led_modval); i++) {
91 if (cmd_level == ns2_led_modval[i].cmd_level &&
92 slow_level == ns2_led_modval[i].slow_level) {
93 *mode = ns2_led_modval[
i].
mode;
104 static void ns2_led_set_mode(
struct ns2_led_data *led_dat,
112 for (i = 0; i <
ARRAY_SIZE(ns2_led_modval); i++) {
113 if (mode == ns2_led_modval[i].mode) {
133 else if (led_dat->
sata)
138 ns2_led_set_mode(led_dat, mode);
143 const char *buff,
size_t count)
158 if (led_dat->
sata == enable)
161 ret = ns2_led_get_mode(led_dat, &mode);
189 const struct ns2_led *
template)
202 dev_err(&pdev->
dev,
"%s: failed to setup command GPIO\n",
214 dev_err(&pdev->
dev,
"%s: failed to setup slow GPIO\n",
221 led_dat->
cdev.name =
template->name;
222 led_dat->
cdev.default_trigger =
template->default_trigger;
224 led_dat->
cdev.brightness_set = ns2_led_set;
226 led_dat->
cmd =
template->cmd;
227 led_dat->
slow =
template->slow;
229 ret = ns2_led_get_mode(led_dat, &mode);
235 led_dat->
cdev.brightness =
258 static void delete_ns2_led(
struct ns2_led_data *led_dat)
281 for (i = 0; i < pdata->
num_leds; i++) {
282 ret = create_ns2_led(pdev, &leds_data[i], &pdata->
leds[i]);
284 for (i = i - 1; i >= 0; i--)
285 delete_ns2_led(&leds_data[i]);
290 platform_set_drvdata(pdev, leds_data);
301 leds_data = platform_get_drvdata(pdev);
303 for (i = 0; i < pdata->
num_leds; i++)
304 delete_ns2_led(&leds_data[i]);
306 platform_set_drvdata(pdev,
NULL);
312 .probe = ns2_led_probe,