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 =