Skip to content

Commit

Permalink
pps: clients: gpio: Rearrange optional stuff in pps_gpio_setup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
andy-shev authored and gregkh committed Mar 24, 2021
1 parent 162a5de commit 6b3bc82
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions drivers/pps/clients/pps-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,31 @@ static int pps_gpio_setup(struct device *dev)
return dev_err_probe(dev, PTR_ERR(data->gpio_pin),
"failed to request PPS GPIO\n");

data->assert_falling_edge =
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 (data->echo_pin) {
ret = device_property_read_u32(dev, "echo-active-ms", &value);
if (ret) {
dev_err(dev, "failed to get echo-active-ms from FW\n");
return ret;
}
data->echo_active_ms = value;
/* sanity check on echo_active_ms */
if (!data->echo_active_ms || data->echo_active_ms > 999) {
dev_err(dev, "echo-active-ms: %u - bad value from FW\n",
data->echo_active_ms);
return -EINVAL;
}
if (!data->echo_pin)
return 0;

ret = device_property_read_u32(dev, "echo-active-ms", &value);
if (ret) {
dev_err(dev, "failed to get echo-active-ms from FW\n");
return ret;
}

data->assert_falling_edge =
device_property_read_bool(dev, "assert-falling-edge");
/* sanity check on echo_active_ms */
if (!value || value > 999) {
dev_err(dev, "echo-active-ms: %u - bad value from FW\n", value);
return -EINVAL;
}

data->echo_active_ms = value;

return 0;
}

Expand Down

0 comments on commit 6b3bc82

Please sign in to comment.