Commit 07068021 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

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: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d369a5d8
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/sysdev.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <xen/xen.h> #include <xen/xen.h>
...@@ -46,9 +45,9 @@ ...@@ -46,9 +45,9 @@
#define BALLOON_CLASS_NAME "xen_memory" #define BALLOON_CLASS_NAME "xen_memory"
static struct sys_device balloon_sysdev; static struct device balloon_dev;
static int register_balloon(struct sys_device *sysdev); static int register_balloon(struct device *dev);
/* React to a change in the target key */ /* React to a change in the target key */
static void watch_target(struct xenbus_watch *watch, static void watch_target(struct xenbus_watch *watch,
...@@ -98,9 +97,9 @@ static int __init balloon_init(void) ...@@ -98,9 +97,9 @@ static int __init balloon_init(void)
pr_info("xen-balloon: Initialising balloon driver.\n"); pr_info("xen-balloon: Initialising balloon driver.\n");
register_balloon(&balloon_sysdev); register_balloon(&balloon_dev);
register_xen_selfballooning(&balloon_sysdev); register_xen_selfballooning(&balloon_dev);
register_xenstore_notifier(&xenstore_notifier); register_xenstore_notifier(&xenstore_notifier);
...@@ -117,31 +116,31 @@ static void balloon_exit(void) ...@@ -117,31 +116,31 @@ static void balloon_exit(void)
module_exit(balloon_exit); module_exit(balloon_exit);
#define BALLOON_SHOW(name, format, args...) \ #define BALLOON_SHOW(name, format, args...) \
static ssize_t show_##name(struct sys_device *dev, \ static ssize_t show_##name(struct device *dev, \
struct sysdev_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
return sprintf(buf, format, ##args); \ return sprintf(buf, format, ##args); \
} \ } \
static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL) static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low)); BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high)); BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
static SYSDEV_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay);
static SYSDEV_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay);
static SYSDEV_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count);
static SYSDEV_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count);
static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr, static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages)); return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
} }
static ssize_t store_target_kb(struct sys_device *dev, static ssize_t store_target_kb(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -158,11 +157,11 @@ static ssize_t store_target_kb(struct sys_device *dev, ...@@ -158,11 +157,11 @@ static ssize_t store_target_kb(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, static DEVICE_ATTR(target_kb, S_IRUGO | S_IWUSR,
show_target_kb, store_target_kb); show_target_kb, store_target_kb);
static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, static ssize_t show_target(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return sprintf(buf, "%llu\n", return sprintf(buf, "%llu\n",
...@@ -170,8 +169,8 @@ static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr ...@@ -170,8 +169,8 @@ static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr
<< PAGE_SHIFT); << PAGE_SHIFT);
} }
static ssize_t store_target(struct sys_device *dev, static ssize_t store_target(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -188,23 +187,23 @@ static ssize_t store_target(struct sys_device *dev, ...@@ -188,23 +187,23 @@ static ssize_t store_target(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, static DEVICE_ATTR(target, S_IRUGO | S_IWUSR,
show_target, store_target); show_target, store_target);
static struct sysdev_attribute *balloon_attrs[] = { static struct device_attribute *balloon_attrs[] = {
&attr_target_kb, &dev_attr_target_kb,
&attr_target, &dev_attr_target,
&attr_schedule_delay.attr, &dev_attr_schedule_delay.attr,
&attr_max_schedule_delay.attr, &dev_attr_max_schedule_delay.attr,
&attr_retry_count.attr, &dev_attr_retry_count.attr,
&attr_max_retry_count.attr &dev_attr_max_retry_count.attr
}; };
static struct attribute *balloon_info_attrs[] = { static struct attribute *balloon_info_attrs[] = {
&attr_current_kb.attr, &dev_attr_current_kb.attr,
&attr_low_kb.attr, &dev_attr_low_kb.attr,
&attr_high_kb.attr, &dev_attr_high_kb.attr,
NULL NULL
}; };
...@@ -213,34 +212,35 @@ static struct attribute_group balloon_info_group = { ...@@ -213,34 +212,35 @@ static struct attribute_group balloon_info_group = {
.attrs = balloon_info_attrs .attrs = balloon_info_attrs
}; };
static struct sysdev_class balloon_sysdev_class = { static struct bus_type balloon_subsys = {
.name = BALLOON_CLASS_NAME .name = BALLOON_CLASS_NAME,
.dev_name = BALLOON_CLASS_NAME,
}; };
static int register_balloon(struct sys_device *sysdev) static int register_balloon(struct device *dev)
{ {
int i, error; int i, error;
error = sysdev_class_register(&balloon_sysdev_class); error = bus_register(&balloon_subsys);
if (error) if (error)
return error; return error;
sysdev->id = 0; dev->id = 0;
sysdev->cls = &balloon_sysdev_class; dev->bus = &balloon_subsys;
error = sysdev_register(sysdev); error = device_register(dev);
if (error) { if (error) {
sysdev_class_unregister(&balloon_sysdev_class); bus_unregister(&balloon_subsys);
return error; return error;
} }
for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) { for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) {
error = sysdev_create_file(sysdev, balloon_attrs[i]); error = device_create_file(dev, balloon_attrs[i]);
if (error) if (error)
goto fail; goto fail;
} }
error = sysfs_create_group(&sysdev->kobj, &balloon_info_group); error = sysfs_create_group(&dev->kobj, &balloon_info_group);
if (error) if (error)
goto fail; goto fail;
...@@ -248,9 +248,9 @@ static int register_balloon(struct sys_device *sysdev) ...@@ -248,9 +248,9 @@ static int register_balloon(struct sys_device *sysdev)
fail: fail:
while (--i >= 0) while (--i >= 0)
sysdev_remove_file(sysdev, balloon_attrs[i]); device_remove_file(dev, balloon_attrs[i]);
sysdev_unregister(sysdev); device_unregister(dev);
sysdev_class_unregister(&balloon_sysdev_class); bus_unregister(&balloon_subsys);
return error; return error;
} }
......
...@@ -266,21 +266,20 @@ static void selfballoon_process(struct work_struct *work) ...@@ -266,21 +266,20 @@ static void selfballoon_process(struct work_struct *work)
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
#include <linux/sysdev.h>
#include <linux/capability.h> #include <linux/capability.h>
#define SELFBALLOON_SHOW(name, format, args...) \ #define SELFBALLOON_SHOW(name, format, args...) \
static ssize_t show_##name(struct sys_device *dev, \ static ssize_t show_##name(struct device *dev, \
struct sysdev_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
return sprintf(buf, format, ##args); \ return sprintf(buf, format, ##args); \
} }
SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled); SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled);
static ssize_t store_selfballooning(struct sys_device *dev, static ssize_t store_selfballooning(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -303,13 +302,13 @@ static ssize_t store_selfballooning(struct sys_device *dev, ...@@ -303,13 +302,13 @@ static ssize_t store_selfballooning(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(selfballooning, S_IRUGO | S_IWUSR, static DEVICE_ATTR(selfballooning, S_IRUGO | S_IWUSR,
show_selfballooning, store_selfballooning); show_selfballooning, store_selfballooning);
SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval); SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval);
static ssize_t store_selfballoon_interval(struct sys_device *dev, static ssize_t store_selfballoon_interval(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -325,13 +324,13 @@ static ssize_t store_selfballoon_interval(struct sys_device *dev, ...@@ -325,13 +324,13 @@ static ssize_t store_selfballoon_interval(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR, static DEVICE_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR,
show_selfballoon_interval, store_selfballoon_interval); show_selfballoon_interval, store_selfballoon_interval);
SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis); SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis);
static ssize_t store_selfballoon_downhys(struct sys_device *dev, static ssize_t store_selfballoon_downhys(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -347,14 +346,14 @@ static ssize_t store_selfballoon_downhys(struct sys_device *dev, ...@@ -347,14 +346,14 @@ static ssize_t store_selfballoon_downhys(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR, static DEVICE_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR,
show_selfballoon_downhys, store_selfballoon_downhys); show_selfballoon_downhys, store_selfballoon_downhys);
SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis); SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis);
static ssize_t store_selfballoon_uphys(struct sys_device *dev, static ssize_t store_selfballoon_uphys(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -370,14 +369,14 @@ static ssize_t store_selfballoon_uphys(struct sys_device *dev, ...@@ -370,14 +369,14 @@ static ssize_t store_selfballoon_uphys(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR, static DEVICE_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR,
show_selfballoon_uphys, store_selfballoon_uphys); show_selfballoon_uphys, store_selfballoon_uphys);
SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n", SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n",
selfballoon_min_usable_mb); selfballoon_min_usable_mb);
static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev, static ssize_t store_selfballoon_min_usable_mb(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -393,7 +392,7 @@ static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev, ...@@ -393,7 +392,7 @@ static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, static DEVICE_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
show_selfballoon_min_usable_mb, show_selfballoon_min_usable_mb,
store_selfballoon_min_usable_mb); store_selfballoon_min_usable_mb);
...@@ -401,8 +400,8 @@ static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, ...@@ -401,8 +400,8 @@ static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
#ifdef CONFIG_FRONTSWAP #ifdef CONFIG_FRONTSWAP
SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking); SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking);
static ssize_t store_frontswap_selfshrinking(struct sys_device *dev, static ssize_t store_frontswap_selfshrinking(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -424,13 +423,13 @@ static ssize_t store_frontswap_selfshrinking(struct sys_device *dev, ...@@ -424,13 +423,13 @@ static ssize_t store_frontswap_selfshrinking(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR, static DEVICE_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR,
show_frontswap_selfshrinking, store_frontswap_selfshrinking); show_frontswap_selfshrinking, store_frontswap_selfshrinking);
SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia); SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia);
static ssize_t store_frontswap_inertia(struct sys_device *dev, static ssize_t store_frontswap_inertia(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -447,13 +446,13 @@ static ssize_t store_frontswap_inertia(struct sys_device *dev, ...@@ -447,13 +446,13 @@ static ssize_t store_frontswap_inertia(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR, static DEVICE_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR,
show_frontswap_inertia, store_frontswap_inertia); show_frontswap_inertia, store_frontswap_inertia);
SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis); SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis);
static ssize_t store_frontswap_hysteresis(struct sys_device *dev, static ssize_t store_frontswap_hysteresis(struct device *dev,
struct sysdev_attribute *attr, struct device_attribute *attr,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
...@@ -469,21 +468,21 @@ static ssize_t store_frontswap_hysteresis(struct sys_device *dev, ...@@ -469,21 +468,21 @@ static ssize_t store_frontswap_hysteresis(struct sys_device *dev,
return count; return count;
} }
static SYSDEV_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR, static DEVICE_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR,
show_frontswap_hysteresis, store_frontswap_hysteresis); show_frontswap_hysteresis, store_frontswap_hysteresis);
#endif /* CONFIG_FRONTSWAP */ #endif /* CONFIG_FRONTSWAP */
static struct attribute *selfballoon_attrs[] = { static struct attribute *selfballoon_attrs[] = {
&attr_selfballooning.attr, &dev_attr_selfballooning.attr,
&attr_selfballoon_interval.attr, &dev_attr_selfballoon_interval.attr,
&attr_selfballoon_downhysteresis.attr, &dev_attr_selfballoon_downhysteresis.attr,
&attr_selfballoon_uphysteresis.attr, &dev_attr_selfballoon_uphysteresis.attr,
&attr_selfballoon_min_usable_mb.attr, &dev_attr_selfballoon_min_usable_mb.attr,
#ifdef CONFIG_FRONTSWAP #ifdef CONFIG_FRONTSWAP
&attr_frontswap_selfshrinking.attr, &dev_attr_frontswap_selfshrinking.attr,
&attr_frontswap_hysteresis.attr, &dev_attr_frontswap_hysteresis.attr,
&attr_frontswap_inertia.attr, &dev_attr_frontswap_inertia.attr,
#endif #endif
NULL NULL
}; };
...@@ -494,12 +493,12 @@ static struct attribute_group selfballoon_group = { ...@@ -494,12 +493,12 @@ static struct attribute_group selfballoon_group = {
}; };
#endif #endif
int register_xen_selfballooning(struct sys_device *sysdev) int register_xen_selfballooning(struct device *dev)
{ {
int error = -1; int error = -1;
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
error = sysfs_create_group(&sysdev->kobj, &selfballoon_group); error = sysfs_create_group(&dev->kobj, &selfballoon_group);
#endif #endif
return error; return error;
} }
......
...@@ -29,11 +29,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages, ...@@ -29,11 +29,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages,
bool highmem); bool highmem);
void free_xenballooned_pages(int nr_pages, struct page **pages); void free_xenballooned_pages(int nr_pages, struct page **pages);
struct sys_device; struct device;
#ifdef CONFIG_XEN_SELFBALLOONING #ifdef CONFIG_XEN_SELFBALLOONING
extern int register_xen_selfballooning(struct sys_device *sysdev); extern int register_xen_selfballooning(struct device *dev);
#else #else
static inline int register_xen_selfballooning(struct sys_device *sysdev) static inline int register_xen_selfballooning(struct device *dev)
{ {
return -ENOSYS; return -ENOSYS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment