diff options
Diffstat (limited to 'drivers/input/serio/altera_ps2.c')
| -rw-r--r-- | drivers/input/serio/altera_ps2.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c index f479ea50919..cce69d6b958 100644 --- a/drivers/input/serio/altera_ps2.c +++ b/drivers/input/serio/altera_ps2.c @@ -12,12 +12,13 @@ */ #include <linux/module.h> -#include <linux/init.h> #include <linux/input.h> #include <linux/serio.h> #include <linux/interrupt.h> #include <linux/platform_device.h> #include <linux/io.h> +#include <linux/slab.h> +#include <linux/of.h> #define DRV_NAME "altera_ps2" @@ -83,7 +84,7 @@ static int altera_ps2_probe(struct platform_device *pdev) { struct ps2if *ps2if; struct serio *serio; - int error; + int error, irq; ps2if = kzalloc(sizeof(struct ps2if), GFP_KERNEL); serio = kzalloc(sizeof(struct serio), GFP_KERNEL); @@ -108,11 +109,13 @@ static int altera_ps2_probe(struct platform_device *pdev) goto err_free_mem; } - ps2if->irq = platform_get_irq(pdev, 0); - if (ps2if->irq < 0) { + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { error = -ENXIO; goto err_free_mem; } + ps2if->irq = irq; if (!request_mem_region(ps2if->iomem_res->start, resource_size(ps2if->iomem_res), pdev->name)) { @@ -159,7 +162,6 @@ static int altera_ps2_remove(struct platform_device *pdev) { struct ps2if *ps2if = platform_get_drvdata(pdev); - platform_set_drvdata(pdev, NULL); serio_unregister_port(ps2if->io); free_irq(ps2if->irq, ps2if); iounmap(ps2if->base); @@ -170,6 +172,15 @@ static int altera_ps2_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id altera_ps2_match[] = { + { .compatible = "ALTR,ps2-1.0", }, + { .compatible = "altr,ps2-1.0", }, + {}, +}; +MODULE_DEVICE_TABLE(of, altera_ps2_match); +#endif /* CONFIG_OF */ + /* * Our device driver structure */ @@ -178,21 +189,11 @@ static struct platform_driver altera_ps2_driver = { .remove = altera_ps2_remove, .driver = { .name = DRV_NAME, + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(altera_ps2_match), }, }; - -static int __init altera_ps2_init(void) -{ - return platform_driver_register(&altera_ps2_driver); -} - -static void __exit altera_ps2_exit(void) -{ - platform_driver_unregister(&altera_ps2_driver); -} - -module_init(altera_ps2_init); -module_exit(altera_ps2_exit); +module_platform_driver(altera_ps2_driver); MODULE_DESCRIPTION("Altera University Program PS2 controller driver"); MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>"); |
