From: minyard@acm.org
To: Jean Delvare <jdelvare@suse.com>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
minyard@acm.org
Cc: Corey Minyard <cminyard@mvista.com>
Subject: [PATCH v2 08/10] i2c-i801: Handle a protocol error in byte-by-byte isr
Date: Sun, 29 May 2016 20:09:02 -0500 [thread overview]
Message-ID: <1464570544-975-9-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1464570544-975-1-git-send-email-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
If a bad number of bytes is read on a transaction, have it
report an error and return -EPROTO for the transaction.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
drivers/i2c/busses/i2c-i801.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index b415948..70da60a 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -230,7 +230,7 @@ struct i801_priv {
/* isr processing */
wait_queue_head_t waitq;
- u8 status;
+ int status;
/* Command state used by isr for byte-by-byte block transactions */
u8 subcmd;
@@ -472,16 +472,18 @@ static void i801_isr_byte_done(struct i801_priv *priv)
(priv->count == 0)) {
priv->len = inb_p(SMBHSTDAT0(priv));
if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) {
- dev_err(&priv->pci_dev->dev,
- "Illegal SMBus block read size %d\n",
- priv->len);
- /* FIXME: Recover */
- priv->len = I2C_SMBUS_BLOCK_MAX;
- } else {
- dev_dbg(&priv->pci_dev->dev,
- "SMBus block read size is %d\n",
- priv->len);
+ /*
+ * Terminate the transaction here, to avoid
+ * getting any more interrupts that might
+ * hold us in an interrupt loop forever.
+ */
+ outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL,
+ SMBHSTCNT(priv));
+ priv->status = -EPROTO;
+ return;
}
+ dev_dbg(&priv->pci_dev->dev,
+ "SMBus block read size is %d\n", priv->len);
priv->data[-1] = priv->len;
}
@@ -541,7 +543,10 @@ static irqreturn_t i801_isr(int irq, void *dev_id)
status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
if (status) {
outb_p(status, SMBHSTSTS(priv));
- priv->status |= status;
+ if (status < 0)
+ priv->status = status;
+ else
+ priv->status |= status;
wake_up(&priv->waitq);
}
--
2.7.4
next prev parent reply other threads:[~2016-05-30 1:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 1:08 [PATCH v2 00/10] i2c-i801: Various cleanups minyard
2016-05-30 1:08 ` [PATCH v2 01/10] i2c-i801: Remove hwpec from block byte-by-byte function minyard
2016-06-09 9:36 ` [v2,01/10] " Benjamin Tissoires
2016-05-30 1:08 ` [PATCH v2 02/10] i2c-i801: Move hostcfg set/reset to i801_access() minyard
2016-06-09 9:39 ` [v2,02/10] " Benjamin Tissoires
2016-06-10 10:43 ` Corey Minyard
2016-05-30 1:08 ` [PATCH v2 03/10] i2c-i801: Move hwpec handling into block transaction minyard
2016-06-09 9:42 ` [v2,03/10] " Benjamin Tissoires
2016-05-30 1:08 ` [PATCH v2 04/10] i2c-i801: Consolidate calls to i801_check_pre() minyard
2016-06-09 9:44 ` [v2,04/10] " Benjamin Tissoires
2016-06-10 10:52 ` Corey Minyard
2016-05-30 1:08 ` [PATCH v2 05/10] i2c-i801: Consolidate calls to i801_check_post minyard
2016-06-09 10:03 ` [v2,05/10] " Benjamin Tissoires
2016-06-10 11:09 ` Corey Minyard
2016-05-30 1:09 ` [PATCH v2 06/10] i2c-i801: Pass around a boolean read/write variable minyard
2016-06-09 10:05 ` [v2,06/10] " Benjamin Tissoires
2016-05-30 1:09 ` [PATCH v2 07/10] i2c-i801: Fix some inconsistent variable names minyard
2016-06-09 14:01 ` [v2,07/10] " Benjamin Tissoires
2016-06-10 11:12 ` Corey Minyard
2016-05-30 1:09 ` minyard [this message]
2016-06-09 14:07 ` [v2,08/10] i2c-i801: Handle a protocol error in byte-by-byte isr Benjamin Tissoires
2016-05-30 1:09 ` [PATCH v2 09/10] i2c-i801: Null isr data buffer when done with it minyard
2016-06-09 14:14 ` [v2,09/10] " Benjamin Tissoires
2016-05-30 1:09 ` [PATCH v2 10/10] i2c-i801: Only write the host control reg when necessary 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=1464570544-975-9-git-send-email-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=jdelvare@suse.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.