linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Gabbasov <andrew_gabbasov@mentor.com>
To: 'Geert Uytterhoeven' <geert@linux-m68k.org>
Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	Linux I2C <linux-i2c@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"Surachari, Bhuvanesh" <Bhuvanesh_Surachari@mentor.com>
Subject: RE: [PATCH] i2c: rcar: add SMBus block read support
Date: Wed, 6 Oct 2021 21:11:51 +0300	[thread overview]
Message-ID: <000001d7badd$a8512d30$f8f38790$@mentor.com> (raw)
In-Reply-To: <CAMuHMdVVDpBAQR+H1TAnpf65aVbAL0Mm0km7Z9L7+1JuF6n1gQ@mail.gmail.com>

Hi Geert,

Thank you for your review!

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: Tuesday, October 05, 2021 4:32 PM
> To: Gabbasov, Andrew <Andrew_Gabbasov@mentor.com>
> Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>; Linux I2C <linux-i2c@vger.kernel.org>; Linux Kernel
> Mailing List <linux-kernel@vger.kernel.org>; Wolfram Sang <wsa+renesas@sang-engineering.com>; Surachari,
> Bhuvanesh <Bhuvanesh_Surachari@mentor.com>
> Subject: Re: [PATCH] i2c: rcar: add SMBus block read support
> 
> Hi Andrew,
> 
> On Wed, Sep 22, 2021 at 6:14 PM Andrew Gabbasov
> <andrew_gabbasov@mentor.com> wrote:
> > The smbus block read is not currently supported for rcar i2c devices.
> > This patchset adds the support to rcar i2c bus so that blocks of data
> > can be read using SMbus block reads.(using i2c_smbus_read_block_data()
> > function from the i2c-core-smbus.c).
> >
> > Inspired by commit 8e8782c71595 ("i2c: imx: add SMBus block read support")
> >
> > This patch (adapted) was tested with v4.14, but due to lack of real
> > hardware with SMBus block read operations support, using "simulation",
> > that is manual analysis of data, read from plain I2C devices with
> > SMBus block read request.
> >
> > Signed-off-by: Bhuvanesh Surachari <bhuvanesh_surachari@mentor.com>
> > Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/i2c/busses/i2c-rcar.c
> > +++ b/drivers/i2c/busses/i2c-rcar.c
> > @@ -429,9 +431,16 @@ static bool rcar_i2c_dma(struct rcar_i2c_priv *priv)
> >                 /*
> >                  * The last two bytes needs to be fetched using PIO in
> >                  * order for the STOP phase to work.
> > +                *
> > +                * For SMBus block read the first byte was received using PIO.
> 
> So it might be easier to read, and more maintainable, to keep the
> old assignments:
> 
>     buf = priv->msg->buf;
>     len = priv->msg->len - 2;
> 
> and adjust them for SMBus afterwards:
> 
>     if (block_data) {
>             /* For SMBus block read the first byte was received using PIO */
>             buf++;
>             len--;
>     }
> 
> ?
> 
> >                  */
> > -               buf = priv->msg->buf;
> > -               len = priv->msg->len - 2;
> > +               if (block_data) {
> > +                       buf = priv->msg->buf + 1;
> > +                       len = priv->msg->len - 3;
> > +               } else {
> > +                       buf = priv->msg->buf;
> > +                       len = priv->msg->len - 2;
> > +               }
> >         } else {
> >                 /*
> >                  * First byte in message was sent using PIO.
> 
> And below we have another case handling buf and len :-(
> 
> So perhaps:
> 
>     buf = priv->msg->buf;
>     len = priv->msg->len;
> 
>     if (read) {
>             /*
>              * The last two bytes needs to be fetched using PIO in
>              * order for the STOP phase to work.
>              */
>             len -= 2;
>     }
>     if (!read || block_data) {
>             /* First byte in message was sent using PIO *
>             buf++;
>             len--;
>     }

Probably I was trying to minimize the changes ;-)

However, I agree with you that the whole code fragment can be simplified
and your variant indeed looks more clean and understandable.
Thank you for your suggestion, I'll submit version 2 of the patch
with this fragment changed.

Thanks!

Best regards,
Andrew


  reply	other threads:[~2021-10-06 18:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 16:06 [PATCH] i2c: rcar: add SMBus block read support Andrew Gabbasov
2021-10-05 13:31 ` Geert Uytterhoeven
2021-10-06 18:11   ` Andrew Gabbasov [this message]
2021-10-06 18:23     ` [PATCH v2] " Andrew Gabbasov
2022-02-17 19:44       ` Wolfram Sang
2022-02-18 11:02         ` Gabbasov, Andrew
2022-03-15 10:45           ` Surachari, Bhuvanesh
2022-03-30 11:04           ` Wolfram Sang
2022-04-01 16:27             ` Wolfram Sang
2022-04-01 16:29           ` Wolfram Sang
2022-03-23 21:52         ` Eugeniu Rosca
2022-03-30 10:58           ` Wolfram Sang
2022-03-30 11:09             ` Wolfram Sang
2022-03-31 16:02               ` Eugeniu Rosca
2022-04-01 16:38                 ` Wolfram Sang
2022-04-05  9:30                   ` Eugeniu Rosca
2022-04-05  9:43                     ` Wolfram Sang
2022-04-06 17:32                       ` Eugeniu Rosca
2022-04-06 19:44                         ` Wolfram Sang
2021-11-18 10:35   ` [PATCH] " Andrew Gabbasov
2022-01-09 19:20   ` Andrew Gabbasov
2022-01-25  6:45   ` Andrew Gabbasov
2022-02-17 14:40   ` Andrew Gabbasov

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='000001d7badd$a8512d30$f8f38790$@mentor.com' \
    --to=andrew_gabbasov@mentor.com \
    --cc=Bhuvanesh_Surachari@mentor.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.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).