From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Hauke Mehrtens <hauke@hauke-m.de>, Andrew Lunn <andrew@lunn.ch>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Chester A. Unal" <chester.a.unal@arinc9.com>,
Daniel Golle <daniel@makrotopia.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Christian Marangi <ansuelsmth@gmail.com>
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH] net: dsa: use regmap_assign_bits() for conditional set/clear
Date: Thu, 24 Sep 2026 16:35:37 +0800 [thread overview]
Message-ID: <20260924083538.461887-1-peng.fan@oss.nxp.com> (raw)
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
next reply other threads:[~2026-09-24 8:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 8:35 Peng Fan (OSS) [this message]
2026-09-30 0:10 ` [PATCH] net: dsa: use regmap_assign_bits() for conditional set/clear patchwork-bot+netdevbpf
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=20260924083538.461887-1-peng.fan@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=ansuelsmth@gmail.com \
--cc=chester.a.unal@arinc9.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hauke@hauke-m.de \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=peng.fan@nxp.com \
/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