From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Parker Newman <parker@finest.io>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Parker Newman" <pnewman@connecttech.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-serial <linux-serial@vger.kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>
Subject: Re: [PATCH v1 11/13] serial: 8250_exar: Use BIT() in exar_ee_read()
Date: Fri, 3 May 2024 18:35:45 +0300 [thread overview]
Message-ID: <ZjUEURneUmZ4nmbC@smile.fi.intel.com> (raw)
In-Reply-To: <20240503102632.112a34bd@SWDEV2.connecttech.local>
On Fri, May 03, 2024 at 10:26:32AM -0400, Parker Newman wrote:
> On Thu, 2 May 2024 20:20:01 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > On Thu, May 02, 2024 at 07:08:21PM +0300, Ilpo Järvinen wrote:
> > > On Thu, 2 May 2024, Andy Shevchenko wrote:
...
> > > > // Send address to read from
> > > > - for (i = 1 << (UART_EXAR_REGB_EE_ADDR_SIZE - 1); i; i >>= 1)
> > > > - exar_ee_write_bit(priv, (ee_addr & i));
> > > > + for (i = UART_EXAR_REGB_EE_ADDR_SIZE - 1; i >= 0; i--)
> > > > + exar_ee_write_bit(priv, ee_addr & BIT(i));
> > > >
> > > > // Read data 1 bit at a time
> > > > for (i = 0; i <= UART_EXAR_REGB_EE_DATA_SIZE; i++) {
> > > > - data <<= 1;
> > > > - data |= exar_ee_read_bit(priv);
> > > > + if (exar_ee_read_bit(priv))
> > > > + data |= BIT(i);
> > >
> > > Does this end up reversing the order of bits? In the original, data was left
> > > shifted which moved the existing bits and added the lsb but the replacement
> > > adds highest bit on each iteration?
> >
> > Oh, seems a good catch!
> >
> > I was also wondering, but missed this somehow. Seems the EEPROM is in BE mode,
> > so two loops has to be aligned.
> >
>
> I just tested this and Ilpo is correct, the read loop portion is backwards as
> expected. This is the corrected loop:
>
> // Read data 1 bit at a time
> for (i = UART_EXAR_REGB_EE_DATA_SIZE; i >= 0; i--) {
> if (exar_ee_read_bit(priv))
> data |= BIT(i);
> }
>
> I know this looks wrong because its looping from 16->0 rather than the
> more intuitive 15->0 for a 16bit value. This is actually correct however
> because according to the AT93C46D datasheet there is always dummy 0 bit
> before the actual 16 bits of data.
>
> I hope that helps,
Yes, it helps and means that we need that comment to be added to the code. Is
it the same applicable to the write part above (for address)? Because AFAIU
mine is one bit longer than yours. Maybe in the original code is a bug? Have
you tried to read high addresses?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-05-03 15:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-02 14:43 [PATCH v1 00/13] serial: 8250_exar: Clean up the driver Andy Shevchenko
2024-05-02 14:43 ` [PATCH v1 01/13] serial: 8250_exar: Don't return positive values as error codes Andy Shevchenko
2024-05-02 14:43 ` [PATCH v1 02/13] serial: 8250_exar: Describe all parameters in kernel doc Andy Shevchenko
2024-05-02 14:43 ` [PATCH v1 03/13] serial: 8250_exar: Kill CTI_PCI_DEVICE() Andy Shevchenko
2024-05-02 15:13 ` Parker Newman
2024-05-02 15:29 ` Andy Shevchenko
2024-05-02 15:36 ` Parker Newman
2024-05-02 15:43 ` Andy Shevchenko
2024-05-02 15:54 ` Parker Newman
2024-05-02 15:59 ` Andy Shevchenko
2024-05-02 14:43 ` [PATCH v1 04/13] serial: 8250_exar: Use PCI_SUBVENDOR_ID_IBM for subvendor ID Andy Shevchenko
2024-05-02 14:43 ` [PATCH v1 05/13] serial: 8250_exar: Trivia typo fixes Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 06/13] serial: 8250_exar: Extract cti_board_init_osc_freq() helper Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 07/13] serial: 8250_exar: Kill unneeded ->board_init() Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 08/13] serial: 8250_exar: Decrease indentation level Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 09/13] serial: 8250_exar: Return directly from switch-cases Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 10/13] serial: 8250_exar: Switch to use dev_err_probe() Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 11/13] serial: 8250_exar: Use BIT() in exar_ee_read() Andy Shevchenko
2024-05-02 16:08 ` Ilpo Järvinen
2024-05-02 17:20 ` Andy Shevchenko
2024-05-03 14:26 ` Parker Newman
2024-05-03 15:35 ` Andy Shevchenko [this message]
2024-05-03 18:56 ` Parker Newman
2024-05-06 8:37 ` Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 12/13] serial: 8250_exar: Make type of bit the same in exar_ee_*_bit() Andy Shevchenko
2024-05-02 14:44 ` [PATCH v1 13/13] serial: 8250_exar: Keep the includes sorted Andy Shevchenko
2024-05-02 15:46 ` [PATCH v1 00/13] serial: 8250_exar: Clean up the driver Parker Newman
2024-05-02 16:01 ` Andy Shevchenko
2024-05-02 16:08 ` Parker Newman
2024-05-02 17:22 ` Andy Shevchenko
2024-05-02 17:49 ` Parker Newman
2024-05-02 18:01 ` Andy Shevchenko
2024-05-03 12:36 ` Parker Newman
2024-05-03 14:47 ` Parker Newman
2024-05-03 15:33 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZjUEURneUmZ4nmbC@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=parker@finest.io \
--cc=pnewman@connecttech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).