summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>2015-12-08 00:40:57 +0300
committerDavid S. Miller <davem@davemloft.net>2015-12-08 21:55:05 -0500
commit39b4b06b8b20ae011373bae5f9552cce17c47f64 (patch)
tree9d70e499e0295581b0b0ad09ea18028394dc859b
parent3242e2b46d297e48846022694502d9023c22f6c1 (diff)
downloadlinux-stable-39b4b06b8b20ae011373bae5f9552cce17c47f64.tar.gz
linux-stable-39b4b06b8b20ae011373bae5f9552cce17c47f64.tar.bz2
linux-stable-39b4b06b8b20ae011373bae5f9552cce17c47f64.zip
sh_eth: factor out common code from MDIO bitbang methods
sh_mm[cd]_ctrl() and sh_set_mdio() all look mostly the same -- factor out their common code and put it into sh_mdio_ctrl(). Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index a2fb45aa776e..f0c7108f84d1 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1033,32 +1033,29 @@ static int bb_read(void *addr, u32 msk)
return (ioread32(addr) & msk) != 0;
}
-/* Data I/O pin control */
-static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
+static void sh_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set)
{
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
- if (bit)
- bb_set(bitbang->addr, PIR_MMD);
+ if (set)
+ bb_set(bitbang->addr, mask);
else
- bb_clr(bitbang->addr, PIR_MMD);
+ bb_clr(bitbang->addr, mask);
+}
+
+/* Data I/O pin control */
+static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
+{
+ sh_mdio_ctrl(ctrl, PIR_MMD, bit);
}
/* Set bit data*/
static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
{
- struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
-
- if (bitbang->set_gate)
- bitbang->set_gate(bitbang->addr);
-
- if (bit)
- bb_set(bitbang->addr, PIR_MDO);
- else
- bb_clr(bitbang->addr, PIR_MDO);
+ sh_mdio_ctrl(ctrl, PIR_MDO, bit);
}
/* Get bit data*/
@@ -1075,15 +1072,7 @@ static int sh_get_mdio(struct mdiobb_ctrl *ctrl)
/* MDC pin control */
static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{
- struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
-
- if (bitbang->set_gate)
- bitbang->set_gate(bitbang->addr);
-
- if (bit)
- bb_set(bitbang->addr, PIR_MDC);
- else
- bb_clr(bitbang->addr, PIR_MDC);
+ sh_mdio_ctrl(ctrl, PIR_MDC, bit);
}
/* mdio bus control struct */