# Re: \[PATCH V1\] input: keyboard: gpio: Support for interrupt only key

- From: Laxman Dewangan \<ldewangan@nvidia.com\>
- Date: 2012-03-19 07:29:58 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2012/03/3837851
- Thread: https://ratatoskr.run/linux-input/2012/03/3835666/t.md

```text
Hi Dmitry,

On Monday 19 March 2012 11:36 AM, Dmitry Torokhov wrote:
>
> OK, so I am generally happy with the patch; the only issue is that in
> interrupt mode the only event type that makes sense is EV_KEY so we need
> to make sure we do not accept anything else.
>

Thanks for taking care of patch. I am ok with this policy.

> Also, I do not think that having button_irq() that is called all the
> time is the best solution; I;d rather pulled RQ number up into button
> data.
>

Yes, this is nice cleanups.

> I tried doing the above in the patch below. Please let me know if it
> still works for you. Note that it depends on some other patches for
> gpio_keys that I have; I am attaching them for your reference.
>

This works fine with one small change.
The function gpio_keys_report_event() is gettign called from probe for initialing the key state. This function should bypass if it is not the gpio based otherwise system crash.
I made following change and after that it works fine.

static void gpio_keys_report_event(struct gpio_button_data *bdata)
{
    const struct gpio_keys_button *button = bdata->button;
    struct input_dev *input = bdata->input;
    unsigned int type = button->type ?: EV_KEY;
    int state;

    if (!gpio_is_valid(button->gpio))
        return;

    state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;


```
