Re: [PATCH net-next] net: dsa: mt7530: Constify struct regmap_config
From: Daniel Golle <daniel@makrotopia.org>
Date: 2025-07-13 20:37:01
Also in:
kernel-janitors, linux-arm-kernel, linux-mediatek, lkml
On Sun, Jul 13, 2025 at 05:09:24PM +0200, Christophe JAILLET wrote:
quoted hunk ↗ jump to hunk
'struct regmap_config' are not modified in these drivers. They be statically defined instead of allocated and populated at run-time. The main benefits are: - it saves some memory at runtime - the structures can be declared as 'const', which is always better for structures that hold some function pointers - the code is less verbose Signed-off-by: Christophe JAILLET <redacted> --- drivers/net/dsa/mt7530-mdio.c | 21 +++++++++------------ drivers/net/dsa/mt7530-mmio.c | 21 ++++++++++----------- 2 files changed, 19 insertions(+), 23 deletions(-)diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c index 51df42ccdbe6..0286a6cecb6f 100644 --- a/drivers/net/dsa/mt7530-mdio.c +++ b/drivers/net/dsa/mt7530-mdio.c@@ -136,10 +136,17 @@ static const struct of_device_id mt7530_of_match[] = { }; MODULE_DEVICE_TABLE(of, mt7530_of_match); +static const struct regmap_config regmap_config = {
Maybe calling this one 'regmap_config_mdio'...
+ .reg_bits = 16, + .val_bits = 32, + .reg_stride = 4, + .max_register = MT7530_CREV, + .disable_locking = true, +}; + ...
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/dsa/mt7530-mmio.c b/drivers/net/dsa/mt7530-mmio.c index 842d74268e77..1dc8b93fb51a 100644 --- a/drivers/net/dsa/mt7530-mmio.c +++ b/drivers/net/dsa/mt7530-mmio.c@@ -18,10 +18,17 @@ static const struct of_device_id mt7988_of_match[] = { }; MODULE_DEVICE_TABLE(of, mt7988_of_match); +static const struct regmap_config sw_regmap_config = {
... and this one 'regmap_config_mmio' would be a bit nicer.
+ .name = "switch", + .reg_bits = 16, + .val_bits = 32, + .reg_stride = 4, + .max_register = MT7530_CREV, +}; +
Other than that: Reviewed-by: Daniel Golle <daniel@makrotopia.org>