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>
This commit is contained in:
parent
448cd1664a
commit
173bdd746b
|
@ -39,6 +39,8 @@ struct gpio_keys_drvdata {
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
struct mutex disable_lock;
|
struct mutex disable_lock;
|
||||||
unsigned int n_buttons;
|
unsigned int n_buttons;
|
||||||
|
int (*enable)(struct device *dev);
|
||||||
|
void (*disable)(struct device *dev);
|
||||||
struct gpio_button_data data[0];
|
struct gpio_button_data data[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -423,6 +425,21 @@ fail2:
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gpio_keys_open(struct input_dev *input)
|
||||||
|
{
|
||||||
|
struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
|
||||||
|
|
||||||
|
return ddata->enable ? ddata->enable(input->dev.parent) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gpio_keys_close(struct input_dev *input)
|
||||||
|
{
|
||||||
|
struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
|
||||||
|
|
||||||
|
if (ddata->disable)
|
||||||
|
ddata->disable(input->dev.parent);
|
||||||
|
}
|
||||||
|
|
||||||
static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
|
||||||
|
@ -444,13 +461,18 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ddata->input = input;
|
ddata->input = input;
|
||||||
ddata->n_buttons = pdata->nbuttons;
|
ddata->n_buttons = pdata->nbuttons;
|
||||||
|
ddata->enable = pdata->enable;
|
||||||
|
ddata->disable = pdata->disable;
|
||||||
mutex_init(&ddata->disable_lock);
|
mutex_init(&ddata->disable_lock);
|
||||||
|
|
||||||
platform_set_drvdata(pdev, ddata);
|
platform_set_drvdata(pdev, ddata);
|
||||||
|
input_set_drvdata(input, ddata);
|
||||||
|
|
||||||
input->name = pdev->name;
|
input->name = pdev->name;
|
||||||
input->phys = "gpio-keys/input0";
|
input->phys = "gpio-keys/input0";
|
||||||
input->dev.parent = &pdev->dev;
|
input->dev.parent = &pdev->dev;
|
||||||
|
input->open = gpio_keys_open;
|
||||||
|
input->close = gpio_keys_close;
|
||||||
|
|
||||||
input->id.bustype = BUS_HOST;
|
input->id.bustype = BUS_HOST;
|
||||||
input->id.vendor = 0x0001;
|
input->id.vendor = 0x0001;
|
||||||
|
|
|
@ -17,6 +17,8 @@ struct gpio_keys_platform_data {
|
||||||
struct gpio_keys_button *buttons;
|
struct gpio_keys_button *buttons;
|
||||||
int nbuttons;
|
int nbuttons;
|
||||||
unsigned int rep:1; /* enable input subsystem auto repeat */
|
unsigned int rep:1; /* enable input subsystem auto repeat */
|
||||||
|
int (*enable)(struct device *dev);
|
||||||
|
void (*disable)(struct device *dev);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue