Re: [U-Boot] [PATCH 09/20] i2c: uniphier-f: replace debug() with dev_dbg()

2017-10-16 Thread Heiko Schocher

Hello Masahiro,

Am 13.10.2017 um 12:21 schrieb Masahiro Yamada:

Use dev_dbg() functions.  It will be helpful to prefix log messages
with the corresponding device name when the core framework is ready.

While I am here, I renamed "dev", which was actually private data,
into "priv" because dev->dev looks confusing.

Signed-off-by: Masahiro Yamada 
---

  drivers/i2c/i2c-uniphier-f.c | 114 ---
  1 file changed, 52 insertions(+), 62 deletions(-)


Reviewed-by: Heiko Schocher 

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 09/20] i2c: uniphier-f: replace debug() with dev_dbg()

2017-10-13 Thread Masahiro Yamada
Use dev_dbg() functions.  It will be helpful to prefix log messages
with the corresponding device name when the core framework is ready.

While I am here, I renamed "dev", which was actually private data,
into "priv" because dev->dev looks confusing.

Signed-off-by: Masahiro Yamada 
---

 drivers/i2c/i2c-uniphier-f.c | 114 ---
 1 file changed, 52 insertions(+), 62 deletions(-)

diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
index e51537b..eb6c9f3 100644
--- a/drivers/i2c/i2c-uniphier-f.c
+++ b/drivers/i2c/i2c-uniphier-f.c
@@ -6,13 +6,12 @@
  * SPDX-License-Identifier:GPL-2.0+
  */
 
-#include 
-#include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -64,35 +63,27 @@ struct uniphier_fi2c_regs {
 
 #define FIOCLK 5000
 
-struct uniphier_fi2c_dev {
+struct uniphier_fi2c_priv {
+   struct udevice *dev;
struct uniphier_fi2c_regs __iomem *regs;/* register base */
unsigned long fioclk;   /* internal operation clock */
unsigned long timeout;  /* time out (us) */
 };
 
-static int reset_bus(struct uniphier_fi2c_regs __iomem *regs)
+static void uniphier_fi2c_reset(struct uniphier_fi2c_priv *priv)
 {
-   u32 val;
-   int ret;
-
-   /* bus forcible reset */
-   writel(I2C_RST_RST, >rst);
-   ret = readl_poll_timeout(>rst, val, !(val & I2C_RST_RST), 1);
-   if (ret < 0)
-   debug("error: fail to reset I2C controller\n");
-
-   return ret;
+   writel(I2C_RST_RST, >regs->rst);
 }
 
-static int check_device_busy(struct uniphier_fi2c_regs __iomem *regs)
+static int uniphier_fi2c_check_bus_busy(struct uniphier_fi2c_priv *priv)
 {
u32 val;
int ret;
 
-   ret = readl_poll_timeout(>sr, val, !(val & I2C_SR_DB), 100);
+   ret = readl_poll_timeout(>regs->sr, val, !(val & I2C_SR_DB), 100);
if (ret < 0) {
-   debug("error: device busy too long. reset...\n");
-   ret = reset_bus(regs);
+   dev_dbg(priv->dev, "error: device busy too long. reset...\n");
+   uniphier_fi2c_reset(priv);
}
 
return ret;
@@ -101,8 +92,7 @@ static int check_device_busy(struct uniphier_fi2c_regs 
__iomem *regs)
 static int uniphier_fi2c_probe(struct udevice *dev)
 {
fdt_addr_t addr;
-   struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
-   int ret;
+   struct uniphier_fi2c_priv *priv = dev_get_priv(dev);
 
addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
@@ -114,85 +104,85 @@ static int uniphier_fi2c_probe(struct udevice *dev)
 
priv->fioclk = FIOCLK;
 
+   priv->dev = dev;
+
/* bus forcible reset */
-   ret = reset_bus(priv->regs);
-   if (ret < 0)
-   return ret;
+   uniphier_fi2c_reset(priv);
 
writel(I2C_BRST_FOEN | I2C_BRST_RSCLO, >regs->brst);
 
return 0;
 }
 
-static int wait_for_irq(struct uniphier_fi2c_dev *dev, u32 flags,
+static int wait_for_irq(struct uniphier_fi2c_priv *priv, u32 flags,
bool *stop)
 {
u32 irq;
int ret;
 
-   ret = readl_poll_timeout(>regs->intr, irq, irq & flags,
-dev->timeout);
+   ret = readl_poll_timeout(>regs->intr, irq, irq & flags,
+priv->timeout);
if (ret < 0) {
-   debug("error: time out\n");
+   dev_dbg(priv->dev, "error: time out\n");
return ret;
}
 
if (irq & I2C_INT_AL) {
-   debug("error: arbitration lost\n");
+   dev_dbg(priv->dev, "error: arbitration lost\n");
*stop = false;
return ret;
}
 
if (irq & I2C_INT_NA) {
-   debug("error: no answer\n");
+   dev_dbg(priv->dev, "error: no answer\n");
return ret;
}
 
return 0;
 }
 
-static int issue_stop(struct uniphier_fi2c_dev *dev, int old_ret)
+static int issue_stop(struct uniphier_fi2c_priv *priv, int old_ret)
 {
int ret;
 
-   debug("stop condition\n");
-   writel(I2C_CR_MST | I2C_CR_STO, >regs->cr);
+   dev_dbg(priv->dev, "stop condition\n");
+   writel(I2C_CR_MST | I2C_CR_STO, >regs->cr);
 
-   ret = check_device_busy(dev->regs);
+   ret = uniphier_fi2c_check_bus_busy(priv);
if (ret < 0)
-   debug("error: device busy after operation\n");
+   dev_dbg(priv->dev, "error: device busy after operation\n");
 
return old_ret ? old_ret : ret;
 }
 
-static int uniphier_fi2c_transmit(struct uniphier_fi2c_dev *dev, uint addr,
+static int uniphier_fi2c_transmit(struct uniphier_fi2c_priv *priv, uint addr,
  uint len, const u8 *buf, bool *stop)
 {
int ret;
const u32 irq_flags =