]> err.no Git - linux-2.6/commitdiff
powerpc/axonram: Use only one block device major number
authorMaxim Shchetynin <maxim@de.ibm.com>
Tue, 15 Jul 2008 19:51:41 +0000 (05:51 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 22 Jul 2008 00:39:31 +0000 (10:39 +1000)
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>
arch/powerpc/sysdev/axonram.c

index 7f59188cd9a111fdb89cd36a9ae0dfafb3d8cff6..9b639ede06daee6a79fcd089d6da27f8484da7ff 100644 (file)
@@ -57,6 +57,8 @@
 #define AXON_RAM_SECTOR_SIZE           1 << AXON_RAM_SECTOR_SHIFT
 #define AXON_RAM_IRQ_FLAGS             IRQF_SHARED | IRQF_TRIGGER_RISING
 
+static int azfs_major, azfs_minor;
+
 struct axon_ram_bank {
        struct of_device        *device;
        struct gendisk          *disk;
@@ -227,19 +229,14 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
                goto failed;
        }
 
-       bank->disk->first_minor = 0;
+       bank->disk->major = azfs_major;
+       bank->disk->first_minor = azfs_minor;
        bank->disk->fops = &axon_ram_devops;
        bank->disk->private_data = bank;
        bank->disk->driverfs_dev = &device->dev;
 
        sprintf(bank->disk->disk_name, "%s%d",
                        AXON_RAM_DEVICE_NAME, axon_ram_bank_id);
-       bank->disk->major = register_blkdev(0, bank->disk->disk_name);
-       if (bank->disk->major < 0) {
-               dev_err(&device->dev, "Cannot register block device\n");
-               rc = -EFAULT;
-               goto failed;
-       }
 
        bank->disk->queue = blk_alloc_queue(GFP_KERNEL);
        if (bank->disk->queue == NULL) {
@@ -276,6 +273,8 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
                goto failed;
        }
 
+       azfs_minor += bank->disk->minors;
+
        return 0;
 
 failed:
@@ -310,7 +309,6 @@ axon_ram_remove(struct of_device *device)
 
        device_remove_file(&device->dev, &dev_attr_ecc);
        free_irq(bank->irq_id, device);
-       unregister_blkdev(bank->disk->major, bank->disk->disk_name);
        del_gendisk(bank->disk);
        iounmap((void __iomem *) bank->io_addr);
        kfree(bank);
@@ -341,6 +339,14 @@ static struct of_platform_driver axon_ram_driver = {
 static int __init
 axon_ram_init(void)
 {
+       azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
+       if (azfs_major < 0) {
+               printk(KERN_ERR "%s cannot become block device major number\n",
+                               AXON_RAM_MODULE_NAME);
+               return -EFAULT;
+       }
+       azfs_minor = 0;
+
        return of_register_platform_driver(&axon_ram_driver);
 }
 
@@ -351,6 +357,7 @@ static void __exit
 axon_ram_exit(void)
 {
        of_unregister_platform_driver(&axon_ram_driver);
+       unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
 }
 
 module_init(axon_ram_init);