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

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>

authored by

Kay Sievers and committed by
Greg Kroah-Hartman
dc6876a2 f4e73bfc

+43 -42
+41 -40
arch/sh/drivers/dma/dma-sysfs.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/init.h> 14 14 #include <linux/stat.h> 15 - #include <linux/sysdev.h> 15 + #include <linux/device.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/err.h> 18 18 #include <linux/string.h> 19 19 #include <asm/dma.h> 20 20 21 - static struct sysdev_class dma_sysclass = { 21 + static struct bus_type dma_subsys = { 22 22 .name = "dma", 23 + .dev_name = "dma", 23 24 }; 24 25 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) 27 28 { 28 29 ssize_t len = 0; 29 30 int i; ··· 44 43 return len; 45 44 } 46 45 47 - static SYSDEV_ATTR(devices, S_IRUGO, dma_show_devices, NULL); 46 + static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL); 48 47 49 - static int __init dma_sysclass_init(void) 48 + static int __init dma_subsys_init(void) 50 49 { 51 50 int ret; 52 51 53 - ret = sysdev_class_register(&dma_sysclass); 52 + ret = subsys_system_register(&dma_subsys, NULL); 54 53 if (unlikely(ret)) 55 54 return ret; 56 55 57 - return sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr); 56 + return device_create_file(dma_subsys.dev_root, &dev_attr_devices.attr); 58 57 } 59 - postcore_initcall(dma_sysclass_init); 58 + postcore_initcall(dma_subsys_init); 60 59 61 - static ssize_t dma_show_dev_id(struct sys_device *dev, 62 - struct sysdev_attribute *attr, char *buf) 60 + static ssize_t dma_show_dev_id(struct device *dev, 61 + struct device_attribute *attr, char *buf) 63 62 { 64 63 struct dma_channel *channel = to_dma_channel(dev); 65 64 return sprintf(buf, "%s\n", channel->dev_id); 66 65 } 67 66 68 - static ssize_t dma_store_dev_id(struct sys_device *dev, 69 - struct sysdev_attribute *attr, 67 + static ssize_t dma_store_dev_id(struct device *dev, 68 + struct device_attribute *attr, 70 69 const char *buf, size_t count) 71 70 { 72 71 struct dma_channel *channel = to_dma_channel(dev); ··· 74 73 return count; 75 74 } 76 75 77 - static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id); 76 + static DEVICE_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id); 78 77 79 - static ssize_t dma_store_config(struct sys_device *dev, 80 - struct sysdev_attribute *attr, 78 + static ssize_t dma_store_config(struct device *dev, 79 + struct device_attribute *attr, 81 80 const char *buf, size_t count) 82 81 { 83 82 struct dma_channel *channel = to_dma_channel(dev); ··· 89 88 return count; 90 89 } 91 90 92 - static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config); 91 + static DEVICE_ATTR(config, S_IWUSR, NULL, dma_store_config); 93 92 94 - static ssize_t dma_show_mode(struct sys_device *dev, 95 - struct sysdev_attribute *attr, char *buf) 93 + static ssize_t dma_show_mode(struct device *dev, 94 + struct device_attribute *attr, char *buf) 96 95 { 97 96 struct dma_channel *channel = to_dma_channel(dev); 98 97 return sprintf(buf, "0x%08x\n", channel->mode); 99 98 } 100 99 101 - static ssize_t dma_store_mode(struct sys_device *dev, 102 - struct sysdev_attribute *attr, 100 + static ssize_t dma_store_mode(struct device *dev, 101 + struct device_attribute *attr, 103 102 const char *buf, size_t count) 104 103 { 105 104 struct dma_channel *channel = to_dma_channel(dev); ··· 107 106 return count; 108 107 } 109 108 110 - static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode); 109 + static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode); 111 110 112 111 #define dma_ro_attr(field, fmt) \ 113 - static ssize_t dma_show_##field(struct sys_device *dev, \ 114 - struct sysdev_attribute *attr, char *buf)\ 112 + static ssize_t dma_show_##field(struct device *dev, \ 113 + struct device_attribute *attr, char *buf)\ 115 114 { \ 116 115 struct dma_channel *channel = to_dma_channel(dev); \ 117 116 return sprintf(buf, fmt, channel->field); \ 118 117 } \ 119 - static SYSDEV_ATTR(field, S_IRUGO, dma_show_##field, NULL); 118 + static DEVICE_ATTR(field, S_IRUGO, dma_show_##field, NULL); 120 119 121 120 dma_ro_attr(count, "0x%08x\n"); 122 121 dma_ro_attr(flags, "0x%08lx\n"); 123 122 124 123 int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info) 125 124 { 126 - struct sys_device *dev = &chan->dev; 125 + struct device *dev = &chan->dev; 127 126 char name[16]; 128 127 int ret; 129 128 130 129 dev->id = chan->vchan; 131 - dev->cls = &dma_sysclass; 130 + dev->bus = &dma_subsys; 132 131 133 - ret = sysdev_register(dev); 132 + ret = device_register(dev); 134 133 if (ret) 135 134 return ret; 136 135 137 - ret |= sysdev_create_file(dev, &attr_dev_id); 138 - ret |= sysdev_create_file(dev, &attr_count); 139 - ret |= sysdev_create_file(dev, &attr_mode); 140 - ret |= sysdev_create_file(dev, &attr_flags); 141 - ret |= sysdev_create_file(dev, &attr_config); 136 + ret |= device_create_file(dev, &dev_attr_dev_id); 137 + ret |= device_create_file(dev, &dev_attr_count); 138 + ret |= device_create_file(dev, &dev_attr_mode); 139 + ret |= device_create_file(dev, &dev_attr_flags); 140 + ret |= device_create_file(dev, &dev_attr_config); 142 141 143 142 if (unlikely(ret)) { 144 143 dev_err(&info->pdev->dev, "Failed creating attrs\n"); ··· 151 150 152 151 void dma_remove_sysfs_files(struct dma_channel *chan, struct dma_info *info) 153 152 { 154 - struct sys_device *dev = &chan->dev; 153 + struct device *dev = &chan->dev; 155 154 char name[16]; 156 155 157 - sysdev_remove_file(dev, &attr_dev_id); 158 - sysdev_remove_file(dev, &attr_count); 159 - sysdev_remove_file(dev, &attr_mode); 160 - sysdev_remove_file(dev, &attr_flags); 161 - sysdev_remove_file(dev, &attr_config); 156 + device_remove_file(dev, &dev_attr_dev_id); 157 + device_remove_file(dev, &dev_attr_count); 158 + device_remove_file(dev, &dev_attr_mode); 159 + device_remove_file(dev, &dev_attr_flags); 160 + device_remove_file(dev, &dev_attr_config); 162 161 163 162 snprintf(name, sizeof(name), "dma%d", chan->chan); 164 163 sysfs_remove_link(&info->pdev->dev.kobj, name); 165 164 166 - sysdev_unregister(dev); 165 + device_unregister(dev); 167 166 }
+2 -2
arch/sh/include/asm/dma.h
··· 14 14 #include <linux/spinlock.h> 15 15 #include <linux/wait.h> 16 16 #include <linux/sched.h> 17 - #include <linux/sysdev.h> 17 + #include <linux/device.h> 18 18 #include <cpu/dma.h> 19 19 #include <asm-generic/dma.h> 20 20 ··· 91 91 92 92 wait_queue_head_t wait_queue; 93 93 94 - struct sys_device dev; 94 + struct device dev; 95 95 void *priv_data; 96 96 }; 97 97