[RFC,2/4] net: dsa: microchip: Use regmap_update_bits
diff mbox series

Message ID 1547695326-31553-3-git-send-email-Tristram.Ha@microchip.com
State RFC
Delegated to: David Miller
Headers show
Series
  • Convert KSZ9477 SPI driver to use regmap
Related show

Commit Message

Tristram.Ha@microchip.com Jan. 17, 2019, 3:22 a.m. UTC
From: Tristram Ha <Tristram.Ha@microchip.com>

Use regmap_update_bits function for bit manipulation in 32-bit access.

Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
---
 drivers/net/dsa/microchip/ksz9477.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 89ed059..14b6371 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -65,31 +65,14 @@ 
 
 static void ksz9477_cfg32(struct ksz_device *dev, u32 addr, u32 bits, bool set)
 {
-	u32 data;
-
-	ksz_read32(dev, addr, &data);
-	if (set)
-		data |= bits;
-	else
-		data &= ~bits;
-	ksz_write32(dev, addr, data);
+	regmap_update_bits(dev->regmap[2], addr, bits, set ? bits : 0);
 }
 
 static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
 			       u32 bits, bool set)
 {
-	u32 addr;
-	u32 data;
-
-	addr = PORT_CTRL_ADDR(port, offset);
-	ksz_read32(dev, addr, &data);
-
-	if (set)
-		data |= bits;
-	else
-		data &= ~bits;
-
-	ksz_write32(dev, addr, data);
+	regmap_update_bits(dev->regmap[2], PORT_CTRL_ADDR(port, offset), bits,
+			   set ? bits : 0);
 }
 
 static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev, u32 waiton,