diff mbox

[2/3] sh_eth: factor out common code from MDIO bitbang methods

Message ID 2708108.aPmlclaWv5@wasted.cogentembedded.com (mailing list archive)
State Awaiting Upstream
Delegated to: Simon Horman
Headers show

Commit Message

Sergei Shtylyov Dec. 7, 2015, 9:40 p.m. UTC
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>

---
 drivers/net/ethernet/renesas/sh_eth.c |   35 +++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Simon Horman Dec. 8, 2015, 12:42 a.m. UTC | #1
On Tue, Dec 08, 2015 at 12:40:57AM +0300, Sergei Shtylyov wrote:
> 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>

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/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_ctr
 /* 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 */