aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2014-05-28 03:44:45 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-06-01 16:22:55 -0400
commit51371cdc86403d9f643efe3d4a4febd11f084c74 (patch)
tree02d1e14223e2af9f9b980dd7d24ef5da1d035135
parent3e3aabac443e25712a3788cf88cc188e13ca8b0e (diff)
i2c: rcar: janitorial cleanup after refactoring
Remove some obvious comments, remove some superfluous debug output (the error code carries the same information), some white space fixing... Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-rcar.c50
1 files changed, 5 insertions, 45 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 4c46d1b1b61d..27b84d734a60 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -80,9 +80,6 @@
80#define RCAR_IRQ_ACK_SEND (~(MAT | MDE)) 80#define RCAR_IRQ_ACK_SEND (~(MAT | MDE))
81#define RCAR_IRQ_ACK_RECV (~(MAT | MDR)) 81#define RCAR_IRQ_ACK_RECV (~(MAT | MDR))
82 82
83/*
84 * flags
85 */
86#define ID_LAST_MSG (1 << 0) 83#define ID_LAST_MSG (1 << 0)
87#define ID_IOERROR (1 << 1) 84#define ID_IOERROR (1 << 1)
88#define ID_DONE (1 << 2) 85#define ID_DONE (1 << 2)
@@ -105,7 +102,7 @@ struct rcar_i2c_priv {
105 int pos; 102 int pos;
106 u32 icccr; 103 u32 icccr;
107 u32 flags; 104 u32 flags;
108 enum rcar_i2c_type devtype; 105 enum rcar_i2c_type devtype;
109}; 106};
110 107
111#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) 108#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
@@ -116,9 +113,7 @@ struct rcar_i2c_priv {
116 113
117#define LOOP_TIMEOUT 1024 114#define LOOP_TIMEOUT 1024
118 115
119/* 116
120 * basic functions
121 */
122static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val) 117static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val)
123{ 118{
124 writel(val, priv->io + reg); 119 writel(val, priv->io + reg);
@@ -147,9 +142,6 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
147 rcar_i2c_write(priv, ICMAR, 0); 142 rcar_i2c_write(priv, ICMAR, 0);
148} 143}
149 144
150/*
151 * bus control functions
152 */
153static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) 145static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
154{ 146{
155 int i; 147 int i;
@@ -164,9 +156,6 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
164 return -EBUSY; 156 return -EBUSY;
165} 157}
166 158
167/*
168 * clock function
169 */
170static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, 159static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
171 u32 bus_speed, 160 u32 bus_speed,
172 struct device *dev) 161 struct device *dev)
@@ -256,10 +245,6 @@ scgd_find:
256 return 0; 245 return 0;
257} 246}
258 247
259/*
260 * status functions
261 */
262
263static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) 248static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
264{ 249{
265 int read = !!rcar_i2c_is_recv(priv); 250 int read = !!rcar_i2c_is_recv(priv);
@@ -380,40 +365,24 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
380static irqreturn_t rcar_i2c_irq(int irq, void *ptr) 365static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
381{ 366{
382 struct rcar_i2c_priv *priv = ptr; 367 struct rcar_i2c_priv *priv = ptr;
383 struct device *dev = rcar_i2c_priv_to_dev(priv);
384 u32 msr; 368 u32 msr;
385 369
386 msr = rcar_i2c_read(priv, ICMSR); 370 msr = rcar_i2c_read(priv, ICMSR);
387 371
388 /* 372 /* Arbitration lost */
389 * Arbitration lost
390 */
391 if (msr & MAL) { 373 if (msr & MAL) {
392 /*
393 * CAUTION
394 *
395 * When arbitration lost, device become _slave_ mode.
396 */
397 dev_dbg(dev, "Arbitration Lost\n");
398 rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST)); 374 rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST));
399 goto out; 375 goto out;
400 } 376 }
401 377
402 /* 378 /* Stop */
403 * Stop
404 */
405 if (msr & MST) { 379 if (msr & MST) {
406 dev_dbg(dev, "Stop\n");
407 rcar_i2c_flags_set(priv, ID_DONE); 380 rcar_i2c_flags_set(priv, ID_DONE);
408 goto out; 381 goto out;
409 } 382 }
410 383
411 /* 384 /* Nack */
412 * Nack
413 */
414 if (msr & MNR) { 385 if (msr & MNR) {
415 dev_dbg(dev, "Nack\n");
416
417 /* go to stop phase */ 386 /* go to stop phase */
418 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP); 387 rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
419 rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP); 388 rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
@@ -421,9 +390,6 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
421 goto out; 390 goto out;
422 } 391 }
423 392
424 /*
425 * recv/send
426 */
427 if (rcar_i2c_is_recv(priv)) 393 if (rcar_i2c_is_recv(priv))
428 rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr)); 394 rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr));
429 else 395 else
@@ -476,9 +442,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
476 if (ret < 0) 442 if (ret < 0)
477 break; 443 break;
478 444
479 /*
480 * wait result
481 */
482 timeout = wait_event_timeout(priv->wait, 445 timeout = wait_event_timeout(priv->wait,
483 rcar_i2c_flags_has(priv, ID_DONE), 446 rcar_i2c_flags_has(priv, ID_DONE),
484 5 * HZ); 447 5 * HZ);
@@ -487,9 +450,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
487 break; 450 break;
488 } 451 }
489 452
490 /*
491 * error handling
492 */
493 if (rcar_i2c_flags_has(priv, ID_NACK)) { 453 if (rcar_i2c_flags_has(priv, ID_NACK)) {
494 ret = -ENXIO; 454 ret = -ENXIO;
495 break; 455 break;