diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-21 16:48:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-21 16:48:37 -0400 |
commit | 61311e1bbc299b3a3a42b8d7f491b428ded964f0 (patch) | |
tree | b86af58eee0d637224f010cf8a431e6d1b47ed48 /drivers | |
parent | 691a55998cc2fc645b51d28edb4f4d36b512826e (diff) | |
parent | 5e4c6564c95ce127beeefe75e15cd11c93487436 (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:
pnp: fix "add acpi:* modalias entries"
UIO: generic irq handling for some uio platform devices
UIO: uio_pdrv: fix license specification
UIO: uio_pdrv: fix memory leak
block: drop references taken by class_find_device()
block: fix partial read() of /proc/{partitions,diskstats}
PM: Remove WARN_ON from device_pm_add
driver core: add init_name to struct device
PM: don't skip device PM init when CONFIG_PM_SLEEP isn't set and CONFIG_PM is set
driver model: anti-oopsing medicine
dev_printk(): constify the `dev' argument
drivers/base/driver.c: remove unused to_dev() macro
Documentation: HOWTO-ja_JP-sync patch
Japanese translation of Documentation/SubmitChecklist
kobject: Replace ALL occurrences of '/' with '!' instead of only the first one.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/class.c | 11 | ||||
-rw-r--r-- | drivers/base/core.c | 31 | ||||
-rw-r--r-- | drivers/base/driver.c | 3 | ||||
-rw-r--r-- | drivers/base/power/main.c | 19 | ||||
-rw-r--r-- | drivers/base/power/power.h | 9 | ||||
-rw-r--r-- | drivers/uio/Kconfig | 13 | ||||
-rw-r--r-- | drivers/uio/Makefile | 1 | ||||
-rw-r--r-- | drivers/uio/uio_pdrv.c | 4 | ||||
-rw-r--r-- | drivers/uio/uio_pdrv_genirq.c | 188 |
9 files changed, 248 insertions, 31 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 5667c2f02c51..cc5e28c8885c 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -295,6 +295,12 @@ int class_for_each_device(struct class *class, struct device *start, | |||
295 | 295 | ||
296 | if (!class) | 296 | if (!class) |
297 | return -EINVAL; | 297 | return -EINVAL; |
298 | if (!class->p) { | ||
299 | WARN(1, "%s called for class '%s' before it was initialized", | ||
300 | __func__, class->name); | ||
301 | return -EINVAL; | ||
302 | } | ||
303 | |||
298 | mutex_lock(&class->p->class_mutex); | 304 | mutex_lock(&class->p->class_mutex); |
299 | list_for_each_entry(dev, &class->p->class_devices, node) { | 305 | list_for_each_entry(dev, &class->p->class_devices, node) { |
300 | if (start) { | 306 | if (start) { |
@@ -344,6 +350,11 @@ struct device *class_find_device(struct class *class, struct device *start, | |||
344 | 350 | ||
345 | if (!class) | 351 | if (!class) |
346 | return NULL; | 352 | return NULL; |
353 | if (!class->p) { | ||
354 | WARN(1, "%s called for class '%s' before it was initialized", | ||
355 | __func__, class->name); | ||
356 | return NULL; | ||
357 | } | ||
347 | 358 | ||
348 | mutex_lock(&class->p->class_mutex); | 359 | mutex_lock(&class->p->class_mutex); |
349 | list_for_each_entry(dev, &class->p->class_devices, node) { | 360 | list_for_each_entry(dev, &class->p->class_devices, node) { |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 068aa1c9538c..d021c98605b3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -53,7 +53,7 @@ static inline int device_is_not_partition(struct device *dev) | |||
53 | * it is attached to. If it is not attached to a bus either, an empty | 53 | * it is attached to. If it is not attached to a bus either, an empty |
54 | * string will be returned. | 54 | * string will be returned. |
55 | */ | 55 | */ |
56 | const char *dev_driver_string(struct device *dev) | 56 | const char *dev_driver_string(const struct device *dev) |
57 | { | 57 | { |
58 | return dev->driver ? dev->driver->name : | 58 | return dev->driver ? dev->driver->name : |
59 | (dev->bus ? dev->bus->name : | 59 | (dev->bus ? dev->bus->name : |
@@ -541,6 +541,7 @@ void device_initialize(struct device *dev) | |||
541 | spin_lock_init(&dev->devres_lock); | 541 | spin_lock_init(&dev->devres_lock); |
542 | INIT_LIST_HEAD(&dev->devres_head); | 542 | INIT_LIST_HEAD(&dev->devres_head); |
543 | device_init_wakeup(dev, 0); | 543 | device_init_wakeup(dev, 0); |
544 | device_pm_init(dev); | ||
544 | set_dev_node(dev, -1); | 545 | set_dev_node(dev, -1); |
545 | } | 546 | } |
546 | 547 | ||
@@ -843,13 +844,19 @@ int device_add(struct device *dev) | |||
843 | { | 844 | { |
844 | struct device *parent = NULL; | 845 | struct device *parent = NULL; |
845 | struct class_interface *class_intf; | 846 | struct class_interface *class_intf; |
846 | int error; | 847 | int error = -EINVAL; |
847 | 848 | ||
848 | dev = get_device(dev); | 849 | dev = get_device(dev); |
849 | if (!dev || !strlen(dev->bus_id)) { | 850 | if (!dev) |
850 | error = -EINVAL; | 851 | goto done; |
851 | goto Done; | 852 | |
852 | } | 853 | /* Temporarily support init_name if it is set. |
854 | * It will override bus_id for now */ | ||
855 | if (dev->init_name) | ||
856 | dev_set_name(dev, "%s", dev->init_name); | ||
857 | |||
858 | if (!strlen(dev->bus_id)) | ||
859 | goto done; | ||
853 | 860 | ||
854 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); | 861 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
855 | 862 | ||
@@ -897,9 +904,10 @@ int device_add(struct device *dev) | |||
897 | error = bus_add_device(dev); | 904 | error = bus_add_device(dev); |
898 | if (error) | 905 | if (error) |
899 | goto BusError; | 906 | goto BusError; |
900 | error = device_pm_add(dev); | 907 | error = dpm_sysfs_add(dev); |
901 | if (error) | 908 | if (error) |
902 | goto PMError; | 909 | goto DPMError; |
910 | device_pm_add(dev); | ||
903 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 911 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
904 | bus_attach_device(dev); | 912 | bus_attach_device(dev); |
905 | if (parent) | 913 | if (parent) |
@@ -917,10 +925,10 @@ int device_add(struct device *dev) | |||
917 | class_intf->add_dev(dev, class_intf); | 925 | class_intf->add_dev(dev, class_intf); |
918 | mutex_unlock(&dev->class->p->class_mutex); | 926 | mutex_unlock(&dev->class->p->class_mutex); |
919 | } | 927 | } |
920 | Done: | 928 | done: |
921 | put_device(dev); | 929 | put_device(dev); |
922 | return error; | 930 | return error; |
923 | PMError: | 931 | DPMError: |
924 | bus_remove_device(dev); | 932 | bus_remove_device(dev); |
925 | BusError: | 933 | BusError: |
926 | if (dev->bus) | 934 | if (dev->bus) |
@@ -944,7 +952,7 @@ int device_add(struct device *dev) | |||
944 | cleanup_device_parent(dev); | 952 | cleanup_device_parent(dev); |
945 | if (parent) | 953 | if (parent) |
946 | put_device(parent); | 954 | put_device(parent); |
947 | goto Done; | 955 | goto done; |
948 | } | 956 | } |
949 | 957 | ||
950 | /** | 958 | /** |
@@ -1007,6 +1015,7 @@ void device_del(struct device *dev) | |||
1007 | struct class_interface *class_intf; | 1015 | struct class_interface *class_intf; |
1008 | 1016 | ||
1009 | device_pm_remove(dev); | 1017 | device_pm_remove(dev); |
1018 | dpm_sysfs_remove(dev); | ||
1010 | if (parent) | 1019 | if (parent) |
1011 | klist_del(&dev->knode_parent); | 1020 | klist_del(&dev->knode_parent); |
1012 | if (MAJOR(dev->devt)) { | 1021 | if (MAJOR(dev->devt)) { |
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 2ef5acf4368b..1e2bda780e48 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c | |||
@@ -16,9 +16,6 @@ | |||
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include "base.h" | 17 | #include "base.h" |
18 | 18 | ||
19 | #define to_dev(node) container_of(node, struct device, driver_list) | ||
20 | |||
21 | |||
22 | static struct device *next_device(struct klist_iter *i) | 19 | static struct device *next_device(struct klist_iter *i) |
23 | { | 20 | { |
24 | struct klist_node *n = klist_next(i); | 21 | struct klist_node *n = klist_next(i); |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 3250c5257b74..273a944d4040 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -67,20 +67,16 @@ void device_pm_unlock(void) | |||
67 | * device_pm_add - add a device to the list of active devices | 67 | * device_pm_add - add a device to the list of active devices |
68 | * @dev: Device to be added to the list | 68 | * @dev: Device to be added to the list |
69 | */ | 69 | */ |
70 | int device_pm_add(struct device *dev) | 70 | void device_pm_add(struct device *dev) |
71 | { | 71 | { |
72 | int error; | ||
73 | |||
74 | pr_debug("PM: Adding info for %s:%s\n", | 72 | pr_debug("PM: Adding info for %s:%s\n", |
75 | dev->bus ? dev->bus->name : "No Bus", | 73 | dev->bus ? dev->bus->name : "No Bus", |
76 | kobject_name(&dev->kobj)); | 74 | kobject_name(&dev->kobj)); |
77 | mutex_lock(&dpm_list_mtx); | 75 | mutex_lock(&dpm_list_mtx); |
78 | if (dev->parent) { | 76 | if (dev->parent) { |
79 | if (dev->parent->power.status >= DPM_SUSPENDING) { | 77 | if (dev->parent->power.status >= DPM_SUSPENDING) |
80 | dev_warn(dev, "parent %s is sleeping, will not add\n", | 78 | dev_warn(dev, "parent %s should not be sleeping\n", |
81 | dev->parent->bus_id); | 79 | dev->parent->bus_id); |
82 | WARN_ON(true); | ||
83 | } | ||
84 | } else if (transition_started) { | 80 | } else if (transition_started) { |
85 | /* | 81 | /* |
86 | * We refuse to register parentless devices while a PM | 82 | * We refuse to register parentless devices while a PM |
@@ -89,13 +85,9 @@ int device_pm_add(struct device *dev) | |||
89 | */ | 85 | */ |
90 | WARN_ON(true); | 86 | WARN_ON(true); |
91 | } | 87 | } |
92 | error = dpm_sysfs_add(dev); | 88 | |
93 | if (!error) { | 89 | list_add_tail(&dev->power.entry, &dpm_list); |
94 | dev->power.status = DPM_ON; | ||
95 | list_add_tail(&dev->power.entry, &dpm_list); | ||
96 | } | ||
97 | mutex_unlock(&dpm_list_mtx); | 90 | mutex_unlock(&dpm_list_mtx); |
98 | return error; | ||
99 | } | 91 | } |
100 | 92 | ||
101 | /** | 93 | /** |
@@ -110,7 +102,6 @@ void device_pm_remove(struct device *dev) | |||
110 | dev->bus ? dev->bus->name : "No Bus", | 102 | dev->bus ? dev->bus->name : "No Bus", |
111 | kobject_name(&dev->kobj)); | 103 | kobject_name(&dev->kobj)); |
112 | mutex_lock(&dpm_list_mtx); | 104 | mutex_lock(&dpm_list_mtx); |
113 | dpm_sysfs_remove(dev); | ||
114 | list_del_init(&dev->power.entry); | 105 | list_del_init(&dev->power.entry); |
115 | mutex_unlock(&dpm_list_mtx); | 106 | mutex_unlock(&dpm_list_mtx); |
116 | } | 107 | } |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index a3252c0e2887..41f51fae042f 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -1,3 +1,8 @@ | |||
1 | static inline void device_pm_init(struct device *dev) | ||
2 | { | ||
3 | dev->power.status = DPM_ON; | ||
4 | } | ||
5 | |||
1 | #ifdef CONFIG_PM_SLEEP | 6 | #ifdef CONFIG_PM_SLEEP |
2 | 7 | ||
3 | /* | 8 | /* |
@@ -11,12 +16,12 @@ static inline struct device *to_device(struct list_head *entry) | |||
11 | return container_of(entry, struct device, power.entry); | 16 | return container_of(entry, struct device, power.entry); |
12 | } | 17 | } |
13 | 18 | ||
14 | extern int device_pm_add(struct device *); | 19 | extern void device_pm_add(struct device *); |
15 | extern void device_pm_remove(struct device *); | 20 | extern void device_pm_remove(struct device *); |
16 | 21 | ||
17 | #else /* CONFIG_PM_SLEEP */ | 22 | #else /* CONFIG_PM_SLEEP */ |
18 | 23 | ||
19 | static inline int device_pm_add(struct device *dev) { return 0; } | 24 | static inline void device_pm_add(struct device *dev) {} |
20 | static inline void device_pm_remove(struct device *dev) {} | 25 | static inline void device_pm_remove(struct device *dev) {} |
21 | 26 | ||
22 | #endif | 27 | #endif |
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 2e9079df26b3..4190be64917f 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig | |||
@@ -33,6 +33,19 @@ config UIO_PDRV | |||
33 | 33 | ||
34 | If you don't know what to do here, say N. | 34 | If you don't know what to do here, say N. |
35 | 35 | ||
36 | config UIO_PDRV_GENIRQ | ||
37 | tristate "Userspace I/O platform driver with generic IRQ handling" | ||
38 | help | ||
39 | Platform driver for Userspace I/O devices, including generic | ||
40 | interrupt handling code. Shared interrupts are not supported. | ||
41 | |||
42 | This kernel driver requires that the matching userspace driver | ||
43 | handles interrupts in a special way. Userspace is responsible | ||
44 | for acknowledging the hardware device if needed, and re-enabling | ||
45 | interrupts in the interrupt controller using the write() syscall. | ||
46 | |||
47 | If you don't know what to do here, say N. | ||
48 | |||
36 | config UIO_SMX | 49 | config UIO_SMX |
37 | tristate "SMX cryptengine UIO interface" | 50 | tristate "SMX cryptengine UIO interface" |
38 | default n | 51 | default n |
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile index e00ce0def1a0..8667bbdef904 100644 --- a/drivers/uio/Makefile +++ b/drivers/uio/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | obj-$(CONFIG_UIO) += uio.o | 1 | obj-$(CONFIG_UIO) += uio.o |
2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o | 2 | obj-$(CONFIG_UIO_CIF) += uio_cif.o |
3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o | 3 | obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o |
4 | obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o | ||
4 | obj-$(CONFIG_UIO_SMX) += uio_smx.o | 5 | obj-$(CONFIG_UIO_SMX) += uio_smx.o |
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c index 5d0d2e85d982..0b4ef39cd85d 100644 --- a/drivers/uio/uio_pdrv.c +++ b/drivers/uio/uio_pdrv.c | |||
@@ -88,6 +88,8 @@ static int uio_pdrv_remove(struct platform_device *pdev) | |||
88 | 88 | ||
89 | uio_unregister_device(pdata->uioinfo); | 89 | uio_unregister_device(pdata->uioinfo); |
90 | 90 | ||
91 | kfree(pdata); | ||
92 | |||
91 | return 0; | 93 | return 0; |
92 | } | 94 | } |
93 | 95 | ||
@@ -114,5 +116,5 @@ module_exit(uio_pdrv_exit); | |||
114 | 116 | ||
115 | MODULE_AUTHOR("Uwe Kleine-Koenig"); | 117 | MODULE_AUTHOR("Uwe Kleine-Koenig"); |
116 | MODULE_DESCRIPTION("Userspace I/O platform driver"); | 118 | MODULE_DESCRIPTION("Userspace I/O platform driver"); |
117 | MODULE_LICENSE("GPL"); | 119 | MODULE_LICENSE("GPL v2"); |
118 | MODULE_ALIAS("platform:" DRIVER_NAME); | 120 | MODULE_ALIAS("platform:" DRIVER_NAME); |
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c new file mode 100644 index 000000000000..1f82c83a92ae --- /dev/null +++ b/drivers/uio/uio_pdrv_genirq.c | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | * drivers/uio/uio_pdrv_genirq.c | ||
3 | * | ||
4 | * Userspace I/O platform driver with generic IRQ handling code. | ||
5 | * | ||
6 | * Copyright (C) 2008 Magnus Damm | ||
7 | * | ||
8 | * Based on uio_pdrv.c by Uwe Kleine-Koenig, | ||
9 | * Copyright (C) 2008 by Digi International Inc. | ||
10 | * All rights reserved. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published by | ||
14 | * the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/uio_driver.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <linux/bitops.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/stringify.h> | ||
23 | |||
24 | #define DRIVER_NAME "uio_pdrv_genirq" | ||
25 | |||
26 | struct uio_pdrv_genirq_platdata { | ||
27 | struct uio_info *uioinfo; | ||
28 | spinlock_t lock; | ||
29 | unsigned long flags; | ||
30 | }; | ||
31 | |||
32 | static irqreturn_t uio_pdrv_genirq_handler(int irq, struct uio_info *dev_info) | ||
33 | { | ||
34 | struct uio_pdrv_genirq_platdata *priv = dev_info->priv; | ||
35 | |||
36 | /* Just disable the interrupt in the interrupt controller, and | ||
37 | * remember the state so we can allow user space to enable it later. | ||
38 | */ | ||
39 | |||
40 | if (!test_and_set_bit(0, &priv->flags)) | ||
41 | disable_irq_nosync(irq); | ||
42 | |||
43 | return IRQ_HANDLED; | ||
44 | } | ||
45 | |||
46 | static int uio_pdrv_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on) | ||
47 | { | ||
48 | struct uio_pdrv_genirq_platdata *priv = dev_info->priv; | ||
49 | unsigned long flags; | ||
50 | |||
51 | /* Allow user space to enable and disable the interrupt | ||
52 | * in the interrupt controller, but keep track of the | ||
53 | * state to prevent per-irq depth damage. | ||
54 | * | ||
55 | * Serialize this operation to support multiple tasks. | ||
56 | */ | ||
57 | |||
58 | spin_lock_irqsave(&priv->lock, flags); | ||
59 | if (irq_on) { | ||
60 | if (test_and_clear_bit(0, &priv->flags)) | ||
61 | enable_irq(dev_info->irq); | ||
62 | } else { | ||
63 | if (!test_and_set_bit(0, &priv->flags)) | ||
64 | disable_irq(dev_info->irq); | ||
65 | } | ||
66 | spin_unlock_irqrestore(&priv->lock, flags); | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static int uio_pdrv_genirq_probe(struct platform_device *pdev) | ||
72 | { | ||
73 | struct uio_info *uioinfo = pdev->dev.platform_data; | ||
74 | struct uio_pdrv_genirq_platdata *priv; | ||
75 | struct uio_mem *uiomem; | ||
76 | int ret = -EINVAL; | ||
77 | int i; | ||
78 | |||
79 | if (!uioinfo || !uioinfo->name || !uioinfo->version) { | ||
80 | dev_err(&pdev->dev, "missing platform_data\n"); | ||
81 | goto bad0; | ||
82 | } | ||
83 | |||
84 | if (uioinfo->handler || uioinfo->irqcontrol || uioinfo->irq_flags) { | ||
85 | dev_err(&pdev->dev, "interrupt configuration error\n"); | ||
86 | goto bad0; | ||
87 | } | ||
88 | |||
89 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
90 | if (!priv) { | ||
91 | ret = -ENOMEM; | ||
92 | dev_err(&pdev->dev, "unable to kmalloc\n"); | ||
93 | goto bad0; | ||
94 | } | ||
95 | |||
96 | priv->uioinfo = uioinfo; | ||
97 | spin_lock_init(&priv->lock); | ||
98 | priv->flags = 0; /* interrupt is enabled to begin with */ | ||
99 | |||
100 | uiomem = &uioinfo->mem[0]; | ||
101 | |||
102 | for (i = 0; i < pdev->num_resources; ++i) { | ||
103 | struct resource *r = &pdev->resource[i]; | ||
104 | |||
105 | if (r->flags != IORESOURCE_MEM) | ||
106 | continue; | ||
107 | |||
108 | if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) { | ||
109 | dev_warn(&pdev->dev, "device has more than " | ||
110 | __stringify(MAX_UIO_MAPS) | ||
111 | " I/O memory resources.\n"); | ||
112 | break; | ||
113 | } | ||
114 | |||
115 | uiomem->memtype = UIO_MEM_PHYS; | ||
116 | uiomem->addr = r->start; | ||
117 | uiomem->size = r->end - r->start + 1; | ||
118 | ++uiomem; | ||
119 | } | ||
120 | |||
121 | while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) { | ||
122 | uiomem->size = 0; | ||
123 | ++uiomem; | ||
124 | } | ||
125 | |||
126 | /* This driver requires no hardware specific kernel code to handle | ||
127 | * interrupts. Instead, the interrupt handler simply disables the | ||
128 | * interrupt in the interrupt controller. User space is responsible | ||
129 | * for performing hardware specific acknowledge and re-enabling of | ||
130 | * the interrupt in the interrupt controller. | ||
131 | * | ||
132 | * Interrupt sharing is not supported. | ||
133 | */ | ||
134 | |||
135 | uioinfo->irq_flags = IRQF_DISABLED; | ||
136 | uioinfo->handler = uio_pdrv_genirq_handler; | ||
137 | uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol; | ||
138 | uioinfo->priv = priv; | ||
139 | |||
140 | ret = uio_register_device(&pdev->dev, priv->uioinfo); | ||
141 | if (ret) { | ||
142 | dev_err(&pdev->dev, "unable to register uio device\n"); | ||
143 | goto bad1; | ||
144 | } | ||
145 | |||
146 | platform_set_drvdata(pdev, priv); | ||
147 | return 0; | ||
148 | bad1: | ||
149 | kfree(priv); | ||
150 | bad0: | ||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | static int uio_pdrv_genirq_remove(struct platform_device *pdev) | ||
155 | { | ||
156 | struct uio_pdrv_genirq_platdata *priv = platform_get_drvdata(pdev); | ||
157 | |||
158 | uio_unregister_device(priv->uioinfo); | ||
159 | kfree(priv); | ||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | static struct platform_driver uio_pdrv_genirq = { | ||
164 | .probe = uio_pdrv_genirq_probe, | ||
165 | .remove = uio_pdrv_genirq_remove, | ||
166 | .driver = { | ||
167 | .name = DRIVER_NAME, | ||
168 | .owner = THIS_MODULE, | ||
169 | }, | ||
170 | }; | ||
171 | |||
172 | static int __init uio_pdrv_genirq_init(void) | ||
173 | { | ||
174 | return platform_driver_register(&uio_pdrv_genirq); | ||
175 | } | ||
176 | |||
177 | static void __exit uio_pdrv_genirq_exit(void) | ||
178 | { | ||
179 | platform_driver_unregister(&uio_pdrv_genirq); | ||
180 | } | ||
181 | |||
182 | module_init(uio_pdrv_genirq_init); | ||
183 | module_exit(uio_pdrv_genirq_exit); | ||
184 | |||
185 | MODULE_AUTHOR("Magnus Damm"); | ||
186 | MODULE_DESCRIPTION("Userspace I/O platform driver with generic IRQ handling"); | ||
187 | MODULE_LICENSE("GPL v2"); | ||
188 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||