diff options
Diffstat (limited to 'drivers/s390/block/xpram.c')
-rw-r--r-- | drivers/s390/block/xpram.c | 99 |
1 files changed, 18 insertions, 81 deletions
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 4c1e56b9b98d..ca7d51f7eccc 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c | |||
@@ -48,15 +48,6 @@ | |||
48 | #define PRINT_ERR(x...) printk(KERN_ERR XPRAM_NAME " error:" x) | 48 | #define PRINT_ERR(x...) printk(KERN_ERR XPRAM_NAME " error:" x) |
49 | 49 | ||
50 | 50 | ||
51 | static struct sysdev_class xpram_sysclass = { | ||
52 | set_kset_name("xpram"), | ||
53 | }; | ||
54 | |||
55 | static struct sys_device xpram_sys_device = { | ||
56 | .id = 0, | ||
57 | .cls = &xpram_sysclass, | ||
58 | }; | ||
59 | |||
60 | typedef struct { | 51 | typedef struct { |
61 | unsigned int size; /* size of xpram segment in pages */ | 52 | unsigned int size; /* size of xpram segment in pages */ |
62 | unsigned int offset; /* start page of xpram segment */ | 53 | unsigned int offset; /* start page of xpram segment */ |
@@ -71,11 +62,11 @@ static int xpram_devs; | |||
71 | /* | 62 | /* |
72 | * Parameter parsing functions. | 63 | * Parameter parsing functions. |
73 | */ | 64 | */ |
74 | static int devs = XPRAM_DEVS; | 65 | static int __initdata devs = XPRAM_DEVS; |
75 | static unsigned int sizes[XPRAM_MAX_DEVS]; | 66 | static char __initdata *sizes[XPRAM_MAX_DEVS]; |
76 | 67 | ||
77 | module_param(devs, int, 0); | 68 | module_param(devs, int, 0); |
78 | module_param_array(sizes, int, NULL, 0); | 69 | module_param_array(sizes, charp, NULL, 0); |
79 | 70 | ||
80 | MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \ | 71 | MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \ |
81 | "the default is " __MODULE_STRING(XPRAM_DEVS) "\n"); | 72 | "the default is " __MODULE_STRING(XPRAM_DEVS) "\n"); |
@@ -86,59 +77,6 @@ MODULE_PARM_DESC(sizes, "list of device (partition) sizes " \ | |||
86 | "claimed by explicit sizes\n"); | 77 | "claimed by explicit sizes\n"); |
87 | MODULE_LICENSE("GPL"); | 78 | MODULE_LICENSE("GPL"); |
88 | 79 | ||
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 | */ | ||
112 | static 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 | /* | 80 | /* |
143 | * Copy expanded memory page (4kB) into main memory | 81 | * Copy expanded memory page (4kB) into main memory |
144 | * Arguments | 82 | * Arguments |
@@ -357,6 +295,7 @@ static int __init xpram_setup_sizes(unsigned long pages) | |||
357 | { | 295 | { |
358 | unsigned long mem_needed; | 296 | unsigned long mem_needed; |
359 | unsigned long mem_auto; | 297 | unsigned long mem_auto; |
298 | unsigned long long size; | ||
360 | int mem_auto_no; | 299 | int mem_auto_no; |
361 | int i; | 300 | int i; |
362 | 301 | ||
@@ -374,7 +313,19 @@ static int __init xpram_setup_sizes(unsigned long pages) | |||
374 | mem_needed = 0; | 313 | mem_needed = 0; |
375 | mem_auto_no = 0; | 314 | mem_auto_no = 0; |
376 | for (i = 0; i < xpram_devs; i++) { | 315 | for (i = 0; i < xpram_devs; i++) { |
377 | xpram_sizes[i] = (sizes[i] + 3) & -4UL; | 316 | if (sizes[i]) { |
317 | size = simple_strtoull(sizes[i], &sizes[i], 0); | ||
318 | switch (sizes[i][0]) { | ||
319 | case 'g': | ||
320 | case 'G': | ||
321 | size <<= 20; | ||
322 | break; | ||
323 | case 'm': | ||
324 | case 'M': | ||
325 | size <<= 10; | ||
326 | } | ||
327 | xpram_sizes[i] = (size + 3) & -4UL; | ||
328 | } | ||
378 | if (xpram_sizes[i]) | 329 | if (xpram_sizes[i]) |
379 | mem_needed += xpram_sizes[i]; | 330 | mem_needed += xpram_sizes[i]; |
380 | else | 331 | else |
@@ -491,8 +442,6 @@ static void __exit xpram_exit(void) | |||
491 | } | 442 | } |
492 | unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME); | 443 | unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME); |
493 | blk_cleanup_queue(xpram_queue); | 444 | blk_cleanup_queue(xpram_queue); |
494 | sysdev_unregister(&xpram_sys_device); | ||
495 | sysdev_class_unregister(&xpram_sysclass); | ||
496 | } | 445 | } |
497 | 446 | ||
498 | static int __init xpram_init(void) | 447 | static int __init xpram_init(void) |
@@ -510,19 +459,7 @@ static int __init xpram_init(void) | |||
510 | rc = xpram_setup_sizes(xpram_pages); | 459 | rc = xpram_setup_sizes(xpram_pages); |
511 | if (rc) | 460 | if (rc) |
512 | return rc; | 461 | return rc; |
513 | rc = sysdev_class_register(&xpram_sysclass); | 462 | return xpram_setup_blkdev(); |
514 | if (rc) | ||
515 | return rc; | ||
516 | |||
517 | rc = sysdev_register(&xpram_sys_device); | ||
518 | if (rc) { | ||
519 | sysdev_class_unregister(&xpram_sysclass); | ||
520 | return rc; | ||
521 | } | ||
522 | rc = xpram_setup_blkdev(); | ||
523 | if (rc) | ||
524 | sysdev_unregister(&xpram_sys_device); | ||
525 | return rc; | ||
526 | } | 463 | } |
527 | 464 | ||
528 | module_init(xpram_init); | 465 | module_init(xpram_init); |