direct-io.hg

changeset 11299:8a0ad47713f1

[NET] front: move register_netdev() + sysfs attribute registering from create_netdev() into the new open_netdev() function.
open_netdev is called as very last thing in netdev_probe.

This closes at least one initialization race: uninitialized
mac address is visible for a short time in
/sys/class/net/${if}/address

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
author kaf24@firebug.cl.cam.ac.uk
date Wed Aug 30 18:40:40 2006 +0100 (2006-08-30)
parents d741e86a8766
children 74db626d2fcf
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	Wed Aug 30 18:19:04 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 30 18:40:40 2006 +0100
     1.3 @@ -193,6 +193,7 @@ static void netfront_closing(struct xenb
     1.4  
     1.5  static void end_access(int, void *);
     1.6  static void netif_disconnect_backend(struct netfront_info *);
     1.7 +static int open_netdev(struct netfront_info *);
     1.8  static void close_netdev(struct netfront_info *);
     1.9  static void netif_free(struct netfront_info *);
    1.10  
    1.11 @@ -263,15 +264,22 @@ static int __devinit netfront_probe(stru
    1.12  	dev->dev.driver_data = info;
    1.13  
    1.14  	err = talk_to_backend(dev, info);
    1.15 -	if (err) {
    1.16 -		xennet_sysfs_delif(info->netdev);
    1.17 -		unregister_netdev(netdev);
    1.18 -		free_netdev(netdev);
    1.19 -		dev->dev.driver_data = NULL;
    1.20 -		return err;
    1.21 -	}
    1.22 +	if (err)
    1.23 +		goto fail_backend;
    1.24 +
    1.25 +	err = open_netdev(info);
    1.26 +	if (err)
    1.27 +		goto fail_open;
    1.28  
    1.29  	return 0;
    1.30 +
    1.31 + fail_open:
    1.32 +	xennet_sysfs_delif(info->netdev);
    1.33 +	unregister_netdev(netdev);
    1.34 + fail_backend:
    1.35 +	free_netdev(netdev);
    1.36 +	dev->dev.driver_data = NULL;
    1.37 +	return err;
    1.38  }
    1.39  
    1.40  
    1.41 @@ -1887,27 +1895,9 @@ create_netdev(int handle, int copying_re
    1.42  	SET_MODULE_OWNER(netdev);
    1.43  	SET_NETDEV_DEV(netdev, &dev->dev);
    1.44  
    1.45 -	err = register_netdev(netdev);
    1.46 -	if (err) {
    1.47 -		printk(KERN_WARNING "%s> register_netdev err=%d\n",
    1.48 -		       __FUNCTION__, err);
    1.49 -		goto exit_free_rx;
    1.50 -	}
    1.51 -
    1.52 -	err = xennet_sysfs_addif(netdev);
    1.53 -	if (err) {
    1.54 -		/* This can be non-fatal: it only means no tuning parameters */
    1.55 -		printk(KERN_WARNING "%s> add sysfs failed err=%d\n",
    1.56 -		       __FUNCTION__, err);
    1.57 -	}
    1.58 -
    1.59  	np->netdev = netdev;
    1.60 -
    1.61  	return netdev;
    1.62  
    1.63 -
    1.64 - exit_free_rx:
    1.65 -	gnttab_free_grant_references(np->gref_rx_head);
    1.66   exit_free_tx:
    1.67  	gnttab_free_grant_references(np->gref_tx_head);
    1.68   exit:
    1.69 @@ -1967,6 +1957,26 @@ static int __devexit netfront_remove(str
    1.70  }
    1.71  
    1.72  
    1.73 +static int open_netdev(struct netfront_info *info)
    1.74 +{
    1.75 +	int err;
    1.76 +	
    1.77 +	err = register_netdev(info->netdev);
    1.78 +	if (err) {
    1.79 +		printk(KERN_WARNING "%s: register_netdev err=%d\n",
    1.80 +		       __FUNCTION__, err);
    1.81 +		return err;
    1.82 +	}
    1.83 +
    1.84 +	err = xennet_sysfs_addif(info->netdev);
    1.85 +	if (err) {
    1.86 +		/* This can be non-fatal: it only means no tuning parameters */
    1.87 +		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
    1.88 +		       __FUNCTION__, err);
    1.89 +	}
    1.90 +	return 0;
    1.91 +}
    1.92 +
    1.93  static void close_netdev(struct netfront_info *info)
    1.94  {
    1.95  	del_timer_sync(&info->rx_refill_timer);