aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-12-14 18:32:50 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-14 18:32:50 -0500
commit070680218379e15c1901f4bf21b98e3cbf12b527 (patch)
tree8bb5afe22614ee94e06d650618949a192181de0f
parentd369a5d8fc70710236ae2d06a0e42dce483712df (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>
-rw-r--r--drivers/xen/xen-balloon.c86
-rw-r--r--drivers/xen/xen-selfballoon.c75
-rw-r--r--include/xen/balloon.h6
3 files changed, 83 insertions, 84 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
49static struct sys_device balloon_sysdev; 48static struct device balloon_dev;
50 49
51static int register_balloon(struct sys_device *sysdev); 50static 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 */
54static void watch_target(struct xenbus_watch *watch, 53static 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)
117module_exit(balloon_exit); 116module_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
128BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); 127BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
129BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low)); 128BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
130BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high)); 129BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
131 130
132static SYSDEV_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); 131static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay);
133static SYSDEV_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); 132static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay);
134static SYSDEV_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); 133static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count);
135static SYSDEV_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); 134static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count);
136 135
137static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr, 136static 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
143static ssize_t store_target_kb(struct sys_device *dev, 142static 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
161static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, 160static 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
165static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, 164static 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
173static ssize_t store_target(struct sys_device *dev, 172static 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
191static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, 190static DEVICE_ATTR(target, S_IRUGO | S_IWUSR,
192 show_target, store_target); 191 show_target, store_target);
193 192
194 193
195static struct sysdev_attribute *balloon_attrs[] = { 194static 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
204static struct attribute *balloon_info_attrs[] = { 203static 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
216static struct sysdev_class balloon_sysdev_class = { 215static 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
220static int register_balloon(struct sys_device *sysdev) 220static 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
diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index d93c70857e03..b7b9e95f8717 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -266,21 +266,20 @@ static void selfballoon_process(struct work_struct *work)
266 266
267#ifdef CONFIG_SYSFS 267#ifdef CONFIG_SYSFS
268 268
269#include <linux/sysdev.h>
270#include <linux/capability.h> 269#include <linux/capability.h>
271 270
272#define SELFBALLOON_SHOW(name, format, args...) \ 271#define SELFBALLOON_SHOW(name, format, args...) \
273 static ssize_t show_##name(struct sys_device *dev, \ 272 static ssize_t show_##name(struct device *dev, \
274 struct sysdev_attribute *attr, \ 273 struct device_attribute *attr, \
275 char *buf) \ 274 char *buf) \
276 { \ 275 { \
277 return sprintf(buf, format, ##args); \ 276 return sprintf(buf, format, ##args); \
278 } 277 }
279 278
280SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled); 279SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled);
281 280
282static ssize_t store_selfballooning(struct sys_device *dev, 281static ssize_t store_selfballooning(struct device *dev,
283 struct sysdev_attribute *attr, 282 struct device_attribute *attr,
284 const char *buf, 283 const char *buf,
285 size_t count) 284 size_t count)
286{ 285{
@@ -303,13 +302,13 @@ static ssize_t store_selfballooning(struct sys_device *dev,
303 return count; 302 return count;
304} 303}
305 304
306static SYSDEV_ATTR(selfballooning, S_IRUGO | S_IWUSR, 305static DEVICE_ATTR(selfballooning, S_IRUGO | S_IWUSR,
307 show_selfballooning, store_selfballooning); 306 show_selfballooning, store_selfballooning);
308 307
309SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval); 308SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval);
310 309
311static ssize_t store_selfballoon_interval(struct sys_device *dev, 310static ssize_t store_selfballoon_interval(struct device *dev,
312 struct sysdev_attribute *attr, 311 struct device_attribute *attr,
313 const char *buf, 312 const char *buf,
314 size_t count) 313 size_t count)
315{ 314{
@@ -325,13 +324,13 @@ static ssize_t store_selfballoon_interval(struct sys_device *dev,
325 return count; 324 return count;
326} 325}
327 326
328static SYSDEV_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR, 327static DEVICE_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR,
329 show_selfballoon_interval, store_selfballoon_interval); 328 show_selfballoon_interval, store_selfballoon_interval);
330 329
331SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis); 330SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis);
332 331
333static ssize_t store_selfballoon_downhys(struct sys_device *dev, 332static ssize_t store_selfballoon_downhys(struct device *dev,
334 struct sysdev_attribute *attr, 333 struct device_attribute *attr,
335 const char *buf, 334 const char *buf,
336 size_t count) 335 size_t count)
337{ 336{
@@ -347,14 +346,14 @@ static ssize_t store_selfballoon_downhys(struct sys_device *dev,
347 return count; 346 return count;
348} 347}
349 348
350static SYSDEV_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR, 349static DEVICE_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR,
351 show_selfballoon_downhys, store_selfballoon_downhys); 350 show_selfballoon_downhys, store_selfballoon_downhys);
352 351
353 352
354SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis); 353SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis);
355 354
356static ssize_t store_selfballoon_uphys(struct sys_device *dev, 355static ssize_t store_selfballoon_uphys(struct device *dev,
357 struct sysdev_attribute *attr, 356 struct device_attribute *attr,
358 const char *buf, 357 const char *buf,
359 size_t count) 358 size_t count)
360{ 359{
@@ -370,14 +369,14 @@ static ssize_t store_selfballoon_uphys(struct sys_device *dev,
370 return count; 369 return count;
371} 370}
372 371
373static SYSDEV_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR, 372static DEVICE_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR,
374 show_selfballoon_uphys, store_selfballoon_uphys); 373 show_selfballoon_uphys, store_selfballoon_uphys);
375 374
376SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n", 375SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n",
377 selfballoon_min_usable_mb); 376 selfballoon_min_usable_mb);
378 377
379static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev, 378static ssize_t store_selfballoon_min_usable_mb(struct device *dev,
380 struct sysdev_attribute *attr, 379 struct device_attribute *attr,
381 const char *buf, 380 const char *buf,
382 size_t count) 381 size_t count)
383{ 382{
@@ -393,7 +392,7 @@ static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev,
393 return count; 392 return count;
394} 393}
395 394
396static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, 395static DEVICE_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
397 show_selfballoon_min_usable_mb, 396 show_selfballoon_min_usable_mb,
398 store_selfballoon_min_usable_mb); 397 store_selfballoon_min_usable_mb);
399 398
@@ -401,8 +400,8 @@ static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
401#ifdef CONFIG_FRONTSWAP 400#ifdef CONFIG_FRONTSWAP
402SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking); 401SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking);
403 402
404static ssize_t store_frontswap_selfshrinking(struct sys_device *dev, 403static ssize_t store_frontswap_selfshrinking(struct device *dev,
405 struct sysdev_attribute *attr, 404 struct device_attribute *attr,
406 const char *buf, 405 const char *buf,
407 size_t count) 406 size_t count)
408{ 407{
@@ -424,13 +423,13 @@ static ssize_t store_frontswap_selfshrinking(struct sys_device *dev,
424 return count; 423 return count;
425} 424}
426 425
427static SYSDEV_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR, 426static DEVICE_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR,
428 show_frontswap_selfshrinking, store_frontswap_selfshrinking); 427 show_frontswap_selfshrinking, store_frontswap_selfshrinking);
429 428
430SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia); 429SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia);
431 430
432static ssize_t store_frontswap_inertia(struct sys_device *dev, 431static ssize_t store_frontswap_inertia(struct device *dev,
433 struct sysdev_attribute *attr, 432 struct device_attribute *attr,
434 const char *buf, 433 const char *buf,
435 size_t count) 434 size_t count)
436{ 435{
@@ -447,13 +446,13 @@ static ssize_t store_frontswap_inertia(struct sys_device *dev,
447 return count; 446 return count;
448} 447}
449 448
450static SYSDEV_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR, 449static DEVICE_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR,
451 show_frontswap_inertia, store_frontswap_inertia); 450 show_frontswap_inertia, store_frontswap_inertia);
452 451
453SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis); 452SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis);
454 453
455static ssize_t store_frontswap_hysteresis(struct sys_device *dev, 454static ssize_t store_frontswap_hysteresis(struct device *dev,
456 struct sysdev_attribute *attr, 455 struct device_attribute *attr,
457 const char *buf, 456 const char *buf,
458 size_t count) 457 size_t count)
459{ 458{
@@ -469,21 +468,21 @@ static ssize_t store_frontswap_hysteresis(struct sys_device *dev,
469 return count; 468 return count;
470} 469}
471 470
472static SYSDEV_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR, 471static DEVICE_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR,
473 show_frontswap_hysteresis, store_frontswap_hysteresis); 472 show_frontswap_hysteresis, store_frontswap_hysteresis);
474 473
475#endif /* CONFIG_FRONTSWAP */ 474#endif /* CONFIG_FRONTSWAP */
476 475
477static struct attribute *selfballoon_attrs[] = { 476static struct attribute *selfballoon_attrs[] = {
478 &attr_selfballooning.attr, 477 &dev_attr_selfballooning.attr,
479 &attr_selfballoon_interval.attr, 478 &dev_attr_selfballoon_interval.attr,
480 &attr_selfballoon_downhysteresis.attr, 479 &dev_attr_selfballoon_downhysteresis.attr,
481 &attr_selfballoon_uphysteresis.attr, 480 &dev_attr_selfballoon_uphysteresis.attr,
482 &attr_selfballoon_min_usable_mb.attr, 481 &dev_attr_selfballoon_min_usable_mb.attr,
483#ifdef CONFIG_FRONTSWAP 482#ifdef CONFIG_FRONTSWAP
484 &attr_frontswap_selfshrinking.attr, 483 &dev_attr_frontswap_selfshrinking.attr,
485 &attr_frontswap_hysteresis.attr, 484 &dev_attr_frontswap_hysteresis.attr,
486 &attr_frontswap_inertia.attr, 485 &dev_attr_frontswap_inertia.attr,
487#endif 486#endif
488 NULL 487 NULL
489}; 488};
@@ -494,12 +493,12 @@ static struct attribute_group selfballoon_group = {
494}; 493};
495#endif 494#endif
496 495
497int register_xen_selfballooning(struct sys_device *sysdev) 496int register_xen_selfballooning(struct device *dev)
498{ 497{
499 int error = -1; 498 int error = -1;
500 499
501#ifdef CONFIG_SYSFS 500#ifdef CONFIG_SYSFS
502 error = sysfs_create_group(&sysdev->kobj, &selfballoon_group); 501 error = sysfs_create_group(&dev->kobj, &selfballoon_group);
503#endif 502#endif
504 return error; 503 return error;
505} 504}
diff --git a/include/xen/balloon.h b/include/xen/balloon.h
index d29c153705bc..cc2e1a7e44ec 100644
--- a/include/xen/balloon.h
+++ b/include/xen/balloon.h
@@ -29,11 +29,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages,
29 bool highmem); 29 bool highmem);
30void free_xenballooned_pages(int nr_pages, struct page **pages); 30void free_xenballooned_pages(int nr_pages, struct page **pages);
31 31
32struct sys_device; 32struct device;
33#ifdef CONFIG_XEN_SELFBALLOONING 33#ifdef CONFIG_XEN_SELFBALLOONING
34extern int register_xen_selfballooning(struct sys_device *sysdev); 34extern int register_xen_selfballooning(struct device *dev);
35#else 35#else
36static inline int register_xen_selfballooning(struct sys_device *sysdev) 36static inline int register_xen_selfballooning(struct device *dev)
37{ 37{
38 return -ENOSYS; 38 return -ENOSYS;
39} 39}