Skip to content

Commit 6b3bc82

Browse files
andy-shevgregkh
authored andcommitted
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>
1 parent 162a5de commit 6b3bc82

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

drivers/pps/clients/pps-gpio.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,31 @@ static int pps_gpio_setup(struct device *dev)
110110
return dev_err_probe(dev, PTR_ERR(data->gpio_pin),
111111
"failed to request PPS GPIO\n");
112112

113+
data->assert_falling_edge =
114+
device_property_read_bool(dev, "assert-falling-edge");
115+
113116
data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW);
114117
if (IS_ERR(data->echo_pin))
115118
return dev_err_probe(dev, PTR_ERR(data->echo_pin),
116119
"failed to request ECHO GPIO\n");
117120

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;
131128
}
132129

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+
135138
return 0;
136139
}
137140

0 commit comments

Comments
 (0)