diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/drivers/dma/dma-sysfs.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/sh/drivers/dma/dma-sysfs.c')
-rw-r--r-- | arch/sh/drivers/dma/dma-sysfs.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c new file mode 100644 index 000000000000..71a6d4e7809f --- /dev/null +++ b/arch/sh/drivers/dma/dma-sysfs.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * arch/sh/drivers/dma/dma-sysfs.c | ||
3 | * | ||
4 | * sysfs interface for SH DMA API | ||
5 | * | ||
6 | * Copyright (C) 2004 Paul Mundt | ||
7 | * | ||
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. | ||
11 | */ | ||
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> | ||
17 | |||
18 | static struct sysdev_class dma_sysclass = { | ||
19 | set_kset_name("dma"), | ||
20 | }; | ||
21 | |||
22 | EXPORT_SYMBOL(dma_sysclass); | ||
23 | |||
24 | static ssize_t dma_show_devices(struct sys_device *dev, char *buf) | ||
25 | { | ||
26 | ssize_t len = 0; | ||
27 | int i; | ||
28 | |||
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]; | ||
32 | |||
33 | len += sprintf(buf + len, "%2d: %14s %s\n", | ||
34 | channel->chan, info->name, | ||
35 | channel->dev_id); | ||
36 | } | ||
37 | |||
38 | return len; | ||
39 | } | ||
40 | |||
41 | static SYSDEV_ATTR(devices, S_IRUGO, dma_show_devices, NULL); | ||
42 | |||
43 | static int __init dma_sysclass_init(void) | ||
44 | { | ||
45 | int ret; | ||
46 | |||
47 | ret = sysdev_class_register(&dma_sysclass); | ||
48 | if (ret == 0) | ||
49 | sysfs_create_file(&dma_sysclass.kset.kobj, &attr_devices.attr); | ||
50 | |||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | postcore_initcall(dma_sysclass_init); | ||
55 | |||
56 | static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf) | ||
57 | { | ||
58 | struct dma_channel *channel = to_dma_channel(dev); | ||
59 | return sprintf(buf, "%s\n", channel->dev_id); | ||
60 | } | ||
61 | |||
62 | static ssize_t dma_store_dev_id(struct sys_device *dev, | ||
63 | const char *buf, size_t count) | ||
64 | { | ||
65 | struct dma_channel *channel = to_dma_channel(dev); | ||
66 | strcpy(channel->dev_id, buf); | ||
67 | return count; | ||
68 | } | ||
69 | |||
70 | static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id); | ||
71 | |||
72 | static ssize_t dma_store_config(struct sys_device *dev, | ||
73 | const char *buf, size_t count) | ||
74 | { | ||
75 | struct dma_channel *channel = to_dma_channel(dev); | ||
76 | unsigned long config; | ||
77 | |||
78 | config = simple_strtoul(buf, NULL, 0); | ||
79 | dma_configure_channel(channel->chan, config); | ||
80 | |||
81 | return count; | ||
82 | } | ||
83 | |||
84 | static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config); | ||
85 | |||
86 | static ssize_t dma_show_mode(struct sys_device *dev, char *buf) | ||
87 | { | ||
88 | struct dma_channel *channel = to_dma_channel(dev); | ||
89 | return sprintf(buf, "0x%08x\n", channel->mode); | ||
90 | } | ||
91 | |||
92 | static ssize_t dma_store_mode(struct sys_device *dev, | ||
93 | const char *buf, size_t count) | ||
94 | { | ||
95 | struct dma_channel *channel = to_dma_channel(dev); | ||
96 | channel->mode = simple_strtoul(buf, NULL, 0); | ||
97 | return count; | ||
98 | } | ||
99 | |||
100 | static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode); | ||
101 | |||
102 | #define dma_ro_attr(field, fmt) \ | ||
103 | static ssize_t dma_show_##field(struct sys_device *dev, char *buf) \ | ||
104 | { \ | ||
105 | struct dma_channel *channel = to_dma_channel(dev); \ | ||
106 | return sprintf(buf, fmt, channel->field); \ | ||
107 | } \ | ||
108 | static SYSDEV_ATTR(field, S_IRUGO, dma_show_##field, NULL); | ||
109 | |||
110 | dma_ro_attr(count, "0x%08x\n"); | ||
111 | dma_ro_attr(flags, "0x%08lx\n"); | ||
112 | |||
113 | int __init dma_create_sysfs_files(struct dma_channel *chan) | ||
114 | { | ||
115 | struct sys_device *dev = &chan->dev; | ||
116 | int ret; | ||
117 | |||
118 | dev->id = chan->chan; | ||
119 | dev->cls = &dma_sysclass; | ||
120 | |||
121 | ret = sysdev_register(dev); | ||
122 | if (ret) | ||
123 | return ret; | ||
124 | |||
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); | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | |||