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]
Message-ID: <576a6244fa3b996327c49023fe953215@walle.cc>
Date:   Thu, 16 Apr 2020 11:34:26 +0200
From:   Michael Walle <michael@...le.cc>
To:     Linus Walleij <linus.walleij@...aro.org>
Cc:     Bartosz Golaszewski <bgolaszewski@...libre.com>,
        linux-gpio <linux-gpio@...r.kernel.org>,
        linux-devicetree <devicetree@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>, linux-hwmon@...r.kernel.org,
        linux-pwm@...r.kernel.org,
        LINUXWATCHDOG <linux-watchdog@...r.kernel.org>,
        arm-soc <linux-arm-kernel@...ts.infradead.org>,
        Rob Herring <robh+dt@...nel.org>,
        Jean Delvare <jdelvare@...e.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Lee Jones <lee.jones@...aro.org>,
        Thierry Reding <thierry.reding@...il.com>,
        Uwe Kleine-König <u.kleine-koenig@...gutronix.de>,
        Wim Van Sebroeck <wim@...ux-watchdog.org>,
        Shawn Guo <shawnguo@...nel.org>, Li Yang <leoyang.li@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jason Cooper <jason@...edaemon.net>,
        Marc Zyngier <maz@...nel.org>, Mark Brown <broonie@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v2 10/16] gpio: add a reusable generic gpio_chip using
 regmap

Am 2020-04-16 11:20, schrieb Linus Walleij:
> On Tue, Apr 14, 2020 at 9:57 PM Michael Walle <michael@...le.cc> wrote:
> 
>> So what about the following:
>> 
>> #define GPIO_REGMAP_ADDR_ZERO (unsigned int)(-1)
> 
> Yeah with regmap explicitly using int I guess we can't use
> S32_MAX, so that is fair.
> 
>> So this way the user might assign the base addresses the normal way
>> except when he wants to use zero, in that case he has to use
>> 
>>    ->base_adr = GPIO_REGMAP_ADDR_ZERO;
>> 
>> gpio-regmap.c could use then:
>> 
>> if (base_addr)
>>    something_useful(gpio_regmap_addr(base_addr));
>> 
>> unsigned int gpio_regmap_addr(unsigned int addr)
>> {
>>    return (addr == GPIO_REGMAP_ADDR_ZERO) ? 0 : addr;
>> }
> 
> That's reasonably clean.

Ok, at least on that side. For my sl28 gpio driver I then have
the problem that depending on 'base' I might have to use
GPIO_REGMAP_ADDR_ZERO:

   #define GPIO_REG_DIR 0
   config.reg_dir_out_base = base + GPIO_REG_DIR;

So there is still a convenience macro:
   #define GPIO_REGMAP_ADDR(addr) ((addr) ? addr : GPIO_REGMAP_ADDR_ZERO)

which you can use if you can't be sure that the address is not non-zero.
So the code in my sl28 gpio driver looks like:

  config.reg_dir_out_base = GPIO_REGMAP_ADDR(base + GPIO_REG_DIR);

I'll respin the patch with the current remarks.

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ