From: Jean Delvare <jdelvare@suse.de>
To: minyard@acm.org
Cc: linux-i2c@vger.kernel.org, Corey Minyard <cminyard@mvista.com>
Subject: Re: [PATCH 1/5] i2c-i801: hwpec and check_pre cleanups
Date: Wed, 25 May 2016 13:04:45 +0200 [thread overview]
Message-ID: <20160525130445.60dc8f26@endymion> (raw)
In-Reply-To: <1453223377-20608-2-git-send-email-minyard@acm.org>
Sorry, I accidentally sent the previous reply while I wasn't done with
the review yet.
On Tue, 19 Jan 2016 11:09:33 -0600, minyard@acm.org wrote:
> @@ -691,13 +682,15 @@ static int i801_block_transaction(struct i801_priv *priv,
> doesn't mention this limitation. */
> if ((priv->features & FEATURE_BLOCK_BUFFER)
> && command != I2C_SMBUS_I2C_BLOCK_DATA
> - && i801_set_block_buffer_mode(priv) == 0)
> + && i801_set_block_buffer_mode(priv) == 0) {
> + if (hwpec)
> + priv->xact_extra |= SMBHSTCNT_PEC_EN;
> result = i801_block_transaction_by_block(priv, data,
> - read_write, hwpec);
> - else
> + read_write);
> + } else
> result = i801_block_transaction_byte_by_byte(priv, data,
> read_write,
> - command, hwpec);
> + command);
>
> (...)
> @@ -776,11 +770,17 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
> return -EOPNOTSUPP;
> }
>
> - if (hwpec) /* enable/disable hardware PEC */
> + result = i801_check_pre(priv);
> + if (result < 0)
> + return result;
> +
> + if (hwpec) { /* enable/disable hardware PEC */
> outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv));
> - else
> + } else {
> outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC),
> SMBAUXCTL(priv));
> + priv->xact_extra &= ~SMBHSTCNT_PEC_EN;
> + }
I'm confused by this asymmetry. You clear the PEC flag here, but you
set it in i801_block_transaction() above. Originally the flag was set
in i801_block_transaction_by_block() (and didn't have to be cleared, as
it was temporary.)
With your implementation, PEC may or may not be enabled if a driver
asks for a non-block transaction with PEC. If this is the first
transaction then it will not be enabled (bug already existed before
your patch.) But if the previous transaction was a block transaction
with PEC then the flag will still be present, so PEC will still be
enabled. The previous implementation was wrong but at least it was
consistently so.
This makes me believe we should rather fix the bugs first, and then
look into cleaning up this part of the code.
If you start storing transaction-dependent information in struct
i801_priv, you must make sure that nothing will leak from one
transaction to the next. I still have to review the rest of your patch
series, but I don't think it makes sense to carry the PEC flag that way
if the rest of the transaction information is still passed as function
parameters.
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2016-05-25 11:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 17:09 [PATCH 0/5] minyard
2016-01-19 17:09 ` [PATCH 1/5] i2c-i801: hwpec and check_pre cleanups minyard
2016-05-25 9:30 ` Jean Delvare
2016-05-25 11:04 ` Jean Delvare [this message]
2016-01-19 17:09 ` [PATCH 2/5] i2c-i801: Move hostcfg set/reset to i801_access() minyard
2016-05-25 11:42 ` Jean Delvare
2016-01-19 17:09 ` [PATCH 3/5] i2c-i801: Move PEC handling into i2c_block_transaction() minyard
2016-05-25 12:00 ` Jean Delvare
2016-01-19 17:09 ` [PATCH 4/5] i2c-i801: clean up block transaction minyard
2016-05-25 12:31 ` Jean Delvare
2016-01-19 17:09 ` [PATCH 5/5] i2c-i801: Remove redundant code and event-drive minyard
2016-05-25 12:52 ` Jean Delvare
2016-05-25 16:58 ` Corey Minyard
2016-05-26 7:17 ` Jean Delvare
2016-05-26 12:15 ` Corey Minyard
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=20160525130445.60dc8f26@endymion \
--to=jdelvare@suse.de \
--cc=cminyard@mvista.com \
--cc=linux-i2c@vger.kernel.org \
--cc=minyard@acm.org \
/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).