summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2014-05-28 09:44:41 +0200
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>2015-02-04 11:14:15 +0100
commit060e667617aee0981b8aa04963a1219372b2db8a (patch)
treea5b4fbe5fd6092826ee4a3ddc041b01c0255d94a /drivers
parent51a1175f87d34301945a554a77737a6d5cef3dbe (diff)
downloadkernel-common-060e667617aee0981b8aa04963a1219372b2db8a.tar.gz
kernel-common-060e667617aee0981b8aa04963a1219372b2db8a.tar.bz2
kernel-common-060e667617aee0981b8aa04963a1219372b2db8a.zip
i2c: rcar: refactor setting up msg
Setting up a read or write message is similar enough to be done in one function. Also, move a helper function into the new function since it is only used here. 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> (cherry picked from commit 386babf8e2f7dd483f88e5c0c4c761346b750185) Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-rcar.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 828b519146fc..42005ccd3254 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -155,11 +155,6 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
rcar_i2c_write(priv, ICMAR, 0);
}
-static void rcar_i2c_set_addr(struct rcar_i2c_priv *priv, u32 recv)
-{
- rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | recv);
-}
-
/*
* bus control functions
*/
@@ -279,25 +274,14 @@ static void rcar_i2c_status_bit_clear(struct rcar_i2c_priv *priv, u32 bit)
rcar_i2c_write(priv, ICMSR, ~bit);
}
-/*
- * recv/send functions
- */
-static int rcar_i2c_recv(struct rcar_i2c_priv *priv)
+static int rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
{
- rcar_i2c_set_addr(priv, 1);
- rcar_i2c_status_clear(priv);
- rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
- rcar_i2c_write(priv, ICMIER, RCAR_IRQ_RECV);
-
- return 0;
-}
+ int read = !!rcar_i2c_is_recv(priv);
-static int rcar_i2c_send(struct rcar_i2c_priv *priv)
-{
- rcar_i2c_set_addr(priv, 0);
+ rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
rcar_i2c_status_clear(priv);
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
- rcar_i2c_write(priv, ICMIER, RCAR_IRQ_SEND);
+ rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);
return 0;
}
@@ -520,11 +504,7 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
if (priv->msg == &msgs[num - 1])
rcar_i2c_flags_set(priv, ID_LAST_MSG);
- /* start send/recv */
- if (rcar_i2c_is_recv(priv))
- ret = rcar_i2c_recv(priv);
- else
- ret = rcar_i2c_send(priv);
+ ret = rcar_i2c_prepare_msg(priv);
spin_unlock_irqrestore(&priv->lock, flags);
/*-------------- spin unlock -----------------*/