net: dsa: use regmap_assign_bits() for conditional set/clear
Subsystems (7)
PATCH 1/1 net: dsa: use regmap_assign_bits() for conditional set/clear
From: Peng Fan <[email protected]>
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 <[email protected]>
--- 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(-)
drivers/net/dsa/lantiq/lantiq_gswip_common.c +2 -6
@@ -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 ; }
drivers/net/dsa/mt7530.c +2 -8
@@ -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 valuregmap_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);
drivers/net/dsa/qca/qca8k-common.c +3 -12
@@ -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)
Signature · 1 line
2.50.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 24 Sep 2026 16:35:37 +0800 you wrote:
From: Peng Fan <[email protected]>
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 <[email protected]>[...]
Here is the summary with links:
- net: dsa: use regmap_assign_bits() for conditional set/clear
https://git.kernel.org/netdev/net-next/c/679950fedec7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html