net: sysfs: Fix weird usage of class's namespace relevant fields
Subsystems (2)
PATCH 1/1 net: sysfs: Fix weird usage of class's namespace relevant fields
From: Zijun Hu <[email protected]>
Device class has two namespace relevant fields which are associated by the following usage:
struct class {
...
const struct kobj_ns_type_operations *ns_type;
const void *(*namespace)(const struct device *dev);
...
}
if (dev->class && dev->class->ns_type)
dev->class->namespace(dev);The usage looks weird since it checks @ns_type but calls namespace() it is found for all existing class definitions that the other filed is also assigned once one is assigned in current kernel tree, so fix this weird usage by checking @namespace to call namespace().
---
driver-core tree has similar fix as shown below:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=a169a663bfa8198f33a5c1002634cc89e5128025
--- net/core/net-sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/net-sysfs.c +2 -2
@@ -1056,7 +1056,7 @@ static const void *rx_queue_namespace(const struct kobject *kobj)struct device *dev = &queue->dev->dev;const void *ns =NULL ; -if (dev->class && dev->class->ns_type) +if (dev->class && dev->class->namespace) ns = dev->class->namespace (dev);return ns;
@@ -1740,7 +1740,7 @@ static const void *netdev_queue_namespace(const struct kobject *kobj)struct device *dev = &queue->dev->dev;const void *ns =NULL ; -if (dev->class && dev->class->ns_type) +if (dev->class && dev->class->namespace) ns = dev->class->namespace (dev);return ns;
---
base-commit: 88fac17500f4ea49c7bac136cf1b27e7b9980075
change-id: 20240904-fix_class_ns-adf1ac05b6fc
Best regards,
Signature · 1 line
Zijun Hu <[email protected]>
Quoted 19 lines · Zijun Hu
From: Zijun Hu <[email protected]>
Device class has two namespace relevant fields which are associated by the following usage:
struct class { ... const struct kobj_ns_type_operations *ns_type; const void *(*namespace)(const struct device *dev); ... } if (dev->class && dev->class->ns_type) dev->class->namespace(dev);The usage looks weird since it checks @ns_type but calls
namespace()it is found for all existing class definitions that the other filed is also assigned once one is assigned in current kernel tree, so fix this weird usage by checking @namespace to callnamespace().
Quoted 4 lines
Signed-off-by Zijun Hu <[email protected]>---
driver-core tree has similar fix as shown below:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=a169a663bfa8198f33a5c1002634cc89e5128025
Thanks,
I agree that this change is consistent with the one at the link above. And that, given your explanation there and here, this change makes sense.
I don't think there is a need to repost because of this, but for future reference, please keep in mind that patches like this - non bug fixes for Networking code - should, in general, be targeted at net-next.
Subject: [PATCH net-next] ...
Quoted 33 lines · Simon Horman
Quoted 19 lines · Zijun Hu
From: Zijun Hu <[email protected]>
Device class has two namespace relevant fields which are associated by the following usage:
struct class { ... const struct kobj_ns_type_operations *ns_type; const void *(*namespace)(const struct device *dev); ... } if (dev->class && dev->class->ns_type) dev->class->namespace(dev);The usage looks weird since it checks @ns_type but calls
namespace()it is found for all existing class definitions that the other filed is also assigned once one is assigned in current kernel tree, so fix this weird usage by checking @namespace to callnamespace().Quoted 4 lines
Signed-off-by Zijun Hu <[email protected]>---
driver-core tree has similar fix as shown below:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=a169a663bfa8198f33a5c1002634cc89e5128025Thanks,
I agree that this change is consistent with the one at the link above. And that, given your explanation there and here, this change makes sense.
Reviewed-by Simon Horman <[email protected]>
Quoted 7 lines
I don't think there is a need to repost because of this, but for future reference, please keep in mind that patches like this - non bug fixes for Networking code - should, in general, be targeted at net-next.
Subject: [PATCH net-next] ...
thank you very much for such important reminder i will follow this guidance for further net patches. (^^)
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 14 lines · On Thu, 05 Sep 2024 07:35:38 +0800 you wrote:
From: Zijun Hu <[email protected]>
Device class has two namespace relevant fields which are associated by the following usage:
struct class { ... const struct kobj_ns_type_operations *ns_type; const void *(*namespace)(const struct device *dev); ... } if (dev->class && dev->class->ns_type) dev->class->namespace(dev);
Quoted 1 line
[...]
Here is the summary with links:
- net: sysfs: Fix weird usage of class's namespace relevant fields
https://git.kernel.org/netdev/net-next/c/8f088541991b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html