blob: 3df5d68d09f0b6f8adc36125a48c1432186e6220 [file] [log] [blame]
Greg Kroah-Hartman6a55d2c2017-11-14 18:38:00 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Xpram.c -- the S/390 expanded memory RAM-disk
4 *
5 * significant parts of this code are based on
6 * the sbull device driver presented in
7 * A. Rubini: Linux Device Drivers
8 *
9 * Author of XPRAM specific coding: Reinhard Buendgen
10 * buendgen@de.ibm.com
11 * Rewrite for 2.5: Martin Schwidefsky <schwidefsky@de.ibm.com>
12 *
13 * External interfaces:
14 * Interfaces to linux kernel
15 * xpram_setup: read kernel parameters
16 * Device specific file operations
17 * xpram_iotcl
18 * xpram_open
19 *
20 * "ad-hoc" partitioning:
21 * the expanded memory can be partitioned among several devices
22 * (with different minors). The partitioning set up can be
23 * set by kernel or module parameters (int devs & int sizes[])
24 *
25 * Potential future improvements:
26 * generic hard disk support to replace ad-hoc partitioning
27 */
28
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +010029#define KMSG_COMPONENT "xpram"
30#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/module.h>
33#include <linux/moduleparam.h>
34#include <linux/ctype.h> /* isdigit, isxdigit */
35#include <linux/errno.h>
36#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/blkdev.h>
38#include <linux/blkpg.h>
39#include <linux/hdreg.h> /* HDIO_GETGEO */
Kay Sieversedbaa602011-12-21 16:26:03 -080040#include <linux/device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/bio.h>
Michael Holzheu14532092009-06-16 10:30:27 +020042#include <linux/suspend.h>
43#include <linux/platform_device.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090044#include <linux/gfp.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080045#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#define XPRAM_NAME "xpram"
48#define XPRAM_DEVS 1 /* one partition */
49#define XPRAM_MAX_DEVS 32 /* maximal number of devices (partitions) */
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051typedef struct {
52 unsigned int size; /* size of xpram segment in pages */
53 unsigned int offset; /* start page of xpram segment */
54} xpram_device_t;
55
56static xpram_device_t xpram_devices[XPRAM_MAX_DEVS];
57static unsigned int xpram_sizes[XPRAM_MAX_DEVS];
58static struct gendisk *xpram_disks[XPRAM_MAX_DEVS];
Martin Schwidefsky3ce66092008-10-10 21:33:24 +020059static struct request_queue *xpram_queues[XPRAM_MAX_DEVS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static unsigned int xpram_pages;
61static int xpram_devs;
62
63/*
64 * Parameter parsing functions.
65 */
Martin Schwidefsky0c0db032011-03-03 17:56:05 +010066static int devs = XPRAM_DEVS;
67static char *sizes[XPRAM_MAX_DEVS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69module_param(devs, int, 0);
Heiko Carstens5c898ba2006-07-12 16:40:14 +020070module_param_array(sizes, charp, NULL, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72MODULE_PARM_DESC(devs, "number of devices (\"partitions\"), " \
73 "the default is " __MODULE_STRING(XPRAM_DEVS) "\n");
74MODULE_PARM_DESC(sizes, "list of device (partition) sizes " \
75 "the defaults are 0s \n" \
76 "All devices with size 0 equally partition the "
77 "remaining space on the expanded strorage not "
78 "claimed by explicit sizes\n");
79MODULE_LICENSE("GPL");
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081/*
82 * Copy expanded memory page (4kB) into main memory
83 * Arguments
84 * page_addr: address of target page
85 * xpage_index: index of expandeded memory page
86 * Return value
87 * 0: if operation succeeds
88 * -EIO: if pgin failed
89 * -ENXIO: if xpram has vanished
90 */
91static int xpram_page_in (unsigned long page_addr, unsigned int xpage_index)
92{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020093 int cc = 2; /* return unused cc 2 if pgin traps */
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020095 asm volatile(
96 " .insn rre,0xb22e0000,%1,%2\n" /* pgin %1,%2 */
97 "0: ipm %0\n"
98 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200100 EX_TABLE(0b,1b)
101 : "+d" (cc) : "a" (__pa(page_addr)), "d" (xpage_index) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 if (cc == 3)
103 return -ENXIO;
Martin Schwidefsky8df22b42008-07-14 09:59:24 +0200104 if (cc == 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 return -ENXIO;
Martin Schwidefsky8df22b42008-07-14 09:59:24 +0200106 if (cc == 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 return 0;
109}
110
111/*
112 * Copy a 4kB page of main memory to an expanded memory page
113 * Arguments
114 * page_addr: address of source page
115 * xpage_index: index of expandeded memory page
116 * Return value
117 * 0: if operation succeeds
118 * -EIO: if pgout failed
119 * -ENXIO: if xpram has vanished
120 */
121static long xpram_page_out (unsigned long page_addr, unsigned int xpage_index)
122{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200123 int cc = 2; /* return unused cc 2 if pgin traps */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200125 asm volatile(
126 " .insn rre,0xb22f0000,%1,%2\n" /* pgout %1,%2 */
127 "0: ipm %0\n"
128 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 "1:\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200130 EX_TABLE(0b,1b)
131 : "+d" (cc) : "a" (__pa(page_addr)), "d" (xpage_index) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 if (cc == 3)
133 return -ENXIO;
Martin Schwidefsky8df22b42008-07-14 09:59:24 +0200134 if (cc == 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return -ENXIO;
Martin Schwidefsky8df22b42008-07-14 09:59:24 +0200136 if (cc == 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 return 0;
139}
140
141/*
142 * Check if xpram is available.
143 */
Michael Holzheu14532092009-06-16 10:30:27 +0200144static int xpram_present(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145{
146 unsigned long mem_page;
147 int rc;
148
149 mem_page = (unsigned long) __get_free_page(GFP_KERNEL);
150 if (!mem_page)
151 return -ENOMEM;
152 rc = xpram_page_in(mem_page, 0);
153 free_page(mem_page);
154 return rc ? -ENXIO : 0;
155}
156
157/*
158 * Return index of the last available xpram page.
159 */
Michael Holzheu14532092009-06-16 10:30:27 +0200160static unsigned long xpram_highest_page_index(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
162 unsigned int page_index, add_bit;
163 unsigned long mem_page;
164
165 mem_page = (unsigned long) __get_free_page(GFP_KERNEL);
166 if (!mem_page)
167 return 0;
168
169 page_index = 0;
170 add_bit = 1ULL << (sizeof(unsigned int)*8 - 1);
171 while (add_bit > 0) {
172 if (xpram_page_in(mem_page, page_index | add_bit) == 0)
173 page_index |= add_bit;
174 add_bit >>= 1;
175 }
176
177 free_page (mem_page);
178
179 return page_index;
180}
181
182/*
183 * Block device make request function.
184 */
Jens Axboedece1632015-11-05 10:41:16 -0700185static blk_qc_t xpram_make_request(struct request_queue *q, struct bio *bio)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Christoph Hellwig74d46992017-08-23 19:10:32 +0200187 xpram_device_t *xdev = bio->bi_disk->private_data;
Kent Overstreet79886132013-11-23 17:19:00 -0800188 struct bio_vec bvec;
189 struct bvec_iter iter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 unsigned int index;
191 unsigned long page_addr;
192 unsigned long bytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
NeilBrownaf67c312017-06-18 14:38:57 +1000194 blk_queue_split(q, &bio);
Kent Overstreet54efd502015-04-23 22:37:18 -0700195
Kent Overstreet4f024f32013-10-11 15:44:27 -0700196 if ((bio->bi_iter.bi_sector & 7) != 0 ||
197 (bio->bi_iter.bi_size & 4095) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 /* Request is not page-aligned. */
199 goto fail;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700200 if ((bio->bi_iter.bi_size >> 12) > xdev->size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 /* Request size is no page-aligned. */
202 goto fail;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700203 if ((bio->bi_iter.bi_sector >> 3) > 0xffffffffU - xdev->offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 goto fail;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700205 index = (bio->bi_iter.bi_sector >> 3) + xdev->offset;
Kent Overstreet79886132013-11-23 17:19:00 -0800206 bio_for_each_segment(bvec, bio, iter) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 page_addr = (unsigned long)
Kent Overstreet79886132013-11-23 17:19:00 -0800208 kmap(bvec.bv_page) + bvec.bv_offset;
209 bytes = bvec.bv_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 if ((page_addr & 4095) != 0 || (bytes & 4095) != 0)
211 /* More paranoia. */
212 goto fail;
213 while (bytes > 0) {
214 if (bio_data_dir(bio) == READ) {
215 if (xpram_page_in(page_addr, index) != 0)
216 goto fail;
217 } else {
218 if (xpram_page_out(page_addr, index) != 0)
219 goto fail;
220 }
221 page_addr += 4096;
222 bytes -= 4096;
223 index++;
224 }
225 }
Christoph Hellwig4246a0b2015-07-20 15:29:37 +0200226 bio_endio(bio);
Jens Axboedece1632015-11-05 10:41:16 -0700227 return BLK_QC_T_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228fail:
NeilBrown6712ecf2007-09-27 12:47:43 +0200229 bio_io_error(bio);
Jens Axboedece1632015-11-05 10:41:16 -0700230 return BLK_QC_T_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231}
232
Christoph Hellwiga885c8c2006-01-08 01:02:50 -0800233static int xpram_getgeo(struct block_device *bdev, struct hd_geometry *geo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 unsigned long size;
Christoph Hellwiga885c8c2006-01-08 01:02:50 -0800236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 /*
238 * get geometry: we have to fake one... trim the size to a
239 * multiple of 64 (32k): tell we have 16 sectors, 4 heads,
240 * whatever cylinders. Tell also that data starts at sector. 4.
241 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 size = (xpram_pages * 8) & ~0x3f;
Christoph Hellwiga885c8c2006-01-08 01:02:50 -0800243 geo->cylinders = size >> 6;
244 geo->heads = 4;
245 geo->sectors = 16;
246 geo->start = 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 return 0;
248}
249
Alexey Dobriyan83d5cde2009-09-21 17:01:13 -0700250static const struct block_device_operations xpram_devops =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251{
252 .owner = THIS_MODULE,
Christoph Hellwiga885c8c2006-01-08 01:02:50 -0800253 .getgeo = xpram_getgeo,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
256/*
257 * Setup xpram_sizes array.
258 */
259static int __init xpram_setup_sizes(unsigned long pages)
260{
261 unsigned long mem_needed;
262 unsigned long mem_auto;
Heiko Carstensf257b062006-07-17 16:09:23 +0200263 unsigned long long size;
Sebastian Ott7e2e2b92014-01-20 16:43:33 +0100264 char *sizes_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 int mem_auto_no;
266 int i;
267
268 /* Check number of devices. */
269 if (devs <= 0 || devs > XPRAM_MAX_DEVS) {
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100270 pr_err("%d is not a valid number of XPRAM devices\n",devs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 return -EINVAL;
272 }
273 xpram_devs = devs;
274
275 /*
276 * Copy sizes array to xpram_sizes and align partition
277 * sizes to page boundary.
278 */
279 mem_needed = 0;
280 mem_auto_no = 0;
281 for (i = 0; i < xpram_devs; i++) {
Heiko Carstensf257b062006-07-17 16:09:23 +0200282 if (sizes[i]) {
Sebastian Ott7e2e2b92014-01-20 16:43:33 +0100283 size = simple_strtoull(sizes[i], &sizes_end, 0);
284 switch (*sizes_end) {
Heiko Carstensf257b062006-07-17 16:09:23 +0200285 case 'g':
286 case 'G':
287 size <<= 20;
288 break;
289 case 'm':
290 case 'M':
291 size <<= 10;
292 }
293 xpram_sizes[i] = (size + 3) & -4UL;
294 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 if (xpram_sizes[i])
296 mem_needed += xpram_sizes[i];
297 else
298 mem_auto_no++;
299 }
300
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100301 pr_info(" number of devices (partitions): %d \n", xpram_devs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 for (i = 0; i < xpram_devs; i++) {
303 if (xpram_sizes[i])
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100304 pr_info(" size of partition %d: %u kB\n",
305 i, xpram_sizes[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 else
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100307 pr_info(" size of partition %d to be set "
308 "automatically\n",i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 }
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100310 pr_info(" memory needed (for sized partitions): %lu kB\n",
311 mem_needed);
312 pr_info(" partitions to be sized automatically: %d\n",
313 mem_auto_no);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 if (mem_needed > pages * 4) {
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100316 pr_err("Not enough expanded memory available\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 return -EINVAL;
318 }
319
320 /*
321 * partitioning:
322 * xpram_sizes[i] != 0; partition i has size xpram_sizes[i] kB
323 * else: ; all partitions with zero xpram_sizes[i]
324 * partition equally the remaining space
325 */
326 if (mem_auto_no) {
327 mem_auto = ((pages - mem_needed / 4) / mem_auto_no) * 4;
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100328 pr_info(" automatically determined "
329 "partition size: %lu kB\n", mem_auto);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 for (i = 0; i < xpram_devs; i++)
331 if (xpram_sizes[i] == 0)
332 xpram_sizes[i] = mem_auto;
333 }
334 return 0;
335}
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337static int __init xpram_setup_blkdev(void)
338{
339 unsigned long offset;
340 int i, rc = -ENOMEM;
341
342 for (i = 0; i < xpram_devs; i++) {
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200343 xpram_disks[i] = alloc_disk(1);
344 if (!xpram_disks[i])
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 goto out;
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200346 xpram_queues[i] = blk_alloc_queue(GFP_KERNEL);
347 if (!xpram_queues[i]) {
348 put_disk(xpram_disks[i]);
349 goto out;
350 }
Bart Van Assche8b904b52018-03-07 17:10:10 -0800351 blk_queue_flag_set(QUEUE_FLAG_NONROT, xpram_queues[i]);
352 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, xpram_queues[i]);
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200353 blk_queue_make_request(xpram_queues[i], xpram_make_request);
Martin K. Petersene1defc42009-05-22 17:17:49 -0400354 blk_queue_logical_block_size(xpram_queues[i], 4096);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 }
356
357 /*
358 * Register xpram major.
359 */
360 rc = register_blkdev(XPRAM_MAJOR, XPRAM_NAME);
361 if (rc < 0)
362 goto out;
363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 * Setup device structures.
366 */
367 offset = 0;
368 for (i = 0; i < xpram_devs; i++) {
369 struct gendisk *disk = xpram_disks[i];
370
371 xpram_devices[i].size = xpram_sizes[i] / 4;
372 xpram_devices[i].offset = offset;
373 offset += xpram_devices[i].size;
374 disk->major = XPRAM_MAJOR;
375 disk->first_minor = i;
376 disk->fops = &xpram_devops;
377 disk->private_data = &xpram_devices[i];
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200378 disk->queue = xpram_queues[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 sprintf(disk->disk_name, "slram%d", i);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 set_capacity(disk, xpram_sizes[i] << 1);
381 add_disk(disk);
382 }
383
384 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385out:
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200386 while (i--) {
387 blk_cleanup_queue(xpram_queues[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 put_disk(xpram_disks[i]);
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200389 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 return rc;
391}
392
393/*
Michael Holzheu14532092009-06-16 10:30:27 +0200394 * Resume failed: Print error message and call panic.
395 */
396static void xpram_resume_error(const char *message)
397{
Christian Borntraeger2c48c4d2009-07-07 16:37:11 +0200398 pr_err("Resuming the system failed: %s\n", message);
Michael Holzheu14532092009-06-16 10:30:27 +0200399 panic("xpram resume error\n");
400}
401
402/*
403 * Check if xpram setup changed between suspend and resume.
404 */
405static int xpram_restore(struct device *dev)
406{
407 if (!xpram_pages)
408 return 0;
409 if (xpram_present() != 0)
410 xpram_resume_error("xpram disappeared");
411 if (xpram_pages != xpram_highest_page_index() + 1)
412 xpram_resume_error("Size of xpram changed");
Michael Holzheu14532092009-06-16 10:30:27 +0200413 return 0;
414}
415
Alexey Dobriyan47145212009-12-14 18:00:08 -0800416static const struct dev_pm_ops xpram_pm_ops = {
Michael Holzheu14532092009-06-16 10:30:27 +0200417 .restore = xpram_restore,
418};
419
420static struct platform_driver xpram_pdrv = {
421 .driver = {
422 .name = XPRAM_NAME,
Michael Holzheu14532092009-06-16 10:30:27 +0200423 .pm = &xpram_pm_ops,
424 },
425};
426
427static struct platform_device *xpram_pdev;
428
429/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 * Finally, the init/exit functions.
431 */
432static void __exit xpram_exit(void)
433{
434 int i;
435 for (i = 0; i < xpram_devs; i++) {
436 del_gendisk(xpram_disks[i]);
Martin Schwidefsky3ce66092008-10-10 21:33:24 +0200437 blk_cleanup_queue(xpram_queues[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 put_disk(xpram_disks[i]);
439 }
440 unregister_blkdev(XPRAM_MAJOR, XPRAM_NAME);
Michael Holzheu14532092009-06-16 10:30:27 +0200441 platform_device_unregister(xpram_pdev);
442 platform_driver_unregister(&xpram_pdrv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443}
444
445static int __init xpram_init(void)
446{
447 int rc;
448
449 /* Find out size of expanded memory. */
450 if (xpram_present() != 0) {
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100451 pr_err("No expanded memory available\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 return -ENODEV;
453 }
Christian Borntraegere620c492006-09-20 15:59:32 +0200454 xpram_pages = xpram_highest_page_index() + 1;
Martin Schwidefskyd1c2f892008-12-25 13:39:31 +0100455 pr_info(" %u pages expanded memory found (%lu KB).\n",
456 xpram_pages, (unsigned long) xpram_pages*4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 rc = xpram_setup_sizes(xpram_pages);
458 if (rc)
459 return rc;
Michael Holzheu14532092009-06-16 10:30:27 +0200460 rc = platform_driver_register(&xpram_pdrv);
461 if (rc)
462 return rc;
463 xpram_pdev = platform_device_register_simple(XPRAM_NAME, -1, NULL, 0);
464 if (IS_ERR(xpram_pdev)) {
465 rc = PTR_ERR(xpram_pdev);
466 goto fail_platform_driver_unregister;
467 }
468 rc = xpram_setup_blkdev();
469 if (rc)
470 goto fail_platform_device_unregister;
471 return 0;
472
473fail_platform_device_unregister:
474 platform_device_unregister(xpram_pdev);
475fail_platform_driver_unregister:
476 platform_driver_unregister(&xpram_pdrv);
477 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
480module_init(xpram_init);
481module_exit(xpram_exit);