diff options
author | Janusz Krzysztofik <jmkrzyszt@gmail.com> | 2018-06-21 18:41:20 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2018-07-02 08:28:27 -0400 |
commit | df88c5768927855e54b8f0bd7dd478150b30beda (patch) | |
tree | 56702f660ab256688e0cab1ca77bd1e7692b3a86 /drivers/input | |
parent | 68e62a15a9146dead4a221ad1a31e3b186f12734 (diff) |
Input: ams_delta_serio: convert to platform driver
Convert the driver to an "ams-delta-serio" platform driver. For it to
be used with Amstrad Delta, register an "ams-delta-serio" platform
device from the board init file.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/serio/ams_delta_serio.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 3df501c3421b..a2a7fa19bf49 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c | |||
@@ -22,15 +22,17 @@ | |||
22 | */ | 22 | */ |
23 | #include <linux/gpio.h> | 23 | #include <linux/gpio.h> |
24 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
25 | #include <linux/platform_device.h> | ||
25 | #include <linux/serio.h> | 26 | #include <linux/serio.h> |
26 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
28 | 29 | ||
29 | #include <asm/mach-types.h> | ||
30 | #include <mach/board-ams-delta.h> | 30 | #include <mach/board-ams-delta.h> |
31 | 31 | ||
32 | #include <mach/ams-delta-fiq.h> | 32 | #include <mach/ams-delta-fiq.h> |
33 | 33 | ||
34 | #define DRIVER_NAME "ams-delta-serio" | ||
35 | |||
34 | MODULE_AUTHOR("Matt Callow"); | 36 | MODULE_AUTHOR("Matt Callow"); |
35 | MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); | 37 | MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); |
36 | MODULE_LICENSE("GPL"); | 38 | MODULE_LICENSE("GPL"); |
@@ -126,13 +128,10 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { | |||
126 | }, | 128 | }, |
127 | }; | 129 | }; |
128 | 130 | ||
129 | static int __init ams_delta_serio_init(void) | 131 | static int ams_delta_serio_init(struct platform_device *pdev) |
130 | { | 132 | { |
131 | int err; | 133 | int err; |
132 | 134 | ||
133 | if (!machine_is_ams_delta()) | ||
134 | return -ENODEV; | ||
135 | |||
136 | ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); | 135 | ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); |
137 | if (!ams_delta_serio) | 136 | if (!ams_delta_serio) |
138 | return -ENOMEM; | 137 | return -ENOMEM; |
@@ -142,22 +141,22 @@ static int __init ams_delta_serio_init(void) | |||
142 | ams_delta_serio->close = ams_delta_serio_close; | 141 | ams_delta_serio->close = ams_delta_serio_close; |
143 | strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", | 142 | strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", |
144 | sizeof(ams_delta_serio->name)); | 143 | sizeof(ams_delta_serio->name)); |
145 | strlcpy(ams_delta_serio->phys, "GPIO/serio0", | 144 | strlcpy(ams_delta_serio->phys, dev_name(&pdev->dev), |
146 | sizeof(ams_delta_serio->phys)); | 145 | sizeof(ams_delta_serio->phys)); |
146 | ams_delta_serio->dev.parent = &pdev->dev; | ||
147 | 147 | ||
148 | err = gpio_request_array(ams_delta_gpios, | 148 | err = gpio_request_array(ams_delta_gpios, |
149 | ARRAY_SIZE(ams_delta_gpios)); | 149 | ARRAY_SIZE(ams_delta_gpios)); |
150 | if (err) { | 150 | if (err) { |
151 | pr_err("ams_delta_serio: Couldn't request gpio pins\n"); | 151 | dev_err(&pdev->dev, "Couldn't request gpio pins\n"); |
152 | goto serio; | 152 | goto serio; |
153 | } | 153 | } |
154 | 154 | ||
155 | err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), | 155 | err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), |
156 | ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, | 156 | ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, |
157 | "ams-delta-serio", 0); | 157 | DRIVER_NAME, 0); |
158 | if (err < 0) { | 158 | if (err < 0) { |
159 | pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", | 159 | dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); |
160 | gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); | ||
161 | goto gpio; | 160 | goto gpio; |
162 | } | 161 | } |
163 | /* | 162 | /* |
@@ -179,13 +178,22 @@ serio: | |||
179 | kfree(ams_delta_serio); | 178 | kfree(ams_delta_serio); |
180 | return err; | 179 | return err; |
181 | } | 180 | } |
182 | module_init(ams_delta_serio_init); | ||
183 | 181 | ||
184 | static void __exit ams_delta_serio_exit(void) | 182 | static int ams_delta_serio_exit(struct platform_device *pdev) |
185 | { | 183 | { |
186 | serio_unregister_port(ams_delta_serio); | 184 | serio_unregister_port(ams_delta_serio); |
187 | free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); | 185 | free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); |
188 | gpio_free_array(ams_delta_gpios, | 186 | gpio_free_array(ams_delta_gpios, |
189 | ARRAY_SIZE(ams_delta_gpios)); | 187 | ARRAY_SIZE(ams_delta_gpios)); |
188 | |||
189 | return 0; | ||
190 | } | 190 | } |
191 | module_exit(ams_delta_serio_exit); | 191 | |
192 | static struct platform_driver ams_delta_serio_driver = { | ||
193 | .probe = ams_delta_serio_init, | ||
194 | .remove = ams_delta_serio_exit, | ||
195 | .driver = { | ||
196 | .name = DRIVER_NAME | ||
197 | }, | ||
198 | }; | ||
199 | module_platform_driver(ams_delta_serio_driver); | ||