diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 01:27:29 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 09:43:08 -0700 |
commit | cd1ae0e49bdd814cfaa2e5ab28cff21a30e20085 (patch) | |
tree | 1b993b9de4cb9a8578022a4014063c3e87ec996e /arch/um/drivers | |
parent | 1a80521990a0e30e61a92994a009adc52161b070 (diff) |
uml: network formatting
Style and other non-functional changes in the UML networking code, including
include tidying
style violations
copyright updates
printks getting severities
userspace code calling libc directly rather than using the os_*
wrappers
There's also a exit path cleanup in the pcap driver.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r-- | arch/um/drivers/daemon.h | 20 | ||||
-rw-r--r-- | arch/um/drivers/daemon_kern.c | 31 | ||||
-rw-r--r-- | arch/um/drivers/daemon_user.c | 81 | ||||
-rw-r--r-- | arch/um/drivers/mcast.h | 16 | ||||
-rw-r--r-- | arch/um/drivers/mcast_kern.c | 55 | ||||
-rw-r--r-- | arch/um/drivers/mcast_user.c | 62 | ||||
-rw-r--r-- | arch/um/drivers/net_kern.c | 197 | ||||
-rw-r--r-- | arch/um/drivers/net_user.c | 126 | ||||
-rw-r--r-- | arch/um/drivers/pcap_kern.c | 27 | ||||
-rw-r--r-- | arch/um/drivers/pcap_user.c | 49 | ||||
-rw-r--r-- | arch/um/drivers/slip_kern.c | 34 | ||||
-rw-r--r-- | arch/um/drivers/slip_user.c | 122 | ||||
-rw-r--r-- | arch/um/drivers/slirp_kern.c | 55 | ||||
-rw-r--r-- | arch/um/drivers/slirp_user.c | 67 | ||||
-rw-r--r-- | arch/um/drivers/vde_kern.c | 8 | ||||
-rw-r--r-- | arch/um/drivers/vde_user.c | 8 |
16 files changed, 479 insertions, 479 deletions
diff --git a/arch/um/drivers/daemon.h b/arch/um/drivers/daemon.h index 3bc3cf6b94a..6e0e891f8a0 100644 --- a/arch/um/drivers/daemon.h +++ b/arch/um/drivers/daemon.h @@ -1,8 +1,11 @@ -/* - * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) +/* + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ +#ifndef __DAEMON_H__ +#define __DAEMON_H__ + #include "net_user.h" #define SWITCH_VERSION 3 @@ -20,16 +23,7 @@ struct daemon_data { extern const struct net_user_info daemon_user_info; -extern int daemon_user_write(int fd, void *buf, int len, +extern int daemon_user_write(int fd, void *buf, int len, struct daemon_data *pri); -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ +#endif diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c index adeece11e59..ac507bb87fe 100644 --- a/arch/um/drivers/daemon_kern.c +++ b/arch/um/drivers/daemon_kern.c @@ -1,16 +1,14 @@ /* - * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and * James Leu (jleu@mindspring.net). + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Copyright (C) 2001 by various other people who didn't put their name here. * Licensed under the GPL. */ -#include "linux/kernel.h" #include "linux/init.h" -#include "linux/netdevice.h" -#include "linux/etherdevice.h" +#include <linux/netdevice.h> #include "net_kern.h" -#include "net_user.h" #include "daemon.h" struct daemon_init { @@ -36,25 +34,26 @@ static void daemon_init(struct net_device *dev, void *data) dpri->data_addr = NULL; dpri->local_addr = NULL; - printk("daemon backend (uml_switch version %d) - %s:%s", + printk("daemon backend (uml_switch version %d) - %s:%s", SWITCH_VERSION, dpri->sock_type, dpri->ctl_sock); printk("\n"); } -static int daemon_read(int fd, struct sk_buff **skb, +static int daemon_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) { *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); - if(*skb == NULL) return(-ENOMEM); - return(net_recvfrom(fd, skb_mac_header(*skb), - (*skb)->dev->mtu + ETH_HEADER_OTHER)); + if (*skb == NULL) + return -ENOMEM; + return net_recvfrom(fd, skb_mac_header(*skb), + (*skb)->dev->mtu + ETH_HEADER_OTHER); } static int daemon_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) { - return(daemon_user_write(fd, (*skb)->data, (*skb)->len, - (struct daemon_data *) &lp->user)); + return daemon_user_write(fd, (*skb)->data, (*skb)->len, + (struct daemon_data *) &lp->user); } static const struct net_kern_info daemon_kern_info = { @@ -72,14 +71,14 @@ static int daemon_setup(char *str, char **mac_out, void *data) *init = ((struct daemon_init) { .sock_type = "unix", .ctl_sock = "/tmp/uml.ctl" }); - + remain = split_if_spec(str, mac_out, &init->sock_type, &init->ctl_sock, NULL); - if(remain != NULL) + if (remain != NULL) printk(KERN_WARNING "daemon_setup : Ignoring data socket " "specification\n"); - - return(1); + + return 1; } static struct transport daemon_transport = { diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c index 8d2008f0668..90983d480ac 100644 --- a/arch/um/drivers/daemon_user.c +++ b/arch/um/drivers/daemon_user.c @@ -1,22 +1,23 @@ /* - * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and * James Leu (jleu@mindspring.net). * Copyright (C) 2001 by various other people who didn't put their name here. * Licensed under the GPL. */ -#include <errno.h> -#include <unistd.h> #include <stdint.h> +#include <unistd.h> +#include <errno.h> +#include <sys/types.h> #include <sys/socket.h> -#include <sys/un.h> #include <sys/time.h> -#include "net_user.h" +#include <sys/un.h> #include "daemon.h" -#include "kern_util.h" -#include "user.h" +#include "net_user.h" #include "os.h" #include "um_malloc.h" +#include "user.h" #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) @@ -36,8 +37,9 @@ static struct sockaddr_un *new_addr(void *name, int len) struct sockaddr_un *sun; sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); - if(sun == NULL){ - printk("new_addr: allocation of sockaddr_un failed\n"); + if (sun == NULL) { + printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " + "failed\n"); return NULL; } sun->sun_family = AF_UNIX; @@ -54,38 +56,39 @@ static int connect_to_switch(struct daemon_data *pri) int fd, n, err; pri->control = socket(AF_UNIX, SOCK_STREAM, 0); - if(pri->control < 0){ + if (pri->control < 0) { err = -errno; - printk("daemon_open : control socket failed, errno = %d\n", - -err); + printk(UM_KERN_ERR "daemon_open : control socket failed, " + "errno = %d\n", -err); return err; } - if(connect(pri->control, (struct sockaddr *) ctl_addr, - sizeof(*ctl_addr)) < 0){ + if (connect(pri->control, (struct sockaddr *) ctl_addr, + sizeof(*ctl_addr)) < 0) { err = -errno; - printk("daemon_open : control connect failed, errno = %d\n", - -err); + printk(UM_KERN_ERR "daemon_open : control connect failed, " + "errno = %d\n", -err); goto out; } fd = socket(AF_UNIX, SOCK_DGRAM, 0); - if(fd < 0){ + if (fd < 0) { err = -errno; - printk("daemon_open : data socket failed, errno = %d\n", - -err); + printk(UM_KERN_ERR "daemon_open : data socket failed, " + "errno = %d\n", -err); goto out; } - if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){ + if (bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0) { err = -errno; - printk("daemon_open : data bind failed, errno = %d\n", - -err); + printk(UM_KERN_ERR "daemon_open : data bind failed, " + "errno = %d\n", -err); goto out_close; } sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); - if(sun == NULL){ - printk("new_addr: allocation of sockaddr_un failed\n"); + if (sun == NULL) { + printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " + "failed\n"); err = -ENOMEM; goto out_close; } @@ -94,18 +97,18 @@ static int connect_to_switch(struct daemon_data *pri) req.version = SWITCH_VERSION; req.type = REQ_NEW_CONTROL; req.sock = *local_addr; - n = os_write_file(pri->control, &req, sizeof(req)); - if(n != sizeof(req)){ - printk("daemon_open : control setup request failed, err = %d\n", - -n); + n = write(pri->control, &req, sizeof(req)); + if (n != sizeof(req)) { + printk(UM_KERN_ERR "daemon_open : control setup request " + "failed, err = %d\n", -errno); err = -ENOTCONN; goto out_free; } - n = os_read_file(pri->control, sun, sizeof(*sun)); - if(n != sizeof(*sun)){ - printk("daemon_open : read of data socket failed, err = %d\n", - -n); + n = read(pri->control, sun, sizeof(*sun)); + if (n != sizeof(*sun)) { + printk(UM_KERN_ERR "daemon_open : read of data socket failed, " + "err = %d\n", -errno); err = -ENOTCONN; goto out_free; } @@ -116,9 +119,9 @@ static int connect_to_switch(struct daemon_data *pri) out_free: kfree(sun); out_close: - os_close_file(fd); + close(fd); out: - os_close_file(pri->control); + close(pri->control); return err; } @@ -132,8 +135,8 @@ static int daemon_user_init(void *data, void *dev) int usecs; } name; - if(!strcmp(pri->sock_type, "unix")) - pri->ctl_addr = new_addr(pri->ctl_sock, + if (!strcmp(pri->sock_type, "unix")) + pri->ctl_addr = new_addr(pri->ctl_sock, strlen(pri->ctl_sock) + 1); name.zero = 0; name.pid = os_getpid(); @@ -142,7 +145,7 @@ static int daemon_user_init(void *data, void *dev) pri->local_addr = new_addr(&name, sizeof(name)); pri->dev = dev; pri->fd = connect_to_switch(pri); - if(pri->fd < 0){ + if (pri->fd < 0) { kfree(pri->local_addr); pri->local_addr = NULL; return pri->fd; @@ -161,9 +164,9 @@ static void daemon_remove(void *data) { struct daemon_data *pri = data; - os_close_file(pri->fd); + close(pri->fd); pri->fd = -1; - os_close_file(pri->control); + close(pri->control); pri->control = -1; kfree(pri->data_addr); diff --git a/arch/um/drivers/mcast.h b/arch/um/drivers/mcast.h index bc56af9d3e5..6fa282e896b 100644 --- a/arch/um/drivers/mcast.h +++ b/arch/um/drivers/mcast.h @@ -1,8 +1,11 @@ /* - * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ +#ifndef __DRIVERS_MCAST_H +#define __DRIVERS_MCAST_H + #include "net_user.h" struct mcast_data { @@ -18,13 +21,4 @@ extern const struct net_user_info mcast_user_info; extern int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri); -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ +#endif diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c index e6b8e0dd72a..5027b870d11 100644 --- a/arch/um/drivers/mcast_kern.c +++ b/arch/um/drivers/mcast_kern.c @@ -1,24 +1,20 @@ /* * user-mode-linux networking multicast transport * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * * based on the existing uml-networking code, which is - * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and * James Leu (jleu@mindspring.net). * Copyright (C) 2001 by various other people who didn't put their name here. * * Licensed under the GPL. */ -#include "linux/kernel.h" #include "linux/init.h" -#include "linux/netdevice.h" -#include "linux/etherdevice.h" -#include "linux/in.h" -#include "linux/inet.h" -#include "net_kern.h" -#include "net_user.h" +#include <linux/netdevice.h> #include "mcast.h" +#include "net_kern.h" struct mcast_init { char *addr; @@ -39,26 +35,23 @@ static void mcast_init(struct net_device *dev, void *data) dpri->ttl = init->ttl; dpri->dev = dev; - printk("mcast backend "); - printk("multicast address: %s:%u, TTL:%u ", + printk("mcast backend multicast address: %s:%u, TTL:%u\n", dpri->addr, dpri->port, dpri->ttl); - - printk("\n"); } static int mcast_read(int fd, struct sk_buff **skb, struct uml_net_private *lp) { *skb = ether_adjust_skb(*skb, ETH_HEADER_OTHER); - if(*skb == NULL) return(-ENOMEM); - return(net_recvfrom(fd, skb_mac_header(*skb), - (*skb)->dev->mtu + ETH_HEADER_OTHER)); + if (*skb == NULL) + return -ENOMEM; + return net_recvfrom(fd, skb_mac_header(*skb), + (*skb)->dev->mtu + ETH_HEADER_OTHER); } -static int mcast_write(int fd, struct sk_buff **skb, - struct uml_net_private *lp) +static int mcast_write(int fd, struct sk_buff **skb, struct uml_net_private *lp) { - return mcast_user_write(fd, (*skb)->data, (*skb)->len, - (struct mcast_data *) &lp->user); + return mcast_user_write(fd, (*skb)->data, (*skb)->len, + (struct mcast_data *) &lp->user); } static const struct net_kern_info mcast_kern_info = { @@ -81,34 +74,34 @@ int mcast_setup(char *str, char **mac_out, void *data) remain = split_if_spec(str, mac_out, &init->addr, &port_str, &ttl_str, NULL); - if(remain != NULL){ + if (remain != NULL) { printk(KERN_ERR "mcast_setup - Extra garbage on " "specification : '%s'\n", remain); - return(0); + return 0; } - - if(port_str != NULL){ + + if (port_str != NULL) { init->port = simple_strtoul(port_str, &last, 10); - if((*last != '\0') || (last == port_str)){ - printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", + if ((*last != '\0') || (last == port_str)) { + printk(KERN_ERR "mcast_setup - Bad port : '%s'\n", port_str); - return(0); + return 0; } } - if(ttl_str != NULL){ + if (ttl_str != NULL) { init->ttl = simple_strtoul(ttl_str, &last, 10); - if((*last != '\0') || (last == ttl_str)){ - printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", + if ((*last != '\0') || (last == ttl_str)) { + printk(KERN_ERR "mcast_setup - Bad ttl : '%s'\n", ttl_str); - return(0); + return 0; } } printk(KERN_INFO "Configured mcast device: %s:%u-%u\n", init->addr, init->port, init->ttl); - return(1); + return 1; } static struct transport mcast_transport = { diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c index 236a3dfc297..e427b5322a3 100644 --- a/arch/um/drivers/mcast_user.c +++ b/arch/um/drivers/mcast_user.c @@ -1,9 +1,10 @@ /* * user-mode-linux networking multicast transport + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Copyright (C) 2001 by Harald Welte <laforge@gnumonks.org> * * based on the existing uml-networking code, which is - * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and + * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and * James Leu (jleu@mindspring.net). * Copyright (C) 2001 by various other people who didn't put their name here. * @@ -11,18 +12,13 @@ * */ -#include <errno.h> #include <unistd.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/time.h> +#include <errno.h> #include <netinet/in.h> -#include "net_user.h" #include "mcast.h" -#include "kern_util.h" -#include "user.h" -#include "os.h" +#include "net_user.h" #include "um_malloc.h" +#include "user.h" #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) @@ -31,8 +27,9 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port) struct sockaddr_in *sin; sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); - if(sin == NULL){ - printk("new_addr: allocation of sockaddr_in failed\n"); + if (sin == NULL) { + printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in " + "failed\n"); return NULL; } sin->sin_family = AF_INET; @@ -71,17 +68,17 @@ static int mcast_open(void *data) fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0){ + if (fd < 0) { err = -errno; - printk("mcast_open : data socket failed, errno = %d\n", - errno); + printk(UM_KERN_ERR "mcast_open : data socket failed, " + "errno = %d\n", errno); goto out; } if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { err = -errno; - printk("mcast_open: SO_REUSEADDR failed, errno = %d\n", - errno); + printk(UM_KERN_ERR "mcast_open: SO_REUSEADDR failed, " + "errno = %d\n", errno); goto out_close; } @@ -89,45 +86,46 @@ static int mcast_open(void *data) if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &pri->ttl, sizeof(pri->ttl)) < 0) { err = -errno; - printk("mcast_open: IP_MULTICAST_TTL failed, error = %d\n", - errno); + printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_TTL failed, " + "error = %d\n", errno); goto out_close; } /* set LOOP, so data does get fed back to local sockets */ if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) { err = -errno; - printk("mcast_open: IP_MULTICAST_LOOP failed, error = %d\n", - errno); + printk(UM_KERN_ERR "mcast_open: IP_MULTICAST_LOOP failed, " + "error = %d\n", errno); goto out_close; } /* bind socket to mcast address */ if (bind(fd, (struct sockaddr *) sin, sizeof(*sin)) < 0) { err = -errno; - printk("mcast_open : data bind failed, errno = %d\n", errno); + printk(UM_KERN_ERR "mcast_open : data bind failed, " + "errno = %d\n", errno); goto out_close; } /* subscribe to the multicast group */ mreq.imr_multiaddr.s_addr = sin->sin_addr.s_addr; mreq.imr_interface.s_addr = 0; - if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, + if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { err = -errno; - printk("mcast_open: IP_ADD_MEMBERSHIP failed, error = %d\n", - errno); - printk("There appears not to be a multicast-capable network " - "interface on the host.\n"); - printk("eth0 should be configured in order to use the " - "multicast transport.\n"); + printk(UM_KERN_ERR "mcast_open: IP_ADD_MEMBERSHIP failed, " + "error = %d\n", errno); + printk(UM_KERN_ERR "There appears not to be a multicast-" + "capable network interface on the host.\n"); + printk(UM_KERN_ERR "eth0 should be configured in order to use " + "the multicast transport.\n"); goto out_close; } return fd; out_close: - os_close_file(fd); + close(fd); out: return err; } @@ -142,11 +140,11 @@ static void mcast_close(int fd, void *data) mreq.imr_interface.s_addr = 0; if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { - printk("mcast_open: IP_DROP_MEMBERSHIP failed, error = %d\n", - errno); + printk(UM_KERN_ERR "mcast_open: IP_DROP_MEMBERSHIP failed, " + "error = %d\n", errno); } - os_close_file(fd); + close(fd); } int mcast_user_write(int fd, void *buf, int len, struct mcast_data *pri) diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index d35d0c1ee7f..b097a24c149 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -1,33 +1,28 @@ /* + * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) and * James Leu (jleu@mindspring.net). * Copyright (C) 2001 by various other people who didn't put their name here. * Licensed under the GPL. */ -#include "linux/kernel.h" -#include "linux/netdevice.h" -#include "linux/rtnetlink.h" -#include "linux/skbuff.h" -#include "linux/socket.h" -#include "linux/spinlock.h" -#include "linux/module.h" -#include "linux/init.h" -#include "linux/etherdevice.h" -#include "linux/list.h" -#include "linux/inetdevice.h" -#include "linux/ctype.h" -#include "linux/bootmem.h" -#include "linux/ethtool.h" -#include "linux/platform_device.h" -#include "asm/uaccess.h" -#include "kern_util.h" -#include "net_kern.h" -#include "net_user.h" -#include "mconsole_kern.h" +#include <linux/bootmem.h> +#include <linux/etherdevice.h> +#include <linux/ethtool.h> +#include <linux/inetdevice.h> +#include <linux/init.h> +#include <linux/list.h> +#include <linux/netdevice.h> +#include <linux/platform_device.h> +#include <linux/rtnetlink.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> #include "init.h" -#include "irq_user.h" #include "irq_kern.h" +#include "irq_user.h" +#include "mconsole_kern.h" +#include "net_kern.h" +#include "net_user.h" static inline void set_ether_mac(struct net_device *dev, unsigned char *addr) { @@ -84,12 +79,12 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) struct uml_net_private *lp = dev->priv; int err; - if(!netif_running(dev)) - return(IRQ_NONE); + if (!netif_running(dev)) + return IRQ_NONE; spin_lock(&lp->lock); - while((err = uml_net_rx(dev)) > 0) ; - if(err < 0) { + while ((err = uml_net_rx(dev)) > 0) ; + if (err < 0) { printk(KERN_ERR "Device '%s' read returned %d, shutting it down\n", dev->name, err); @@ -115,20 +110,20 @@ static int uml_net_open(struct net_device *dev) struct uml_net_private *lp = dev->priv; int err; - if(lp->fd >= 0){ + if (lp->fd >= 0) { err = -ENXIO; goto out; } lp->fd = (*lp->open)(&lp->user); - if(lp->fd < 0){ + if (lp->fd < 0) { err = lp->fd; goto out; } err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt, IRQF_DISABLED | IRQF_SHARED, dev->name, dev); - if(err != 0){ + if (err != 0) { printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err); err = -ENETUNREACH; goto out_close; @@ -141,7 +136,7 @@ static int uml_net_open(struct net_device *dev) * is full when we get here. In this case, new data is never queued, * SIGIOs never arrive, and the net never works. */ - while((err = uml_net_rx(dev)) > 0) ; + while ((err = uml_net_rx(dev)) > 0) ; spin_lock(&opened_lock); list_add(&lp->list, &opened); @@ -149,7 +144,7 @@ static int uml_net_open(struct net_device *dev) return 0; out_close: - if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user); + if (lp->close != NULL) (*lp->close)(lp->fd, &lp->user); lp->fd = -1; out: return err; @@ -162,7 +157,7 @@ static int uml_net_close(struct net_device *dev) netif_stop_queue(dev); free_irq(dev->irq, dev); - if(lp->close != NULL) + if (lp->close != NULL) (*lp->close)(lp->fd, &lp->user); lp->fd = -1; @@ -185,7 +180,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev) len = (*lp->write)(lp->fd, &skb, lp); - if(len == skb->len) { + if (len == skb->len) { lp->stats.tx_packets++; lp->stats.tx_bytes += skb->len; dev->trans_start = jiffies; @@ -194,7 +189,7 @@ static int uml_net_start_xmit(struct sk_buff *skb, struct net_device *dev) /* this is normally done in the interrupt when tx finishes */ netif_wake_queue(dev); } - else if(len == 0){ + else if (len == 0) { netif_start_queue(dev); lp->stats.tx_dropped++; } @@ -218,8 +213,10 @@ static struct net_device_stats *uml_net_get_stats(struct net_device *dev) static void uml_net_set_multicast_list(struct net_device *dev) { - if (dev->flags & IFF_PROMISC) return; - else if (dev->mc_count) dev->flags |= IFF_ALLMULTI; + if (dev->flags & IFF_PROMISC) + return; + else if (dev->mc_count) + dev->flags |= IFF_ALLMULTI; else dev->flags &= ~IFF_ALLMULTI; } @@ -249,7 +246,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu) spin_lock_irq(&lp->lock); new_mtu = (*lp->set_mtu)(new_mtu, &lp->user); - if(new_mtu < 0){ + if (new_mtu < 0) { err = new_mtu; goto out; } @@ -288,13 +285,13 @@ static void setup_etheraddr(char *str, unsigned char *addr, char *name) char *end; int i; - if(str == NULL) + if (str == NULL) goto random; - for(i=0;i<6;i++){ + for (i = 0;i < 6; i++) { addr[i] = simple_strtoul(str, &end, 16); - if((end == str) || - ((*end != ':') && (*end != ',') && (*end != '\0'))){ + if ((end == str) || + ((*end != ':') && (*end != ',') && (*end != '\0'))) { printk(KERN_ERR "setup_etheraddr: failed to parse '%s' " "as an ethernet address\n", str); @@ -349,7 +346,7 @@ static void net_device_release(struct device *dev) struct net_device *netdev = device->dev; struct uml_net_private *lp = netdev->priv; - if(lp->remove != NULL) + if (lp->remove != NULL) (*lp->remove)(&lp->user); list_del(&device->list); kfree(device); @@ -413,7 +410,7 @@ static void eth_configure(int n, void *init, char *mac, device->pdev.name = DRIVER_NAME; device->pdev.dev.release = net_device_release; device->pdev.dev.driver_data = device; - if(platform_device_register(&device->pdev)) + if (platform_device_register(&device->pdev)) goto out_free_netdev; SET_NETDEV_DEV(dev,&device->pdev.dev); @@ -493,9 +490,9 @@ static struct uml_net *find_device(int n) struct list_head *ele; spin_lock(&devices_lock); - list_for_each(ele, &devices){ + list_for_each(ele, &devices) { device = list_entry(ele, struct uml_net, list); - if(device->index == n) + if (device->index == n) goto out; } device = NULL; @@ -511,19 +508,19 @@ static int eth_parse(char *str, int *index_out, char **str_out, int n, err = -EINVAL;; n = simple_strtoul(str, &end, 0); - if(end == str){ + if (end == str) { *error_out = "Bad device number"; return err; } str = end; - if(*str != '='){ + if (*str != '=') { *error_out = "Expected '=' after device number"; return err; } str++; - if(find_device(n)){ + if (find_device(n)) { *error_out = "Device already configured"; return err; } @@ -551,20 +548,20 @@ static int check_transport(struct transport *transport, char *eth, int n, int len; len = strlen(transport->name); - if(strncmp(eth, transport->name, len)) + if (strncmp(eth, transport->name, len)) return 0; eth += len; - if(*eth == ',') + if (*eth == ',') eth++; - else if(*eth != '\0') + else if (*eth != '\0') return 0; *init_out = kmalloc(transport->setup_size, GFP_KERNEL); - if(*init_out == NULL) + if (*init_out == NULL) return 1; - if(!transport->setup(eth, mac_out, *init_out)){ + if (!transport->setup(eth, mac_out, *init_out)) { kfree(*init_out); *init_out = NULL; } @@ -584,13 +581,13 @@ void register_transport(struct transport *new) list_add(&new->list, &transports); spin_unlock(&transports_lock); - list_for_each_safe(ele, next, ð_cmd_line){ + list_for_each_safe(ele, next, ð_cmd_line) { eth = list_entry(ele, struct eth_init, list); match = check_transport(new, eth->init, eth->index, &init, &mac); - if(!match) + if (!match) continue; - else if(init != NULL){ + else if (init != NULL) { eth_configure(eth->index, init, mac, new); kfree(init); } @@ -607,11 +604,11 @@ static int eth_setup_common(char *str, int index) int found = 0; spin_lock(&transports_lock); - list_for_each(ele, &transports){ + list_for_each(ele, &transports) { transport = list_entry(ele, struct transport, list); - if(!check_transport(transport, str, index, &init, &mac)) + if (!check_transport(transport, str, index, &init, &mac)) continue; - if(init != NULL){ + if (init != NULL) { eth_configure(index, init, mac, transport); kfree(init); } @@ -630,15 +627,15 @@ static int __init eth_setup(char *str) int n, err; err = eth_parse(str, &n, &str, &error); - if(err){ + if (err) { printk(KERN_ERR "eth_setup - Couldn't parse '%s' : %s\n", str, error); return 1; } new = alloc_bootmem(sizeof(*new)); - if (new == NULL){ - printk("eth_init : alloc_bootmem failed\n"); + if (new == NULL) { + printk(KERN_ERR "eth_init : alloc_bootmem failed\n"); return 1; } @@ -661,36 +658,36 @@ static int net_config(char *str, char **error_out) int n, err; err = eth_parse(str, &n, &str, error_out); - if(err) + if (err) return err; /* This string is broken up and the pieces used by the underlying * driver. So, it is freed only if eth_setup_common fails. */ str = kstrdup(str, GFP_KERNEL); - if(str == NULL){ + if (str == NULL) { *error_out = "net_config failed to strdup string"; return -ENOMEM; } err = !eth_setup_common(str, n); - if(err) + if (err) kfree(str); - return(err); + return err; } static int net_id(char **str, int *start_out, int *end_out) { - char *end; - int n; + char *end; + int n; n = simple_strtoul(*str, &end, 0); - if((*end != '\0') || (end == *str)) + if ((*end != '\0') || (end == *str)) return -1; - *start_out = n; - *end_out = n; - *str = end; - return n; + *start_out = n; + *end_out = n; + *str = end; + return n; } static int net_remove(int n, char **error_out) @@ -700,12 +697,12 @@ static int net_remove(int n, char **error_out) struct uml_net_private *lp; device = find_device(n); - if(device == NULL) + if (device == NULL) return -ENODEV; dev = device->dev; lp = dev->priv; - if(lp->fd > 0) + if (lp->fd > 0) return -EBUSY; unregister_netdev(dev); platform_device_unregister(&device->pdev); @@ -731,13 +728,13 @@ static int uml_inetaddr_event(struct notifier_block *this, unsigned long event, void (*proc)(unsigned char *, unsigned char *, void *); unsigned char addr_buf[4], netmask_buf[4]; - if(dev->open != uml_net_open) + if (dev->open != uml_net_open) return NOTIFY_DONE; lp = dev->priv; proc = NULL; - switch (event){ + switch (event) { case NETDEV_UP: proc = lp->add_address; break; @@ -745,7 +742,7 @@ static int uml_inetaddr_event(struct notifier_bloc |