Skip to content

Commit 0706802

Browse files
kaysieversgregkh
authored andcommitted
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 <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Signed-off-by: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d369a5d commit 0706802

File tree

3 files changed

+83
-84
lines changed

3 files changed

+83
-84
lines changed

drivers/xen/xen-balloon.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
#include <linux/kernel.h>
3434
#include <linux/module.h>
35-
#include <linux/sysdev.h>
3635
#include <linux/capability.h>
3736

3837
#include <xen/xen.h>
@@ -46,9 +45,9 @@
4645

4746
#define BALLOON_CLASS_NAME "xen_memory"
4847

49-
static struct sys_device balloon_sysdev;
48+
static struct device balloon_dev;
5049

51-
static int register_balloon(struct sys_device *sysdev);
50+
static int register_balloon(struct device *dev);
5251

5352
/* React to a change in the target key */
5453
static void watch_target(struct xenbus_watch *watch,
@@ -98,9 +97,9 @@ static int __init balloon_init(void)
9897

9998
pr_info("xen-balloon: Initialising balloon driver.\n");
10099

101-
register_balloon(&balloon_sysdev);
100+
register_balloon(&balloon_dev);
102101

103-
register_xen_selfballooning(&balloon_sysdev);
102+
register_xen_selfballooning(&balloon_dev);
104103

105104
register_xenstore_notifier(&xenstore_notifier);
106105

@@ -117,31 +116,31 @@ static void balloon_exit(void)
117116
module_exit(balloon_exit);
118117

119118
#define BALLOON_SHOW(name, format, args...) \
120-
static ssize_t show_##name(struct sys_device *dev, \
121-
struct sysdev_attribute *attr, \
119+
static ssize_t show_##name(struct device *dev, \
120+
struct device_attribute *attr, \
122121
char *buf) \
123122
{ \
124123
return sprintf(buf, format, ##args); \
125124
} \
126-
static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL)
125+
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
127126

128127
BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
129128
BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
130129
BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
131130

132-
static SYSDEV_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay);
133-
static SYSDEV_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay);
134-
static SYSDEV_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count);
135-
static SYSDEV_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count);
131+
static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay);
132+
static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay);
133+
static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count);
134+
static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count);
136135

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,
138137
char *buf)
139138
{
140139
return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
141140
}
142141

143-
static ssize_t store_target_kb(struct sys_device *dev,
144-
struct sysdev_attribute *attr,
142+
static ssize_t store_target_kb(struct device *dev,
143+
struct device_attribute *attr,
145144
const char *buf,
146145
size_t count)
147146
{
@@ -158,20 +157,20 @@ static ssize_t store_target_kb(struct sys_device *dev,
158157
return count;
159158
}
160159

161-
static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR,
160+
static DEVICE_ATTR(target_kb, S_IRUGO | S_IWUSR,
162161
show_target_kb, store_target_kb);
163162

164163

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,
166165
char *buf)
167166
{
168167
return sprintf(buf, "%llu\n",
169168
(unsigned long long)balloon_stats.target_pages
170169
<< PAGE_SHIFT);
171170
}
172171

173-
static ssize_t store_target(struct sys_device *dev,
174-
struct sysdev_attribute *attr,
172+
static ssize_t store_target(struct device *dev,
173+
struct device_attribute *attr,
175174
const char *buf,
176175
size_t count)
177176
{
@@ -188,23 +187,23 @@ static ssize_t store_target(struct sys_device *dev,
188187
return count;
189188
}
190189

191-
static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR,
190+
static DEVICE_ATTR(target, S_IRUGO | S_IWUSR,
192191
show_target, store_target);
193192

194193

195-
static struct sysdev_attribute *balloon_attrs[] = {
196-
&attr_target_kb,
197-
&attr_target,
198-
&attr_schedule_delay.attr,
199-
&attr_max_schedule_delay.attr,
200-
&attr_retry_count.attr,
201-
&attr_max_retry_count.attr
194+
static struct device_attribute *balloon_attrs[] = {
195+
&dev_attr_target_kb,
196+
&dev_attr_target,
197+
&dev_attr_schedule_delay.attr,
198+
&dev_attr_max_schedule_delay.attr,
199+
&dev_attr_retry_count.attr,
200+
&dev_attr_max_retry_count.attr
202201
};
203202

204203
static struct attribute *balloon_info_attrs[] = {
205-
&attr_current_kb.attr,
206-
&attr_low_kb.attr,
207-
&attr_high_kb.attr,
204+
&dev_attr_current_kb.attr,
205+
&dev_attr_low_kb.attr,
206+
&dev_attr_high_kb.attr,
208207
NULL
209208
};
210209

@@ -213,44 +212,45 @@ static struct attribute_group balloon_info_group = {
213212
.attrs = balloon_info_attrs
214213
};
215214

216-
static struct sysdev_class balloon_sysdev_class = {
217-
.name = BALLOON_CLASS_NAME
215+
static struct bus_type balloon_subsys = {
216+
.name = BALLOON_CLASS_NAME,
217+
.dev_name = BALLOON_CLASS_NAME,
218218
};
219219

220-
static int register_balloon(struct sys_device *sysdev)
220+
static int register_balloon(struct device *dev)
221221
{
222222
int i, error;
223223

224-
error = sysdev_class_register(&balloon_sysdev_class);
224+
error = bus_register(&balloon_subsys);
225225
if (error)
226226
return error;
227227

228-
sysdev->id = 0;
229-
sysdev->cls = &balloon_sysdev_class;
228+
dev->id = 0;
229+
dev->bus = &balloon_subsys;
230230

231-
error = sysdev_register(sysdev);
231+
error = device_register(dev);
232232
if (error) {
233-
sysdev_class_unregister(&balloon_sysdev_class);
233+
bus_unregister(&balloon_subsys);
234234
return error;
235235
}
236236

237237
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]);
239239
if (error)
240240
goto fail;
241241
}
242242

243-
error = sysfs_create_group(&sysdev->kobj, &balloon_info_group);
243+
error = sysfs_create_group(&dev->kobj, &balloon_info_group);
244244
if (error)
245245
goto fail;
246246

247247
return 0;
248248

249249
fail:
250250
while (--i >= 0)
251-
sysdev_remove_file(sysdev, balloon_attrs[i]);
252-
sysdev_unregister(sysdev);
253-
sysdev_class_unregister(&balloon_sysdev_class);
251+
device_remove_file(dev, balloon_attrs[i]);
252+
device_unregister(dev);
253+
bus_unregister(&balloon_subsys);
254254
return error;
255255
}
256256

drivers/xen/xen-selfballoon.c

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,20 @@ static void selfballoon_process(struct work_struct *work)
266266

267267
#ifdef CONFIG_SYSFS
268268

269-
#include <linux/sysdev.h>
270269
#include <linux/capability.h>
271270

272271
#define SELFBALLOON_SHOW(name, format, args...) \
273-
static ssize_t show_##name(struct sys_device *dev, \
274-
struct sysdev_attribute *attr, \
275-
char *buf) \
272+
static ssize_t show_##name(struct device *dev, \
273+
struct device_attribute *attr, \
274+
char *buf) \
276275
{ \
277276
return sprintf(buf, format, ##args); \
278277
}
279278

280279
SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled);
281280

282-
static ssize_t store_selfballooning(struct sys_device *dev,
283-
struct sysdev_attribute *attr,
281+
static ssize_t store_selfballooning(struct device *dev,
282+
struct device_attribute *attr,
284283
const char *buf,
285284
size_t count)
286285
{
@@ -303,13 +302,13 @@ static ssize_t store_selfballooning(struct sys_device *dev,
303302
return count;
304303
}
305304

306-
static SYSDEV_ATTR(selfballooning, S_IRUGO | S_IWUSR,
305+
static DEVICE_ATTR(selfballooning, S_IRUGO | S_IWUSR,
307306
show_selfballooning, store_selfballooning);
308307

309308
SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval);
310309

311-
static ssize_t store_selfballoon_interval(struct sys_device *dev,
312-
struct sysdev_attribute *attr,
310+
static ssize_t store_selfballoon_interval(struct device *dev,
311+
struct device_attribute *attr,
313312
const char *buf,
314313
size_t count)
315314
{
@@ -325,13 +324,13 @@ static ssize_t store_selfballoon_interval(struct sys_device *dev,
325324
return count;
326325
}
327326

328-
static SYSDEV_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR,
327+
static DEVICE_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR,
329328
show_selfballoon_interval, store_selfballoon_interval);
330329

331330
SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis);
332331

333-
static ssize_t store_selfballoon_downhys(struct sys_device *dev,
334-
struct sysdev_attribute *attr,
332+
static ssize_t store_selfballoon_downhys(struct device *dev,
333+
struct device_attribute *attr,
335334
const char *buf,
336335
size_t count)
337336
{
@@ -347,14 +346,14 @@ static ssize_t store_selfballoon_downhys(struct sys_device *dev,
347346
return count;
348347
}
349348

350-
static SYSDEV_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR,
349+
static DEVICE_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR,
351350
show_selfballoon_downhys, store_selfballoon_downhys);
352351

353352

354353
SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis);
355354

356-
static ssize_t store_selfballoon_uphys(struct sys_device *dev,
357-
struct sysdev_attribute *attr,
355+
static ssize_t store_selfballoon_uphys(struct device *dev,
356+
struct device_attribute *attr,
358357
const char *buf,
359358
size_t count)
360359
{
@@ -370,14 +369,14 @@ static ssize_t store_selfballoon_uphys(struct sys_device *dev,
370369
return count;
371370
}
372371

373-
static SYSDEV_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR,
372+
static DEVICE_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR,
374373
show_selfballoon_uphys, store_selfballoon_uphys);
375374

376375
SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n",
377376
selfballoon_min_usable_mb);
378377

379-
static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev,
380-
struct sysdev_attribute *attr,
378+
static ssize_t store_selfballoon_min_usable_mb(struct device *dev,
379+
struct device_attribute *attr,
381380
const char *buf,
382381
size_t count)
383382
{
@@ -393,16 +392,16 @@ static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev,
393392
return count;
394393
}
395394

396-
static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
395+
static DEVICE_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR,
397396
show_selfballoon_min_usable_mb,
398397
store_selfballoon_min_usable_mb);
399398

400399

401400
#ifdef CONFIG_FRONTSWAP
402401
SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking);
403402

404-
static ssize_t store_frontswap_selfshrinking(struct sys_device *dev,
405-
struct sysdev_attribute *attr,
403+
static ssize_t store_frontswap_selfshrinking(struct device *dev,
404+
struct device_attribute *attr,
406405
const char *buf,
407406
size_t count)
408407
{
@@ -424,13 +423,13 @@ static ssize_t store_frontswap_selfshrinking(struct sys_device *dev,
424423
return count;
425424
}
426425

427-
static SYSDEV_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR,
426+
static DEVICE_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR,
428427
show_frontswap_selfshrinking, store_frontswap_selfshrinking);
429428

430429
SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia);
431430

432-
static ssize_t store_frontswap_inertia(struct sys_device *dev,
433-
struct sysdev_attribute *attr,
431+
static ssize_t store_frontswap_inertia(struct device *dev,
432+
struct device_attribute *attr,
434433
const char *buf,
435434
size_t count)
436435
{
@@ -447,13 +446,13 @@ static ssize_t store_frontswap_inertia(struct sys_device *dev,
447446
return count;
448447
}
449448

450-
static SYSDEV_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR,
449+
static DEVICE_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR,
451450
show_frontswap_inertia, store_frontswap_inertia);
452451

453452
SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis);
454453

455-
static ssize_t store_frontswap_hysteresis(struct sys_device *dev,
456-
struct sysdev_attribute *attr,
454+
static ssize_t store_frontswap_hysteresis(struct device *dev,
455+
struct device_attribute *attr,
457456
const char *buf,
458457
size_t count)
459458
{
@@ -469,21 +468,21 @@ static ssize_t store_frontswap_hysteresis(struct sys_device *dev,
469468
return count;
470469
}
471470

472-
static SYSDEV_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR,
471+
static DEVICE_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR,
473472
show_frontswap_hysteresis, store_frontswap_hysteresis);
474473

475474
#endif /* CONFIG_FRONTSWAP */
476475

477476
static struct attribute *selfballoon_attrs[] = {
478-
&attr_selfballooning.attr,
479-
&attr_selfballoon_interval.attr,
480-
&attr_selfballoon_downhysteresis.attr,
481-
&attr_selfballoon_uphysteresis.attr,
482-
&attr_selfballoon_min_usable_mb.attr,
477+
&dev_attr_selfballooning.attr,
478+
&dev_attr_selfballoon_interval.attr,
479+
&dev_attr_selfballoon_downhysteresis.attr,
480+
&dev_attr_selfballoon_uphysteresis.attr,
481+
&dev_attr_selfballoon_min_usable_mb.attr,
483482
#ifdef CONFIG_FRONTSWAP
484-
&attr_frontswap_selfshrinking.attr,
485-
&attr_frontswap_hysteresis.attr,
486-
&attr_frontswap_inertia.attr,
483+
&dev_attr_frontswap_selfshrinking.attr,
484+
&dev_attr_frontswap_hysteresis.attr,
485+
&dev_attr_frontswap_inertia.attr,
487486
#endif
488487
NULL
489488
};
@@ -494,12 +493,12 @@ static struct attribute_group selfballoon_group = {
494493
};
495494
#endif
496495

497-
int register_xen_selfballooning(struct sys_device *sysdev)
496+
int register_xen_selfballooning(struct device *dev)
498497
{
499498
int error = -1;
500499

501500
#ifdef CONFIG_SYSFS
502-
error = sysfs_create_group(&sysdev->kobj, &selfballoon_group);
501+
error = sysfs_create_group(&dev->kobj, &selfballoon_group);
503502
#endif
504503
return error;
505504
}

0 commit comments

Comments
 (0)