mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-11 13:15:47 +00:00
ath79: gpio-latch-mikrotik: use dev_err_probe
It automatically adds the error code at the end of the message. It also deals with -EPROBE_DEFER automatically (doesn't output). Simpler code. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/16350 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
d3dad5b10b
commit
1e8dde776a
@ -121,24 +121,19 @@ static int gpio_latch_probe(struct platform_device *pdev)
|
|||||||
mutex_init(&glc->latch_mutex);
|
mutex_init(&glc->latch_mutex);
|
||||||
|
|
||||||
n = gpiod_count(dev, NULL);
|
n = gpiod_count(dev, NULL);
|
||||||
if (n <= 0) {
|
if (n <= 0)
|
||||||
dev_err(dev, "failed to get gpios: %d\n", n);
|
return dev_err_probe(dev, n, "failed to get gpios");
|
||||||
return n;
|
if (n != GPIO_LATCH_LINES) {
|
||||||
} else if (n != GPIO_LATCH_LINES) {
|
dev_err(dev, "expected %d gpios", GPIO_LATCH_LINES);
|
||||||
dev_err(dev, "expected %d gpios\n", GPIO_LATCH_LINES);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
glc->gpios[i] = devm_gpiod_get_index_optional(dev, NULL, i,
|
glc->gpios[i] = devm_gpiod_get_index_optional(dev, NULL, i,
|
||||||
GPIOD_OUT_LOW);
|
GPIOD_OUT_LOW);
|
||||||
if (IS_ERR(glc->gpios[i])) {
|
if (IS_ERR(glc->gpios[i]))
|
||||||
if (PTR_ERR(glc->gpios[i]) != -EPROBE_DEFER) {
|
return dev_err_probe(dev, PTR_ERR(glc->gpios[i]),
|
||||||
dev_err(dev, "failed to get gpio %d: %ld\n", i,
|
"failed to get gpio %d", i);
|
||||||
PTR_ERR(glc->gpios[i]));
|
|
||||||
}
|
|
||||||
return PTR_ERR(glc->gpios[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glc->le_gpio = 8;
|
glc->le_gpio = 8;
|
||||||
@ -162,13 +157,7 @@ static int gpio_latch_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
platform_set_drvdata(pdev, glc);
|
platform_set_drvdata(pdev, glc);
|
||||||
|
|
||||||
i = gpiochip_add(&glc->gc);
|
return gpiochip_add(&glc->gc);
|
||||||
if (i) {
|
|
||||||
dev_err(dev, "gpiochip_add() failed: %d\n", i);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gpio_latch_remove(struct platform_device *pdev)
|
static int gpio_latch_remove(struct platform_device *pdev)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user