netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: netdev@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Subject: [PATCH 2/3] sh_eth: factor out common code from MDIO bitbang methods
Date: Tue, 08 Dec 2015 00:40:57 +0300	[thread overview]
Message-ID: <2708108.aPmlclaWv5@wasted.cogentembedded.com> (raw)
In-Reply-To: <1582774.FcjyuztLtc@wasted.cogentembedded.com>

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(-)

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 */


  parent reply	other threads:[~2015-12-07 21:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 21:39 [PATCH 0/3] sh_eth: optimize MDIO code Sergei Shtylyov
2015-12-07 21:40 ` [PATCH 1/3] sh_eth: remove mask fields from 'struct bb_info' Sergei Shtylyov
2015-12-08  0:42   ` Simon Horman
2015-12-07 21:40 ` Sergei Shtylyov [this message]
2015-12-08  0:42   ` [PATCH 2/3] sh_eth: factor out common code from MDIO bitbang methods Simon Horman
2015-12-07 21:41 ` [PATCH 3/3] sh_eth: get rid of bb_{set|clr|read}() Sergei Shtylyov
2015-12-08  0:42   ` Simon Horman
2015-12-09  2:56 ` [PATCH 0/3] sh_eth: optimize MDIO code David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2708108.aPmlclaWv5@wasted.cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-sh@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).