net: dsa: use regmap_assign_bits() for conditional set/clear

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>
Link: https://patch.msgid.link/20260924083538.461887-1-peng.fan@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Peng Fan 2026-09-24 16:35:37 +08:00 committed by Jakub Kicinski
parent 883c308be4
commit 679950fede
3 changed files with 7 additions and 26 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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)