leds-lt3593.c (30e5c3e6b74b6f8998a2b8407c66acf33ac521d0) leds-lt3593.c (df07cf81268192e42c4cdf91f5f4bf9aaac1b2f0)
1/*
2 * LEDs driver for LT3593 controllers
3 *
4 * See the datasheet at http://cds.linear.com/docs/Datasheet/3593f.pdf
5 *
6 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
7 *
8 * Based on leds-gpio.c,

--- 75 unchanged lines hidden (view full) ---

84
85static int __devinit create_lt3593_led(const struct gpio_led *template,
86 struct lt3593_led_data *led_dat, struct device *parent)
87{
88 int ret, state;
89
90 /* skip leds on GPIOs that aren't available */
91 if (!gpio_is_valid(template->gpio)) {
1/*
2 * LEDs driver for LT3593 controllers
3 *
4 * See the datasheet at http://cds.linear.com/docs/Datasheet/3593f.pdf
5 *
6 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
7 *
8 * Based on leds-gpio.c,

--- 75 unchanged lines hidden (view full) ---

84
85static int __devinit create_lt3593_led(const struct gpio_led *template,
86 struct lt3593_led_data *led_dat, struct device *parent)
87{
88 int ret, state;
89
90 /* skip leds on GPIOs that aren't available */
91 if (!gpio_is_valid(template->gpio)) {
92 dev_info(parent, "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n",
92 printk(KERN_INFO "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n",
93 KBUILD_MODNAME, template->gpio, template->name);
94 return 0;
95 }
96
93 KBUILD_MODNAME, template->gpio, template->name);
94 return 0;
95 }
96
97 ret = gpio_request(template->gpio, template->name);
98 if (ret < 0)
99 return ret;
100
97 led_dat->cdev.name = template->name;
98 led_dat->cdev.default_trigger = template->default_trigger;
99 led_dat->gpio = template->gpio;
100
101 led_dat->cdev.brightness_set = lt3593_led_set;
102
103 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
104 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
105
106 if (!template->retain_state_suspended)
107 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
108
101 led_dat->cdev.name = template->name;
102 led_dat->cdev.default_trigger = template->default_trigger;
103 led_dat->gpio = template->gpio;
104
105 led_dat->cdev.brightness_set = lt3593_led_set;
106
107 state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
108 led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
109
110 if (!template->retain_state_suspended)
111 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
112
109 ret = devm_gpio_request_one(parent, template->gpio,
110 GPIOF_DIR_OUT | state, template->name);
113 ret = gpio_direction_output(led_dat->gpio, state);
111 if (ret < 0)
114 if (ret < 0)
112 return ret;
115 goto err;
113
114 INIT_WORK(&led_dat->work, lt3593_led_work);
115
116 ret = led_classdev_register(parent, &led_dat->cdev);
117 if (ret < 0)
116
117 INIT_WORK(&led_dat->work, lt3593_led_work);
118
119 ret = led_classdev_register(parent, &led_dat->cdev);
120 if (ret < 0)
118 return ret;
121 goto err;
119
122
120 dev_info(parent, "%s: registered LT3593 LED '%s' at GPIO %d\n",
123 printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n",
121 KBUILD_MODNAME, template->name, template->gpio);
122
123 return 0;
124 KBUILD_MODNAME, template->name, template->gpio);
125
126 return 0;
127
128err:
129 gpio_free(led_dat->gpio);
130 return ret;
124}
125
126static void delete_lt3593_led(struct lt3593_led_data *led)
127{
128 if (!gpio_is_valid(led->gpio))
129 return;
130
131 led_classdev_unregister(&led->cdev);
132 cancel_work_sync(&led->work);
131}
132
133static void delete_lt3593_led(struct lt3593_led_data *led)
134{
135 if (!gpio_is_valid(led->gpio))
136 return;
137
138 led_classdev_unregister(&led->cdev);
139 cancel_work_sync(&led->work);
140 gpio_free(led->gpio);
133}
134
135static int __devinit lt3593_led_probe(struct platform_device *pdev)
136{
137 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
138 struct lt3593_led_data *leds_data;
139 int i, ret = 0;
140

--- 35 unchanged lines hidden (view full) ---

176 for (i = 0; i < pdata->num_leds; i++)
177 delete_lt3593_led(&leds_data[i]);
178
179 return 0;
180}
181
182static struct platform_driver lt3593_led_driver = {
183 .probe = lt3593_led_probe,
141}
142
143static int __devinit lt3593_led_probe(struct platform_device *pdev)
144{
145 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
146 struct lt3593_led_data *leds_data;
147 int i, ret = 0;
148

--- 35 unchanged lines hidden (view full) ---

184 for (i = 0; i < pdata->num_leds; i++)
185 delete_lt3593_led(&leds_data[i]);
186
187 return 0;
188}
189
190static struct platform_driver lt3593_led_driver = {
191 .probe = lt3593_led_probe,
184 .remove = __devexit_p(lt3593_led_remove),
192 .remove = lt3593_led_remove,
185 .driver = {
186 .name = "leds-lt3593",
187 .owner = THIS_MODULE,
188 },
189};
190
191module_platform_driver(lt3593_led_driver);
192
193MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
194MODULE_DESCRIPTION("LED driver for LT3593 controllers");
195MODULE_LICENSE("GPL");
196MODULE_ALIAS("platform:leds-lt3593");
193 .driver = {
194 .name = "leds-lt3593",
195 .owner = THIS_MODULE,
196 },
197};
198
199module_platform_driver(lt3593_led_driver);
200
201MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
202MODULE_DESCRIPTION("LED driver for LT3593 controllers");
203MODULE_LICENSE("GPL");
204MODULE_ALIAS("platform:leds-lt3593");