diff mbox series

[v1,09/10] gpio: pca953x: Get rid of useless goto label

Message ID 20230901134041.1165562-9-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,01/10] gpio: pca953x: Drop unused fields in struct pca953x_platform_data | expand

Commit Message

Andy Shevchenko Sept. 1, 2023, 1:40 p.m. UTC
In a few functions goto label is useless as there are no locking,
no nothing that may justify its usage. Get rid of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

Comments

Bartosz Golaszewski Sept. 4, 2023, 7:41 a.m. UTC | #1
On Fri, Sep 1, 2023 at 3:40 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> In a few functions goto label is useless as there are no locking,
> no nothing that may justify its usage. Get rid of it.
>

I guess it was supposed to be "so nothing" but I'll fix it when applying.

Bart

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index bf27e2d920f7..16f5e3043bf0 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -988,20 +988,18 @@ static int device_pca95xx_init(struct pca953x_chip *chip)
>         ret = regcache_sync_region(chip->regmap, regaddr,
>                                    regaddr + NBANK(chip) - 1);
>         if (ret)
> -               goto out;
> +               return ret;
>
>         regaddr = chip->recalc_addr(chip, chip->regs->direction, 0);
>         ret = regcache_sync_region(chip->regmap, regaddr,
>                                    regaddr + NBANK(chip) - 1);
>         if (ret)
> -               goto out;
> +               return ret;
>
>         /* clear polarity inversion */
>         bitmap_zero(val, MAX_LINE);
>
> -       ret = pca953x_write_regs(chip, chip->regs->invert, val);
> -out:
> -       return ret;
> +       return pca953x_write_regs(chip, chip->regs->invert, val);
>  }
>
>  static int device_pca957x_init(struct pca953x_chip *chip)
> @@ -1012,19 +1010,13 @@ static int device_pca957x_init(struct pca953x_chip *chip)
>
>         ret = device_pca95xx_init(chip);
>         if (ret)
> -               goto out;
> +               return ret;
>
>         /* To enable register 6, 7 to control pull up and pull down */
>         for (i = 0; i < NBANK(chip); i++)
>                 bitmap_set_value8(val, 0x02, i * BANK_SZ);
>
> -       ret = pca953x_write_regs(chip, PCA957X_BKEN, val);
> -       if (ret)
> -               goto out;
> -
> -       return 0;
> -out:
> -       return ret;
> +       return pca953x_write_regs(chip, PCA957X_BKEN, val);
>  }
>
>  static void pca953x_disable_regulator(void *reg)
> @@ -1262,12 +1254,10 @@ static int pca953x_resume(struct device *dev)
>         }
>
>         ret = pca953x_restore_context(chip);
> -       if (ret) {
> +       if (ret)
>                 dev_err(dev, "Failed to restore register map: %d\n", ret);
> -               return ret;
> -       }
>
> -       return 0;
> +       return ret;
>  }
>
>  static DEFINE_SIMPLE_DEV_PM_OPS(pca953x_pm_ops, pca953x_suspend, pca953x_resume);
> --
> 2.40.0.1.gaa8946217a0b
>
Andy Shevchenko Sept. 4, 2023, 8:38 a.m. UTC | #2
On Mon, Sep 4, 2023 at 10:41 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> On Fri, Sep 1, 2023 at 3:40 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > In a few functions goto label is useless as there are no locking,

are --> is (that's I missed)

> > no nothing that may justify its usage. Get rid of it.
>
> I guess it was supposed to be "so nothing" but I'll fix it when applying.

Either will work, while original is incorrect grammatically, the de
facto use of it is common
https://www.urbandictionary.com/define.php?term=no%20nothing
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index bf27e2d920f7..16f5e3043bf0 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -988,20 +988,18 @@  static int device_pca95xx_init(struct pca953x_chip *chip)
 	ret = regcache_sync_region(chip->regmap, regaddr,
 				   regaddr + NBANK(chip) - 1);
 	if (ret)
-		goto out;
+		return ret;
 
 	regaddr = chip->recalc_addr(chip, chip->regs->direction, 0);
 	ret = regcache_sync_region(chip->regmap, regaddr,
 				   regaddr + NBANK(chip) - 1);
 	if (ret)
-		goto out;
+		return ret;
 
 	/* clear polarity inversion */
 	bitmap_zero(val, MAX_LINE);
 
-	ret = pca953x_write_regs(chip, chip->regs->invert, val);
-out:
-	return ret;
+	return pca953x_write_regs(chip, chip->regs->invert, val);
 }
 
 static int device_pca957x_init(struct pca953x_chip *chip)
@@ -1012,19 +1010,13 @@  static int device_pca957x_init(struct pca953x_chip *chip)
 
 	ret = device_pca95xx_init(chip);
 	if (ret)
-		goto out;
+		return ret;
 
 	/* To enable register 6, 7 to control pull up and pull down */
 	for (i = 0; i < NBANK(chip); i++)
 		bitmap_set_value8(val, 0x02, i * BANK_SZ);
 
-	ret = pca953x_write_regs(chip, PCA957X_BKEN, val);
-	if (ret)
-		goto out;
-
-	return 0;
-out:
-	return ret;
+	return pca953x_write_regs(chip, PCA957X_BKEN, val);
 }
 
 static void pca953x_disable_regulator(void *reg)
@@ -1262,12 +1254,10 @@  static int pca953x_resume(struct device *dev)
 	}
 
 	ret = pca953x_restore_context(chip);
-	if (ret) {
+	if (ret)
 		dev_err(dev, "Failed to restore register map: %d\n", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(pca953x_pm_ops, pca953x_suspend, pca953x_resume);