Re: [PATCH v2] gpio: mxc: Shift generic request/free after gpiochip registration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 25, 2016 at 8:02 PM, Deepak Das <deepak_das@xxxxxxxxxx> wrote:

> generic gpio request/free should be added after gpiocip registration
> to validate mapping of gpiochip with pinctrl subsystem.
>
> gpiochip->pin_ranges list contains the information used by pinctrl
> subsystem to configure corresponding pins for gpio usage.
> This list will be empty if gpiochip fails to map with
> pinctrl subsystem for any reason.
> For Ex.:-
> generic gpio request/free should not be used if IOMUX pin controller
> device node is disabled in device tree.
>
> This commit checks above list and skips adding generic gpio request/free
> if list is found empty.
>
> Signed-off-by: Deepak Das <deepak_das@xxxxxxxxxx>
> Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@xxxxxxxxxx>

So we should not dereference gpiolib internals.

> -       if (of_property_read_bool(np, "gpio-ranges")) {
> -               port->gc.request = gpiochip_generic_request;
> -               port->gc.free = gpiochip_generic_free;
> -       }
> -
>         port->gc.to_irq = mxc_gpio_to_irq;
>         port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
>                                              pdev->id * 32;
> @@ -471,6 +466,11 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>         if (err)
>                 goto out_bgio;
>
> +       if (!list_empty(&port->gc.pin_ranges)) {
> +               port->gc.request = gpiochip_generic_request;
> +               port->gc.free = gpiochip_generic_free;
> +       }

Can't you just check the "gpio-ranges" property later instead?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux