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, 14 Apr 2020 21:57:15 +0200
From:   Michael Walle <michael@...le.cc>
To:     Bartosz Golaszewski <bgolaszewski@...libre.com>
Cc:     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>,
        Linus Walleij <linus.walleij@...aro.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

Hi Mark, Hi Bartosz, Hi Linus,

Am 2020-04-14 20:41, schrieb Michael Walle:
> Am 2020-04-14 19:00, schrieb Bartosz Golaszewski:
>> wt., 14 kwi 2020 o 12:07 Michael Walle <michael@...le.cc> napisał(a):
>>> >>
>>> >> So the best from a user perspective I've could come up with was:
>>> >>
>>> >>    ->base_reg = GPIO_REGMAP_ADDR(addr);
>>> >>
>>> >> I'm open for suggestions.
>>> >>
>>> >
>>> > Maybe setting the pointer to ERR_PTR(-ENOENT) which will result in
>>> > IS_ERR() returning true?
>>> 
>>> Unfortunatly, its not a pointer, but only a regular unsigned int (ie
>>> the type the regmap API has for its "reg" property). It could be a
>>> pointer of course but then the user would have to allocate additional
>>> memory.
>>> 
>>> -michael
>>> 
>> 
>> Eek, of course it's not a pointer. If possible I'd like to avoid this
>> GPIO_REGMAP_ADDR() macro, so how about having some separate field for
>> invalid offsets making every offset 'valid' by default?
> 
> IMHO this has the same problems as mentioned in the response to Mark's
> idea. Normally, the user sets only some addresses, thus he has to mark
> all other as invalid. And if you add another address, you have to touch
> all the drivers to mark it as invalid.
> 
> We could add some force bits like the "use_ack" flag in the bgpio 
> driver,
> where you can force the use of the value 0. But I'd really like to find
> a better way..

So what about the following:

#define GPIO_REGMAP_ADDR_ZERO (unsigned int)(-1)

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;
}

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ