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] [day] [month] [year] [list]
Message-ID: <20241211182817.12d63645@jic23-huawei>
Date: Wed, 11 Dec 2024 18:28:17 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Yu-Hsian Yang <j2anfernee@...il.com>
Cc: avifishman70@...il.com, tmaimon77@...il.com, tali.perry1@...il.com,
 venture@...gle.com, yuenn@...gle.com, benjaminfair@...gle.com,
 lars@...afoo.de, robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
 nuno.sa@...log.com, dlechner@...libre.com, javier.carrasco.cruz@...il.com,
 andriy.shevchenko@...ux.intel.com, marcelo.schmitt@...log.com,
 olivier.moysan@...s.st.com, mitrutzceclan@...il.com, tgamblin@...libre.com,
 matteomartelli3@...il.com, alisadariana@...il.com, gstols@...libre.com,
 thomas.bonnefille@...tlin.com, ramona.nechita@...log.com,
 mike.looijmans@...ic.nl, chanh@...amperecomputing.com, KWLIU@...oton.com,
 yhyang2@...oton.com, openbmc@...ts.ozlabs.org, linux-iio@...r.kernel.org,
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: add Nuvoton NCT720x ADC driver

On Tue, 10 Dec 2024 13:47:25 +0800
Yu-Hsian Yang <j2anfernee@...il.com> wrote:

> Dear Jonathan Cameron,
> 
> Sorry the above mail is not finished and just sent it.
> I would explain why we can't use bulk read sequential bytes in our chips.
Ah! I replied to previous. Let me see what you added.


> > > > +
> > > > +     guard(mutex)(&chip->access_lock);
> > > > +     err  = regmap_read(chip->regmap, REG_CHANNEL_ENABLE_1, &value);
> > > > +     if (err < 0)
> > > > +             return err;
> > > > +     data[0] = (u8)value;
> > > > +
> > > > +     err  = regmap_read(chip->regmap, REG_CHANNEL_ENABLE_2, &value);
> > > > +     if (err < 0)
> > > > +             return err;  
> > >
> > > Here I think you can use a bulk read as the registers are next to each other.
> > >  
> >  
> Generally, registers with 8 bits support Byte format, and registers
> with more than 8 bits support Word format.
> If transmission a Word command to a register that supports Byte
> format, the second byte will get 0xFF.
> Here, if we use regmap_bulk_read(), we would get first byte correct
> and second byte is wrong 0xff.
> 
> I use i2ctransfer command to demo it.
> root@...-npcm845:~# i2ctransfer -f -y 5 w1@...d 0x13 r1
> 0xff
> root@...-npcm845:~# i2ctransfer -f -y 5 w1@...d 0x14 r1
> 0x0f
> 
> root@...-npcm845:~# i2ctransfer -f -y 5 w1@...d 0x13 r2
> 0xff 0xff
> And if we read four bytes, you can see the first and third byte as we wanted.
> root@...-npcm845:~# i2ctransfer -f -y 5 w1@...d 0x13 r4
> 0xff 0xff 0x0f 0xff
> 
> so we can't use bulk read directly since it would get a second byte 0xff.
> The safe method is to  use read byte twice.
That command does not do the same thing as regmap_bulk_read() will here.
It will issue a series of byte reads.

Jonathan



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ