aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 20:02:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 20:02:07 -0500
commit40d7ee5d162203b40b5f4fbb312ab016edddb97f (patch)
tree432db33df85f7f244676127a189a828dfbf2877b /drivers/uio
parent5fec8bdbf9a1c4df4ad3f20e52aa2d8caed490c8 (diff)
parentb8ac9fc0e8cda9f9776019c5b0464b0c6d2d4c90 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (60 commits) uio: make uio_info's name and version const UIO: Documentation for UIO ioport info handling UIO: Pass information about ioports to userspace (V2) UIO: uio_pdrv_genirq: allow custom irq_flags UIO: use pci_ioremap_bar() in drivers/uio arm: struct device - replace bus_id with dev_name(), dev_set_name() libata: struct device - replace bus_id with dev_name(), dev_set_name() avr: struct device - replace bus_id with dev_name(), dev_set_name() block: struct device - replace bus_id with dev_name(), dev_set_name() chris: struct device - replace bus_id with dev_name(), dev_set_name() dmi: struct device - replace bus_id with dev_name(), dev_set_name() gadget: struct device - replace bus_id with dev_name(), dev_set_name() gpio: struct device - replace bus_id with dev_name(), dev_set_name() gpu: struct device - replace bus_id with dev_name(), dev_set_name() hwmon: struct device - replace bus_id with dev_name(), dev_set_name() i2o: struct device - replace bus_id with dev_name(), dev_set_name() IA64: struct device - replace bus_id with dev_name(), dev_set_name() i7300_idle: struct device - replace bus_id with dev_name(), dev_set_name() infiniband: struct device - replace bus_id with dev_name(), dev_set_name() ISDN: struct device - replace bus_id with dev_name(), dev_set_name() ...
Diffstat (limited to 'drivers/uio')
-rw-r--r--drivers/uio/uio.c159
-rw-r--r--drivers/uio/uio_cif.c3
-rw-r--r--drivers/uio/uio_pdrv_genirq.c5
3 files changed, 146 insertions, 21 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 2d2440cd57a9..4ca85a113aa2 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -35,6 +35,7 @@ struct uio_device {
35 int vma_count; 35 int vma_count;
36 struct uio_info *info; 36 struct uio_info *info;
37 struct kobject *map_dir; 37 struct kobject *map_dir;
38 struct kobject *portio_dir;
38}; 39};
39 40
40static int uio_major; 41static int uio_major;
@@ -75,17 +76,17 @@ static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
75 return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK); 76 return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK);
76} 77}
77 78
78struct uio_sysfs_entry { 79struct map_sysfs_entry {
79 struct attribute attr; 80 struct attribute attr;
80 ssize_t (*show)(struct uio_mem *, char *); 81 ssize_t (*show)(struct uio_mem *, char *);
81 ssize_t (*store)(struct uio_mem *, const char *, size_t); 82 ssize_t (*store)(struct uio_mem *, const char *, size_t);
82}; 83};
83 84
84static struct uio_sysfs_entry addr_attribute = 85static struct map_sysfs_entry addr_attribute =
85 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 86 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
86static struct uio_sysfs_entry size_attribute = 87static struct map_sysfs_entry size_attribute =
87 __ATTR(size, S_IRUGO, map_size_show, NULL); 88 __ATTR(size, S_IRUGO, map_size_show, NULL);
88static struct uio_sysfs_entry offset_attribute = 89static struct map_sysfs_entry offset_attribute =
89 __ATTR(offset, S_IRUGO, map_offset_show, NULL); 90 __ATTR(offset, S_IRUGO, map_offset_show, NULL);
90 91
91static struct attribute *attrs[] = { 92static struct attribute *attrs[] = {
@@ -106,9 +107,9 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
106{ 107{
107 struct uio_map *map = to_map(kobj); 108 struct uio_map *map = to_map(kobj);
108 struct uio_mem *mem = map->mem; 109 struct uio_mem *mem = map->mem;
109 struct uio_sysfs_entry *entry; 110 struct map_sysfs_entry *entry;
110 111
111 entry = container_of(attr, struct uio_sysfs_entry, attr); 112 entry = container_of(attr, struct map_sysfs_entry, attr);
112 113
113 if (!entry->show) 114 if (!entry->show)
114 return -EIO; 115 return -EIO;
@@ -116,16 +117,93 @@ static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
116 return entry->show(mem, buf); 117 return entry->show(mem, buf);
117} 118}
118 119
119static struct sysfs_ops uio_sysfs_ops = { 120static struct sysfs_ops map_sysfs_ops = {
120 .show = map_type_show, 121 .show = map_type_show,
121}; 122};
122 123
123static struct kobj_type map_attr_type = { 124static struct kobj_type map_attr_type = {
124 .release = map_release, 125 .release = map_release,
125 .sysfs_ops = &uio_sysfs_ops, 126 .sysfs_ops = &map_sysfs_ops,
126 .default_attrs = attrs, 127 .default_attrs = attrs,
127}; 128};
128 129
130struct uio_portio {
131 struct kobject kobj;
132 struct uio_port *port;
133};
134#define to_portio(portio) container_of(portio, struct uio_portio, kobj)
135
136static ssize_t portio_start_show(struct uio_port *port, char *buf)
137{
138 return sprintf(buf, "0x%lx\n", port->start);
139}
140
141static ssize_t portio_size_show(struct uio_port *port, char *buf)
142{
143 return sprintf(buf, "0x%lx\n", port->size);
144}
145
146static ssize_t portio_porttype_show(struct uio_port *port, char *buf)
147{
148 const char *porttypes[] = {"none", "x86", "gpio", "other"};
149
150 if ((port->porttype < 0) || (port->porttype > UIO_PORT_OTHER))
151 return -EINVAL;
152
153 return sprintf(buf, "port_%s\n", porttypes[port->porttype]);
154}
155
156struct portio_sysfs_entry {
157 struct attribute attr;
158 ssize_t (*show)(struct uio_port *, char *);
159 ssize_t (*store)(struct uio_port *, const char *, size_t);
160};
161
162static struct portio_sysfs_entry portio_start_attribute =
163 __ATTR(start, S_IRUGO, portio_start_show, NULL);
164static struct portio_sysfs_entry portio_size_attribute =
165 __ATTR(size, S_IRUGO, portio_size_show, NULL);
166static struct portio_sysfs_entry portio_porttype_attribute =
167 __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL);
168
169static struct attribute *portio_attrs[] = {
170 &portio_start_attribute.attr,
171 &portio_size_attribute.attr,
172 &portio_porttype_attribute.attr,
173 NULL,
174};
175
176static void portio_release(struct kobject *kobj)
177{
178 struct uio_portio *portio = to_portio(kobj);
179 kfree(portio);
180}
181
182static ssize_t portio_type_show(struct kobject *kobj, struct attribute *attr,
183 char *buf)
184{
185 struct uio_portio *portio = to_portio(kobj);
186 struct uio_port *port = portio->port;
187 struct portio_sysfs_entry *entry;
188
189 entry = container_of(attr, struct portio_sysfs_entry, attr);
190
191 if (!entry->show)
192 return -EIO;
193
194 return entry->show(port, buf);
195}
196
197static struct sysfs_ops portio_sysfs_ops = {
198 .show = portio_type_show,
199};
200
201static struct kobj_type portio_attr_type = {
202 .release = portio_release,
203 .sysfs_ops = &portio_sysfs_ops,
204 .default_attrs = portio_attrs,
205};
206
129static ssize_t show_name(struct device *dev, 207static ssize_t show_name(struct device *dev,
130 struct device_attribute *attr, char *buf) 208 struct device_attribute *attr, char *buf)
131{ 209{
@@ -177,10 +255,13 @@ static struct attribute_group uio_attr_grp = {
177static int uio_dev_add_attributes(struct uio_device *idev) 255static int uio_dev_add_attributes(struct uio_device *idev)
178{ 256{
179 int ret; 257 int ret;
180 int mi; 258 int mi, pi;
181 int map_found = 0; 259 int map_found = 0;
260 int portio_found = 0;
182 struct uio_mem *mem; 261 struct uio_mem *mem;
183 struct uio_map *map; 262 struct uio_map *map;
263 struct uio_port *port;
264 struct uio_portio *portio;
184 265
185 ret = sysfs_create_group(&idev->dev->kobj, &uio_attr_grp); 266 ret = sysfs_create_group(&idev->dev->kobj, &uio_attr_grp);
186 if (ret) 267 if (ret)
@@ -195,25 +276,58 @@ static int uio_dev_add_attributes(struct uio_device *idev)
195 idev->map_dir = kobject_create_and_add("maps", 276 idev->map_dir = kobject_create_and_add("maps",
196 &idev->dev->kobj); 277 &idev->dev->kobj);
197 if (!idev->map_dir) 278 if (!idev->map_dir)
198 goto err; 279 goto err_map;
199 } 280 }
200 map = kzalloc(sizeof(*map), GFP_KERNEL); 281 map = kzalloc(sizeof(*map), GFP_KERNEL);
201 if (!map) 282 if (!map)
202 goto err; 283 goto err_map;
203 kobject_init(&map->kobj, &map_attr_type); 284 kobject_init(&map->kobj, &map_attr_type);
204 map->mem = mem; 285 map->mem = mem;
205 mem->map = map; 286 mem->map = map;
206 ret = kobject_add(&map->kobj, idev->map_dir, "map%d", mi); 287 ret = kobject_add(&map->kobj, idev->map_dir, "map%d", mi);
207 if (ret) 288 if (ret)
208 goto err; 289 goto err_map;
209 ret = kobject_uevent(&map->kobj, KOBJ_ADD); 290 ret = kobject_uevent(&map->kobj, KOBJ_ADD);
210 if (ret) 291 if (ret)
211 goto err; 292 goto err_map;
293 }
294
295 for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
296 port = &idev->info->port[pi];
297 if (port->size == 0)
298 break;
299 if (!portio_found) {
300 portio_found = 1;
301 idev->portio_dir = kobject_create_and_add("portio",
302 &idev->dev->kobj);
303 if (!idev->portio_dir)
304 goto err_portio;
305 }
306 portio = kzalloc(sizeof(*portio), GFP_KERNEL);
307 if (!portio)
308 goto err_portio;
309 kobject_init(&portio->kobj, &portio_attr_type);
310 portio->port = port;
311 port->portio = portio;
312 ret = kobject_add(&portio->kobj, idev->portio_dir,
313 "port%d", pi);
314 if (ret)
315 goto err_portio;
316 ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
317 if (ret)
318 goto err_portio;
212 } 319 }
213 320
214 return 0; 321 return 0;
215 322
216err: 323err_portio:
324 for (pi--; pi >= 0; pi--) {
325 port = &idev->info->port[pi];
326 portio = port->portio;
327 kobject_put(&portio->kobj);
328 }
329 kobject_put(idev->portio_dir);
330err_map:
217 for (mi--; mi>=0; mi--) { 331 for (mi--; mi>=0; mi--) {
218 mem = &idev->info->mem[mi]; 332 mem = &idev->info->mem[mi];
219 map = mem->map; 333 map = mem->map;
@@ -228,15 +342,26 @@ err_group:
228 342
229static void uio_dev_del_attributes(struct uio_device *idev) 343static void uio_dev_del_attributes(struct uio_device *idev)
230{ 344{
231 int mi; 345 int i;
232 struct uio_mem *mem; 346 struct uio_mem *mem;
233 for (mi = 0; mi < MAX_UIO_MAPS; mi++) { 347 struct uio_port *port;
234 mem = &idev->info->mem[mi]; 348
349 for (i = 0; i < MAX_UIO_MAPS; i++) {
350 mem = &idev->info->mem[i];
235 if (mem->size == 0) 351 if (mem->size == 0)
236 break; 352 break;
237 kobject_put(&mem->map->kobj); 353 kobject_put(&mem->map->kobj);
238 } 354 }
239 kobject_put(idev->map_dir); 355 kobject_put(idev->map_dir);
356
357 for (i = 0; i < MAX_UIO_PORT_REGIONS; i++) {
358 port = &idev->info->port[i];
359 if (port->size == 0)
360 break;
361 kobject_put(&port->portio->kobj);
362 }
363 kobject_put(idev->portio_dir);
364
240 sysfs_remove_group(&idev->dev->kobj, &uio_attr_grp); 365 sysfs_remove_group(&idev->dev->kobj, &uio_attr_grp);
241} 366}
242 367
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c
index 57376060b978..c60b8fcf0e3e 100644
--- a/drivers/uio/uio_cif.c
+++ b/drivers/uio/uio_cif.c
@@ -57,8 +57,7 @@ static int __devinit hilscher_pci_probe(struct pci_dev *dev,
57 info->mem[0].addr = pci_resource_start(dev, 0); 57 info->mem[0].addr = pci_resource_start(dev, 0);
58 if (!info->mem[0].addr) 58 if (!info->mem[0].addr)
59 goto out_release; 59 goto out_release;
60 info->mem[0].internal_addr = ioremap(pci_resource_start(dev, 0), 60 info->mem[0].internal_addr = pci_ioremap_bar(dev, 0);
61 pci_resource_len(dev, 0));
62 if (!info->mem[0].internal_addr) 61 if (!info->mem[0].internal_addr)
63 goto out_release; 62 goto out_release;
64 63
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 1f82c83a92ae..3f06818cf9fa 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -81,7 +81,8 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
81 goto bad0; 81 goto bad0;
82 } 82 }
83 83
84 if (uioinfo->handler || uioinfo->irqcontrol || uioinfo->irq_flags) { 84 if (uioinfo->handler || uioinfo->irqcontrol ||
85 uioinfo->irq_flags & IRQF_SHARED) {
85 dev_err(&pdev->dev, "interrupt configuration error\n"); 86 dev_err(&pdev->dev, "interrupt configuration error\n");
86 goto bad0; 87 goto bad0;
87 } 88 }
@@ -132,7 +133,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
132 * Interrupt sharing is not supported. 133 * Interrupt sharing is not supported.
133 */ 134 */
134 135
135 uioinfo->irq_flags = IRQF_DISABLED; 136 uioinfo->irq_flags |= IRQF_DISABLED;
136 uioinfo->handler = uio_pdrv_genirq_handler; 137 uioinfo->handler = uio_pdrv_genirq_handler;
137 uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol; 138 uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol;
138 uioinfo->priv = priv; 139 uioinfo->priv = priv;