Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hans J. Koch and committed by
Greg Kroah-Hartman
27760f86 1e4de816

+43
+43
drivers/uio/uio_pdrv_genirq.c
··· 23 23 #include <linux/pm_runtime.h> 24 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 30 #define DRIVER_NAME "uio_pdrv_genirq" 27 31 28 32 struct uio_pdrv_genirq_platdata { ··· 100 96 struct uio_mem *uiomem; 101 97 int ret = -EINVAL; 102 98 int i; 99 + 100 + if (!uioinfo) { 101 + int irq; 102 + 103 + /* alloc uioinfo for one device */ 104 + uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL); 105 + if (!uioinfo) { 106 + ret = -ENOMEM; 107 + dev_err(&pdev->dev, "unable to kmalloc\n"); 108 + goto bad2; 109 + } 110 + uioinfo->name = pdev->dev.of_node->name; 111 + uioinfo->version = "devicetree"; 112 + 113 + /* Multiple IRQs are not supported */ 114 + irq = platform_get_irq(pdev, 0); 115 + if (irq == -ENXIO) 116 + uioinfo->irq = UIO_IRQ_NONE; 117 + else 118 + uioinfo->irq = irq; 119 + } 103 120 104 121 if (!uioinfo || !uioinfo->name || !uioinfo->version) { 105 122 dev_err(&pdev->dev, "missing platform_data\n"); ··· 205 180 kfree(priv); 206 181 pm_runtime_disable(&pdev->dev); 207 182 bad0: 183 + /* kfree uioinfo for OF */ 184 + if (pdev->dev.of_node) 185 + kfree(uioinfo); 186 + bad2: 208 187 return ret; 209 188 } 210 189 ··· 221 192 222 193 priv->uioinfo->handler = NULL; 223 194 priv->uioinfo->irqcontrol = NULL; 195 + 196 + /* kfree uioinfo for OF */ 197 + if (pdev->dev.of_node) 198 + kfree(priv->uioinfo); 224 199 225 200 kfree(priv); 226 201 return 0; ··· 252 219 .runtime_resume = uio_pdrv_genirq_runtime_nop, 253 220 }; 254 221 222 + #ifdef CONFIG_OF 223 + static const struct of_device_id __devinitconst uio_of_genirq_match[] = { 224 + { /* empty for now */ }, 225 + }; 226 + MODULE_DEVICE_TABLE(of, uio_of_genirq_match); 227 + #else 228 + # define uio_of_genirq_match NULL 229 + #endif 230 + 255 231 static struct platform_driver uio_pdrv_genirq = { 256 232 .probe = uio_pdrv_genirq_probe, 257 233 .remove = uio_pdrv_genirq_remove, ··· 268 226 .name = DRIVER_NAME, 269 227 .owner = THIS_MODULE, 270 228 .pm = &uio_pdrv_genirq_dev_pm_ops, 229 + .of_match_table = uio_of_genirq_match, 271 230 }, 272 231 }; 273 232