ia64/xen-unstable

changeset 13359:b11e75e65f90

[IA64] Move cmdline.c to linux-xen

Need to clean up some build warnings. Probably should have been moved
last time it was modified.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild2.aw
date Wed Jan 10 10:35:24 2007 -0700 (2007-01-10)
parents 8c9c3ae604bc
children 91be8436952d
files xen/arch/ia64/linux-xen/Makefile xen/arch/ia64/linux-xen/README.origin xen/arch/ia64/linux-xen/cmdline.c xen/arch/ia64/linux/Makefile xen/arch/ia64/linux/README.origin xen/arch/ia64/linux/cmdline.c
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/Makefile	Wed Jan 10 08:48:50 2007 -0700
     1.2 +++ b/xen/arch/ia64/linux-xen/Makefile	Wed Jan 10 10:35:24 2007 -0700
     1.3 @@ -1,5 +1,6 @@
     1.4  subdir-y += sn
     1.5  
     1.6 +obj-y += cmdline.o
     1.7  obj-y += efi.o
     1.8  obj-y += entry.o
     1.9  obj-y += irq_ia64.o
     2.1 --- a/xen/arch/ia64/linux-xen/README.origin	Wed Jan 10 08:48:50 2007 -0700
     2.2 +++ b/xen/arch/ia64/linux-xen/README.origin	Wed Jan 10 10:35:24 2007 -0700
     2.3 @@ -5,6 +5,7 @@
     2.4  # (e.g. with #ifdef XEN or XEN in a comment) so that they can be
     2.5  # easily updated to future versions of the corresponding Linux files.
     2.6  
     2.7 +cmdline.c		-> linux/lib/cmdline.c
     2.8  efi.c			-> linux/arch/ia64/kernel/efi.c
     2.9  entry.h			-> linux/arch/ia64/kernel/entry.h
    2.10  entry.S			-> linux/arch/ia64/kernel/entry.S
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/arch/ia64/linux-xen/cmdline.c	Wed Jan 10 10:35:24 2007 -0700
     3.3 @@ -0,0 +1,121 @@
     3.4 +/*
     3.5 + * linux/lib/cmdline.c
     3.6 + * Helper functions generally used for parsing kernel command line
     3.7 + * and module options.
     3.8 + *
     3.9 + * Code and copyrights come from init/main.c and arch/i386/kernel/setup.c.
    3.10 + *
    3.11 + * This source code is licensed under the GNU General Public License,
    3.12 + * Version 2.  See the file COPYING for more details.
    3.13 + *
    3.14 + * GNU Indent formatting options for this file: -kr -i8 -npsl -pcs
    3.15 + *
    3.16 + */
    3.17 +
    3.18 +#include <linux/module.h>
    3.19 +#include <linux/kernel.h>
    3.20 +#include <linux/string.h>
    3.21 +#include <xen/lib.h>
    3.22 +
    3.23 +
    3.24 +/**
    3.25 + *	get_option - Parse integer from an option string
    3.26 + *	@str: option string
    3.27 + *	@pint: (output) integer value parsed from @str
    3.28 + *
    3.29 + *	Read an int from an option string; if available accept a subsequent
    3.30 + *	comma as well.
    3.31 + *
    3.32 + *	Return values:
    3.33 + *	0 : no int in string
    3.34 + *	1 : int found, no subsequent comma
    3.35 + *	2 : int found including a subsequent comma
    3.36 + */
    3.37 +
    3.38 +int get_option (char **str, int *pint)
    3.39 +{
    3.40 +	char *cur = *str;
    3.41 +
    3.42 +	if (!cur || !(*cur))
    3.43 +		return 0;
    3.44 +	*pint = simple_strtol (cur, str, 0);
    3.45 +	if (cur == *str)
    3.46 +		return 0;
    3.47 +	if (**str == ',') {
    3.48 +		(*str)++;
    3.49 +		return 2;
    3.50 +	}
    3.51 +
    3.52 +	return 1;
    3.53 +}
    3.54 +
    3.55 +/**
    3.56 + *	get_options - Parse a string into a list of integers
    3.57 + *	@str: String to be parsed
    3.58 + *	@nints: size of integer array
    3.59 + *	@ints: integer array
    3.60 + *
    3.61 + *	This function parses a string containing a comma-separated
    3.62 + *	list of integers.  The parse halts when the array is
    3.63 + *	full, or when no more numbers can be retrieved from the
    3.64 + *	string.
    3.65 + *
    3.66 + *	Return value is the character in the string which caused
    3.67 + *	the parse to end (typically a null terminator, if @str is
    3.68 + *	completely parseable).
    3.69 + */
    3.70 + 
    3.71 +char *get_options(const char *str, int nints, int *ints)
    3.72 +{
    3.73 +	int res, i = 1;
    3.74 +
    3.75 +	while (i < nints) {
    3.76 +		res = get_option ((char **)&str, ints + i);
    3.77 +		if (res == 0)
    3.78 +			break;
    3.79 +		i++;
    3.80 +		if (res == 1)
    3.81 +			break;
    3.82 +	}
    3.83 +	ints[0] = i - 1;
    3.84 +	return (char *)str;
    3.85 +}
    3.86 +
    3.87 +/**
    3.88 + *	memparse - parse a string with mem suffixes into a number
    3.89 + *	@ptr: Where parse begins
    3.90 + *	@retptr: (output) Pointer to next char after parse completes
    3.91 + *
    3.92 + *	Parses a string into a number.  The number stored at @ptr is
    3.93 + *	potentially suffixed with %K (for kilobytes, or 1024 bytes),
    3.94 + *	%M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or
    3.95 + *	1073741824).  If the number is suffixed with K, M, or G, then
    3.96 + *	the return value is the number multiplied by one kilobyte, one
    3.97 + *	megabyte, or one gigabyte, respectively.
    3.98 + */
    3.99 +
   3.100 +unsigned long long memparse (char *ptr, char **retptr)
   3.101 +{
   3.102 +	unsigned long long ret = simple_strtoull (ptr, retptr, 0);
   3.103 +
   3.104 +	switch (**retptr) {
   3.105 +	case 'G':
   3.106 +	case 'g':
   3.107 +		ret <<= 10;
   3.108 +	case 'M':
   3.109 +	case 'm':
   3.110 +		ret <<= 10;
   3.111 +	case 'K':
   3.112 +	case 'k':
   3.113 +		ret <<= 10;
   3.114 +		(*retptr)++;
   3.115 +	default:
   3.116 +		break;
   3.117 +	}
   3.118 +	return ret;
   3.119 +}
   3.120 +
   3.121 +
   3.122 +EXPORT_SYMBOL(memparse);
   3.123 +EXPORT_SYMBOL(get_option);
   3.124 +EXPORT_SYMBOL(get_options);
     4.1 --- a/xen/arch/ia64/linux/Makefile	Wed Jan 10 08:48:50 2007 -0700
     4.2 +++ b/xen/arch/ia64/linux/Makefile	Wed Jan 10 10:35:24 2007 -0700
     4.3 @@ -4,7 +4,6 @@ subdir-y += sn
     4.4  
     4.5  obj-y += bitop.o
     4.6  obj-y += clear_page.o
     4.7 -obj-y += cmdline.o
     4.8  obj-y += copy_page_mck.o
     4.9  obj-y += efi_stub.o
    4.10  obj-y += extable.o
     5.1 --- a/xen/arch/ia64/linux/README.origin	Wed Jan 10 08:48:50 2007 -0700
     5.2 +++ b/xen/arch/ia64/linux/README.origin	Wed Jan 10 10:35:24 2007 -0700
     5.3 @@ -4,7 +4,6 @@ NOTE: DO NOT commit changes to these fil
     5.4  needs to be changed, move it to ../linux-xen and follow
     5.5  the instructions in the README there.
     5.6  
     5.7 -cmdline.c		-> linux/lib/cmdline.c
     5.8  efi_stub.S		-> linux/arch/ia64/kernel/efi_stub.S
     5.9  extable.c		-> linux/arch/ia64/mm/extable.c
    5.10  hpsim.S			-> linux/arch/ia64/hp/sim/hpsim.S
     6.1 --- a/xen/arch/ia64/linux/cmdline.c	Wed Jan 10 08:48:50 2007 -0700
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,121 +0,0 @@
     6.4 -/*
     6.5 - * linux/lib/cmdline.c
     6.6 - * Helper functions generally used for parsing kernel command line
     6.7 - * and module options.
     6.8 - *
     6.9 - * Code and copyrights come from init/main.c and arch/i386/kernel/setup.c.
    6.10 - *
    6.11 - * This source code is licensed under the GNU General Public License,
    6.12 - * Version 2.  See the file COPYING for more details.
    6.13 - *
    6.14 - * GNU Indent formatting options for this file: -kr -i8 -npsl -pcs
    6.15 - *
    6.16 - */
    6.17 -
    6.18 -#include <linux/module.h>
    6.19 -#include <linux/kernel.h>
    6.20 -#include <linux/string.h>
    6.21 -#include <xen/lib.h>
    6.22 -
    6.23 -
    6.24 -/**
    6.25 - *	get_option - Parse integer from an option string
    6.26 - *	@str: option string
    6.27 - *	@pint: (output) integer value parsed from @str
    6.28 - *
    6.29 - *	Read an int from an option string; if available accept a subsequent
    6.30 - *	comma as well.
    6.31 - *
    6.32 - *	Return values:
    6.33 - *	0 : no int in string
    6.34 - *	1 : int found, no subsequent comma
    6.35 - *	2 : int found including a subsequent comma
    6.36 - */
    6.37 -
    6.38 -int get_option (char **str, int *pint)
    6.39 -{
    6.40 -	char *cur = *str;
    6.41 -
    6.42 -	if (!cur || !(*cur))
    6.43 -		return 0;
    6.44 -	*pint = simple_strtol (cur, str, 0);
    6.45 -	if (cur == *str)
    6.46 -		return 0;
    6.47 -	if (**str == ',') {
    6.48 -		(*str)++;
    6.49 -		return 2;
    6.50 -	}
    6.51 -
    6.52 -	return 1;
    6.53 -}
    6.54 -
    6.55 -/**
    6.56 - *	get_options - Parse a string into a list of integers
    6.57 - *	@str: String to be parsed
    6.58 - *	@nints: size of integer array
    6.59 - *	@ints: integer array
    6.60 - *
    6.61 - *	This function parses a string containing a comma-separated
    6.62 - *	list of integers.  The parse halts when the array is
    6.63 - *	full, or when no more numbers can be retrieved from the
    6.64 - *	string.
    6.65 - *
    6.66 - *	Return value is the character in the string which caused
    6.67 - *	the parse to end (typically a null terminator, if @str is
    6.68 - *	completely parseable).
    6.69 - */
    6.70 - 
    6.71 -char *get_options(const char *str, int nints, int *ints)
    6.72 -{
    6.73 -	int res, i = 1;
    6.74 -
    6.75 -	while (i < nints) {
    6.76 -		res = get_option ((char **)&str, ints + i);
    6.77 -		if (res == 0)
    6.78 -			break;
    6.79 -		i++;
    6.80 -		if (res == 1)
    6.81 -			break;
    6.82 -	}
    6.83 -	ints[0] = i - 1;
    6.84 -	return (char *)str;
    6.85 -}
    6.86 -
    6.87 -/**
    6.88 - *	memparse - parse a string with mem suffixes into a number
    6.89 - *	@ptr: Where parse begins
    6.90 - *	@retptr: (output) Pointer to next char after parse completes
    6.91 - *
    6.92 - *	Parses a string into a number.  The number stored at @ptr is
    6.93 - *	potentially suffixed with %K (for kilobytes, or 1024 bytes),
    6.94 - *	%M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or
    6.95 - *	1073741824).  If the number is suffixed with K, M, or G, then
    6.96 - *	the return value is the number multiplied by one kilobyte, one
    6.97 - *	megabyte, or one gigabyte, respectively.
    6.98 - */
    6.99 -
   6.100 -unsigned long long memparse (char *ptr, char **retptr)
   6.101 -{
   6.102 -	unsigned long long ret = simple_strtoull (ptr, retptr, 0);
   6.103 -
   6.104 -	switch (**retptr) {
   6.105 -	case 'G':
   6.106 -	case 'g':
   6.107 -		ret <<= 10;
   6.108 -	case 'M':
   6.109 -	case 'm':
   6.110 -		ret <<= 10;
   6.111 -	case 'K':
   6.112 -	case 'k':
   6.113 -		ret <<= 10;
   6.114 -		(*retptr)++;
   6.115 -	default:
   6.116 -		break;
   6.117 -	}
   6.118 -	return ret;
   6.119 -}
   6.120 -
   6.121 -
   6.122 -EXPORT_SYMBOL(memparse);
   6.123 -EXPORT_SYMBOL(get_option);
   6.124 -EXPORT_SYMBOL(get_options);