netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] simplify netdev_sysfs_xxx if SYSFS is not configured
@ 2004-05-28 18:03 Stephen Hemminger
  2004-05-29 19:42 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2004-05-28 18:03 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

Don't need all the network sysfs code if CONFIG_SYSFS is not enabled.
Also:
	* netdev_sysfs_unregister is declaration mismatch
	* if netdev_sysfs_register fails print a warning.
	  Need to still mark it as registered so the unregister_netdevice works,
	  but we will probably end up leaking memory in that case.

diff -Nru a/net/core/Makefile b/net/core/Makefile
--- a/net/core/Makefile	2004-05-28 10:09:11 -07:00
+++ b/net/core/Makefile	2004-05-28 10:09:11 -07:00
@@ -6,9 +6,10 @@
 
 obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
 
-obj-y		     += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \
+obj-y		     += flow.o dev.o ethtool.o dev_mcast.o dst.o \
 			neighbour.o rtnetlink.o utils.o link_watch.o filter.o
 
+obj-$(CONFIG_SYSFS) += net-sysfs.o
 obj-$(CONFIG_NETFILTER) += netfilter.o
 obj-$(CONFIG_NET_DIVERT) += dv.o
 obj-$(CONFIG_NET_PKTGEN) += pktgen.o
diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c	2004-05-28 10:09:11 -07:00
+++ b/net/core/dev.c	2004-05-28 10:09:11 -07:00
@@ -220,9 +220,15 @@
 int netdev_fastroute_obstacles;
 #endif
 
+#ifdef CONFIG_SYSFS
 extern int netdev_sysfs_init(void);
 extern int netdev_register_sysfs(struct net_device *);
-extern int netdev_unregister_sysfs(struct net_device *);
+extern void netdev_unregister_sysfs(struct net_device *);
+#else
+#define netdev_sysfs_init()	 	(0)
+#define netdev_register_sysfs(dev)	(0)
+#define	netdev_unregister_sysfs(dev)	do { } while(0)
+#endif
 
 
 /*******************************************************************************
@@ -2971,6 +2977,7 @@
 void netdev_run_todo(void)
 {
 	struct list_head list = LIST_HEAD_INIT(list);
+	int err;
 
 	/* Safe outside mutex since we only care about entries that
 	 * this cpu put into queue while under RTNL.
@@ -2993,7 +3000,10 @@
 
 		switch(dev->reg_state) {
 		case NETREG_REGISTERING:
-			netdev_register_sysfs(dev);
+			err = netdev_register_sysfs(dev);
+			if (err)
+				printk(KERN_ERR "%s: failed sysfs registration (%d)\n",
+				       dev->name, err);
 			dev->reg_state = NETREG_REGISTERED;
 			break;
 
@@ -3037,6 +3047,7 @@
  */
 void free_netdev(struct net_device *dev)
 {
+#ifdef CONFIG_SYSFS
 	/*  Compatiablity with error handling in drivers */
 	if (dev->reg_state == NETREG_UNINITIALIZED) {
 		kfree((char *)dev - dev->padded);
@@ -3048,6 +3059,9 @@
 
 	/* will free via class release */
 	class_device_put(&dev->class_dev);
+#else
+	kfree((char *)dev - dev->padded);
+#endif
 }
  
 /* Synchronize with packet receive processing. */

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

* Re: [PATCH] simplify netdev_sysfs_xxx if SYSFS is not configured
  2004-05-28 18:03 [PATCH] simplify netdev_sysfs_xxx if SYSFS is not configured Stephen Hemminger
@ 2004-05-29 19:42 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-05-29 19:42 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Fri, 28 May 2004 11:03:32 -0700
Stephen Hemminger <shemminger@osdl.org> wrote:

> Don't need all the network sysfs code if CONFIG_SYSFS is not enabled.
> Also:
> 	* netdev_sysfs_unregister is declaration mismatch
> 	* if netdev_sysfs_register fails print a warning.
> 	  Need to still mark it as registered so the unregister_netdevice works,
> 	  but we will probably end up leaking memory in that case.

Applied, thanks.

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

end of thread, other threads:[~2004-05-29 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-28 18:03 [PATCH] simplify netdev_sysfs_xxx if SYSFS is not configured Stephen Hemminger
2004-05-29 19:42 ` David S. Miller

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