Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtmutex-tester: 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: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Kay Sievers and committed by
Greg Kroah-Hartman
997d3eaf ca22e56d

+19 -18
+19 -18
kernel/rtmutex-tester.c
··· 6 6 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com> 7 7 * 8 8 */ 9 + #include <linux/device.h> 9 10 #include <linux/kthread.h> 10 11 #include <linux/export.h> 11 12 #include <linux/sched.h> 12 13 #include <linux/spinlock.h> 13 - #include <linux/sysdev.h> 14 14 #include <linux/timer.h> 15 15 #include <linux/freezer.h> 16 16 ··· 27 27 int opdata; 28 28 int mutexes[MAX_RT_TEST_MUTEXES]; 29 29 int event; 30 - struct sys_device sysdev; 30 + struct device dev; 31 31 }; 32 32 33 33 static struct test_thread_data thread_data[MAX_RT_TEST_THREADS]; ··· 271 271 * 272 272 * opcode:data 273 273 */ 274 - static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr, 274 + static ssize_t sysfs_test_command(struct device *dev, struct device_attribute *attr, 275 275 const char *buf, size_t count) 276 276 { 277 277 struct sched_param schedpar; ··· 279 279 char cmdbuf[32]; 280 280 int op, dat, tid, ret; 281 281 282 - td = container_of(dev, struct test_thread_data, sysdev); 283 - tid = td->sysdev.id; 282 + td = container_of(dev, struct test_thread_data, dev); 283 + tid = td->dev.id; 284 284 285 285 /* strings from sysfs write are not 0 terminated! */ 286 286 if (count >= sizeof(cmdbuf)) ··· 334 334 * @dev: thread to query 335 335 * @buf: char buffer to be filled with thread status info 336 336 */ 337 - static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr, 337 + static ssize_t sysfs_test_status(struct device *dev, struct device_attribute *attr, 338 338 char *buf) 339 339 { 340 340 struct test_thread_data *td; ··· 342 342 char *curr = buf; 343 343 int i; 344 344 345 - td = container_of(dev, struct test_thread_data, sysdev); 346 - tsk = threads[td->sysdev.id]; 345 + td = container_of(dev, struct test_thread_data, dev); 346 + tsk = threads[td->dev.id]; 347 347 348 348 spin_lock(&rttest_lock); 349 349 ··· 360 360 spin_unlock(&rttest_lock); 361 361 362 362 curr += sprintf(curr, ", T: %p, R: %p\n", tsk, 363 - mutexes[td->sysdev.id].owner); 363 + mutexes[td->dev.id].owner); 364 364 365 365 return curr - buf; 366 366 } 367 367 368 - static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL); 369 - static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command); 368 + static DEVICE_ATTR(status, 0600, sysfs_test_status, NULL); 369 + static DEVICE_ATTR(command, 0600, NULL, sysfs_test_command); 370 370 371 - static struct sysdev_class rttest_sysclass = { 371 + static struct bus_type rttest_subsys = { 372 372 .name = "rttest", 373 + .dev_name = "rttest", 373 374 }; 374 375 375 376 static int init_test_thread(int id) 376 377 { 377 - thread_data[id].sysdev.cls = &rttest_sysclass; 378 - thread_data[id].sysdev.id = id; 378 + thread_data[id].dev.bus = &rttest_subsys; 379 + thread_data[id].dev.id = id; 379 380 380 381 threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id); 381 382 if (IS_ERR(threads[id])) 382 383 return PTR_ERR(threads[id]); 383 384 384 - return sysdev_register(&thread_data[id].sysdev); 385 + return device_register(&thread_data[id].dev); 385 386 } 386 387 387 388 static int init_rttest(void) ··· 394 393 for (i = 0; i < MAX_RT_TEST_MUTEXES; i++) 395 394 rt_mutex_init(&mutexes[i]); 396 395 397 - ret = sysdev_class_register(&rttest_sysclass); 396 + ret = subsys_system_register(&rttest_subsys, NULL); 398 397 if (ret) 399 398 return ret; 400 399 ··· 402 401 ret = init_test_thread(i); 403 402 if (ret) 404 403 break; 405 - ret = sysdev_create_file(&thread_data[i].sysdev, &attr_status); 404 + ret = device_create_file(&thread_data[i].dev, &dev_attr_status); 406 405 if (ret) 407 406 break; 408 - ret = sysdev_create_file(&thread_data[i].sysdev, &attr_command); 407 + ret = device_create_file(&thread_data[i].dev, &dev_attr_command); 409 408 if (ret) 410 409 break; 411 410 }