All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Ditto <mditto-Vjf7OWgA3BLqlBn2x/YWAg@public.gmane.org>
To: Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org>,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] i2c-cpm: Detect and report NAK right away instead of timing out.
Date: Fri, 31 Oct 2008 17:29:25 -0700	[thread overview]
Message-ID: <490BA2E5.8010309@consentry.com> (raw)

Make the driver report an ENXIO error immediately upon NAK instead of
waiting for another interrupt and getting a timeout.

Signed-off-by: Mike Ditto <mditto-Vjf7OWgA3BLqlBn2x/YWAg@public.gmane.org>
---
When reading from a device that is not present or declines to respond
to, e.g., a non-existent register address, CPM immediately reports a
NAK condition in the TxBD, but the driver kept waiting until a timeout,
which takes 1 second and causes an ugly console error message.

Index: linux/drivers/i2c/busses/i2c-cpm.c
===================================================================
retrieving revision 1.3
diff -u -p -r1.3 i2c-cpm.c
--- linux/drivers/i2c/busses/i2c-cpm.c	31 Oct 2008 06:36:08 -0000	1.3
+++ linux/drivers/i2c/busses/i2c-cpm.c	1 Nov 2008 00:12:45 -0000
@@ -369,6 +369,7 @@ static int cpm_i2c_xfer(struct i2c_adapt
 		pmsg = &msgs[tptr];
 		if (pmsg->flags & I2C_M_RD)
 			ret = wait_event_interruptible_timeout(cpm->i2c_wait,
+				(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
 				!(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
 				1 * HZ);
 		else

WARNING: multiple messages have this Message-ID (diff)
From: Mike Ditto <mditto@consentry.com>
To: Jochen Friedrich <jochen@scram.de>,
	linuxppc-dev@ozlabs.org, linux-i2c@vger.kernel.org
Subject: [PATCH] i2c-cpm: Detect and report NAK right away instead of timing out.
Date: Fri, 31 Oct 2008 17:29:25 -0700	[thread overview]
Message-ID: <490BA2E5.8010309@consentry.com> (raw)

Make the driver report an ENXIO error immediately upon NAK instead of
waiting for another interrupt and getting a timeout.

Signed-off-by: Mike Ditto <mditto@consentry.com>
---
When reading from a device that is not present or declines to respond
to, e.g., a non-existent register address, CPM immediately reports a
NAK condition in the TxBD, but the driver kept waiting until a timeout,
which takes 1 second and causes an ugly console error message.

Index: linux/drivers/i2c/busses/i2c-cpm.c
===================================================================
retrieving revision 1.3
diff -u -p -r1.3 i2c-cpm.c
--- linux/drivers/i2c/busses/i2c-cpm.c	31 Oct 2008 06:36:08 -0000	1.3
+++ linux/drivers/i2c/busses/i2c-cpm.c	1 Nov 2008 00:12:45 -0000
@@ -369,6 +369,7 @@ static int cpm_i2c_xfer(struct i2c_adapt
 		pmsg = &msgs[tptr];
 		if (pmsg->flags & I2C_M_RD)
 			ret = wait_event_interruptible_timeout(cpm->i2c_wait,
+				(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_NAK) ||
 				!(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
 				1 * HZ);
 		else

             reply	other threads:[~2008-11-01  0:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-01  0:29 Mike Ditto [this message]
2008-11-01  0:29 ` [PATCH] i2c-cpm: Detect and report NAK right away instead of timing out Mike Ditto
     [not found] ` <490BA2E5.8010309-Vjf7OWgA3BLqlBn2x/YWAg@public.gmane.org>
2008-11-03  0:23   ` Ben Dooks
2008-11-03  0:23     ` Ben Dooks
     [not found]     ` <20081103002328.GC30438-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
2008-11-03  3:50       ` Mike Ditto
2008-11-03  3:50         ` Mike Ditto
2008-11-03 11:44       ` Jochen Friedrich
2008-11-03 11:44         ` Jochen Friedrich

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=490BA2E5.8010309@consentry.com \
    --to=mditto-vjf7owga3blqlbn2x/ywag@public.gmane.org \
    --cc=jochen-NIgtFMG+Po8@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.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.