[RFT PATCH 14/21] hte: tegra194: don't access struct gpio_chip

Andy Shevchenko andriy.shevchenko at linux.intel.com
Wed Sep 6 07:47:00 PDT 2023


On Tue, Sep 05, 2023 at 08:53:02PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski at linaro.org>
> 
> Using struct gpio_chip is not safe as it will disappear if the
> underlying driver is unbound for any reason. Switch to using reference
> counted struct gpio_device and its dedicated accessors.

...

> +	struct gpio_device *gdev __free(gpio_device_put) = NULL;

Using this requires cleanup.h to be included.
Does any of the included GPIO headers guarantee that inclusion implicitly?
Even though, it's a good practice to include headers of what we are using
independently if other (library) headers include them. I.o.w. we can rely
only on our headers (here HTE framework related) to guarantee any inclusions
implicitly.

This also applies to other users of the same construct.

...

>  static int tegra_gpiochip_match(struct gpio_chip *chip, void *data)
>  {
>  	return chip->fwnode == of_node_to_fwnode(data);
>  }

Not sure how many users of this kind of match, but it might be useful to have
it by GPIO library

	gpio_device_find_by_fwnode()

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list