aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-17 03:10:20 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:46 -0400
commit12fda16814bba05a84a49a1da25a069d6c249758 (patch)
tree05cb63f14784190d75e98d6ac3f9b2e5949a5539 /drivers/leds/led-class.c
parent58ff407bee5a55f9c1188a3f9d70ffc79485183c (diff)
[PATCH] drivers/led: handle sysfs errors
Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r--drivers/leds/led-class.c26
1 files changed, 21 insertions, 5 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