diff options
author | Maxim Shchetynin <maxim@de.ibm.com> | 2008-07-15 15:51:41 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-21 20:39:31 -0400 |
commit | 9a23409b69440e76d34dc23846cae44f46f60d98 (patch) | |
tree | 77b164c7a07f9e2edfd5efc71b79a986ed3071df /arch/powerpc | |
parent | 18ad7a61e1b700dfe177fabf1c350b4f5d4da8ac (diff) |
powerpc/axonram: Use only one block device major number
Axonram module registers one block device for each DDR2 DIMM found
on a system. This means that each DDR2 DIMM becomes its own block device
major number. This patch lets axonram module to register the only one
block device for all DDR2 DIMMs which also spares kernel resources.
Signed-off-by: Maxim Shchetynin <maxim@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/sysdev/axonram.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 7f59188cd9a1..9b639ede06da 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; |
@@ -227,19 +229,14 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) | |||
227 | goto failed; | 229 | goto failed; |
228 | } | 230 | } |
229 | 231 | ||
230 | bank->disk->first_minor = 0; | 232 | bank->disk->major = azfs_major; |
233 | bank->disk->first_minor = azfs_minor; | ||
231 | bank->disk->fops = &axon_ram_devops; | 234 | bank->disk->fops = &axon_ram_devops; |
232 | bank->disk->private_data = bank; | 235 | bank->disk->private_data = bank; |
233 | bank->disk->driverfs_dev = &device->dev; | 236 | bank->disk->driverfs_dev = &device->dev; |
234 | 237 | ||
235 | sprintf(bank->disk->disk_name, "%s%d", | 238 | sprintf(bank->disk->disk_name, "%s%d", |
236 | AXON_RAM_DEVICE_NAME, axon_ram_bank_id); | 239 | 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 | 240 | ||
244 | bank->disk->queue = blk_alloc_queue(GFP_KERNEL); | 241 | bank->disk->queue = blk_alloc_queue(GFP_KERNEL); |
245 | if (bank->disk->queue == NULL) { | 242 | if (bank->disk->queue == NULL) { |
@@ -276,6 +273,8 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id) | |||
276 | goto failed; | 273 | goto failed; |
277 | } | 274 | } |
278 | 275 | ||
276 | azfs_minor += bank->disk->minors; | ||
277 | |||
279 | return 0; | 278 | return 0; |
280 | 279 | ||
281 | failed: | 280 | failed: |
@@ -310,7 +309,6 @@ axon_ram_remove(struct of_device *device) | |||
310 | 309 | ||
311 | device_remove_file(&device->dev, &dev_attr_ecc); | 310 | device_remove_file(&device->dev, &dev_attr_ecc); |
312 | free_irq(bank->irq_id, device); | 311 | free_irq(bank->irq_id, device); |
313 | unregister_blkdev(bank->disk->major, bank->disk->disk_name); | ||
314 | del_gendisk(bank->disk); | 312 | del_gendisk(bank->disk); |
315 | iounmap((void __iomem *) bank->io_addr); | 313 | iounmap((void __iomem *) bank->io_addr); |
316 | kfree(bank); | 314 | kfree(bank); |
@@ -341,6 +339,14 @@ static struct of_platform_driver axon_ram_driver = { | |||
341 | static int __init | 339 | static int __init |
342 | axon_ram_init(void) | 340 | axon_ram_init(void) |
343 | { | 341 | { |
342 | azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); | ||
343 | if (azfs_major < 0) { | ||
344 | printk(KERN_ERR "%s cannot become block device major number\n", | ||
345 | AXON_RAM_MODULE_NAME); | ||
346 | return -EFAULT; | ||
347 | } | ||
348 | azfs_minor = 0; | ||
349 | |||
344 | return of_register_platform_driver(&axon_ram_driver); | 350 | return of_register_platform_driver(&axon_ram_driver); |
345 | } | 351 | } |
346 | 352 | ||
@@ -351,6 +357,7 @@ static void __exit | |||
351 | axon_ram_exit(void) | 357 | axon_ram_exit(void) |
352 | { | 358 | { |
353 | of_unregister_platform_driver(&axon_ram_driver); | 359 | of_unregister_platform_driver(&axon_ram_driver); |
360 | unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME); | ||
354 | } | 361 | } |
355 | 362 | ||
356 | module_init(axon_ram_init); | 363 | module_init(axon_ram_init); |