mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-07 03:50:59 +00:00
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>
This commit is contained in:
parent
ca22e56deb
commit
997d3eaf02
@ -6,11 +6,11 @@
|
|||||||
* Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
|
* Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include <linux/device.h>
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/sysdev.h>
|
|
||||||
#include <linux/timer.h>
|
#include <linux/timer.h>
|
||||||
#include <linux/freezer.h>
|
#include <linux/freezer.h>
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ struct test_thread_data {
|
|||||||
int opdata;
|
int opdata;
|
||||||
int mutexes[MAX_RT_TEST_MUTEXES];
|
int mutexes[MAX_RT_TEST_MUTEXES];
|
||||||
int event;
|
int event;
|
||||||
struct sys_device sysdev;
|
struct device dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct test_thread_data thread_data[MAX_RT_TEST_THREADS];
|
static struct test_thread_data thread_data[MAX_RT_TEST_THREADS];
|
||||||
@ -271,7 +271,7 @@ static int test_func(void *data)
|
|||||||
*
|
*
|
||||||
* opcode:data
|
* opcode:data
|
||||||
*/
|
*/
|
||||||
static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr,
|
static ssize_t sysfs_test_command(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct sched_param schedpar;
|
struct sched_param schedpar;
|
||||||
@ -279,8 +279,8 @@ static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribut
|
|||||||
char cmdbuf[32];
|
char cmdbuf[32];
|
||||||
int op, dat, tid, ret;
|
int op, dat, tid, ret;
|
||||||
|
|
||||||
td = container_of(dev, struct test_thread_data, sysdev);
|
td = container_of(dev, struct test_thread_data, dev);
|
||||||
tid = td->sysdev.id;
|
tid = td->dev.id;
|
||||||
|
|
||||||
/* strings from sysfs write are not 0 terminated! */
|
/* strings from sysfs write are not 0 terminated! */
|
||||||
if (count >= sizeof(cmdbuf))
|
if (count >= sizeof(cmdbuf))
|
||||||
@ -334,7 +334,7 @@ static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribut
|
|||||||
* @dev: thread to query
|
* @dev: thread to query
|
||||||
* @buf: char buffer to be filled with thread status info
|
* @buf: char buffer to be filled with thread status info
|
||||||
*/
|
*/
|
||||||
static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr,
|
static ssize_t sysfs_test_status(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct test_thread_data *td;
|
struct test_thread_data *td;
|
||||||
@ -342,8 +342,8 @@ static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute
|
|||||||
char *curr = buf;
|
char *curr = buf;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
td = container_of(dev, struct test_thread_data, sysdev);
|
td = container_of(dev, struct test_thread_data, dev);
|
||||||
tsk = threads[td->sysdev.id];
|
tsk = threads[td->dev.id];
|
||||||
|
|
||||||
spin_lock(&rttest_lock);
|
spin_lock(&rttest_lock);
|
||||||
|
|
||||||
@ -360,28 +360,29 @@ static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute
|
|||||||
spin_unlock(&rttest_lock);
|
spin_unlock(&rttest_lock);
|
||||||
|
|
||||||
curr += sprintf(curr, ", T: %p, R: %p\n", tsk,
|
curr += sprintf(curr, ", T: %p, R: %p\n", tsk,
|
||||||
mutexes[td->sysdev.id].owner);
|
mutexes[td->dev.id].owner);
|
||||||
|
|
||||||
return curr - buf;
|
return curr - buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL);
|
static DEVICE_ATTR(status, 0600, sysfs_test_status, NULL);
|
||||||
static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command);
|
static DEVICE_ATTR(command, 0600, NULL, sysfs_test_command);
|
||||||
|
|
||||||
static struct sysdev_class rttest_sysclass = {
|
static struct bus_type rttest_subsys = {
|
||||||
.name = "rttest",
|
.name = "rttest",
|
||||||
|
.dev_name = "rttest",
|
||||||
};
|
};
|
||||||
|
|
||||||
static int init_test_thread(int id)
|
static int init_test_thread(int id)
|
||||||
{
|
{
|
||||||
thread_data[id].sysdev.cls = &rttest_sysclass;
|
thread_data[id].dev.bus = &rttest_subsys;
|
||||||
thread_data[id].sysdev.id = id;
|
thread_data[id].dev.id = id;
|
||||||
|
|
||||||
threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id);
|
threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id);
|
||||||
if (IS_ERR(threads[id]))
|
if (IS_ERR(threads[id]))
|
||||||
return PTR_ERR(threads[id]);
|
return PTR_ERR(threads[id]);
|
||||||
|
|
||||||
return sysdev_register(&thread_data[id].sysdev);
|
return device_register(&thread_data[id].dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_rttest(void)
|
static int init_rttest(void)
|
||||||
@ -393,7 +394,7 @@ static int init_rttest(void)
|
|||||||
for (i = 0; i < MAX_RT_TEST_MUTEXES; i++)
|
for (i = 0; i < MAX_RT_TEST_MUTEXES; i++)
|
||||||
rt_mutex_init(&mutexes[i]);
|
rt_mutex_init(&mutexes[i]);
|
||||||
|
|
||||||
ret = sysdev_class_register(&rttest_sysclass);
|
ret = subsys_system_register(&rttest_subsys, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -401,10 +402,10 @@ static int init_rttest(void)
|
|||||||
ret = init_test_thread(i);
|
ret = init_test_thread(i);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
ret = sysdev_create_file(&thread_data[i].sysdev, &attr_status);
|
ret = device_create_file(&thread_data[i].dev, &dev_attr_status);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
ret = sysdev_create_file(&thread_data[i].sysdev, &attr_command);
|
ret = device_create_file(&thread_data[i].dev, &dev_attr_command);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user