public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/2] power: twl4030: Add twl4030_i2c_read() function
Date: Mon, 26 Oct 2020 22:36:15 +0100	[thread overview]
Message-ID: <20201026213616.20816-1-pali@kernel.org> (raw)

Function twl4030_i2c_read() is like twl4030_i2c_read_u8() but instead of
single value it rather returns array of values.

Signed-off-by: Pali Roh?r <pali@kernel.org>
---
 drivers/power/twl4030.c |  7 +++----
 include/twl4030.h       | 12 +++++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c
index b0d5cba2c4..f48af84e17 100644
--- a/drivers/power/twl4030.c
+++ b/drivers/power/twl4030.c
@@ -201,7 +201,7 @@ int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 	return 0;
 }
 
-int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
+int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *valp, int len)
 {
 	struct udevice *dev;
 	int ret;
@@ -211,12 +211,11 @@ int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
 		pr_err("unable to get I2C bus. ret %d\n", ret);
 		return ret;
 	}
-	ret = dm_i2c_reg_read(dev, reg);
-	if (ret < 0) {
+	ret = dm_i2c_read(dev, reg, valp, len);
+	if (ret) {
 		pr_err("reading from twl4030 failed. ret %d\n", ret);
 		return ret;
 	}
-	*valp = (u8)ret;
 	return 0;
 }
 #endif
diff --git a/include/twl4030.h b/include/twl4030.h
index c27ad615ee..ef05193996 100644
--- a/include/twl4030.h
+++ b/include/twl4030.h
@@ -654,14 +654,20 @@ static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
 	return i2c_write(chip_no, reg, 1, &val, 1);
 }
 
-static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
+static inline int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *val, int len)
 {
-	return i2c_read(chip_no, reg, 1, val, 1);
+	return i2c_read(chip_no, reg, 1, val, len);
 }
 #else
 int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
-int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
+int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *val, int len);
 #endif
+
+static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
+{
+	return twl4030_i2c_read(chip_no, reg, val, 1);
+}
+
 /*
  * Power
  */
-- 
2.20.1

             reply	other threads:[~2020-10-26 21:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20201026213638epcas1p31e20f8b9550ac897a2bdc27d8c4ede14@epcas1p3.samsung.com>
2020-10-26 21:36 ` Pali Rohár [this message]
2020-10-26 21:36   ` [PATCH 2/2] Nokia RX-51: Convert to CONFIG_DM_I2C Pali Rohár
2020-10-26 22:00     ` Tom Rini
2020-10-26 22:45       ` [PATCH v2] " Pali Rohár
2020-11-15 10:19         ` Lokesh Vutla
2020-10-27 21:45   ` [PATCH 1/2] power: twl4030: Add twl4030_i2c_read() function Jaehoon Chung
2020-10-27 21:57     ` Pali Rohár
2020-10-27 22:56       ` Jaehoon Chung

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=20201026213616.20816-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /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