netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const
@ 2025-06-10 20:58 Heiner Kallweit
  2025-06-11  7:02 ` Thangaraj.S
  2025-06-11 21:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Heiner Kallweit @ 2025-06-10 20:58 UTC (permalink / raw)
  To: Thangaraj Samynathan, Rengarajan Sundararajan,
	Microchip Linux Driver Support, Andrew Lunn, Paolo Abeni,
	Eric Dumazet, Jakub Kicinski, David Miller
  Cc: netdev@vger.kernel.org, Linux USB Mailing List

Constify variable fphy_status and make it static.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- extend commit message
---
 drivers/net/usb/lan78xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 759dab980..17c23eada 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -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,
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const
  2025-06-10 20:58 [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const Heiner Kallweit
@ 2025-06-11  7:02 ` Thangaraj.S
  2025-06-11 19:16   ` Heiner Kallweit
  2025-06-11 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Thangaraj.S @ 2025-06-11  7:02 UTC (permalink / raw)
  To: andrew+netdev, davem, hkallweit1, Rengarajan.S, kuba, pabeni,
	edumazet, UNGLinuxDriver
  Cc: linux-usb, netdev

Hi Heiner,
Thanks for the patch
On Tue, 2025-06-10 at 22:58 +0200, Heiner Kallweit wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> Constify variable fphy_status and make it static.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> v2:
> - extend commit message
> ---
>  drivers/net/usb/lan78xx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 759dab980..17c23eada 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -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,
> --
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const
  2025-06-11  7:02 ` Thangaraj.S
@ 2025-06-11 19:16   ` Heiner Kallweit
  0 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2025-06-11 19:16 UTC (permalink / raw)
  To: Thangaraj.S, andrew+netdev, davem, Rengarajan.S, kuba, pabeni,
	edumazet, UNGLinuxDriver
  Cc: linux-usb, netdev

On 11.06.2025 09:02, Thangaraj.S@microchip.com wrote:
> Hi Heiner,
> Thanks for the patch
> On Tue, 2025-06-10 at 22:58 +0200, Heiner Kallweit wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you
>> know the content is safe
>>
>> Constify variable fphy_status and make it static.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> v2:
>> - extend commit message
>> ---
>>  drivers/net/usb/lan78xx.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
>> index 759dab980..17c23eada 100644
>> --- a/drivers/net/usb/lan78xx.c
>> +++ b/drivers/net/usb/lan78xx.c
>> @@ -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,
>> --
>> 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?
> 
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.

> Thanks,
> Thangaraj Samynathan

Heiner

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const
  2025-06-10 20:58 [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const Heiner Kallweit
  2025-06-11  7:02 ` Thangaraj.S
@ 2025-06-11 21:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-11 21:30 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Thangaraj.S, Rengarajan.S, UNGLinuxDriver, andrew+netdev, pabeni,
	edumazet, kuba, davem, netdev, linux-usb

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 10 Jun 2025 22:58:15 +0200 you wrote:
> Constify variable fphy_status and make it static.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> 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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-11 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 20:58 [PATCH v2 net-next] net: usb: lan78xx: make struct fphy_status static const Heiner Kallweit
2025-06-11  7:02 ` Thangaraj.S
2025-06-11 19:16   ` Heiner Kallweit
2025-06-11 21:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).