From: Wolfram Sang <wsa@the-dreams.de>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"Magnus Damm"
<magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"Simon Horman" <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
"Laurent Pinchart"
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
"Geert Uytterhoeven"
<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>,
"Wolfram Sang" <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
"Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Subject: [PATCH v2 4/4] i2c: slave-eeprom: add more info when to increase the pointer
Date: Mon, 23 Mar 2015 08:26:39 +0000 [thread overview]
Message-ID: <1427099199-3628-5-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1427099199-3628-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
It is a bit subtle when to correctly increase the buffer index when
reading. Make this clearer by adding some more comments and pointers to
the docs.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Changes since V1: new patch
drivers/i2c/i2c-slave-eeprom.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c
index 3fb45d894d8072..8223746546093c 100644
--- a/drivers/i2c/i2c-slave-eeprom.c
+++ b/drivers/i2c/i2c-slave-eeprom.c
@@ -48,12 +48,18 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
break;
case I2C_SLAVE_READ_PROCESSED:
+ /* The previous byte made it to the bus, get next one */
eeprom->buffer_idx++;
/* fallthrough */
case I2C_SLAVE_READ_REQUESTED:
spin_lock(&eeprom->buffer_lock);
*val = eeprom->buffer[eeprom->buffer_idx];
spin_unlock(&eeprom->buffer_lock);
+ /*
+ * Do not increment buffer_idx here, because we don't know if
+ * this byte will be actually used. Read Linux I2C slave docs
+ * for details.
+ */
break;
case I2C_SLAVE_STOP:
--
2.1.4
next prev parent reply other threads:[~2015-03-23 8:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 8:26 [PATCH v2 0/4] i2c: slave: API updates Wolfram Sang
2015-03-23 8:26 ` [PATCH v2 1/4] i2c: slave: rework the slave API Wolfram Sang
[not found] ` <1427099199-3628-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2015-03-23 8:26 ` [PATCH v2 2/4] Documentation: i2c: describe the new slave mode Wolfram Sang
[not found] ` <1427099199-3628-3-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2015-03-23 8:45 ` Uwe Kleine-König
[not found] ` <20150323084510.GL5664-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-03-23 9:04 ` Wolfram Sang
2015-04-01 12:17 ` Geert Uytterhoeven
2015-04-02 3:38 ` Wolfram Sang
2015-03-23 8:26 ` [PATCH v2 3/4] i2c: slave: add documentation for i2c-slave-eeprom Wolfram Sang
2015-03-23 8:26 ` Wolfram Sang [this message]
[not found] ` <1427099199-3628-5-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2015-03-23 8:32 ` [PATCH v2 4/4] i2c: slave-eeprom: add more info when to increase the pointer Uwe Kleine-König
2015-03-27 8:55 ` [PATCH v2 0/4] i2c: slave: API updates 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=1427099199-3628-5-git-send-email-wsa@the-dreams.de \
--to=wsa@the-dreams.de \
--cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@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 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).