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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 7 Mar 2023 11:41:55 +0800
From:   Keguang Zhang <keguang.zhang@...il.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>
Subject: Re: [PATCH v2 4/5] gpio: loongson1: Add DT support

On Mon, Mar 6, 2023 at 5:39 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
>
> On Thu, Mar 2, 2023 at 1:53 PM Keguang Zhang <keguang.zhang@...il.com> wrote:
> >
> > This patch adds DT support for Loongson-1 GPIO driver.
> >
> > Signed-off-by: Keguang Zhang <keguang.zhang@...il.com>
> > ---
> > V1 -> V2: Let gpiolib parse ngpios property
> >           Remove unnecessary alias id parsing
> >           Remove superfluous initialization done by bgpio_init()
> >           Add MODULE_DEVICE_TABLE()
> >           Other minor fixes
> > ---
> >  drivers/gpio/gpio-loongson1.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c
> > index 3ac9e49e7efb..94ac0ccb450f 100644
> > --- a/drivers/gpio/gpio-loongson1.c
> > +++ b/drivers/gpio/gpio-loongson1.c
> > @@ -68,25 +68,38 @@ static int ls1x_gpio_probe(struct platform_device *pdev)
> >         ls1x_gc->gc.owner = THIS_MODULE;
> >         ls1x_gc->gc.request = ls1x_gpio_request;
> >         ls1x_gc->gc.free = ls1x_gpio_free;
> > -       ls1x_gc->gc.base = pdev->id * 32;
> > +       /*
> > +        * Clear ngpio to let gpiolib get the correct number
> > +        * by reading ngpios property
> > +        */
> > +       ls1x_gc->gc.ngpio = 0;
> >
>
> Who could have set it before and why would this information need to be
> unconditionally discarded?
>
'ngpio' has been set to 32 by bgpio_init().
But this is incorrect for LS1B who has different number of GPIOs for each group.
To get the right number, I have to discard this default value to let
gpiolib parse 'ngpios' property.


> Bart
>
> >         ret = devm_gpiochip_add_data(dev, &ls1x_gc->gc, ls1x_gc);
> >         if (ret)
> >                 goto err;
> >
> >         platform_set_drvdata(pdev, ls1x_gc);
> > -       dev_info(dev, "Loongson1 GPIO driver registered\n");
> > +
> > +       dev_info(dev, "GPIO controller registered with %d pins\n",
> > +                ls1x_gc->gc.ngpio);
> >
> >         return 0;
> >  err:
> > -       dev_err(dev, "failed to register GPIO device\n");
> > +       dev_err(dev, "failed to register GPIO controller\n");
> >         return ret;
> >  }
> >
> > +static const struct of_device_id ls1x_gpio_dt_ids[] = {
> > +       { .compatible = "loongson,ls1x-gpio" },
> > +       { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, ls1x_gpio_dt_ids);
> > +
> >  static struct platform_driver ls1x_gpio_driver = {
> >         .probe  = ls1x_gpio_probe,
> >         .driver = {
> >                 .name   = "ls1x-gpio",
> > +               .of_match_table = ls1x_gpio_dt_ids,
> >         },
> >  };
> >
> > --
> > 2.34.1
> >



--
Best regards,

Kelvin Cheung

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ