Re: [PATCH] net: sysfs: Fix weird usage of class's namespace relevant fields

From: Simon Horman
Date: Fri Sep 06 2024 - 06:24:13 EST


On Thu, Sep 05, 2024 at 07:35:38AM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>
> 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().
>
> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
> ---
> 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.

Reviewed-by: Simon Horman <horms@xxxxxxxxxx>

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] ...

See: https://docs.kernel.org/process/maintainer-netdev.html