net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)
Subsystems (2)
PATCH RESEND v2 1/1 net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)
phys_port_id_show, phys_port_name_show and phys_switch_id_show would return -EOPNOTSUPP if the netdev didn't implement the corresponding method.
There is no point in creating these files if they are unsupported.
Put these attributes in netdev_phys_group and implement the is_visible method. make phys_(port_id, port_name, switch_id) invisible if the netdev dosen't implement the corresponding method.
---
v2: Remove worthless comments.
v1: https://lore.kernel.org/all/[email protected]/
--- include/linux/netdevice.h | 2 +- net/core/net-sysfs.c | 59 +++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 25 deletions(-)
include/linux/netdevice.h +1 -1
@@ -2388,7 +2388,7 @@ struct net_device {struct dm_hw_stat_delta __rcu *dm_private;#endif struct device dev; -const struct attribute_group *sysfs_groups[4 ]; +const struct attribute_group *sysfs_groups[5 ];const struct attribute_group *sysfs_rx_queue_group;const struct rtnl_link_ops *rtnl_link_ops;
net/core/net-sysfs.c +35 -24
95 lines not on this page · raw message
Signature · 1 line
2.25.1
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 11 lines · On Thu, 12 Jun 2025 14:27:07 +0000 you wrote:
phys_port_id_show,phys_port_name_showandphys_switch_id_showwould return-EOPNOTSUPPif the netdev didn't implement the corresponding method.There is no point in creating these files if they are unsupported.
Put these attributes in
netdev_phys_groupand implement theis_visiblemethod. makephys_(port_id, port_name, switch_id)invisible if the netdev dosen't implement the corresponding method.[...]
Here is the summary with links:
- [RESEND,net-next,v2] net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)
https://git.kernel.org/netdev/net-next/c/0c17270f9b92
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html