Commit 51371cdc authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 3e3aabac
...@@ -80,9 +80,6 @@ ...@@ -80,9 +80,6 @@
#define RCAR_IRQ_ACK_SEND (~(MAT | MDE)) #define RCAR_IRQ_ACK_SEND (~(MAT | MDE))
#define RCAR_IRQ_ACK_RECV (~(MAT | MDR)) #define RCAR_IRQ_ACK_RECV (~(MAT | MDR))
/*
* flags
*/
#define ID_LAST_MSG (1 << 0) #define ID_LAST_MSG (1 << 0)
#define ID_IOERROR (1 << 1) #define ID_IOERROR (1 << 1)
#define ID_DONE (1 << 2) #define ID_DONE (1 << 2)
...@@ -105,7 +102,7 @@ struct rcar_i2c_priv { ...@@ -105,7 +102,7 @@ struct rcar_i2c_priv {
int pos; int pos;
u32 icccr; u32 icccr;
u32 flags; u32 flags;
enum rcar_i2c_type devtype; enum rcar_i2c_type devtype;
}; };
#define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent) #define rcar_i2c_priv_to_dev(p) ((p)->adap.dev.parent)
...@@ -116,9 +113,7 @@ struct rcar_i2c_priv { ...@@ -116,9 +113,7 @@ struct rcar_i2c_priv {
#define LOOP_TIMEOUT 1024 #define LOOP_TIMEOUT 1024
/*
* basic functions
*/
static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val) static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val)
{ {
writel(val, priv->io + reg); writel(val, priv->io + reg);
...@@ -147,9 +142,6 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv) ...@@ -147,9 +142,6 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
rcar_i2c_write(priv, ICMAR, 0); rcar_i2c_write(priv, ICMAR, 0);
} }
/*
* bus control functions
*/
static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
{ {
int i; int i;
...@@ -164,9 +156,6 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) ...@@ -164,9 +156,6 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
return -EBUSY; return -EBUSY;
} }
/*
* clock function
*/
static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
u32 bus_speed, u32 bus_speed,
struct device *dev) struct device *dev)
...@@ -256,10 +245,6 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, ...@@ -256,10 +245,6 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
return 0; return 0;
} }
/*
* status functions
*/
static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv) static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
{ {
int read = !!rcar_i2c_is_recv(priv); int read = !!rcar_i2c_is_recv(priv);
...@@ -380,40 +365,24 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr) ...@@ -380,40 +365,24 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
static irqreturn_t rcar_i2c_irq(int irq, void *ptr) static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
{ {
struct rcar_i2c_priv *priv = ptr; struct rcar_i2c_priv *priv = ptr;
struct device *dev = rcar_i2c_priv_to_dev(priv);
u32 msr; u32 msr;
msr = rcar_i2c_read(priv, ICMSR); msr = rcar_i2c_read(priv, ICMSR);
/* /* Arbitration lost */
* Arbitration lost
*/
if (msr & MAL) { if (msr & MAL) {
/*
* CAUTION
*
* When arbitration lost, device become _slave_ mode.
*/
dev_dbg(dev, "Arbitration Lost\n");
rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST)); rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST));
goto out; goto out;
} }
/* /* Stop */
* Stop
*/
if (msr & MST) { if (msr & MST) {
dev_dbg(dev, "Stop\n");
rcar_i2c_flags_set(priv, ID_DONE); rcar_i2c_flags_set(priv, ID_DONE);
goto out; goto out;
} }
/* /* Nack */
* Nack
*/
if (msr & MNR) { if (msr & MNR) {
dev_dbg(dev, "Nack\n");
/* go to stop phase */ /* go to stop phase */
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP); rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP); rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
...@@ -421,9 +390,6 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr) ...@@ -421,9 +390,6 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
goto out; goto out;
} }
/*
* recv/send
*/
if (rcar_i2c_is_recv(priv)) if (rcar_i2c_is_recv(priv))
rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr)); rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr));
else else
...@@ -476,9 +442,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -476,9 +442,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
if (ret < 0) if (ret < 0)
break; break;
/*
* wait result
*/
timeout = wait_event_timeout(priv->wait, timeout = wait_event_timeout(priv->wait,
rcar_i2c_flags_has(priv, ID_DONE), rcar_i2c_flags_has(priv, ID_DONE),
5 * HZ); 5 * HZ);
...@@ -487,9 +450,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -487,9 +450,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
break; break;
} }
/*
* error handling
*/
if (rcar_i2c_flags_has(priv, ID_NACK)) { if (rcar_i2c_flags_has(priv, ID_NACK)) {
ret = -ENXIO; ret = -ENXIO;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment