From: Gerd Knorr Add sysfs support to the uml network driver. Also comment the eth_init function, I think that one is never ever needed as the devices are initialized when the underlying transport mechanism registeres. Signed-off-by: Gerd Knorr Signed-off-by: Andrew Morton --- 25-akpm/arch/um/drivers/net_kern.c | 24 ++++++++++++++++++++++-- 25-akpm/arch/um/include/net_kern.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff -puN arch/um/drivers/net_kern.c~uml-sysfs-support-for-uml-network-driver arch/um/drivers/net_kern.c --- 25/arch/um/drivers/net_kern.c~uml-sysfs-support-for-uml-network-driver Thu Dec 9 14:01:01 2004 +++ 25-akpm/arch/um/drivers/net_kern.c Thu Dec 9 14:01:01 2004 @@ -30,6 +30,8 @@ #include "irq_user.h" #include "irq_kern.h" +#define DRIVER_NAME "uml-netdev" + static spinlock_t opened_lock = SPIN_LOCK_UNLOCKED; LIST_HEAD(opened); @@ -246,7 +248,7 @@ static int uml_net_ioctl(struct net_devi { static const struct ethtool_drvinfo info = { .cmd = ETHTOOL_GDRVINFO, - .driver = "uml virtual ethernet", + .driver = DRIVER_NAME, .version = "42", }; void *useraddr; @@ -283,6 +285,12 @@ void uml_net_user_timer_expire(unsigned static spinlock_t devices_lock = SPIN_LOCK_UNLOCKED; static struct list_head devices = LIST_HEAD_INIT(devices); +static struct device_driver uml_net_driver = { + .name = DRIVER_NAME, + .bus = &platform_bus_type, +}; +static int driver_registered; + static int eth_configure(int n, void *init, char *mac, struct transport *transport) { @@ -324,6 +332,16 @@ static int eth_configure(int n, void *in return 1; } + /* sysfs register */ + if (!driver_registered) { + driver_register(¨_net_driver); + driver_registered = 1; + } + device->pdev.id = n; + device->pdev.name = DRIVER_NAME; + platform_device_register(&device->pdev); + SET_NETDEV_DEV(dev,&device->pdev.dev); + /* If this name ends up conflicting with an existing registered * netdevice, that is OK, register_netdev{,ice}() will notice this * and fail. @@ -559,6 +577,7 @@ __uml_help(eth_setup, " Configure a network device.\n\n" ); +#if 0 static int eth_init(void) { struct list_head *ele, *next; @@ -573,8 +592,8 @@ static int eth_init(void) return(1); } - __initcall(eth_init); +#endif static int net_config(char *str) { @@ -615,6 +634,7 @@ static int net_remove(char *str) if(lp->fd > 0) return(-1); if(lp->remove != NULL) (*lp->remove)(&lp->user); unregister_netdev(dev); + platform_device_unregister(&device->pdev); list_del(&device->list); kfree(device); diff -puN arch/um/include/net_kern.h~uml-sysfs-support-for-uml-network-driver arch/um/include/net_kern.h --- 25/arch/um/include/net_kern.h~uml-sysfs-support-for-uml-network-driver Thu Dec 9 14:01:01 2004 +++ 25-akpm/arch/um/include/net_kern.h Thu Dec 9 14:01:01 2004 @@ -14,6 +14,7 @@ struct uml_net { struct list_head list; struct net_device *dev; + struct platform_device pdev; int index; unsigned char mac[ETH_ALEN]; int have_mac; _