public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@free-electrons.com>
To: davem@davemloft.net, jason@lakedaemon.net, andrew@lunn.ch,
	gregory.clement@free-electrons.com,
	sebastian.hesselbarth@gmail.com, f.fainelli@gmail.com
Cc: Antoine Tenart <antoine.tenart@free-electrons.com>,
	thomas.petazzoni@free-electrons.com, nadavh@marvell.com,
	mw@semihalf.com, linux@armlinux.org.uk, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/9] net: mvmdio: move the read valid check into its own function
Date: Mon, 12 Jun 2017 11:57:40 +0200	[thread overview]
Message-ID: <20170612095745.11300-5-antoine.tenart@free-electrons.com> (raw)
In-Reply-To: <20170612095745.11300-1-antoine.tenart@free-electrons.com>

Move the read valid check in its own function. This is needed as a
requirement to factorize the driver to add the xMDIO support in the
future.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 583f1c5753c2..2ed819d25305 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -69,6 +69,11 @@ static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev)
 	return !(readl(dev->regs) & MVMDIO_SMI_BUSY);
 }
 
+static int orion_mdio_smi_is_read_valid(struct orion_mdio_dev *dev)
+{
+	return readl(dev->regs) & MVMDIO_SMI_READ_VALID;
+}
+
 /* Wait for the SMI unit to be ready for another operation
  */
 static int orion_mdio_wait_ready(struct mii_bus *bus)
@@ -113,7 +118,6 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 			   int regnum)
 {
 	struct orion_mdio_dev *dev = bus->priv;
-	u32 val;
 	int ret;
 
 	mutex_lock(&dev->lock);
@@ -131,14 +135,13 @@ static int orion_mdio_read(struct mii_bus *bus, int mii_id,
 	if (ret < 0)
 		goto out;
 
-	val = readl(dev->regs);
-	if (!(val & MVMDIO_SMI_READ_VALID)) {
+	if (!orion_mdio_smi_is_read_valid(dev)) {
 		dev_err(bus->parent, "SMI bus read not valid\n");
 		ret = -ENODEV;
 		goto out;
 	}
 
-	ret = val & GENMASK(15, 0);
+	ret = readl(dev->regs) & GENMASK(15, 0);
 out:
 	mutex_unlock(&dev->lock);
 	return ret;
-- 
2.9.4

  parent reply	other threads:[~2017-06-12 10:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12  9:57 [PATCH v3 0/9] net: mvmdio: add xMDIO xSMI support Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 1/9] net: mvmdio: reorder headers alphabetically Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 2/9] net: mvmdio: use tabs for defines Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 3/9] net: mvmdio: use GENMASK for masks Antoine Tenart
2017-06-12  9:57 ` Antoine Tenart [this message]
2017-06-12  9:57 ` [PATCH v3 5/9] net: mvmdio: introduce an ops structure Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 6/9] net: mvmdio: put the poll intervals in the " Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 7/9] net: mvmdio: add xmdio xsmi support Antoine Tenart
2017-06-12 10:07   ` Russell King - ARM Linux
2017-06-12 10:17   ` Russell King - ARM Linux
2017-06-12 10:41     ` Russell King - ARM Linux
2017-06-12 10:42       ` Russell King - ARM Linux
2017-06-12 10:42       ` Russell King - ARM Linux
2017-06-12 11:54     ` Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 8/9] dt-bindings: orion-mdio: document the new xmdio compatible Antoine Tenart
2017-06-12  9:57 ` [PATCH v3 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k Antoine Tenart

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=20170612095745.11300-5-antoine.tenart@free-electrons.com \
    --to=antoine.tenart@free-electrons.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mw@semihalf.com \
    --cc=nadavh@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=thomas.petazzoni@free-electrons.com \
    /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