gpio: pca953x: propagate the errno from the chip_init functions
authorWolfram Sang <w.sang@pengutronix.de>
Fri, 14 Oct 2011 13:32:00 +0000 (15:32 +0200)
committerGrant Likely <grant.likely@secretlab.ca>
Sat, 29 Oct 2011 10:26:29 +0000 (12:26 +0200)
Initializing the chips may return with an error, but this error gets
dropped in probe(). Propagate this further to the driver core. Also,
simplify returning the error in one of the init functions.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
drivers/gpio/gpio-pca953x.c

index 45de6a4..a3fef0c 100644 (file)
@@ -595,9 +595,6 @@ static int __devinit device_pca953x_init(struct pca953x_chip *chip, int invert)
 
        /* set platform specific polarity inversion */
        ret = pca953x_write_reg(chip, PCA953X_INVERT, invert);
 
        /* set platform specific polarity inversion */
        ret = pca953x_write_reg(chip, PCA953X_INVERT, invert);
-       if (ret)
-               goto out;
-       return 0;
 out:
        return ret;
 }
 out:
        return ret;
 }
@@ -639,7 +636,7 @@ static int __devinit pca953x_probe(struct i2c_client *client,
        struct pca953x_platform_data *pdata;
        struct pca953x_chip *chip;
        int irq_base=0, invert=0;
        struct pca953x_platform_data *pdata;
        struct pca953x_chip *chip;
        int irq_base=0, invert=0;
-       int ret = 0;
+       int ret;
 
        chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
        if (chip == NULL)
 
        chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
        if (chip == NULL)
@@ -672,9 +669,11 @@ static int __devinit pca953x_probe(struct i2c_client *client,
        pca953x_setup_gpio(chip, id->driver_data & PCA_GPIO_MASK);
 
        if (chip->chip_type == PCA953X_TYPE)
        pca953x_setup_gpio(chip, id->driver_data & PCA_GPIO_MASK);
 
        if (chip->chip_type == PCA953X_TYPE)
-               device_pca953x_init(chip, invert);
+               ret = device_pca953x_init(chip, invert);
        else
        else
-               device_pca957x_init(chip, invert);
+               ret = device_pca957x_init(chip, invert);
+       if (ret)
+               goto out_failed;
 
        ret = pca953x_irq_setup(chip, id, irq_base);
        if (ret)
 
        ret = pca953x_irq_setup(chip, id, irq_base);
        if (ret)