drivers/net/dsa/lantiq/lantiq_gswip_common.c | 8 ++------ drivers/net/dsa/mt7530.c | 10 ++-------- drivers/net/dsa/qca/qca8k-common.c | 15 +++------------ 3 files changed, 7 insertions(+), 26 deletions(-)
From: Peng Fan <peng.fan@nxp.com>
Replace if/else blocks using regmap_set_bits()/regmap_clear_bits() with
the simpler regmap_assign_bits() calls in the lantiq gswip, mt7530 and
qca8k drivers.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/net/dsa/lantiq/lantiq_gswip_common.c | 8 ++------
drivers/net/dsa/mt7530.c | 10 ++--------
drivers/net/dsa/qca/qca8k-common.c | 15 +++------------
3 files changed, 7 insertions(+), 26 deletions(-)
diff --git a/drivers/net/dsa/lantiq/lantiq_gswip_common.c b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
index 6150dc3ffb641..20ed487f37ca2 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip_common.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
@@ -1279,12 +1279,8 @@ static int gswip_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
/* Enable MLEN for ports with non-standard MTUs, including the special
* header on the CPU port added above.
*/
- if (new_mtu != ETH_DATA_LEN)
- regmap_set_bits(priv->gswip, GSWIP_MAC_CTRL_2p(port),
- GSWIP_MAC_CTRL_2_MLEN);
- else
- regmap_clear_bits(priv->gswip, GSWIP_MAC_CTRL_2p(port),
- GSWIP_MAC_CTRL_2_MLEN);
+ regmap_assign_bits(priv->gswip, GSWIP_MAC_CTRL_2p(port),
+ GSWIP_MAC_CTRL_2_MLEN, new_mtu != ETH_DATA_LEN);
return 0;
}
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 14692497e1a61..834263c9b0b5a 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2150,10 +2150,7 @@ mt7530_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
struct mt7530_priv *priv = gpiochip_get_data(gc);
u32 bit = mt7530_gpio_to_bit(offset);
- if (value)
- regmap_set_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit);
- else
- regmap_clear_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit);
+ regmap_assign_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit, value);
return 0;
}
@@ -2191,10 +2188,7 @@ mt7530_gpio_direction_output(struct gpio_chip *gc, unsigned int offset, int valu
regmap_set_bits(priv->regmap, MT7530_LED_GPIO_DIR, bit);
- if (value)
- regmap_set_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit);
- else
- regmap_clear_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit);
+ regmap_assign_bits(priv->regmap, MT7530_LED_GPIO_DATA, bit, value);
regmap_set_bits(priv->regmap, MT7530_LED_GPIO_OE, bit);
diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
index 13005f10edb7d..ab978cc8367f7 100644
--- a/drivers/net/dsa/qca/qca8k-common.c
+++ b/drivers/net/dsa/qca/qca8k-common.c
@@ -471,10 +471,7 @@ void qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable)
if (port > 0 && port < 6)
mask |= QCA8K_PORT_STATUS_LINK_AUTO;
- if (enable)
- regmap_set_bits(priv->regmap, QCA8K_REG_PORT_STATUS(port), mask);
- else
- regmap_clear_bits(priv->regmap, QCA8K_REG_PORT_STATUS(port), mask);
+ regmap_assign_bits(priv->regmap, QCA8K_REG_PORT_STATUS(port), mask, enable);
}
void qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset,
@@ -562,14 +559,8 @@ static int qca8k_port_configure_learning(struct dsa_switch *ds, int port,
{
struct qca8k_priv *priv = ds->priv;
- if (learning)
- return regmap_set_bits(priv->regmap,
- QCA8K_PORT_LOOKUP_CTRL(port),
- QCA8K_PORT_LOOKUP_LEARN);
- else
- return regmap_clear_bits(priv->regmap,
- QCA8K_PORT_LOOKUP_CTRL(port),
- QCA8K_PORT_LOOKUP_LEARN);
+ return regmap_assign_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port),
+ QCA8K_PORT_LOOKUP_LEARN, learning);
}
void qca8k_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
--
2.50.1
© 2016 - 2026 Red Hat, Inc.