Re: [PATCH V2 1/2] input: gpio-keys: add support for disable button from DT

From: Dmitry Torokhov
Date: Wed Jan 13 2016 - 02:06:16 EST


On Wed, Jan 13, 2016 at 11:44:16AM +0530, Laxman Dewangan wrote:
> Add support to disable the button from DT via status property
> if given button is not supporting on given platforms.
>
> This will help to re-use the existing dtsi file with status
> enable/disable across platforms.
>
> Signed-off-by: Laxman Dewangan <ldewangan@xxxxxxxxxx>
> ---
> Changes from V1:
> - Converted print to dev_dbg.
>
> drivers/input/keyboard/gpio_keys.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index bef317f..08bada8 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -632,6 +632,14 @@ gpio_keys_get_devtree_pdata(struct device *dev)
> for_each_child_of_node(node, pp) {

> enum of_gpio_flags flags;
>
> + /* Ignore the button if status of node is disabled */
> + error = of_device_is_available(pp);
> + if (!error) {
> + dev_dbg(dev, "Button %s is ignored\n", pp->name);
> + pdata->nbuttons--;

Looking at this some more, maybe we should be using
of_get_available_child_count() when calculating pdata->nbuttons (and do
not decrement it here) and maybe even use
for_each_available_child_of_node() in this loop and forego manual check.

> + continue;
> + }
> +
> button = &pdata->buttons[i++];
>
> button->gpio = of_get_gpio_flags(pp, 0, &flags);
> --
> 2.1.4
>

Thanks.

--
Dmitry