From: Marek Vasut <marex@denx.de>
To: netdev@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Tristram Ha <Tristram.Ha@microchip.com>,
Woojung Huh <Woojung.Huh@microchip.com>
Subject: [PATCH 1/5] net: dsa: microchip: Replace ad-hoc polling with regmap
Date: Thu, 27 Jun 2019 23:55:52 +0200 [thread overview]
Message-ID: <20190627215556.23768-2-marex@denx.de> (raw)
In-Reply-To: <20190627215556.23768-1-marex@denx.de>
Regmap provides polling function to poll for bits in a register,
use in instead of reimplementing it.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Cc: Woojung Huh <Woojung.Huh@microchip.com>
---
drivers/net/dsa/microchip/ksz9477.c | 14 +++++---------
drivers/net/dsa/microchip/ksz_common.h | 14 --------------
2 files changed, 5 insertions(+), 23 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 8f13dcc05a10..ece25f38e02a 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -263,12 +263,8 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
static void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr,
u64 *cnt)
{
- struct ksz_poll_ctx ctx = {
- .dev = dev,
- .port = port,
- .offset = REG_PORT_MIB_CTRL_STAT__4,
- };
struct ksz_port *p = &dev->ports[port];
+ unsigned int val;
u32 data;
int ret;
@@ -278,11 +274,11 @@ static void ksz9477_r_mib_cnt(struct ksz_device *dev, int port, u16 addr,
data |= (addr << MIB_COUNTER_INDEX_S);
ksz_pwrite32(dev, port, REG_PORT_MIB_CTRL_STAT__4, data);
- ret = readx_poll_timeout(ksz_pread32_poll, &ctx, data,
- !(data & MIB_COUNTER_READ), 10, 1000);
-
+ ret = regmap_read_poll_timeout(dev->regmap[2],
+ PORT_CTRL_ADDR(port, REG_PORT_MIB_CTRL_STAT__4),
+ val, !(val & MIB_COUNTER_READ), 10, 1000);
/* failed to read MIB. get out of loop */
- if (ret < 0) {
+ if (ret) {
dev_dbg(dev->dev, "Failed to get MIB\n");
return;
}
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 745318424f71..ee7096d8af07 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -119,20 +119,6 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,
ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data);
}
-struct ksz_poll_ctx {
- struct ksz_device *dev;
- int port;
- int offset;
-};
-
-static inline u32 ksz_pread32_poll(struct ksz_poll_ctx *ctx)
-{
- u32 data;
-
- ksz_pread32(ctx->dev, ctx->port, ctx->offset, &data);
- return data;
-}
-
/* Regmap tables generation */
#define KSZ_SPI_OP_RD 3
#define KSZ_SPI_OP_WR 2
--
2.20.1
next prev parent reply other threads:[~2019-06-27 21:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-27 21:55 [PATCH 0/5] net: dsa: microchip: Further regmap cleanups Marek Vasut
2019-06-27 21:55 ` Marek Vasut [this message]
2019-06-28 0:38 ` [PATCH 1/5] net: dsa: microchip: Replace ad-hoc polling with regmap Andrew Lunn
2019-06-28 2:43 ` Florian Fainelli
2019-06-27 21:55 ` [PATCH 2/5] net: dsa: microchip: Replace ksz9477_wait_vlan_ctrl_ready " Marek Vasut
2019-06-28 0:39 ` Andrew Lunn
2019-06-28 2:44 ` Florian Fainelli
2019-06-27 21:55 ` [PATCH 3/5] net: dsa: microchip: Replace ksz9477_wait_alu_ready " Marek Vasut
2019-06-28 0:40 ` Andrew Lunn
2019-06-27 21:55 ` [PATCH 4/5] net: dsa: microchip: Replace ksz9477_wait_alu_sta_ready " Marek Vasut
2019-06-28 0:41 ` Andrew Lunn
2019-06-27 21:55 ` [PATCH 5/5] net: dsa: microchip: Replace bit RMW " Marek Vasut
2019-06-28 0:42 ` Andrew Lunn
2019-06-28 2:25 ` [PATCH 0/5] net: dsa: microchip: Further regmap cleanups David Miller
2019-06-28 15:31 ` Vivien Didelot
2019-06-28 16:36 ` Marek Vasut
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=20190627215556.23768-2-marex@denx.de \
--to=marex@denx.de \
--cc=Tristram.Ha@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--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).