aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2007-07-08 18:19:31 -0400
committerRichard Purdie <rpurdie@rpsys.net>2007-07-15 20:15:51 -0400
commitf8a7c6fe14f556ca8eeddce258cb21392d0c3a2f (patch)
tree517e178330a46186e6bbd09ba60e453ce32ca485 /drivers/leds/led-class.c
parentf9f451d9cac24b9bd49947d1c6971f3d689381fa (diff)
leds: Convert from struct class_device to struct device
Convert the LEDs class from struct class_device to struct device since class_device is scheduled for removal. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r--drivers/leds/led-class.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 3c1711210e38..4211293ce862 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -2,7 +2,7 @@
2 * LED Class Core 2 * LED Class Core
3 * 3 *
4 * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu> 4 * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
5 * Copyright (C) 2005-2006 Richard Purdie <rpurdie@openedhand.com> 5 * Copyright (C) 2005-2007 Richard Purdie <rpurdie@openedhand.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -24,9 +24,10 @@
24 24
25static struct class *leds_class; 25static struct class *leds_class;
26 26
27static ssize_t led_brightness_show(struct class_device *dev, char *buf) 27static ssize_t led_brightness_show(struct device *dev,
28 struct device_attribute *attr, char *buf)
28{ 29{
29 struct led_classdev *led_cdev = class_get_devdata(dev); 30 struct led_classdev *led_cdev = dev_get_drvdata(dev);
30 ssize_t ret = 0; 31 ssize_t ret = 0;
31 32
32 /* no lock needed for this */ 33 /* no lock needed for this */
@@ -36,10 +37,10 @@ static ssize_t led_brightness_show(struct class_device *dev, char *buf)
36 return ret; 37 return ret;
37} 38}
38 39
39static ssize_t led_brightness_store(struct class_device *dev, 40static ssize_t led_brightness_store(struct device *dev,
40 const char *buf, size_t size) 41 struct device_attribute *attr, const char *buf, size_t size)
41{ 42{
42 struct led_classdev *led_cdev = class_get_devdata(dev); 43 struct led_classdev *led_cdev = dev_get_drvdata(dev);
43 ssize_t ret = -EINVAL; 44 ssize_t ret = -EINVAL;
44 char *after; 45 char *after;
45 unsigned long state = simple_strtoul(buf, &after, 10); 46 unsigned long state = simple_strtoul(buf, &after, 10);
@@ -56,10 +57,9 @@ static ssize_t led_brightness_store(struct class_device *dev,
56 return ret; 57 return ret;
57} 58}
58 59
59static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, 60static DEVICE_ATTR(brightness, 0644, led_brightness_show, led_brightness_store);
60 led_brightness_store);
61#ifdef CONFIG_LEDS_TRIGGERS 61#ifdef CONFIG_LEDS_TRIGGERS
62static CLASS_DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); 62static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
63#endif 63#endif
64 64
65/** 65/**
@@ -93,16 +93,15 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc; 94 int rc;
95 95
96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->dev = device_create(leds_class, parent, 0, "%s",
97 parent, "%s", led_cdev->name); 97 led_cdev->name);
98 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->dev)))
99 return PTR_ERR(led_cdev->class_dev); 99 return PTR_ERR(led_cdev->dev);
100 100
101 class_set_devdata(led_cdev->class_dev, led_cdev); 101 dev_set_drvdata(led_cdev->dev, led_cdev);
102 102
103 /* register the attributes */ 103 /* register the attributes */
104 rc = class_device_create_file(led_cdev->class_dev, 104 rc = device_create_file(led_cdev->dev, &dev_attr_brightness);
105 &class_device_attr_brightness);
106 if (rc) 105 if (rc)
107 goto err_out; 106 goto err_out;
108 107
@@ -114,8 +113,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
114#ifdef CONFIG_LEDS_TRIGGERS 113#ifdef CONFIG_LEDS_TRIGGERS
115 rwlock_init(&led_cdev->trigger_lock); 114 rwlock_init(&led_cdev->trigger_lock);
116 115
117 rc = class_device_create_file(led_cdev->class_dev, 116 rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
118 &class_device_attr_trigger);
119 if (rc) 117 if (rc)
120 goto err_out_led_list; 118 goto err_out_led_list;
121 119
@@ -123,18 +121,17 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
123#endif 121#endif
124 122
125 printk(KERN_INFO "Registered led device: %s\n", 123 printk(KERN_INFO "Registered led device: %s\n",
126 led_cdev->class_dev->class_id); 124 led_cdev->name);
127 125
128 return 0; 126 return 0;
129 127
130#ifdef CONFIG_LEDS_TRIGGERS 128#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list: 129err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev, 130 device_remove_file(led_cdev->dev, &dev_attr_brightness);
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node); 131 list_del(&led_cdev->node);
135#endif 132#endif
136err_out: 133err_out:
137 class_device_unregister(led_cdev->class_dev); 134 device_unregister(led_cdev->dev);
138 return rc; 135 return rc;
139} 136}
140EXPORT_SYMBOL_GPL(led_classdev_register); 137EXPORT_SYMBOL_GPL(led_classdev_register);
@@ -147,18 +144,16 @@ EXPORT_SYMBOL_GPL(led_classdev_register);
147 */ 144 */
148void led_classdev_unregister(struct led_classdev *led_cdev) 145void led_classdev_unregister(struct led_classdev *led_cdev)
149{ 146{
150 class_device_remove_file(led_cdev->class_dev, 147 device_remove_file(led_cdev->dev, &dev_attr_brightness);
151 &class_device_attr_brightness);
152#ifdef CONFIG_LEDS_TRIGGERS 148#ifdef CONFIG_LEDS_TRIGGERS
153 class_device_remove_file(led_cdev->class_dev, 149 device_remove_file(led_cdev->dev, &dev_attr_trigger);
154 &class_device_attr_trigger);
155 write_lock(&led_cdev->trigger_lock); 150 write_lock(&led_cdev->trigger_lock);
156 if (led_cdev->trigger) 151 if (led_cdev->trigger)
157 led_trigger_set(led_cdev, NULL); 152 led_trigger_set(led_cdev, NULL);
158 write_unlock(&led_cdev->trigger_lock); 153 write_unlock(&led_cdev->trigger_lock);
159#endif 154#endif
160 155
161 class_device_unregister(led_cdev->class_dev); 156 device_unregister(led_cdev->dev);
162 157
163 write_lock(&leds_list_lock); 158 write_lock(&leds_list_lock);
164 list_del(&led_cdev->node); 159 list_del(&led_cdev->node);