ia64/xen-unstable

changeset 10095:cb4d2fc638ec

[NET] front: clean up create_netdev interface.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 10:40:55 2006 +0100 (2006-05-18)
parents b9b316bfab15
children 25dbb1819633
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:21:11 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:40:55 2006 +0100
     1.3 @@ -163,7 +163,7 @@ static const char *be_state_name[] = {
     1.4  
     1.5  static int talk_to_backend(struct xenbus_device *, struct netfront_info *);
     1.6  static int setup_device(struct xenbus_device *, struct netfront_info *);
     1.7 -static int create_netdev(int, struct xenbus_device *, struct net_device **);
     1.8 +static struct net_device *create_netdev(int, struct xenbus_device *);
     1.9  
    1.10  static void netfront_closing(struct xenbus_device *);
    1.11  
    1.12 @@ -181,6 +181,13 @@ static int send_fake_arp(struct net_devi
    1.13  
    1.14  static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
    1.15  
    1.16 +#ifdef CONFIG_SYSFS
    1.17 +static int xennet_sysfs_addif(struct net_device *netdev);
    1.18 +static void xennet_sysfs_delif(struct net_device *netdev);
    1.19 +#else /* !CONFIG_SYSFS */
    1.20 +#define xennet_sysfs_addif(dev) (0)
    1.21 +#define xennet_sysfs_delif(dev) do { } while(0)
    1.22 +#endif
    1.23  
    1.24  /**
    1.25   * Entry point to this code when a new device is created.  Allocate the basic
    1.26 @@ -202,8 +209,9 @@ static int __devinit netfront_probe(stru
    1.27  		return err;
    1.28  	}
    1.29  
    1.30 -	err = create_netdev(handle, dev, &netdev);
    1.31 -	if (err) {
    1.32 +	netdev = create_netdev(handle, dev);
    1.33 +	if (IS_ERR(netdev)) {
    1.34 +		err = PTR_ERR(netdev);
    1.35  		xenbus_dev_fatal(dev, err, "creating netdev");
    1.36  		return err;
    1.37  	}
    1.38 @@ -213,6 +221,7 @@ static int __devinit netfront_probe(stru
    1.39  
    1.40  	err = talk_to_backend(dev, info);
    1.41  	if (err) {
    1.42 +		xennet_sysfs_delif(info->netdev);
    1.43  		unregister_netdev(netdev);
    1.44  		free_netdev(netdev);
    1.45  		dev->data = NULL;
    1.46 @@ -1204,12 +1213,7 @@ static void xennet_sysfs_delif(struct ne
    1.47  	}
    1.48  }
    1.49  
    1.50 -#else /* !CONFIG_SYSFS */
    1.51 -
    1.52 -#define xennet_sysfs_addif(dev) (0)
    1.53 -#define xennet_sysfs_delif(dev) do { } while(0)
    1.54 -
    1.55 -#endif
    1.56 +#endif /* CONFIG_SYSFS */
    1.57  
    1.58  
    1.59  /*
    1.60 @@ -1225,8 +1229,8 @@ static void network_set_multicast_list(s
    1.61   * @param val return parameter for created device
    1.62   * @return 0 on success, error code otherwise
    1.63   */
    1.64 -static int __devinit create_netdev(int handle, struct xenbus_device *dev,
    1.65 -				   struct net_device **val)
    1.66 +static struct net_device * __devinit create_netdev(int handle,
    1.67 +						   struct xenbus_device *dev)
    1.68  {
    1.69  	int i, err = 0;
    1.70  	struct net_device *netdev = NULL;
    1.71 @@ -1236,7 +1240,7 @@ static int __devinit create_netdev(int h
    1.72  	if (!netdev) {
    1.73  		printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
    1.74  		       __FUNCTION__);
    1.75 -		return -ENOMEM;
    1.76 +		return ERR_PTR(-ENOMEM);
    1.77  	}
    1.78  
    1.79  	np                = netdev_priv(netdev);
    1.80 @@ -1312,10 +1316,8 @@ static int __devinit create_netdev(int h
    1.81  	}
    1.82  
    1.83  	np->netdev = netdev;
    1.84 -	if (val)
    1.85 -		*val = netdev;
    1.86  
    1.87 -	return 0;
    1.88 +	return netdev;
    1.89  
    1.90  
    1.91   exit_free_rx:
    1.92 @@ -1324,7 +1326,7 @@ static int __devinit create_netdev(int h
    1.93  	gnttab_free_grant_references(np->gref_tx_head);
    1.94   exit:
    1.95  	free_netdev(netdev);
    1.96 -	return err;
    1.97 +	return ERR_PTR(err);
    1.98  }
    1.99  
   1.100  /*