Commit 39b4b06b authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by David S. Miller

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: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3242e2b4
...@@ -1033,32 +1033,29 @@ static int bb_read(void *addr, u32 msk) ...@@ -1033,32 +1033,29 @@ static int bb_read(void *addr, u32 msk)
return (ioread32(addr) & msk) != 0; return (ioread32(addr) & msk) != 0;
} }
/* Data I/O pin control */ static void sh_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set)
static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
if (bitbang->set_gate) if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr); bitbang->set_gate(bitbang->addr);
if (bit) if (set)
bb_set(bitbang->addr, PIR_MMD); bb_set(bitbang->addr, mask);
else 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*/ /* Set bit data*/
static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit) static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); sh_mdio_ctrl(ctrl, PIR_MDO, bit);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
if (bit)
bb_set(bitbang->addr, PIR_MDO);
else
bb_clr(bitbang->addr, PIR_MDO);
} }
/* Get bit data*/ /* Get bit data*/
...@@ -1075,15 +1072,7 @@ static int sh_get_mdio(struct mdiobb_ctrl *ctrl) ...@@ -1075,15 +1072,7 @@ static int sh_get_mdio(struct mdiobb_ctrl *ctrl)
/* MDC pin control */ /* MDC pin control */
static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit) static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); sh_mdio_ctrl(ctrl, PIR_MDC, bit);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
if (bit)
bb_set(bitbang->addr, PIR_MDC);
else
bb_clr(bitbang->addr, PIR_MDC);
} }
/* mdio bus control struct */ /* mdio bus control struct */
......
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