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, 31 Jan 2023 23:36:14 +0100
From:   Angel Iglesias <ang.iglesiasg@...il.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-iio@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Andreas Klinger <ak@...klinger.de>, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 7/7] iio: pressure: bmp280: Add nvmem operations for
 BMP580

On Mon, 2023-01-30 at 14:29 +0200, Andy Shevchenko wrote:
> On Sun, Jan 29, 2023 at 02:33:09AM +0100, Angel Iglesias wrote:
> > The pressure sensor BMP580 contains a non-volatile memory that stores
> > trimming and configuration params. That memory provides an programmable
> > user range of three 2-byte words.
> 
> ...
> 
> > +#define NVM_READ       false
> > +#define NVM_WRITE      true
> 
> How is it helpful and why it's not namespaced properly (can collide with
> NVM framework)?

I thought it could provide clarity using those aliases calling
bmp580_nvm_operation() helper function on nvmen callbacks, instead of using
just true or false. Not my brightest idea for sure.

> ...
> 
> > +       /* Wait until NVM is ready again */
> > +       do {
> > +               ret = regmap_read(data->regmap, BMP580_REG_STATUS, &reg);
> > +               if (ret) {
> > +                       dev_err(data->dev, "failed to check nvm status\n");
> > +                       reg &= ~BMP580_STATUS_NVM_RDY_MASK;
> > +               }
> > +       } while (time_before(jiffies, deadline) && !(reg &
> > BMP580_STATUS_NVM_RDY_MASK));
> 
> regmap_read_poll_timeout()?

Yes, thanks for pointing out, that's way better than the current loop.

> 
> > +       if (!(reg & BMP580_STATUS_NVM_RDY_MASK)) {
> 
>         if (ret) {
>                 ...
>                 return ret;
>         }
> 
> > +               dev_err(data->dev,
> > +                       "reached timeout waiting for nvm operation
> > completion\n");
> > +               return -ETIMEDOUT;
> > +       }
> 
> ...
> 
> > +       while (bytes >= sizeof(u16)) {
> 
> sizeof(*dst) ?
> 
> Or sizeof(data->le16)?
> 
> > +               addr = bmp580_nvmem_addrs[offset / sizeof(u16)];
> 
> Ditto.
> 
> ...
> 
> > +               bytes -= sizeof(u16);
> > +               offset += sizeof(u16);
> 
> Ditto.
> 
> > +       }
> 
> ...
> 
> > +static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
> > +                             size_t bytes)
> > +{
> 
> Same comments as per above function.

Got it!

> >  }
> 
> 

Thanks for your time,
Angel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ