From: b.galvani@gmail.com (Beniamino Galvani)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 4/4] i2c: meson: add some comments
Date: Sun, 26 Nov 2017 17:40:57 +0100 [thread overview]
Message-ID: <20171126164057.27728-5-b.galvani@gmail.com> (raw)
In-Reply-To: <20171126164057.27728-1-b.galvani@gmail.com>
Add some comment describing the purpose of struct members and
functions.
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
drivers/i2c/meson_i2c.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/meson_i2c.c b/drivers/i2c/meson_i2c.c
index 2f39214ad2..4f37d2f316 100644
--- a/drivers/i2c/meson_i2c.c
+++ b/drivers/i2c/meson_i2c.c
@@ -44,12 +44,12 @@ struct i2c_regs {
struct meson_i2c {
struct i2c_regs *regs;
- struct i2c_msg *msg;
- bool last;
- uint count;
- uint pos;
- u32 tokens[2];
- uint num_tokens;
+ struct i2c_msg *msg; /* Current I2C message */
+ bool last; /* Whether the message is the last */
+ uint count; /* Number of bytes in the current transfer */
+ uint pos; /* Position of current transfer in message */
+ u32 tokens[2]; /* Sequence of tokens to be written */
+ uint num_tokens; /* Number of tokens to be written */
};
static void meson_i2c_reset_tokens(struct meson_i2c *i2c)
@@ -69,6 +69,10 @@ static void meson_i2c_add_token(struct meson_i2c *i2c, int token)
i2c->num_tokens++;
}
+/*
+ * Retrieve data for the current transfer (which can be at most 8
+ * bytes) from the device internal buffer.
+ */
static void meson_i2c_get_data(struct meson_i2c *i2c, u8 *buf, int len)
{
u32 rdata0, rdata1;
@@ -86,6 +90,10 @@ static void meson_i2c_get_data(struct meson_i2c *i2c, u8 *buf, int len)
*buf++ = (rdata1 >> (i - 4) * 8) & 0xff;
}
+/*
+ * Write data for the current transfer (which can be at most 8 bytes)
+ * to the device internal buffer.
+ */
static void meson_i2c_put_data(struct meson_i2c *i2c, u8 *buf, int len)
{
u32 wdata0 = 0, wdata1 = 0;
@@ -103,6 +111,11 @@ static void meson_i2c_put_data(struct meson_i2c *i2c, u8 *buf, int len)
debug("meson i2c: write data %08x %08x len %d\n", wdata0, wdata1, len);
}
+/*
+ * Prepare the next transfer: pick the next 8 bytes in the remaining
+ * part of message and write tokens and data (if needed) to the
+ * device.
+ */
static void meson_i2c_prepare_xfer(struct meson_i2c *i2c)
{
bool write = !(i2c->msg->flags & I2C_M_RD);
--
2.14.3
next prev parent reply other threads:[~2017-11-26 16:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-26 16:40 [PATCH 0/4] meson i2c driver cleanups Beniamino Galvani
2017-11-26 16:40 ` [PATCH 1/4] i2c: meson: improve Kconfig description Beniamino Galvani
2017-11-27 17:09 ` Simon Glass
2017-12-07 8:24 ` Heiko Schocher
2017-12-07 12:19 ` Heiko Schocher
2017-11-26 16:40 ` [PATCH 2/4] i2c: meson: reduce timeout Beniamino Galvani
2017-11-27 17:09 ` Simon Glass
2017-12-07 8:24 ` Heiko Schocher
2017-12-07 12:19 ` Heiko Schocher
2017-11-26 16:40 ` [PATCH 3/4] i2c: meson: fix return codes on error Beniamino Galvani
2017-11-27 17:09 ` Simon Glass
2017-12-07 8:25 ` Heiko Schocher
2017-12-07 12:20 ` Heiko Schocher
2017-11-26 16:40 ` Beniamino Galvani [this message]
2017-11-27 17:10 ` [PATCH 4/4] i2c: meson: add some comments Simon Glass
2017-12-07 8:25 ` Heiko Schocher
2017-12-07 12:20 ` Heiko Schocher
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=20171126164057.27728-5-b.galvani@gmail.com \
--to=b.galvani@gmail.com \
--cc=linus-amlogic@lists.infradead.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).