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, mw@semihalf.com, linux@armlinux.org.uk, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/8] net: mvmdio: move the read valid check into its own function Date: Thu, 8 Jun 2017 11:26:49 +0200 [thread overview] Message-ID: <20170608092653.25221-5-antoine.tenart@free-electrons.com> (raw) In-Reply-To: <20170608092653.25221-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 96af8d57d9e5..6cbdb221c1ab 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
WARNING: multiple messages have this Message-ID (diff)
From: antoine.tenart@free-electrons.com (Antoine Tenart) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/8] net: mvmdio: move the read valid check into its own function Date: Thu, 8 Jun 2017 11:26:49 +0200 [thread overview] Message-ID: <20170608092653.25221-5-antoine.tenart@free-electrons.com> (raw) In-Reply-To: <20170608092653.25221-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 96af8d57d9e5..6cbdb221c1ab 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
next prev parent reply other threads:[~2017-06-08 10:00 UTC|newest] Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-08 9:26 [PATCH v2 0/8] net: mvmdio: add xSMI support Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 1/8] net: mvmdio: reorder headers alphabetically Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 2/8] net: mvmdio: use tabs for defines Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 3/8] net: mvmdio: use GENMASK for masks Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 10:35 ` Sergei Shtylyov 2017-06-08 10:35 ` Sergei Shtylyov 2017-06-08 9:26 ` Antoine Tenart [this message] 2017-06-08 9:26 ` [PATCH v2 4/8] net: mvmdio: move the read valid check into its own function Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 5/8] net: mvmdio: introduce an ops structure Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 6/8] net: mvmdio: put the poll intervals in the " Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 9:26 ` [PATCH v2 7/8] net: mvmdio: add xmdio support Antoine Tenart 2017-06-08 9:26 ` Antoine Tenart 2017-06-08 16:03 ` Andrew Lunn 2017-06-08 16:03 ` Andrew Lunn 2017-06-09 6:40 ` Antoine Tenart 2017-06-09 6:40 ` Antoine Tenart 2017-06-09 20:00 ` Russell King - ARM Linux 2017-06-09 20:00 ` Russell King - ARM Linux 2017-06-08 16:42 ` Florian Fainelli 2017-06-08 16:42 ` Florian Fainelli 2017-06-08 16:55 ` Andrew Lunn 2017-06-08 16:55 ` Andrew Lunn 2017-06-09 6:39 ` Antoine Tenart 2017-06-09 6:39 ` Antoine Tenart 2017-06-09 8:25 ` Antoine Tenart 2017-06-09 8:25 ` Antoine Tenart 2017-06-09 13:26 ` Andrew Lunn 2017-06-09 13:26 ` Andrew Lunn 2017-06-09 14:09 ` Antoine Tenart 2017-06-09 14:09 ` Antoine Tenart 2017-06-09 14:49 ` Andrew Lunn 2017-06-09 14:49 ` Andrew Lunn 2017-06-09 14:56 ` Antoine Tenart 2017-06-09 14:56 ` Antoine Tenart 2017-06-09 15:03 ` Andrew Lunn 2017-06-09 15:03 ` Andrew Lunn 2017-06-09 16:22 ` Antoine Tenart 2017-06-09 16:22 ` Antoine Tenart 2017-06-09 19:56 ` Russell King - ARM Linux 2017-06-09 19:56 ` Russell King - ARM Linux 2017-06-09 19:51 ` Russell King - ARM Linux 2017-06-09 19:51 ` Russell King - ARM Linux 2017-06-08 9:26 ` [PATCH v2 8/8] arm64: marvell: dts: add xmdio nodes for 7k/8k Antoine Tenart 2017-06-08 9:26 ` 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=20170608092653.25221-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=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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.