diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-12-14 18:32:50 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-12-14 18:32:50 -0500 |
commit | 070680218379e15c1901f4bf21b98e3cbf12b527 (patch) | |
tree | 8bb5afe22614ee94e06d650618949a192181de0f /drivers/xen/xen-balloon.c | |
parent | d369a5d8fc70710236ae2d06a0e42dce483712df (diff) |
xen-balloon: convert sysdev_class to a regular subsystem
After all sysdev classes are ported to regular driver core entities, the
sysdev implementation will be entirely removed from the kernel.
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/xen/xen-balloon.c')
-rw-r--r-- | drivers/xen/xen-balloon.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 9cc2259c9992..3832e303c33a 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c | |||
@@ -32,7 +32,6 @@ | |||
32 | 32 | ||
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/sysdev.h> | ||
36 | #include <linux/capability.h> | 35 | #include <linux/capability.h> |
37 | 36 | ||
38 | #include <xen/xen.h> | 37 | #include <xen/xen.h> |
@@ -46,9 +45,9 @@ | |||
46 | 45 | ||
47 | #define BALLOON_CLASS_NAME "xen_memory" | 46 | #define BALLOON_CLASS_NAME "xen_memory" |
48 | 47 | ||
49 | static struct sys_device balloon_sysdev; | 48 | static struct device balloon_dev; |
50 | 49 | ||
51 | static int register_balloon(struct sys_device *sysdev); | 50 | static int register_balloon(struct device *dev); |
52 | 51 | ||
53 | /* React to a change in the target key */ | 52 | /* React to a change in the target key */ |
54 | static void watch_target(struct xenbus_watch *watch, | 53 | static void watch_target(struct xenbus_watch *watch, |
@@ -98,9 +97,9 @@ static int __init balloon_init(void) | |||
98 | 97 | ||
99 | pr_info("xen-balloon: Initialising balloon driver.\n"); | 98 | pr_info("xen-balloon: Initialising balloon driver.\n"); |
100 | 99 | ||
101 | register_balloon(&balloon_sysdev); | 100 | register_balloon(&balloon_dev); |
102 | 101 | ||
103 | register_xen_selfballooning(&balloon_sysdev); | 102 | register_xen_selfballooning(&balloon_dev); |
104 | 103 | ||
105 | register_xenstore_notifier(&xenstore_notifier); | 104 | register_xenstore_notifier(&xenstore_notifier); |
106 | 105 | ||
@@ -117,31 +116,31 @@ static void balloon_exit(void) | |||
117 | module_exit(balloon_exit); | 116 | module_exit(balloon_exit); |
118 | 117 | ||
119 | #define BALLOON_SHOW(name, format, args...) \ | 118 | #define BALLOON_SHOW(name, format, args...) \ |
120 | static ssize_t show_##name(struct sys_device *dev, \ | 119 | static ssize_t show_##name(struct device *dev, \ |
121 | struct sysdev_attribute *attr, \ | 120 | struct device_attribute *attr, \ |
122 | char *buf) \ | 121 | char *buf) \ |
123 | { \ | 122 | { \ |
124 | return sprintf(buf, format, ##args); \ | 123 | return sprintf(buf, format, ##args); \ |
125 | } \ | 124 | } \ |
126 | static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL) | 125 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) |
127 | 126 | ||
128 | BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); | 127 | BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); |
129 | BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low)); | 128 | BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low)); |
130 | BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high)); | 129 | BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high)); |
131 | 130 | ||
132 | static SYSDEV_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); | 131 | static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); |
133 | static SYSDEV_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); | 132 | static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); |
134 | static SYSDEV_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); | 133 | static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); |
135 | static SYSDEV_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); | 134 | static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); |
136 | 135 | ||
137 | static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr, | 136 | static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, |
138 | char *buf) | 137 | char *buf) |
139 | { | 138 | { |
140 | return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages)); | 139 | return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages)); |
141 | } | 140 | } |
142 | 141 | ||
143 | static ssize_t store_target_kb(struct sys_device *dev, | 142 | static ssize_t store_target_kb(struct device *dev, |
144 | struct sysdev_attribute *attr, | 143 | struct device_attribute *attr, |
145 | const char *buf, | 144 | const char *buf, |
146 | size_t count) | 145 | size_t count) |
147 | { | 146 | { |
@@ -158,11 +157,11 @@ static ssize_t store_target_kb(struct sys_device *dev, | |||
158 | return count; | 157 | return count; |
159 | } | 158 | } |
160 | 159 | ||
161 | static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, | 160 | static DEVICE_ATTR(target_kb, S_IRUGO | S_IWUSR, |
162 | show_target_kb, store_target_kb); | 161 | show_target_kb, store_target_kb); |
163 | 162 | ||
164 | 163 | ||
165 | static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, | 164 | static ssize_t show_target(struct device *dev, struct device_attribute *attr, |
166 | char *buf) | 165 | char *buf) |
167 | { | 166 | { |
168 | return sprintf(buf, "%llu\n", | 167 | return sprintf(buf, "%llu\n", |
@@ -170,8 +169,8 @@ static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr | |||
170 | << PAGE_SHIFT); | 169 | << PAGE_SHIFT); |
171 | } | 170 | } |
172 | 171 | ||
173 | static ssize_t store_target(struct sys_device *dev, | 172 | static ssize_t store_target(struct device *dev, |
174 | struct sysdev_attribute *attr, | 173 | struct device_attribute *attr, |
175 | const char *buf, | 174 | const char *buf, |
176 | size_t count) | 175 | size_t count) |
177 | { | 176 | { |
@@ -188,23 +187,23 @@ static ssize_t store_target(struct sys_device *dev, | |||
188 | return count; | 187 | return count; |
189 | } | 188 | } |
190 | 189 | ||
191 | static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, | 190 | static DEVICE_ATTR(target, S_IRUGO | S_IWUSR, |
192 | show_target, store_target); | 191 | show_target, store_target); |
193 | 192 | ||
194 | 193 | ||
195 | static struct sysdev_attribute *balloon_attrs[] = { | 194 | static struct device_attribute *balloon_attrs[] = { |
196 | &attr_target_kb, | 195 | &dev_attr_target_kb, |
197 | &attr_target, | 196 | &dev_attr_target, |
198 | &attr_schedule_delay.attr, | 197 | &dev_attr_schedule_delay.attr, |
199 | &attr_max_schedule_delay.attr, | 198 | &dev_attr_max_schedule_delay.attr, |
200 | &attr_retry_count.attr, | 199 | &dev_attr_retry_count.attr, |
201 | &attr_max_retry_count.attr | 200 | &dev_attr_max_retry_count.attr |
202 | }; | 201 | }; |
203 | 202 | ||
204 | static struct attribute *balloon_info_attrs[] = { | 203 | static struct attribute *balloon_info_attrs[] = { |
205 | &attr_current_kb.attr, | 204 | &dev_attr_current_kb.attr, |
206 | &attr_low_kb.attr, | 205 | &dev_attr_low_kb.attr, |
207 | &attr_high_kb.attr, | 206 | &dev_attr_high_kb.attr, |
208 | NULL | 207 | NULL |
209 | }; | 208 | }; |
210 | 209 | ||
@@ -213,34 +212,35 @@ static struct attribute_group balloon_info_group = { | |||
213 | .attrs = balloon_info_attrs | 212 | .attrs = balloon_info_attrs |
214 | }; | 213 | }; |
215 | 214 | ||
216 | static struct sysdev_class balloon_sysdev_class = { | 215 | static struct bus_type balloon_subsys = { |
217 | .name = BALLOON_CLASS_NAME | 216 | .name = BALLOON_CLASS_NAME, |
217 | .dev_name = BALLOON_CLASS_NAME, | ||
218 | }; | 218 | }; |
219 | 219 | ||
220 | static int register_balloon(struct sys_device *sysdev) | 220 | static int register_balloon(struct device *dev) |
221 | { | 221 | { |
222 | int i, error; | 222 | int i, error; |
223 | 223 | ||
224 | error = sysdev_class_register(&balloon_sysdev_class); | 224 | error = bus_register(&balloon_subsys); |
225 | if (error) | 225 | if (error) |
226 | return error; | 226 | return error; |
227 | 227 | ||
228 | sysdev->id = 0; | 228 | dev->id = 0; |
229 | sysdev->cls = &balloon_sysdev_class; | 229 | dev->bus = &balloon_subsys; |
230 | 230 | ||
231 | error = sysdev_register(sysdev); | 231 | error = device_register(dev); |
232 | if (error) { | 232 | if (error) { |
233 | sysdev_class_unregister(&balloon_sysdev_class); | 233 | bus_unregister(&balloon_subsys); |
234 | return error; | 234 | return error; |
235 | } | 235 | } |
236 | 236 | ||
237 | for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) { | 237 | for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) { |
238 | error = sysdev_create_file(sysdev, balloon_attrs[i]); | 238 | error = device_create_file(dev, balloon_attrs[i]); |
239 | if (error) | 239 | if (error) |
240 | goto fail; | 240 | goto fail; |
241 | } | 241 | } |
242 | 242 | ||
243 | error = sysfs_create_group(&sysdev->kobj, &balloon_info_group); | 243 | error = sysfs_create_group(&dev->kobj, &balloon_info_group); |
244 | if (error) | 244 | if (error) |
245 | goto fail; | 245 | goto fail; |
246 | 246 | ||
@@ -248,9 +248,9 @@ static int register_balloon(struct sys_device *sysdev) | |||
248 | 248 | ||
249 | fail: | 249 | fail: |
250 | while (--i >= 0) | 250 | while (--i >= 0) |
251 | sysdev_remove_file(sysdev, balloon_attrs[i]); | 251 | device_remove_file(dev, balloon_attrs[i]); |
252 | sysdev_unregister(sysdev); | 252 | device_unregister(dev); |
253 | sysdev_class_unregister(&balloon_sysdev_class); | 253 | bus_unregister(&balloon_subsys); |
254 | return error; | 254 | return error; |
255 | } | 255 | } |
256 | 256 | ||