Re: [PATCH] gpio: pl061: hook request if gpio-ranges avaiable

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

 



Hi Xinwei,

Do I miss anything? At here, .request pointer isn't null. It always
points to pl061_gpio_request().

Best Regards
Haojian

On 9 October 2014 18:38, k00278426 <kong.kongxinwei@xxxxxxxxxxxxx> wrote:
> On 2014/10/9 17:42, Haojian Zhuang wrote:
>
> gpio-ranges property could binds gpio to pinctrl. But there may be some
> gpios without pinctrl operation. So check whether gpio-ranges property
> exists in device node first.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@xxxxxxxxxx>
> ---
>  drivers/gpio/gpio-pl061.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index 84b49cf..d1813f0 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -52,28 +52,34 @@ struct pl061_gpio {
>
>   void __iomem *base;
>   struct gpio_chip gc;
> + int uses_pinctrl;
>
>  #ifdef CONFIG_PM
>   struct pl061_context_save_regs csave_regs;
>  #endif
>  };
>
> -static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset)
> +static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
>  {
>   /*
>   * Map back to global GPIO space and request muxing, the direction
>   * parameter does not matter for this controller.
>   */
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - return pinctrl_request_gpio(gpio);
> + if (chip->uses_pinctrl)
> + return pinctrl_request_gpio(gpio);
> + return 0;
>  }
>
>        In the request_gpio process,if the .request point is null,the  return
> of request_gpio process will value 0. the request_gpio process will not
> enter the pintrcl system.
>   so the request_gpio have deal with the "if" branch.
>
>
> -static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset)
> +static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
>  {
> - int gpio = chip->base + offset;
> + struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
> + int gpio = gc->base + offset;
>
> - pinctrl_free_gpio(gpio);
> + if (chip->uses_pinctrl)
> + pinctrl_free_gpio(gpio);
>  }
>
>  static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
> @@ -264,6 +270,9 @@ static int pl061_probe(struct amba_device *adev, const
> struct amba_id *id)
>
>   spin_lock_init(&chip->lock);
>
> + /* Hook the request()/free() for pinctrl operation */
> + if (of_property_read_bool(dev->of_node, "gpio-ranges"))
> + chip->uses_pinctrl = true;
>   chip->gc.request = pl061_gpio_request;
>   chip->gc.free = pl061_gpio_free;
>   chip->gc.direction_input = pl061_direction_input;
>
>
--
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