diff options
Diffstat (limited to 'arch/powerpc/sysdev/axonram.c')
-rw-r--r-- | arch/powerpc/sysdev/axonram.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 7f59188cd9a1..9e105cbc5e5f 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c | |||
@@ -57,6 +57,8 @@ | |||
57 | #define AXON_RAM_SECTOR_SIZE 1 << AXON_RAM_SECTOR_SHIFT | 57 | #define AXON_RAM_SECTOR_SIZE 1 << AXON_RAM_SECTOR_SHIFT |
58 | #define AXON_RAM_IRQ_FLAGS IRQF_SHARED | IRQF_TRIGGER_RISING | 58 | #define AXON_RAM_IRQ_FLAGS IRQF_SHARED | IRQF_TRIGGER_RISING |
59 | 59 | ||
60 | static int azfs_major, azfs_minor; | ||
61 | |||
60 | struct axon_ram_bank { | 62 | struct axon_ram_bank { |
61 | struct of_device *device; | 63 | struct of_device *device; |
62 | struct gendisk *disk; | 64 | struct gendisk *disk; |
@@ -148,7 +150,10 @@ axon_ram_direct_access(struct block_device *device, sector_t sector, | |||
148 | struct axon_ram_bank *bank = device->bd_disk->private_data; | 150 | struct axon_ram_bank *bank = device->bd_disk->private_data; |
149 | loff_t offset; | 151 | loff_t offset; |
150 | 152 | ||
151 | offset = sector << AXON_RAM_SECTOR_SHIFT; | 153 | offset = sector; |
154 | if (device->bd_part != NULL) | ||
155 | offset += device->bd_part->start_sect; | ||
156 | offset <<= AXON_RAM_SECTOR_SHIFT; | ||
152 | if (offset >= bank->size) { | 157 | if (offset >= bank->size) { |
153 | dev_err(&bank->device->dev, "Access outside of address space\n"); | 158 | dev_err(&bank->device->dev, "Access outside of address space\n"); |
154 | return -ERANGE; | 159 | return -ERANGE; |
@@ -227,19 +232,14 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) | |||
227 | goto failed; | 232 | goto failed; |
228 | } | 233 | } |
229 | 234 | ||
230 | bank->disk->first_minor = 0; | 235 | bank->disk->major = azfs_major; |
236 | bank->disk->first_minor = azfs_minor; | ||
231 | bank->disk->fops = &axon_ram_devops; | 237 | bank->disk->fops = &axon_ram_devops; |
232 | bank->disk->private_data = bank; | 238 | bank->disk->private_data = bank; |
233 | bank->disk->driverfs_dev = &device->dev; | 239 | bank->disk->driverfs_dev = &device->dev; |
234 | 240 | ||
235 | sprintf(bank->disk->disk_name, "%s%d", | 241 | sprintf(bank->disk->disk_name, "%s%d", |
236 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id); | 242 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id); |
237 | bank->disk->major = register_blkdev(0, bank->disk->disk_name); | ||
238 | if (bank->disk->major < 0) { | ||
239 | dev_err(&device->dev, "Cannot register block device\n"); | ||
240 | rc = -EFAULT; | ||
241 | goto failed; | ||
242 | } | ||
243 | 243 | ||
244 | bank->disk->queue = blk_alloc_queue(GFP_KERNEL); | 244 | bank->disk->queue = blk_alloc_queue(GFP_KERNEL); |
245 | if (bank->disk->queue == NULL) { | 245 | if (bank->disk->queue == NULL) { |
@@ -276,6 +276,8 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) | |||
276 | goto failed; | 276 | goto failed; |
277 | } | 277 | } |
278 | 278 | ||
279 | azfs_minor += bank->disk->minors; | ||
280 | |||
279 | return 0; | 281 | return 0; |
280 | 282 | ||
281 | failed: | 283 | failed: |
@@ -310,7 +312,6 @@ axon_ram_remove(struct of_device *device) | |||
310 | 312 | ||
311 | device_remove_file(&device->dev, &dev_attr_ecc); | 313 | device_remove_file(&device->dev, &dev_attr_ecc); |
312 | free_irq(bank->irq_id, device); | 314 | free_irq(bank->irq_id, device); |
313 | unregister_blkdev(bank->disk->major, bank->disk->disk_name); | ||
314 | del_gendisk(bank->disk); | 315 | del_gendisk(bank->disk); |
315 | iounmap((void __iomem *) bank->io_addr); | 316 | iounmap((void __iomem *) bank->io_addr); |
316 | kfree(bank); | 317 | kfree(bank); |
@@ -341,6 +342,14 @@ static struct of_platform_driver axon_ram_driver = { | |||
341 | static int __init | 342 | static int __init |
342 | axon_ram_init(void) | 343 | axon_ram_init(void) |
343 | { | 344 | { |
345 | azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); | ||
346 | if (azfs_major < 0) { | ||
347 | printk(KERN_ERR "%s cannot become block device major number\n", | ||
348 | AXON_RAM_MODULE_NAME); | ||
349 | return -EFAULT; | ||
350 | } | ||
351 | azfs_minor = 0; | ||
352 | |||
344 | return of_register_platform_driver(&axon_ram_driver); | 353 | return of_register_platform_driver(&axon_ram_driver); |
345 | } | 354 | } |
346 | 355 | ||
@@ -351,6 +360,7 @@ static void __exit | |||
351 | axon_ram_exit(void) | 360 | axon_ram_exit(void) |
352 | { | 361 | { |
353 | of_unregister_platform_driver(&axon_ram_driver); | 362 | of_unregister_platform_driver(&axon_ram_driver); |
363 | unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); | ||
354 | } | 364 | } |
355 | 365 | ||
356 | module_init(axon_ram_init); | 366 | module_init(axon_ram_init); |