Commit 4e493886 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (2/25) Removing ->nr_real

	Since ->nr_real is always 1 now, we can remove that field completely.
Removed the last remnants of switch in disk_name() (it could be killed
a long time ago, I just forgot to remove the last two cases when md and i2o
got converted).  Collapsed several instances of
disk->part[minor - disk->first_minor] - in cases when we know that we deal
with disk->part[0].
parent b3152267
...@@ -1280,7 +1280,6 @@ static void mfm_geninit (void) ...@@ -1280,7 +1280,6 @@ static void mfm_geninit (void)
outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */ outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */
for (i = 0; i < mfm_drives; i++) { for (i = 0; i < mfm_drives; i++) {
mfm_gendisk[i].nr_real = 1;
add_gendisk(mfm_gendisk + i); add_gendisk(mfm_gendisk + i);
mfm_geometry (i); mfm_geometry (i);
register_disk(mfm_gendisk + i, mk_kdev(MAJOR_NR,i<<6), 1<<6, register_disk(mfm_gendisk + i, mk_kdev(MAJOR_NR,i<<6), 1<<6,
......
...@@ -1973,7 +1973,6 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) ...@@ -1973,7 +1973,6 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
disk->first_minor = n << DAC960_MaxPartitionsBits; disk->first_minor = n << DAC960_MaxPartitionsBits;
disk->major_name = names + 9 * n; disk->major_name = names + 9 * n;
disk->minor_shift = DAC960_MaxPartitionsBits; disk->minor_shift = DAC960_MaxPartitionsBits;
disk->nr_real = 1;
disk->fops = &DAC960_BlockDeviceOperations; disk->fops = &DAC960_BlockDeviceOperations;
add_gendisk(disk); add_gendisk(disk);
} }
......
...@@ -1704,7 +1704,6 @@ static void acsi_geninit(void) ...@@ -1704,7 +1704,6 @@ static void acsi_geninit(void)
disk->minor_shift = (acsi_info[i].type==HARDDISK)?4:0; disk->minor_shift = (acsi_info[i].type==HARDDISK)?4:0;
disk->part = acsi_part + (i<<4); disk->part = acsi_part + (i<<4);
disk->fops = &acsi_fops; disk->fops = &acsi_fops;
disk->nr_real = 1;
add_gendisk(disk); add_gendisk(disk);
register_disk(disk, mk_kdev(disk->major, disk->first_minor), register_disk(disk, mk_kdev(disk->major, disk->first_minor),
1<<disk->minor_shift, 1<<disk->minor_shift,
......
...@@ -2447,7 +2447,6 @@ static int __init cciss_init_one(struct pci_dev *pdev, ...@@ -2447,7 +2447,6 @@ static int __init cciss_init_one(struct pci_dev *pdev,
disk->major_name = NULL; disk->major_name = NULL;
disk->minor_shift = NWD_SHIFT; disk->minor_shift = NWD_SHIFT;
disk->part = hba[i]->hd + (j << NWD_SHIFT); disk->part = hba[i]->hd + (j << NWD_SHIFT);
disk->nr_real = 1;
if( !(drv->nr_blocks)) if( !(drv->nr_blocks))
continue; continue;
(BLK_DEFAULT_QUEUE(MAJOR_NR + i))->hardsect_size = drv->block_size; (BLK_DEFAULT_QUEUE(MAJOR_NR + i))->hardsect_size = drv->block_size;
......
...@@ -451,7 +451,6 @@ int __init cpqarray_init(void) ...@@ -451,7 +451,6 @@ int __init cpqarray_init(void)
disk->first_minor = j<<NWD_SHIFT; disk->first_minor = j<<NWD_SHIFT;
disk->minor_shift = NWD_SHIFT; disk->minor_shift = NWD_SHIFT;
disk->part = ida + i*256 + (j<<NWD_SHIFT); disk->part = ida + i*256 + (j<<NWD_SHIFT);
disk->nr_real = 1;
disk->de_arr = &de_arr[i][j]; disk->de_arr = &de_arr[i][j];
disk->fops = &ida_fops; disk->fops = &ida_fops;
if (!drv->nr_blks) if (!drv->nr_blks)
......
...@@ -162,9 +162,8 @@ static int show_partition(struct seq_file *part, void *v) ...@@ -162,9 +162,8 @@ static int show_partition(struct seq_file *part, void *v)
seq_puts(part, "major minor #blocks name\n\n"); seq_puts(part, "major minor #blocks name\n\n");
/* show the full disk and all non-0 size partitions of it */ /* show the full disk and all non-0 size partitions of it */
for (n = 0; n < (sgp->nr_real << sgp->minor_shift); n++) { for (n = 0; n < 1<<sgp->minor_shift; n++) {
int minormask = (1<<sgp->minor_shift) - 1; if (n && sgp->part[n].nr_sects == 0)
if ((n & minormask) && sgp->part[n].nr_sects == 0)
continue; continue;
seq_printf(part, "%4d %4d %10ld %s\n", seq_printf(part, "%4d %4d %10ld %s\n",
sgp->major, n + sgp->first_minor, sgp->major, n + sgp->first_minor,
......
...@@ -687,7 +687,6 @@ static int pd_detect( void ) ...@@ -687,7 +687,6 @@ static int pd_detect( void )
PD.gd.major_name = PD.name; PD.gd.major_name = PD.name;
PD.gd.minor_shift = PD_BITS; PD.gd.minor_shift = PD_BITS;
PD.gd.fops = &pd_fops; PD.gd.fops = &pd_fops;
PD.gd.nr_real = 1;
PD.gd.major = major; PD.gd.major = major;
PD.gd.first_minor = unit << PD_BITS; PD.gd.first_minor = unit << PD_BITS;
PD.gd.part = pd_hd + (unit << PD_BITS); PD.gd.part = pd_hd + (unit << PD_BITS);
......
...@@ -154,7 +154,6 @@ static struct gendisk ps2esdi_gendisk[2] = { ...@@ -154,7 +154,6 @@ static struct gendisk ps2esdi_gendisk[2] = {
minor_shift: 6, minor_shift: 6,
part: ps2esdi, part: ps2esdi,
fops: &ps2esdi_fops, fops: &ps2esdi_fops,
nr_real: 1
},{ },{
major: MAJOR_NR, major: MAJOR_NR,
first_minor: 64, first_minor: 64,
...@@ -162,7 +161,6 @@ static struct gendisk ps2esdi_gendisk[2] = { ...@@ -162,7 +161,6 @@ static struct gendisk ps2esdi_gendisk[2] = {
minor_shift: 6, minor_shift: 6,
part: ps2esdi+64, part: ps2esdi+64,
fops: &ps2esdi_fops, fops: &ps2esdi_fops,
nr_real: 1
} }
}; };
......
...@@ -1193,7 +1193,6 @@ int __init mm_init(void) ...@@ -1193,7 +1193,6 @@ int __init mm_init(void)
sprintf(mm_names + i*6, "umem%c", 'a'+i); sprintf(mm_names + i*6, "umem%c", 'a'+i);
spin_lock_init(&cards[i].lock); spin_lock_init(&cards[i].lock);
disk->part = mm_partitions + (i << MM_SHIFT); disk->part = mm_partitions + (i << MM_SHIFT);
disk->nr_real = 1;
disk->major = major_nr; disk->major = major_nr;
disk->first_minor = i << MM_SHIFT; disk->first_minor = i << MM_SHIFT;
disk->major_name = mm_names + i*6; disk->major_name = mm_names + i*6;
......
...@@ -135,7 +135,6 @@ static struct gendisk xd_gendisk[2] = { ...@@ -135,7 +135,6 @@ static struct gendisk xd_gendisk[2] = {
.minor_shift = 6, .minor_shift = 6,
.part = xd_struct, .part = xd_struct,
.fops = &xd_fops, .fops = &xd_fops,
.nr_real = 1
},{ },{
.major = MAJOR_NR, .major = MAJOR_NR,
.first_minor = 64, .first_minor = 64,
...@@ -143,7 +142,6 @@ static struct gendisk xd_gendisk[2] = { ...@@ -143,7 +142,6 @@ static struct gendisk xd_gendisk[2] = {
.minor_shift = 6, .minor_shift = 6,
.part = xd_struct + 64, .part = xd_struct + 64,
.fops = &xd_fops, .fops = &xd_fops,
.nr_real = 1
} }
}; };
......
...@@ -849,7 +849,6 @@ static void __init hd_geninit(void) ...@@ -849,7 +849,6 @@ static void __init hd_geninit(void)
} }
for(drive=0; drive < NR_HD; drive++) { for(drive=0; drive < NR_HD; drive++) {
hd_gendisk[drive].nr_real = 1;
add_gendisk(hd_gendisk + drive); add_gendisk(hd_gendisk + drive);
register_disk(hd_gendisk + drive, register_disk(hd_gendisk + drive,
mk_kdev(MAJOR_NR,drive<<6), 1<<6, mk_kdev(MAJOR_NR,drive<<6), 1<<6,
......
...@@ -861,7 +861,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -861,7 +861,6 @@ static void init_gendisk (ide_hwif_t *hwif)
sprintf(names + 4*unit, "hd%c",'a'+hwif->index*MAX_DRIVES+unit); sprintf(names + 4*unit, "hd%c",'a'+hwif->index*MAX_DRIVES+unit);
gd[unit].major_name = names + 4*unit; gd[unit].major_name = names + 4*unit;
gd[unit].minor_shift = PARTN_BITS; gd[unit].minor_shift = PARTN_BITS;
gd[unit].nr_real = 1;
gd[unit].fops = ide_fops; gd[unit].fops = ide_fops;
hwif->gd[unit] = gd + unit; hwif->gd[unit] = gd + unit;
} }
......
...@@ -1459,7 +1459,6 @@ static int do_md_run(mddev_t * mddev) ...@@ -1459,7 +1459,6 @@ static int do_md_run(mddev_t * mddev)
sprintf(major_name, "md%d", mdidx(mddev)); sprintf(major_name, "md%d", mdidx(mddev));
disk->major_name = major_name; disk->major_name = major_name;
disk->part = md_hd_struct + mdidx(mddev); disk->part = md_hd_struct + mdidx(mddev);
disk->nr_real = 1;
disk->fops = &md_fops; disk->fops = &md_fops;
mddev->pers = pers[pnum]; mddev->pers = pers[pnum];
......
...@@ -1773,7 +1773,6 @@ int i2o_block_init(void) ...@@ -1773,7 +1773,6 @@ int i2o_block_init(void)
disk->minor_shift = 4; disk->minor_shift = 4;
disk->part = i2ob + (i<<4); disk->part = i2ob + (i<<4);
disk->fops = &i2ob_fops; disk->fops = &i2ob_fops;
disk->nr_real = 1;
disk->major_name = i2o_names + i*8; disk->major_name = i2o_names + i*8;
sprintf(disk->major_name, "i2o/hd%c", 'a' + i); sprintf(disk->major_name, "i2o/hd%c", 'a' + i);
} }
......
...@@ -1254,7 +1254,6 @@ static void ftl_notify_add(struct mtd_info *mtd) ...@@ -1254,7 +1254,6 @@ static void ftl_notify_add(struct mtd_info *mtd)
disk->minor_shift = PART_BITS; disk->minor_shift = PART_BITS;
disk->part = ftl_hd + (device << 4); disk->part = ftl_hd + (device << 4);
disk->fops = &ftl_blk_fops; disk->fops = &ftl_blk_fops;
disk->nr_real = 1;
partition->mtd = mtd; partition->mtd = mtd;
partition->disk = disk; partition->disk = disk;
......
...@@ -152,7 +152,6 @@ static void NFTL_setup(struct mtd_info *mtd) ...@@ -152,7 +152,6 @@ static void NFTL_setup(struct mtd_info *mtd)
gd->minor_shift = NFTL_PARTN_BITS; gd->minor_shift = NFTL_PARTN_BITS;
gd->part = part_table + (firstfree << NFTL_PARTN_BITS); gd->part = part_table + (firstfree << NFTL_PARTN_BITS);
gd->major_name = name; gd->major_name = name;
gd->nr_real = 1;
nftl->disk = gd; nftl->disk = gd;
add_gendisk(gd); add_gendisk(gd);
register_disk(gd, mk_kdev(MAJOR_NR,firstfree<<NFTL_PARTN_BITS), register_disk(gd, mk_kdev(MAJOR_NR,firstfree<<NFTL_PARTN_BITS),
......
...@@ -106,7 +106,6 @@ dasd_register_major(int major) ...@@ -106,7 +106,6 @@ dasd_register_major(int major)
disk->major = new_major; disk->major = new_major;
disk->first_minor = i << DASD_PARTN_BITS; disk->first_minor = i << DASD_PARTN_BITS;
disk->minor_shift = DASD_PARTN_BITS; disk->minor_shift = DASD_PARTN_BITS;
disk->nr_real = 1;
disk->fops = &dasd_device_operations; disk->fops = &dasd_device_operations;
disk->de_arr = mi->de_arr + i; disk->de_arr = mi->de_arr + i;
disk->flags = mi->flags + i; disk->flags = mi->flags + i;
......
...@@ -1351,7 +1351,6 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1351,7 +1351,6 @@ static int sd_attach(Scsi_Device * sdp)
} }
sd_template.nr_dev++; sd_template.nr_dev++;
gd->nr_real = 1;
gd->de_arr[0] = sdp->de; gd->de_arr[0] = sdp->de;
gd->driverfs_dev_arr[0] = &sdp->sdev_driverfs_dev; gd->driverfs_dev_arr[0] = &sdp->sdev_driverfs_dev;
gd->major = SD_MAJOR(dsk_nr>>4); gd->major = SD_MAJOR(dsk_nr>>4);
......
...@@ -602,8 +602,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * ...@@ -602,8 +602,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
struct gendisk *g = get_gendisk(dev); struct gendisk *g = get_gendisk(dev);
bdev->bd_contains = bdev; bdev->bd_contains = bdev;
if (g) { if (g) {
int shift = g->minor_shift; unsigned minor0 = g->first_minor;
unsigned minor0 = (minor >> shift) << shift;
if (minor != minor0) { if (minor != minor0) {
struct block_device *disk; struct block_device *disk;
disk = bdget(MKDEV(major(dev), minor0)); disk = bdget(MKDEV(major(dev), minor0));
......
...@@ -89,14 +89,12 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) = ...@@ -89,14 +89,12 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
char *disk_name (struct gendisk *hd, int minor, char *buf) char *disk_name (struct gendisk *hd, int minor, char *buf)
{ {
unsigned int unit = (minor >> hd->minor_shift); unsigned int part = minor - hd->first_minor;
unsigned int part = (minor & ((1 << hd->minor_shift) -1 )); struct hd_struct *p = hd->part + part;
struct hd_struct *p = hd->part + minor - hd->first_minor;
char s[40]; char s[40];
const char *maj; const char *maj;
if ((((minor - hd->first_minor) >> hd->minor_shift) < hd->nr_real) && if (part < 1<<hd->minor_shift && p->de) {
p->de) {
int pos; int pos;
pos = devfs_generate_path(p->de, buf, 64); pos = devfs_generate_path(p->de, buf, 64);
...@@ -104,23 +102,7 @@ char *disk_name (struct gendisk *hd, int minor, char *buf) ...@@ -104,23 +102,7 @@ char *disk_name (struct gendisk *hd, int minor, char *buf)
return buf + pos; return buf + pos;
} }
/* maj = hd->major_name;
* Yes, I know, ... in cases is gccism and not a pretty one.
* However, the first variant will eventually consume _all_ cases
* and switch will disappear.
*/
switch (hd->major) {
default:
maj = hd->major_name;
break;
case MD_MAJOR:
sprintf(s, "%s%d", "md", unit);
maj = s;
break;
case I2O_MAJOR:
sprintf(s, "%s%c", hd->major_name, unit + 'a');
maj = s;
}
if (!part) if (!part)
sprintf(buf, "%s", maj); sprintf(buf, "%s", maj);
else if (isdigit(maj[strlen(maj)-1])) else if (isdigit(maj[strlen(maj)-1]))
...@@ -150,7 +132,6 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL); ...@@ -150,7 +132,6 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL);
void driverfs_create_partitions(struct gendisk *hd, int minor) void driverfs_create_partitions(struct gendisk *hd, int minor)
{ {
int pos = -1; int pos = -1;
int devnum = (minor - hd->first_minor) >> hd->minor_shift;
char dirname[256]; char dirname[256];
struct device *parent = 0; struct device *parent = 0;
int max_p; int max_p;
...@@ -160,13 +141,13 @@ void driverfs_create_partitions(struct gendisk *hd, int minor) ...@@ -160,13 +141,13 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
/* get parent driverfs device structure */ /* get parent driverfs device structure */
if (hd->driverfs_dev_arr) if (hd->driverfs_dev_arr)
parent = hd->driverfs_dev_arr[devnum]; parent = hd->driverfs_dev_arr[0];
else /* if driverfs not supported by subsystem, skip partitions */ else /* if driverfs not supported by subsystem, skip partitions */
return; return;
/* get parent device node directory name */ /* get parent device node directory name */
if (hd->de_arr) { if (hd->de_arr) {
dir = hd->de_arr[devnum]; dir = hd->de_arr[0];
if (dir) if (dir)
pos = devfs_generate_path (dir, dirname, pos = devfs_generate_path (dir, dirname,
sizeof dirname); sizeof dirname);
...@@ -268,7 +249,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -268,7 +249,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
return; return;
if (hd->de_arr) if (hd->de_arr)
de = hd->de_arr[(minor(dev)-hd->first_minor)>>hd->minor_shift]; de = hd->de_arr[0];
i = devfs_generate_path (de, buf, sizeof buf); i = devfs_generate_path (de, buf, sizeof buf);
if (i >= 0) { if (i >= 0) {
printk(KERN_INFO " /dev/%s:", buf + i); printk(KERN_INFO " /dev/%s:", buf + i);
...@@ -315,7 +296,6 @@ void check_partition(struct gendisk *hd, struct block_device *bdev) ...@@ -315,7 +296,6 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
static void devfs_register_partition (struct gendisk *dev, int minor, int part) static void devfs_register_partition (struct gendisk *dev, int minor, int part)
{ {
int devnum = (minor - dev->first_minor) >> dev->minor_shift;
devfs_handle_t dir; devfs_handle_t dir;
unsigned int devfs_flags = DEVFS_FL_DEFAULT; unsigned int devfs_flags = DEVFS_FL_DEFAULT;
struct hd_struct *p = dev->part + minor - dev->first_minor; struct hd_struct *p = dev->part + minor - dev->first_minor;
...@@ -326,7 +306,7 @@ static void devfs_register_partition (struct gendisk *dev, int minor, int part) ...@@ -326,7 +306,7 @@ static void devfs_register_partition (struct gendisk *dev, int minor, int part)
dir = devfs_get_parent(p[0].de); dir = devfs_get_parent(p[0].de);
if (!dir) if (!dir)
return; return;
if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) ) if ( dev->flags && (dev->flags[0] & GENHD_FL_REMOVABLE) )
devfs_flags |= DEVFS_FL_REMOVABLE; devfs_flags |= DEVFS_FL_REMOVABLE;
sprintf (devname, "part%d", part); sprintf (devname, "part%d", part);
p[part].de = devfs_register (dir, devname, devfs_flags, p[part].de = devfs_register (dir, devname, devfs_flags,
...@@ -340,7 +320,6 @@ static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER; ...@@ -340,7 +320,6 @@ static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
static void devfs_register_disc (struct gendisk *dev, int minor) static void devfs_register_disc (struct gendisk *dev, int minor)
{ {
int pos = 0; int pos = 0;
int devnum = (minor - dev->first_minor) >> dev->minor_shift;
devfs_handle_t dir, slave; devfs_handle_t dir, slave;
unsigned int devfs_flags = DEVFS_FL_DEFAULT; unsigned int devfs_flags = DEVFS_FL_DEFAULT;
char dirname[64], symlink[16]; char dirname[64], symlink[16];
...@@ -349,10 +328,10 @@ static void devfs_register_disc (struct gendisk *dev, int minor) ...@@ -349,10 +328,10 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
if (p[0].de) if (p[0].de)
return; return;
if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) ) if ( dev->flags && (dev->flags[0] & GENHD_FL_REMOVABLE) )
devfs_flags |= DEVFS_FL_REMOVABLE; devfs_flags |= DEVFS_FL_REMOVABLE;
if (dev->de_arr) { if (dev->de_arr) {
dir = dev->de_arr[devnum]; dir = dev->de_arr[0];
if (!dir) /* Aware driver wants to block disc management */ if (!dir) /* Aware driver wants to block disc management */
return; return;
pos = devfs_generate_path(dir, dirname + 3, sizeof dirname-3); pos = devfs_generate_path(dir, dirname + 3, sizeof dirname-3);
...@@ -362,7 +341,7 @@ static void devfs_register_disc (struct gendisk *dev, int minor) ...@@ -362,7 +341,7 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
} else { } else {
/* Unaware driver: construct "real" directory */ /* Unaware driver: construct "real" directory */
sprintf(dirname, "../%s/disc%d", dev->major_name, sprintf(dirname, "../%s/disc%d", dev->major_name,
(dev->first_minor >> dev->minor_shift) + devnum); dev->first_minor >> dev->minor_shift);
dir = devfs_mk_dir(NULL, dirname + 3, NULL); dir = devfs_mk_dir(NULL, dirname + 3, NULL);
} }
if (!devfs_handle) if (!devfs_handle)
......
...@@ -76,8 +76,6 @@ struct gendisk { ...@@ -76,8 +76,6 @@ struct gendisk {
get real minor */ get real minor */
struct hd_struct *part; /* [indexed by minor] */ struct hd_struct *part; /* [indexed by minor] */
int nr_real; /* number of real devices */
struct gendisk *next; struct gendisk *next;
struct block_device_operations *fops; struct block_device_operations *fops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment