diff mbox

[net-next-2.6,v2] allow access to sysfs_groups member

Message ID 20091118205952.GB282@e-circ.dyndns.org
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Kurt Van Dijck Nov. 18, 2009, 8:59 p.m. UTC
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(-)

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

Comments

David Miller Nov. 18, 2009, 9:08 p.m. UTC | #1
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.
--
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
Kurt Van Dijck Nov. 18, 2009, 9:42 p.m. UTC | #2
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
--
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
Eric W. Biederman Nov. 20, 2009, 1:11 a.m. UTC | #3
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
--
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
Kurt Van Dijck Nov. 20, 2009, 10:21 a.m. UTC | #4
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
--
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
Eric W. Biederman Nov. 20, 2009, 4:32 p.m. UTC | #5
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
--
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
Kurt Van Dijck Nov. 21, 2009, 11:47 a.m. UTC | #6
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
--
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
diff mbox

Patch

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 */