netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next-2.6 PATCH] allow access to sysfs_groups member
@ 2009-11-13 10:51 Kurt Van Dijck
  2009-11-13 22:27 ` Stephen Hemminger
  0 siblings, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-13 10:51 UTC (permalink / raw)
  To: Stephen Hemminger, Oliver Hartkopp, Wolfgang Grandegger; +Cc: netdev

In a recent post, I asked for way to hold the uevent that adds a
net_device until a driver had added some extra sysfs files.

The use-case for such thing is a (PCMCIA) CAN card, that has 2 (CAN)
network chips. The driver could add a 'channel' sysfs file that
indicates the channel on the card, but this sysfs file is not present
yet when the uevent is generated.

This patch applied to a 2.6.30 kernel did allow to use non-standard
sysfs properties in udev rules (together with a match on device/driver).

I believe the above use-case is not limited to CAN, but any other
network type.

This patch allows adding sysfs attribute groups during netdevice registration.
The idea is that before the register_netdev call, several calls to
netdev_sysfs_add_group can be done.
The existing sysfs groups that are added in netdev_register_kobject use the
same function too.
I did not touch the number of possible groups (currently still 3).

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
---

 include/linux/netdevice.h |    2 ++
 net/core/net-sysfs.c      |   28 +++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8380009..9d16687 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1115,6 +1115,8 @@ extern int		dev_open(struct net_device *dev);
 extern int		dev_close(struct net_device *dev);
 extern void		dev_disable_lro(struct net_device *dev);
 extern int		dev_queue_xmit(struct sk_buff *skb);
+extern int		netdev_sysfs_add_group(struct net_device *net,
+				struct attribute_group *grp);
 extern int		register_netdevice(struct net_device *dev);
 extern void		unregister_netdevice(struct net_device *dev);
 extern void		free_netdev(struct net_device *dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 753c420..2938fdc 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -527,27 +527,45 @@ void netdev_unregister_kobject(struct net_device * net)
 	device_del(dev);
 }
 
+/* Add a sysfs group to the netdev groups */
+int netdev_sysfs_add_group(struct net_device *net,
+		struct attribute_group *grp)
+{
+	struct attribute_group **groups = net->sysfs_groups;
+	struct attribute_group **end;
+
+	/* end pointer, with room for null terminator */
+	end = &net->sysfs_groups[ARRAY_SIZE(net->sysfs_groups) - 1];
+	for (; groups < end; ++groups) {
+		if (!*groups) {
+			*groups = grp;
+			return 0;
+		}
+	}
+	return -ENOSPC;
+}
+EXPORT_SYMBOL(netdev_sysfs_add_group);
+
 /* Create sysfs entries for network device. */
 int netdev_register_kobject(struct net_device *net)
 {
 	struct device *dev = &(net->dev);
-	const struct attribute_group **groups = net->sysfs_groups;
 
 	dev->class = &net_class;
 	dev->platform_data = net;
-	dev->groups = groups;
+	dev->groups = net->sysfs_groups;
 
 	dev_set_name(dev, "%s", net->name);
 
 #ifdef CONFIG_SYSFS
-	*groups++ = &netstat_group;
+	netdev_sysfs_add_group(net, &netstat_group);
 
 #ifdef CONFIG_WIRELESS_EXT_SYSFS
 	if (net->ieee80211_ptr)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #ifdef CONFIG_WIRELESS_EXT
 	else if (net->wireless_handlers)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #endif
 #endif
 #endif /* CONFIG_SYSFS */

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

* Re: [net-next-2.6 PATCH] allow access to sysfs_groups member
  2009-11-13 10:51 [net-next-2.6 PATCH] allow access to sysfs_groups member Kurt Van Dijck
@ 2009-11-13 22:27 ` Stephen Hemminger
  2009-11-14 16:54   ` [net-next-2.6 PATCH v2] " Kurt Van Dijck
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Hemminger @ 2009-11-13 22:27 UTC (permalink / raw)
  To: Kurt Van Dijck; +Cc: Oliver Hartkopp, Wolfgang Grandegger, netdev

On Fri, 13 Nov 2009 11:51:57 +0100
Kurt Van Dijck <kurt.van.dijck@eia.be> wrote:

> +/* Add a sysfs group to the netdev groups */
> +int netdev_sysfs_add_group(struct net_device *net,
> +		struct attribute_group *grp)
> +{
> +	struct attribute_group **groups = net->sysfs_groups;
> +	struct attribute_group **end;
> +
> +	/* end pointer, with room for null terminator */
> +	end = &net->sysfs_groups[ARRAY_SIZE(net->sysfs_groups) - 1];
> +	for (; groups < end; ++groups) {
> +		if (!*groups) {
> +			*groups = grp;
> +			return 0;
> +		}
> +	}
> +	return -ENOSPC;
> +}
> +EXPORT_SYMBOL(netdev_sysfs_add_group);

EXPORT_SYMBOL_GPL() for all device/sysfs related stuff.

Also, need some way to BUG() if this is done after device has
been registered.  

Another way to add sub-directories which is what bridge, bonding,
and others do is to use another kobject. I think this is what you
want for the case of two CAN objects under one netdevice.

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

* [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-13 22:27 ` Stephen Hemminger
@ 2009-11-14 16:54   ` Kurt Van Dijck
  2009-11-16 16:46     ` Stephen Hemminger
  0 siblings, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-14 16:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Oliver Hartkopp, Wolfgang Grandegger, netdev

On Fri, Nov 13, 2009 at 02:27:38PM -0800, Stephen Hemminger wrote:
> On Fri, 13 Nov 2009 11:51:57 +0100
> Kurt Van Dijck <kurt.van.dijck@eia.be> wrote:
[...]
> EXPORT_SYMBOL_GPL() for all device/sysfs related stuff.
Ok, no problem
> 
> Also, need some way to BUG() if this is done after device has
> been registered.  
Ok. I gave it a try. I _think_ I did it write, but a second look would
not harm :-). I was not able to run a real test yet.
> 
> Another way to add sub-directories which is what bridge, bonding,
> and others do is to use another kobject. I think this is what you
> want for the case of two CAN objects under one netdevice.
In fact, I wanted to add this for cards that have multiple seperate CAN
network device, combined on 1 PCI or PCMCIA device.
In the 'add network' uevent, a udev rule could find properties of the
card (device/ symlink). Right now, there is no way to tell if a network
device is bus 1 or 2 on the card. in CAN, there's no such thing as a MAC
address.
I encountered this issue with a softing CAN card (not yet in mainline),
and there are other drivers in the socketCAN queue that have the same
problem.

The ethernet cards with multiple busses (that I've seen yet :-) )
combine multiple PCI devices on 1 card, and identification of the
'instance on the card' can happen with the sysfs properties delivered by
the PCI bus.
CAN devices with multiple busses typically are combined all together on
1 single device on the PCI or PCMCIA bus.

So, I wanted to add a 'channel' property in /sys/class/net/canX, which
could indicate the instance on the device. Such property must be
installed by the driver, not the bus the device is on.
This patch allows me to have this channel property present at the moment
of the uevent.

I can imagine other subsystems may benefit from this too.

Regards,
Kurt Van Dijck
---

This patch allows adding sysfs attribute groups during netdevice registration.
The idea is that before the register_netdev call, several calls to
netdev_sysfs_add_group can be done.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
---
 include/linux/netdevice.h |    2 ++
 net/core/net-sysfs.c      |   29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8380009..ebfc789 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1115,6 +1115,8 @@ extern int		dev_open(struct net_device *dev);
 extern int		dev_close(struct net_device *dev);
 extern void		dev_disable_lro(struct net_device *dev);
 extern int		dev_queue_xmit(struct sk_buff *skb);
+extern int		netdev_sysfs_add_group(struct net_device *net,
+				const struct attribute_group *grp);
 extern int		register_netdevice(struct net_device *dev);
 extern void		unregister_netdevice(struct net_device *dev);
 extern void		free_netdev(struct net_device *dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 753c420..6451e9a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -527,27 +527,46 @@ void netdev_unregister_kobject(struct net_device * net)
 	device_del(dev);
 }
 
+/* Add a sysfs group to the netdev groups */
+int netdev_sysfs_add_group(struct net_device *net,
+		const struct attribute_group *grp)
+{
+	struct attribute_group **groups = net->sysfs_groups;
+	struct attribute_group **end;
+
+	BUG_ON(net->reg_state >= NETREG_REGISTERED);
+	/* end pointer, with room for null terminator */
+	end = &net->sysfs_groups[ARRAY_SIZE(net->sysfs_groups) - 1];
+	for (; groups < end; ++groups) {
+		if (!*groups) {
+			*groups = grp;
+			return 0;
+		}
+	}
+	return -ENOSPC;
+}
+EXPORT_SYMBOL_GPL(netdev_sysfs_add_group);
+
 /* Create sysfs entries for network device. */
 int netdev_register_kobject(struct net_device *net)
 {
 	struct device *dev = &(net->dev);
-	const struct attribute_group **groups = net->sysfs_groups;
 
 	dev->class = &net_class;
 	dev->platform_data = net;
-	dev->groups = groups;
+	dev->groups = net->sysfs_groups;
 
 	dev_set_name(dev, "%s", net->name);
 
 #ifdef CONFIG_SYSFS
-	*groups++ = &netstat_group;
+	netdev_sysfs_add_group(net, &netstat_group);
 
 #ifdef CONFIG_WIRELESS_EXT_SYSFS
 	if (net->ieee80211_ptr)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #ifdef CONFIG_WIRELESS_EXT
 	else if (net->wireless_handlers)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #endif
 #endif
 #endif /* CONFIG_SYSFS */

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-14 16:54   ` [net-next-2.6 PATCH v2] " Kurt Van Dijck
@ 2009-11-16 16:46     ` Stephen Hemminger
  2009-11-17 16:21       ` Kurt Van Dijck
  2009-11-18 15:43       ` Kurt Van Dijck
  0 siblings, 2 replies; 17+ messages in thread
From: Stephen Hemminger @ 2009-11-16 16:46 UTC (permalink / raw)
  To: Kurt Van Dijck; +Cc: Oliver Hartkopp, Wolfgang Grandegger, netdev

On Sat, 14 Nov 2009 17:54:09 +0100
Kurt Van Dijck <kurt.van.dijck@eia.be> wrote:

> On Fri, Nov 13, 2009 at 02:27:38PM -0800, Stephen Hemminger wrote:
> > On Fri, 13 Nov 2009 11:51:57 +0100
> > Kurt Van Dijck <kurt.van.dijck@eia.be> wrote:
> [...]
> > EXPORT_SYMBOL_GPL() for all device/sysfs related stuff.
> Ok, no problem
> > 
> > Also, need some way to BUG() if this is done after device has
> > been registered.  
> Ok. I gave it a try. I _think_ I did it write, but a second look would
> not harm :-). I was not able to run a real test yet.
> > 
> > Another way to add sub-directories which is what bridge, bonding,
> > and others do is to use another kobject. I think this is what you
> > want for the case of two CAN objects under one netdevice.
> In fact, I wanted to add this for cards that have multiple seperate CAN
> network device, combined on 1 PCI or PCMCIA device.
> In the 'add network' uevent, a udev rule could find properties of the
> card (device/ symlink). Right now, there is no way to tell if a network
> device is bus 1 or 2 on the card. in CAN, there's no such thing as a MAC
> address.
> I encountered this issue with a softing CAN card (not yet in mainline),
> and there are other drivers in the socketCAN queue that have the same
> problem.
> 
> The ethernet cards with multiple busses (that I've seen yet :-) )
> combine multiple PCI devices on 1 card, and identification of the
> 'instance on the card' can happen with the sysfs properties delivered by
> the PCI bus.
> CAN devices with multiple busses typically are combined all together on
> 1 single device on the PCI or PCMCIA bus.
> 
> So, I wanted to add a 'channel' property in /sys/class/net/canX, which
> could indicate the instance on the device. Such property must be
> installed by the driver, not the bus the device is on.
> This patch allows me to have this channel property present at the moment
> of the uevent.
> 
> I can imagine other subsystems may benefit from this too.

Okay by me.

Acked-by: Stephen Hemminger <shemminger@vyatta.com>


-- 

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-16 16:46     ` Stephen Hemminger
@ 2009-11-17 16:21       ` Kurt Van Dijck
  2009-11-18 15:43       ` Kurt Van Dijck
  1 sibling, 0 replies; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-17 16:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Mon, Nov 16, 2009 at 08:46:12AM -0800, Stephen Hemminger wrote:
> 
[...]
> 

Stephen,
Thanks for your review.

Kurt

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-16 16:46     ` Stephen Hemminger
  2009-11-17 16:21       ` Kurt Van Dijck
@ 2009-11-18 15:43       ` Kurt Van Dijck
  2009-11-18 16:08         ` David Miller
  1 sibling, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-18 15:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, David Miller

On Mon, Nov 16, 2009 at 08:46:12AM -0800, Stephen Hemminger wrote:
> 
> Okay by me.
> 
Sorry for asking.
I'm not very experienced yet with git etc.
Is there anything I'm supposed to do/deliver to get the patch committed?

kind regards,
Kurt


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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 15:43       ` Kurt Van Dijck
@ 2009-11-18 16:08         ` David Miller
  2009-11-18 16:41           ` Kurt Van Dijck
  0 siblings, 1 reply; 17+ messages in thread
From: David Miller @ 2009-11-18 16:08 UTC (permalink / raw)
  To: kurt.van.dijck; +Cc: shemminger, netdev

From: Kurt Van Dijck <kurt.van.dijck@eia.be>
Date: Wed, 18 Nov 2009 16:43:13 +0100

> Is there anything I'm supposed to do/deliver to get the patch committed?

Please just resubmit it fully with full changelog and signoffs.

Thanks.

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 16:08         ` David Miller
@ 2009-11-18 16:41           ` Kurt Van Dijck
  2009-11-18 17:57             ` David Miller
  0 siblings, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-18 16:41 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, netdev

This patch allows adding sysfs attribute groups during netdevice registration.
The idea is that before the register_netdev call, several calls to
netdev_sysfs_add_group can be done. These attributes are accessible (by
udev) during the uevent.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
---
 include/linux/netdevice.h |    2 ++
 net/core/net-sysfs.c      |   29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8380009..ebfc789 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1115,6 +1115,8 @@ extern int                dev_open(struct net_device *dev);
 extern int             dev_close(struct net_device *dev);
 extern void            dev_disable_lro(struct net_device *dev);
 extern int             dev_queue_xmit(struct sk_buff *skb);
+extern int             netdev_sysfs_add_group(struct net_device *net,
+                               const struct attribute_group *grp);
 extern int             register_netdevice(struct net_device *dev);
 extern void            unregister_netdevice(struct net_device *dev);
 extern void            free_netdev(struct net_device *dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 753c420..6451e9a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -527,27 +527,46 @@ void netdev_unregister_kobject(struct net_device * net)
        device_del(dev);
 }

+/* Add a sysfs group to the netdev groups */
+int netdev_sysfs_add_group(struct net_device *net,
+               const struct attribute_group *grp)
+{
+       struct attribute_group **groups = net->sysfs_groups;
+       struct attribute_group **end;
+
+       BUG_ON(net->reg_state >= NETREG_REGISTERED);
+       /* end pointer, with room for null terminator */
+       end = &net->sysfs_groups[ARRAY_SIZE(net->sysfs_groups) - 1];
+       for (; groups < end; ++groups) {
+               if (!*groups) {
+                       *groups = grp;
+                       return 0;
+               }
+       }
+       return -ENOSPC;
+}
+EXPORT_SYMBOL_GPL(netdev_sysfs_add_group);
+
 /* Create sysfs entries for network device. */
 int netdev_register_kobject(struct net_device *net)
 {
        struct device *dev = &(net->dev);
-       const struct attribute_group **groups = net->sysfs_groups;

        dev->class = &net_class;
        dev->platform_data = net;
-       dev->groups = groups;
+       dev->groups = net->sysfs_groups;

        dev_set_name(dev, "%s", net->name);

 #ifdef CONFIG_SYSFS
-       *groups++ = &netstat_group;
+       netdev_sysfs_add_group(net, &netstat_group);

 #ifdef CONFIG_WIRELESS_EXT_SYSFS
        if (net->ieee80211_ptr)
-               *groups++ = &wireless_group;
+               netdev_sysfs_add_group(net, &wireless_group);
 #ifdef CONFIG_WIRELESS_EXT
        else if (net->wireless_handlers)
-               *groups++ = &wireless_group;
+               netdev_sysfs_add_group(net, &wireless_group);
 #endif
 #endif
 #endif /* CONFIG_SYSFS */


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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 16:41           ` Kurt Van Dijck
@ 2009-11-18 17:57             ` David Miller
  2009-11-18 20:57               ` Kurt Van Dijck
  2009-11-18 20:59               ` Kurt Van Dijck
  0 siblings, 2 replies; 17+ messages in thread
From: David Miller @ 2009-11-18 17:57 UTC (permalink / raw)
  To: kurt.van.dijck; +Cc: shemminger, netdev

From: Kurt Van Dijck <kurt.van.dijck@eia.be>
Date: Wed, 18 Nov 2009 17:41:26 +0100

> This patch allows adding sysfs attribute groups during netdevice registration.
> The idea is that before the register_netdev call, several calls to
> netdev_sysfs_add_group can be done. These attributes are accessible (by
> udev) during the uevent.
> 
> Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
> Acked-by: Stephen Hemminger <shemminger@vyatta.com>

Patch is corrupted by your email client.  Tab characters have
been turned into spaces, etc.

Please fix this up and resubmit.

Thanks.

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 17:57             ` David Miller
@ 2009-11-18 20:57               ` Kurt Van Dijck
  2009-11-18 20:59               ` Kurt Van Dijck
  1 sibling, 0 replies; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-18 20:57 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, netdev

On Wed, Nov 18, 2009 at 09:57:16AM -0800, David Miller wrote:
> > This patch allows adding sysfs attribute groups during netdevice registration.
> > The idea is that before the register_netdev call, several calls to
> > netdev_sysfs_add_group can be done. These attributes are accessible (by
> > udev) during the uevent.
> > 
> > Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
> > Acked-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> Patch is corrupted by your email client.  Tab characters have
> been turned into spaces, etc.
Oops. My fault. I did an copy in X ...
Sorry for that.
> 
> Please fix this up and resubmit.
> 
> Thanks.

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 17:57             ` David Miller
  2009-11-18 20:57               ` Kurt Van Dijck
@ 2009-11-18 20:59               ` Kurt Van Dijck
  2009-11-18 21:08                 ` David Miller
  1 sibling, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-18 20:59 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, netdev

This patch allows adding sysfs attribute groups during netdevice registration.
The idea is that before the register_netdev call, several calls to
netdev_sysfs_add_group can be done. These attributes are accessible (by
udev) during the uevent.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
---
 include/linux/netdevice.h |    2 ++
 net/core/net-sysfs.c      |   29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8380009..ebfc789 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1115,6 +1115,8 @@ extern int		dev_open(struct net_device *dev);
 extern int		dev_close(struct net_device *dev);
 extern void		dev_disable_lro(struct net_device *dev);
 extern int		dev_queue_xmit(struct sk_buff *skb);
+extern int		netdev_sysfs_add_group(struct net_device *net,
+				const struct attribute_group *grp);
 extern int		register_netdevice(struct net_device *dev);
 extern void		unregister_netdevice(struct net_device *dev);
 extern void		free_netdev(struct net_device *dev);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 753c420..6451e9a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -527,27 +527,46 @@ void netdev_unregister_kobject(struct net_device * net)
 	device_del(dev);
 }
 
+/* Add a sysfs group to the netdev groups */
+int netdev_sysfs_add_group(struct net_device *net,
+		const struct attribute_group *grp)
+{
+	struct attribute_group **groups = net->sysfs_groups;
+	struct attribute_group **end;
+
+	BUG_ON(net->reg_state >= NETREG_REGISTERED);
+	/* end pointer, with room for null terminator */
+	end = &net->sysfs_groups[ARRAY_SIZE(net->sysfs_groups) - 1];
+	for (; groups < end; ++groups) {
+		if (!*groups) {
+			*groups = grp;
+			return 0;
+		}
+	}
+	return -ENOSPC;
+}
+EXPORT_SYMBOL_GPL(netdev_sysfs_add_group);
+
 /* Create sysfs entries for network device. */
 int netdev_register_kobject(struct net_device *net)
 {
 	struct device *dev = &(net->dev);
-	const struct attribute_group **groups = net->sysfs_groups;
 
 	dev->class = &net_class;
 	dev->platform_data = net;
-	dev->groups = groups;
+	dev->groups = net->sysfs_groups;
 
 	dev_set_name(dev, "%s", net->name);
 
 #ifdef CONFIG_SYSFS
-	*groups++ = &netstat_group;
+	netdev_sysfs_add_group(net, &netstat_group);
 
 #ifdef CONFIG_WIRELESS_EXT_SYSFS
 	if (net->ieee80211_ptr)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #ifdef CONFIG_WIRELESS_EXT
 	else if (net->wireless_handlers)
-		*groups++ = &wireless_group;
+		netdev_sysfs_add_group(net, &wireless_group);
 #endif
 #endif
 #endif /* CONFIG_SYSFS */

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 20:59               ` Kurt Van Dijck
@ 2009-11-18 21:08                 ` David Miller
  2009-11-18 21:42                   ` Kurt Van Dijck
  0 siblings, 1 reply; 17+ messages in thread
From: David Miller @ 2009-11-18 21:08 UTC (permalink / raw)
  To: kurt.van.dijck; +Cc: shemminger, netdev

From: Kurt Van Dijck <kurt.van.dijck@eia.be>
Date: Wed, 18 Nov 2009 21:59:52 +0100

> This patch allows adding sysfs attribute groups during netdevice registration.
> The idea is that before the register_netdev call, several calls to
> netdev_sysfs_add_group can be done. These attributes are accessible (by
> udev) during the uevent.
> 
> Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
> Acked-by: Stephen Hemminger <shemminger@vyatta.com>

Unfortunately, the code in this function is much different
in net-next-2.6 which is where I want to add this, and your
patch doesn't apply.

Please rebase your patch on that tree, thank you.

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 21:08                 ` David Miller
@ 2009-11-18 21:42                   ` Kurt Van Dijck
  2009-11-20  1:11                     ` Eric W. Biederman
  0 siblings, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-18 21:42 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On Wed, Nov 18, 2009 at 01:08:59PM -0800, David Miller wrote:
>
> Unfortunately, the code in this function is much different
> in net-next-2.6 which is where I want to add this, and your
> patch doesn't apply.
> 
> Please rebase your patch on that tree, thank you.
As I mentioned, I'm not experienced with using git yet.
Is there a fine manual I can inspect? I get lost in the man-pages.

Sorry for generating so much noise.
Kurt

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-18 21:42                   ` Kurt Van Dijck
@ 2009-11-20  1:11                     ` Eric W. Biederman
  2009-11-20 10:21                       ` Kurt Van Dijck
  0 siblings, 1 reply; 17+ messages in thread
From: Eric W. Biederman @ 2009-11-20  1:11 UTC (permalink / raw)
  To: Kurt Van Dijck; +Cc: David Miller, netdev

Kurt Van Dijck <kurt.van.dijck@eia.be> writes:

> On Wed, Nov 18, 2009 at 01:08:59PM -0800, David Miller wrote:
>>
>> Unfortunately, the code in this function is much different
>> in net-next-2.6 which is where I want to add this, and your
>> patch doesn't apply.
>> 
>> Please rebase your patch on that tree, thank you.
> As I mentioned, I'm not experienced with using git yet.
> Is there a fine manual I can inspect? I get lost in the man-pages.

git clone git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git

Should get you started.

In this case please look at how I modified the bonding driver to do
what you are trying to do.  That is the conflict in net-next and
I think it was actually less code.

The other very useful command is: git log -u some/path/

Git has fine manual pages and git command --help works for the builtin
git commands.

Eric

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-20  1:11                     ` Eric W. Biederman
@ 2009-11-20 10:21                       ` Kurt Van Dijck
  2009-11-20 16:32                         ` Eric W. Biederman
  0 siblings, 1 reply; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-20 10:21 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: David Miller, netdev

On Thu, Nov 19, 2009 at 05:11:45PM -0800, Eric W. Biederman wrote:
> Kurt Van Dijck <kurt.van.dijck@eia.be> writes:
> 
> > On Wed, Nov 18, 2009 at 01:08:59PM -0800, David Miller wrote:
> >>
> >> Unfortunately, the code in this function is much different
> >> in net-next-2.6 which is where I want to add this, and your
> >> patch doesn't apply.
> >> 
> >> Please rebase your patch on that tree, thank you.
> > As I mentioned, I'm not experienced with using git yet.
> > Is there a fine manual I can inspect? I get lost in the man-pages.
> 
> git clone git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
> 
> Should get you started.
$ git pull git://git.kernel.... master
did the job today. It took me a while
> 
> In this case please look at how I modified the bonding driver to do
> what you are trying to do.  That is the conflict in net-next and
> I think it was actually less code.
It _is_ less code (does a little less too :-) ).
It solves the problem anyway. I'll stop with my patch.

Thanks.
Kurt

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-20 10:21                       ` Kurt Van Dijck
@ 2009-11-20 16:32                         ` Eric W. Biederman
  2009-11-21 11:47                           ` Kurt Van Dijck
  0 siblings, 1 reply; 17+ messages in thread
From: Eric W. Biederman @ 2009-11-20 16:32 UTC (permalink / raw)
  To: Kurt Van Dijck; +Cc: David Miller, netdev

Kurt Van Dijck <kurt.van.dijck@eia.be> writes:

> On Thu, Nov 19, 2009 at 05:11:45PM -0800, Eric W. Biederman wrote:
>> Kurt Van Dijck <kurt.van.dijck@eia.be> writes:
>> 
>> > On Wed, Nov 18, 2009 at 01:08:59PM -0800, David Miller wrote:
>> >>
>> >> Unfortunately, the code in this function is much different
>> >> in net-next-2.6 which is where I want to add this, and your
>> >> patch doesn't apply.
>> >> 
>> >> Please rebase your patch on that tree, thank you.
>> > As I mentioned, I'm not experienced with using git yet.
>> > Is there a fine manual I can inspect? I get lost in the man-pages.
>> 
>> git clone git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
>> 
>> Should get you started.
> $ git pull git://git.kernel.... master
> did the job today. It took me a while

An incremental  pull typically much faster than the initial one.

>> In this case please look at how I modified the bonding driver to do
>> what you are trying to do.  That is the conflict in net-next and
>> I think it was actually less code.

> It _is_ less code (does a little less too :-) ).
> It solves the problem anyway. I'll stop with my patch.

You were just worried about CAN devices and not all network devices
correct?

Eric

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

* Re: [net-next-2.6 PATCH v2] allow access to sysfs_groups member
  2009-11-20 16:32                         ` Eric W. Biederman
@ 2009-11-21 11:47                           ` Kurt Van Dijck
  0 siblings, 0 replies; 17+ messages in thread
From: Kurt Van Dijck @ 2009-11-21 11:47 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: David Miller, netdev

On Fri, Nov 20, 2009 at 08:32:48AM -0800, Eric W. Biederman wrote:
> 
> Kurt Van Dijck <kurt.van.dijck@eia.be> writes:
> 
> >> In this case please look at how I modified the bonding driver to do
> >> what you are trying to do.  That is the conflict in net-next and
> >> I think it was actually less code.
> 
> > It _is_ less code (does a little less too :-) ).
> > It solves the problem anyway. I'll stop with my patch.
> 
> You were just worried about CAN devices and not all network devices
> correct?
Yes, but even not _every_ CAN device. It's driver dependant issue.
> 
> Eric
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2009-11-21 11:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-13 10:51 [net-next-2.6 PATCH] allow access to sysfs_groups member Kurt Van Dijck
2009-11-13 22:27 ` Stephen Hemminger
2009-11-14 16:54   ` [net-next-2.6 PATCH v2] " Kurt Van Dijck
2009-11-16 16:46     ` Stephen Hemminger
2009-11-17 16:21       ` Kurt Van Dijck
2009-11-18 15:43       ` Kurt Van Dijck
2009-11-18 16:08         ` David Miller
2009-11-18 16:41           ` Kurt Van Dijck
2009-11-18 17:57             ` David Miller
2009-11-18 20:57               ` Kurt Van Dijck
2009-11-18 20:59               ` Kurt Van Dijck
2009-11-18 21:08                 ` David Miller
2009-11-18 21:42                   ` Kurt Van Dijck
2009-11-20  1:11                     ` Eric W. Biederman
2009-11-20 10:21                       ` Kurt Van Dijck
2009-11-20 16:32                         ` Eric W. Biederman
2009-11-21 11:47                           ` Kurt Van Dijck

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