ide: make drive->id an union (take 2)

Make drive->id an unnamed union so id can be accessed either by using
'u16 *id' or 'struct hd_driveid *driveid'.  Then convert all existing
drive->id users accordingly (using 'u16 *id' when possible).

This is an intermediate step to make ide 'struct hd_driveid'-free.

While at it:

- Add missing KERN_CONTs in it821x.c.

- Use ATA_ID_WORDS and ATA_ID_*_LEN defines.

- Remove unnecessary checks for drive->id.

- s/drive_table/table/ in ide_in_drive_list().

- Cleanup ide_config_drive_speed() a bit.

- s/drive1/dev1/ & s/drive0/dev0/ in ide_undecoded_slave().

v2:
Fix typo in drivers/ide/ppc/pmac.c. (From Stephen Rothwell)

There should be no functional changes caused by this patch.
Signed-off-by: 's avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 5b90e990
......@@ -265,8 +265,8 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
* If we're going to be doing MW_DMA_1 or MW_DMA_2, we should
* take care to note the values in the ID...
*/
if (use_dma_info && drive->id->eide_dma_time > cycle_time)
cycle_time = drive->id->eide_dma_time;
if (use_dma_info && drive->id[ATA_ID_EIDE_DMA_TIME] > cycle_time)
cycle_time = drive->id[ATA_ID_EIDE_DMA_TIME];
drive->drive_data = cycle_time;
......
......@@ -213,7 +213,8 @@ static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed)
palm_bk3710_setudmamode(base, is_slave,
xferspeed - XFER_UDMA_0);
} else {
palm_bk3710_setdmamode(base, is_slave, drive->id->eide_dma_min,
palm_bk3710_setdmamode(base, is_slave,
drive->id[ATA_ID_EIDE_DMA_MIN],
xferspeed);
}
}
......
......@@ -584,7 +584,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
* This function executes the _STM ACPI method for the target channel.
*
* _STM requires Identify Drive data, which has to passed as an argument.
* Unfortunately hd_driveid is a mangled version which we can't readily
* Unfortunately drive->id is a mangled version which we can't readily
* use; hence we'll get the information afresh.
*/
void ide_acpi_push_timing(ide_hwif_t *hwif)
......@@ -614,10 +614,10 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
in_params[0].buffer.length = sizeof(struct GTM_buffer);
in_params[0].buffer.pointer = (u8 *)&hwif->acpidata->gtm;
in_params[1].type = ACPI_TYPE_BUFFER;
in_params[1].buffer.length = sizeof(struct hd_driveid);
in_params[1].buffer.length = sizeof(ATA_ID_WORDS * 2);
in_params[1].buffer.pointer = (u8 *)&master->idbuff;
in_params[2].type = ACPI_TYPE_BUFFER;
in_params[2].buffer.length = sizeof(struct hd_driveid);
in_params[2].buffer.length = sizeof(ATA_ID_WORDS * 2);
in_params[2].buffer.pointer = (u8 *)&slave->idbuff;
/* Output buffer: _STM has no output */
......
......@@ -1866,14 +1866,14 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
{ NULL, NULL, 0 }
};
static unsigned int ide_cd_flags(struct hd_driveid *id)
static unsigned int ide_cd_flags(u16 *id)
{
const struct cd_list_entry *cle = ide_cd_quirks_list;
while (cle->id_model) {
if (strcmp(cle->id_model, id->model) == 0 &&
if (strcmp(cle->id_model, (char *)&id[ATA_ID_PROD]) == 0 &&
(cle->id_firmware == NULL ||
strstr(id->fw_rev, cle->id_firmware)))
strstr((char *)&id[ATA_ID_FW_REV], cle->id_firmware)))
return cle->cd_flags;
cle++;
}
......@@ -1885,7 +1885,8 @@ static int ide_cdrom_setup(ide_drive_t *drive)
{
struct cdrom_info *cd = drive->driver_data;
struct cdrom_device_info *cdi = &cd->devinfo;
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
char *fw_rev = (char *)&id[ATA_ID_FW_REV];
int nslots;
blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn);
......@@ -1900,15 +1901,15 @@ static int ide_cdrom_setup(ide_drive_t *drive)
drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT |
ide_cd_flags(id);
if ((id->config & 0x0060) == 0x20)
if ((id[ATA_ID_CONFIG] & 0x0060) == 0x20)
drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT;
if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) &&
id->fw_rev[4] == '1' && id->fw_rev[6] <= '2')
fw_rev[4] == '1' && fw_rev[6] <= '2')
drive->atapi_flags |= (IDE_AFLAG_TOCTRACKS_AS_BCD |
IDE_AFLAG_TOCADDR_AS_BCD);
else if ((drive->atapi_flags & IDE_AFLAG_VERTOS_600_ESD) &&
id->fw_rev[4] == '1' && id->fw_rev[6] <= '2')
fw_rev[4] == '1' && fw_rev[6] <= '2')
drive->atapi_flags |= IDE_AFLAG_TOCTRACKS_AS_BCD;
else if (drive->atapi_flags & IDE_AFLAG_SANYO_3CD)
/* 3 => use CD in slot 0 */
......
......@@ -99,12 +99,13 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
*
* It is called only once for each drive.
*/
static int lba_capacity_is_ok(struct hd_driveid *id)
static int lba_capacity_is_ok(u16 *id)
{
struct hd_driveid *driveid = (struct hd_driveid *)id;
unsigned long lba_sects, chs_sects, head, tail;
/* No non-LBA info .. so valid! */
if (id->cyls == 0)
if (id[ATA_ID_CYLS] == 0)
return 1;
/*
......@@ -113,15 +114,15 @@ static int lba_capacity_is_ok(struct hd_driveid *id)
* Some drives can be jumpered to use 15 heads instead of 16.
* Some drives can be jumpered to use 4092 cyls instead of 16383.
*/
if ((id->cyls == 16383
|| (id->cyls == 4092 && id->cur_cyls == 16383)) &&
id->sectors == 63 &&
(id->heads == 15 || id->heads == 16) &&
(id->lba_capacity >= 16383*63*id->heads))
if ((id[ATA_ID_CYLS] == 16383 ||
(id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) &&
id[ATA_ID_SECTORS] == 63 &&
(id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
(driveid->lba_capacity >= 16383 * 63 * id[ATA_ID_HEADS]))
return 1;
lba_sects = id->lba_capacity;
chs_sects = id->cyls * id->heads * id->sectors;
lba_sects = driveid->lba_capacity;
chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
/* perform a rough sanity check on lba_sects: within 10% is OK */
if ((lba_sects - chs_sects) < chs_sects/10)
......@@ -132,7 +133,7 @@ static int lba_capacity_is_ok(struct hd_driveid *id)
tail = (lba_sects & 0xffff);
lba_sects = (head | (tail << 16));
if ((lba_sects - chs_sects) < chs_sects/10) {
id->lba_capacity = lba_sects;
driveid->lba_capacity = lba_sects;
return 1; /* lba_capacity is (now) good */
}
......@@ -389,18 +390,20 @@ static unsigned long long sectors_to_MB(unsigned long long n)
* so on non-buggy drives we need test only one.
* However, we should also check whether these fields are valid.
*/
static inline int idedisk_supports_hpa(const struct hd_driveid *id)
static inline int idedisk_supports_hpa(const u16 *id)
{
return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400);
return (id[ATA_ID_COMMAND_SET_1] & 0x0400) &&
(id[ATA_ID_CFS_ENABLE_1] & 0x0400);
}
/*
* The same here.
*/
static inline int idedisk_supports_lba48(const struct hd_driveid *id)
static inline int idedisk_supports_lba48(const u16 *id)
{
return (id->command_set_2 & 0x0400) && (id->cfs_enable_2 & 0x0400)
&& id->lba_capacity_2;
return (id[ATA_ID_COMMAND_SET_2] & 0x0400) &&
(id[ATA_ID_CFS_ENABLE_2] & 0x0400) &&
((struct hd_driveid *)id)->lba_capacity_2;
}
/*
......@@ -453,7 +456,8 @@ static void idedisk_check_hpa(ide_drive_t *drive)
static void init_idedisk_capacity(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
struct hd_driveid *driveid = drive->driveid;
u16 *id = drive->id;
/*
* If this drive supports the Host Protected Area feature set,
* then we may need to change our opinion about the drive's capacity.
......@@ -463,13 +467,13 @@ static void init_idedisk_capacity(ide_drive_t *drive)
if (idedisk_supports_lba48(id)) {
/* drive speaks 48-bit LBA */
drive->select.b.lba = 1;
drive->capacity64 = id->lba_capacity_2;
drive->capacity64 = driveid->lba_capacity_2;
if (hpa)
idedisk_check_hpa(drive);
} else if ((id->capability & 2) && lba_capacity_is_ok(id)) {
} else if ((driveid->capability & 2) && lba_capacity_is_ok(id)) {
/* drive speaks 28-bit LBA */
drive->select.b.lba = 1;
drive->capacity64 = id->lba_capacity;
drive->capacity64 = driveid->lba_capacity;
if (hpa)
idedisk_check_hpa(drive);
} else {
......@@ -523,7 +527,7 @@ static int proc_idedisk_read_cache
int len;
if (drive->id_read)
len = sprintf(out, "%i\n", drive->id->buf_size / 2);
len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2);
else
len = sprintf(out, "(none)\n");
......@@ -618,7 +622,7 @@ static int set_multcount(ide_drive_t *drive, int arg)
struct request *rq;
int error;
if (arg < 0 || arg > drive->id->max_multsect)
if (arg < 0 || arg > drive->driveid->max_multsect)
return -EINVAL;
if (drive->special.b.set_multmode)
......@@ -650,7 +654,7 @@ static int set_nowerr(ide_drive_t *drive, int arg)
static void update_ordered(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
unsigned ordered = QUEUE_ORDERED_NONE;
prepare_flush_fn *prep_fn = NULL;
......@@ -762,8 +766,6 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
#ifdef CONFIG_IDE_PROC_FS
static void idedisk_add_settings(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1,
&drive->bios_cyl, NULL);
ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1,
......@@ -773,7 +775,7 @@ static void idedisk_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1,
&drive->addressing, set_lba_addressing);
ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0,
id->max_multsect, 1, 1, &drive->mult_count,
drive->driveid->max_multsect, 1, 1, &drive->mult_count,
set_multcount);
ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1,
&drive->nowerr, set_nowerr);
......@@ -795,7 +797,8 @@ static inline void idedisk_add_settings(ide_drive_t *drive) { ; }
static void idedisk_setup(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
char *m = (char *)&id[ATA_ID_PROD];
unsigned long long capacity;
idedisk_add_settings(drive);
......@@ -807,7 +810,7 @@ static void idedisk_setup(ide_drive_t *drive)
/*
* Removable disks (eg. SYQUEST); ignore 'WD' drives
*/
if (id->model[0] != 'W' || id->model[1] != 'D')
if (m[0] != 'W' || m[1] != 'D')
drive->doorlocking = 1;
}
......@@ -880,14 +883,14 @@ static void idedisk_setup(ide_drive_t *drive)
drive->name, capacity, sectors_to_MB(capacity));
/* Only print cache size when it was specified */
if (id->buf_size)
printk(KERN_CONT " w/%dKiB Cache", id->buf_size / 2);
if (id[ATA_ID_BUF_SIZE])
printk(KERN_CONT " w/%dKiB Cache", id[ATA_ID_BUF_SIZE] / 2);
printk(KERN_CONT ", CHS=%d/%d/%d\n",
drive->bios_cyl, drive->bios_head, drive->bios_sect);
/* write cache enabled? */
if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))
if ((id[ATA_ID_CSFO] & 1) || (id[ATA_ID_CFS_ENABLE_1] & (1 << 5)))
drive->wcache = 1;
write_cache(drive, 1);
......
......@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
static int config_drive_for_dma (ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
if (drive->media != ide_disk) {
if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA)
......@@ -299,16 +299,17 @@ static int config_drive_for_dma (ide_drive_t *drive)
* Enable DMA on any drive that has
* UltraDMA (mode 0/1/2/3/4/5/6) enabled
*/
if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
if ((id[ATA_ID_FIELD_VALID] & 4) &&
((id[ATA_ID_UDMA_MODES] >> 8) & 0x7f))
return 1;
/*
* Enable DMA on any drive that has mode2 DMA
* (multi or single) enabled
*/
if (id->field_valid & 2) /* regular DMA */
if ((id->dma_mword & 0x404) == 0x404 ||
(id->dma_1word & 0x404) == 0x404)
if (id[ATA_ID_FIELD_VALID] & 2) /* regular DMA */
if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 ||
(id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404)
return 1;
/* Consult the list of known "good" drives */
......@@ -591,12 +592,12 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
int __ide_dma_bad_drive (ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
int blacklist = ide_in_drive_list(id, drive_blacklist);
if (blacklist) {
printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n",
drive->name, id->model);
drive->name, (char *)&id[ATA_ID_PROD]);
return blacklist;
}
return 0;
......@@ -612,21 +613,21 @@ static const u8 xfer_mode_bases[] = {
static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
{
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
ide_hwif_t *hwif = drive->hwif;
const struct ide_port_ops *port_ops = hwif->port_ops;
unsigned int mask = 0;
switch(base) {
case XFER_UDMA_0:
if ((id->field_valid & 4) == 0)
if ((id[ATA_ID_FIELD_VALID] & 4) == 0)
break;
if (port_ops && port_ops->udma_filter)
mask = port_ops->udma_filter(drive);
else
mask = hwif->ultra_mask;
mask &= id->dma_ultra;
mask &= id[ATA_ID_UDMA_MODES];
/*
* avoid false cable warning from eighty_ninty_three()
......@@ -637,19 +638,19 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
}
break;
case XFER_MW_DMA_0:
if ((id->field_valid & 2) == 0)
if ((id[ATA_ID_FIELD_VALID] & 2) == 0)
break;
if (port_ops && port_ops->mdma_filter)
mask = port_ops->mdma_filter(drive);
else
mask = hwif->mwdma_mask;
mask &= id->dma_mword;
mask &= id[ATA_ID_MWDMA_MODES];
break;
case XFER_SW_DMA_0:
if (id->field_valid & 2) {
mask = id->dma_1word & hwif->swdma_mask;
} else if (id->tDMA) {
u8 mode = id->tDMA;
if (id[ATA_ID_FIELD_VALID] & 2) {
mask = id[ATA_ID_SWDMA_MODES] & hwif->swdma_mask;
} else if (drive->driveid->tDMA) {
u8 mode = drive->driveid->tDMA;
/*
* if the mode is valid convert it to the mask
......@@ -706,7 +707,8 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode)
/*
* is this correct?
*/
if (ide_dma_good_drive(drive) && drive->id->eide_dma_time < 150)
if (ide_dma_good_drive(drive) &&
drive->id[ATA_ID_EIDE_DMA_TIME] < 150)
mode = XFER_MW_DMA_1;
}
......@@ -725,7 +727,7 @@ static int ide_tune_dma(ide_drive_t *drive)
ide_hwif_t *hwif = drive->hwif;
u8 speed;
if (drive->nodma || (drive->id->capability & 1) == 0)
if (drive->nodma || (drive->driveid->capability & 1) == 0)
return 0;
/* consult the list of known "bad" drives */
......@@ -767,13 +769,15 @@ static int ide_dma_check(ide_drive_t *drive)
int ide_id_dma_bug(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
if (id->field_valid & 4) {
if ((id->dma_ultra >> 8) && (id->dma_mword >> 8))
if (id[ATA_ID_FIELD_VALID] & 4) {
if ((id[ATA_ID_UDMA_MODES] >> 8) &&
(id[ATA_ID_MWDMA_MODES] >> 8))
goto err_out;
} else if (id->field_valid & 2) {
if ((id->dma_mword >> 8) && (id->dma_1word >> 8))
} else if (id[ATA_ID_FIELD_VALID] & 2) {
if ((id[ATA_ID_MWDMA_MODES] >> 8) &&
(id[ATA_ID_SWDMA_MODES] >> 8))
goto err_out;
}
return 0;
......
......@@ -965,12 +965,12 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
* Check whether we can support a drive, based on the ATAPI IDENTIFY command
* results.
*/
static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id)
static int idefloppy_identify_device(ide_drive_t *drive, u16 *id)
{
u8 gcw[2];
u8 device_type, protocol, removable, drq_type, packet_size;
*((u16 *) &gcw) = id->config;
*((u16 *)&gcw) = id[ATA_ID_CONFIG];
device_type = gcw[1] & 0x1F;
removable = (gcw[0] & 0x80) >> 7;
......@@ -981,7 +981,8 @@ static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id)
#ifdef CONFIG_PPC
/* kludge for Apple PowerBook internal zip */
if (device_type == 5 &&
!strstr(id->model, "CD-ROM") && strstr(id->model, "ZIP"))
!strstr((char *)&id[ATA_ID_PROD], "CD-ROM") &&
strstr((char *)&id[ATA_ID_PROD], "ZIP"))
device_type = 0;
#endif
......@@ -1024,9 +1025,10 @@ static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
{
u16 *id = drive->id;
u8 gcw[2];
*((u16 *) &gcw) = drive->id->config;
*((u16 *)&gcw) = id[ATA_ID_CONFIG];
floppy->pc = floppy->pc_stack;
drive->pc_callback = ide_floppy_callback;
......@@ -1041,7 +1043,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
* it. It should be fixed as of version 1.9, but to be on the safe side
* we'll leave the limitation below for the 2.2.x tree.
*/
if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) {
if (!strncmp((char *)&id[ATA_ID_PROD], "IOMEGA ZIP 100 ATAPI", 20)) {
drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE;
/* This value will be visible in the /proc/ide/hdx/settings */
floppy->ticks = IDEFLOPPY_TICKS_DELAY;
......@@ -1052,7 +1054,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
* Guess what? The IOMEGA Clik! drive also needs the above fix. It makes
* nasty clicking noises without it, so please don't remove this.
*/
if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) {
if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) {
blk_queue_max_sectors(drive->queue, 64);
drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE;
}
......
......@@ -400,11 +400,11 @@ const struct ide_tp_ops default_tp_ops = {
.output_data = ide_output_data,
};
void ide_fix_driveid(struct hd_driveid *driveid)
void ide_fix_driveid(u16 *id)
{
#ifndef __LITTLE_ENDIAN
# ifdef __BIG_ENDIAN
u16 *id = (u16 *)driveid;
struct hd_driveid *driveid = (struct hd_driveid *)id;
int i;
for (i = 0; i < 256; i++) {
......@@ -593,18 +593,18 @@ EXPORT_SYMBOL(ide_wait_stat);
/**
* ide_in_drive_list - look for drive in black/white list
* @id: drive identifier
* @drive_table: list to inspect
* @table: list to inspect
*
* Look for a drive in the blacklist and the whitelist tables
* Returns 1 if the drive is found in the table.
*/
int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
int ide_in_drive_list(u16 *id, const struct drive_list_entry *table)
{
for ( ; drive_table->id_model; drive_table++)
if ((!strcmp(drive_table->id_model, id->model)) &&
(!drive_table->id_firmware ||
strstr(id->fw_rev, drive_table->id_firmware)))
for ( ; table->id_model; table++)
if ((!strcmp(table->id_model, (char *)&id[ATA_ID_PROD])) &&
(!table->id_firmware ||
strstr((char *)&id[ATA_ID_FW_REV], table->id_firmware)))
return 1;
return 0;
}
......@@ -635,7 +635,7 @@ static const struct drive_list_entry ivb_list[] = {
u8 eighty_ninty_three (ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
int ivb = ide_in_drive_list(id, ivb_list);
if (hwif->cbl == ATA_CBL_PATA40_SHORT)
......@@ -657,7 +657,8 @@ u8 eighty_ninty_three (ide_drive_t *drive)
* - force bit13 (80c cable present) check also for !ivb devices
* (unless the slave device is pre-ATA3)
*/
if ((id->hw_config & 0x4000) || (ivb && (id->hw_config & 0x2000)))
if ((id[ATA_ID_HW_CONFIG] & 0x4000) ||
(ivb && (id[ATA_ID_HW_CONFIG] & 0x2000)))
return 1;
no_80w:
......@@ -678,7 +679,7 @@ int ide_driveid_update(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
struct hd_driveid *id;
u16 *id;
unsigned long timeout, flags;
u8 stat;
......@@ -722,16 +723,16 @@ int ide_driveid_update(ide_drive_t *drive)
local_irq_enable();
local_irq_restore(flags);
ide_fix_driveid(id);
if (id) {
drive->id->dma_ultra = id->dma_ultra;
drive->id->dma_mword = id->dma_mword;
drive->id->dma_1word = id->dma_1word;
/* anything more ? */
kfree(id);
if (drive->using_dma && ide_id_dma_bug(drive))
ide_dma_off(drive);
}
drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES];
drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES];
drive->id[ATA_ID_SWDMA_MODES] = id[ATA_ID_SWDMA_MODES];
/* anything more ? */
kfree(id);
if (drive->using_dma && ide_id_dma_bug(drive))
ide_dma_off(drive);
return 1;
}
......@@ -740,6 +741,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
{
ide_hwif_t *hwif = drive->hwif;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
u16 *id = drive->id, i;
int error = 0;
u8 stat;
ide_task_t task;
......@@ -750,7 +752,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
#endif
/* Skip setting PIO flow-control modes on pre-EIDE drives */
if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08))
if ((speed & 0xf8) == XFER_PIO_0 && !(drive->driveid->capability & 8))
goto skip;
/*
......@@ -802,9 +804,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
return error;
}
drive->id->dma_ultra &= ~0xFF00;
drive->id->dma_mword &= ~0x0F00;
drive->id->dma_1word &= ~0x0F00;
id[ATA_ID_UDMA_MODES] &= ~0xFF00;
id[ATA_ID_MWDMA_MODES] &= ~0x0F00;
id[ATA_ID_SWDMA_MODES] &= ~0x0F00;
skip:
#ifdef CONFIG_BLK_DEV_IDEDMA
......@@ -814,23 +816,17 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
ide_dma_off_quietly(drive);
#endif
switch(speed) {
case XFER_UDMA_7: drive->id->dma_ultra |= 0x8080; break;
case XFER_UDMA_6: drive->id->dma_ultra |= 0x4040; break;
case XFER_UDMA_5: drive->id->dma_ultra |= 0x2020; break;
case XFER_UDMA_4: drive->id->dma_ultra |= 0x1010; break;
case XFER_UDMA_3: drive->id->dma_ultra |= 0x0808; break;
case XFER_UDMA_2: drive->id->dma_ultra |= 0x0404; break;
case XFER_UDMA_1: drive->id->dma_ultra |= 0x0202; break;
case XFER_UDMA_0: drive->id->dma_ultra |= 0x0101; break;
case XFER_MW_DMA_2: drive->id->dma_mword |= 0x0404; break;
case XFER_MW_DMA_1: drive->id->dma_mword |= 0x0202; break;
case XFER_MW_DMA_0: drive->id->dma_mword |= 0x0101; break;
case XFER_SW_DMA_2: drive->id->dma_1word |= 0x0404; break;
case XFER_SW_DMA_1: drive->id->dma_1word |= 0x0202; break;
case XFER_SW_DMA_0: drive->id->dma_1word |= 0x0101; break;
default: break;
if (speed >= XFER_UDMA_0) {
i = 1 << (speed - XFER_UDMA_0);
id[ATA_ID_UDMA_MODES] |= (i << 8 | i);
} else if (speed >= XFER_MW_DMA_0) {
i = 1 << (speed - XFER_MW_DMA_0);
id[ATA_ID_MWDMA_MODES] |= (i << 8 | i);
} else if (speed >= XFER_SW_DMA_0) {
i = 1 << (speed - XFER_SW_DMA_0);
id[ATA_ID_SWDMA_MODES] |= (i << 8 | i);
}
if (!drive->init_speed)
drive->init_speed = speed;
drive->current_speed = speed;
......@@ -1035,7 +1031,7 @@ out:
static void ide_disk_pre_reset(ide_drive_t *drive)
{
int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1;
int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
drive->special.all = 0;
drive->special.b.set_geometry = legacy;
......
......@@ -90,29 +90,31 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
{
int pio_mode;
struct hd_driveid* id = drive->id;
int overridden = 0;
u16 *id = drive->id;
int pio_mode = -1, overridden = 0;
if (mode_wanted != 255)
return min_t(u8, mode_wanted, max_mode);
if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 &&
(pio_mode = ide_scan_pio_blacklist(id->model)) != -1) {
if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0)
pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]);
if (pio_mode != -1) {
printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
} else {
pio_mode = id->tPIO;
pio_mode = drive->driveid->tPIO;
if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */
pio_mode = 2;
overridden = 1;
}
if (id->field_valid & 2) { /* drive implements ATA2? */
if (id->capability & 8) { /* IORDY supported? */
if (id->eide_pio_modes & 7) {
if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */
if (drive->driveid->capability & 8) { /* IORDY sup? */
if (id[ATA_ID_PIO_MODES] & 7) {
overridden = 0;
if (id->eide_pio_modes & 4)
if (id[ATA_ID_PIO_MODES] & 4)
pio_mode = 5;
else if (id->eide_pio_modes & 2)
else if (id[ATA_ID_PIO_MODES] & 2)
pio_mode = 4;
else
pio_mode = 3;
......
......@@ -50,44 +50,44 @@
static void generic_id(ide_drive_t *drive)
{
drive->id->cyls = drive->cyl;
drive->id->heads = drive->head;
drive->id->sectors = drive->sect;
drive->id->cur_cyls = drive->cyl;
drive->id->cur_heads = drive->head;
drive->id->cur_sectors = drive->sect;
u16 *id = drive->id;
id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl;
id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head;
id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect;
}
static void ide_disk_init_chs(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
u16 *id = drive->id;
/* Extract geometry if we did not already have one for the drive */
if (!drive->cyl || !drive->head || !drive->sect) {
drive->cyl = drive->bios_cyl = id->cyls;
drive->head = drive->bios_head = id->heads;
drive->sect = drive->bios_sect = id->sectors;
drive->cyl = drive->bios_cyl = id[ATA_ID_CYLS];
drive->head = drive->bios_head = id[ATA_ID_HEADS];
drive->sect = drive->bios_sect = id[ATA_ID_SECTORS];
}
/* Handle logical geometry translation by the drive */
if ((id->field_valid & 1) && id->cur_cyls &&