Skip to content

Commit dc6876a

Browse files
kaysieversgregkh
authored andcommitted
sh: dma - 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: Paul Mundt <lethal@linux-sh.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent f4e73bf commit dc6876a

2 files changed

Lines changed: 43 additions & 42 deletions

File tree

‎arch/sh/drivers/dma/dma-sysfs.c‎

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@
1212
#include <linux/kernel.h>
1313
#include <linux/init.h>
1414
#include <linux/stat.h>
15-
#include <linux/sysdev.h>
15+
#include <linux/device.h>
1616
#include <linux/platform_device.h>
1717
#include <linux/err.h>
1818
#include <linux/string.h>
1919
#include <asm/dma.h>
2020

21-
static struct sysdev_class dma_sysclass = {
21+
static struct bus_type dma_subsys = {
2222
.name = "dma",
23+
.dev_name = "dma",
2324
};
2425

25-
static ssize_t dma_show_devices(struct sys_device *dev,
26-
struct sysdev_attribute *attr, char *buf)
26+
static ssize_t dma_show_devices(struct device *dev,
27+
struct device_attribute *attr, char *buf)
2728
{
2829
ssize_t len = 0;
2930
int i;
@@ -43,40 +44,40 @@ static ssize_t dma_show_devices(struct sys_device *dev,
4344
return len;
4445
}
4546

46-
static SYSDEV_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
47+
static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
4748

48-
static int __init dma_sysclass_init(void)
49+
static int __init dma_subsys_init(void)
4950
{
5051
int ret;
5152

52-
ret = sysdev_class_register(&dma_sysclass);
53+
ret = subsys_system_register(&dma_subsys, NULL);
5354
if (unlikely(ret))
5455
return ret;
5556

56-
return sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr);
57+
return device_create_file(dma_subsys.dev_root, &dev_attr_devices.attr);
5758
}
58-
postcore_initcall(dma_sysclass_init);
59+
postcore_initcall(dma_subsys_init);
5960

60-
static ssize_t dma_show_dev_id(struct sys_device *dev,
61-
struct sysdev_attribute *attr, char *buf)
61+
static ssize_t dma_show_dev_id(struct device *dev,
62+
struct device_attribute *attr, char *buf)
6263
{
6364
struct dma_channel *channel = to_dma_channel(dev);
6465
return sprintf(buf, "%s\n", channel->dev_id);
6566
}
6667

67-
static ssize_t dma_store_dev_id(struct sys_device *dev,
68-
struct sysdev_attribute *attr,
68+
static ssize_t dma_store_dev_id(struct device *dev,
69+
struct device_attribute *attr,
6970
const char *buf, size_t count)
7071
{
7172
struct dma_channel *channel = to_dma_channel(dev);
7273
strcpy(channel->dev_id, buf);
7374
return count;
7475
}
7576

76-
static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
77+
static DEVICE_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
7778

78-
static ssize_t dma_store_config(struct sys_device *dev,
79-
struct sysdev_attribute *attr,
79+
static ssize_t dma_store_config(struct device *dev,
80+
struct device_attribute *attr,
8081
const char *buf, size_t count)
8182
{
8283
struct dma_channel *channel = to_dma_channel(dev);
@@ -88,56 +89,56 @@ static ssize_t dma_store_config(struct sys_device *dev,
8889
return count;
8990
}
9091

91-
static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
92+
static DEVICE_ATTR(config, S_IWUSR, NULL, dma_store_config);
9293

93-
static ssize_t dma_show_mode(struct sys_device *dev,
94-
struct sysdev_attribute *attr, char *buf)
94+
static ssize_t dma_show_mode(struct device *dev,
95+
struct device_attribute *attr, char *buf)
9596
{
9697
struct dma_channel *channel = to_dma_channel(dev);
9798
return sprintf(buf, "0x%08x\n", channel->mode);
9899
}
99100

100-
static ssize_t dma_store_mode(struct sys_device *dev,
101-
struct sysdev_attribute *attr,
101+
static ssize_t dma_store_mode(struct device *dev,
102+
struct device_attribute *attr,
102103
const char *buf, size_t count)
103104
{
104105
struct dma_channel *channel = to_dma_channel(dev);
105106
channel->mode = simple_strtoul(buf, NULL, 0);
106107
return count;
107108
}
108109

109-
static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
110+
static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
110111

111112
#define dma_ro_attr(field, fmt) \
112-
static ssize_t dma_show_##field(struct sys_device *dev, \
113-
struct sysdev_attribute *attr, char *buf)\
113+
static ssize_t dma_show_##field(struct device *dev, \
114+
struct device_attribute *attr, char *buf)\
114115
{ \
115116
struct dma_channel *channel = to_dma_channel(dev); \
116117
return sprintf(buf, fmt, channel->field); \
117118
} \
118-
static SYSDEV_ATTR(field, S_IRUGO, dma_show_##field, NULL);
119+
static DEVICE_ATTR(field, S_IRUGO, dma_show_##field, NULL);
119120

120121
dma_ro_attr(count, "0x%08x\n");
121122
dma_ro_attr(flags, "0x%08lx\n");
122123

123124
int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
124125
{
125-
struct sys_device *dev = &chan->dev;
126+
struct device *dev = &chan->dev;
126127
char name[16];
127128
int ret;
128129

129130
dev->id = chan->vchan;
130-
dev->cls = &dma_sysclass;
131+
dev->bus = &dma_subsys;
131132

132-
ret = sysdev_register(dev);
133+
ret = device_register(dev);
133134
if (ret)
134135
return ret;
135136

136-
ret |= sysdev_create_file(dev, &attr_dev_id);
137-
ret |= sysdev_create_file(dev, &attr_count);
138-
ret |= sysdev_create_file(dev, &attr_mode);
139-
ret |= sysdev_create_file(dev, &attr_flags);
140-
ret |= sysdev_create_file(dev, &attr_config);
137+
ret |= device_create_file(dev, &dev_attr_dev_id);
138+
ret |= device_create_file(dev, &dev_attr_count);
139+
ret |= device_create_file(dev, &dev_attr_mode);
140+
ret |= device_create_file(dev, &dev_attr_flags);
141+
ret |= device_create_file(dev, &dev_attr_config);
141142

142143
if (unlikely(ret)) {
143144
dev_err(&info->pdev->dev, "Failed creating attrs\n");
@@ -150,17 +151,17 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
150151

151152
void dma_remove_sysfs_files(struct dma_channel *chan, struct dma_info *info)
152153
{
153-
struct sys_device *dev = &chan->dev;
154+
struct device *dev = &chan->dev;
154155
char name[16];
155156

156-
sysdev_remove_file(dev, &attr_dev_id);
157-
sysdev_remove_file(dev, &attr_count);
158-
sysdev_remove_file(dev, &attr_mode);
159-
sysdev_remove_file(dev, &attr_flags);
160-
sysdev_remove_file(dev, &attr_config);
157+
device_remove_file(dev, &dev_attr_dev_id);
158+
device_remove_file(dev, &dev_attr_count);
159+
device_remove_file(dev, &dev_attr_mode);
160+
device_remove_file(dev, &dev_attr_flags);
161+
device_remove_file(dev, &dev_attr_config);
161162

162163
snprintf(name, sizeof(name), "dma%d", chan->chan);
163164
sysfs_remove_link(&info->pdev->dev.kobj, name);
164165

165-
sysdev_unregister(dev);
166+
device_unregister(dev);
166167
}

‎arch/sh/include/asm/dma.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/spinlock.h>
1515
#include <linux/wait.h>
1616
#include <linux/sched.h>
17-
#include <linux/sysdev.h>
17+
#include <linux/device.h>
1818
#include <cpu/dma.h>
1919
#include <asm-generic/dma.h>
2020

@@ -91,7 +91,7 @@ struct dma_channel {
9191

9292
wait_queue_head_t wait_queue;
9393

94-
struct sys_device dev;
94+
struct device dev;
9595
void *priv_data;
9696
};
9797

0 commit comments

Comments
 (0)