From: Wolfram Sang <wsa@the-dreams.de>
To: Jean Delvare <jdelvare@suse.de>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] i2c: algo-bit: add support for I2C_M_STOP
Date: Tue, 20 Jun 2017 19:28:10 +0200 [thread overview]
Message-ID: <20170620172810.h2anac45n5u3oova@ninjato> (raw)
In-Reply-To: <20170619103002.5d502c92@endymion>
[-- Attachment #1: Type: text/plain, Size: 2771 bytes --]
Hi Jean,
> > + bool did_stop = false;
>
> I'm pretty certain you want to declare and initialize this variable
> outside the loop.
Why? Well, it doesn't matter anymore but what is wrong with limiting the
variable like this?
> > + if (pmsg->flags & I2C_M_STOP && i != num - 1) {
>
> I recommend adding parentheses around the bit matching when combined
> with &&. I know it is not strictly needed and the compiler doesn't
> care, but I find it easier to read, and there seems to be a consensus
> (90 %) on that in the kernel tree.
Either both in parens, or none ;) But doesn't matter as well anymore.
> 1* Repeated start happens between messages of a same transaction, and
> you handle that case above. However in the case of 10-bit address
> clients, there is also a repeated start happening during the address
> phase of the transaction, if the first message is a read. Did you check
> what the SCCB protocol expects in that case?
SCCB defines addresses to be 7 bit.
> 2* I'm not sure why you add the enforced stop at the end of one
> iteration and the start at the beginning of the next iteration. It
> would be more simple and efficient to do both at the beginning of the
> next iteration. The only case where it would make a difference is if
> both I2C_M_NOSTART and I2C_M_STOP are specified. In this case you
> currently emit a stop condition but no start, which I don't think can
> work at all.
Ehrm, probably I was just too tied to the ordering of "first start -
then data - then stop - then next loop" :)
> What about something like that instead? Or I am missing something?
No, I did miss it.
> --- linux-4.11.orig/drivers/i2c/algos/i2c-algo-bit.c 2017-06-19 09:57:17.949074198 +0200
> +++ linux-4.11/drivers/i2c/algos/i2c-algo-bit.c 2017-06-19 10:23:26.711088536 +0200
> @@ -553,8 +553,17 @@ static int bit_xfer(struct i2c_adapter *
> nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
> if (!(pmsg->flags & I2C_M_NOSTART)) {
> if (i) {
> - bit_dbg(3, &i2c_adap->dev, "emitting "
> - "repeated start condition\n");
> + if (msgs[i - 1].flags & I2C_M_STOP) {
> + bit_dbg(3, &i2c_adap->dev,
> + "emitting enforced stop condition\n");
> + i2c_stop(adap);
> + bit_dbg(3, &i2c_adap->dev,
> + "emitting start condition\n");
> + i2c_start(adap);
> + }
else
> +
> + bit_dbg(3, &i2c_adap->dev,
> + "emitting repeated start condition\n");
> i2c_repstart(adap);
> }
> ret = bit_doAddress(i2c_adap, pmsg);
A lot better! I like it very much. And also
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Do you want to cook up a patch or shall I? I'd just need a SoB then.
Thanks for the improvement!
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-06-20 17:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-17 17:12 [PATCH] i2c: algo-bit: add support for I2C_M_STOP Wolfram Sang
2017-06-19 8:30 ` Jean Delvare
2017-06-20 17:28 ` Wolfram Sang [this message]
2017-06-21 7:18 ` Jean Delvare
2017-06-21 14:30 ` Wolfram Sang
2017-06-22 9:06 ` Jean Delvare
2017-06-22 10:15 ` Wolfram Sang
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=20170620172810.h2anac45n5u3oova@ninjato \
--to=wsa@the-dreams.de \
--cc=jdelvare@suse.de \
--cc=linux-i2c@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).