ledtrig-gpio.c (033692eb3ec8305f6e9998b297aaec6899680637) | ledtrig-gpio.c (2282e125a406e09331c5a785e3df29035c99a607) |
---|---|
1/* 2 * ledtrig-gio.c - LED Trigger Based on GPIO events 3 * 4 * Copyright 2009 Felipe Balbi <me@felipebalbi.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 148 unchanged lines hidden (view full) --- 157 /* After changing the GPIO, we need to update the LED. */ 158 gpio_trig_irq(0, led); 159 } 160 161 return ret ? ret : n; 162} 163static DEVICE_ATTR(gpio, 0644, gpio_trig_gpio_show, gpio_trig_gpio_store); 164 | 1/* 2 * ledtrig-gio.c - LED Trigger Based on GPIO events 3 * 4 * Copyright 2009 Felipe Balbi <me@felipebalbi.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. --- 148 unchanged lines hidden (view full) --- 157 /* After changing the GPIO, we need to update the LED. */ 158 gpio_trig_irq(0, led); 159 } 160 161 return ret ? ret : n; 162} 163static DEVICE_ATTR(gpio, 0644, gpio_trig_gpio_show, gpio_trig_gpio_store); 164 |
165static void gpio_trig_activate(struct led_classdev *led) | 165static int gpio_trig_activate(struct led_classdev *led) |
166{ 167 struct gpio_trig_data *gpio_data; 168 int ret; 169 170 gpio_data = kzalloc(sizeof(*gpio_data), GFP_KERNEL); 171 if (!gpio_data) | 166{ 167 struct gpio_trig_data *gpio_data; 168 int ret; 169 170 gpio_data = kzalloc(sizeof(*gpio_data), GFP_KERNEL); 171 if (!gpio_data) |
172 return; | 172 return 0; |
173 174 ret = device_create_file(led->dev, &dev_attr_gpio); 175 if (ret) 176 goto err_gpio; 177 178 ret = device_create_file(led->dev, &dev_attr_inverted); 179 if (ret) 180 goto err_inverted; 181 182 ret = device_create_file(led->dev, &dev_attr_desired_brightness); 183 if (ret) 184 goto err_brightness; 185 186 gpio_data->led = led; 187 led->trigger_data = gpio_data; 188 led->activated = true; 189 | 173 174 ret = device_create_file(led->dev, &dev_attr_gpio); 175 if (ret) 176 goto err_gpio; 177 178 ret = device_create_file(led->dev, &dev_attr_inverted); 179 if (ret) 180 goto err_inverted; 181 182 ret = device_create_file(led->dev, &dev_attr_desired_brightness); 183 if (ret) 184 goto err_brightness; 185 186 gpio_data->led = led; 187 led->trigger_data = gpio_data; 188 led->activated = true; 189 |
190 return; | 190 return 0; |
191 192err_brightness: 193 device_remove_file(led->dev, &dev_attr_inverted); 194 195err_inverted: 196 device_remove_file(led->dev, &dev_attr_gpio); 197 198err_gpio: 199 kfree(gpio_data); | 191 192err_brightness: 193 device_remove_file(led->dev, &dev_attr_inverted); 194 195err_inverted: 196 device_remove_file(led->dev, &dev_attr_gpio); 197 198err_gpio: 199 kfree(gpio_data); |
200 201 return 0; |
|
200} 201 202static void gpio_trig_deactivate(struct led_classdev *led) 203{ 204 struct gpio_trig_data *gpio_data = led->trigger_data; 205 206 if (led->activated) { 207 device_remove_file(led->dev, &dev_attr_gpio); --- 30 unchanged lines hidden --- | 202} 203 204static void gpio_trig_deactivate(struct led_classdev *led) 205{ 206 struct gpio_trig_data *gpio_data = led->trigger_data; 207 208 if (led->activated) { 209 device_remove_file(led->dev, &dev_attr_gpio); --- 30 unchanged lines hidden --- |