[PATCH 2/3] drm/sitronix/st7571-i2c: Make the reset GPIO to be optional

Marcus Folkesson marcus.folkesson at gmail.com
Thu Jul 10 11:10:45 UTC 2025


Hello Javier,

On Thu, Jul 10, 2025 at 01:00:41PM +0200, Javier Martinez Canillas wrote:
> >
> > devm_gpiod_get_optional() returns -ENOENT when the GPIO is not found,
> > and that is no error we want to propagage upwards.
> >
> > Maybe something like this instead:
> > if (IS_ERR(st7571->reset) && IS_ERR(st7571->reset) != -ENOENT)
> >
> 
> Are you sure about that? As far as I know, that is exactly the
> difference between gpiod_get() and gpiod_get_optional() variants.
> 
> From the gpiod_get_optional() function helper kernel-doc [0]:
> 
> /**
>  * gpiod_get_optional - obtain an optional GPIO for a given GPIO function
>  * @dev: GPIO consumer, can be NULL for system-global GPIOs
>  * @con_id: function within the GPIO consumer
>  * @flags: optional GPIO initialization flags
>  *
>  * This is equivalent to gpiod_get(), except that when no GPIO was assigned to
>  * the requested function it will return NULL. This is convenient for drivers
>  * that need to handle optional GPIOs.
>  *
>  * Returns:
>  * The GPIO descriptor corresponding to the function @con_id of device
>  * dev, NULL if no GPIO has been assigned to the requested function, or
>  * another IS_ERR() code if an error occurred while trying to acquire the GPIO.
>  */
> 
> while the gpiod_get() kernel-doc says the following:
> 
> /**
>  * gpiod_get - obtain a GPIO for a given GPIO function
>  * @dev:	GPIO consumer, can be NULL for system-global GPIOs
>  * @con_id:	function within the GPIO consumer
>  * @flags:	optional GPIO initialization flags
>  *
>  * Returns:
>  * The GPIO descriptor corresponding to the function @con_id of device
>  * dev, -ENOENT if no GPIO has been assigned to the requested function, or
>  * another IS_ERR() code if an error occurred while trying to acquire the GPIO.
>  */
> 

You are completely righ.

Reviewed-by: Marcus Folkesson <marcus.folkesson at gmail.com>

Best regards,
Marcus Folkesson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20250710/673b8b74/attachment-0001.sig>


More information about the dri-devel mailing list