lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcXR9=5WwZqe=juLBDT1CZnYfWHCGDb4Tp211sL2AA_Gw@mail.gmail.com>
Date:   Wed, 31 Aug 2022 23:55:49 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Martyn Welch <martyn.welch@...labora.com>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Collabora Kernel ML <kernel@...labora.com>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/5] gpio: pca953x: Swap if statements to save later complexity

On Mon, Aug 29, 2022 at 4:43 PM Martyn Welch <martyn.welch@...labora.com> wrote:
>
> A later patch in the series adds support for a further chip type that
> shares some similarity with the PCA953X_TYPE. In order to keep the logic
> simple,

If you say so...
Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>

> swap over the if and else portions where checks are made against
> PCA953X_TYPE and instead check for PCA957X_TYPE.
>
> Signed-off-by: Martyn Welch <martyn.welch@...labora.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 41e7ff83a735..19a8eb94a629 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -293,13 +293,13 @@ static bool pca953x_readable_register(struct device *dev, unsigned int reg)
>         struct pca953x_chip *chip = dev_get_drvdata(dev);
>         u32 bank;
>
> -       if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) {
> -               bank = PCA953x_BANK_INPUT | PCA953x_BANK_OUTPUT |
> -                      PCA953x_BANK_POLARITY | PCA953x_BANK_CONFIG;
> -       } else {
> +       if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) {
>                 bank = PCA957x_BANK_INPUT | PCA957x_BANK_OUTPUT |
>                        PCA957x_BANK_POLARITY | PCA957x_BANK_CONFIG |
>                        PCA957x_BANK_BUSHOLD;
> +       } else {
> +               bank = PCA953x_BANK_INPUT | PCA953x_BANK_OUTPUT |
> +                      PCA953x_BANK_POLARITY | PCA953x_BANK_CONFIG;
>         }
>
>         if (chip->driver_data & PCA_PCAL) {
> @@ -316,12 +316,12 @@ static bool pca953x_writeable_register(struct device *dev, unsigned int reg)
>         struct pca953x_chip *chip = dev_get_drvdata(dev);
>         u32 bank;
>
> -       if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) {
> -               bank = PCA953x_BANK_OUTPUT | PCA953x_BANK_POLARITY |
> -                       PCA953x_BANK_CONFIG;
> -       } else {
> +       if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) {
>                 bank = PCA957x_BANK_OUTPUT | PCA957x_BANK_POLARITY |
>                         PCA957x_BANK_CONFIG | PCA957x_BANK_BUSHOLD;
> +       } else {
> +               bank = PCA953x_BANK_OUTPUT | PCA953x_BANK_POLARITY |
> +                       PCA953x_BANK_CONFIG;
>         }
>
>         if (chip->driver_data & PCA_PCAL)
> @@ -336,10 +336,10 @@ static bool pca953x_volatile_register(struct device *dev, unsigned int reg)
>         struct pca953x_chip *chip = dev_get_drvdata(dev);
>         u32 bank;
>
> -       if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE)
> -               bank = PCA953x_BANK_INPUT;
> -       else
> +       if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE)
>                 bank = PCA957x_BANK_INPUT;
> +       else
> +               bank = PCA953x_BANK_INPUT;
>
>         if (chip->driver_data & PCA_PCAL)
>                 bank |= PCAL9xxx_BANK_IRQ_STAT;
> @@ -1069,13 +1069,12 @@ static int pca953x_probe(struct i2c_client *client,
>         /* initialize cached registers from their original values.
>          * we can't share this chip with another i2c master.
>          */
> -
> -       if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) {
> -               chip->regs = &pca953x_regs;
> -               ret = device_pca95xx_init(chip, invert);
> -       } else {
> +       if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) {
>                 chip->regs = &pca957x_regs;
>                 ret = device_pca957x_init(chip, invert);
> +       } else {
> +               chip->regs = &pca953x_regs;
> +               ret = device_pca95xx_init(chip, invert);
>         }
>         if (ret)
>                 goto err_exit;
> --
> 2.35.1
>


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ