[PATCH 2/3] drm/sitronix/st7571-i2c: Make the reset GPIO to be optional
Javier Martinez Canillas
javierm at redhat.com
Fri Jul 11 19:25:00 UTC 2025
Marcus Folkesson <marcus.folkesson at gmail.com> writes:
Hello Marcus,
> 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>
>
Thanks for your review! Do you plan to look at the other patches too ?
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
More information about the dri-devel
mailing list