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)
outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */
for (i = 0; i < mfm_drives; i++) {
mfm_gendisk[i].nr_real = 1;
add_gendisk(mfm_gendisk + i);
mfm_geometry (i);
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)
disk->first_minor = n << DAC960_MaxPartitionsBits;
disk->major_name = names + 9 * n;
disk->minor_shift = DAC960_MaxPartitionsBits;
disk->nr_real = 1;
disk->fops = &DAC960_BlockDeviceOperations;
add_gendisk(disk);
}
......
......@@ -1704,7 +1704,6 @@ static void acsi_geninit(void)
disk->minor_shift = (acsi_info[i].type==HARDDISK)?4:0;
disk->part = acsi_part + (i<<4);
disk->fops = &acsi_fops;
disk->nr_real = 1;
add_gendisk(disk);
register_disk(disk, mk_kdev(disk->major, disk->first_minor),
1<<disk->minor_shift,
......
......@@ -2447,7 +2447,6 @@ static int __init cciss_init_one(struct pci_dev *pdev,
disk->major_name = NULL;
disk->minor_shift = NWD_SHIFT;
disk->part = hba[i]->hd + (j << NWD_SHIFT);
disk->nr_real = 1;
if( !(drv->nr_blocks))
continue;
(BLK_DEFAULT_QUEUE(MAJOR_NR + i))->hardsect_size = drv->block_size;
......
......@@ -451,7 +451,6 @@ int __init cpqarray_init(void)
disk->first_minor = j<<NWD_SHIFT;
disk->minor_shift = NWD_SHIFT;
disk->part = ida + i*256 + (j<<NWD_SHIFT);
disk->nr_real = 1;
disk->de_arr = &de_arr[i][j];
disk->fops = &ida_fops;
if (!drv->nr_blks)
......
......@@ -162,9 +162,8 @@ static int show_partition(struct seq_file *part, void *v)
seq_puts(part, "major minor #blocks name\n\n");
/* show the full disk and all non-0 size partitions of it */
for (n = 0; n < (sgp->nr_real << sgp->minor_shift); n++) {
int minormask = (1<<sgp->minor_shift) - 1;
if ((n & minormask) && sgp->part[n].nr_sects == 0)
for (n = 0; n < 1<<sgp->minor_shift; n++) {
if (n && sgp->part[n].nr_sects == 0)
continue;
seq_printf(part, "%4d %4d %10ld %s\n",
sgp->major, n + sgp->first_minor,
......
......@@ -687,7 +687,6 @@ static int pd_detect( void )
PD.gd.major_name = PD.name;
PD.gd.minor_shift = PD_BITS;
PD.gd.fops = &pd_fops;
PD.gd.nr_real = 1;
PD.gd.major = major;
PD.gd.first_minor = unit << PD_BITS;
PD.gd.part = pd_hd + (unit << PD_BITS);
......
......@@ -154,7 +154,6 @@ static struct gendisk ps2esdi_gendisk[2] = {
minor_shift: 6,
part: ps2esdi,
fops: &ps2esdi_fops,
nr_real: 1
},{
major: MAJOR_NR,
first_minor: 64,
......@@ -162,7 +161,6 @@ static struct gendisk ps2esdi_gendisk[2] = {
minor_shift: 6,
part: ps2esdi+64,
fops: &ps2esdi_fops,
nr_real: 1
}
};
......
......@@ -1193,7 +1193,6 @@ int __init mm_init(void)
sprintf(mm_names + i*6, "umem%c", 'a'+i);
spin_lock_init(&cards[i].lock);
disk->part = mm_partitions + (i << MM_SHIFT);
disk->nr_real = 1;
disk->major = major_nr;
disk->first_minor = i << MM_SHIFT;
disk->major_name = mm_names + i*6;
......
......@@ -135,7 +135,6 @@ static struct gendisk xd_gendisk[2] = {
.minor_shift = 6,
.part = xd_struct,
.fops = &xd_fops,
.nr_real = 1
},{
.major = MAJOR_NR,
.first_minor = 64,
......@@ -143,7 +142,6 @@ static struct gendisk xd_gendisk[2] = {
.minor_shift = 6,
.part = xd_struct + 64,
.fops = &xd_fops,
.nr_real = 1
}
};
......
......@@ -849,7 +849,6 @@ static void __init hd_geninit(void)
}
for(drive=0; drive < NR_HD; drive++) {
hd_gendisk[drive].nr_real = 1;
add_gendisk(hd_gendisk + drive);
register_disk(hd_gendisk + drive,
mk_kdev(MAJOR_NR,drive<<6), 1<<6,
......
......@@ -861,7 +861,6 @@ static void init_gendisk (ide_hwif_t *hwif)
sprintf(names + 4*unit, "hd%c",'a'+hwif->index*MAX_DRIVES+unit);
gd[unit].major_name = names + 4*unit;
gd[unit].minor_shift = PARTN_BITS;
gd[unit].nr_real = 1;
gd[unit].fops = ide_fops;
hwif->gd[unit] = gd + unit;
}
......
......@@ -1459,7 +1459,6 @@ static int do_md_run(mddev_t * mddev)
sprintf(major_name, "md%d", mdidx(mddev));
disk->major_name = major_name;
disk->part = md_hd_struct + mdidx(mddev);
disk->nr_real = 1;
disk->fops = &md_fops;
mddev->pers = pers[pnum];
......
......@@ -1773,7 +1773,6 @@ int i2o_block_init(void)
disk->minor_shift = 4;
disk->part = i2ob + (i<<4);
disk->fops = &i2ob_fops;
disk->nr_real = 1;
disk->major_name = i2o_names + i*8;
sprintf(disk->major_name, "i2o/hd%c", 'a' + i);
}
......
......@@ -1254,7 +1254,6 @@ static void ftl_notify_add(struct mtd_info *mtd)
disk->minor_shift = PART_BITS;
disk->part = ftl_hd + (device << 4);
disk->fops = &ftl_blk_fops;
disk->nr_real = 1;
partition->mtd = mtd;
partition->disk = disk;
......
......@@ -152,7 +152,6 @@ static void NFTL_setup(struct mtd_info *mtd)
gd->minor_shift = NFTL_PARTN_BITS;
gd->part = part_table + (firstfree << NFTL_PARTN_BITS);
gd->major_name = name;
gd->nr_real = 1;
nftl->disk = gd;
add_gendisk(gd);
register_disk(gd, mk_kdev(MAJOR_NR,firstfree<<NFTL_PARTN_BITS),
......
......@@ -106,7 +106,6 @@ dasd_register_major(int major)
disk->major = new_major;
disk->first_minor = i << DASD_PARTN_BITS;
disk->minor_shift = DASD_PARTN_BITS;
disk->nr_real = 1;
disk->fops = &dasd_device_operations;
disk->de_arr = mi->de_arr + i;
disk->flags = mi->flags + i;
......
......@@ -1351,7 +1351,6 @@ static int sd_attach(Scsi_Device * sdp)
}
sd_template.nr_dev++;
gd->nr_real = 1;
gd->de_arr[0] = sdp->de;
gd->driverfs_dev_arr[0] = &sdp->sdev_driverfs_dev;
gd->major = SD_MAJOR(dsk_nr>>4);
......
......@@ -602,8 +602,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file *
struct gendisk *g = get_gendisk(dev);
bdev->bd_contains = bdev;
if (g) {
int shift = g->minor_shift;
unsigned minor0 = (minor >> shift) << shift;
unsigned minor0 = g->first_minor;
if (minor != minor0) {
struct block_device *disk;
disk = bdget(MKDEV(major(dev), minor0));
......
......@@ -89,14 +89,12 @@ static int (*check_part[])(struct parsed_partitions *, struct block_device *) =
char *disk_name (struct gendisk *hd, int minor, char *buf)
{
unsigned int unit = (minor >> hd->minor_shift);
unsigned int part = (minor & ((1 << hd->minor_shift) -1 ));
struct hd_struct *p = hd->part + minor - hd->first_minor;
unsigned int part = minor - hd->first_minor;
struct hd_struct *p = hd->part + part;
char s[40];
const char *maj;
if ((((minor - hd->first_minor) >> hd->minor_shift) < hd->nr_real) &&
p->de) {
if (part < 1<<hd->minor_shift && p->de) {
int pos;
pos = devfs_generate_path(p->de, buf, 64);
......@@ -104,23 +102,7 @@ char *disk_name (struct gendisk *hd, int minor, char *buf)
return buf + pos;
}
/*
* 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;
}
maj = hd->major_name;
if (!part)
sprintf(buf, "%s", maj);
else if (isdigit(maj[strlen(maj)-1]))
......@@ -150,7 +132,6 @@ static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL);
void driverfs_create_partitions(struct gendisk *hd, int minor)
{
int pos = -1;
int devnum = (minor - hd->first_minor) >> hd->minor_shift;
char dirname[256];
struct device *parent = 0;
int max_p;
......@@ -160,13 +141,13 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
/* get parent driverfs device structure */
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 */
return;
/* get parent device node directory name */
if (hd->de_arr) {
dir = hd->de_arr[devnum];
dir = hd->de_arr[0];
if (dir)
pos = devfs_generate_path (dir, dirname,
sizeof dirname);
......@@ -268,7 +249,7 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
return;
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);
if (i >= 0) {
printk(KERN_INFO " /dev/%s:", buf + i);
......@@ -315,7 +296,6 @@ void check_partition(struct gendisk *hd, struct block_device *bdev)
#ifdef CONFIG_DEVFS_FS
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;
unsigned int devfs_flags = DEVFS_FL_DEFAULT;
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)
dir = devfs_get_parent(p[0].de);
if (!dir)
return;
if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) )
if ( dev->flags && (dev->flags[0] & GENHD_FL_REMOVABLE) )
devfs_flags |= DEVFS_FL_REMOVABLE;
sprintf (devname, "part%d", part);
p[part].de = devfs_register (dir, devname, devfs_flags,
......@@ -340,7 +320,6 @@ static struct unique_numspace disc_numspace = UNIQUE_NUMBERSPACE_INITIALISER;
static void devfs_register_disc (struct gendisk *dev, int minor)
{
int pos = 0;
int devnum = (minor - dev->first_minor) >> dev->minor_shift;
devfs_handle_t dir, slave;
unsigned int devfs_flags = DEVFS_FL_DEFAULT;
char dirname[64], symlink[16];
......@@ -349,10 +328,10 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
if (p[0].de)
return;
if ( dev->flags && (dev->flags[devnum] & GENHD_FL_REMOVABLE) )
if ( dev->flags && (dev->flags[0] & GENHD_FL_REMOVABLE) )
devfs_flags |= DEVFS_FL_REMOVABLE;
if (dev->de_arr) {
dir = dev->de_arr[devnum];
dir = dev->de_arr[0];
if (!dir) /* Aware driver wants to block disc management */
return;
pos = devfs_generate_path(dir, dirname + 3, sizeof dirname-3);
......@@ -362,7 +341,7 @@ static void devfs_register_disc (struct gendisk *dev, int minor)
} else {
/* Unaware driver: construct "real" directory */
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);
}
if (!devfs_handle)
......
......@@ -76,8 +76,6 @@ struct gendisk {
get real minor */
struct hd_struct *part; /* [indexed by minor] */
int nr_real; /* number of real devices */
struct gendisk *next;
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