aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 15:46:37 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 15:46:37 -0500
commit31564cbd77baa88405862d4aa0d00893ab1d8cb7 (patch)
tree2eaec947ab64ccfa2d94ca29bf14feb70b8a4b61 /drivers/input/keyboard
parent6842d98de7bb726dfddc719cb9ae022b26a0f2b8 (diff)
parent022573c275500e1a50889949f679d04b5446edf6 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull second round of input updates from Dmitry Torokhov: "As usual, there are a couple of new drivers, input core now supports managed input devices (devres), a slew of drivers now have device tree support and a bunch of fixes and cleanups." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (71 commits) Input: walkera0701 - fix crash on startup Input: matrix-keymap - provide a proper module license Input: gpio_keys_polled - switch to using gpio_request_one() Input: gpio_keys - switch to using gpio_request_one() Input: wacom - fix touch support for Bamboo Fun CTH-461 Input: xpad - add a few new VID/PID combinations Input: xpad - minor formatting fixes Input: gpio-keys-polled - honor 'autorepeat' setting in platform data Input: tca8418-keypad - switch to using managed resources Input: tca8418_keypad - increase severity of failures in probe() Input: tca8418_keypad - move device ID tables closer to where they are used Input: tca8418_keypad - use dev_get_platdata() to retrieve platform data Input: tca8418_keypad - use a temporary variable for parent device Input: tca8418_keypad - add support for shared interrupt Input: tca8418_keypad - add support for device tree bindings Input: remove Compaq iPAQ H3600 (Bitsy) touchscreen driver Input: bu21013_ts - add support for Device Tree booting Input: bu21013_ts - move GPIO init and exit functions into the driver Input: bu21013_ts - request regulator that actually exists ARM: ux500: Strip out duplicate touch screen platform information ...
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/adp5520-keys.c6
-rw-r--r--drivers/input/keyboard/adp5588-keys.c18
-rw-r--r--drivers/input/keyboard/adp5589-keys.c21
-rw-r--r--drivers/input/keyboard/bf54x-keys.c6
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c4
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c6
-rw-r--r--drivers/input/keyboard/gpio_keys.c90
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c26
-rw-r--r--drivers/input/keyboard/hilkbd.c10
-rw-r--r--drivers/input/keyboard/imx_keypad.c9
-rw-r--r--drivers/input/keyboard/jornada680_kbd.c6
-rw-r--r--drivers/input/keyboard/jornada720_kbd.c6
-rw-r--r--drivers/input/keyboard/lm8323.c6
-rw-r--r--drivers/input/keyboard/lm8333.c6
-rw-r--r--drivers/input/keyboard/locomokbd.c8
-rw-r--r--drivers/input/keyboard/lpc32xx-keys.c8
-rw-r--r--drivers/input/keyboard/matrix_keypad.c129
-rw-r--r--drivers/input/keyboard/max7359_keypad.c6
-rw-r--r--drivers/input/keyboard/mcs_touchkey.c6
-rw-r--r--drivers/input/keyboard/mpr121_touchkey.c12
-rw-r--r--drivers/input/keyboard/nomadik-ske-keypad.c38
-rw-r--r--drivers/input/keyboard/omap-keypad.c6
-rw-r--r--drivers/input/keyboard/omap4-keypad.c10
-rw-r--r--drivers/input/keyboard/opencores-kbd.c6
-rw-r--r--drivers/input/keyboard/pmic8xxx-keypad.c10
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c6
-rw-r--r--drivers/input/keyboard/pxa930_rotary.c6
-rw-r--r--drivers/input/keyboard/qt1070.c8
-rw-r--r--drivers/input/keyboard/qt2160.c31
-rw-r--r--drivers/input/keyboard/samsung-keypad.c109
-rw-r--r--drivers/input/keyboard/sh_keysc.c6
-rw-r--r--drivers/input/keyboard/spear-keyboard.c98
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c142
-rw-r--r--drivers/input/keyboard/tc3589x-keypad.c6
-rw-r--r--drivers/input/keyboard/tca6416-keypad.c8
-rw-r--r--drivers/input/keyboard/tca8418_keypad.c179
-rw-r--r--drivers/input/keyboard/tegra-kbc.c16
-rw-r--r--drivers/input/keyboard/tnetv107x-keypad.c6
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c8
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c6
41 files changed, 580 insertions, 516 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index febead4bf8a5..5a240c60342d 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -134,7 +134,7 @@ config KEYBOARD_QT1070
134 134
135config KEYBOARD_QT2160 135config KEYBOARD_QT2160
136 tristate "Atmel AT42QT2160 Touch Sensor Chip" 136 tristate "Atmel AT42QT2160 Touch Sensor Chip"
137 depends on I2C && EXPERIMENTAL 137 depends on I2C
138 help 138 help
139 If you say yes here you get support for Atmel AT42QT2160 Touch 139 If you say yes here you get support for Atmel AT42QT2160 Touch
140 Sensor chip as a keyboard input. 140 Sensor chip as a keyboard input.
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
index e9e8674dfda1..ef26b17fb159 100644
--- a/drivers/input/keyboard/adp5520-keys.c
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -69,7 +69,7 @@ static int adp5520_keys_notifier(struct notifier_block *nb,
69 return 0; 69 return 0;
70} 70}
71 71
72static int __devinit adp5520_keys_probe(struct platform_device *pdev) 72static int adp5520_keys_probe(struct platform_device *pdev)
73{ 73{
74 struct adp5520_keys_platform_data *pdata = pdev->dev.platform_data; 74 struct adp5520_keys_platform_data *pdata = pdev->dev.platform_data;
75 struct input_dev *input; 75 struct input_dev *input;
@@ -182,7 +182,7 @@ err:
182 return ret; 182 return ret;
183} 183}
184 184
185static int __devexit adp5520_keys_remove(struct platform_device *pdev) 185static int adp5520_keys_remove(struct platform_device *pdev)
186{ 186{
187 struct adp5520_keys *dev = platform_get_drvdata(pdev); 187 struct adp5520_keys *dev = platform_get_drvdata(pdev);
188 188
@@ -200,7 +200,7 @@ static struct platform_driver adp5520_keys_driver = {
200 .owner = THIS_MODULE, 200 .owner = THIS_MODULE,
201 }, 201 },
202 .probe = adp5520_keys_probe, 202 .probe = adp5520_keys_probe,
203 .remove = __devexit_p(adp5520_keys_remove), 203 .remove = adp5520_keys_remove,
204}; 204};
205module_platform_driver(adp5520_keys_driver); 205module_platform_driver(adp5520_keys_driver);
206 206
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index b083bf10f139..dbd2047f1641 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -145,7 +145,7 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
145 return ret; 145 return ret;
146} 146}
147 147
148static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad, 148static int adp5588_build_gpiomap(struct adp5588_kpad *kpad,
149 const struct adp5588_kpad_platform_data *pdata) 149 const struct adp5588_kpad_platform_data *pdata)
150{ 150{
151 bool pin_used[ADP5588_MAXGPIO]; 151 bool pin_used[ADP5588_MAXGPIO];
@@ -170,7 +170,7 @@ static int __devinit adp5588_build_gpiomap(struct adp5588_kpad *kpad,
170 return n_unused; 170 return n_unused;
171} 171}
172 172
173static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad) 173static int adp5588_gpio_add(struct adp5588_kpad *kpad)
174{ 174{
175 struct device *dev = &kpad->client->dev; 175 struct device *dev = &kpad->client->dev;
176 const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 176 const struct adp5588_kpad_platform_data *pdata = dev->platform_data;
@@ -224,7 +224,7 @@ static int __devinit adp5588_gpio_add(struct adp5588_kpad *kpad)
224 return 0; 224 return 0;
225} 225}
226 226
227static void __devexit adp5588_gpio_remove(struct adp5588_kpad *kpad) 227static void adp5588_gpio_remove(struct adp5588_kpad *kpad)
228{ 228{
229 struct device *dev = &kpad->client->dev; 229 struct device *dev = &kpad->client->dev;
230 const struct adp5588_kpad_platform_data *pdata = dev->platform_data; 230 const struct adp5588_kpad_platform_data *pdata = dev->platform_data;
@@ -319,7 +319,7 @@ static irqreturn_t adp5588_irq(int irq, void *handle)
319 return IRQ_HANDLED; 319 return IRQ_HANDLED;
320} 320}
321 321
322static int __devinit adp5588_setup(struct i2c_client *client) 322static int adp5588_setup(struct i2c_client *client)
323{ 323{
324 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 324 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data;
325 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data; 325 const struct adp5588_gpio_platform_data *gpio_data = pdata->gpio_data;
@@ -382,7 +382,7 @@ static int __devinit adp5588_setup(struct i2c_client *client)
382 return 0; 382 return 0;
383} 383}
384 384
385static void __devinit adp5588_report_switch_state(struct adp5588_kpad *kpad) 385static void adp5588_report_switch_state(struct adp5588_kpad *kpad)
386{ 386{
387 int gpi_stat1 = adp5588_read(kpad->client, GPIO_DAT_STAT1); 387 int gpi_stat1 = adp5588_read(kpad->client, GPIO_DAT_STAT1);
388 int gpi_stat2 = adp5588_read(kpad->client, GPIO_DAT_STAT2); 388 int gpi_stat2 = adp5588_read(kpad->client, GPIO_DAT_STAT2);
@@ -420,8 +420,8 @@ static void __devinit adp5588_report_switch_state(struct adp5588_kpad *kpad)
420} 420}
421 421
422 422
423static int __devinit adp5588_probe(struct i2c_client *client, 423static int adp5588_probe(struct i2c_client *client,
424 const struct i2c_device_id *id) 424 const struct i2c_device_id *id)
425{ 425{
426 struct adp5588_kpad *kpad; 426 struct adp5588_kpad *kpad;
427 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data; 427 const struct adp5588_kpad_platform_data *pdata = client->dev.platform_data;
@@ -587,7 +587,7 @@ static int __devinit adp5588_probe(struct i2c_client *client,
587 return error; 587 return error;
588} 588}
589 589
590static int __devexit adp5588_remove(struct i2c_client *client) 590static int adp5588_remove(struct i2c_client *client)
591{ 591{
592 struct adp5588_kpad *kpad = i2c_get_clientdata(client); 592 struct adp5588_kpad *kpad = i2c_get_clientdata(client);
593 593
@@ -650,7 +650,7 @@ static struct i2c_driver adp5588_driver = {
650#endif 650#endif
651 }, 651 },
652 .probe = adp5588_probe, 652 .probe = adp5588_probe,
653 .remove = __devexit_p(adp5588_remove), 653 .remove = adp5588_remove,
654 .id_table = adp5588_id, 654 .id_table = adp5588_id,
655}; 655};
656 656
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 74e603213386..67d12b3427c9 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -464,7 +464,7 @@ static int adp5589_gpio_direction_output(struct gpio_chip *chip,
464 return ret; 464 return ret;
465} 465}
466 466
467static int __devinit adp5589_build_gpiomap(struct adp5589_kpad *kpad, 467static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
468 const struct adp5589_kpad_platform_data *pdata) 468 const struct adp5589_kpad_platform_data *pdata)
469{ 469{
470 bool pin_used[ADP5589_MAXGPIO]; 470 bool pin_used[ADP5589_MAXGPIO];
@@ -496,7 +496,7 @@ static int __devinit adp5589_build_gpiomap(struct adp5589_kpad *kpad,
496 return n_unused; 496 return n_unused;
497} 497}
498 498
499static int __devinit adp5589_gpio_add(struct adp5589_kpad *kpad) 499static int adp5589_gpio_add(struct adp5589_kpad *kpad)
500{ 500{
501 struct device *dev = &kpad->client->dev; 501 struct device *dev = &kpad->client->dev;
502 const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 502 const struct adp5589_kpad_platform_data *pdata = dev->platform_data;
@@ -550,7 +550,7 @@ static int __devinit adp5589_gpio_add(struct adp5589_kpad *kpad)
550 return 0; 550 return 0;
551} 551}
552 552
553static void __devexit adp5589_gpio_remove(struct adp5589_kpad *kpad) 553static void adp5589_gpio_remove(struct adp5589_kpad *kpad)
554{ 554{
555 struct device *dev = &kpad->client->dev; 555 struct device *dev = &kpad->client->dev;
556 const struct adp5589_kpad_platform_data *pdata = dev->platform_data; 556 const struct adp5589_kpad_platform_data *pdata = dev->platform_data;
@@ -641,8 +641,7 @@ static irqreturn_t adp5589_irq(int irq, void *handle)
641 return IRQ_HANDLED; 641 return IRQ_HANDLED;
642} 642}
643 643
644static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad, 644static int adp5589_get_evcode(struct adp5589_kpad *kpad, unsigned short key)
645 unsigned short key)
646{ 645{
647 int i; 646 int i;
648 647
@@ -655,7 +654,7 @@ static int __devinit adp5589_get_evcode(struct adp5589_kpad *kpad,
655 return -EINVAL; 654 return -EINVAL;
656} 655}
657 656
658static int __devinit adp5589_setup(struct adp5589_kpad *kpad) 657static int adp5589_setup(struct adp5589_kpad *kpad)
659{ 658{
660 struct i2c_client *client = kpad->client; 659 struct i2c_client *client = kpad->client;
661 const struct adp5589_kpad_platform_data *pdata = 660 const struct adp5589_kpad_platform_data *pdata =
@@ -820,7 +819,7 @@ static int __devinit adp5589_setup(struct adp5589_kpad *kpad)
820 return 0; 819 return 0;
821} 820}
822 821
823static void __devinit adp5589_report_switch_state(struct adp5589_kpad *kpad) 822static void adp5589_report_switch_state(struct adp5589_kpad *kpad)
824{ 823{
825 int gpi_stat_tmp, pin_loc; 824 int gpi_stat_tmp, pin_loc;
826 int i; 825 int i;
@@ -860,8 +859,8 @@ static void __devinit adp5589_report_switch_state(struct adp5589_kpad *kpad)
860 input_sync(kpad->input); 859 input_sync(kpad->input);
861} 860}
862 861
863static int __devinit adp5589_probe(struct i2c_client *client, 862static int adp5589_probe(struct i2c_client *client,
864 const struct i2c_device_id *id) 863 const struct i2c_device_id *id)
865{ 864{
866 struct adp5589_kpad *kpad; 865 struct adp5589_kpad *kpad;
867 const struct adp5589_kpad_platform_data *pdata = 866 const struct adp5589_kpad_platform_data *pdata =
@@ -1045,7 +1044,7 @@ err_free_mem:
1045 return error; 1044 return error;
1046} 1045}
1047 1046
1048static int __devexit adp5589_remove(struct i2c_client *client) 1047static int adp5589_remove(struct i2c_client *client)
1049{ 1048{
1050 struct adp5589_kpad *kpad = i2c_get_clientdata(client); 1049 struct adp5589_kpad *kpad = i2c_get_clientdata(client);
1051 1050
@@ -1104,7 +1103,7 @@ static struct i2c_driver adp5589_driver = {
1104 .pm = &adp5589_dev_pm_ops, 1103 .pm = &adp5589_dev_pm_ops,
1105 }, 1104 },
1106 .probe = adp5589_probe, 1105 .probe = adp5589_probe,
1107 .remove = __devexit_p(adp5589_remove), 1106 .remove = adp5589_remove,
1108 .id_table = adp5589_id, 1107 .id_table = adp5589_id,
1109}; 1108};
1110 1109
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index 8eb9116e0a5f..20b9fa91fb9e 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -177,7 +177,7 @@ static irqreturn_t bfin_kpad_isr(int irq, void *dev_id)
177 return IRQ_HANDLED; 177 return IRQ_HANDLED;
178} 178}
179 179
180static int __devinit bfin_kpad_probe(struct platform_device *pdev) 180static int bfin_kpad_probe(struct platform_device *pdev)
181{ 181{
182 struct bf54x_kpad *bf54x_kpad; 182 struct bf54x_kpad *bf54x_kpad;
183 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data; 183 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data;
@@ -331,7 +331,7 @@ out:
331 return error; 331 return error;
332} 332}
333 333
334static int __devexit bfin_kpad_remove(struct platform_device *pdev) 334static int bfin_kpad_remove(struct platform_device *pdev)
335{ 335{
336 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data; 336 struct bfin_kpad_platform_data *pdata = pdev->dev.platform_data;
337 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); 337 struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev);
@@ -390,7 +390,7 @@ static struct platform_driver bfin_kpad_device_driver = {
390 .owner = THIS_MODULE, 390 .owner = THIS_MODULE,
391 }, 391 },
392 .probe = bfin_kpad_probe, 392 .probe = bfin_kpad_probe,
393 .remove = __devexit_p(bfin_kpad_remove), 393 .remove = bfin_kpad_remove,
394 .suspend = bfin_kpad_suspend, 394 .suspend = bfin_kpad_suspend,
395 .resume = bfin_kpad_resume, 395 .resume = bfin_kpad_resume,
396}; 396};
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
index d5bacbb479b0..4e4e453ea15e 100644
--- a/drivers/input/keyboard/davinci_keyscan.c
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -303,7 +303,7 @@ fail1:
303 return error; 303 return error;
304} 304}
305 305
306static int __devexit davinci_ks_remove(struct platform_device *pdev) 306static int davinci_ks_remove(struct platform_device *pdev)
307{ 307{
308 struct davinci_ks *davinci_ks = platform_get_drvdata(pdev); 308 struct davinci_ks *davinci_ks = platform_get_drvdata(pdev);
309 309
@@ -326,7 +326,7 @@ static struct platform_driver davinci_ks_driver = {
326 .name = "davinci_keyscan", 326 .name = "davinci_keyscan",
327 .owner = THIS_MODULE, 327 .owner = THIS_MODULE,
328 }, 328 },
329 .remove = __devexit_p(davinci_ks_remove), 329 .remove = davinci_ks_remove,
330}; 330};
331 331
332static int __init davinci_ks_init(void) 332static int __init davinci_ks_init(void)
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index 7363402de8d4..9857e8fd0987 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -232,7 +232,7 @@ static int ep93xx_keypad_resume(struct device *dev)
232static SIMPLE_DEV_PM_OPS(ep93xx_keypad_pm_ops, 232static SIMPLE_DEV_PM_OPS(ep93xx_keypad_pm_ops,
233 ep93xx_keypad_suspend, ep93xx_keypad_resume); 233 ep93xx_keypad_suspend, ep93xx_keypad_resume);
234 234
235static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) 235static int ep93xx_keypad_probe(struct platform_device *pdev)
236{ 236{
237 struct ep93xx_keypad *keypad; 237 struct ep93xx_keypad *keypad;
238 const struct matrix_keymap_data *keymap_data; 238 const struct matrix_keymap_data *keymap_data;
@@ -346,7 +346,7 @@ failed_free:
346 return err; 346 return err;
347} 347}
348 348
349static int __devexit ep93xx_keypad_remove(struct platform_device *pdev) 349static int ep93xx_keypad_remove(struct platform_device *pdev)
350{ 350{
351 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev); 351 struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
352 struct resource *res; 352 struct resource *res;
@@ -380,7 +380,7 @@ static struct platform_driver ep93xx_keypad_driver = {
380 .pm = &ep93xx_keypad_pm_ops, 380 .pm = &ep93xx_keypad_pm_ops,
381 }, 381 },
382 .probe = ep93xx_keypad_probe, 382 .probe = ep93xx_keypad_probe,
383 .remove = __devexit_p(ep93xx_keypad_remove), 383 .remove = ep93xx_keypad_remove,
384}; 384};
385module_platform_driver(ep93xx_keypad_driver); 385module_platform_driver(ep93xx_keypad_driver);
386 386
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 6a68041c261d..d327f5a2bb0e 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -423,10 +423,10 @@ out:
423 return IRQ_HANDLED; 423 return IRQ_HANDLED;
424} 424}
425 425
426static int __devinit gpio_keys_setup_key(struct platform_device *pdev, 426static int gpio_keys_setup_key(struct platform_device *pdev,
427 struct input_dev *input, 427 struct input_dev *input,
428 struct gpio_button_data *bdata, 428 struct gpio_button_data *bdata,
429 const struct gpio_keys_button *button) 429 const struct gpio_keys_button *button)
430{ 430{
431 const char *desc = button->desc ? button->desc : "gpio_keys"; 431 const char *desc = button->desc ? button->desc : "gpio_keys";
432 struct device *dev = &pdev->dev; 432 struct device *dev = &pdev->dev;
@@ -440,21 +440,13 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
440 440
441 if (gpio_is_valid(button->gpio)) { 441 if (gpio_is_valid(button->gpio)) {
442 442
443 error = gpio_request(button->gpio, desc); 443 error = gpio_request_one(button->gpio, GPIOF_IN, desc);
444 if (error < 0) { 444 if (error < 0) {
445 dev_err(dev, "Failed to request GPIO %d, error %d\n", 445 dev_err(dev, "Failed to request GPIO %d, error %d\n",
446 button->gpio, error); 446 button->gpio, error);
447 return error; 447 return error;
448 } 448 }
449 449
450 error = gpio_direction_input(button->gpio);
451 if (error < 0) {
452 dev_err(dev,
453 "Failed to configure direction for GPIO %d, error %d\n",
454 button->gpio, error);
455 goto fail;
456 }
457
458 if (button->debounce_interval) { 450 if (button->debounce_interval) {
459 error = gpio_set_debounce(button->gpio, 451 error = gpio_set_debounce(button->gpio,
460 button->debounce_interval * 1000); 452 button->debounce_interval * 1000);
@@ -526,12 +518,35 @@ fail:
526 return error; 518 return error;
527} 519}
528 520
521static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
522{
523 struct input_dev *input = ddata->input;
524 int i;
525
526 for (i = 0; i < ddata->pdata->nbuttons; i++) {
527 struct gpio_button_data *bdata = &ddata->data[i];
528 if (gpio_is_valid(bdata->button->gpio))
529 gpio_keys_gpio_report_event(bdata);
530 }
531 input_sync(input);
532}
533
529static int gpio_keys_open(struct input_dev *input) 534static int gpio_keys_open(struct input_dev *input)
530{ 535{
531 struct gpio_keys_drvdata *ddata = input_get_drvdata(input); 536 struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
532 const struct gpio_keys_platform_data *pdata = ddata->pdata; 537 const struct gpio_keys_platform_data *pdata = ddata->pdata;
538 int error;
539
540 if (pdata->enable) {
541 error = pdata->enable(input->dev.parent);
542 if (error)
543 return error;
544 }
545
546 /* Report current state of buttons that are connected to GPIOs */
547 gpio_keys_report_state(ddata);
533 548
534 return pdata->enable ? pdata->enable(input->dev.parent) : 0; 549 return 0;
535} 550}
536 551
537static void gpio_keys_close(struct input_dev *input) 552static void gpio_keys_close(struct input_dev *input)
@@ -551,7 +566,7 @@ static void gpio_keys_close(struct input_dev *input)
551/* 566/*
552 * Translate OpenFirmware node properties into platform_data 567 * Translate OpenFirmware node properties into platform_data
553 */ 568 */
554static struct gpio_keys_platform_data * __devinit 569static struct gpio_keys_platform_data *
555gpio_keys_get_devtree_pdata(struct device *dev) 570gpio_keys_get_devtree_pdata(struct device *dev)
556{ 571{
557 struct device_node *node, *pp; 572 struct device_node *node, *pp;
@@ -658,7 +673,7 @@ static void gpio_remove_key(struct gpio_button_data *bdata)
658 gpio_free(bdata->button->gpio); 673 gpio_free(bdata->button->gpio);
659} 674}
660 675
661static int __devinit gpio_keys_probe(struct platform_device *pdev) 676static int gpio_keys_probe(struct platform_device *pdev)
662{ 677{
663 struct device *dev = &pdev->dev; 678 struct device *dev = &pdev->dev;
664 const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); 679 const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
@@ -731,14 +746,6 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
731 goto fail3; 746 goto fail3;
732 } 747 }
733 748
734 /* get current state of buttons that are connected to GPIOs */
735 for (i = 0; i < pdata->nbuttons; i++) {
736 struct gpio_button_data *bdata = &ddata->data[i];
737 if (gpio_is_valid(bdata->button->gpio))
738 gpio_keys_gpio_report_event(bdata);
739 }
740 input_sync(input);
741
742 device_init_wakeup(&pdev->dev, wakeup); 749 device_init_wakeup(&pdev->dev, wakeup);
743 750
744 return 0; 751 return 0;
@@ -760,7 +767,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
760 return error; 767 return error;
761} 768}
762 769
763static int __devexit gpio_keys_remove(struct platform_device *pdev) 770static int gpio_keys_remove(struct platform_device *pdev)
764{ 771{
765 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); 772 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);
766 struct input_dev *input = ddata->input; 773 struct input_dev *input = ddata->input;
@@ -788,6 +795,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
788static int gpio_keys_suspend(struct device *dev) 795static int gpio_keys_suspend(struct device *dev)
789{ 796{
790 struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); 797 struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
798 struct input_dev *input = ddata->input;
791 int i; 799 int i;
792 800
793 if (device_may_wakeup(dev)) { 801 if (device_may_wakeup(dev)) {
@@ -796,6 +804,11 @@ static int gpio_keys_suspend(struct device *dev)
796 if (bdata->button->wakeup) 804 if (bdata->button->wakeup)
797 enable_irq_wake(bdata->irq); 805 enable_irq_wake(bdata->irq);
798 } 806 }
807 } else {
808 mutex_lock(&input->mutex);
809 if (input->users)
810 gpio_keys_close(input);
811 mutex_unlock(&input->mutex);
799 } 812 }
800 813
801 return 0; 814 return 0;
@@ -804,18 +817,27 @@ static int gpio_keys_suspend(struct device *dev)
804static int gpio_keys_resume(struct device *dev) 817static int gpio_keys_resume(struct device *dev)
805{ 818{
806 struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); 819 struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
820 struct input_dev *input = ddata->input;
821 int error = 0;
807 int i; 822 int i;
808 823
809 for (i = 0; i < ddata->pdata->nbuttons; i++) { 824 if (device_may_wakeup(dev)) {
810 struct gpio_button_data *bdata = &ddata->data[i]; 825 for (i = 0; i < ddata->pdata->nbuttons; i++) {
811 if (bdata->button->wakeup && device_may_wakeup(dev)) 826 struct gpio_button_data *bdata = &ddata->data[i];
812 disable_irq_wake(bdata->irq); 827 if (bdata->button->wakeup)
813 828 disable_irq_wake(bdata->irq);
814 if (gpio_is_valid(bdata->button->gpio)) 829 }
815 gpio_keys_gpio_report_event(bdata); 830 } else {
831 mutex_lock(&input->mutex);
832 if (input->users)
833 error = gpio_keys_open(input);
834 mutex_unlock(&input->mutex);
816 } 835 }
817 input_sync(ddata->input);
818 836
837 if (error)
838 return error;
839
840 gpio_keys_report_state(ddata);
819 return 0; 841 return 0;
820} 842}
821#endif 843#endif
@@ -824,7 +846,7 @@ static SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops, gpio_keys_suspend, gpio_keys_resume);
824 846
825static struct platform_driver gpio_keys_device_driver = { 847static struct platform_driver gpio_keys_device_driver = {
826 .probe = gpio_keys_probe, 848 .probe = gpio_keys_probe,
827 .remove = __devexit_p(gpio_keys_remove), 849 .remove = gpio_keys_remove,
828 .driver = { 850 .driver = {
829 .name = "gpio-keys", 851 .name = "gpio-keys",
830 .owner = THIS_MODULE, 852 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index f2142de789e7..f686fd970553 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -103,8 +103,7 @@ static void gpio_keys_polled_close(struct input_polled_dev *dev)
103} 103}
104 104
105#ifdef CONFIG_OF 105#ifdef CONFIG_OF
106static struct gpio_keys_platform_data * __devinit 106static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct device *dev)
107gpio_keys_polled_get_devtree_pdata(struct device *dev)
108{ 107{
109 struct device_node *node, *pp; 108 struct device_node *node, *pp;
110 struct gpio_keys_platform_data *pdata; 109 struct gpio_keys_platform_data *pdata;
@@ -196,7 +195,7 @@ gpio_keys_polled_get_devtree_pdata(struct device *dev)
196} 195}
197#endif 196#endif
198 197
199static int __devinit gpio_keys_polled_probe(struct platform_device *pdev) 198static int gpio_keys_polled_probe(struct platform_device *pdev)
200{ 199{
201 struct device *dev = &pdev->dev; 200 struct device *dev = &pdev->dev;
202 const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev); 201 const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
@@ -246,7 +245,6 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
246 245
247 input = poll_dev->input; 246 input = poll_dev->input;
248 247
249 input->evbit[0] = BIT(EV_KEY);
250 input->name = pdev->name; 248 input->name = pdev->name;
251 input->phys = DRV_NAME"/input0"; 249 input->phys = DRV_NAME"/input0";
252 input->dev.parent = &pdev->dev; 250 input->dev.parent = &pdev->dev;
@@ -256,6 +254,10 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
256 input->id.product = 0x0001; 254 input->id.product = 0x0001;
257 input->id.version = 0x0100; 255 input->id.version = 0x0100;
258 256
257 __set_bit(EV_KEY, input->evbit);
258 if (pdata->rep)
259 __set_bit(EV_REP, input->evbit);
260
259 for (i = 0; i < pdata->nbuttons; i++) { 261 for (i = 0; i < pdata->nbuttons; i++) {
260 struct gpio_keys_button *button = &pdata->buttons[i]; 262 struct gpio_keys_button *button = &pdata->buttons[i];
261 struct gpio_keys_button_data *bdata = &bdev->data[i]; 263 struct gpio_keys_button_data *bdata = &bdev->data[i];
@@ -268,22 +270,14 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
268 goto err_free_gpio; 270 goto err_free_gpio;
269 } 271 }
270 272
271 error = gpio_request(gpio, 273 error = gpio_request_one(gpio, GPIOF_IN,
272 button->desc ? button->desc : DRV_NAME); 274 button->desc ?: DRV_NAME);
273 if (error) { 275 if (error) {
274 dev_err(dev, "unable to claim gpio %u, err=%d\n", 276 dev_err(dev, "unable to claim gpio %u, err=%d\n",
275 gpio, error); 277 gpio, error);
276 goto err_free_gpio; 278 goto err_free_gpio;
277 } 279 }
278 280
279 error = gpio_direction_input(gpio);
280 if (error) {
281 dev_err(dev,
282 "unable to set direction on gpio %u, err=%d\n",
283 gpio, error);
284 goto err_free_gpio;
285 }
286
287 bdata->can_sleep = gpio_cansleep(gpio); 281 bdata->can_sleep = gpio_cansleep(gpio);
288 bdata->last_state = -1; 282 bdata->last_state = -1;
289 bdata->threshold = DIV_ROUND_UP(button->debounce_interval, 283 bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
@@ -329,7 +323,7 @@ err_free_pdata:
329 return error; 323 return error;
330} 324}
331 325
332static int __devexit gpio_keys_polled_remove(struct platform_device *pdev) 326static int gpio_keys_polled_remove(struct platform_device *pdev)
333{ 327{
334 struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev); 328 struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
335 const struct gpio_keys_platform_data *pdata = bdev->pdata; 329 const struct gpio_keys_platform_data *pdata = bdev->pdata;
@@ -357,7 +351,7 @@ static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
357 351
358static struct platform_driver gpio_keys_polled_driver = { 352static struct platform_driver gpio_keys_polled_driver = {
359 .probe = gpio_keys_polled_probe, 353 .probe = gpio_keys_polled_probe,
360 .remove = __devexit_p(gpio_keys_polled_remove), 354 .remove = gpio_keys_polled_remove,
361 .driver = { 355 .driver = {
362 .name = DRV_NAME, 356 .name = DRV_NAME,
363 .owner = THIS_MODULE, 357 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index 5f72440b50c8..198dc07a1be5 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -200,7 +200,7 @@ static void hil_do(unsigned char cmd, unsigned char *data, unsigned int len)
200 200
201 201
202/* initialize HIL */ 202/* initialize HIL */
203static int __devinit hil_keyb_init(void) 203static int hil_keyb_init(void)
204{ 204{
205 unsigned char c; 205 unsigned char c;
206 unsigned int i, kbid; 206 unsigned int i, kbid;
@@ -286,7 +286,7 @@ err1:
286 return err; 286 return err;
287} 287}
288 288
289static void __devexit hil_keyb_exit(void) 289static void hil_keyb_exit(void)
290{ 290{
291 if (HIL_IRQ) 291 if (HIL_IRQ)
292 free_irq(HIL_IRQ, hil_dev.dev_id); 292 free_irq(HIL_IRQ, hil_dev.dev_id);
@@ -299,7 +299,7 @@ static void __devexit hil_keyb_exit(void)
299} 299}
300 300
301#if defined(CONFIG_PARISC) 301#if defined(CONFIG_PARISC)
302static int __devinit hil_probe_chip(struct parisc_device *dev) 302static int hil_probe_chip(struct parisc_device *dev)
303{ 303{
304 /* Only allow one HIL keyboard */ 304 /* Only allow one HIL keyboard */
305 if (hil_dev.dev) 305 if (hil_dev.dev)
@@ -320,7 +320,7 @@ static int __devinit hil_probe_chip(struct parisc_device *dev)
320 return hil_keyb_init(); 320 return hil_keyb_init();
321} 321}
322 322
323static int __devexit hil_remove_chip(struct parisc_device *dev) 323static int hil_remove_chip(struct parisc_device *dev)
324{ 324{
325 hil_keyb_exit(); 325 hil_keyb_exit();
326 326
@@ -341,7 +341,7 @@ static struct parisc_driver hil_driver = {
341 .name = "hil", 341 .name = "hil",
342 .id_table = hil_tbl, 342 .id_table = hil_tbl,
343 .probe = hil_probe_chip, 343 .probe = hil_probe_chip,
344 .remove = __devexit_p(hil_remove_chip), 344 .remove = hil_remove_chip,
345}; 345};
346 346
347static int __init hil_init(void) 347static int __init hil_init(void)
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index cdc252612c0b..6d150e3e1f55 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -362,7 +362,8 @@ static void imx_keypad_inhibit(struct imx_keypad *keypad)
362 writew(reg_val, keypad->mmio_base + KPSR); 362 writew(reg_val, keypad->mmio_base + KPSR);
363 363
364 /* Colums as open drain and disable all rows */ 364 /* Colums as open drain and disable all rows */
365 writew(0xff00, keypad->mmio_base + KPCR); 365 reg_val = (keypad->cols_en_mask & 0xff) << 8;
366 writew(reg_val, keypad->mmio_base + KPCR);
366} 367}
367 368
368static void imx_keypad_close(struct input_dev *dev) 369static void imx_keypad_close(struct input_dev *dev)
@@ -413,7 +414,7 @@ open_err:
413 return -EIO; 414 return -EIO;
414} 415}
415 416
416static int __devinit imx_keypad_probe(struct platform_device *pdev) 417static int imx_keypad_probe(struct platform_device *pdev)
417{ 418{
418 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; 419 const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data;
419 struct imx_keypad *keypad; 420 struct imx_keypad *keypad;
@@ -554,7 +555,7 @@ failed_rel_mem:
554 return error; 555 return error;
555} 556}
556 557
557static int __devexit imx_keypad_remove(struct platform_device *pdev) 558static int imx_keypad_remove(struct platform_device *pdev)
558{ 559{
559 struct imx_keypad *keypad = platform_get_drvdata(pdev); 560 struct imx_keypad *keypad = platform_get_drvdata(pdev);
560 struct resource *res; 561 struct resource *res;
@@ -632,7 +633,7 @@ static struct platform_driver imx_keypad_driver = {
632 .pm = &imx_kbd_pm_ops, 633 .pm = &imx_kbd_pm_ops,
633 }, 634 },
634 .probe = imx_keypad_probe, 635 .probe = imx_keypad_probe,
635 .remove = __devexit_p(imx_keypad_remove), 636 .remove = imx_keypad_remove,
636}; 637};
637module_platform_driver(imx_keypad_driver); 638module_platform_driver(imx_keypad_driver);
638 639
diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c
index 24f3ea01c4d5..74e75a6e8deb 100644
--- a/drivers/input/keyboard/jornada680_kbd.c
+++ b/drivers/input/keyboard/jornada680_kbd.c
@@ -179,7 +179,7 @@ static void jornadakbd680_poll(struct input_polled_dev *dev)
179 memcpy(jornadakbd->old_scan, jornadakbd->new_scan, JORNADA_SCAN_SIZE); 179 memcpy(jornadakbd->old_scan, jornadakbd->new_scan, JORNADA_SCAN_SIZE);
180} 180}
181 181
182static int __devinit jornada680kbd_probe(struct platform_device *pdev) 182static int jornada680kbd_probe(struct platform_device *pdev)
183{ 183{
184 struct jornadakbd *jornadakbd; 184 struct jornadakbd *jornadakbd;
185 struct input_polled_dev *poll_dev; 185 struct input_polled_dev *poll_dev;
@@ -240,7 +240,7 @@ static int __devinit jornada680kbd_probe(struct platform_device *pdev)
240 240
241} 241}
242 242
243static int __devexit jornada680kbd_remove(struct platform_device *pdev) 243static int jornada680kbd_remove(struct platform_device *pdev)
244{ 244{
245 struct jornadakbd *jornadakbd = platform_get_drvdata(pdev); 245 struct jornadakbd *jornadakbd = platform_get_drvdata(pdev);
246 246
@@ -258,7 +258,7 @@ static struct platform_driver jornada680kbd_driver = {
258 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
259 }, 259 },
260 .probe = jornada680kbd_probe, 260 .probe = jornada680kbd_probe,
261 .remove = __devexit_p(jornada680kbd_remove), 261 .remove = jornada680kbd_remove,
262}; 262};
263module_platform_driver(jornada680kbd_driver); 263module_platform_driver(jornada680kbd_driver);
264 264
diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c
index 9d639fa1afbd..5ceef636df2f 100644
--- a/drivers/input/keyboard/jornada720_kbd.c
+++ b/drivers/input/keyboard/jornada720_kbd.c
@@ -94,7 +94,7 @@ static irqreturn_t jornada720_kbd_interrupt(int irq, void *dev_id)
94 return IRQ_HANDLED; 94 return IRQ_HANDLED;
95}; 95};
96 96
97static int __devinit jornada720_kbd_probe(struct platform_device *pdev) 97static int jornada720_kbd_probe(struct platform_device *pdev)
98{ 98{
99 struct jornadakbd *jornadakbd; 99 struct jornadakbd *jornadakbd;
100 struct input_dev *input_dev; 100 struct input_dev *input_dev;
@@ -152,7 +152,7 @@ static int __devinit jornada720_kbd_probe(struct platform_device *pdev)
152 return err; 152 return err;
153}; 153};
154 154
155static int __devexit jornada720_kbd_remove(struct platform_device *pdev) 155static int jornada720_kbd_remove(struct platform_device *pdev)
156{ 156{
157 struct jornadakbd *jornadakbd = platform_get_drvdata(pdev); 157 struct jornadakbd *jornadakbd = platform_get_drvdata(pdev);
158 158
@@ -173,6 +173,6 @@ static struct platform_driver jornada720_kbd_driver = {
173 .owner = THIS_MODULE, 173 .owner = THIS_MODULE,
174 }, 174 },
175 .probe = jornada720_kbd_probe, 175 .probe = jornada720_kbd_probe,
176 .remove = __devexit_p(jornada720_kbd_remove), 176 .remove = jornada720_kbd_remove,
177}; 177};
178module_platform_driver(jornada720_kbd_driver); 178module_platform_driver(jornada720_kbd_driver);
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index 39ac2787e275..93c812662134 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -624,7 +624,7 @@ static ssize_t lm8323_set_disable(struct device *dev,
624} 624}
625static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable); 625static DEVICE_ATTR(disable_kp, 0644, lm8323_show_disable, lm8323_set_disable);
626 626
627static int __devinit lm8323_probe(struct i2c_client *client, 627static int lm8323_probe(struct i2c_client *client,
628 const struct i2c_device_id *id) 628 const struct i2c_device_id *id)
629{ 629{
630 struct lm8323_platform_data *pdata = client->dev.platform_data; 630 struct lm8323_platform_data *pdata = client->dev.platform_data;
@@ -764,7 +764,7 @@ fail1:
764 return err; 764 return err;
765} 765}
766 766
767static int __devexit lm8323_remove(struct i2c_client *client) 767static int lm8323_remove(struct i2c_client *client)
768{ 768{
769 struct lm8323_chip *lm = i2c_get_clientdata(client); 769 struct lm8323_chip *lm = i2c_get_clientdata(client);
770 int i; 770 int i;
@@ -846,7 +846,7 @@ static struct i2c_driver lm8323_i2c_driver = {
846 .pm = &lm8323_pm_ops, 846 .pm = &lm8323_pm_ops,
847 }, 847 },
848 .probe = lm8323_probe, 848 .probe = lm8323_probe,
849 .remove = __devexit_p(lm8323_remove), 849 .remove = lm8323_remove,
850 .id_table = lm8323_id, 850 .id_table = lm8323_id,
851}; 851};
852MODULE_DEVICE_TABLE(i2c, lm8323_id); 852MODULE_DEVICE_TABLE(i2c, lm8323_id);
diff --git a/drivers/input/keyboard/lm8333.c b/drivers/input/keyboard/lm8333.c
index 081fd9effa8c..5a8ca35dc9af 100644
--- a/drivers/input/keyboard/lm8333.c
+++ b/drivers/input/keyboard/lm8333.c
@@ -128,7 +128,7 @@ static irqreturn_t lm8333_irq_thread(int irq, void *data)
128 return IRQ_HANDLED; 128 return IRQ_HANDLED;
129} 129}
130 130
131static int __devinit lm8333_probe(struct i2c_client *client, 131static int lm8333_probe(struct i2c_client *client,
132 const struct i2c_device_id *id) 132 const struct i2c_device_id *id)
133{ 133{
134 const struct lm8333_platform_data *pdata = client->dev.platform_data; 134 const struct lm8333_platform_data *pdata = client->dev.platform_data;
@@ -202,7 +202,7 @@ static int __devinit lm8333_probe(struct i2c_client *client,
202 return err; 202 return err;
203} 203}
204 204
205static int __devexit lm8333_remove(struct i2c_client *client) 205static int lm8333_remove(struct i2c_client *client)
206{ 206{
207 struct lm8333 *lm8333 = i2c_get_clientdata(client); 207 struct lm8333 *lm8333 = i2c_get_clientdata(client);
208 208
@@ -225,7 +225,7 @@ static struct i2c_driver lm8333_driver = {
225 .owner = THIS_MODULE, 225 .owner = THIS_MODULE,
226 }, 226 },
227 .probe = lm8333_probe, 227 .probe = lm8333_probe,
228 .remove = __devexit_p(lm8333_remove), 228 .remove = lm8333_remove,
229 .id_table = lm8333_id, 229 .id_table = lm8333_id,
230}; 230};
231module_i2c_driver(lm8333_driver); 231module_i2c_driver(lm8333_driver);
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index b1ab29861e1c..c94d610b9d78 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -46,7 +46,7 @@ MODULE_LICENSE("GPL");
46#define KEY_CENTER KEY_F15 46#define KEY_CENTER KEY_F15
47 47
48static const unsigned char 48static const unsigned char
49locomokbd_keycode[LOCOMOKBD_NUMKEYS] __devinitconst = { 49locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
50 0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0, /* 0 - 9 */ 50 0, KEY_ESC, KEY_ACTIVITY, 0, 0, 0, 0, 0, 0, 0, /* 0 - 9 */
51 0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT, /* 10 - 19 */ 51 0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_HOME, KEY_CONTACT, /* 10 - 19 */
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 29 */ 52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 29 */
@@ -236,7 +236,7 @@ static void locomokbd_close(struct input_dev *dev)
236 locomo_writel(r, locomokbd->base + LOCOMO_KIC); 236 locomo_writel(r, locomokbd->base + LOCOMO_KIC);
237} 237}
238 238
239static int __devinit locomokbd_probe(struct locomo_dev *dev) 239static int locomokbd_probe(struct locomo_dev *dev)
240{ 240{
241 struct locomokbd *locomokbd; 241 struct locomokbd *locomokbd;
242 struct input_dev *input_dev; 242 struct input_dev *input_dev;
@@ -321,7 +321,7 @@ static int __devinit locomokbd_probe(struct locomo_dev *dev)
321 return err; 321 return err;
322} 322}
323 323
324static int __devexit locomokbd_remove(struct locomo_dev *dev) 324static int locomokbd_remove(struct locomo_dev *dev)
325{ 325{
326 struct locomokbd *locomokbd = locomo_get_drvdata(dev); 326 struct locomokbd *locomokbd = locomo_get_drvdata(dev);
327 327
@@ -345,7 +345,7 @@ static struct locomo_driver keyboard_driver = {
345 }, 345 },
346 .devid = LOCOMO_DEVID_KEYBOARD, 346 .devid = LOCOMO_DEVID_KEYBOARD,
347 .probe = locomokbd_probe, 347 .probe = locomokbd_probe,
348 .remove = __devexit_p(locomokbd_remove), 348 .remove = locomokbd_remove,
349}; 349};
350 350
351static int __init locomokbd_init(void) 351static int __init locomokbd_init(void)
diff --git a/drivers/input/keyboard/lpc32xx-keys.c b/drivers/input/keyboard/lpc32xx-keys.c
index dd786c8a7584..1b8add6cfb9d 100644
--- a/drivers/input/keyboard/lpc32xx-keys.c
+++ b/drivers/input/keyboard/lpc32xx-keys.c
@@ -139,7 +139,7 @@ static void lpc32xx_kscan_close(struct input_dev *dev)
139 clk_disable_unprepare(kscandat->clk); 139 clk_disable_unprepare(kscandat->clk);
140} 140}
141 141
142static int __devinit lpc32xx_parse_dt(struct device *dev, 142static int lpc32xx_parse_dt(struct device *dev,
143 struct lpc32xx_kscan_drv *kscandat) 143 struct lpc32xx_kscan_drv *kscandat)
144{ 144{
145 struct device_node *np = dev->of_node; 145 struct device_node *np = dev->of_node;
@@ -166,7 +166,7 @@ static int __devinit lpc32xx_parse_dt(struct device *dev,
166 return 0; 166 return 0;
167} 167}
168 168
169static int __devinit lpc32xx_kscan_probe(struct platform_device *pdev) 169static int lpc32xx_kscan_probe(struct platform_device *pdev)
170{ 170{
171 struct lpc32xx_kscan_drv *kscandat; 171 struct lpc32xx_kscan_drv *kscandat;
172 struct input_dev *input; 172 struct input_dev *input;
@@ -310,7 +310,7 @@ err_free_mem:
310 return error; 310 return error;
311} 311}
312 312
313static int __devexit lpc32xx_kscan_remove(struct platform_device *pdev) 313static int lpc32xx_kscan_remove(struct platform_device *pdev)
314{ 314{
315 struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev); 315 struct lpc32xx_kscan_drv *kscandat = platform_get_drvdata(pdev);
316 316
@@ -377,7 +377,7 @@ MODULE_DEVICE_TABLE(of, lpc32xx_kscan_match);
377 377
378static struct platform_driver lpc32xx_kscan_driver = { 378static struct platform_driver lpc32xx_kscan_driver = {
379 .probe = lpc32xx_kscan_probe, 379 .probe = lpc32xx_kscan_probe,
380 .remove = __devexit_p(lpc32xx_kscan_remove), 380 .remove = lpc32xx_kscan_remove,
381 .driver = { 381 .driver = {
382 .name = DRV_NAME, 382 .name = DRV_NAME,
383 .owner = THIS_MODULE, 383 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 18b72372028a..f4ff0dda7597 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -23,6 +23,9 @@
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/input/matrix_keypad.h> 24#include <linux/input/matrix_keypad.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/of.h>
27#include <linux/of_gpio.h>
28#include <linux/of_platform.h>
26 29
27struct matrix_keypad { 30struct matrix_keypad {
28 const struct matrix_keypad_platform_data *pdata; 31 const struct matrix_keypad_platform_data *pdata;
@@ -37,8 +40,6 @@ struct matrix_keypad {
37 bool scan_pending; 40 bool scan_pending;
38 bool stopped; 41 bool stopped;
39 bool gpio_all_disabled; 42 bool gpio_all_disabled;
40
41 unsigned short keycodes[];
42}; 43};
43 44
44/* 45/*
@@ -118,6 +119,7 @@ static void matrix_keypad_scan(struct work_struct *work)
118 struct matrix_keypad *keypad = 119 struct matrix_keypad *keypad =
119 container_of(work, struct matrix_keypad, work.work); 120 container_of(work, struct matrix_keypad, work.work);
120 struct input_dev *input_dev = keypad->input_dev; 121 struct input_dev *input_dev = keypad->input_dev;
122 const unsigned short *keycodes = input_dev->keycode;
121 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 123 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
122 uint32_t new_state[MATRIX_MAX_COLS]; 124 uint32_t new_state[MATRIX_MAX_COLS];
123 int row, col, code; 125 int row, col, code;
@@ -153,7 +155,7 @@ static void matrix_keypad_scan(struct work_struct *work)
153 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift); 155 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift);
154 input_event(input_dev, EV_MSC, MSC_SCAN, code); 156 input_event(input_dev, EV_MSC, MSC_SCAN, code);
155 input_report_key(input_dev, 157 input_report_key(input_dev,
156 keypad->keycodes[code], 158 keycodes[code],
157 new_state[col] & (1 << row)); 159 new_state[col] & (1 << row));
158 } 160 }
159 } 161 }
@@ -299,8 +301,8 @@ static int matrix_keypad_resume(struct device *dev)
299static SIMPLE_DEV_PM_OPS(matrix_keypad_pm_ops, 301static SIMPLE_DEV_PM_OPS(matrix_keypad_pm_ops,
300 matrix_keypad_suspend, matrix_keypad_resume); 302 matrix_keypad_suspend, matrix_keypad_resume);
301 303
302static int __devinit matrix_keypad_init_gpio(struct platform_device *pdev, 304static int matrix_keypad_init_gpio(struct platform_device *pdev,
303 struct matrix_keypad *keypad) 305 struct matrix_keypad *keypad)
304{ 306{
305 const struct matrix_keypad_platform_data *pdata = keypad->pdata; 307 const struct matrix_keypad_platform_data *pdata = keypad->pdata;
306 int i, err; 308 int i, err;
@@ -394,33 +396,95 @@ static void matrix_keypad_free_gpio(struct matrix_keypad *keypad)
394 gpio_free(pdata->col_gpios[i]); 396 gpio_free(pdata->col_gpios[i]);
395} 397}
396 398
397static int __devinit matrix_keypad_probe(struct platform_device *pdev) 399#ifdef CONFIG_OF
400static struct matrix_keypad_platform_data *
401matrix_keypad_parse_dt(struct device *dev)
402{
403 struct matrix_keypad_platform_data *pdata;
404 struct device_node *np = dev->of_node;
405 unsigned int *gpios;
406 int i;
407
408 if (!np) {
409 dev_err(dev, "device lacks DT data\n");
410 return ERR_PTR(-ENODEV);
411 }
412
413 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
414 if (!pdata) {
415 dev_err(dev, "could not allocate memory for platform data\n");
416 return ERR_PTR(-ENOMEM);
417 }
418
419 pdata->num_row_gpios = of_gpio_named_count(np, "row-gpios");
420 pdata->num_col_gpios = of_gpio_named_count(np, "col-gpios");
421 if (!pdata->num_row_gpios || !pdata->num_col_gpios) {
422 dev_err(dev, "number of keypad rows/columns not specified\n");
423 return ERR_PTR(-EINVAL);
424 }
425
426 if (of_get_property(np, "linux,no-autorepeat", NULL))
427 pdata->no_autorepeat = true;
428 if (of_get_property(np, "linux,wakeup", NULL))
429 pdata->wakeup = true;
430 if (of_get_property(np, "gpio-activelow", NULL))
431 pdata->active_low = true;
432
433 of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms);
434 of_property_read_u32(np, "col-scan-delay-us",
435 &pdata->col_scan_delay_us);
436
437 gpios = devm_kzalloc(dev,
438 sizeof(unsigned int) *
439 (pdata->num_row_gpios + pdata->num_col_gpios),
440 GFP_KERNEL);
441 if (!gpios) {
442 dev_err(dev, "could not allocate memory for gpios\n");
443 return ERR_PTR(-ENOMEM);
444 }
445
446 for (i = 0; i < pdata->num_row_gpios; i++)
447 gpios[i] = of_get_named_gpio(np, "row-gpios", i);
448
449 for (i = 0; i < pdata->num_col_gpios; i++)
450 gpios[pdata->num_row_gpios + i] =
451 of_get_named_gpio(np, "col-gpios", i);
452
453 pdata->row_gpios = gpios;
454 pdata->col_gpios = &gpios[pdata->num_row_gpios];
455
456 return pdata;
457}
458#else
459static inline struct matrix_keypad_platform_data *
460matrix_keypad_parse_dt(struct device *dev)
461{
462 dev_err(dev, "no platform data defined\n");
463
464 return ERR_PTR(-EINVAL);
465}
466#endif
467
468static int matrix_keypad_probe(struct platform_device *pdev)
398{ 469{
399 const struct matrix_keypad_platform_data *pdata; 470 const struct matrix_keypad_platform_data *pdata;
400 const struct matrix_keymap_data *keymap_data;
401 struct matrix_keypad *keypad; 471 struct matrix_keypad *keypad;
402 struct input_dev *input_dev; 472 struct input_dev *input_dev;
403 unsigned int row_shift;
404 size_t keymap_size;
405 int err; 473 int err;
406 474
407 pdata = pdev->dev.platform_data; 475 pdata = dev_get_platdata(&pdev->dev);
408 if (!pdata) { 476 if (!pdata) {
409 dev_err(&pdev->dev, "no platform data defined\n"); 477 pdata = matrix_keypad_parse_dt(&pdev->dev);
410 return -EINVAL; 478 if (IS_ERR(pdata)) {
411 } 479 dev_err(&pdev->dev, "no platform data defined\n");
412 480 return PTR_ERR(pdata);
413 keymap_data = pdata->keymap_data; 481 }
414 if (!keymap_data) { 482 } else if (!pdata->keymap_data) {
415 dev_err(&pdev->dev, "no keymap data defined\n"); 483 dev_err(&pdev->dev, "no keymap data defined\n");
416 return -EINVAL; 484 return -EINVAL;
417 } 485 }
418 486
419 row_shift = get_count_order(pdata->num_col_gpios); 487 keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL);
420 keymap_size = (pdata->num_row_gpios << row_shift) *
421 sizeof(keypad->keycodes[0]);
422 keypad = kzalloc(sizeof(struct matrix_keypad) + keymap_size,
423 GFP_KERNEL);
424 input_dev = input_allocate_device(); 488 input_dev = input_allocate_device();
425 if (!keypad || !input_dev) { 489 if (!keypad || !input_dev) {
426 err = -ENOMEM; 490 err = -ENOMEM;
@@ -429,7 +493,7 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
429 493
430 keypad->input_dev = input_dev; 494 keypad->input_dev = input_dev;
431 keypad->pdata = pdata; 495 keypad->pdata = pdata;
432 keypad->row_shift = row_shift; 496 keypad->row_shift = get_count_order(pdata->num_col_gpios);
433 keypad->stopped = true; 497 keypad->stopped = true;
434 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan); 498 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
435 spin_lock_init(&keypad->lock); 499 spin_lock_init(&keypad->lock);
@@ -440,12 +504,14 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
440 input_dev->open = matrix_keypad_start; 504 input_dev->open = matrix_keypad_start;
441 input_dev->close = matrix_keypad_stop; 505 input_dev->close = matrix_keypad_stop;
442 506
443 err = matrix_keypad_build_keymap(keymap_data, NULL, 507 err = matrix_keypad_build_keymap(pdata->keymap_data, NULL,
444 pdata->num_row_gpios, 508 pdata->num_row_gpios,
445 pdata->num_col_gpios, 509 pdata->num_col_gpios,
446 keypad->keycodes, input_dev); 510 NULL, input_dev);
447 if (err) 511 if (err) {
512 dev_err(&pdev->dev, "failed to build keymap\n");
448 goto err_free_mem; 513 goto err_free_mem;
514 }
449 515
450 if (!pdata->no_autorepeat) 516 if (!pdata->no_autorepeat)
451 __set_bit(EV_REP, input_dev->evbit); 517 __set_bit(EV_REP, input_dev->evbit);
@@ -473,7 +539,7 @@ err_free_mem:
473 return err; 539 return err;
474} 540}
475 541
476static int __devexit matrix_keypad_remove(struct platform_device *pdev) 542static int matrix_keypad_remove(struct platform_device *pdev)
477{ 543{
478 struct matrix_keypad *keypad = platform_get_drvdata(pdev); 544 struct matrix_keypad *keypad = platform_get_drvdata(pdev);
479 545
@@ -488,13 +554,22 @@ static int __devexit matrix_keypad_remove(struct platform_device *pdev)
488 return 0; 554 return 0;
489} 555}
490 556
557#ifdef CONFIG_OF
558static const struct of_device_id matrix_keypad_dt_match[] = {
559 { .compatible = "gpio-matrix-keypad" },
560 { }
561};
562MODULE_DEVICE_TABLE(of, matrix_keypad_dt_match);
563#endif
564
491static struct platform_driver matrix_keypad_driver = { 565static struct platform_driver matrix_keypad_driver = {
492 .probe = matrix_keypad_probe, 566 .probe = matrix_keypad_probe,
493 .remove = __devexit_p(matrix_keypad_remove), 567 .remove = matrix_keypad_remove,
494 .driver = { 568 .driver = {
495 .name = "matrix-keypad", 569 .name = "matrix-keypad",
496 .owner = THIS_MODULE, 570 .owner = THIS_MODULE,
497 .pm = &matrix_keypad_pm_ops, 571 .pm = &matrix_keypad_pm_ops,
572 .of_match_table = of_match_ptr(matrix_keypad_dt_match),
498 }, 573 },
499}; 574};
500module_platform_driver(matrix_keypad_driver); 575module_platform_driver(matrix_keypad_driver);
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 8edada8ae712..7c7af2b01e65 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -179,7 +179,7 @@ static void max7359_initialize(struct i2c_client *client)
179 max7359_fall_deepsleep(client); 179 max7359_fall_deepsleep(client);
180} 180}
181 181
182static int __devinit max7359_probe(struct i2c_client *client, 182static int max7359_probe(struct i2c_client *client,
183 const struct i2c_device_id *id) 183 const struct i2c_device_id *id)
184{ 184{
185 const struct matrix_keymap_data *keymap_data = client->dev.platform_data; 185 const struct matrix_keymap_data *keymap_data = client->dev.platform_data;
@@ -260,7 +260,7 @@ failed_free_mem:
260 return error; 260 return error;
261} 261}
262 262
263static int __devexit max7359_remove(struct i2c_client *client) 263static int max7359_remove(struct i2c_client *client)
264{ 264{
265 struct max7359_keypad *keypad = i2c_get_clientdata(client); 265 struct max7359_keypad *keypad = i2c_get_clientdata(client);
266 266
@@ -312,7 +312,7 @@ static struct i2c_driver max7359_i2c_driver = {
312 .pm = &max7359_pm, 312 .pm = &max7359_pm,
313 }, 313 },
314 .probe = max7359_probe, 314 .probe = max7359_probe,
315 .remove = __devexit_p(max7359_remove), 315 .remove = max7359_remove,
316 .id_table = max7359_ids, 316 .id_table = max7359_ids,
317}; 317};
318 318
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index 0d77f6c84950..7c236f9c6a51 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -97,7 +97,7 @@ static irqreturn_t mcs_touchkey_interrupt(int irq, void *dev_id)
97 return IRQ_HANDLED; 97 return IRQ_HANDLED;
98} 98}
99 99
100static int __devinit mcs_touchkey_probe(struct i2c_client *client, 100static int mcs_touchkey_probe(struct i2c_client *client,
101 const struct i2c_device_id *id) 101 const struct i2c_device_id *id)
102{ 102{
103 const struct mcs_platform_data *pdata; 103 const struct mcs_platform_data *pdata;
@@ -200,7 +200,7 @@ err_free_mem:
200 return error; 200 return error;
201} 201}
202 202
203static int __devexit mcs_touchkey_remove(struct i2c_client *client) 203static int mcs_touchkey_remove(struct i2c_client *client)
204{ 204{
205 struct mcs_touchkey_data *data = i2c_get_clientdata(client); 205 struct mcs_touchkey_data *data = i2c_get_clientdata(client);
206 206
@@ -270,7 +270,7 @@ static struct i2c_driver mcs_touchkey_driver = {
270 .pm = &mcs_touchkey_pm_ops, 270 .pm = &mcs_touchkey_pm_ops,
271 }, 271 },
272 .probe = mcs_touchkey_probe, 272 .probe = mcs_touchkey_probe,
273 .remove = __devexit_p(mcs_touchkey_remove), 273 .remove = mcs_touchkey_remove,
274 .shutdown = mcs_touchkey_shutdown, 274 .shutdown = mcs_touchkey_shutdown,
275 .id_table = mcs_touchkey_id, 275 .id_table = mcs_touchkey_id,
276}; 276};
diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c
index 7613f1cac951..f7f3e9a9fd3f 100644
--- a/drivers/input/keyboard/mpr121_touchkey.c
+++ b/drivers/input/keyboard/mpr121_touchkey.c
@@ -71,7 +71,7 @@ struct mpr121_init_register {
71 u8 val; 71 u8 val;
72}; 72};
73 73
74static const struct mpr121_init_register init_reg_table[] __devinitconst = { 74static const struct mpr121_init_register init_reg_table[] = {
75 { MHD_RISING_ADDR, 0x1 }, 75 { MHD_RISING_ADDR, 0x1 },
76 { NHD_RISING_ADDR, 0x1 }, 76 { NHD_RISING_ADDR, 0x1 },
77 { MHD_FALLING_ADDR, 0x1 }, 77 { MHD_FALLING_ADDR, 0x1 },
@@ -123,7 +123,7 @@ out:
123 return IRQ_HANDLED; 123 return IRQ_HANDLED;
124} 124}
125 125
126static int __devinit mpr121_phys_init(const struct mpr121_platform_data *pdata, 126static int mpr121_phys_init(const struct mpr121_platform_data *pdata,
127 struct mpr121_touchkey *mpr121, 127 struct mpr121_touchkey *mpr121,
128 struct i2c_client *client) 128 struct i2c_client *client)
129{ 129{
@@ -185,8 +185,8 @@ err_i2c_write:
185 return ret; 185 return ret;
186} 186}
187 187
188static int __devinit mpr_touchkey_probe(struct i2c_client *client, 188static int mpr_touchkey_probe(struct i2c_client *client,
189 const struct i2c_device_id *id) 189 const struct i2c_device_id *id)
190{ 190{
191 const struct mpr121_platform_data *pdata = client->dev.platform_data; 191 const struct mpr121_platform_data *pdata = client->dev.platform_data;
192 struct mpr121_touchkey *mpr121; 192 struct mpr121_touchkey *mpr121;
@@ -272,7 +272,7 @@ err_free_mem:
272 return error; 272 return error;
273} 273}
274 274
275static int __devexit mpr_touchkey_remove(struct i2c_client *client) 275static int mpr_touchkey_remove(struct i2c_client *client)
276{ 276{
277 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client); 277 struct mpr121_touchkey *mpr121 = i2c_get_clientdata(client);
278 278
@@ -327,7 +327,7 @@ static struct i2c_driver mpr_touchkey_driver = {
327 }, 327 },
328 .id_table = mpr121_id, 328 .id_table = mpr121_id,
329 .probe = mpr_touchkey_probe, 329 .probe = mpr_touchkey_probe,
330 .remove = __devexit_p(mpr_touchkey_remove), 330 .remove = mpr_touchkey_remove,
331}; 331};
332 332
333module_i2c_driver(mpr_touchkey_driver); 333module_i2c_driver(mpr_touchkey_driver);
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index 49f5fa64e0b1..0e6a8151fee3 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -67,6 +67,7 @@ struct ske_keypad {
67 const struct ske_keypad_platform_data *board; 67 const struct ske_keypad_platform_data *board;
68 unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS]; 68 unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS];
69 struct clk *clk; 69 struct clk *clk;
70 struct clk *pclk;
70 spinlock_t ske_keypad_lock; 71 spinlock_t ske_keypad_lock;
71}; 72};
72 73
@@ -271,11 +272,18 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
271 goto err_free_mem_region; 272 goto err_free_mem_region;
272 } 273 }
273 274
275 keypad->pclk = clk_get(&pdev->dev, "apb_pclk");
276 if (IS_ERR(keypad->pclk)) {
277 dev_err(&pdev->dev, "failed to get pclk\n");
278 error = PTR_ERR(keypad->pclk);
279 goto err_iounmap;
280 }
281
274 keypad->clk = clk_get(&pdev->dev, NULL); 282 keypad->clk = clk_get(&pdev->dev, NULL);
275 if (IS_ERR(keypad->clk)) { 283 if (IS_ERR(keypad->clk)) {
276 dev_err(&pdev->dev, "failed to get clk\n"); 284 dev_err(&pdev->dev, "failed to get clk\n");
277 error = PTR_ERR(keypad->clk); 285 error = PTR_ERR(keypad->clk);
278 goto err_iounmap; 286 goto err_pclk;
279 } 287 }
280 288
281 input->id.bustype = BUS_HOST; 289 input->id.bustype = BUS_HOST;
@@ -287,14 +295,25 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
287 keypad->keymap, input); 295 keypad->keymap, input);
288 if (error) { 296 if (error) {
289 dev_err(&pdev->dev, "Failed to build keymap\n"); 297 dev_err(&pdev->dev, "Failed to build keymap\n");
290 goto err_iounmap; 298 goto err_clk;
291 } 299 }
292 300
293 input_set_capability(input, EV_MSC, MSC_SCAN); 301 input_set_capability(input, EV_MSC, MSC_SCAN);
294 if (!plat->no_autorepeat) 302 if (!plat->no_autorepeat)
295 __set_bit(EV_REP, input->evbit); 303 __set_bit(EV_REP, input->evbit);
296 304
297 clk_enable(keypad->clk); 305 error = clk_prepare_enable(keypad->pclk);
306 if (error) {
307 dev_err(&pdev->dev, "Failed to prepare/enable pclk\n");
308 goto err_clk;
309 }
310
311 error = clk_prepare_enable(keypad->clk);
312 if (error) {
313 dev_err(&pdev->dev, "Failed to prepare/enable clk\n");
314 goto err_pclk_disable;
315 }
316
298 317
299 /* go through board initialization helpers */ 318 /* go through board initialization helpers */
300 if (keypad->board->init) 319 if (keypad->board->init)
@@ -330,8 +349,13 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
330err_free_irq: 349err_free_irq:
331 free_irq(keypad->irq, keypad); 350 free_irq(keypad->irq, keypad);
332err_clk_disable: 351err_clk_disable:
333 clk_disable(keypad->clk); 352 clk_disable_unprepare(keypad->clk);
353err_pclk_disable:
354 clk_disable_unprepare(keypad->pclk);
355err_clk:
334 clk_put(keypad->clk); 356 clk_put(keypad->clk);
357err_pclk:
358 clk_put(keypad->pclk);
335err_iounmap: 359err_iounmap:
336 iounmap(keypad->reg_base); 360 iounmap(keypad->reg_base);
337err_free_mem_region: 361err_free_mem_region:
@@ -342,7 +366,7 @@ err_free_mem:
342 return error; 366 return error;
343} 367}
344 368
345static int __devexit ske_keypad_remove(struct platform_device *pdev) 369static int ske_keypad_remove(struct platform_device *pdev)
346{ 370{
347 struct ske_keypad *keypad = platform_get_drvdata(pdev); 371 struct ske_keypad *keypad = platform_get_drvdata(pdev);
348 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 372 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -351,7 +375,7 @@ static int __devexit ske_keypad_remove(struct platform_device *pdev)
351 375
352 input_unregister_device(keypad->input); 376 input_unregister_device(keypad->input);
353 377
354 clk_disable(keypad->clk); 378 clk_disable_unprepare(keypad->clk);
355 clk_put(keypad->clk); 379 clk_put(keypad->clk);
356 380
357 if (keypad->board->exit) 381 if (keypad->board->exit)
@@ -403,7 +427,7 @@ static struct platform_driver ske_keypad_driver = {
403 .owner = THIS_MODULE, 427 .owner = THIS_MODULE,
404 .pm = &ske_keypad_dev_pm_ops, 428 .pm = &ske_keypad_dev_pm_ops,
405 }, 429 },
406 .remove = __devexit_p(ske_keypad_remove), 430 .remove = ske_keypad_remove,
407}; 431};
408 432
409static int __init ske_keypad_init(void) 433static int __init ske_keypad_init(void)
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 4a5fcc8026f5..d0d5226d9cd4 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -244,7 +244,7 @@ static int omap_kp_resume(struct platform_device *dev)
244#define omap_kp_resume NULL 244#define omap_kp_resume NULL
245#endif 245#endif
246 246
247static int __devinit omap_kp_probe(struct platform_device *pdev) 247static int omap_kp_probe(struct platform_device *pdev)
248{ 248{
249 struct omap_kp *omap_kp; 249 struct omap_kp *omap_kp;
250 struct input_dev *input_dev; 250 struct input_dev *input_dev;
@@ -357,7 +357,7 @@ err2:
357 return -EINVAL; 357 return -EINVAL;
358} 358}
359 359
360static int __devexit omap_kp_remove(struct platform_device *pdev) 360static int omap_kp_remove(struct platform_device *pdev)
361{ 361{
362 struct omap_kp *omap_kp = platform_get_drvdata(pdev); 362 struct omap_kp *omap_kp = platform_get_drvdata(pdev);
363 363
@@ -379,7 +379,7 @@ static int __devexit omap_kp_remove(struct platform_device *pdev)
379 379
380static struct platform_driver omap_kp_driver = { 380static struct platform_driver omap_kp_driver = {
381 .probe = omap_kp_probe, 381 .probe = omap_kp_probe,
382 .remove = __devexit_p(omap_kp_remove), 382 .remove = omap_kp_remove,
383 .suspend = omap_kp_suspend, 383 .suspend = omap_kp_suspend,
384 .resume = omap_kp_resume, 384 .resume = omap_kp_resume,
385 .driver = { 385 .driver = {
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index c05f98c41410..e25b022692cd 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -211,8 +211,8 @@ static void omap4_keypad_close(struct input_dev *input)
211} 211}
212 212
213#ifdef CONFIG_OF 213#ifdef CONFIG_OF
214static int __devinit omap4_keypad_parse_dt(struct device *dev, 214static int omap4_keypad_parse_dt(struct device *dev,
215 struct omap4_keypad *keypad_data) 215 struct omap4_keypad *keypad_data)
216{ 216{
217 struct device_node *np = dev->of_node; 217 struct device_node *np = dev->of_node;
218 218
@@ -241,7 +241,7 @@ static inline int omap4_keypad_parse_dt(struct device *dev,
241} 241}
242#endif 242#endif
243 243
244static int __devinit omap4_keypad_probe(struct platform_device *pdev) 244static int omap4_keypad_probe(struct platform_device *pdev)
245{ 245{
246 const struct omap4_keypad_platform_data *pdata = 246 const struct omap4_keypad_platform_data *pdata =
247 dev_get_platdata(&pdev->dev); 247 dev_get_platdata(&pdev->dev);
@@ -406,7 +406,7 @@ err_free_keypad:
406 return error; 406 return error;
407} 407}
408 408
409static int __devexit omap4_keypad_remove(struct platform_device *pdev) 409static int omap4_keypad_remove(struct platform_device *pdev)
410{ 410{
411 struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); 411 struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);
412 struct resource *res; 412 struct resource *res;
@@ -440,7 +440,7 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
440 440
441static struct platform_driver omap4_keypad_driver = { 441static struct platform_driver omap4_keypad_driver = {
442 .probe = omap4_keypad_probe, 442 .probe = omap4_keypad_probe,
443 .remove = __devexit_p(omap4_keypad_remove), 443 .remove = omap4_keypad_remove,
444 .driver = { 444 .driver = {
445 .name = "omap4-keypad", 445 .name = "omap4-keypad",
446 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index abe728c7b88e..7ac5f174c6f7 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -37,7 +37,7 @@ static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
37 return IRQ_HANDLED; 37 return IRQ_HANDLED;
38} 38}
39 39
40static int __devinit opencores_kbd_probe(struct platform_device *pdev) 40static int opencores_kbd_probe(struct platform_device *pdev)
41{ 41{
42 struct input_dev *input; 42 struct input_dev *input;
43 struct opencores_kbd *opencores_kbd; 43 struct opencores_kbd *opencores_kbd;
@@ -139,7 +139,7 @@ static int __devinit opencores_kbd_probe(struct platform_device *pdev)
139 return error; 139 return error;
140} 140}
141 141
142static int __devexit opencores_kbd_remove(struct platform_device *pdev) 142static int opencores_kbd_remove(struct platform_device *pdev)
143{ 143{
144 struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev); 144 struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
145 145
@@ -158,7 +158,7 @@ static int __devexit opencores_kbd_remove(struct platform_device *pdev)
158 158
159static struct platform_driver opencores_kbd_device_driver = { 159static struct platform_driver opencores_kbd_device_driver = {
160 .probe = opencores_kbd_probe, 160 .probe = opencores_kbd_probe,
161 .remove = __devexit_p(opencores_kbd_remove), 161 .remove = opencores_kbd_remove,
162 .driver = { 162 .driver = {
163 .name = "opencores-kbd", 163 .name = "opencores-kbd",
164 }, 164 },
diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c b/drivers/input/keyboard/pmic8xxx-keypad.c
index 52c34657d301..74339e139d43 100644
--- a/drivers/input/keyboard/pmic8xxx-keypad.c
+++ b/drivers/input/keyboard/pmic8xxx-keypad.c
@@ -397,7 +397,7 @@ static irqreturn_t pmic8xxx_kp_irq(int irq, void *data)
397 return IRQ_HANDLED; 397 return IRQ_HANDLED;
398} 398}
399 399
400static int __devinit pmic8xxx_kpd_init(struct pmic8xxx_kp *kp) 400static int pmic8xxx_kpd_init(struct pmic8xxx_kp *kp)
401{ 401{
402 int bits, rc, cycles; 402 int bits, rc, cycles;
403 u8 scan_val = 0, ctrl_val = 0; 403 u8 scan_val = 0, ctrl_val = 0;
@@ -447,7 +447,7 @@ static int __devinit pmic8xxx_kpd_init(struct pmic8xxx_kp *kp)
447 447
448} 448}
449 449
450static int __devinit pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios, 450static int pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios,
451 struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config) 451 struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config)
452{ 452{
453 int rc, i; 453 int rc, i;
@@ -518,7 +518,7 @@ static void pmic8xxx_kp_close(struct input_dev *dev)
518 * - set irq edge type. 518 * - set irq edge type.
519 * - enable the keypad controller. 519 * - enable the keypad controller.
520 */ 520 */
521static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev) 521static int pmic8xxx_kp_probe(struct platform_device *pdev)
522{ 522{
523 const struct pm8xxx_keypad_platform_data *pdata = 523 const struct pm8xxx_keypad_platform_data *pdata =
524 dev_get_platdata(&pdev->dev); 524 dev_get_platdata(&pdev->dev);
@@ -712,7 +712,7 @@ err_alloc_device:
712 return rc; 712 return rc;
713} 713}
714 714
715static int __devexit pmic8xxx_kp_remove(struct platform_device *pdev) 715static int pmic8xxx_kp_remove(struct platform_device *pdev)
716{ 716{
717 struct pmic8xxx_kp *kp = platform_get_drvdata(pdev); 717 struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
718 718
@@ -773,7 +773,7 @@ static SIMPLE_DEV_PM_OPS(pm8xxx_kp_pm_ops,
773 773
774static struct platform_driver pmic8xxx_kp_driver = { 774static struct platform_driver pmic8xxx_kp_driver = {
775 .probe = pmic8xxx_kp_probe, 775 .probe = pmic8xxx_kp_probe,
776 .remove = __devexit_p(pmic8xxx_kp_remove), 776 .remove = pmic8xxx_kp_remove,
777 .driver = { 777 .driver = {
778 .name = PM8XXX_KEYPAD_DEV_NAME, 778 .name = PM8XXX_KEYPAD_DEV_NAME,
779 .owner = THIS_MODULE, 779 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index cad9d5dd5973..5330d8fbf6c0 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -482,7 +482,7 @@ static const struct dev_pm_ops pxa27x_keypad_pm_ops = {
482}; 482};
483#endif 483#endif
484 484
485static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) 485static int pxa27x_keypad_probe(struct platform_device *pdev)
486{ 486{
487 struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data; 487 struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data;
488 struct pxa27x_keypad *keypad; 488 struct pxa27x_keypad *keypad;
@@ -595,7 +595,7 @@ failed_free:
595 return error; 595 return error;
596} 596}
597 597
598static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) 598static int pxa27x_keypad_remove(struct platform_device *pdev)
599{ 599{
600 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); 600 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev);
601 struct resource *res; 601 struct resource *res;
@@ -620,7 +620,7 @@ MODULE_ALIAS("platform:pxa27x-keypad");
620 620
621static struct platform_driver pxa27x_keypad_driver = { 621static struct platform_driver pxa27x_keypad_driver = {
622 .probe = pxa27x_keypad_probe, 622 .probe = pxa27x_keypad_probe,
623 .remove = __devexit_p(pxa27x_keypad_remove), 623 .remove = pxa27x_keypad_remove,
624 .driver = { 624 .driver = {
625 .name = "pxa27x-keypad", 625 .name = "pxa27x-keypad",
626 .owner = THIS_MODULE, 626 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/pxa930_rotary.c b/drivers/input/keyboard/pxa930_rotary.c
index 41488f9add20..bcad95be73aa 100644
--- a/drivers/input/keyboard/pxa930_rotary.c
+++ b/drivers/input/keyboard/pxa930_rotary.c
@@ -82,7 +82,7 @@ static void pxa930_rotary_close(struct input_dev *dev)
82 clear_sbcr(r); 82 clear_sbcr(r);
83} 83}
84 84
85static int __devinit pxa930_rotary_probe(struct platform_device *pdev) 85static int pxa930_rotary_probe(struct platform_device *pdev)
86{ 86{
87 struct pxa930_rotary_platform_data *pdata = pdev->dev.platform_data; 87 struct pxa930_rotary_platform_data *pdata = pdev->dev.platform_data;
88 struct pxa930_rotary *r; 88 struct pxa930_rotary *r;
@@ -174,7 +174,7 @@ failed_free:
174 return err; 174 return err;
175} 175}
176 176
177static int __devexit pxa930_rotary_remove(struct platform_device *pdev) 177static int pxa930_rotary_remove(struct platform_device *pdev)
178{ 178{
179 struct pxa930_rotary *r = platform_get_drvdata(pdev); 179 struct pxa930_rotary *r = platform_get_drvdata(pdev);
180 180
@@ -193,7 +193,7 @@ static struct platform_driver pxa930_rotary_driver = {
193 .owner = THIS_MODULE, 193 .owner = THIS_MODULE,
194 }, 194 },
195 .probe = pxa930_rotary_probe, 195 .probe = pxa930_rotary_probe,
196 .remove = __devexit_p(pxa930_rotary_remove), 196 .remove = pxa930_rotary_remove,
197}; 197};
198module_platform_driver(pxa930_rotary_driver); 198module_platform_driver(pxa930_rotary_driver);
199 199
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
index ca68f2992d72..42b773b3125a 100644
--- a/drivers/input/keyboard/qt1070.c
+++ b/drivers/input/keyboard/qt1070.c
@@ -91,7 +91,7 @@ static int qt1070_write(struct i2c_client *client, u8 reg, u8 data)
91 return ret; 91 return ret;
92} 92}
93 93
94static bool __devinit qt1070_identify(struct i2c_client *client) 94static bool qt1070_identify(struct i2c_client *client)
95{ 95{
96 int id, ver; 96 int id, ver;
97 97
@@ -140,7 +140,7 @@ static irqreturn_t qt1070_interrupt(int irq, void *dev_id)
140 return IRQ_HANDLED; 140 return IRQ_HANDLED;
141} 141}
142 142
143static int __devinit qt1070_probe(struct i2c_client *client, 143static int qt1070_probe(struct i2c_client *client,
144 const struct i2c_device_id *id) 144 const struct i2c_device_id *id)
145{ 145{
146 struct qt1070_data *data; 146 struct qt1070_data *data;
@@ -230,7 +230,7 @@ err_free_mem:
230 return err; 230 return err;
231} 231}
232 232
233static int __devexit qt1070_remove(struct i2c_client *client) 233static int qt1070_remove(struct i2c_client *client)
234{ 234{
235 struct qt1070_data *data = i2c_get_clientdata(client); 235 struct qt1070_data *data = i2c_get_clientdata(client);
236 236
@@ -256,7 +256,7 @@ static struct i2c_driver qt1070_driver = {
256 }, 256 },
257 .id_table = qt1070_id, 257 .id_table = qt1070_id,
258 .probe = qt1070_probe, 258 .probe = qt1070_probe,
259 .remove = __devexit_p(qt1070_remove), 259 .remove = qt1070_remove,
260}; 260};
261 261
262module_i2c_driver(qt1070_driver); 262module_i2c_driver(qt1070_driver);
diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 76b7d430d03a..3dc2b0f27b0c 100644
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -183,7 +183,7 @@ static void qt2160_worker(struct work_struct *work)
183 qt2160_schedule_read(qt2160); 183 qt2160_schedule_read(qt2160);
184} 184}
185 185
186static int __devinit qt2160_read(struct i2c_client *client, u8 reg) 186static int qt2160_read(struct i2c_client *client, u8 reg)
187{ 187{
188 int ret; 188 int ret;
189 189
@@ -204,29 +204,20 @@ static int __devinit qt2160_read(struct i2c_client *client, u8 reg)
204 return ret; 204 return ret;
205} 205}
206 206
207static int __devinit qt2160_write(struct i2c_client *client, u8 reg, u8 data) 207static int qt2160_write(struct i2c_client *client, u8 reg, u8 data)
208{ 208{
209 int error; 209 int ret;
210
211 error = i2c_smbus_write_byte(client, reg);
212 if (error) {
213 dev_err(&client->dev,
214 "couldn't send request. Returned %d\n", error);
215 return error;
216 }
217 210
218 error = i2c_smbus_write_byte(client, data); 211 ret = i2c_smbus_write_byte_data(client, reg, data);
219 if (error) { 212 if (ret < 0)
220 dev_err(&client->dev, 213 dev_err(&client->dev,
221 "couldn't write data. Returned %d\n", error); 214 "couldn't write data. Returned %d\n", ret);
222 return error;
223 }
224 215
225 return error; 216 return ret;
226} 217}
227 218
228 219
229static bool __devinit qt2160_identify(struct i2c_client *client) 220static bool qt2160_identify(struct i2c_client *client)
230{ 221{
231 int id, ver, rev; 222 int id, ver, rev;
232 223
@@ -257,7 +248,7 @@ static bool __devinit qt2160_identify(struct i2c_client *client)
257 return true; 248 return true;
258} 249}
259 250
260static int __devinit qt2160_probe(struct i2c_client *client, 251static int qt2160_probe(struct i2c_client *client,
261 const struct i2c_device_id *id) 252 const struct i2c_device_id *id)
262{ 253{
263 struct qt2160_data *qt2160; 254 struct qt2160_data *qt2160;
@@ -344,7 +335,7 @@ err_free_mem:
344 return error; 335 return error;
345} 336}
346 337
347static int __devexit qt2160_remove(struct i2c_client *client) 338static int qt2160_remove(struct i2c_client *client)
348{ 339{
349 struct qt2160_data *qt2160 = i2c_get_clientdata(client); 340 struct qt2160_data *qt2160 = i2c_get_clientdata(client);
350 341
@@ -375,7 +366,7 @@ static struct i2c_driver qt2160_driver = {
375 366
376 .id_table = qt2160_idtable, 367 .id_table = qt2160_idtable,
377 .probe = qt2160_probe, 368 .probe = qt2160_probe,
378 .remove = __devexit_p(qt2160_remove), 369 .remove = qt2160_remove,
379}; 370};
380 371
381module_i2c_driver(qt2160_driver); 372module_i2c_driver(qt2160_driver);
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 9d7a111486f7..22e357b51024 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -309,7 +309,7 @@ static void samsung_keypad_parse_dt_gpio(struct device *dev,
309 struct samsung_keypad *keypad) 309 struct samsung_keypad *keypad)
310{ 310{
311 struct device_node *np = dev->of_node; 311 struct device_node *np = dev->of_node;
312 int gpio, ret, row, col; 312 int gpio, error, row, col;
313 313
314 for (row = 0; row < keypad->rows; row++) { 314 for (row = 0; row < keypad->rows; row++) {
315 gpio = of_get_named_gpio(np, "row-gpios", row); 315 gpio = of_get_named_gpio(np, "row-gpios", row);
@@ -320,10 +320,11 @@ static void samsung_keypad_parse_dt_gpio(struct device *dev,
320 continue; 320 continue;
321 } 321 }
322 322
323 ret = gpio_request(gpio, "keypad-row"); 323 error = devm_gpio_request(dev, gpio, "keypad-row");
324 if (ret) 324 if (error)
325 dev_err(dev, "keypad row[%d] gpio request failed\n", 325 dev_err(dev,
326 row); 326 "keypad row[%d] gpio request failed: %d\n",
327 row, error);
327 } 328 }
328 329
329 for (col = 0; col < keypad->cols; col++) { 330 for (col = 0; col < keypad->cols; col++) {
@@ -335,38 +336,22 @@ static void samsung_keypad_parse_dt_gpio(struct device *dev,
335 continue; 336 continue;
336 } 337 }
337 338
338 ret = gpio_request(gpio, "keypad-col"); 339 error = devm_gpio_request(dev, gpio, "keypad-col");
339 if (ret) 340 if (error)
340 dev_err(dev, "keypad column[%d] gpio request failed\n", 341 dev_err(dev,
341 col); 342 "keypad column[%d] gpio request failed: %d\n",
343 col, error);
342 } 344 }
343} 345}
344
345static void samsung_keypad_dt_gpio_free(struct samsung_keypad *keypad)
346{
347 int cnt;
348
349 for (cnt = 0; cnt < keypad->rows; cnt++)
350 if (gpio_is_valid(keypad->row_gpios[cnt]))
351 gpio_free(keypad->row_gpios[cnt]);
352
353 for (cnt = 0; cnt < keypad->cols; cnt++)
354 if (gpio_is_valid(keypad->col_gpios[cnt]))
355 gpio_free(keypad->col_gpios[cnt]);
356}
357#else 346#else
358static 347static
359struct samsung_keypad_platdata *samsung_keypad_parse_dt(struct device *dev) 348struct samsung_keypad_platdata *samsung_keypad_parse_dt(struct device *dev)
360{ 349{
361 return NULL; 350 return NULL;
362} 351}
363
364static void samsung_keypad_dt_gpio_free(struct samsung_keypad *keypad)
365{
366}
367#endif 352#endif
368 353
369static int __devinit samsung_keypad_probe(struct platform_device *pdev) 354static int samsung_keypad_probe(struct platform_device *pdev)
370{ 355{
371 const struct samsung_keypad_platdata *pdata; 356 const struct samsung_keypad_platdata *pdata;
372 const struct matrix_keymap_data *keymap_data; 357 const struct matrix_keymap_data *keymap_data;
@@ -405,36 +390,30 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev)
405 row_shift = get_count_order(pdata->cols); 390 row_shift = get_count_order(pdata->cols);
406 keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]); 391 keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]);
407 392
408 keypad = kzalloc(sizeof(*keypad) + keymap_size, GFP_KERNEL); 393 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size,
409 input_dev = input_allocate_device(); 394 GFP_KERNEL);
410 if (!keypad || !input_dev) { 395 input_dev = devm_input_allocate_device(&pdev->dev);
411 error = -ENOMEM; 396 if (!keypad || !input_dev)
412 goto err_free_mem; 397 return -ENOMEM;
413 }
414 398
415 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 399 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
416 if (!res) { 400 if (!res)
417 error = -ENODEV; 401 return -ENODEV;
418 goto err_free_mem;
419 }
420 402
421 keypad->base = ioremap(res->start, resource_size(res)); 403 keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
422 if (!keypad->base) { 404 if (!keypad->base)
423 error = -EBUSY; 405 return -EBUSY;
424 goto err_free_mem;
425 }
426 406
427 keypad->clk = clk_get(&pdev->dev, "keypad"); 407 keypad->clk = devm_clk_get(&pdev->dev, "keypad");
428 if (IS_ERR(keypad->clk)) { 408 if (IS_ERR(keypad->clk)) {
429 dev_err(&pdev->dev, "failed to get keypad clk\n"); 409 dev_err(&pdev->dev, "failed to get keypad clk\n");
430 error = PTR_ERR(keypad->clk); 410 return PTR_ERR(keypad->clk);
431 goto err_unmap_base;
432 } 411 }
433 412
434 error = clk_prepare(keypad->clk); 413 error = clk_prepare(keypad->clk);
435 if (error) { 414 if (error) {
436 dev_err(&pdev->dev, "keypad clock prepare failed\n"); 415 dev_err(&pdev->dev, "keypad clock prepare failed\n");
437 goto err_put_clk; 416 return error;
438 } 417 }
439 418
440 keypad->input_dev = input_dev; 419 keypad->input_dev = input_dev;
@@ -479,14 +458,15 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev)
479 keypad->irq = platform_get_irq(pdev, 0); 458 keypad->irq = platform_get_irq(pdev, 0);
480 if (keypad->irq < 0) { 459 if (keypad->irq < 0) {
481 error = keypad->irq; 460 error = keypad->irq;
482 goto err_put_clk; 461 goto err_unprepare_clk;
483 } 462 }
484 463
485 error = request_threaded_irq(keypad->irq, NULL, samsung_keypad_irq, 464 error = devm_request_threaded_irq(&pdev->dev, keypad->irq, NULL,
486 IRQF_ONESHOT, dev_name(&pdev->dev), keypad); 465 samsung_keypad_irq, IRQF_ONESHOT,
466 dev_name(&pdev->dev), keypad);
487 if (error) { 467 if (error) {
488 dev_err(&pdev->dev, "failed to register keypad interrupt\n"); 468 dev_err(&pdev->dev, "failed to register keypad interrupt\n");
489 goto err_put_clk; 469 goto err_unprepare_clk;
490 } 470 }
491 471
492 device_init_wakeup(&pdev->dev, pdata->wakeup); 472 device_init_wakeup(&pdev->dev, pdata->wakeup);
@@ -495,7 +475,7 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev)
495 475
496 error = input_register_device(keypad->input_dev); 476 error = input_register_device(keypad->input_dev);
497 if (error) 477 if (error)
498 goto err_free_irq; 478 goto err_disable_runtime_pm;
499 479
500 if (pdev->dev.of_node) { 480 if (pdev->dev.of_node) {
501 devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); 481 devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap);
@@ -504,26 +484,16 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev)
504 } 484 }
505 return 0; 485 return 0;
506 486
507err_free_irq: 487err_disable_runtime_pm:
508 free_irq(keypad->irq, keypad);
509 pm_runtime_disable(&pdev->dev); 488 pm_runtime_disable(&pdev->dev);
510 device_init_wakeup(&pdev->dev, 0); 489 device_init_wakeup(&pdev->dev, 0);
511 platform_set_drvdata(pdev, NULL); 490 platform_set_drvdata(pdev, NULL);
512err_unprepare_clk: 491err_unprepare_clk:
513 clk_unprepare(keypad->clk); 492 clk_unprepare(keypad->clk);
514err_put_clk:
515 clk_put(keypad->clk);
516 samsung_keypad_dt_gpio_free(keypad);
517err_unmap_base:
518 iounmap(keypad->base);
519err_free_mem:
520 input_free_device(input_dev);
521 kfree(keypad);
522
523 return error; 493 return error;
524} 494}
525 495
526static int __devexit samsung_keypad_remove(struct platform_device *pdev) 496static int samsung_keypad_remove(struct platform_device *pdev)
527{ 497{
528 struct samsung_keypad *keypad = platform_get_drvdata(pdev); 498 struct samsung_keypad *keypad = platform_get_drvdata(pdev);
529 499
@@ -533,18 +503,7 @@ static int __devexit samsung_keypad_remove(struct platform_device *pdev)
533 503
534 input_unregister_device(keypad->input_dev); 504 input_unregister_device(keypad->input_dev);
535 505
536 /*
537 * It is safe to free IRQ after unregistering device because
538 * samsung_keypad_close will shut off interrupts.
539 */
540 free_irq(keypad->irq, keypad);
541
542 clk_unprepare(keypad->clk); 506 clk_unprepare(keypad->clk);
543 clk_put(keypad->clk);
544 samsung_keypad_dt_gpio_free(keypad);
545
546 iounmap(keypad->base);
547 kfree(keypad);
548 507
549 return 0; 508 return 0;
550} 509}
@@ -685,7 +644,7 @@ MODULE_DEVICE_TABLE(platform, samsung_keypad_driver_ids);
685 644
686static struct platform_driver samsung_keypad_driver = { 645static struct platform_driver samsung_keypad_driver = {
687 .probe = samsung_keypad_probe, 646 .probe = samsung_keypad_probe,
688 .remove = __devexit_p(samsung_keypad_remove), 647 .remove = samsung_keypad_remove,
689 .driver = { 648 .driver = {
690 .name = "samsung-keypad", 649 .name = "samsung-keypad",
691 .owner = THIS_MODULE, 650 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index da54ad5db154..fdb9eb2df380 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -162,7 +162,7 @@ static irqreturn_t sh_keysc_isr(int irq, void *dev_id)
162 return IRQ_HANDLED; 162 return IRQ_HANDLED;
163} 163}
164 164
165static int __devinit sh_keysc_probe(struct platform_device *pdev) 165static int sh_keysc_probe(struct platform_device *pdev)
166{ 166{
167 struct sh_keysc_priv *priv; 167 struct sh_keysc_priv *priv;
168 struct sh_keysc_info *pdata; 168 struct sh_keysc_info *pdata;
@@ -272,7 +272,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev)
272 return error; 272 return error;
273} 273}
274 274
275static int __devexit sh_keysc_remove(struct platform_device *pdev) 275static int sh_keysc_remove(struct platform_device *pdev)
276{ 276{
277 struct sh_keysc_priv *priv = platform_get_drvdata(pdev); 277 struct sh_keysc_priv *priv = platform_get_drvdata(pdev);
278 278
@@ -331,7 +331,7 @@ static SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops,
331 331
332static struct platform_driver sh_keysc_device_driver = { 332static struct platform_driver sh_keysc_device_driver = {
333 .probe = sh_keysc_probe, 333 .probe = sh_keysc_probe,
334 .remove = __devexit_p(sh_keysc_remove), 334 .remove = sh_keysc_remove,
335 .driver = { 335 .driver = {
336 .name = "sh_keysc", 336 .name = "sh_keysc",
337 .pm = &sh_keysc_dev_pm_ops, 337 .pm = &sh_keysc_dev_pm_ops,
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index c7ca97f44bfb..695d237417d6 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -55,15 +55,15 @@
55 55
56struct spear_kbd { 56struct spear_kbd {
57 struct input_dev *input; 57 struct input_dev *input;
58 struct resource *res;
59 void __iomem *io_base; 58 void __iomem *io_base;
60 struct clk *clk; 59 struct clk *clk;
61 unsigned int irq; 60 unsigned int irq;
62 unsigned int mode; 61 unsigned int mode;
62 unsigned int suspended_rate;
63 unsigned short last_key; 63 unsigned short last_key;
64 unsigned short keycodes[NUM_ROWS * NUM_COLS]; 64 unsigned short keycodes[NUM_ROWS * NUM_COLS];
65 bool rep; 65 bool rep;
66 unsigned int suspended_rate; 66 bool irq_wake_enabled;
67 u32 mode_ctl_reg; 67 u32 mode_ctl_reg;
68}; 68};
69 69
@@ -146,7 +146,7 @@ static void spear_kbd_close(struct input_dev *dev)
146} 146}
147 147
148#ifdef CONFIG_OF 148#ifdef CONFIG_OF
149static int __devinit spear_kbd_parse_dt(struct platform_device *pdev, 149static int spear_kbd_parse_dt(struct platform_device *pdev,
150 struct spear_kbd *kbd) 150 struct spear_kbd *kbd)
151{ 151{
152 struct device_node *np = pdev->dev.of_node; 152 struct device_node *np = pdev->dev.of_node;
@@ -181,7 +181,7 @@ static inline int spear_kbd_parse_dt(struct platform_device *pdev,
181} 181}
182#endif 182#endif
183 183
184static int __devinit spear_kbd_probe(struct platform_device *pdev) 184static int spear_kbd_probe(struct platform_device *pdev)
185{ 185{
186 struct kbd_platform_data *pdata = dev_get_platdata(&pdev->dev); 186 struct kbd_platform_data *pdata = dev_get_platdata(&pdev->dev);
187 const struct matrix_keymap_data *keymap = pdata ? pdata->keymap : NULL; 187 const struct matrix_keymap_data *keymap = pdata ? pdata->keymap : NULL;
@@ -203,12 +203,16 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
203 return irq; 203 return irq;
204 } 204 }
205 205
206 kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); 206 kbd = devm_kzalloc(&pdev->dev, sizeof(*kbd), GFP_KERNEL);
207 input_dev = input_allocate_device(); 207 if (!kbd) {
208 if (!kbd || !input_dev) { 208 dev_err(&pdev->dev, "not enough memory for driver data\n");
209 dev_err(&pdev->dev, "out of memory\n"); 209 return -ENOMEM;
210 error = -ENOMEM; 210 }
211 goto err_free_mem; 211
212 input_dev = devm_input_allocate_device(&pdev->dev);
213 if (!input_dev) {
214 dev_err(&pdev->dev, "unable to allocate input device\n");
215 return -ENOMEM;
212 } 216 }
213 217
214 kbd->input = input_dev; 218 kbd->input = input_dev;
@@ -217,37 +221,25 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
217 if (!pdata) { 221 if (!pdata) {
218 error = spear_kbd_parse_dt(pdev, kbd); 222 error = spear_kbd_parse_dt(pdev, kbd);
219 if (error) 223 if (error)
220 goto err_free_mem; 224 return error;
221 } else { 225 } else {
222 kbd->mode = pdata->mode; 226 kbd->mode = pdata->mode;
223 kbd->rep = pdata->rep; 227 kbd->rep = pdata->rep;
224 kbd->suspended_rate = pdata->suspended_rate; 228 kbd->suspended_rate = pdata->suspended_rate;
225 } 229 }
226 230
227 kbd->res = request_mem_region(res->start, resource_size(res), 231 kbd->io_base = devm_request_and_ioremap(&pdev->dev, res);
228 pdev->name);
229 if (!kbd->res) {
230 dev_err(&pdev->dev, "keyboard region already claimed\n");
231 error = -EBUSY;
232 goto err_free_mem;
233 }
234
235 kbd->io_base = ioremap(res->start, resource_size(res));
236 if (!kbd->io_base) { 232 if (!kbd->io_base) {
237 dev_err(&pdev->dev, "ioremap failed for kbd_region\n"); 233 dev_err(&pdev->dev, "request-ioremap failed for kbd_region\n");
238 error = -ENOMEM; 234 return -ENOMEM;
239 goto err_release_mem_region;
240 } 235 }
241 236
242 kbd->clk = clk_get(&pdev->dev, NULL); 237 kbd->clk = devm_clk_get(&pdev->dev, NULL);
243 if (IS_ERR(kbd->clk)) { 238 if (IS_ERR(kbd->clk))
244 error = PTR_ERR(kbd->clk); 239 return PTR_ERR(kbd->clk);
245 goto err_iounmap;
246 }
247 240
248 input_dev->name = "Spear Keyboard"; 241 input_dev->name = "Spear Keyboard";
249 input_dev->phys = "keyboard/input0"; 242 input_dev->phys = "keyboard/input0";
250 input_dev->dev.parent = &pdev->dev;
251 input_dev->id.bustype = BUS_HOST; 243 input_dev->id.bustype = BUS_HOST;
252 input_dev->id.vendor = 0x0001; 244 input_dev->id.vendor = 0x0001;
253 input_dev->id.product = 0x0001; 245 input_dev->id.product = 0x0001;
@@ -259,7 +251,7 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
259 kbd->keycodes, input_dev); 251 kbd->keycodes, input_dev);
260 if (error) { 252 if (error) {
261 dev_err(&pdev->dev, "Failed to build keymap\n"); 253 dev_err(&pdev->dev, "Failed to build keymap\n");
262 goto err_put_clk; 254 return error;
263 } 255 }
264 256
265 if (kbd->rep) 257 if (kbd->rep)
@@ -268,48 +260,36 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev)
268 260
269 input_set_drvdata(input_dev, kbd); 261 input_set_drvdata(input_dev, kbd);
270 262
271 error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd); 263 error = devm_request_irq(&pdev->dev, irq, spear_kbd_interrupt, 0,
264 "keyboard", kbd);
272 if (error) { 265 if (error) {
273 dev_err(&pdev->dev, "request_irq fail\n"); 266 dev_err(&pdev->dev, "request_irq failed\n");
274 goto err_put_clk; 267 return error;
275 } 268 }
276 269
270 error = clk_prepare(kbd->clk);
271 if (error)
272 return error;
273
277 error = input_register_device(input_dev); 274 error = input_register_device(input_dev);
278 if (error) { 275 if (error) {
279 dev_err(&pdev->dev, "Unable to register keyboard device\n"); 276 dev_err(&pdev->dev, "Unable to register keyboard device\n");
280 goto err_free_irq; 277 clk_unprepare(kbd->clk);
278 return error;
281 } 279 }
282 280
283 device_init_wakeup(&pdev->dev, 1); 281 device_init_wakeup(&pdev->dev, 1);
284 platform_set_drvdata(pdev, kbd); 282 platform_set_drvdata(pdev, kbd);
285 283
286 return 0; 284 return 0;
287
288err_free_irq:
289 free_irq(kbd->irq, kbd);
290err_put_clk:
291 clk_put(kbd->clk);
292err_iounmap:
293 iounmap(kbd->io_base);
294err_release_mem_region:
295 release_mem_region(res->start, resource_size(res));
296err_free_mem:
297 input_free_device(input_dev);
298 kfree(kbd);
299
300 return error;
301} 285}
302 286
303static int __devexit spear_kbd_remove(struct platform_device *pdev) 287static int spear_kbd_remove(struct platform_device *pdev)
304{ 288{
305 struct spear_kbd *kbd = platform_get_drvdata(pdev); 289 struct spear_kbd *kbd = platform_get_drvdata(pdev);
306 290
307 free_irq(kbd->irq, kbd);
308 input_unregister_device(kbd->input); 291 input_unregister_device(kbd->input);
309 clk_put(kbd->clk); 292 clk_unprepare(kbd->clk);
310 iounmap(kbd->io_base);
311 release_mem_region(kbd->res->start, resource_size(kbd->res));
312 kfree(kbd);
313 293
314 device_init_wakeup(&pdev->dev, 0); 294 device_init_wakeup(&pdev->dev, 0);
315 platform_set_drvdata(pdev, NULL); 295 platform_set_drvdata(pdev, NULL);
@@ -333,7 +313,8 @@ static int spear_kbd_suspend(struct device *dev)
333 mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG); 313 mode_ctl_reg = readl_relaxed(kbd->io_base + MODE_CTL_REG);
334 314
335 if (device_may_wakeup(&pdev->dev)) { 315 if (device_may_wakeup(&pdev->dev)) {
336 enable_irq_wake(kbd->irq); 316 if (!enable_irq_wake(kbd->irq))
317 kbd->irq_wake_enabled = true;
337 318
338 /* 319 /*
339 * reprogram the keyboard operating frequency as on some 320 * reprogram the keyboard operating frequency as on some
@@ -379,7 +360,10 @@ static int spear_kbd_resume(struct device *dev)
379 mutex_lock(&input_dev->mutex); 360 mutex_lock(&input_dev->mutex);
380 361
381 if (device_may_wakeup(&pdev->dev)) { 362 if (device_may_wakeup(&pdev->dev)) {
382 disable_irq_wake(kbd->irq); 363 if (kbd->irq_wake_enabled) {
364 kbd->irq_wake_enabled = false;
365 disable_irq_wake(kbd->irq);
366 }
383 } else { 367 } else {
384 if (input_dev->users) 368 if (input_dev->users)
385 clk_enable(kbd->clk); 369 clk_enable(kbd->clk);
@@ -407,7 +391,7 @@ MODULE_DEVICE_TABLE(of, spear_kbd_id_table);
407 391
408static struct platform_driver spear_kbd_driver = { 392static struct platform_driver spear_kbd_driver = {
409 .probe = spear_kbd_probe, 393 .probe = spear_kbd_probe,
410 .remove = __devexit_p(spear_kbd_remove), 394 .remove = spear_kbd_remove,
411 .driver = { 395 .driver = {
412 .name = "keyboard", 396 .name = "keyboard",
413 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 470a8778dec1..5cbec56f7720 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -166,7 +166,7 @@ static irqreturn_t stmpe_keypad_irq(int irq, void *dev)
166 return IRQ_HANDLED; 166 return IRQ_HANDLED;
167} 167}
168 168
169static int __devinit stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) 169static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad)
170{ 170{
171 const struct stmpe_keypad_variant *variant = keypad->variant; 171 const struct stmpe_keypad_variant *variant = keypad->variant;
172 unsigned int col_gpios = variant->col_gpios; 172 unsigned int col_gpios = variant->col_gpios;
@@ -207,7 +207,7 @@ static int __devinit stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad)
207 return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); 207 return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD);
208} 208}
209 209
210static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad) 210static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
211{ 211{
212 const struct stmpe_keypad_platform_data *plat = keypad->plat; 212 const struct stmpe_keypad_platform_data *plat = keypad->plat;
213 const struct stmpe_keypad_variant *variant = keypad->variant; 213 const struct stmpe_keypad_variant *variant = keypad->variant;
@@ -257,105 +257,131 @@ static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
257 (plat->debounce_ms << 1)); 257 (plat->debounce_ms << 1));
258} 258}
259 259
260static int __devinit stmpe_keypad_probe(struct platform_device *pdev) 260static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad)
261{ 261{
262 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 262 int row, col;
263
264 for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) {
265 for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) {
266 int code = MATRIX_SCAN_CODE(row, col,
267 STMPE_KEYPAD_ROW_SHIFT);
268 if (keypad->keymap[code] != KEY_RESERVED) {
269 keypad->rows |= 1 << row;
270 keypad->cols |= 1 << col;
271 }
272 }
273 }
274}
275
276#ifdef CONFIG_OF
277static const struct stmpe_keypad_platform_data *
278stmpe_keypad_of_probe(struct device *dev)
279{
280 struct device_node *np = dev->of_node;
263 struct stmpe_keypad_platform_data *plat; 281 struct stmpe_keypad_platform_data *plat;
282
283 if (!np)
284 return ERR_PTR(-ENODEV);
285
286 plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
287 if (!plat)
288 return ERR_PTR(-ENOMEM);
289
290 of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
291 of_property_read_u32(np, "st,scan-count", &plat->scan_count);
292
293 plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");
294
295 return plat;
296}
297#else
298static inline const struct stmpe_keypad_platform_data *
299stmpe_keypad_of_probe(struct device *dev)
300{
301 return ERR_PTR(-EINVAL);
302}
303#endif
304
305static int stmpe_keypad_probe(struct platform_device *pdev)
306{
307 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
308 const struct stmpe_keypad_platform_data *plat;
264 struct stmpe_keypad *keypad; 309 struct stmpe_keypad *keypad;
265 struct input_dev *input; 310 struct input_dev *input;
266 int ret; 311 int error;
267 int irq; 312 int irq;
268 int i;
269 313
270 plat = stmpe->pdata->keypad; 314 plat = stmpe->pdata->keypad;
271 if (!plat) 315 if (!plat) {
272 return -ENODEV; 316 plat = stmpe_keypad_of_probe(&pdev->dev);
317 if (IS_ERR(plat))
318 return PTR_ERR(plat);
319 }
273 320
274 irq = platform_get_irq(pdev, 0); 321 irq = platform_get_irq(pdev, 0);
275 if (irq < 0) 322 if (irq < 0)
276 return irq; 323 return irq;
277 324
278 keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL); 325 keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
326 GFP_KERNEL);
279 if (!keypad) 327 if (!keypad)
280 return -ENOMEM; 328 return -ENOMEM;
281 329
282 input = input_allocate_device(); 330 input = devm_input_allocate_device(&pdev->dev);
283 if (!input) { 331 if (!input)
284 ret = -ENOMEM; 332 return -ENOMEM;
285 goto out_freekeypad;
286 }
287 333
288 input->name = "STMPE keypad"; 334 input->name = "STMPE keypad";
289 input->id.bustype = BUS_I2C; 335 input->id.bustype = BUS_I2C;
290 input->dev.parent = &pdev->dev; 336 input->dev.parent = &pdev->dev;
291 337
292 ret = matrix_keypad_build_keymap(plat->keymap_data, NULL, 338 error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
293 STMPE_KEYPAD_MAX_ROWS, 339 STMPE_KEYPAD_MAX_ROWS,
294 STMPE_KEYPAD_MAX_COLS, 340 STMPE_KEYPAD_MAX_COLS,
295 keypad->keymap, input); 341 keypad->keymap, input);
296 if (ret) 342 if (error)
297 goto out_freeinput; 343 return error;
298 344
299 input_set_capability(input, EV_MSC, MSC_SCAN); 345 input_set_capability(input, EV_MSC, MSC_SCAN);
300 if (!plat->no_autorepeat) 346 if (!plat->no_autorepeat)
301 __set_bit(EV_REP, input->evbit); 347 __set_bit(EV_REP, input->evbit);
302 348
303 for (i = 0; i < plat->keymap_data->keymap_size; i++) { 349 stmpe_keypad_fill_used_pins(keypad);
304 unsigned int key = plat->keymap_data->keymap[i];
305
306 keypad->cols |= 1 << KEY_COL(key);
307 keypad->rows |= 1 << KEY_ROW(key);
308 }
309 350
310 keypad->stmpe = stmpe; 351 keypad->stmpe = stmpe;
311 keypad->plat = plat; 352 keypad->plat = plat;
312 keypad->input = input; 353 keypad->input = input;
313 keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; 354 keypad->variant = &stmpe_keypad_variants[stmpe->partnum];
314 355
315 ret = stmpe_keypad_chip_init(keypad); 356 error = stmpe_keypad_chip_init(keypad);
316 if (ret < 0) 357 if (error < 0)
317 goto out_freeinput; 358 return error;
318 359
319 ret = input_register_device(input); 360 error = devm_request_threaded_irq(&pdev->dev, irq,
320 if (ret) { 361 NULL, stmpe_keypad_irq,
321 dev_err(&pdev->dev, 362 IRQF_ONESHOT, "stmpe-keypad", keypad);
322 "unable to register input device: %d\n", ret); 363 if (error) {
323 goto out_freeinput; 364 dev_err(&pdev->dev, "unable to get irq: %d\n", error);
365 return error;
324 } 366 }
325 367
326 ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT, 368 error = input_register_device(input);
327 "stmpe-keypad", keypad); 369 if (error) {
328 if (ret) { 370 dev_err(&pdev->dev,
329 dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 371 "unable to register input device: %d\n", error);
330 goto out_unregisterinput; 372 return error;
331 } 373 }
332 374
333 platform_set_drvdata(pdev, keypad); 375 platform_set_drvdata(pdev, keypad);
334 376
335 return 0; 377 return 0;
336
337out_unregisterinput:
338 input_unregister_device(input);
339 input = NULL;
340out_freeinput:
341 input_free_device(input);
342out_freekeypad:
343 kfree(keypad);
344 return ret;
345} 378}
346 379
347static int __devexit stmpe_keypad_remove(struct platform_device *pdev) 380static int stmpe_keypad_remove(struct platform_device *pdev)
348{ 381{
349 struct stmpe_keypad *keypad = platform_get_drvdata(pdev); 382 struct stmpe_keypad *keypad = platform_get_drvdata(pdev);
350 struct stmpe *stmpe = keypad->stmpe;
351 int irq = platform_get_irq(pdev, 0);
352
353 stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD);
354 383
355 free_irq(irq, keypad); 384 stmpe_disable(keypad->stmpe, STMPE_BLOCK_KEYPAD);
356 input_unregister_device(keypad->input);
357 platform_set_drvdata(pdev, NULL);
358 kfree(keypad);
359 385
360 return 0; 386 return 0;
361} 387}
@@ -364,7 +390,7 @@ static struct platform_driver stmpe_keypad_driver = {
364 .driver.name = "stmpe-keypad", 390 .driver.name = "stmpe-keypad",
365 .driver.owner = THIS_MODULE, 391 .driver.owner = THIS_MODULE,
366 .probe = stmpe_keypad_probe, 392 .probe = stmpe_keypad_probe,
367 .remove = __devexit_p(stmpe_keypad_remove), 393 .remove = stmpe_keypad_remove,
368}; 394};
369module_platform_driver(stmpe_keypad_driver); 395module_platform_driver(stmpe_keypad_driver);
370 396
diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index 7d498e698508..2fb0d76a04c4 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -299,7 +299,7 @@ static void tc3589x_keypad_close(struct input_dev *input)
299 tc3589x_keypad_disable(keypad); 299 tc3589x_keypad_disable(keypad);
300} 300}
301 301
302static int __devinit tc3589x_keypad_probe(struct platform_device *pdev) 302static int tc3589x_keypad_probe(struct platform_device *pdev)
303{ 303{
304 struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent); 304 struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent);
305 struct tc_keypad *keypad; 305 struct tc_keypad *keypad;
@@ -382,7 +382,7 @@ err_free_mem:
382 return error; 382 return error;
383} 383}
384 384
385static int __devexit tc3589x_keypad_remove(struct platform_device *pdev) 385static int tc3589x_keypad_remove(struct platform_device *pdev)
386{ 386{
387 struct tc_keypad *keypad = platform_get_drvdata(pdev); 387 struct tc_keypad *keypad = platform_get_drvdata(pdev);
388 int irq = platform_get_irq(pdev, 0); 388 int irq = platform_get_irq(pdev, 0);
@@ -448,7 +448,7 @@ static struct platform_driver tc3589x_keypad_driver = {
448 .pm = &tc3589x_keypad_dev_pm_ops, 448 .pm = &tc3589x_keypad_dev_pm_ops,
449 }, 449 },
450 .probe = tc3589x_keypad_probe, 450 .probe = tc3589x_keypad_probe,
451 .remove = __devexit_p(tc3589x_keypad_remove), 451 .remove = tc3589x_keypad_remove,
452}; 452};
453module_platform_driver(tc3589x_keypad_driver); 453module_platform_driver(tc3589x_keypad_driver);
454 454
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index c355cdde8d22..bfc832c35a7c 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -166,7 +166,7 @@ static void tca6416_keys_close(struct input_dev *dev)
166 disable_irq(chip->irqnum); 166 disable_irq(chip->irqnum);
167} 167}
168 168
169static int __devinit tca6416_setup_registers(struct tca6416_keypad_chip *chip) 169static int tca6416_setup_registers(struct tca6416_keypad_chip *chip)
170{ 170{
171 int error; 171 int error;
172 172
@@ -197,7 +197,7 @@ static int __devinit tca6416_setup_registers(struct tca6416_keypad_chip *chip)
197 return 0; 197 return 0;
198} 198}
199 199
200static int __devinit tca6416_keypad_probe(struct i2c_client *client, 200static int tca6416_keypad_probe(struct i2c_client *client,
201 const struct i2c_device_id *id) 201 const struct i2c_device_id *id)
202{ 202{
203 struct tca6416_keys_platform_data *pdata; 203 struct tca6416_keys_platform_data *pdata;
@@ -313,7 +313,7 @@ fail1:
313 return error; 313 return error;
314} 314}
315 315
316static int __devexit tca6416_keypad_remove(struct i2c_client *client) 316static int tca6416_keypad_remove(struct i2c_client *client)
317{ 317{
318 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); 318 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
319 319
@@ -361,7 +361,7 @@ static struct i2c_driver tca6416_keypad_driver = {
361 .pm = &tca6416_keypad_dev_pm_ops, 361 .pm = &tca6416_keypad_dev_pm_ops,
362 }, 362 },
363 .probe = tca6416_keypad_probe, 363 .probe = tca6416_keypad_probe,
364 .remove = __devexit_p(tca6416_keypad_remove), 364 .remove = tca6416_keypad_remove,
365 .id_table = tca6416_id, 365 .id_table = tca6416_id,
366}; 366};
367 367
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
index 893869b29ed9..50e9c5e195e1 100644
--- a/drivers/input/keyboard/tca8418_keypad.c
+++ b/drivers/input/keyboard/tca8418_keypad.c
@@ -35,6 +35,7 @@
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36#include <linux/input.h> 36#include <linux/input.h>
37#include <linux/input/tca8418_keypad.h> 37#include <linux/input/tca8418_keypad.h>
38#include <linux/of.h>
38 39
39/* TCA8418 hardware limits */ 40/* TCA8418 hardware limits */
40#define TCA8418_MAX_ROWS 8 41#define TCA8418_MAX_ROWS 8
@@ -109,25 +110,11 @@
109#define KEY_EVENT_CODE 0x7f 110#define KEY_EVENT_CODE 0x7f
110#define KEY_EVENT_VALUE 0x80 111#define KEY_EVENT_VALUE 0x80
111 112
112
113static const struct i2c_device_id tca8418_id[] = {
114 { TCA8418_NAME, 8418, },
115 { }
116};
117MODULE_DEVICE_TABLE(i2c, tca8418_id);
118
119struct tca8418_keypad { 113struct tca8418_keypad {
120 unsigned int rows;
121 unsigned int cols;
122 unsigned int keypad_mask; /* Mask for keypad col/rol regs */
123 unsigned int irq;
124 unsigned int row_shift;
125
126 struct i2c_client *client; 114 struct i2c_client *client;
127 struct input_dev *input; 115 struct input_dev *input;
128 116
129 /* Flexible array member, must be at end of struct */ 117 unsigned int row_shift;
130 unsigned short keymap[];
131}; 118};
132 119
133/* 120/*
@@ -172,6 +159,8 @@ static int tca8418_read_byte(struct tca8418_keypad *keypad_data,
172 159
173static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) 160static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
174{ 161{
162 struct input_dev *input = keypad_data->input;
163 unsigned short *keymap = input->keycode;
175 int error, col, row; 164 int error, col, row;
176 u8 reg, state, code; 165 u8 reg, state, code;
177 166
@@ -190,9 +179,8 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
190 col = (col) ? col - 1 : TCA8418_MAX_COLS - 1; 179 col = (col) ? col - 1 : TCA8418_MAX_COLS - 1;
191 180
192 code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift); 181 code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift);
193 input_event(keypad_data->input, EV_MSC, MSC_SCAN, code); 182 input_event(input, EV_MSC, MSC_SCAN, code);
194 input_report_key(keypad_data->input, 183 input_report_key(input, keymap[code], state);
195 keypad_data->keymap[code], state);
196 184
197 /* Read for next loop */ 185 /* Read for next loop */
198 error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg); 186 error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg);
@@ -202,7 +190,7 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
202 dev_err(&keypad_data->client->dev, 190 dev_err(&keypad_data->client->dev,
203 "unable to read REG_KEY_EVENT_A\n"); 191 "unable to read REG_KEY_EVENT_A\n");
204 192
205 input_sync(keypad_data->input); 193 input_sync(input);
206} 194}
207 195
208/* 196/*
@@ -218,16 +206,18 @@ static irqreturn_t tca8418_irq_handler(int irq, void *dev_id)
218 if (error) { 206 if (error) {
219 dev_err(&keypad_data->client->dev, 207 dev_err(&keypad_data->client->dev,
220 "unable to read REG_INT_STAT\n"); 208 "unable to read REG_INT_STAT\n");
221 goto exit; 209 return IRQ_NONE;
222 } 210 }
223 211
212 if (!reg)
213 return IRQ_NONE;
214
224 if (reg & INT_STAT_OVR_FLOW_INT) 215 if (reg & INT_STAT_OVR_FLOW_INT)
225 dev_warn(&keypad_data->client->dev, "overflow occurred\n"); 216 dev_warn(&keypad_data->client->dev, "overflow occurred\n");
226 217
227 if (reg & INT_STAT_K_INT) 218 if (reg & INT_STAT_K_INT)
228 tca8418_read_keypad(keypad_data); 219 tca8418_read_keypad(keypad_data);
229 220
230exit:
231 /* Clear all interrupts, even IRQs we didn't check (GPI, CAD, LCK) */ 221 /* Clear all interrupts, even IRQs we didn't check (GPI, CAD, LCK) */
232 reg = 0xff; 222 reg = 0xff;
233 error = tca8418_write_byte(keypad_data, REG_INT_STAT, reg); 223 error = tca8418_write_byte(keypad_data, REG_INT_STAT, reg);
@@ -241,7 +231,8 @@ exit:
241/* 231/*
242 * Configure the TCA8418 for keypad operation 232 * Configure the TCA8418 for keypad operation
243 */ 233 */
244static int __devinit tca8418_configure(struct tca8418_keypad *keypad_data) 234static int tca8418_configure(struct tca8418_keypad *keypad_data,
235 u32 rows, u32 cols)
245{ 236{
246 int reg, error; 237 int reg, error;
247 238
@@ -253,9 +244,8 @@ static int __devinit tca8418_configure(struct tca8418_keypad *keypad_data)
253 244
254 245
255 /* Assemble a mask for row and column registers */ 246 /* Assemble a mask for row and column registers */
256 reg = ~(~0 << keypad_data->rows); 247 reg = ~(~0 << rows);
257 reg += (~(~0 << keypad_data->cols)) << 8; 248 reg += (~(~0 << cols)) << 8;
258 keypad_data->keypad_mask = reg;
259 249
260 /* Set registers to keypad mode */ 250 /* Set registers to keypad mode */
261 error |= tca8418_write_byte(keypad_data, REG_KP_GPIO1, reg); 251 error |= tca8418_write_byte(keypad_data, REG_KP_GPIO1, reg);
@@ -270,145 +260,144 @@ static int __devinit tca8418_configure(struct tca8418_keypad *keypad_data)
270 return error; 260 return error;
271} 261}
272 262
273static int __devinit tca8418_keypad_probe(struct i2c_client *client, 263static int tca8418_keypad_probe(struct i2c_client *client,
274 const struct i2c_device_id *id) 264 const struct i2c_device_id *id)
275{ 265{
266 struct device *dev = &client->dev;
276 const struct tca8418_keypad_platform_data *pdata = 267 const struct tca8418_keypad_platform_data *pdata =
277 client->dev.platform_data; 268 dev_get_platdata(dev);
278 struct tca8418_keypad *keypad_data; 269 struct tca8418_keypad *keypad_data;
279 struct input_dev *input; 270 struct input_dev *input;
271 const struct matrix_keymap_data *keymap_data = NULL;
272 u32 rows = 0, cols = 0;
273 bool rep = false;
274 bool irq_is_gpio = false;
275 int irq;
280 int error, row_shift, max_keys; 276 int error, row_shift, max_keys;
281 277
282 /* Copy the platform data */ 278 /* Copy the platform data */
283 if (!pdata) { 279 if (pdata) {
284 dev_dbg(&client->dev, "no platform data\n"); 280 if (!pdata->keymap_data) {
285 return -EINVAL; 281 dev_err(dev, "no keymap data defined\n");
286 } 282 return -EINVAL;
287 283 }
288 if (!pdata->keymap_data) { 284 keymap_data = pdata->keymap_data;
289 dev_err(&client->dev, "no keymap data defined\n"); 285 rows = pdata->rows;
290 return -EINVAL; 286 cols = pdata->cols;
287 rep = pdata->rep;
288 irq_is_gpio = pdata->irq_is_gpio;
289 } else {
290 struct device_node *np = dev->of_node;
291 of_property_read_u32(np, "keypad,num-rows", &rows);
292 of_property_read_u32(np, "keypad,num-columns", &cols);
293 rep = of_property_read_bool(np, "keypad,autorepeat");
291 } 294 }
292 295
293 if (!pdata->rows || pdata->rows > TCA8418_MAX_ROWS) { 296 if (!rows || rows > TCA8418_MAX_ROWS) {
294 dev_err(&client->dev, "invalid rows\n"); 297 dev_err(dev, "invalid rows\n");
295 return -EINVAL; 298 return -EINVAL;
296 } 299 }
297 300
298 if (!pdata->cols || pdata->cols > TCA8418_MAX_COLS) { 301 if (!cols || cols > TCA8418_MAX_COLS) {
299 dev_err(&client->dev, "invalid columns\n"); 302 dev_err(dev, "invalid columns\n");
300 return -EINVAL; 303 return -EINVAL;
301 } 304 }
302 305
303 /* Check i2c driver capabilities */ 306 /* Check i2c driver capabilities */
304 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 307 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
305 dev_err(&client->dev, "%s adapter not supported\n", 308 dev_err(dev, "%s adapter not supported\n",
306 dev_driver_string(&client->adapter->dev)); 309 dev_driver_string(&client->adapter->dev));
307 return -ENODEV; 310 return -ENODEV;
308 } 311 }
309 312
310 row_shift = get_count_order(pdata->cols); 313 row_shift = get_count_order(cols);
311 max_keys = pdata->rows << row_shift; 314 max_keys = rows << row_shift;
312 315
313 /* Allocate memory for keypad_data, keymap and input device */ 316 /* Allocate memory for keypad_data and input device */
314 keypad_data = kzalloc(sizeof(*keypad_data) + 317 keypad_data = devm_kzalloc(dev, sizeof(*keypad_data), GFP_KERNEL);
315 max_keys * sizeof(keypad_data->keymap[0]), GFP_KERNEL);
316 if (!keypad_data) 318 if (!keypad_data)
317 return -ENOMEM; 319 return -ENOMEM;
318 320
319 keypad_data->rows = pdata->rows;
320 keypad_data->cols = pdata->cols;
321 keypad_data->client = client; 321 keypad_data->client = client;
322 keypad_data->row_shift = row_shift; 322 keypad_data->row_shift = row_shift;
323 323
324 /* Initialize the chip or fail if chip isn't present */ 324 /* Initialize the chip or fail if chip isn't present */
325 error = tca8418_configure(keypad_data); 325 error = tca8418_configure(keypad_data, rows, cols);
326 if (error < 0) 326 if (error < 0)
327 goto fail1; 327 return error;
328 328
329 /* Configure input device */ 329 /* Configure input device */
330 input = input_allocate_device(); 330 input = devm_input_allocate_device(dev);
331 if (!input) { 331 if (!input)
332 error = -ENOMEM; 332 return -ENOMEM;
333 goto fail1; 333
334 }
335 keypad_data->input = input; 334 keypad_data->input = input;
336 335
337 input->name = client->name; 336 input->name = client->name;
338 input->dev.parent = &client->dev;
339
340 input->id.bustype = BUS_I2C; 337 input->id.bustype = BUS_I2C;
341 input->id.vendor = 0x0001; 338 input->id.vendor = 0x0001;
342 input->id.product = 0x001; 339 input->id.product = 0x001;
343 input->id.version = 0x0001; 340 input->id.version = 0x0001;
344 341
345 error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, 342 error = matrix_keypad_build_keymap(keymap_data, NULL, rows, cols,
346 pdata->rows, pdata->cols, 343 NULL, input);
347 keypad_data->keymap, input);
348 if (error) { 344 if (error) {
349 dev_dbg(&client->dev, "Failed to build keymap\n"); 345 dev_err(dev, "Failed to build keymap\n");
350 goto fail2; 346 return error;
351 } 347 }
352 348
353 if (pdata->rep) 349 if (rep)
354 __set_bit(EV_REP, input->evbit); 350 __set_bit(EV_REP, input->evbit);
355 input_set_capability(input, EV_MSC, MSC_SCAN); 351 input_set_capability(input, EV_MSC, MSC_SCAN);
356 352
357 input_set_drvdata(input, keypad_data); 353 input_set_drvdata(input, keypad_data);
358 354
359 if (pdata->irq_is_gpio) 355 irq = client->irq;
360 client->irq = gpio_to_irq(client->irq); 356 if (irq_is_gpio)
357 irq = gpio_to_irq(irq);
361 358
362 error = request_threaded_irq(client->irq, NULL, tca8418_irq_handler, 359 error = devm_request_threaded_irq(dev, irq, NULL, tca8418_irq_handler,
363 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 360 IRQF_TRIGGER_FALLING |
364 client->name, keypad_data); 361 IRQF_SHARED |
362 IRQF_ONESHOT,
363 client->name, keypad_data);
365 if (error) { 364 if (error) {
366 dev_dbg(&client->dev, 365 dev_err(dev, "Unable to claim irq %d; error %d\n",
367 "Unable to claim irq %d; error %d\n",
368 client->irq, error); 366 client->irq, error);
369 goto fail2; 367 return error;
370 } 368 }
371 369
372 error = input_register_device(input); 370 error = input_register_device(input);
373 if (error) { 371 if (error) {
374 dev_dbg(&client->dev, 372 dev_err(dev, "Unable to register input device, error: %d\n",
375 "Unable to register input device, error: %d\n", error); 373 error);
376 goto fail3; 374 return error;
377 } 375 }
378 376
379 i2c_set_clientdata(client, keypad_data);
380 return 0; 377 return 0;
381
382fail3:
383 free_irq(client->irq, keypad_data);
384fail2:
385 input_free_device(input);
386fail1:
387 kfree(keypad_data);
388 return error;
389} 378}
390 379
391static int __devexit tca8418_keypad_remove(struct i2c_client *client) 380static const struct i2c_device_id tca8418_id[] = {
392{ 381 { TCA8418_NAME, 8418, },
393 struct tca8418_keypad *keypad_data = i2c_get_clientdata(client); 382 { }
394 383};
395 free_irq(keypad_data->client->irq, keypad_data); 384MODULE_DEVICE_TABLE(i2c, tca8418_id);
396
397 input_unregister_device(keypad_data->input);
398
399 kfree(keypad_data);
400
401 return 0;
402}
403 385
386#ifdef CONFIG_OF
387static const struct of_device_id tca8418_dt_ids[] __devinitconst = {
388 { .compatible = "ti,tca8418", },
389 { }
390};
391MODULE_DEVICE_TABLE(of, tca8418_dt_ids);
392#endif
404 393
405static struct i2c_driver tca8418_keypad_driver = { 394static struct i2c_driver tca8418_keypad_driver = {
406 .driver = { 395 .driver = {
407 .name = TCA8418_NAME, 396 .name = TCA8418_NAME,
408 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
398 .of_match_table = of_match_ptr(tca8418_dt_ids),
409 }, 399 },
410 .probe = tca8418_keypad_probe, 400 .probe = tca8418_keypad_probe,
411 .remove = __devexit_p(tca8418_keypad_remove),
412 .id_table = tca8418_id, 401 .id_table = tca8418_id,
413}; 402};
414 403
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 5faaf2553e33..c76f96872d31 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -87,7 +87,7 @@ struct tegra_kbc {
87 struct clk *clk; 87 struct clk *clk;
88}; 88};
89 89
90static const u32 tegra_kbc_default_keymap[] __devinitdata = { 90static const u32 tegra_kbc_default_keymap[] = {
91 KEY(0, 2, KEY_W), 91 KEY(0, 2, KEY_W),
92 KEY(0, 3, KEY_S), 92 KEY(0, 3, KEY_S),
93 KEY(0, 4, KEY_A), 93 KEY(0, 4, KEY_A),
@@ -223,7 +223,7 @@ static const u32 tegra_kbc_default_keymap[] __devinitdata = {
223}; 223};
224 224
225static const 225static const
226struct matrix_keymap_data tegra_kbc_default_keymap_data __devinitdata = { 226struct matrix_keymap_data tegra_kbc_default_keymap_data = {
227 .keymap = tegra_kbc_default_keymap, 227 .keymap = tegra_kbc_default_keymap,
228 .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap), 228 .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap),
229}; 229};
@@ -573,7 +573,7 @@ static void tegra_kbc_close(struct input_dev *dev)
573 return tegra_kbc_stop(kbc); 573 return tegra_kbc_stop(kbc);
574} 574}
575 575
576static bool __devinit 576static bool
577tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata, 577tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
578 struct device *dev, unsigned int *num_rows) 578 struct device *dev, unsigned int *num_rows)
579{ 579{
@@ -619,7 +619,7 @@ tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
619} 619}
620 620
621#ifdef CONFIG_OF 621#ifdef CONFIG_OF
622static struct tegra_kbc_platform_data * __devinit tegra_kbc_dt_parse_pdata( 622static struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata(
623 struct platform_device *pdev) 623 struct platform_device *pdev)
624{ 624{
625 struct tegra_kbc_platform_data *pdata; 625 struct tegra_kbc_platform_data *pdata;
@@ -670,7 +670,7 @@ static inline struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata(
670} 670}
671#endif 671#endif
672 672
673static int __devinit tegra_kbd_setup_keymap(struct tegra_kbc *kbc) 673static int tegra_kbd_setup_keymap(struct tegra_kbc *kbc)
674{ 674{
675 const struct tegra_kbc_platform_data *pdata = kbc->pdata; 675 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
676 const struct matrix_keymap_data *keymap_data = pdata->keymap_data; 676 const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
@@ -697,7 +697,7 @@ static int __devinit tegra_kbd_setup_keymap(struct tegra_kbc *kbc)
697 return retval; 697 return retval;
698} 698}
699 699
700static int __devinit tegra_kbc_probe(struct platform_device *pdev) 700static int tegra_kbc_probe(struct platform_device *pdev)
701{ 701{
702 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data; 702 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data;
703 struct tegra_kbc *kbc; 703 struct tegra_kbc *kbc;
@@ -838,7 +838,7 @@ err_free_pdata:
838 return err; 838 return err;
839} 839}
840 840
841static int __devexit tegra_kbc_remove(struct platform_device *pdev) 841static int tegra_kbc_remove(struct platform_device *pdev)
842{ 842{
843 struct tegra_kbc *kbc = platform_get_drvdata(pdev); 843 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
844 struct resource *res; 844 struct resource *res;
@@ -954,7 +954,7 @@ MODULE_DEVICE_TABLE(of, tegra_kbc_of_match);
954 954
955static struct platform_driver tegra_kbc_driver = { 955static struct platform_driver tegra_kbc_driver = {
956 .probe = tegra_kbc_probe, 956 .probe = tegra_kbc_probe,
957 .remove = __devexit_p(tegra_kbc_remove), 957 .remove = tegra_kbc_remove,
958 .driver = { 958 .driver = {
959 .name = "tegra-kbc", 959 .name = "tegra-kbc",
960 .owner = THIS_MODULE, 960 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index 4c34f21fbe2d..ee1635011292 100644
--- a/drivers/input/keyboard/tnetv107x-keypad.c
+++ b/drivers/input/keyboard/tnetv107x-keypad.c
@@ -153,7 +153,7 @@ static void keypad_stop(struct input_dev *dev)
153 clk_disable(kp->clk); 153 clk_disable(kp->clk);
154} 154}
155 155
156static int __devinit keypad_probe(struct platform_device *pdev) 156static int keypad_probe(struct platform_device *pdev)
157{ 157{
158 const struct matrix_keypad_platform_data *pdata; 158 const struct matrix_keypad_platform_data *pdata;
159 const struct matrix_keymap_data *keymap_data; 159 const struct matrix_keymap_data *keymap_data;
@@ -301,7 +301,7 @@ error_res:
301 return error; 301 return error;
302} 302}
303 303
304static int __devexit keypad_remove(struct platform_device *pdev) 304static int keypad_remove(struct platform_device *pdev)
305{ 305{
306 struct keypad_data *kp = platform_get_drvdata(pdev); 306 struct keypad_data *kp = platform_get_drvdata(pdev);
307 307
@@ -319,7 +319,7 @@ static int __devexit keypad_remove(struct platform_device *pdev)
319 319
320static struct platform_driver keypad_driver = { 320static struct platform_driver keypad_driver = {
321 .probe = keypad_probe, 321 .probe = keypad_probe,
322 .remove = __devexit_p(keypad_remove), 322 .remove = keypad_remove,
323 .driver.name = "tnetv107x-keypad", 323 .driver.name = "tnetv107x-keypad",
324 .driver.owner = THIS_MODULE, 324 .driver.owner = THIS_MODULE,
325}; 325};
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index a2c6f79aa101..04f84fd57173 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -271,7 +271,7 @@ static irqreturn_t do_kp_irq(int irq, void *_kp)
271 return IRQ_HANDLED; 271 return IRQ_HANDLED;
272} 272}
273 273
274static int __devinit twl4030_kp_program(struct twl4030_keypad *kp) 274static int twl4030_kp_program(struct twl4030_keypad *kp)
275{ 275{
276 u8 reg; 276 u8 reg;
277 int i; 277 int i;
@@ -328,7 +328,7 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
328 * Registers keypad device with input subsystem 328 * Registers keypad device with input subsystem
329 * and configures TWL4030 keypad registers 329 * and configures TWL4030 keypad registers
330 */ 330 */
331static int __devinit twl4030_kp_probe(struct platform_device *pdev) 331static int twl4030_kp_probe(struct platform_device *pdev)
332{ 332{
333 struct twl4030_keypad_data *pdata = pdev->dev.platform_data; 333 struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
334 const struct matrix_keymap_data *keymap_data; 334 const struct matrix_keymap_data *keymap_data;
@@ -432,7 +432,7 @@ err1:
432 return error; 432 return error;
433} 433}
434 434
435static int __devexit twl4030_kp_remove(struct platform_device *pdev) 435static int twl4030_kp_remove(struct platform_device *pdev)
436{ 436{
437 struct twl4030_keypad *kp = platform_get_drvdata(pdev); 437 struct twl4030_keypad *kp = platform_get_drvdata(pdev);
438 438
@@ -452,7 +452,7 @@ static int __devexit twl4030_kp_remove(struct platform_device *pdev)
452 452
453static struct platform_driver twl4030_kp_driver = { 453static struct platform_driver twl4030_kp_driver = {
454 .probe = twl4030_kp_probe, 454 .probe = twl4030_kp_probe,
455 .remove = __devexit_p(twl4030_kp_remove), 455 .remove = twl4030_kp_remove,
456 .driver = { 456 .driver = {
457 .name = "twl4030_keypad", 457 .name = "twl4030_keypad",
458 .owner = THIS_MODULE, 458 .owner = THIS_MODULE,
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
index e0f6cd1ad0fd..ee163bee8cce 100644
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ b/drivers/input/keyboard/w90p910_keypad.c
@@ -118,7 +118,7 @@ static void w90p910_keypad_close(struct input_dev *dev)
118 clk_disable(keypad->clk); 118 clk_disable(keypad->clk);
119} 119}
120 120
121static int __devinit w90p910_keypad_probe(struct platform_device *pdev) 121static int w90p910_keypad_probe(struct platform_device *pdev)
122{ 122{
123 const struct w90p910_keypad_platform_data *pdata = 123 const struct w90p910_keypad_platform_data *pdata =
124 pdev->dev.platform_data; 124 pdev->dev.platform_data;
@@ -234,7 +234,7 @@ failed_free:
234 return error; 234 return error;
235} 235}
236 236
237static int __devexit w90p910_keypad_remove(struct platform_device *pdev) 237static int w90p910_keypad_remove(struct platform_device *pdev)
238{ 238{
239 struct w90p910_keypad *keypad = platform_get_drvdata(pdev); 239 struct w90p910_keypad *keypad = platform_get_drvdata(pdev);
240 struct resource *res; 240 struct resource *res;
@@ -257,7 +257,7 @@ static int __devexit w90p910_keypad_remove(struct platform_device *pdev)
257 257
258static struct platform_driver w90p910_keypad_driver = { 258static struct platform_driver w90p910_keypad_driver = {
259 .probe = w90p910_keypad_probe, 259 .probe = w90p910_keypad_probe,
260 .remove = __devexit_p(w90p910_keypad_remove), 260 .remove = w90p910_keypad_remove,
261 .driver = { 261 .driver = {
262 .name = "nuc900-kpi", 262 .name = "nuc900-kpi",
263 .owner = THIS_MODULE, 263 .owner = THIS_MODULE,