Commit 5b76d7b4 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: gpio_keys - report initial state when opening the device

Instead of reporting the initial stage when the device is registered we
should do it when the device is opened (so there are users).
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a57da347
...@@ -526,12 +526,35 @@ static int gpio_keys_setup_key(struct platform_device *pdev, ...@@ -526,12 +526,35 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
return error; return error;
} }
static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
{
struct input_dev *input = ddata->input;
int i;
for (i = 0; i < ddata->pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i];
if (gpio_is_valid(bdata->button->gpio))
gpio_keys_gpio_report_event(bdata);
}
input_sync(input);
}
static int gpio_keys_open(struct input_dev *input) static int gpio_keys_open(struct input_dev *input)
{ {
struct gpio_keys_drvdata *ddata = input_get_drvdata(input); struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
const struct gpio_keys_platform_data *pdata = ddata->pdata; const struct gpio_keys_platform_data *pdata = ddata->pdata;
int error;
if (pdata->enable) {
error = pdata->enable(input->dev.parent);
if (error)
return error;
}
return pdata->enable ? pdata->enable(input->dev.parent) : 0; /* Report current state of buttons that are connected to GPIOs */
gpio_keys_report_state(ddata);
return 0;
} }
static void gpio_keys_close(struct input_dev *input) static void gpio_keys_close(struct input_dev *input)
...@@ -731,14 +754,6 @@ static int gpio_keys_probe(struct platform_device *pdev) ...@@ -731,14 +754,6 @@ static int gpio_keys_probe(struct platform_device *pdev)
goto fail3; goto fail3;
} }
/* get current state of buttons that are connected to GPIOs */
for (i = 0; i < pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i];
if (gpio_is_valid(bdata->button->gpio))
gpio_keys_gpio_report_event(bdata);
}
input_sync(input);
device_init_wakeup(&pdev->dev, wakeup); device_init_wakeup(&pdev->dev, wakeup);
return 0; return 0;
...@@ -810,11 +825,9 @@ static int gpio_keys_resume(struct device *dev) ...@@ -810,11 +825,9 @@ static int gpio_keys_resume(struct device *dev)
struct gpio_button_data *bdata = &ddata->data[i]; struct gpio_button_data *bdata = &ddata->data[i];
if (bdata->button->wakeup && device_may_wakeup(dev)) if (bdata->button->wakeup && device_may_wakeup(dev))
disable_irq_wake(bdata->irq); disable_irq_wake(bdata->irq);
if (gpio_is_valid(bdata->button->gpio))
gpio_keys_gpio_report_event(bdata);
} }
input_sync(ddata->input);
gpio_keys_report_state(ddata);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment