提交 54377cd0 编写于 作者: W Wolfgang Grandegger 提交者: Ben Dooks

i2c: i2c-mpc: use dev based printout function

This patch used the dev_dbg, dev_err, etc. functions for debug
and error output instead of printk and pr_debug.
Signed-off-by: NWolfgang Grandegger <wg@grandegger.com>
Signed-off-by: NBen Dooks <ben-linux@fluff.org>
上级 8101a300
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define CSR_RXAK 0x01 #define CSR_RXAK 0x01
struct mpc_i2c { struct mpc_i2c {
struct device *dev;
void __iomem *base; void __iomem *base;
u32 interrupt; u32 interrupt;
wait_queue_head_t queue; wait_queue_head_t queue;
...@@ -104,7 +105,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -104,7 +105,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
schedule(); schedule();
if (time_after(jiffies, orig_jiffies + timeout)) { if (time_after(jiffies, orig_jiffies + timeout)) {
pr_debug("I2C: timeout\n"); dev_dbg(i2c->dev, "timeout\n");
writeccr(i2c, 0); writeccr(i2c, 0);
result = -EIO; result = -EIO;
break; break;
...@@ -118,7 +119,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -118,7 +119,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
(i2c->interrupt & CSR_MIF), timeout); (i2c->interrupt & CSR_MIF), timeout);
if (unlikely(!(i2c->interrupt & CSR_MIF))) { if (unlikely(!(i2c->interrupt & CSR_MIF))) {
pr_debug("I2C: wait timeout\n"); dev_dbg(i2c->dev, "wait timeout\n");
writeccr(i2c, 0); writeccr(i2c, 0);
result = -ETIMEDOUT; result = -ETIMEDOUT;
} }
...@@ -131,17 +132,17 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -131,17 +132,17 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
return result; return result;
if (!(x & CSR_MCF)) { if (!(x & CSR_MCF)) {
pr_debug("I2C: unfinished\n"); dev_dbg(i2c->dev, "unfinished\n");
return -EIO; return -EIO;
} }
if (x & CSR_MAL) { if (x & CSR_MAL) {
pr_debug("I2C: MAL\n"); dev_dbg(i2c->dev, "MAL\n");
return -EIO; return -EIO;
} }
if (writing && (x & CSR_RXAK)) { if (writing && (x & CSR_RXAK)) {
pr_debug("I2C: No RXAK\n"); dev_dbg(i2c->dev, "No RXAK\n");
/* generate stop */ /* generate stop */
writeccr(i2c, CCR_MEN); writeccr(i2c, CCR_MEN);
return -EIO; return -EIO;
...@@ -263,12 +264,12 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -263,12 +264,12 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
/* Allow bus up to 1s to become not busy */ /* Allow bus up to 1s to become not busy */
while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) { while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
if (signal_pending(current)) { if (signal_pending(current)) {
pr_debug("I2C: Interrupted\n"); dev_dbg(i2c->dev, "Interrupted\n");
writeccr(i2c, 0); writeccr(i2c, 0);
return -EINTR; return -EINTR;
} }
if (time_after(jiffies, orig_jiffies + HZ)) { if (time_after(jiffies, orig_jiffies + HZ)) {
pr_debug("I2C: timeout\n"); dev_dbg(i2c->dev, "timeout\n");
if (readb(i2c->base + MPC_I2C_SR) == if (readb(i2c->base + MPC_I2C_SR) ==
(CSR_MCF | CSR_MBB | CSR_RXAK)) (CSR_MCF | CSR_MBB | CSR_RXAK))
mpc_i2c_fixup(i2c); mpc_i2c_fixup(i2c);
...@@ -279,9 +280,10 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -279,9 +280,10 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
for (i = 0; ret >= 0 && i < num; i++) { for (i = 0; ret >= 0 && i < num; i++) {
pmsg = &msgs[i]; pmsg = &msgs[i];
pr_debug("Doing %s %d bytes to 0x%02x - %d of %d messages\n", dev_dbg(i2c->dev,
pmsg->flags & I2C_M_RD ? "read" : "write", "Doing %s %d bytes to 0x%02x - %d of %d messages\n",
pmsg->len, pmsg->addr, i + 1, num); pmsg->flags & I2C_M_RD ? "read" : "write",
pmsg->len, pmsg->addr, i + 1, num);
if (pmsg->flags & I2C_M_RD) if (pmsg->flags & I2C_M_RD)
ret = ret =
mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i); mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
...@@ -320,6 +322,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op, ...@@ -320,6 +322,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
if (!i2c) if (!i2c)
return -ENOMEM; return -ENOMEM;
i2c->dev = &op->dev; /* for debug and error output */
if (of_get_property(op->node, "dfsrr", NULL)) if (of_get_property(op->node, "dfsrr", NULL))
i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR; i2c->flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
...@@ -331,7 +335,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, ...@@ -331,7 +335,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
i2c->base = of_iomap(op->node, 0); i2c->base = of_iomap(op->node, 0);
if (!i2c->base) { if (!i2c->base) {
printk(KERN_ERR "i2c-mpc - failed to map controller\n"); dev_err(i2c->dev, "failed to map controller\n");
result = -ENOMEM; result = -ENOMEM;
goto fail_map; goto fail_map;
} }
...@@ -341,8 +345,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, ...@@ -341,8 +345,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
result = request_irq(i2c->irq, mpc_i2c_isr, result = request_irq(i2c->irq, mpc_i2c_isr,
IRQF_SHARED, "i2c-mpc", i2c); IRQF_SHARED, "i2c-mpc", i2c);
if (result < 0) { if (result < 0) {
printk(KERN_ERR dev_err(i2c->dev, "failed to attach interrupt\n");
"i2c-mpc - failed to attach interrupt\n");
goto fail_request; goto fail_request;
} }
} }
...@@ -357,7 +360,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, ...@@ -357,7 +360,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
result = i2c_add_adapter(&i2c->adap); result = i2c_add_adapter(&i2c->adap);
if (result < 0) { if (result < 0) {
printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); dev_err(i2c->dev, "failed to add adapter\n");
goto fail_add; goto fail_add;
} }
of_register_i2c_devices(&i2c->adap, op->node); of_register_i2c_devices(&i2c->adap, op->node);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册