Re: [PATCH] pps: clients: gpio: Continue after failing to get optional ECHO pin

From: Rodolfo Giometti
Date: Mon Jun 03 2024 - 02:36:00 EST


On 01/06/24 00:44, Curtis Klein wrote:
Warn but do not fail when devm_gpiod_get_optional returns an error when
trying to get the ECHO pin. When creating a pps-gpio device using
platform data and GPIO lookup tables, the call to gpiod_get_optional
will match on the unlabeled pin meant as the input when searching for
the "echo" pin. Since it is already in use as the PPS input, it will

I'm not sure to well understand what you mean here: why the "echo" pin should be already in use as the PPS input?

Can you please explain better this situation with a real example?

fail with -EBUSY. As the ECHO pin is optional, we just warn on the error
and continue the initialization. This allows us to support devices
created using GPIO lookup tables instead of ACPI, DT, swnode, etc.

Signed-off-by: Curtis Klein <curtis.klein@xxxxxxx>
---
drivers/pps/clients/pps-gpio.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c
index 2f4b11b4dfcd..b7db4a3ee97e 100644
--- a/drivers/pps/clients/pps-gpio.c
+++ b/drivers/pps/clients/pps-gpio.c
@@ -114,9 +114,12 @@ static int pps_gpio_setup(struct device *dev)
device_property_read_bool(dev, "assert-falling-edge");
data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW);
- if (IS_ERR(data->echo_pin))
- return dev_err_probe(dev, PTR_ERR(data->echo_pin),
- "failed to request ECHO GPIO\n");
+ if (IS_ERR(data->echo_pin)) {
+ dev_warn(dev, "failed to request ECHO GPIO: %ld\n",
+ PTR_ERR(data->echo_pin));
+ data->echo_pin = NULL;
+ return 0;
+ }
if (!data->echo_pin)
return 0;

Thanks,

Rodolfo

--
GNU/Linux Solutions e-mail: giometti@xxxxxxxxxxxx
Linux Device Driver giometti@xxxxxxxx
Embedded Systems phone: +39 349 2432127
UNIX programming