From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher denx Date: Fri, 03 Jul 2015 08:52:53 +0200 Subject: [U-Boot] [PATCH 02/55] dm: i2c: Add a message debug function In-Reply-To: <1435882592-487-3-git-send-email-sjg@chromium.org> References: <1435882592-487-1-git-send-email-sjg@chromium.org> <1435882592-487-3-git-send-email-sjg@chromium.org> Message-ID: <55963145.8020206@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Simon, Am 03.07.2015 um 02:15 schrieb Simon Glass: > Add a way to dump the contents of an I2C message for debugging purposes. > > Signed-off-by: Simon Glass > --- > > drivers/i2c/i2c-uclass.c | 16 ++++++++++++++++ > include/i2c.h | 10 ++++++++++ > 2 files changed, 26 insertions(+) Acked-by: Heiko Schocher bye, Heiko > > diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c > index eaba965..42d6e89 100644 > --- a/drivers/i2c/i2c-uclass.c > +++ b/drivers/i2c/i2c-uclass.c > @@ -18,6 +18,22 @@ DECLARE_GLOBAL_DATA_PTR; > > #define I2C_MAX_OFFSET_LEN 4 > > +/* Useful debugging function */ > +void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs) > +{ > + int i; > + > + for (i = 0; i < nmsgs; i++) { > + struct i2c_msg *m = &msg[i]; > + > + printf(" %s %x len=%x", m->flags & I2C_M_RD ? "R" : "W", > + msg->addr, msg->len); > + if (!(m->flags & I2C_M_RD)) > + printf(": %x", m->buf[0]); > + printf("\n"); > + } > +} > + > /** > * i2c_setup_offset() - Set up a new message with a chip offset > * > diff --git a/include/i2c.h b/include/i2c.h > index 9300d97..a5498a3 100644 > --- a/include/i2c.h > +++ b/include/i2c.h > @@ -473,6 +473,16 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, > int i2c_chip_ofdata_to_platdata(const void *blob, int node, > struct dm_i2c_chip *chip); > > +/** > + * i2c_dump_msgs() - Dump a list of I2C messages > + * > + * This may be useful for debugging. > + * > + * @msg: Message list to dump > + * @nmsgs: Number of messages > + */ > +void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs); > + > #ifndef CONFIG_DM_I2C > > /* > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany