diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2007-07-08 18:19:31 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2007-07-15 20:15:51 -0400 |
commit | f8a7c6fe14f556ca8eeddce258cb21392d0c3a2f (patch) | |
tree | 517e178330a46186e6bbd09ba60e453ce32ca485 /drivers | |
parent | f9f451d9cac24b9bd49947d1c6971f3d689381fa (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')
-rw-r--r-- | drivers/leds/led-class.c | 49 | ||||
-rw-r--r-- | drivers/leds/led-triggers.c | 13 | ||||
-rw-r--r-- | drivers/leds/leds-locomo.c | 2 | ||||
-rw-r--r-- | drivers/leds/leds.h | 8 | ||||
-rw-r--r-- | drivers/leds/ledtrig-timer.c | 49 |
5 files changed, 58 insertions, 63 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 | ||
25 | static struct class *leds_class; | 25 | static struct class *leds_class; |
26 | 26 | ||
27 | static ssize_t led_brightness_show(struct class_device *dev, char *buf) | 27 | static 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 | ||
39 | static ssize_t led_brightness_store(struct class_device *dev, | 40 | static 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 | ||
59 | static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, | 60 | static DEVICE_ATTR(brightness, 0644, led_brightness_show, led_brightness_store); |
60 | led_brightness_store); | ||
61 | #ifdef CONFIG_LEDS_TRIGGERS | 61 | #ifdef CONFIG_LEDS_TRIGGERS |
62 | static CLASS_DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); | 62 | static 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 |
131 | err_out_led_list: | 129 | err_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 |
136 | err_out: | 133 | err_out: |
137 | class_device_unregister(led_cdev->class_dev); | 134 | device_unregister(led_cdev->dev); |
138 | return rc; | 135 | return rc; |
139 | } | 136 | } |
140 | EXPORT_SYMBOL_GPL(led_classdev_register); | 137 | EXPORT_SYMBOL_GPL(led_classdev_register); |
@@ -147,18 +144,16 @@ EXPORT_SYMBOL_GPL(led_classdev_register); | |||
147 | */ | 144 | */ |
148 | void led_classdev_unregister(struct led_classdev *led_cdev) | 145 | void 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); |
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index b2438a03082b..575368c2b100 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * LED Triggers Core | 2 | * LED Triggers Core |
3 | * | 3 | * |
4 | * Copyright 2005-2006 Openedhand Ltd. | 4 | * Copyright 2005-2007 Openedhand Ltd. |
5 | * | 5 | * |
6 | * Author: Richard Purdie <rpurdie@openedhand.com> | 6 | * Author: Richard Purdie <rpurdie@openedhand.com> |
7 | * | 7 | * |
@@ -28,10 +28,10 @@ | |||
28 | static DEFINE_RWLOCK(triggers_list_lock); | 28 | static DEFINE_RWLOCK(triggers_list_lock); |
29 | static LIST_HEAD(trigger_list); | 29 | static LIST_HEAD(trigger_list); |
30 | 30 | ||
31 | ssize_t led_trigger_store(struct class_device *dev, const char *buf, | 31 | ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, |
32 | size_t count) | 32 | const char *buf, size_t count) |
33 | { | 33 | { |
34 | struct led_classdev *led_cdev = class_get_devdata(dev); | 34 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
35 | char trigger_name[TRIG_NAME_MAX]; | 35 | char trigger_name[TRIG_NAME_MAX]; |
36 | struct led_trigger *trig; | 36 | struct led_trigger *trig; |
37 | size_t len; | 37 | size_t len; |
@@ -67,9 +67,10 @@ ssize_t led_trigger_store(struct class_device *dev, const char *buf, | |||
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | ssize_t led_trigger_show(struct class_device *dev, char *buf) | 70 | ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr, |
71 | char *buf) | ||
71 | { | 72 | { |
72 | struct led_classdev *led_cdev = class_get_devdata(dev); | 73 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
73 | struct led_trigger *trig; | 74 | struct led_trigger *trig; |
74 | int len = 0; | 75 | int len = 0; |
75 | 76 | ||
diff --git a/drivers/leds/leds-locomo.c b/drivers/leds/leds-locomo.c index 6f2d449ba983..bfac499f3258 100644 --- a/drivers/leds/leds-locomo.c +++ b/drivers/leds/leds-locomo.c | |||
@@ -19,7 +19,7 @@ | |||
19 | static void locomoled_brightness_set(struct led_classdev *led_cdev, | 19 | static void locomoled_brightness_set(struct led_classdev *led_cdev, |
20 | enum led_brightness value, int offset) | 20 | enum led_brightness value, int offset) |
21 | { | 21 | { |
22 | struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->class_dev->dev); | 22 | struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev); |
23 | unsigned long flags; | 23 | unsigned long flags; |
24 | 24 | ||
25 | local_irq_save(flags); | 25 | local_irq_save(flags); |
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h index a715c4ed93ff..f2f3884fe063 100644 --- a/drivers/leds/leds.h +++ b/drivers/leds/leds.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #ifndef __LEDS_H_INCLUDED | 13 | #ifndef __LEDS_H_INCLUDED |
14 | #define __LEDS_H_INCLUDED | 14 | #define __LEDS_H_INCLUDED |
15 | 15 | ||
16 | #include <linux/device.h> | ||
16 | #include <linux/leds.h> | 17 | #include <linux/leds.h> |
17 | 18 | ||
18 | static inline void led_set_brightness(struct led_classdev *led_cdev, | 19 | static inline void led_set_brightness(struct led_classdev *led_cdev, |
@@ -37,8 +38,9 @@ void led_trigger_set(struct led_classdev *led_cdev, | |||
37 | #define led_trigger_set(x, y) do {} while(0) | 38 | #define led_trigger_set(x, y) do {} while(0) |
38 | #endif | 39 | #endif |
39 | 40 | ||
40 | ssize_t led_trigger_store(struct class_device *dev, const char *buf, | 41 | ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr, |
41 | size_t count); | 42 | const char *buf, size_t count); |
42 | ssize_t led_trigger_show(struct class_device *dev, char *buf); | 43 | ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr, |
44 | char *buf); | ||
43 | 45 | ||
44 | #endif /* __LEDS_H_INCLUDED */ | 46 | #endif /* __LEDS_H_INCLUDED */ |
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index d756bdb01c59..ed9ff02c77ea 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c | |||
@@ -52,9 +52,10 @@ static void led_timer_function(unsigned long data) | |||
52 | mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay)); | 52 | mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay)); |
53 | } | 53 | } |
54 | 54 | ||
55 | static ssize_t led_delay_on_show(struct class_device *dev, char *buf) | 55 | static ssize_t led_delay_on_show(struct device *dev, |
56 | struct device_attribute *attr, char *buf) | ||
56 | { | 57 | { |
57 | struct led_classdev *led_cdev = class_get_devdata(dev); | 58 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
58 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 59 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
59 | 60 | ||
60 | sprintf(buf, "%lu\n", timer_data->delay_on); | 61 | sprintf(buf, "%lu\n", timer_data->delay_on); |
@@ -62,10 +63,10 @@ static ssize_t led_delay_on_show(struct class_device *dev, char *buf) | |||
62 | return strlen(buf) + 1; | 63 | return strlen(buf) + 1; |
63 | } | 64 | } |
64 | 65 | ||
65 | static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, | 66 | static ssize_t led_delay_on_store(struct device *dev, |
66 | size_t size) | 67 | struct device_attribute *attr, const char *buf, size_t size) |
67 | { | 68 | { |
68 | struct led_classdev *led_cdev = class_get_devdata(dev); | 69 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
69 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 70 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
70 | int ret = -EINVAL; | 71 | int ret = -EINVAL; |
71 | char *after; | 72 | char *after; |
@@ -84,9 +85,10 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, | |||
84 | return ret; | 85 | return ret; |
85 | } | 86 | } |
86 | 87 | ||
87 | static ssize_t led_delay_off_show(struct class_device *dev, char *buf) | 88 | static ssize_t led_delay_off_show(struct device *dev, |
89 | struct device_attribute *attr, char *buf) | ||
88 | { | 90 | { |
89 | struct led_classdev *led_cdev = class_get_devdata(dev); | 91 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
90 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 92 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
91 | 93 | ||
92 | sprintf(buf, "%lu\n", timer_data->delay_off); | 94 | sprintf(buf, "%lu\n", timer_data->delay_off); |
@@ -94,10 +96,10 @@ static ssize_t led_delay_off_show(struct class_device *dev, char *buf) | |||
94 | return strlen(buf) + 1; | 96 | return strlen(buf) + 1; |
95 | } | 97 | } |
96 | 98 | ||
97 | static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, | 99 | static ssize_t led_delay_off_store(struct device *dev, |
98 | size_t size) | 100 | struct device_attribute *attr, const char *buf, size_t size) |
99 | { | 101 | { |
100 | struct led_classdev *led_cdev = class_get_devdata(dev); | 102 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
101 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 103 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
102 | int ret = -EINVAL; | 104 | int ret = -EINVAL; |
103 | char *after; | 105 | char *after; |
@@ -116,10 +118,8 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, | |||
116 | return ret; | 118 | return ret; |
117 | } | 119 | } |
118 | 120 | ||
119 | static CLASS_DEVICE_ATTR(delay_on, 0644, led_delay_on_show, | 121 | static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store); |
120 | led_delay_on_store); | 122 | static DEVICE_ATTR(delay_off, 0644, led_delay_off_show, led_delay_off_store); |
121 | static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show, | ||
122 | led_delay_off_store); | ||
123 | 123 | ||
124 | static void timer_trig_activate(struct led_classdev *led_cdev) | 124 | static void timer_trig_activate(struct led_classdev *led_cdev) |
125 | { | 125 | { |
@@ -136,18 +136,17 @@ static void timer_trig_activate(struct led_classdev *led_cdev) | |||
136 | timer_data->timer.function = led_timer_function; | 136 | timer_data->timer.function = led_timer_function; |
137 | timer_data->timer.data = (unsigned long) led_cdev; | 137 | timer_data->timer.data = (unsigned long) led_cdev; |
138 | 138 | ||
139 | rc = class_device_create_file(led_cdev->class_dev, | 139 | rc = device_create_file(led_cdev->dev, &dev_attr_delay_on); |
140 | &class_device_attr_delay_on); | 140 | if (rc) |
141 | if (rc) goto err_out; | 141 | goto err_out; |
142 | rc = class_device_create_file(led_cdev->class_dev, | 142 | rc = device_create_file(led_cdev->dev, &dev_attr_delay_off); |
143 | &class_device_attr_delay_off); | 143 | if (rc) |
144 | if (rc) goto err_out_delayon; | 144 | goto err_out_delayon; |
145 | 145 | ||
146 | return; | 146 | return; |
147 | 147 | ||
148 | err_out_delayon: | 148 | err_out_delayon: |
149 | class_device_remove_file(led_cdev->class_dev, | 149 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); |
150 | &class_device_attr_delay_on); | ||
151 | err_out: | 150 | err_out: |
152 | led_cdev->trigger_data = NULL; | 151 | led_cdev->trigger_data = NULL; |
153 | kfree(timer_data); | 152 | kfree(timer_data); |
@@ -158,10 +157,8 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev) | |||
158 | struct timer_trig_data *timer_data = led_cdev->trigger_data; | 157 | struct timer_trig_data *timer_data = led_cdev->trigger_data; |
159 | 158 | ||
160 | if (timer_data) { | 159 | if (timer_data) { |
161 | class_device_remove_file(led_cdev->class_dev, | 160 | device_remove_file(led_cdev->dev, &dev_attr_delay_on); |
162 | &class_device_attr_delay_on); | 161 | device_remove_file(led_cdev->dev, &dev_attr_delay_off); |
163 | class_device_remove_file(led_cdev->class_dev, | ||
164 | &class_device_attr_delay_off); | ||
165 | del_timer_sync(&timer_data->timer); | 162 | del_timer_sync(&timer_data->timer); |
166 | kfree(timer_data); | 163 | kfree(timer_data); |
167 | } | 164 | } |