net: usb: lan78xx: make struct fphy_status static const
Subsystems (5)
PATCH v2 1/1 net: usb: lan78xx: make struct fphy_status static const
Constify variable fphy_status and make it static.
---
v2:
- extend commit message
--- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/lan78xx.c +1 -1
@@ -2630,7 +2630,7 @@ static int lan78xx_configure_flowcontrol(struct lan78xx_net *dev,*/ static struct phy_device *lan78xx_register_fixed_phy (struct lan78xx_net *dev) { -struct fixed_phy_status fphy_status = { +static const struct fixed_phy_status fphy_status = { .link =1 , .speed =SPEED_1000 , .duplex =DUPLEX_FULL ,
Signature · 1 line
2.49.0
[email protected]
maintainerHi Heiner,
Thanks for the patch
Quoted 26 lines · Heiner Kallweit
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Constify variable
fphy_statusand make it static.Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- extend commit message--- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/usb/lan78xx.c +1
-1@@ -2630,7 +2630,7 @@ static int lan78xx_configure_flowcontrol(structlan78xx_net *dev, */ static struct phy_device *lan78xx_register_fixed_phy (struct lan78xx_net *dev) { -struct fixed_phy_status fphy_status = { +static const struct fixed_phy_status fphy_status = { .link =1 ,
Quoted 5 lines
.speed =
SPEED_1000,
.duplex =DUPLEX_FULL,
--
2.49.0
This patch changes fphy_status to static const, but as far as I can tell,the function is only called once during probe, and the struct is initialized and used immediately. Since it's not reused and doesn't
need to persist beyond the function call, I don't see a clear reason
for making it static const. Is there a specific motivation behind this
change?
Thanks,
Thangaraj Samynathan
Quoted 32 lines · On 11.06.2025 09:02, [email protected] wrote:
Hi Heiner,
Thanks for the patchQuoted 29 lines · Heiner Kallweit
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Constify variable
fphy_statusand make it static.Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- extend commit message--- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/usb/lan78xx.c +1
-1@@ -2630,7 +2630,7 @@ static int lan78xx_configure_flowcontrol(structlan78xx_net *dev, */ static struct phy_device *lan78xx_register_fixed_phy (struct lan78xx_net *dev) { -struct fixed_phy_status fphy_status = { +static const struct fixed_phy_status fphy_status = { .link =1 ,.speed =
SPEED_1000,
.duplex =DUPLEX_FULL,
--
Quoted 9 lines
Quoted 2 lines
2.49.0
This patch changes
fphy_statusto static const, but as far as I can tell,the function is only called once during probe, and the struct is initialized and used immediately. Since it's not reused and doesn't
need to persist beyond the function call, I don't see a clear reason
for making it static const. Is there a specific motivation behind this
change?
From a compiler perspective there's not much of a difference, also as of today the compiler uses a pre-filled struct instead of creating it dynamically. At least that's the case for me with gcc 15.1.1. Just that with the change the prefilled struct is properly placed in the rodata segment.
Main reason is to make clear to the reader, and to the compiler, that this is immutable configuration data. Not different from e.g. regmap users, where typically a static const struct regmap_config is used for initialization.
Quoted 2 lines
Thanks,
Thangaraj Samynathan
Heiner
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 8 lines · On Tue, 10 Jun 2025 22:58:15 +0200 you wrote:
Constify variable
fphy_statusand make it static.Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- extend commit message[...]
Here is the summary with links:
- [v2,net-next] net: usb: lan78xx: make struct fphy_status static const
https://git.kernel.org/netdev/net-next/c/ae4e3334dd05
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html