Commit 07586b33 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (23/25) move pointer to gendisk from hwif to drive

	 ide switched from hwif->gd[i] to hwif->drive[i]->disk - IOW, instead
of array of two pointers to gendisks refered from hwif, we keep these pointers
in relevant drives.  Cleaned up.
parent c276ff4d
...@@ -2593,9 +2593,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) ...@@ -2593,9 +2593,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo; struct cdrom_device_info *devinfo = &info->devinfo;
int minor = (drive->select.b.unit) << PARTN_BITS;
devinfo->dev = mk_kdev(HWIF(drive)->major, minor); devinfo->dev = mk_kdev(drive->disk->major, drive->disk->first_minor);
devinfo->ops = &ide_cdrom_dops; devinfo->ops = &ide_cdrom_dops;
devinfo->mask = 0; devinfo->mask = 0;
*(int *)&devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed; *(int *)&devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed;
...@@ -2622,7 +2621,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) ...@@ -2622,7 +2621,8 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
devinfo->mask |= CDC_CLOSE_TRAY; devinfo->mask |= CDC_CLOSE_TRAY;
devinfo->de = devfs_register(drive->de, "cd", DEVFS_FL_DEFAULT, devinfo->de = devfs_register(drive->de, "cd", DEVFS_FL_DEFAULT,
HWIF(drive)->major, minor, drive->disk->major,
drive->disk->first_minor,
S_IFBLK | S_IRUGO | S_IWUGO, S_IFBLK | S_IRUGO | S_IWUGO,
ide_fops, NULL); ide_fops, NULL);
...@@ -2823,13 +2823,12 @@ int ide_cdrom_setup (ide_drive_t *drive) ...@@ -2823,13 +2823,12 @@ int ide_cdrom_setup (ide_drive_t *drive)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *cdi = &info->devinfo; struct cdrom_device_info *cdi = &info->devinfo;
int minor = drive->select.b.unit << PARTN_BITS;
int nslots; int nslots;
/* /*
* default to read-only always and fix latter at the bottom * default to read-only always and fix latter at the bottom
*/ */
set_device_ro(mk_kdev(HWIF(drive)->major, minor), 1); set_device_ro(mk_kdev(drive->disk->major, drive->disk->first_minor), 1);
blk_queue_hardsect_size(&drive->queue, CD_FRAMESIZE); blk_queue_hardsect_size(&drive->queue, CD_FRAMESIZE);
blk_queue_prep_rq(&drive->queue, ll_10byte_cmd_build); blk_queue_prep_rq(&drive->queue, ll_10byte_cmd_build);
...@@ -2951,7 +2950,7 @@ int ide_cdrom_setup (ide_drive_t *drive) ...@@ -2951,7 +2950,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
nslots = ide_cdrom_probe_capabilities (drive); nslots = ide_cdrom_probe_capabilities (drive);
if (CDROM_CONFIG_FLAGS(drive)->dvd_ram) if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
set_device_ro(mk_kdev(HWIF(drive)->major, minor), 0); set_device_ro(mk_kdev(drive->disk->major, drive->disk->first_minor), 0);
if (ide_cdrom_register (drive, nslots)) { if (ide_cdrom_register (drive, nslots)) {
printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
...@@ -2998,8 +2997,8 @@ void ide_cdrom_release (struct inode *inode, struct file *file, ...@@ -2998,8 +2997,8 @@ void ide_cdrom_release (struct inode *inode, struct file *file,
static static
int ide_cdrom_check_media_change (ide_drive_t *drive) int ide_cdrom_check_media_change (ide_drive_t *drive)
{ {
return cdrom_media_changed(mk_kdev(HWIF (drive)->major, return cdrom_media_changed(mk_kdev(drive->disk->major,
(drive->select.b.unit) << PARTN_BITS)); drive->disk->first_minor));
} }
static static
...@@ -3025,9 +3024,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive) ...@@ -3025,9 +3024,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
{ {
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo; struct cdrom_device_info *devinfo = &info->devinfo;
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
if (ide_unregister_subdriver (drive)) if (ide_unregister_subdriver (drive))
return 1; return 1;
...@@ -3092,9 +3089,7 @@ MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); ...@@ -3092,9 +3089,7 @@ MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cdrom_reinit (ide_drive_t *drive) static int ide_cdrom_reinit (ide_drive_t *drive)
{ {
struct cdrom_info *info; struct cdrom_info *info;
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
struct request_sense sense; struct request_sense sense;
if (!strstr("ide-cdrom", drive->driver_req)) if (!strstr("ide-cdrom", drive->driver_req))
......
...@@ -1618,9 +1618,7 @@ static void idedisk_setup (ide_drive_t *drive) ...@@ -1618,9 +1618,7 @@ static void idedisk_setup (ide_drive_t *drive)
static int idedisk_cleanup (ide_drive_t *drive) static int idedisk_cleanup (ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache) if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive)) if (do_idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
...@@ -1672,9 +1670,7 @@ MODULE_DESCRIPTION("ATA DISK Driver"); ...@@ -1672,9 +1670,7 @@ MODULE_DESCRIPTION("ATA DISK Driver");
static int idedisk_reinit(ide_drive_t *drive) static int idedisk_reinit(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
/* strstr("foo", "") is non-NULL */ /* strstr("foo", "") is non-NULL */
if (!strstr("ide-disk", drive->driver_req)) if (!strstr("ide-disk", drive->driver_req))
......
...@@ -2112,9 +2112,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -2112,9 +2112,7 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
static int idefloppy_cleanup (ide_drive_t *drive) static int idefloppy_cleanup (ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
if (ide_unregister_subdriver (drive)) if (ide_unregister_subdriver (drive))
return 1; return 1;
...@@ -2181,9 +2179,7 @@ static ide_driver_t idefloppy_driver = { ...@@ -2181,9 +2179,7 @@ static ide_driver_t idefloppy_driver = {
static int idefloppy_reinit (ide_drive_t *drive) static int idefloppy_reinit (ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy; idefloppy_floppy_t *floppy;
ide_hwif_t *hwif = HWIF(drive); struct gendisk *g = drive->disk;
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
if (!strstr("ide-floppy", drive->driver_req)) if (!strstr("ide-floppy", drive->driver_req))
goto failed; goto failed;
if (!drive->present) if (!drive->present)
......
...@@ -848,7 +848,7 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -848,7 +848,7 @@ static void init_gendisk (ide_hwif_t *hwif)
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].fops = ide_fops; gd[unit].fops = ide_fops;
hwif->gd[unit] = gd + unit; hwif->drives[unit].disk = gd + unit;
} }
for (unit = 0; unit < units; ++unit) { for (unit = 0; unit < units; ++unit) {
......
...@@ -1748,10 +1748,7 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio ...@@ -1748,10 +1748,7 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio
void ide_revalidate_drive (ide_drive_t *drive) void ide_revalidate_drive (ide_drive_t *drive)
{ {
ide_hwif_t *hwif = HWIF(drive); drive->disk->part[0].nr_sects = current_capacity(drive);
int unit = drive - hwif->drives;
struct gendisk *g = hwif->gd[unit];
g->part[0].nr_sects = current_capacity(drive);
} }
/* /*
...@@ -2058,13 +2055,13 @@ void ide_unregister (unsigned int index) ...@@ -2058,13 +2055,13 @@ void ide_unregister (unsigned int index)
blk_dev[hwif->major].data = NULL; blk_dev[hwif->major].data = NULL;
blk_dev[hwif->major].queue = NULL; blk_dev[hwif->major].queue = NULL;
blk_clear(hwif->major); blk_clear(hwif->major);
gd = hwif->gd[0]; gd = hwif->drives[0].disk;
if (gd) { if (gd) {
int i; int i;
kfree(gd->part); kfree(gd->part);
kfree(gd); kfree(gd);
for (i = 0; i < MAX_DRIVES; i++) for (i = 0; i < MAX_DRIVES; i++)
hwif->gd[i] = NULL; hwif->drives[i].disk = NULL;
} }
old_hwif = *hwif; old_hwif = *hwif;
init_hwif_data (index); /* restore hwif data to pristine status */ init_hwif_data (index); /* restore hwif data to pristine status */
......
...@@ -530,6 +530,7 @@ typedef struct ide_drive_s { ...@@ -530,6 +530,7 @@ typedef struct ide_drive_s {
unsigned int failures; /* current failure count */ unsigned int failures; /* current failure count */
unsigned int max_failures; /* maximum allowed failure count */ unsigned int max_failures; /* maximum allowed failure count */
struct list_head list; struct list_head list;
struct gendisk *disk;
} ide_drive_t; } ide_drive_t;
/* /*
...@@ -716,7 +717,6 @@ typedef struct hwif_s { ...@@ -716,7 +717,6 @@ typedef struct hwif_s {
*/ */
hw_regs_t hw; /* Hardware info */ hw_regs_t hw; /* Hardware info */
ide_drive_t drives[MAX_DRIVES]; /* drive info */ ide_drive_t drives[MAX_DRIVES]; /* drive info */
struct gendisk *gd[MAX_DRIVES];/* gendisk structure */
int addressing; /* hosts addressing */ int addressing; /* hosts addressing */
void (*tuneproc)(ide_drive_t *, byte); /* routine to tune PIO mode for drives */ void (*tuneproc)(ide_drive_t *, byte); /* routine to tune PIO mode for drives */
int (*speedproc)(ide_drive_t *, byte); /* routine to retune DMA modes for drives */ int (*speedproc)(ide_drive_t *, byte); /* routine to retune DMA modes for drives */
......
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