Re: [PATCH net-next] net: dsa: mt7530: Constify struct regmap_config

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 13, 2025 at 05:09:24PM +0200, Christophe JAILLET wrote:
> '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 <christophe.jaillet@xxxxxxxxxx>
> ---
>  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,
> +};
> +
> ...

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




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux