aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShubhrajyoti D <shubhrajyoti@ti.com>2010-08-03 22:44:40 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-08-03 22:45:31 -0400
commit173bdd746b128241d3d6d202142820692e7dd530 (patch)
tree4586610c9aee7d3689004e03ab0d4ed4e250f32d
parent448cd1664a573e69f54bfd32f3bb7220212b6cf5 (diff)
Input: gpio_keys - add hooks to enable/disable device
Allow platform code to specify callbcks that will be invoked when input device is opened or closed, allowing, for example, to enable the device. Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/keyboard/gpio_keys.c22
-rw-r--r--include/linux/gpio_keys.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index a9fd147f2ba7..6069abe31e42 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -39,6 +39,8 @@ struct gpio_keys_drvdata {
39 struct input_dev *input; 39 struct input_dev *input;
40 struct mutex disable_lock; 40 struct mutex disable_lock;
41 unsigned int n_buttons; 41 unsigned int n_buttons;
42 int (*enable)(struct device *dev);
43 void (*disable)(struct device *dev);
42 struct gpio_button_data data[0]; 44 struct gpio_button_data data[0];
43}; 45};
44 46
@@ -423,6 +425,21 @@ fail2:
423 return error; 425 return error;
424} 426}
425 427
428static int gpio_keys_open(struct input_dev *input)
429{
430 struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
431
432 return ddata->enable ? ddata->enable(input->dev.parent) : 0;
433}
434
435static void gpio_keys_close(struct input_dev *input)
436{
437 struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
438
439 if (ddata->disable)
440 ddata->disable(input->dev.parent);
441}
442
426static int __devinit gpio_keys_probe(struct platform_device *pdev) 443static int __devinit gpio_keys_probe(struct platform_device *pdev)
427{ 444{
428 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 445 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
@@ -444,13 +461,18 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
444 461
445 ddata->input = input; 462 ddata->input = input;
446 ddata->n_buttons = pdata->nbuttons; 463 ddata->n_buttons = pdata->nbuttons;
464 ddata->enable = pdata->enable;
465 ddata->disable = pdata->disable;
447 mutex_init(&ddata->disable_lock); 466 mutex_init(&ddata->disable_lock);
448 467
449 platform_set_drvdata(pdev, ddata); 468 platform_set_drvdata(pdev, ddata);
469 input_set_drvdata(input, ddata);
450 470
451 input->name = pdev->name; 471 input->name = pdev->name;
452 input->phys = "gpio-keys/input0"; 472 input->phys = "gpio-keys/input0";
453 input->dev.parent = &pdev->dev; 473 input->dev.parent = &pdev->dev;
474 input->open = gpio_keys_open;
475 input->close = gpio_keys_close;
454 476
455 input->id.bustype = BUS_HOST; 477 input->id.bustype = BUS_HOST;
456 input->id.vendor = 0x0001; 478 input->id.vendor = 0x0001;
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index cd0b3f30f48e..ce73a30113b4 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -17,6 +17,8 @@ struct gpio_keys_platform_data {
17 struct gpio_keys_button *buttons; 17 struct gpio_keys_button *buttons;
18 int nbuttons; 18 int nbuttons;
19 unsigned int rep:1; /* enable input subsystem auto repeat */ 19 unsigned int rep:1; /* enable input subsystem auto repeat */
20 int (*enable)(struct device *dev);
21 void (*disable)(struct device *dev);
20}; 22};
21 23
22#endif 24#endif