aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/led-class.c26
-rw-r--r--drivers/leds/ledtrig-timer.c16
2 files changed, 35 insertions, 7 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aecbbe2e89a9..3c1711210e38 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -91,6 +91,8 @@ EXPORT_SYMBOL_GPL(led_classdev_resume);
91 */ 91 */
92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) 92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc;
95
94 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0,
95 parent, "%s", led_cdev->name); 97 parent, "%s", led_cdev->name);
96 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->class_dev)))
@@ -99,8 +101,10 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
99 class_set_devdata(led_cdev->class_dev, led_cdev); 101 class_set_devdata(led_cdev->class_dev, led_cdev);
100 102
101 /* register the attributes */ 103 /* register the attributes */
102 class_device_create_file(led_cdev->class_dev, 104 rc = class_device_create_file(led_cdev->class_dev,
103 &class_device_attr_brightness); 105 &class_device_attr_brightness);
106 if (rc)
107 goto err_out;
104 108
105 /* add to the list of leds */ 109 /* add to the list of leds */
106 write_lock(&leds_list_lock); 110 write_lock(&leds_list_lock);
@@ -110,16 +114,28 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
110#ifdef CONFIG_LEDS_TRIGGERS 114#ifdef CONFIG_LEDS_TRIGGERS
111 rwlock_init(&led_cdev->trigger_lock); 115 rwlock_init(&led_cdev->trigger_lock);
112 116
113 led_trigger_set_default(led_cdev); 117 rc = class_device_create_file(led_cdev->class_dev,
118 &class_device_attr_trigger);
119 if (rc)
120 goto err_out_led_list;
114 121
115 class_device_create_file(led_cdev->class_dev, 122 led_trigger_set_default(led_cdev);
116 &class_device_attr_trigger);
117#endif 123#endif
118 124
119 printk(KERN_INFO "Registered led device: %s\n", 125 printk(KERN_INFO "Registered led device: %s\n",
120 led_cdev->class_dev->class_id); 126 led_cdev->class_dev->class_id);
121 127
122 return 0; 128 return 0;
129
130#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev,
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node);
135#endif
136err_out:
137 class_device_unregister(led_cdev->class_dev);
138 return rc;
123} 139}
124EXPORT_SYMBOL_GPL(led_classdev_register); 140EXPORT_SYMBOL_GPL(led_classdev_register);
125 141
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 179c2876b541..29a8818a32ec 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -123,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
123static void timer_trig_activate(struct led_classdev *led_cdev) 123static void timer_trig_activate(struct led_classdev *led_cdev)
124{ 124{
125 struct timer_trig_data *timer_data; 125 struct timer_trig_data *timer_data;
126 int rc;
126 127
127 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL); 128 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
128 if (!timer_data) 129 if (!timer_data)
@@ -134,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
134 timer_data->timer.function = led_timer_function; 135 timer_data->timer.function = led_timer_function;
135 timer_data->timer.data = (unsigned long) led_cdev; 136 timer_data->timer.data = (unsigned long) led_cdev;
136 137
137 class_device_create_file(led_cdev->class_dev, 138 rc = class_device_create_file(led_cdev->class_dev,
138 &class_device_attr_delay_on); 139 &class_device_attr_delay_on);
139 class_device_create_file(led_cdev->class_dev, 140 if (rc) goto err_out;
141 rc = class_device_create_file(led_cdev->class_dev,
140 &class_device_attr_delay_off); 142 &class_device_attr_delay_off);
143 if (rc) goto err_out_delayon;
144
145 return;
146
147err_out_delayon:
148 class_device_remove_file(led_cdev->class_dev,
149 &class_device_attr_delay_on);
150err_out:
151 led_cdev->trigger_data = NULL;
152 kfree(timer_data);
141} 153}
142 154
143static void timer_trig_deactivate(struct led_classdev *led_cdev) 155static void timer_trig_deactivate(struct led_classdev *led_cdev)