[Cbe-oss-dev] [PATCH] axonram: use only one block device major number
Maxim Shchetynin
maxim at linux.vnet.ibm.com
Fri Apr 25 01:23:15 EST 2008
Hello,
attached is a small patch which lets axonram module to register the only one major number for all Axon's DDR2 DIMMs - without this patch axonram registers separate block device major number per DDR2.
Subject: axonram: use only one block device major number
From: Maxim Shchetynin <maxim at de.ibm.com>
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 at de.ibm.com>
diff -Nuarp linux-2.6.25/arch/powerpc/sysdev/axonram.c linux-2.6.25-axonram/arch/powerpc/sysdev/axonram.c
--- linux-2.6.25/arch/powerpc/sysdev/axonram.c 2008-04-17 04:49:44.000000000 +0200
+++ linux-2.6.25-axonram/arch/powerpc/sysdev/axonram.c 2008-04-23 17:47:25.608826219 +0200
@@ -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;
@@ -226,19 +228,14 @@ axon_ram_probe(struct of_device *device,
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) {
@@ -275,6 +272,8 @@ axon_ram_probe(struct of_device *device,
goto failed;
}
+ azfs_minor += bank->disk->minors;
+
return 0;
failed:
@@ -309,7 +308,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);
@@ -340,6 +338,14 @@ static struct of_platform_driver axon_ra
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);
}
@@ -350,6 +356,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);
Mit freundlichen Grüßen / met vriendelijke groeten / avec regards
Maxim V. Shchetynin
Linux Kernel Entwicklung
IBM Deutschland Entwicklung GmbH
Linux für Cell, Abteilung 3250
Schönaicher Straße 220
71032 Böblingen
Vorsitzender des Aufsichtsrats: Johann Weihen
Geschäftsführung: Herbert Kircher
Sitz der Gesellschaft: Böblingen
Registriergericht: Amtsgericht Stuttgart, HRB 243294
Fahr nur so schnell wie dein Schutzengel fliegen kann!
More information about the cbe-oss-dev
mailing list