aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/block
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2006-07-12 10:40:14 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2006-07-12 10:40:14 -0400
commit5c898ba9d4b6c14fdd367b96e3641c2508b4a4a9 (patch)
treeb55464fbfb94ef31a99deeca1ef327f21b593a5f /drivers/s390/block
parentabdba61a4361e5d47c1633c9e7f56d32dbf4aae8 (diff)
[S390] xpram module parameter parsing.
The module parameters for xpram are not or in a wrong way parsed. The xpram module uses the module_param_array directive with an int parameter which causes the kernel to automatically parse the passed numbers. This will cause errors if arguments are omitted or cause wrong results if arguments have size qualifiers. Use module_param_array with charp and parse the arguments later. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/block')
-rw-r--r--drivers/s390/block/xpram.c63
1 files changed, 6 insertions, 57 deletions
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index 4c1e56b9b98d..4cd879cb9bdd 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -71,11 +71,11 @@ static int xpram_devs;
71/* 71/*
72 * Parameter parsing functions. 72 * Parameter parsing functions.
73 */ 73 */
74static int devs = XPRAM_DEVS; 74static int __initdata devs = XPRAM_DEVS;
75static unsigned int sizes[XPRAM_MAX_DEVS]; 75static char __initdata *sizes[XPRAM_MAX_DEVS];
76 76
77module_param(devs, int, 0); 77module_param(devs, int, 0);
78module_param_array(sizes, int, NULL, 0); 78module_param_array(sizes, charp, NULL, 0);
79 79
80MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \ 80MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \
81 "the default is " __MODULE_STRING(XPRAM_DEVS) "\n"); 81 "the default is " __MODULE_STRING(XPRAM_DEVS) "\n");
@@ -86,59 +86,6 @@ MODULE_PARM_DESC(sizes, "list of device (partition) sizes " \
86 "claimed by explicit sizes\n"); 86 "claimed by explicit sizes\n");
87MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL");
88 88
89#ifndef MODULE
90/*
91 * Parses the kernel parameters given in the kernel parameter line.
92 * The expected format is
93 * <number_of_partitions>[","<partition_size>]*
94 * where
95 * devices is a positive integer that initializes xpram_devs
96 * each size is a non-negative integer possibly followed by a
97 * magnitude (k,K,m,M,g,G), the list of sizes initialises
98 * xpram_sizes
99 *
100 * Arguments
101 * str: substring of kernel parameter line that contains xprams
102 * kernel parameters.
103 *
104 * Result 0 on success, -EINVAL else -- only for Version > 2.3
105 *
106 * Side effects
107 * the global variabls devs is set to the value of
108 * <number_of_partitions> and sizes[i] is set to the i-th
109 * partition size (if provided). A parsing error of a value
110 * results in this value being set to -EINVAL.
111 */
112static int __init xpram_setup (char *str)
113{
114 char *cp;
115 int i;
116
117 devs = simple_strtoul(str, &cp, 10);
118 if (cp <= str || devs > XPRAM_MAX_DEVS)
119 return 0;
120 for (i = 0; (i < devs) && (*cp++ == ','); i++) {
121 sizes[i] = simple_strtoul(cp, &cp, 10);
122 if (*cp == 'g' || *cp == 'G') {
123 sizes[i] <<= 20;
124 cp++;
125 } else if (*cp == 'm' || *cp == 'M') {
126 sizes[i] <<= 10;
127 cp++;
128 } else if (*cp == 'k' || *cp == 'K')
129 cp++;
130 while (isspace(*cp)) cp++;
131 }
132 if (*cp == ',' && i >= devs)
133 PRINT_WARN("partition sizes list has too many entries.\n");
134 else if (*cp != 0)
135 PRINT_WARN("ignored '%s' at end of parameter string.\n", cp);
136 return 1;
137}
138
139__setup("xpram_parts=", xpram_setup);
140#endif
141
142/* 89/*
143 * Copy expanded memory page (4kB) into main memory 90 * Copy expanded memory page (4kB) into main memory
144 * Arguments 91 * Arguments
@@ -374,7 +321,9 @@ static int __init xpram_setup_sizes(unsigned long pages)
374 mem_needed = 0; 321 mem_needed = 0;
375 mem_auto_no = 0; 322 mem_auto_no = 0;
376 for (i = 0; i < xpram_devs; i++) { 323 for (i = 0; i < xpram_devs; i++) {
377 xpram_sizes[i] = (sizes[i] + 3) & -4UL; 324 if (sizes[i])
325 xpram_sizes[i] =
326 (memparse(sizes[i], &sizes[i]) + 3) & -4UL;
378 if (xpram_sizes[i]) 327 if (xpram_sizes[i])
379 mem_needed += xpram_sizes[i]; 328 mem_needed += xpram_sizes[i];
380 else 329 else