ia64/xen-unstable

changeset 10186:ac4a961f7e64

Remove net_driver_util module. Inline the one mac-parsing function
into the netfront and netback drivers. Take the opportunity to fix
the mac-parsing logic.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 25 22:57:44 2006 +0100 (2006-05-25)
parents 93db1b536f38
children b6937b931419
files linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile linux-2.6-xen-sparse/drivers/xen/Makefile linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Thu May 25 21:41:04 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/Makefile	Thu May 25 22:57:44 2006 +0100
     1.3 @@ -2,7 +2,6 @@
     1.4  ifneq ($(CONFIG_XEN_IA64_DOM0_VP),y)
     1.5  obj-y   += util.o
     1.6  endif
     1.7 -obj-$(CONFIG_XEN_IA64_DOM0_VP)	+= net_driver_util.o
     1.8  
     1.9  obj-y	+= core/
    1.10  #obj-y	+= char/
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/Makefile	Thu May 25 21:41:04 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Makefile	Thu May 25 22:57:44 2006 +0100
     2.3 @@ -1,5 +1,4 @@
     2.4  
     2.5 -obj-y	+= net_driver_util.o
     2.6  obj-y	+= util.o
     2.7  
     2.8  obj-y	+= core/
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/net_driver_util.c	Thu May 25 21:41:04 2006 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,58 +0,0 @@
     3.4 -/*****************************************************************************
     3.5 - *
     3.6 - * Utility functions for Xen network devices.
     3.7 - *
     3.8 - * Copyright (c) 2005 XenSource Ltd.
     3.9 - * 
    3.10 - * This program is free software; you can redistribute it and/or
    3.11 - * modify it under the terms of the GNU General Public License version 2
    3.12 - * as published by the Free Software Foundation; or, when distributed
    3.13 - * separately from the Linux kernel or incorporated into other
    3.14 - * software packages, subject to the following license:
    3.15 - * 
    3.16 - * Permission is hereby granted, free of charge, to any person obtaining a
    3.17 - * copy of this source file (the "Software"), to deal in the Software without
    3.18 - * restriction, including without limitation the rights to use, copy, modify,
    3.19 - * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    3.20 - * and to permit persons to whom the Software is furnished to do so, subject
    3.21 - * to the following conditions:
    3.22 - * 
    3.23 - * The above copyright notice and this permission notice shall be included in
    3.24 - * all copies or substantial portions of the Software.
    3.25 - * 
    3.26 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    3.27 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    3.28 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    3.29 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    3.30 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    3.31 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    3.32 - * DEALINGS IN THE SOFTWARE.
    3.33 - */
    3.34 -
    3.35 -#include <linux/if_ether.h>
    3.36 -#include <linux/err.h>
    3.37 -#include <linux/module.h>
    3.38 -#include <xen/net_driver_util.h>
    3.39 -
    3.40 -
    3.41 -int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
    3.42 -{
    3.43 -	char *s;
    3.44 -	int i;
    3.45 -	char *e;
    3.46 -	char *macstr = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
    3.47 -	if (IS_ERR(macstr))
    3.48 -		return PTR_ERR(macstr);
    3.49 -	s = macstr;
    3.50 -	for (i = 0; i < ETH_ALEN; i++) {
    3.51 -		mac[i] = simple_strtoul(s, &e, 16);
    3.52 -		if (s == e || (e[0] != ':' && e[0] != 0)) {
    3.53 -			kfree(macstr);
    3.54 -			return -ENOENT;
    3.55 -		}
    3.56 -		s = &e[1];
    3.57 -	}
    3.58 -	kfree(macstr);
    3.59 -	return 0;
    3.60 -}
    3.61 -EXPORT_SYMBOL_GPL(xen_net_read_mac);
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Thu May 25 21:41:04 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Thu May 25 22:57:44 2006 +0100
     4.3 @@ -17,21 +17,17 @@
     4.4      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     4.5  */
     4.6  
     4.7 -
     4.8  #include <stdarg.h>
     4.9  #include <linux/module.h>
    4.10  #include <xen/xenbus.h>
    4.11 -#include <xen/net_driver_util.h>
    4.12  #include "common.h"
    4.13  
    4.14 -
    4.15  #if 0
    4.16  #undef DPRINTK
    4.17  #define DPRINTK(fmt, args...) \
    4.18      printk("netback/xenbus (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
    4.19  #endif
    4.20  
    4.21 -
    4.22  struct backend_info
    4.23  {
    4.24  	struct xenbus_device *dev;
    4.25 @@ -40,14 +36,12 @@ struct backend_info
    4.26  	enum xenbus_state frontend_state;
    4.27  };
    4.28  
    4.29 -
    4.30  static int connect_rings(struct backend_info *);
    4.31  static void connect(struct backend_info *);
    4.32  static void maybe_connect(struct backend_info *);
    4.33  static void backend_changed(struct xenbus_watch *, const char **,
    4.34  			    unsigned int);
    4.35  
    4.36 -
    4.37  static int netback_remove(struct xenbus_device *dev)
    4.38  {
    4.39  	struct backend_info *be = dev->data;
    4.40 @@ -273,6 +267,27 @@ static void xen_net_read_rate(struct xen
    4.41  	kfree(ratestr);
    4.42  }
    4.43  
    4.44 +static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
    4.45 +{
    4.46 +	char *s, *e, *macstr;
    4.47 +	int i;
    4.48 +
    4.49 +	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
    4.50 +	if (IS_ERR(macstr))
    4.51 +		return PTR_ERR(macstr);
    4.52 +
    4.53 +	for (i = 0; i < ETH_ALEN; i++) {
    4.54 +		mac[i] = simple_strtoul(s, &e, 16);
    4.55 +		if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) {
    4.56 +			kfree(macstr);
    4.57 +			return -ENOENT;
    4.58 +		}
    4.59 +		s = e+1;
    4.60 +	}
    4.61 +
    4.62 +	kfree(macstr);
    4.63 +	return 0;
    4.64 +}
    4.65  
    4.66  static void connect(struct backend_info *be)
    4.67  {
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 25 21:41:04 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 25 22:57:44 2006 +0100
     5.3 @@ -60,7 +60,6 @@
     5.4  #include <asm/uaccess.h>
     5.5  #include <xen/interface/grant_table.h>
     5.6  #include <xen/gnttab.h>
     5.7 -#include <xen/net_driver_util.h>
     5.8  
     5.9  #define GRANT_INVALID_REF	0
    5.10  
    5.11 @@ -233,6 +232,27 @@ static int netfront_resume(struct xenbus
    5.12  	return talk_to_backend(dev, info);
    5.13  }
    5.14  
    5.15 +static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
    5.16 +{
    5.17 +	char *s, *e, *macstr;
    5.18 +	int i;
    5.19 +
    5.20 +	macstr = s = xenbus_read(XBT_NULL, dev->nodename, "mac", NULL);
    5.21 +	if (IS_ERR(macstr))
    5.22 +		return PTR_ERR(macstr);
    5.23 +
    5.24 +	for (i = 0; i < ETH_ALEN; i++) {
    5.25 +		mac[i] = simple_strtoul(s, &e, 16);
    5.26 +		if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) {
    5.27 +			kfree(macstr);
    5.28 +			return -ENOENT;
    5.29 +		}
    5.30 +		s = e+1;
    5.31 +	}
    5.32 +
    5.33 +	kfree(macstr);
    5.34 +	return 0;
    5.35 +}
    5.36  
    5.37  /* Common code used when first setting up, and when resuming. */
    5.38  static int talk_to_backend(struct xenbus_device *dev,
     6.1 --- a/linux-2.6-xen-sparse/include/xen/net_driver_util.h	Thu May 25 21:41:04 2006 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,48 +0,0 @@
     6.4 -/*****************************************************************************
     6.5 - *
     6.6 - * Utility functions for Xen network devices.
     6.7 - *
     6.8 - * Copyright (c) 2005 XenSource Ltd.
     6.9 - * 
    6.10 - * This program is free software; you can redistribute it and/or
    6.11 - * modify it under the terms of the GNU General Public License version 2
    6.12 - * as published by the Free Software Foundation; or, when distributed
    6.13 - * separately from the Linux kernel or incorporated into other
    6.14 - * software packages, subject to the following license:
    6.15 - * 
    6.16 - * Permission is hereby granted, free of charge, to any person obtaining a
    6.17 - * copy of this source file (the "Software"), to deal in the Software without
    6.18 - * restriction, including without limitation the rights to use, copy, modify,
    6.19 - * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    6.20 - * and to permit persons to whom the Software is furnished to do so, subject
    6.21 - * to the following conditions:
    6.22 - * 
    6.23 - * The above copyright notice and this permission notice shall be included in
    6.24 - * all copies or substantial portions of the Software.
    6.25 - * 
    6.26 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    6.27 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    6.28 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    6.29 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    6.30 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    6.31 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    6.32 - * DEALINGS IN THE SOFTWARE.
    6.33 - */
    6.34 -
    6.35 -#ifndef _ASM_XEN_NET_DRIVER_UTIL_H
    6.36 -#define _ASM_XEN_NET_DRIVER_UTIL_H
    6.37 -
    6.38 -
    6.39 -#include <xen/xenbus.h>
    6.40 -
    6.41 -
    6.42 -/**
    6.43 - * Read the 'mac' node at the given device's node in the store, and parse that
    6.44 - * as colon-separated octets, placing result the given mac array.  mac must be
    6.45 - * a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
    6.46 - * Return 0 on success, or -errno on error.
    6.47 - */
    6.48 -int xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
    6.49 -
    6.50 -
    6.51 -#endif /* _ASM_XEN_NET_DRIVER_UTIL_H */