[U-Boot] [PATCH 35/50] dm: power: Tidy up debugging output and return values
Simon Glass
sjg at chromium.org
Thu Jan 14 00:25:25 CET 2016
The currect PMIC debugging is a little confusing. Adjust it so that it is
clear whether the operation succeeded or failed. Also, avoid creating a new
error return value when a perfectly good one is already available.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
drivers/power/pmic/pmic-uclass.c | 11 ++++++++---
drivers/power/pmic/rk808.c | 14 ++++++++++----
drivers/power/regulator/regulator-uclass.c | 2 +-
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
index 8b19998..7211026 100644
--- a/drivers/power/pmic/pmic-uclass.c
+++ b/drivers/power/pmic/pmic-uclass.c
@@ -133,8 +133,9 @@ int pmic_reg_read(struct udevice *dev, uint reg)
u8 byte;
int ret;
+ debug("%s: reg=%x", __func__, reg);
ret = pmic_read(dev, reg, &byte, 1);
- debug("%s: reg=%x, value=%x\n", __func__, reg, byte);
+ debug(", value=%x, ret=%d\n", byte, ret);
return ret ? ret : byte;
}
@@ -142,9 +143,13 @@ int pmic_reg_read(struct udevice *dev, uint reg)
int pmic_reg_write(struct udevice *dev, uint reg, uint value)
{
u8 byte = value;
+ int ret;
+
+ debug("%s: reg=%x, value=%x", __func__, reg, value);
+ ret = pmic_write(dev, reg, &byte, 1);
+ debug(", ret=%d\n", ret);
- debug("%s: reg=%x, value=%x\n", __func__, reg, value);
- return pmic_write(dev, reg, &byte, 1);
+ return ret;
}
int pmic_clrsetbits(struct udevice *dev, uint reg, uint clr, uint set)
diff --git a/drivers/power/pmic/rk808.c b/drivers/power/pmic/rk808.c
index 11d5f07..770f471 100644
--- a/drivers/power/pmic/rk808.c
+++ b/drivers/power/pmic/rk808.c
@@ -30,9 +30,12 @@ static int rk808_reg_count(struct udevice *dev)
static int rk808_write(struct udevice *dev, uint reg, const uint8_t *buff,
int len)
{
- if (dm_i2c_write(dev, reg, buff, len)) {
+ int ret;
+
+ ret = dm_i2c_write(dev, reg, buff, len);
+ if (ret) {
debug("write error to device: %p register: %#x!", dev, reg);
- return -EIO;
+ return ret;
}
return 0;
@@ -40,9 +43,12 @@ static int rk808_write(struct udevice *dev, uint reg, const uint8_t *buff,
static int rk808_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
{
- if (dm_i2c_read(dev, reg, buff, len)) {
+ int ret;
+
+ ret = dm_i2c_read(dev, reg, buff, len);
+ if (ret) {
debug("read error from device: %p register: %#x!", dev, reg);
- return -EIO;
+ return ret;
}
return 0;
diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c
index 4241a4c..fec2886 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -178,7 +178,7 @@ static void regulator_show(struct udevice *dev, int ret)
printf("; set %d uA", uc_pdata->min_uA);
printf("; enabling");
if (ret)
- printf(" (ret: %d)\n", ret);
+ printf(" (ret: %d)", ret);
printf("\n");
}
--
2.6.0.rc2.230.g3dd15c0
More information about the U-Boot
mailing list