[PATCH 2/2] firmware: altera-serial: simplify handling of optional gpio

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Mon Sep 26 02:11:37 PDT 2016


Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 drivers/firmware/altera_serial.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/firmware/altera_serial.c b/drivers/firmware/altera_serial.c
index 5486d9ec63e9..ddee991ed073 100644
--- a/drivers/firmware/altera_serial.c
+++ b/drivers/firmware/altera_serial.c
@@ -221,15 +221,13 @@ static int altera_spi_of(struct device_d *dev, struct fpga_spi *this)
 	int ret;
 
 	name = "nstat-gpios";
-	if (!of_get_property(n, name, NULL)) {
+	this->nstat_gpio = of_get_named_gpio(n, name, 0);
+	if (this->nstat_gpio == -ENOENT) {
 		dev_info(dev, "nstat-gpio is not specified, assuming it is not connected\n");
 		this->nstat_gpio = -1;
-	} else {
-		this->nstat_gpio = of_get_named_gpio(n, name, 0);
-		if (this->nstat_gpio < 0) {
-			ret = this->nstat_gpio;
-			goto out;
-		}
+	} else if (this->nstat_gpio < 0) {
+		ret = this->nstat_gpio;
+		goto out;
 	}
 
 	name = "confd-gpios";
-- 
2.9.3




More information about the barebox mailing list