ia64/xen-unstable

view xen/arch/ia64/linux/cmdline.c @ 9003:5e751dddf4d0

[IA64] cleanup warning in xen/ia64 (arch/ia64/linux)

These patches fix many issue (ex. panic dom0, oops domU/dom0...).
we will fix compile warnnings one step at a time.

Signed-off-by: Tsunehisa Doi <doi.tsunehisa@jp.fujitsu.com>
Signed-off-by: Kouya SHIMURA <kouya@jp.fujitsu.com>
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Tue Feb 28 10:24:03 2006 -0700 (2006-02-28)
parents 9312a3e8a6f8
children
line source
1 /*
2 * linux/lib/cmdline.c
3 * Helper functions generally used for parsing kernel command line
4 * and module options.
5 *
6 * Code and copyrights come from init/main.c and arch/i386/kernel/setup.c.
7 *
8 * This source code is licensed under the GNU General Public License,
9 * Version 2. See the file COPYING for more details.
10 *
11 * GNU Indent formatting options for this file: -kr -i8 -npsl -pcs
12 *
13 */
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/string.h>
18 #include <xen/lib.h>
21 /**
22 * get_option - Parse integer from an option string
23 * @str: option string
24 * @pint: (output) integer value parsed from @str
25 *
26 * Read an int from an option string; if available accept a subsequent
27 * comma as well.
28 *
29 * Return values:
30 * 0 : no int in string
31 * 1 : int found, no subsequent comma
32 * 2 : int found including a subsequent comma
33 */
35 int get_option (char **str, int *pint)
36 {
37 char *cur = *str;
39 if (!cur || !(*cur))
40 return 0;
41 *pint = simple_strtol (cur, str, 0);
42 if (cur == *str)
43 return 0;
44 if (**str == ',') {
45 (*str)++;
46 return 2;
47 }
49 return 1;
50 }
52 /**
53 * get_options - Parse a string into a list of integers
54 * @str: String to be parsed
55 * @nints: size of integer array
56 * @ints: integer array
57 *
58 * This function parses a string containing a comma-separated
59 * list of integers. The parse halts when the array is
60 * full, or when no more numbers can be retrieved from the
61 * string.
62 *
63 * Return value is the character in the string which caused
64 * the parse to end (typically a null terminator, if @str is
65 * completely parseable).
66 */
68 char *get_options(const char *str, int nints, int *ints)
69 {
70 int res, i = 1;
72 while (i < nints) {
73 res = get_option ((char **)&str, ints + i);
74 if (res == 0)
75 break;
76 i++;
77 if (res == 1)
78 break;
79 }
80 ints[0] = i - 1;
81 return (char *)str;
82 }
84 /**
85 * memparse - parse a string with mem suffixes into a number
86 * @ptr: Where parse begins
87 * @retptr: (output) Pointer to next char after parse completes
88 *
89 * Parses a string into a number. The number stored at @ptr is
90 * potentially suffixed with %K (for kilobytes, or 1024 bytes),
91 * %M (for megabytes, or 1048576 bytes), or %G (for gigabytes, or
92 * 1073741824). If the number is suffixed with K, M, or G, then
93 * the return value is the number multiplied by one kilobyte, one
94 * megabyte, or one gigabyte, respectively.
95 */
97 unsigned long long memparse (char *ptr, char **retptr)
98 {
99 unsigned long long ret = simple_strtoull (ptr, retptr, 0);
101 switch (**retptr) {
102 case 'G':
103 case 'g':
104 ret <<= 10;
105 case 'M':
106 case 'm':
107 ret <<= 10;
108 case 'K':
109 case 'k':
110 ret <<= 10;
111 (*retptr)++;
112 default:
113 break;
114 }
115 return ret;
116 }
119 EXPORT_SYMBOL(memparse);
120 EXPORT_SYMBOL(get_option);
121 EXPORT_SYMBOL(get_options);