aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio/uio_pdrv_genirq.c
diff options
context:
space:
mode:
authorHans J. Koch <hjk@hansjkoch.de>2011-07-07 17:11:38 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-08 18:01:17 -0400
commit27760f868663310ff9e701f47aec33da3b906f34 (patch)
treec1374b8345c407283512ad67450fbae6a7d80f0a /drivers/uio/uio_pdrv_genirq.c
parent1e4de81653bae3f5e6d06e3384853d31d564bbec (diff)
uio: uio_pdrv_genirq: Add OF support
Adding OF binding to genirq. Version string is setup to the "devicetree". Compatible string is not setup for now but you can add your custom compatible string to uio_of_genirq_match structure. For example with "vendor,device" compatible string: static const struct of_device_id __devinitconst uio_of_genirq_match[] = { { .compatible = "vendor,device", }, { /* empty for now */ }, }; Signed-off-by: Michal Simek <monstr@monstr.eu> Signed-off-by: Hans J. Koch <hjk@hansjkoch.de> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de> CC: Hans J. Koch <hjk@hansjkoch.de> CC: Arnd Bergmann <arnd@arndb.de> CC: John Williams <john.williams@petalogix.com> CC: Grant Likely <grant.likely@secretlab.ca> CC: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/uio/uio_pdrv_genirq.c')
-rw-r--r--drivers/uio/uio_pdrv_genirq.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 0f424af7f109..f8f81db32159 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -23,6 +23,10 @@
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25 25
26#include <linux/of.h>
27#include <linux/of_platform.h>
28#include <linux/of_address.h>
29
26#define DRIVER_NAME "uio_pdrv_genirq" 30#define DRIVER_NAME "uio_pdrv_genirq"
27 31
28struct uio_pdrv_genirq_platdata { 32struct uio_pdrv_genirq_platdata {
@@ -97,6 +101,27 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
97 int ret = -EINVAL; 101 int ret = -EINVAL;
98 int i; 102 int i;
99 103
104 if (!uioinfo) {
105 int irq;
106
107 /* alloc uioinfo for one device */
108 uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
109 if (!uioinfo) {
110 ret = -ENOMEM;
111 dev_err(&pdev->dev, "unable to kmalloc\n");
112 goto bad2;
113 }
114 uioinfo->name = pdev->dev.of_node->name;
115 uioinfo->version = "devicetree";
116
117 /* Multiple IRQs are not supported */
118 irq = platform_get_irq(pdev, 0);
119 if (irq == -ENXIO)
120 uioinfo->irq = UIO_IRQ_NONE;
121 else
122 uioinfo->irq = irq;
123 }
124
100 if (!uioinfo || !uioinfo->name || !uioinfo->version) { 125 if (!uioinfo || !uioinfo->name || !uioinfo->version) {
101 dev_err(&pdev->dev, "missing platform_data\n"); 126 dev_err(&pdev->dev, "missing platform_data\n");
102 goto bad0; 127 goto bad0;
@@ -180,6 +205,10 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
180 kfree(priv); 205 kfree(priv);
181 pm_runtime_disable(&pdev->dev); 206 pm_runtime_disable(&pdev->dev);
182 bad0: 207 bad0:
208 /* kfree uioinfo for OF */
209 if (pdev->dev.of_node)
210 kfree(uioinfo);
211 bad2:
183 return ret; 212 return ret;
184} 213}
185 214
@@ -193,6 +222,10 @@ static int uio_pdrv_genirq_remove(struct platform_device *pdev)
193 priv->uioinfo->handler = NULL; 222 priv->uioinfo->handler = NULL;
194 priv->uioinfo->irqcontrol = NULL; 223 priv->uioinfo->irqcontrol = NULL;
195 224
225 /* kfree uioinfo for OF */
226 if (pdev->dev.of_node)
227 kfree(priv->uioinfo);
228
196 kfree(priv); 229 kfree(priv);
197 return 0; 230 return 0;
198} 231}
@@ -219,6 +252,15 @@ static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {
219 .runtime_resume = uio_pdrv_genirq_runtime_nop, 252 .runtime_resume = uio_pdrv_genirq_runtime_nop,
220}; 253};
221 254
255#ifdef CONFIG_OF
256static const struct of_device_id __devinitconst uio_of_genirq_match[] = {
257 { /* empty for now */ },
258};
259MODULE_DEVICE_TABLE(of, uio_of_genirq_match);
260#else
261# define uio_of_genirq_match NULL
262#endif
263
222static struct platform_driver uio_pdrv_genirq = { 264static struct platform_driver uio_pdrv_genirq = {
223 .probe = uio_pdrv_genirq_probe, 265 .probe = uio_pdrv_genirq_probe,
224 .remove = uio_pdrv_genirq_remove, 266 .remove = uio_pdrv_genirq_remove,
@@ -226,6 +268,7 @@ static struct platform_driver uio_pdrv_genirq = {
226 .name = DRIVER_NAME, 268 .name = DRIVER_NAME,
227 .owner = THIS_MODULE, 269 .owner = THIS_MODULE,
228 .pm = &uio_pdrv_genirq_dev_pm_ops, 270 .pm = &uio_pdrv_genirq_dev_pm_ops,
271 .of_match_table = uio_of_genirq_match,
229 }, 272 },
230}; 273};
231 274