Commit ab3bfaa2 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (5/25) Removing bogus arrays - ->flags[]

	Seeing that now disk->flags[] always consists of one element, we
replace char *flags with int flags, remove the junk from places that used
to allocate these "arrays" and do obvious updates of the code
(s/->flags[0]/->flags/).
parent 097b3217
...@@ -3147,6 +3147,9 @@ static int ide_cdrom_reinit (ide_drive_t *drive) ...@@ -3147,6 +3147,9 @@ static int ide_cdrom_reinit (ide_drive_t *drive)
cdrom_read_toc(drive, &sense); cdrom_read_toc(drive, &sense);
g->minor_shift = 0; g->minor_shift = 0;
/* probably bogus, but that's the old behaviour */
g->de_arr[0] = NULL;
g->flags = 0;
add_gendisk(g); add_gendisk(g);
register_disk(g, mk_kdev(g->major,g->first_minor), register_disk(g, mk_kdev(g->major,g->first_minor),
1<<g->minor_shift, ide_fops, 1<<g->minor_shift, ide_fops,
......
...@@ -1516,8 +1516,6 @@ static void idedisk_add_settings(ide_drive_t *drive) ...@@ -1516,8 +1516,6 @@ static void idedisk_add_settings(ide_drive_t *drive)
static void idedisk_setup (ide_drive_t *drive) static void idedisk_setup (ide_drive_t *drive)
{ {
int i;
struct hd_driveid *id = drive->id; struct hd_driveid *id = drive->id;
unsigned long capacity; unsigned long capacity;
...@@ -1538,15 +1536,6 @@ static void idedisk_setup (ide_drive_t *drive) ...@@ -1538,15 +1536,6 @@ static void idedisk_setup (ide_drive_t *drive)
drive->doorlocking = 1; drive->doorlocking = 1;
} }
} }
for (i = 0; i < MAX_DRIVES; ++i) {
ide_hwif_t *hwif = HWIF(drive);
if (drive != &hwif->drives[i]) continue;
hwif->gd[i]->de_arr[i] = drive->de;
if (drive->removable)
hwif->gd[i]->flags[i] |= GENHD_FL_REMOVABLE;
break;
}
#if 1 #if 1
(void) probe_lba_addressing(drive, 1); (void) probe_lba_addressing(drive, 1);
...@@ -1714,6 +1703,8 @@ static int idedisk_reinit(ide_drive_t *drive) ...@@ -1714,6 +1703,8 @@ static int idedisk_reinit(ide_drive_t *drive)
} }
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
g->minor_shift = PARTN_BITS; g->minor_shift = PARTN_BITS;
g->de_arr[0] = drive->de;
g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
add_gendisk(g); add_gendisk(g);
register_disk(g, mk_kdev(g->major,g->first_minor), register_disk(g, mk_kdev(g->major,g->first_minor),
1<<g->minor_shift, ide_fops, 1<<g->minor_shift, ide_fops,
......
...@@ -2065,7 +2065,6 @@ static void idefloppy_add_settings(ide_drive_t *drive) ...@@ -2065,7 +2065,6 @@ static void idefloppy_add_settings(ide_drive_t *drive)
static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
{ {
struct idefloppy_id_gcw gcw; struct idefloppy_id_gcw gcw;
int i;
*((unsigned short *) &gcw) = drive->id->config; *((unsigned short *) &gcw) = drive->id->config;
drive->driver_data = floppy; drive->driver_data = floppy;
...@@ -2108,15 +2107,6 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -2108,15 +2107,6 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
(void) idefloppy_get_capacity (drive); (void) idefloppy_get_capacity (drive);
idefloppy_add_settings(drive); idefloppy_add_settings(drive);
for (i = 0; i < MAX_DRIVES; ++i) {
ide_hwif_t *hwif = HWIF(drive);
if (drive != &hwif->drives[i]) continue;
hwif->gd[i]->de_arr[i] = drive->de;
if (drive->removable)
hwif->gd[i]->flags[i] |= GENHD_FL_REMOVABLE;
break;
}
} }
static int idefloppy_cleanup (ide_drive_t *drive) static int idefloppy_cleanup (ide_drive_t *drive)
...@@ -2221,6 +2211,8 @@ static int idefloppy_reinit (ide_drive_t *drive) ...@@ -2221,6 +2211,8 @@ static int idefloppy_reinit (ide_drive_t *drive)
idefloppy_setup (drive, floppy); idefloppy_setup (drive, floppy);
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
g->minor_shift = PARTN_BITS; g->minor_shift = PARTN_BITS;
g->de_arr[0] = drive->de;
g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0;
add_gendisk(g); add_gendisk(g);
register_disk(g, mk_kdev(g->major,g->first_minor), register_disk(g, mk_kdev(g->major,g->first_minor),
1<<g->minor_shift, ide_fops, 1<<g->minor_shift, ide_fops,
......
...@@ -809,7 +809,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -809,7 +809,6 @@ static void init_gendisk (ide_hwif_t *hwif)
struct gendisk *gd; struct gendisk *gd;
struct hd_struct *part; struct hd_struct *part;
devfs_handle_t *de_arr; devfs_handle_t *de_arr;
char *flags;
unsigned int unit, units, minors; unsigned int unit, units, minors;
extern devfs_handle_t ide_devfs_handle; extern devfs_handle_t ide_devfs_handle;
char *names; char *names;
...@@ -841,11 +840,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -841,11 +840,6 @@ static void init_gendisk (ide_hwif_t *hwif)
goto err_kmalloc_gd_de_arr; goto err_kmalloc_gd_de_arr;
memset(de_arr, 0, sizeof(devfs_handle_t) * MAX_DRIVES); memset(de_arr, 0, sizeof(devfs_handle_t) * MAX_DRIVES);
flags = kmalloc(sizeof(char) * MAX_DRIVES, GFP_KERNEL);
if (!flags)
goto err_kmalloc_gd_flags;
memset(flags, 0, sizeof(char) * MAX_DRIVES);
names = kmalloc (4 * MAX_DRIVES, GFP_KERNEL); names = kmalloc (4 * MAX_DRIVES, GFP_KERNEL);
if (!names) if (!names)
goto err_kmalloc_gd_names; goto err_kmalloc_gd_names;
...@@ -854,7 +848,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -854,7 +848,6 @@ static void init_gendisk (ide_hwif_t *hwif)
for (unit = 0; unit < units; ++unit) { for (unit = 0; unit < units; ++unit) {
gd[unit].part = part + (unit << PARTN_BITS); gd[unit].part = part + (unit << PARTN_BITS);
gd[unit].de_arr = de_arr + unit; gd[unit].de_arr = de_arr + unit;
gd[unit].flags = flags + unit;
hwif->drives[unit].part = gd[unit].part; hwif->drives[unit].part = gd[unit].part;
gd[unit].major = hwif->major; gd[unit].major = hwif->major;
gd[unit].first_minor = unit << PARTN_BITS; gd[unit].first_minor = unit << PARTN_BITS;
...@@ -891,8 +884,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -891,8 +884,6 @@ static void init_gendisk (ide_hwif_t *hwif)
return; return;
err_kmalloc_gd_names: err_kmalloc_gd_names:
kfree(names);
err_kmalloc_gd_flags:
kfree(de_arr); kfree(de_arr);
err_kmalloc_gd_de_arr: err_kmalloc_gd_de_arr:
kfree(part); kfree(part);
......
...@@ -2064,8 +2064,6 @@ void ide_unregister (unsigned int index) ...@@ -2064,8 +2064,6 @@ void ide_unregister (unsigned int index)
kfree(gd->part); kfree(gd->part);
if (gd->de_arr) if (gd->de_arr)
kfree (gd->de_arr); kfree (gd->de_arr);
if (gd->flags)
kfree (gd->flags);
kfree(gd); kfree(gd);
for (i = 0; i < MAX_DRIVES; i++) for (i = 0; i < MAX_DRIVES; i++)
hwif->gd[i] = NULL; hwif->gd[i] = NULL;
......
...@@ -35,7 +35,6 @@ struct major_info { ...@@ -35,7 +35,6 @@ struct major_info {
int major; int major;
struct gendisk disks[DASD_PER_MAJOR]; struct gendisk disks[DASD_PER_MAJOR];
devfs_handle_t de_arr[DASD_PER_MAJOR]; devfs_handle_t de_arr[DASD_PER_MAJOR];
char flags[DASD_PER_MAJOR];
char names[DASD_PER_MAJOR * 8]; char names[DASD_PER_MAJOR * 8];
struct hd_struct part[1<<MINORBITS]; struct hd_struct part[1<<MINORBITS];
}; };
...@@ -108,7 +107,6 @@ dasd_register_major(int major) ...@@ -108,7 +107,6 @@ dasd_register_major(int major)
disk->minor_shift = DASD_PARTN_BITS; disk->minor_shift = DASD_PARTN_BITS;
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->part = mi->part + (i << DASD_PARTN_BITS); disk->part = mi->part + (i << DASD_PARTN_BITS);
} }
......
...@@ -1302,7 +1302,6 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1302,7 +1302,6 @@ static int sd_attach(Scsi_Device * sdp)
struct gendisk disk; struct gendisk disk;
devfs_handle_t de; devfs_handle_t de;
struct device *dev; struct device *dev;
char flags;
char name[5]; char name[5];
} *p; } *p;
struct gendisk *gd; struct gendisk *gd;
...@@ -1316,7 +1315,6 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1316,7 +1315,6 @@ static int sd_attach(Scsi_Device * sdp)
return 1; return 1;
gd = &p->disk; gd = &p->disk;
gd->de_arr = &p->de; gd->de_arr = &p->de;
gd->flags = &p->flags;
gd->driverfs_dev_arr = &p->dev; gd->driverfs_dev_arr = &p->dev;
SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n", SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n",
...@@ -1361,8 +1359,7 @@ static int sd_attach(Scsi_Device * sdp) ...@@ -1361,8 +1359,7 @@ static int sd_attach(Scsi_Device * sdp)
else else
sprintf(p->name, "sd%c", 'a'+dsk_nr%26); sprintf(p->name, "sd%c", 'a'+dsk_nr%26);
gd->major_name = p->name; gd->major_name = p->name;
if (sdp->removable) gd->flags = sdp->removable ? GENHD_FL_REMOVABLE : 0;
gd->flags[0] |= GENHD_FL_REMOVABLE;
sd_disks[dsk_nr] = gd; sd_disks[dsk_nr] = gd;
sd_dskname(dsk_nr, diskname); sd_dskname(dsk_nr, diskname);
printk(KERN_NOTICE "Attached scsi %sdisk %s at scsi%d, channel %d, " printk(KERN_NOTICE "Attached scsi %sdisk %s at scsi%d, channel %d, "
......
...@@ -260,7 +260,7 @@ static void devfs_register_partition(struct gendisk *dev, int part) ...@@ -260,7 +260,7 @@ static void devfs_register_partition(struct gendisk *dev, 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[0] & GENHD_FL_REMOVABLE) ) if (dev->flags & 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,
...@@ -282,7 +282,7 @@ static void devfs_register_disc(struct gendisk *dev) ...@@ -282,7 +282,7 @@ static void devfs_register_disc(struct gendisk *dev)
if (p[0].de) if (p[0].de)
return; return;
if ( dev->flags && (dev->flags[0] & GENHD_FL_REMOVABLE) ) if (dev->flags & 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[0]; dir = dev->de_arr[0];
......
...@@ -81,7 +81,7 @@ struct gendisk { ...@@ -81,7 +81,7 @@ struct gendisk {
devfs_handle_t *de_arr; /* one per physical disc */ devfs_handle_t *de_arr; /* one per physical disc */
struct device **driverfs_dev_arr;/* support driverfs hierarchy */ struct device **driverfs_dev_arr;/* support driverfs hierarchy */
char *flags; /* one per physical disc */ int flags;
}; };
/* drivers/block/genhd.c */ /* drivers/block/genhd.c */
......
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