]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: gpio: Correct use of -ENODEV in drivers
authorSimon Glass <sjg@chromium.org>
Sun, 17 Sep 2017 22:54:53 +0000 (16:54 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 9 Oct 2017 02:41:09 +0000 (20:41 -0600)
In U-Boot -ENODEV means that there is no device. When there is a problem
with the device, drivers should return an error like -ENXIO or -EREMOTEIO.
When the device tree properties cannot be read correct , they should
return -EINVAL.

Update various GPIO drivers to follow this rule, to help with consistency
for future driver writers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Adam Ford <aford173@gmail.com>
drivers/gpio/adi_gpio2.c
drivers/gpio/atmel_pio4.c
drivers/gpio/imx_rgpio2p.c
drivers/gpio/mxc_gpio.c
drivers/gpio/omap_gpio.c
drivers/gpio/tegra186_gpio.c
drivers/i2c/imx_lpi2c.c
drivers/i2c/mxc_i2c.c
drivers/i2c/tegra186_bpmp_i2c.c

index 4db08a344adbfd8b6c80dcde7fd4bfd061afefbe..1012f2d8eb8d2093621976ed91c9b8dab3432f58 100644 (file)
@@ -138,7 +138,7 @@ int peripheral_request(unsigned short per, const char *label)
                return 0;
 
        if (!(per & P_DEFINED))
-               return -ENODEV;
+               return -EINVAL;
 
        BUG_ON(ident >= MAX_RESOURCES);
 
index f3689467f01fd9a2bf25e9dc0052108c6d01b88e..30bc4296e3aa4235ac57bc659e2f14f0552ed40e 100644 (file)
@@ -50,11 +50,11 @@ static int atmel_pio4_config_io_func(u32 port, u32 pin,
        u32 reg, mask;
 
        if (pin >= ATMEL_PIO_NPINS_PER_BANK)
-               return -ENODEV;
+               return -EINVAL;
 
        port_base = atmel_pio4_port_base(port);
        if (!port_base)
-               return -ENODEV;
+               return -EINVAL;
 
        mask = 1 << pin;
        reg = func;
@@ -128,11 +128,11 @@ int atmel_pio4_set_pio_output(u32 port, u32 pin, u32 value)
        u32 reg, mask;
 
        if (pin >= ATMEL_PIO_NPINS_PER_BANK)
-               return -ENODEV;
+               return -EINVAL;
 
        port_base = atmel_pio4_port_base(port);
        if (!port_base)
-               return -ENODEV;
+               return -EINVAL;
 
        mask = 0x01 << pin;
        reg = ATMEL_PIO_CFGR_FUNC_GPIO | ATMEL_PIO_DIR_MASK;
@@ -154,11 +154,11 @@ int atmel_pio4_get_pio_input(u32 port, u32 pin)
        u32 reg, mask;
 
        if (pin >= ATMEL_PIO_NPINS_PER_BANK)
-               return -ENODEV;
+               return -EINVAL;
 
        port_base = atmel_pio4_port_base(port);
        if (!port_base)
-               return -ENODEV;
+               return -EINVAL;
 
        mask = 0x01 << pin;
        reg = ATMEL_PIO_CFGR_FUNC_GPIO;
index e60e9d2a0106f3563b2f56ce8fbe4686e01f25ca..7825714e8003c0e92573c11673013de58034e909 100644 (file)
@@ -168,7 +168,7 @@ static int imx_rgpio2p_bind(struct udevice *dev)
 
        addr = devfdt_get_addr_index(dev, 1);
        if (addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        /*
         * TODO:
index 0c42bd6cecd9149d03d4576cab23c0bd035831a6..c480eba9407a40c89575b72b94e0b2c4d01140c5 100644 (file)
@@ -304,7 +304,7 @@ static int mxc_gpio_bind(struct udevice *dev)
 
        addr = devfdt_get_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        /*
         * TODO:
index 1ab12f3f1e1cb13cd32207771d3f60bce951a189..7243100219a99399dd7b9985ed393a944ca42883 100644 (file)
@@ -307,7 +307,7 @@ static int omap_gpio_bind(struct udevice *dev)
 
        base_addr = devfdt_get_addr(dev);
        if (base_addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        /*
        * TODO:
index c5a7e13cceb8f88aba4d52f3a4920232c586738e..deb59e8b32024842fdb860ec40952766395f5b95 100644 (file)
@@ -181,7 +181,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
 
        regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
        if (regs == (uint32_t *)FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        for (port = 0; port < ctlr_data->port_count; port++) {
                struct tegra186_gpio_platdata *plat;
index aa97196e237c903694e19cc8e0ab999f889b21a8..e7ec17fe9e1b1c83d3021fadcb0968955fa2f3c9 100644 (file)
@@ -412,7 +412,7 @@ static int imx_lpi2c_probe(struct udevice *bus)
 
        addr = devfdt_get_addr(bus);
        if (addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        i2c_bus->base = addr;
        i2c_bus->index = bus->seq;
index b7bb76c0ed0c794ce1f7e183465e06ed397353e0..abf1da2ae3ee846cc8b4a88cd662fe5a8edd55a5 100644 (file)
@@ -176,7 +176,7 @@ static int bus_i2c_set_bus_speed(struct mxc_i2c_bus *i2c_bus, int speed)
        int reg_shift = quirk ? VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
 
        if (!base)
-               return -ENODEV;
+               return -EINVAL;
 
        /* Store divider value */
        writeb(idx, base + (IFDR << reg_shift));
@@ -239,7 +239,7 @@ static int tx_byte(struct mxc_i2c_bus *i2c_bus, u8 byte)
        if (ret < 0)
                return ret;
        if (ret & I2SR_RX_NO_AK)
-               return -ENODEV;
+               return -EREMOTEIO;
        return 0;
 }
 
@@ -418,14 +418,14 @@ static int i2c_init_transfer(struct mxc_i2c_bus *i2c_bus, u8 chip,
                        VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT;
 
        if (!i2c_bus->base)
-               return -ENODEV;
+               return -EINVAL;
 
        for (retry = 0; retry < 3; retry++) {
                ret = i2c_init_transfer_(i2c_bus, chip, addr, alen);
                if (ret >= 0)
                        return 0;
                i2c_imx_stop(i2c_bus);
-               if (ret == -ENODEV)
+               if (ret == -EREMOTEIO)
                        return ret;
 
                printf("%s: failed for chip 0x%x retry=%d\n", __func__, chip,
@@ -754,7 +754,7 @@ static int mxc_i2c_probe(struct udevice *bus)
 
        addr = devfdt_get_addr(bus);
        if (addr == FDT_ADDR_T_NONE)
-               return -ENODEV;
+               return -EINVAL;
 
        i2c_bus->base = addr;
        i2c_bus->index = bus->seq;
@@ -783,7 +783,7 @@ static int mxc_i2c_probe(struct udevice *bus)
                    !dm_gpio_is_valid(&i2c_bus->scl_gpio) |
                    ret | ret2) {
                        dev_err(dev, "i2c bus %d at %lu, fail to request scl/sda gpio\n", bus->seq, i2c_bus->base);
-                       return -ENODEV;
+                       return -EINVAL;
                }
        }
 
index 931c6de508c02b2c0c3475470908a61f7f59b1fe..b46a09a4e07e1638f076e531225e00b18da0b57e 100644 (file)
@@ -94,7 +94,7 @@ static int tegra186_bpmp_i2c_probe(struct udevice *dev)
                                            "nvidia,bpmp-bus-id", U32_MAX);
        if (priv->bpmp_bus_id == U32_MAX) {
                debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);
-               return -ENODEV;
+               return -EINVAL;
        }
 
        return 0;