Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pps: clients: gpio: Rearrange optional stuff in pps_gpio_setup()

Rearrange optional stuff in pps_gpio_setup() so it will go after mandatory one
and with reduced indentation. This will increase readability of the sources.

Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210318130321.24227-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
6b3bc828 162a5dea

+18 -15
+18 -15
drivers/pps/clients/pps-gpio.c
··· 110 110 return dev_err_probe(dev, PTR_ERR(data->gpio_pin), 111 111 "failed to request PPS GPIO\n"); 112 112 113 + data->assert_falling_edge = 114 + device_property_read_bool(dev, "assert-falling-edge"); 115 + 113 116 data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW); 114 117 if (IS_ERR(data->echo_pin)) 115 118 return dev_err_probe(dev, PTR_ERR(data->echo_pin), 116 119 "failed to request ECHO GPIO\n"); 117 120 118 - if (data->echo_pin) { 119 - ret = device_property_read_u32(dev, "echo-active-ms", &value); 120 - if (ret) { 121 - dev_err(dev, "failed to get echo-active-ms from FW\n"); 122 - return ret; 123 - } 124 - data->echo_active_ms = value; 125 - /* sanity check on echo_active_ms */ 126 - if (!data->echo_active_ms || data->echo_active_ms > 999) { 127 - dev_err(dev, "echo-active-ms: %u - bad value from FW\n", 128 - data->echo_active_ms); 129 - return -EINVAL; 130 - } 121 + if (!data->echo_pin) 122 + return 0; 123 + 124 + ret = device_property_read_u32(dev, "echo-active-ms", &value); 125 + if (ret) { 126 + dev_err(dev, "failed to get echo-active-ms from FW\n"); 127 + return ret; 131 128 } 132 129 133 - data->assert_falling_edge = 134 - device_property_read_bool(dev, "assert-falling-edge"); 130 + /* sanity check on echo_active_ms */ 131 + if (!value || value > 999) { 132 + dev_err(dev, "echo-active-ms: %u - bad value from FW\n", value); 133 + return -EINVAL; 134 + } 135 + 136 + data->echo_active_ms = value; 137 + 135 138 return 0; 136 139 } 137 140