kbuild: fix silentoldconfig with make O=
[linux-2.6/verdex.git] / arch / sh / drivers / dma / dma-sysfs.c
blob71a6d4e7809fbe91699fc04a85cf4c8a380b1fa8
1 /*
2 * arch/sh/drivers/dma/dma-sysfs.c
4 * sysfs interface for SH DMA API
6 * Copyright (C) 2004 Paul Mundt
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/sysdev.h>
15 #include <linux/module.h>
16 #include <asm/dma.h>
18 static struct sysdev_class dma_sysclass = {
19 set_kset_name("dma"),
22 EXPORT_SYMBOL(dma_sysclass);
24 static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
26 ssize_t len = 0;
27 int i;
29 for (i = 0; i < MAX_DMA_CHANNELS; i++) {
30 struct dma_info *info = get_dma_info(i);
31 struct dma_channel *channel = &info->channels[i];
33 len += sprintf(buf + len, "%2d: %14s %s\n",
34 channel->chan, info->name,
35 channel->dev_id);
38 return len;
41 static SYSDEV_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
43 static int __init dma_sysclass_init(void)
45 int ret;
47 ret = sysdev_class_register(&dma_sysclass);
48 if (ret == 0)
49 sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr);
51 return ret;
54 postcore_initcall(dma_sysclass_init);
56 static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf)
58 struct dma_channel *channel = to_dma_channel(dev);
59 return sprintf(buf, "%s\n", channel->dev_id);
62 static ssize_t dma_store_dev_id(struct sys_device *dev,
63 const char *buf, size_t count)
65 struct dma_channel *channel = to_dma_channel(dev);
66 strcpy(channel->dev_id, buf);
67 return count;
70 static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
72 static ssize_t dma_store_config(struct sys_device *dev,
73 const char *buf, size_t count)
75 struct dma_channel *channel = to_dma_channel(dev);
76 unsigned long config;
78 config = simple_strtoul(buf, NULL, 0);
79 dma_configure_channel(channel->chan, config);
81 return count;
84 static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
86 static ssize_t dma_show_mode(struct sys_device *dev, char *buf)
88 struct dma_channel *channel = to_dma_channel(dev);
89 return sprintf(buf, "0x%08x\n", channel->mode);
92 static ssize_t dma_store_mode(struct sys_device *dev,
93 const char *buf, size_t count)
95 struct dma_channel *channel = to_dma_channel(dev);
96 channel->mode = simple_strtoul(buf, NULL, 0);
97 return count;
100 static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
102 #define dma_ro_attr(field, fmt) \
103 static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \
105 struct dma_channel *channel = to_dma_channel(dev); \
106 return sprintf(buf, fmt, channel->field); \
108 static SYSDEV_ATTR(field, S_IRUGO, dma_show_##field, NULL);
110 dma_ro_attr(count, "0x%08x\n");
111 dma_ro_attr(flags, "0x%08lx\n");
113 int __init dma_create_sysfs_files(struct dma_channel *chan)
115 struct sys_device *dev = &chan->dev;
116 int ret;
118 dev->id = chan->chan;
119 dev->cls = &dma_sysclass;
121 ret = sysdev_register(dev);
122 if (ret)
123 return ret;
125 sysdev_create_file(dev, &attr_dev_id);
126 sysdev_create_file(dev, &attr_count);
127 sysdev_create_file(dev, &attr_mode);
128 sysdev_create_file(dev, &attr_flags);
129 sysdev_create_file(dev, &attr_config);
131 return 0;