Skip to contentSkip to conversation

ide: make ide 'struct hd_driveid'-free

PATCH New Bartlomiej Zolnierkiewicz 1 participant 11 messages Jul 22, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ide: make ide 'struct hd_driveid'-free

Hi,

This patchset (against pata tree + recently posted 'ata: add missing ATA_ID_* defines (take 2)' patch) converts drivers/ide/ from using struct hd_driveid to use 'raw' id + ATA_ID_* defines instead. This is a part of larger project to remove <linux/hdreg.h> + allows us to safely use ata_id_() & co. inline helpers from <linux/ata.h> in drivers/ide/.

patches:
#01-02 - drive-by fixes
#03-05 - preparatory cleanups
#06-07 - main conversion from struct hd_driveid to 'raw' id #08-10 - use more ata_id_*() helpers in drivers/ide/

diffstat:

 drivers/ide/arm/icside.c       |    4 
 drivers/ide/arm/palm_bk3710.c  |    3 
 drivers/ide/ide-acpi.c         |    6 -
 drivers/ide/ide-cd.c           |   15 +-
 drivers/ide/ide-disk.c         |  103 +++++++++-----------
 drivers/ide/ide-dma.c          |   62 ++++++------
 drivers/ide/ide-floppy.c       |   14 +-
 drivers/ide/ide-io.c           |    2 
 drivers/ide/ide-iops.c         |  209 +++++++++++------------------------------
 drivers/ide/ide-lib.c          |   28 ++---
 drivers/ide/ide-probe.c        |  164 ++++++++++++++++----------------
 drivers/ide/ide-proc.c         |    5 
 drivers/ide/ide-tape.c         |    7 -
 drivers/ide/ide-taskfile.c     |    6 -
 drivers/ide/ide-timings.c      |   23 ++--
 drivers/ide/ide.c              |   67 ++++++++++---
 drivers/ide/legacy/qd65xx.c    |   26 ++---
 drivers/ide/pci/alim15x3.c     |    4 
 drivers/ide/pci/cs5530.c       |   12 +-
 drivers/ide/pci/hpt366.c       |    8 -
 drivers/ide/pci/it821x.c       |   55 +++++-----
 drivers/ide/pci/pdc202xx_new.c |    4 
 drivers/ide/pci/pdc202xx_old.c |    8 -
 drivers/ide/pci/sc1200.c       |   12 +-
 drivers/ide/pci/serverworks.c  |    4 
 drivers/ide/pci/siimage.c      |    8 -
 drivers/ide/ppc/pmac.c         |    6 -
 drivers/scsi/ide-scsi.c        |   13 +-
 include/linux/ide.h            |   32 +++---
 29 files changed, 438 insertions(+), 472 deletions(-)
#1 lore raw

PATCH 1/10 ide: fix pre-EIDE SWDMA support on big-endian

id->tDMA is of 'unsigned char' type so endianness is already correct and calling le16_to_cpu() is wrong.

---
 drivers/ide/ide-dma.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/ide/ide-dma.c +1 -5
Index: b/drivers/ide/ide-dma.c
===================================================================
@@ -649,11 +649,7 @@ static unsigned int ide_get_mode_mask(id
 		if (id->field_valid & 2) {
 			mask = id->dma_1word & hwif->swdma_mask;
 		} else if (id->tDMA) {
-			/*
-			 * ide_fix_driveid() doesn't convert ->tDMA to the
-			 * CPU endianness so we need to do it here
-			 */
-			u8 mode = le16_to_cpu(id->tDMA);
+			u8 mode = id->tDMA;
 
 			/*
 			 * if the mode is valid convert it to the mask
#2 lore raw

PATCH 2/10 ide: fix ide_fix_driveid()

In reply to Bartlomiej Zolnierkiewicz

Fix byte-swapping for id->words161_175[], id->words206_254[] and id->words206_254[].

[ Luckily all words previously left in LE byte-order are marked as
reserved so this fix shouldn't affect user-space applications. ]

---
 drivers/ide/ide-iops.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ide/ide-iops.c +3 -3
Index: b/drivers/ide/ide-iops.c
===================================================================
@@ -484,11 +484,11 @@ void ide_fix_driveid (struct hd_driveid 
 	for (i = 0; i < 3; i++)
 		id->words157_159[i] = __le16_to_cpu(id->words157_159[i]);
 	id->cfa_power      = __le16_to_cpu(id->cfa_power);
-	for (i = 0; i < 14; i++)
+	for (i = 0; i < 15; i++)
 		id->words161_175[i] = __le16_to_cpu(id->words161_175[i]);
-	for (i = 0; i < 31; i++)
+	for (i = 0; i < 30; i++)
 		id->words176_205[i] = __le16_to_cpu(id->words176_205[i]);
-	for (i = 0; i < 48; i++)
+	for (i = 0; i < 49; i++)
 		id->words206_254[i] = __le16_to_cpu(id->words206_254[i]);
 	id->integrity_word  = __le16_to_cpu(id->integrity_word);
 # else
#3 lore raw

PATCH 3/10 ide: remove superfluous check from ide_disk_special()

In reply to Bartlomiej Zolnierkiewicz

This condition is checked by both ide_disk_init_mult_count() and set_multcount() so no need to do it again in ide_disk_special().

---
 drivers/ide/ide-io.c |    2 --
 1 file changed, 2 deletions(-)
drivers/ide/ide-io.c +0 -2
Index: b/drivers/ide/ide-io.c
===================================================================
@@ -540,8 +540,6 @@ static ide_startstop_t ide_disk_special(
 		ide_tf_set_restore_cmd(drive, &args.tf);
 	} else if (s->b.set_multmode) {
 		s->b.set_multmode = 0;
-		if (drive->mult_req > drive->id->max_multsect)
-			drive->mult_req = drive->id->max_multsect;
 		ide_tf_set_setmult_cmd(drive, &args.tf);
 	} else if (s->all) {
 		int special = s->all;
#4 lore raw

PATCH 4/10 ide: cleanup ide_disk_init_mult_count()

In reply to Bartlomiej Zolnierkiewicz

* Remove superfluous checks for drive->mult_req.

* No need to zero drive's fields.

* Move the common code out of #ifdef scope.

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-probe.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/ide/ide-probe.c +10 -11
Index: b/drivers/ide/ide-probe.c
===================================================================
@@ -89,20 +89,19 @@ static void ide_disk_init_mult_count(ide
 {
 	struct hd_driveid *id = drive->id;
 
-	drive->mult_count = 0;
 	if (id->max_multsect) {
 #ifdef CONFIG_IDEDISK_MULTI_MODE
-		id->multsect = ((id->max_multsect/2) > 1) ? id->max_multsect : 0;
-		id->multsect_valid = id->multsect ? 1 : 0;
-		drive->mult_req = id->multsect_valid ? id->max_multsect : 0;
-		drive->special.b.set_multmode = drive->mult_req ? 1 : 0;
-#else	/* original, pre IDE-NFG, per request of AC */
-		drive->mult_req = 0;
-		if (drive->mult_req > id->max_multsect)
-			drive->mult_req = id->max_multsect;
-		if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect))
-			drive->special.b.set_multmode = 1;
+		if ((id->max_multsect / 2) > 1) {
+			id->multsect = id->max_multsect;
+			id->multsect_valid = 1;
+		} else {
+			id->multsect = 0;
+			id->multsect_valid = 0;
+		}
+		drive->mult_req = id->multsect;
 #endif
+		if ((id->multsect_valid & 1) && id->multsect)
+			drive->special.b.set_multmode = 1;
 	}
 }
 
#5 lore raw

PATCH 5/10 ide: cleanup ide_fix_driveid()

In reply to Bartlomiej Zolnierkiewicz

Do all __le16_to_cpu() swapping in one loop.

---
 drivers/ide/ide-iops.c |  105 ++++++++-----------------------------------------
 1 file changed, 19 insertions(+), 86 deletions(-)
drivers/ide/ide-iops.c +19 -86
Index: b/drivers/ide/ide-iops.c
===================================================================
@@ -400,97 +400,30 @@ const struct ide_tp_ops default_tp_ops =
 	.output_data		= ide_output_data,
 };
 
-void ide_fix_driveid (struct hd_driveid *id)
+void ide_fix_driveid(struct hd_driveid *driveid)
 {
 #ifndef __LITTLE_ENDIAN
 # ifdef __BIG_ENDIAN
+	u16 *id = (u16 *)driveid;
 	int i;
-	u16 *stringcast;
 
-	id->config         = __le16_to_cpu(id->config);
-	id->cyls           = __le16_to_cpu(id->cyls);
-	id->reserved2      = __le16_to_cpu(id->reserved2);
-	id->heads          = __le16_to_cpu(id->heads);
-	id->track_bytes    = __le16_to_cpu(id->track_bytes);
-	id->sector_bytes   = __le16_to_cpu(id->sector_bytes);
-	id->sectors        = __le16_to_cpu(id->sectors);
-	id->vendor0        = __le16_to_cpu(id->vendor0);
-	id->vendor1        = __le16_to_cpu(id->vendor1);
-	id->vendor2        = __le16_to_cpu(id->vendor2);
-	stringcast = (u16 *)&id->serial_no[0];
-	for (i = 0; i < (20/2); i++)
-		stringcast[i] = __le16_to_cpu(stringcast[i]);
-	id->buf_type       = __le16_to_cpu(id->buf_type);
-	id->buf_size       = __le16_to_cpu(id->buf_size);
-	id->ecc_bytes      = __le16_to_cpu(id->ecc_bytes);
-	stringcast = (u16 *)&id->fw_rev[0];
-	for (i = 0; i < (8/2); i++)
-		stringcast[i] = __le16_to_cpu(stringcast[i]);
-	stringcast = (u16 *)&id->model[0];
-	for (i = 0; i < (40/2); i++)
-		stringcast[i] = __le16_to_cpu(stringcast[i]);
-	id->dword_io       = __le16_to_cpu(id->dword_io);
-	id->reserved50     = __le16_to_cpu(id->reserved50);
-	id->field_valid    = __le16_to_cpu(id->field_valid);
-	id->cur_cyls       = __le16_to_cpu(id->cur_cyls);
-	id->cur_heads      = __le16_to_cpu(id->cur_heads);
-	id->cur_sectors    = __le16_to_cpu(id->cur_sectors);
-	id->cur_capacity0  = __le16_to_cpu(id->cur_capacity0);
-	id->cur_capacity1  = __le16_to_cpu(id->cur_capacity1);
-	id->lba_capacity   = __le32_to_cpu(id->lba_capacity);
-	id->dma_1word      = __le16_to_cpu(id->dma_1word);
-	id->dma_mword      = __le16_to_cpu(id->dma_mword);
-	id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes);
-	id->eide_dma_min   = __le16_to_cpu(id->eide_dma_min);
-	id->eide_dma_time  = __le16_to_cpu(id->eide_dma_time);
-	id->eide_pio       = __le16_to_cpu(id->eide_pio);
-	id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy);
-	for (i = 0; i < 2; ++i)
-		id->words69_70[i] = __le16_to_cpu(id->words69_70[i]);
-	for (i = 0; i < 4; ++i)
-		id->words71_74[i] = __le16_to_cpu(id->words71_74[i]);
-	id->queue_depth    = __le16_to_cpu(id->queue_depth);
-	for (i = 0; i < 4; ++i)
-		id->words76_79[i] = __le16_to_cpu(id->words76_79[i]);
-	id->major_rev_num  = __le16_to_cpu(id->major_rev_num);
-	id->minor_rev_num  = __le16_to_cpu(id->minor_rev_num);
-	id->command_set_1  = __le16_to_cpu(id->command_set_1);
-	id->command_set_2  = __le16_to_cpu(id->command_set_2);
-	id->cfsse          = __le16_to_cpu(id->cfsse);
-	id->cfs_enable_1   = __le16_to_cpu(id->cfs_enable_1);
-	id->cfs_enable_2   = __le16_to_cpu(id->cfs_enable_2);
-	id->csf_default    = __le16_to_cpu(id->csf_default);
-	id->dma_ultra      = __le16_to_cpu(id->dma_ultra);
-	id->trseuc         = __le16_to_cpu(id->trseuc);
-	id->trsEuc         = __le16_to_cpu(id->trsEuc);
-	id->CurAPMvalues   = __le16_to_cpu(id->CurAPMvalues);
-	id->mprc           = __le16_to_cpu(id->mprc);
-	id->hw_config      = __le16_to_cpu(id->hw_config);
-	id->acoustic       = __le16_to_cpu(id->acoustic);
-	id->msrqs          = __le16_to_cpu(id->msrqs);
-	id->sxfert         = __le16_to_cpu(id->sxfert);
-	id->sal            = __le16_to_cpu(id->sal);
-	id->spg            = __le32_to_cpu(id->spg);
-	id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2);
-	for (i = 0; i < 22; i++)
-		id->words104_125[i]   = __le16_to_cpu(id->words104_125[i]);
-	id->last_lun       = __le16_to_cpu(id->last_lun);
-	id->word127        = __le16_to_cpu(id->word127);
-	id->dlf            = __le16_to_cpu(id->dlf);
-	id->csfo           = __le16_to_cpu(id->csfo);
-	for (i = 0; i < 26; i++)
-		id->words130_155[i] = __le16_to_cpu(id->words130_155[i]);
-	id->word156        = __le16_to_cpu(id->word156);
-	for (i = 0; i < 3; i++)
-		id->words157_159[i] = __le16_to_cpu(id->words157_159[i]);
-	id->cfa_power      = __le16_to_cpu(id->cfa_power);
-	for (i = 0; i < 15; i++)
-		id->words161_175[i] = __le16_to_cpu(id->words161_175[i]);
-	for (i = 0; i < 30; i++)
-		id->words176_205[i] = __le16_to_cpu(id->words176_205[i]);
-	for (i = 0; i < 49; i++)
-		id->words206_254[i] = __le16_to_cpu(id->words206_254[i]);
-	id->integrity_word  = __le16_to_cpu(id->integrity_word);
+	for (i = 0; i < 256; i++) {
+		/*  these words are accessed as two 8-bit values */
+		if (i == 47 || i == 49 || i == 51 || i == 52 || i == 59)
+			continue;
+		if (i == 60 || i == 61)	/* ->lba_capacity is 32-bit */
+			continue;
+		if (i == 98 || i == 99)	/* ->spg is 32-bit */
+			continue;
+		if (i > 99 && i < 104)	/* ->lba_capacity_2 is 64-bit */
+			continue;
+
+		id[i] = __le16_to_cpu(id[i]);
+	}
+
+	driveid->lba_capacity	= __le32_to_cpu(driveid->lba_capacity);
+	driveid->spg		= __le32_to_cpu(driveid->spg);
+	driveid->lba_capacity_2	= __le64_to_cpu(driveid->lba_capacity_2);
 # else
 #  error "Please fix <asm/byteorder.h>"
 # endif
#6 lore raw

PATCH 6/10 ide: make drive->id an union

In reply to Bartlomiej Zolnierkiewicz

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().

There should be no functional changes caused by this patch.

---
 drivers/ide/arm/icside.c       |    4 -
 drivers/ide/arm/palm_bk3710.c  |    3 -
 drivers/ide/ide-acpi.c         |    6 +-
 drivers/ide/ide-cd.c           |   15 ++---
 drivers/ide/ide-disk.c         |   63 +++++++++++-----------
 drivers/ide/ide-dma.c          |   50 +++++++++--------
 drivers/ide/ide-floppy.c       |   14 ++--
 drivers/ide/ide-iops.c         |   78 ++++++++++++---------------
 drivers/ide/ide-lib.c          |   24 ++++----
 drivers/ide/ide-probe.c        |  117 +++++++++++++++++++++--------------------
 drivers/ide/ide-proc.c         |    5 -
 drivers/ide/ide-tape.c         |    7 +-
 drivers/ide/ide-taskfile.c     |    6 +-
 drivers/ide/ide-timings.c      |   21 +++----
 drivers/ide/ide.c              |    8 +-
 drivers/ide/legacy/qd65xx.c    |   22 ++++---
 drivers/ide/pci/alim15x3.c     |    4 -
 drivers/ide/pci/cs5530.c       |   10 ++-
 drivers/ide/pci/hpt366.c       |    8 +-
 drivers/ide/pci/it821x.c       |   51 ++++++++---------
 drivers/ide/pci/pdc202xx_new.c |    4 -
 drivers/ide/pci/pdc202xx_old.c |    6 +-
 drivers/ide/pci/sc1200.c       |   10 ++-
 drivers/ide/pci/serverworks.c  |    4 +
 drivers/ide/pci/siimage.c      |    8 +-
 drivers/ide/ppc/pmac.c         |    6 +-
 drivers/scsi/ide-scsi.c        |   13 ++--
 include/linux/ide.h            |   23 ++++----
 28 files changed, 311 insertions(+), 279 deletions(-)
drivers/ide/arm/icside.c +2 -2
Index: b/drivers/ide/arm/icside.c
===================================================================
@@ -265,8 +265,8 @@ static void icside_set_dma_mode(ide_driv
 	 * 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;
 
drivers/ide/arm/palm_bk3710.c +2 -1
Index: b/drivers/ide/arm/palm_bk3710.c
===================================================================
@@ -213,7 +213,8 @@ static void palm_bk3710_set_dma_mode(ide
 		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);
 	}
 }
drivers/ide/ide-acpi.c +3 -3
Index: b/drivers/ide/ide-acpi.c
===================================================================
@@ -584,7 +584,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwi
  * 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 *hw
 	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 */
 
drivers/ide/ide-cd.c +8 -7
Index: b/drivers/ide/ide-cd.c
===================================================================
@@ -1858,14 +1858,14 @@ static const struct cd_list_entry ide_cd
 	{ 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++;
 	}
@@ -1877,7 +1877,8 @@ static int ide_cdrom_setup(ide_drive_t *
 {
 	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);
@@ -1892,15 +1893,15 @@ static int ide_cdrom_setup(ide_drive_t *
 	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 */
drivers/ide/ide-disk.c +33 -30

169 lines not on this page · raw message

drivers/ide/ide-dma.c +27 -23

129 lines not on this page · raw message

drivers/ide/ide-floppy.c +8 -6
Index: b/drivers/ide/ide-floppy.c
===================================================================
@@ -964,12 +964,12 @@ static sector_t idefloppy_capacity(ide_d
  * 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;
@@ -980,7 +980,8 @@ static int idefloppy_identify_device(ide
 #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
 
@@ -1023,9 +1024,10 @@ static inline void idefloppy_add_setting
 
 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;
 
@@ -1040,7 +1042,7 @@ static void idefloppy_setup(ide_drive_t 
 	 * 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;
@@ -1051,7 +1053,7 @@ static void idefloppy_setup(ide_drive_t 
 	 * 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;
 	}
drivers/ide/ide-iops.c +37 -41

155 lines not on this page · raw message

drivers/ide/ide-lib.c +13 -11
Index: b/drivers/ide/ide-lib.c
===================================================================
@@ -90,29 +90,31 @@ static u8 ide_rate_filter(ide_drive_t *d
 
 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;
drivers/ide/ide-probe.c +62 -55

247 lines not on this page · raw message

drivers/ide/ide-proc.c +2 -3
Index: b/drivers/ide/ide-proc.c
===================================================================
@@ -561,11 +561,10 @@ static int proc_ide_read_dmodel
 	(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
 	ide_drive_t	*drive = (ide_drive_t *) data;
-	struct hd_driveid *id = drive->id;
+	char		*m = (char *)&drive->id[ATA_ID_PROD];
 	int		len;
 
-	len = sprintf(page, "%.40s\n",
-		(id && id->model[0]) ? (char *)id->model : "(none)");
+	len = sprintf(page, "%.40s\n", m[0] ? m : "(none)");
 	PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
 }
 
drivers/ide/ide-tape.c +4 -3
Index: b/drivers/ide/ide-tape.c
===================================================================
@@ -2309,7 +2309,7 @@ static int idetape_identify_device(ide_d
 	if (drive->id_read == 0)
 		return 1;
 
-	*((unsigned short *) &gcw) = drive->id->config;
+	*((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];
 
 	protocol	=   (gcw[1] & 0xC0) >> 6;
 	device_type	=    gcw[1] & 0x1F;
@@ -2461,7 +2461,7 @@ static void idetape_setup(ide_drive_t *d
 		drive->dsc_overlap = 0;
 	}
 	/* Seagate Travan drives do not support DSC overlap. */
-	if (strstr(drive->id->model, "Seagate STT3401"))
+	if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401"))
 		drive->dsc_overlap = 0;
 	tape->minor = minor;
 	tape->name[0] = 'h';
@@ -2469,7 +2469,8 @@ static void idetape_setup(ide_drive_t *d
 	tape->name[2] = '0' + minor;
 	tape->chrdev_dir = IDETAPE_DIR_NONE;
 	tape->pc = tape->pc_stack;
-	*((unsigned short *) &gcw) = drive->id->config;
+
+	*((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];
 
 	/* Command packet DRQ type */
 	if (((gcw[0] & 0x60) >> 5) == 1)
drivers/ide/ide-taskfile.c +4 -2
Index: b/drivers/ide/ide-taskfile.c
===================================================================
@@ -729,7 +729,7 @@ int ide_cmd_ioctl (ide_drive_t *drive, u
 	u8 args[4], xfer_rate = 0;
 	ide_task_t tfargs;
 	struct ide_taskfile *tf = &tfargs.tf;
-	struct hd_driveid *id = drive->id;
+	u16 *id = drive->id;
 
 	if (NULL == (void *) arg) {
 		struct request *rq;
@@ -772,7 +772,9 @@ int ide_cmd_ioctl (ide_drive_t *drive, u
 	if (tf->command == WIN_SETFEATURES &&
 	    tf->feature == SETFEATURES_XFER &&
 	    tf->nsect >= XFER_SW_DMA_0 &&
-	    (id->dma_ultra || id->dma_mword || id->dma_1word)) {
+	    (id[ATA_ID_UDMA_MODES] ||
+	     id[ATA_ID_MWDMA_MODES] ||
+	     id[ATA_ID_SWDMA_MODES])) {
 		xfer_rate = args[1];
 		if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) {
 			printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
drivers/ide/ide-timings.c +10 -11
Index: b/drivers/ide/ide-timings.c
===================================================================
@@ -78,15 +78,15 @@ EXPORT_SYMBOL_GPL(ide_timing_find_mode);
 
 u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
 {
-	struct hd_driveid *id = drive->id;
+	u16 *id = drive->id;
 	struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 	u16 cycle = 0;
 
-	if (id->field_valid & 2) {
-		if (id->capability & 8)
-			cycle = id->eide_pio_iordy;
+	if (id[ATA_ID_FIELD_VALID] & 2) {
+		if (drive->driveid->capability & 8)
+			cycle = id[ATA_ID_EIDE_PIO_IORDY];
 		else
-			cycle = id->eide_pio;
+			cycle = id[ATA_ID_EIDE_PIO];
 
 		/* conservative "downgrade" for all pre-ATA2 drives */
 		if (pio < 3 && cycle < t->cycle)
@@ -138,7 +138,7 @@ EXPORT_SYMBOL_GPL(ide_timing_merge);
 int ide_timing_compute(ide_drive_t *drive, u8 speed,
 		       struct ide_timing *t, int T, int UT)
 {
-	struct hd_driveid *id = drive->id;
+	u16 *id = drive->id;
 	struct ide_timing *s, p;
 
 	/*
@@ -157,16 +157,15 @@ int ide_timing_compute(ide_drive_t *driv
 	 * If the drive is an EIDE drive, it can tell us it needs extended
 	 * PIO/MWDMA cycle timing.
 	 */
-	if (id && id->field_valid & 2) {	/* EIDE drive */
-
+	if (id[ATA_ID_FIELD_VALID] & 2) {	/* EIDE drive */
 		memset(&p, 0, sizeof(p));
 
 		if (speed <= XFER_PIO_2)
-			p.cycle = p.cyc8b = id->eide_pio;
+			p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO];
 		else if (speed <= XFER_PIO_5)
-			p.cycle = p.cyc8b = id->eide_pio_iordy;
+			p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY];
 		else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
-			p.cycle = id->eide_dma_min;
+			p.cycle = id[ATA_ID_EIDE_DMA_MIN];
 
 		ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B);
 	}
drivers/ide/ide.c +4 -4
Index: b/drivers/ide/ide.c
===================================================================
@@ -328,7 +328,7 @@ int set_using_dma(ide_drive_t *drive, in
 	if (arg < 0 || arg > 1)
 		return -EINVAL;
 
-	if (!drive->id || !(drive->id->capability & 1))
+	if ((drive->driveid->capability & 1) == 0)
 		goto out;
 
 	if (hwif->dma_ops == NULL)
@@ -710,21 +710,21 @@ static ssize_t model_show(struct device 
 			  char *buf)
 {
 	ide_drive_t *drive = to_ide_device(dev);
-	return sprintf(buf, "%s\n", drive->id->model);
+	return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]);
 }
 
 static ssize_t firmware_show(struct device *dev, struct device_attribute *attr,
 			     char *buf)
 {
 	ide_drive_t *drive = to_ide_device(dev);
-	return sprintf(buf, "%s\n", drive->id->fw_rev);
+	return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]);
 }
 
 static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
 			   char *buf)
 {
 	ide_drive_t *drive = to_ide_device(dev);
-	return sprintf(buf, "%s\n", drive->id->serial_no);
+	return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]);
 }
 
 static struct device_attribute ide_dev_attrs[] = {
drivers/ide/legacy/qd65xx.c +12 -10
Index: b/drivers/ide/legacy/qd65xx.c
===================================================================
@@ -151,12 +151,14 @@ static int qd_find_disk_type (ide_drive_
 		int *active_time, int *recovery_time)
 {
 	struct qd65xx_timing_s *p;
-	char model[40];
+	char *m = (char *)&drive->id[ATA_ID_PROD];
+	char model[ATA_ID_PROD_LEN];
 
-	if (!*drive->id->model) return 0;
+	if (*m == 0)
+		return 0;
 
-	strncpy(model,drive->id->model,40);
-	ide_fixstring(model,40,1); /* byte-swap */
+	strncpy(model, m, ATA_ID_PROD_LEN);
+	ide_fixstring(model, ATA_ID_PROD_LEN, 1); /* byte-swap */
 
 	for (p = qd65xx_timing ; p->offset != -1 ; p++) {
 		if (!strncmp(p->model, model+p->offset, 4)) {
@@ -185,20 +187,20 @@ static void qd_set_timing (ide_drive_t *
 
 static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
+	u16 *id = drive->id;
 	int active_time   = 175;
 	int recovery_time = 415; /* worst case values from the dos driver */
 
 	/*
 	 * FIXME: use "pio" value
 	 */
-	if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)
-		&& drive->id->tPIO && (drive->id->field_valid & 0x02)
-		&& drive->id->eide_pio >= 240) {
-
+	if (!qd_find_disk_type(drive, &active_time, &recovery_time) &&
+	    drive->driveid->tPIO && (id[ATA_ID_FIELD_VALID] & 2) &&
+	    id[ATA_ID_EIDE_PIO] >= 240) {
 		printk(KERN_INFO "%s: PIO mode%d\n", drive->name,
-				drive->id->tPIO);
+				drive->driveid->tPIO);
 		active_time = 110;
-		recovery_time = drive->id->eide_pio - 120;
+		recovery_time = drive->id[ATA_ID_EIDE_PIO] - 120;
 	}
 
 	qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time));
drivers/ide/pci/alim15x3.c +2 -2
Index: b/drivers/ide/pci/alim15x3.c
===================================================================
@@ -134,8 +134,8 @@ static u8 ali_udma_filter(ide_drive_t *d
 	if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
 		if (drive->media != ide_disk)
 			return 0;
-		if (chip_is_1543c_e && strstr(drive->id->model, "WDC ") &&
-		    wdc_udma == 0)
+		if (wdc_udma == 0 && chip_is_1543c_e &&
+		    strstr((char *)&drive->id[ATA_ID_PROD], "WDC "))
 			return 0;
 	}
 
drivers/ide/pci/cs5530.c +6 -4
Index: b/drivers/ide/pci/cs5530.c
===================================================================
@@ -82,16 +82,18 @@ static u8 cs5530_udma_filter(ide_drive_t
 {
 	ide_hwif_t *hwif = drive->hwif;
 	ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1];
-	struct hd_driveid *mateid = mate->id;
+	u16 *mateid = mate->id;
 	u8 mask = hwif->ultra_mask;
 
 	if (mate->present == 0)
 		goto out;
 
-	if ((mateid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
-		if ((mateid->field_valid & 4) && (mateid->dma_ultra & 7))
+	if ((mate->driveid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
+		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
+		    (mateid[ATA_ID_UDMA_MODES] & 7))
 			goto out;
-		if ((mateid->field_valid & 2) && (mateid->dma_mword & 7))
+		if ((mateid[ATA_ID_FIELD_VALID] & 2) &&
+		    (mateid[ATA_ID_MWDMA_MODES] & 7))
 			mask = 0;
 	}
 out:
drivers/ide/pci/hpt366.c +4 -4
Index: b/drivers/ide/pci/hpt366.c
===================================================================
@@ -605,10 +605,10 @@ static const struct hpt_info hpt371n __d
 
 static int check_in_drive_list(ide_drive_t *drive, const char **list)
 {
-	struct hd_driveid *id = drive->id;
+	char *m = (char *)&drive->id[ATA_ID_PROD];
 
 	while (*list)
-		if (!strcmp(*list++,id->model))
+		if (!strcmp(*list++, m))
 			return 1;
 	return 0;
 }
@@ -728,11 +728,11 @@ static void hpt3xx_set_pio_mode(ide_driv
 
 static void hpt3xx_quirkproc(ide_drive_t *drive)
 {
-	struct hd_driveid *id	= drive->id;
+	char *m			= (char *)&drive->id[ATA_ID_PROD];
 	const  char **list	= quirk_drives;
 
 	while (*list)
-		if (strstr(id->model, *list++)) {
+		if (strstr(m, *list++)) {
 			drive->quirk_list = 1;
 			return;
 		}
drivers/ide/pci/it821x.c +25 -26

77 lines not on this page · raw message

drivers/ide/pci/pdc202xx_new.c +2 -2
Index: b/drivers/ide/pci/pdc202xx_new.c
===================================================================
@@ -203,10 +203,10 @@ static u8 __devinit pdcnew_cable_detect(
 
 static void pdcnew_quirkproc(ide_drive_t *drive)
 {
-	const char **list, *model = drive->id->model;
+	const char **list, *m = (char *)&drive->id[ATA_ID_PROD];
 
 	for (list = pdc_quirk_drives; *list != NULL; list++)
-		if (strstr(model, *list) != NULL) {
+		if (strstr(m, *list) != NULL) {
 			drive->quirk_list = 2;
 			return;
 		}
drivers/ide/pci/pdc202xx_old.c +3 -3
Index: b/drivers/ide/pci/pdc202xx_old.c
===================================================================
@@ -86,7 +86,7 @@ static void pdc202xx_set_mode(ide_drive_
 		 * Prefetch_EN / IORDY_EN / PA[3:0] bits of register A
 		 */
 		AP &= ~0x3f;
-		if (drive->id->capability & 4)
+		if (drive->driveid->capability & 4)
 			AP |= 0x20;	/* set IORDY_EN bit */
 		if (drive->media == ide_disk)
 			AP |= 0x10;	/* set Prefetch_EN bit */
@@ -154,10 +154,10 @@ static void pdc_old_disable_66MHz_clock(
 
 static void pdc202xx_quirkproc(ide_drive_t *drive)
 {
-	const char **list, *model = drive->id->model;
+	const char **list, *m = (char *)&drive->id[ATA_ID_PROD];
 
 	for (list = pdc_quirk_drives; *list != NULL; list++)
-		if (strstr(model, *list) != NULL) {
+		if (strstr(m, *list) != NULL) {
 			drive->quirk_list = 2;
 			return;
 		}
drivers/ide/pci/sc1200.c +6 -4
Index: b/drivers/ide/pci/sc1200.c
===================================================================
@@ -105,16 +105,18 @@ static u8 sc1200_udma_filter(ide_drive_t
 {
 	ide_hwif_t *hwif = drive->hwif;
 	ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1];
-	struct hd_driveid *mateid = mate->id;
+	u16 *mateid = mate->id;
 	u8 mask = hwif->ultra_mask;
 
 	if (mate->present == 0)
 		goto out;
 
-	if ((mateid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
-		if ((mateid->field_valid & 4) && (mateid->dma_ultra & 7))
+	if ((mate->driveid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
+		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
+		    (mateid[ATA_ID_UDMA_MODES] & 7))
 			goto out;
-		if ((mateid->field_valid & 2) && (mateid->dma_mword & 7))
+		if ((mateid[ATA_ID_FIELD_VALID] & 2) &&
+		    (mateid[ATA_ID_MWDMA_MODES] & 7))
 			mask = 0;
 	}
 out:
drivers/ide/pci/serverworks.c +3 -1
Index: b/drivers/ide/pci/serverworks.c
===================================================================
@@ -57,8 +57,10 @@ static struct pci_dev *isa_dev;
 
 static int check_in_drive_lists (ide_drive_t *drive, const char **list)
 {
+	char *m = (char *)&drive->id[ATA_ID_PROD];
+
 	while (*list)
-		if (!strcmp(*list++, drive->id->model))
+		if (!strcmp(*list++, m))
 			return 1;
 	return 0;
 }
drivers/ide/pci/siimage.c +5 -3
Index: b/drivers/ide/pci/siimage.c
===================================================================
@@ -223,7 +223,9 @@ static u8 sil_pata_udma_filter(ide_drive
 
 static u8 sil_sata_udma_filter(ide_drive_t *drive)
 {
-	return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6;
+	char *m = (char *)&drive->id[ATA_ID_PROD];
+
+	return strstr(m, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6;
 }
 
 /**
@@ -616,8 +618,8 @@ static void __devinit init_mmio_iops_sii
 
 static int is_dev_seagate_sata(ide_drive_t *drive)
 {
-	const char *s	= &drive->id->model[0];
-	unsigned len	= strnlen(s, sizeof(drive->id->model));
+	const char *s	= (const char *)&drive->id[ATA_ID_PROD];
+	unsigned len	= strnlen(s, ATA_ID_PROD_LEN);
 
 	if ((len > 4) && (!memcmp(s, "ST", 2)))
 		if ((!memcmp(s + len - 2, "AS", 2)) ||
drivers/ide/ppc/pmac.c +3 -3
Index: b/drivers/ide/ppc/pmac.c
===================================================================
@@ -669,9 +669,9 @@ static void
 set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
 		 	u8 speed)
 {
+	u16 *id = drive->id;
 	int cycleTime, accessTime = 0, recTime = 0;
 	unsigned accessTicks, recTicks;
-	struct hd_driveid *id = drive->id;
 	struct mdma_timings_t* tm = NULL;
 	int i;
 
@@ -686,8 +686,8 @@ set_timings_mdma(ide_drive_t *drive, int
 	}
 
 	/* Check if drive provides explicit DMA cycle time */
-	if ((id->field_valid & 2) && id->eide_dma_time)
-		cycleTime = max_t(int, id->eide_dma_time, cycleTime);
+	if ((id[ATA_ID_FIELD_VALID] & 2) && id[ATA_ID_EIDE_DMA_TIME)
+		cycleTime = max_t(int, id[ATA_ID_EIDE_DMA_TIME], cycleTime);
 
 	/* OHare limits according to some old Apple sources */	
 	if ((intf_type == controller_ohare) && (cycleTime < 150))
drivers/scsi/ide-scsi.c +7 -6
Index: b/drivers/scsi/ide-scsi.c
===================================================================
@@ -451,7 +451,7 @@ static inline void idescsi_add_settings(
  */
 static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi)
 {
-	if (drive->id && (drive->id->config & 0x0060) == 0x20)
+	if ((drive->id[ATA_ID_CONFIG] & 0x0060) == 0x20)
 		set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags);
 	clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
 #if IDESCSI_DEBUG_LOG
@@ -810,6 +810,7 @@ static int ide_scsi_probe(ide_drive_t *d
 	struct gendisk *g;
 	static int warned;
 	int err = -ENOMEM;
+	u16 last_lun;
 
 	if (!warned && drive->media == ide_cdrom) {
 		printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n");
@@ -835,12 +836,12 @@ static int ide_scsi_probe(ide_drive_t *d
 
 	host->max_id = 1;
 
-	if (drive->id->last_lun)
-		debug_log("%s: id->last_lun=%u\n", drive->name,
-			  drive->id->last_lun);
+	last_lun = drive->id[ATA_ID_LAST_LUN];
+	if (last_lun)
+		debug_log("%s: last_lun=%u\n", drive->name, last_lun);
 
-	if ((drive->id->last_lun & 0x7) != 7)
-		host->max_lun = (drive->id->last_lun & 0x7) + 1;
+	if ((last_lun & 7) != 7)
+		host->max_lun = (last_lun & 7) + 1;
 	else
 		host->max_lun = 1;
 
include/linux/ide.h +14 -9
Index: b/include/linux/ide.h
===================================================================
@@ -389,7 +389,11 @@ struct ide_drive_s {
 	struct request		*rq;	/* current request */
 	struct ide_drive_s 	*next;	/* circular list of hwgroup drives */
 	void		*driver_data;	/* extra driver data */
-	struct hd_driveid	*id;	/* drive model identification info */
+	union {
+		/* identification info */
+		struct hd_driveid	*driveid;
+		u16			*id;
+	};
 #ifdef CONFIG_IDE_PROC_FS
 	struct proc_dir_entry *proc;	/* /proc/ide/ directory entry */
 	struct ide_settings_s *settings;/* /proc/ide/ drive settings */
@@ -920,7 +924,7 @@ ide_startstop_t __ide_error(ide_drive_t 
 
 ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
 
-extern void ide_fix_driveid(struct hd_driveid *);
+void ide_fix_driveid(u16 *);
 
 extern void ide_fixstring(u8 *, const int, const int);
 
@@ -1241,7 +1245,7 @@ struct drive_list_entry {
 	const char *id_firmware;
 };
 
-int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *);
+int ide_in_drive_list(u16 *, const struct drive_list_entry *);
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
 int __ide_dma_bad_drive(ide_drive_t *);
@@ -1347,12 +1351,13 @@ const char *ide_xfer_verbose(u8 mode);
 extern void ide_toggle_bounce(ide_drive_t *drive, int on);
 extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
 
-static inline int ide_dev_has_iordy(struct hd_driveid *id)
+static inline int ide_dev_has_iordy(u16 *id)
 {
-	return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0;
+	return ((id[ATA_ID_FIELD_VALID] & 2) &&
+		(((struct hd_driveid *)id)->capability & 8)) ? 1 : 0;
 }
 
-static inline int ide_dev_is_sata(struct hd_driveid *id)
+static inline int ide_dev_is_sata(u16 *id)
 {
 	/*
 	 * See if word 93 is 0 AND drive is at least ATA-5 compatible
@@ -1360,7 +1365,7 @@ static inline int ide_dev_is_sata(struct
 	 * this trick allows us to filter out the reserved values of
 	 * 0x0000 and 0xffff along with the earlier ATA revisions...
 	 */
-	if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020)
+	if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020)
 		return 1;
 	return 0;
 }
@@ -1437,11 +1442,11 @@ extern struct bus_type ide_bus_type;
 extern struct class *ide_port_class;
 
 /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
-#define ide_id_has_flush_cache(id)	((id)->cfs_enable_2 & 0x3000)
+#define ide_id_has_flush_cache(id)	((id)[ATA_ID_CFS_ENABLE_2] & 0x3000)
 
 /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */
 #define ide_id_has_flush_cache_ext(id)	\
-	(((id)->cfs_enable_2 & 0x2400) == 0x2400)
+	(((id)[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400)
 
 static inline void ide_dump_identify(u8 *id)
 {
#7 lore raw

PATCH 7/10 ide: remove drive->driveid

In reply to Bartlomiej Zolnierkiewicz

* Factor out HDIO_[OBSOLETE,GET]_IDENTITY ioctls handling to ide_get_identity_ioctl().

* Use temporary buffer in ide_get_identity_ioctl() instead of accessing drive->id directly.

* Add ide_id_to_hd_driveid() inline to convert raw id into struct hd_driveid format (needed on big-endian).

* Use ide_id_to_hd_driveid() in ide_get_identity_ioctl(), cleanup ide_fix_driveid() and switch ide to use use raw id.

* Remove no longer needed drive->driveid.

This leaves us with 3 users of struct hd_driveid in tree:
- arch/um/drivers/ubd_kern.c
- drivers/block/xsysace.c
- drivers/usb/storage/isd200.c

While at it:

* Use ata_id_u{32,64}() and ata_id_has_{dma,lba,iordy}() macros.

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-disk.c         |   23 +++++++--------
 drivers/ide/ide-dma.c          |    6 ++--
 drivers/ide/ide-iops.c         |   20 +------------
 drivers/ide/ide-lib.c          |    4 +-
 drivers/ide/ide-probe.c        |   22 +++++++--------
 drivers/ide/ide-timings.c      |    2 -
 drivers/ide/ide.c              |   59 +++++++++++++++++++++++++++++++++++------
 drivers/ide/legacy/qd65xx.c    |    4 +-
 drivers/ide/pci/cs5530.c       |    2 -
 drivers/ide/pci/it821x.c       |    4 +-
 drivers/ide/pci/pdc202xx_old.c |    2 -
 drivers/ide/pci/sc1200.c       |    2 -
 include/linux/ide.h            |    9 +-----
 13 files changed, 90 insertions(+), 69 deletions(-)
drivers/ide/ide-disk.c +11 -12
Index: b/drivers/ide/ide-disk.c
===================================================================
@@ -94,13 +94,14 @@ static void ide_disk_put(struct ide_disk
  */
 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[ATA_ID_CYLS] == 0)
 		return 1;
 
+	lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
+
 	/*
 	 * The ATA spec tells large drives to return
 	 * C/H/S = 16383/16/63 independent of their size.
@@ -111,10 +112,9 @@ static int lba_capacity_is_ok(u16 *id)
 	     (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]))
+	    (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
 		return 1;
 
-	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 */
@@ -126,7 +126,7 @@ static int lba_capacity_is_ok(u16 *id)
 	tail = (lba_sects & 0xffff);
 	lba_sects = (head | (tail << 16));
 	if ((lba_sects - chs_sects) < chs_sects/10) {
-		driveid->lba_capacity = lba_sects;
+		*(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
 		return 1;	/* lba_capacity is (now) good */
 	}
 
@@ -396,7 +396,7 @@ static inline int idedisk_supports_lba48
 {
 	return (id[ATA_ID_COMMAND_SET_2] & 0x0400) &&
 	       (id[ATA_ID_CFS_ENABLE_2] & 0x0400) &&
-	       ((struct hd_driveid *)id)->lba_capacity_2;
+	       ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
 }
 
 /*
@@ -463,7 +463,6 @@ static void idedisk_check_hpa(ide_drive_
  */
 static void init_idedisk_capacity(ide_drive_t *drive)
 {
-	struct hd_driveid *driveid = drive->driveid;
 	u16 *id = drive->id;
 	/*
 	 * If this drive supports the Host Protected Area feature set,
@@ -474,13 +473,13 @@ static void init_idedisk_capacity(ide_dr
 	if (idedisk_supports_lba48(id)) {
 		/* drive speaks 48-bit LBA */
 		drive->select.b.lba = 1;
-		drive->capacity64 = driveid->lba_capacity_2;
+		drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
 		if (hpa)
 			idedisk_check_hpa(drive);
-	} else if ((driveid->capability & 2) && lba_capacity_is_ok(id)) {
+	} else if (ata_id_has_lba(id) && lba_capacity_is_ok(id)) {
 		/* drive speaks 28-bit LBA */
 		drive->select.b.lba = 1;
-		drive->capacity64 = driveid->lba_capacity;
+		drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
 		if (hpa)
 			idedisk_check_hpa(drive);
 	} else {
@@ -629,7 +628,7 @@ static int set_multcount(ide_drive_t *dr
 	struct request *rq;
 	int error;
 
-	if (arg < 0 || arg > drive->driveid->max_multsect)
+	if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff))
 		return -EINVAL;
 
 	if (drive->special.b.set_multmode)
@@ -782,8 +781,8 @@ static void idedisk_add_settings(ide_dri
 	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,
-			drive->driveid->max_multsect, 1, 1, &drive->mult_count,
-			set_multcount);
+			drive->id[ATA_ID_MAX_MULTSECT] & 0xff, 1, 1,
+			&drive->mult_count, set_multcount);
 	ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1,
 			&drive->nowerr, set_nowerr);
 	ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1,
drivers/ide/ide-dma.c +3 -3
Index: b/drivers/ide/ide-dma.c
===================================================================
@@ -649,8 +649,8 @@ static unsigned int ide_get_mode_mask(id
 	case XFER_SW_DMA_0:
 		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;
+		} else if (id[ATA_ID_OLD_DMA_MODES] >> 8) {
+			u8 mode = id[ATA_ID_OLD_DMA_MODES] >> 8;
 
 			/*
 			 * if the mode is valid convert it to the mask
@@ -727,7 +727,7 @@ static int ide_tune_dma(ide_drive_t *dri
 	ide_hwif_t *hwif = drive->hwif;
 	u8 speed;
 
-	if (drive->nodma || (drive->driveid->capability & 1) == 0)
+	if (drive->nodma || ata_id_has_dma(drive->id) == 0)
 		return 0;
 
 	/* consult the list of known "bad" drives */
drivers/ide/ide-iops.c +2 -18
Index: b/drivers/ide/ide-iops.c
===================================================================
@@ -404,26 +404,10 @@ void ide_fix_driveid(u16 *id)
 {
 #ifndef __LITTLE_ENDIAN
 # ifdef __BIG_ENDIAN
-	struct hd_driveid *driveid = (struct hd_driveid *)id;
 	int i;
 
-	for (i = 0; i < 256; i++) {
-		/*  these words are accessed as two 8-bit values */
-		if (i == 47 || i == 49 || i == 51 || i == 52 || i == 59)
-			continue;
-		if (i == 60 || i == 61)	/* ->lba_capacity is 32-bit */
-			continue;
-		if (i == 98 || i == 99)	/* ->spg is 32-bit */
-			continue;
-		if (i > 99 && i < 104)	/* ->lba_capacity_2 is 64-bit */
-			continue;
-
+	for (i = 0; i < 256; i++)
 		id[i] = __le16_to_cpu(id[i]);
-	}
-
-	driveid->lba_capacity	= __le32_to_cpu(driveid->lba_capacity);
-	driveid->spg		= __le32_to_cpu(driveid->spg);
-	driveid->lba_capacity_2	= __le64_to_cpu(driveid->lba_capacity_2);
 # else
 #  error "Please fix <asm/byteorder.h>"
 # endif
@@ -752,7 +736,7 @@ int ide_config_drive_speed(ide_drive_t *
 #endif
 
 	/* Skip setting PIO flow-control modes on pre-EIDE drives */
-	if ((speed & 0xf8) == XFER_PIO_0 && !(drive->driveid->capability & 8))
+	if ((speed & 0xf8) == XFER_PIO_0 && ata_id_has_iordy(drive->id) == 0)
 		goto skip;
 
 	/*
drivers/ide/ide-lib.c +2 -2
Index: b/drivers/ide/ide-lib.c
===================================================================
@@ -102,14 +102,14 @@ u8 ide_get_best_pio_mode (ide_drive_t *d
 	if (pio_mode != -1) {
 		printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name);
 	} else {
-		pio_mode = drive->driveid->tPIO;
+		pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8;
 		if (pio_mode > 2) {	/* 2 is maximum allowed tPIO value */
 			pio_mode = 2;
 			overridden = 1;
 		}
 
 		if (id[ATA_ID_FIELD_VALID] & 2) {	      /* ATA2? */
-			if (drive->driveid->capability & 8) { /* IORDY sup? */
+			if (ata_id_has_iordy(id)) {
 				if (id[ATA_ID_PIO_MODES] & 7) {
 					overridden = 0;
 					if (id[ATA_ID_PIO_MODES] & 4)
drivers/ide/ide-probe.c +11 -11
Index: b/drivers/ide/ide-probe.c
===================================================================
@@ -87,20 +87,20 @@ static void ide_disk_init_chs(ide_drive_
 
 static void ide_disk_init_mult_count(ide_drive_t *drive)
 {
-	struct hd_driveid *id = drive->driveid;
+	u16 *id = drive->id;
+	u8 max_multsect = id[ATA_ID_MAX_MULTSECT] & 0xff;
 
-	if (id->max_multsect) {
+	if (max_multsect) {
 #ifdef CONFIG_IDEDISK_MULTI_MODE
-		if ((id->max_multsect / 2) > 1) {
-			id->multsect = id->max_multsect;
-			id->multsect_valid = 1;
-		} else {
-			id->multsect = 0;
-			id->multsect_valid = 0;
-		}
-		drive->mult_req = id->multsect;
+		if ((max_multsect / 2) > 1)
+			id[ATA_ID_MULTSECT] = max_multsect | 0x100;
+		else
+			id[ATA_ID_MULTSECT] &= ~0x1ff;
+
+		drive->mult_req = id[ATA_ID_MULTSECT] & 0xff;
 #endif
-		if ((id->multsect_valid & 1) && id->multsect)
+		if ((id[ATA_ID_MULTSECT] & 0x100) &&
+		    (id[ATA_ID_MULTSECT] & 0xff))
 			drive->special.b.set_multmode = 1;
 	}
 }
drivers/ide/ide-timings.c +1 -1
Index: b/drivers/ide/ide-timings.c
===================================================================
@@ -83,7 +83,7 @@ u16 ide_pio_cycle_time(ide_drive_t *driv
 	u16 cycle = 0;
 
 	if (id[ATA_ID_FIELD_VALID] & 2) {
-		if (drive->driveid->capability & 8)
+		if (ata_id_has_iordy(drive->id))
 			cycle = id[ATA_ID_EIDE_PIO_IORDY];
 		else
 			cycle = id[ATA_ID_EIDE_PIO];
drivers/ide/ide.c +51 -8

82 lines not on this page · raw message

drivers/ide/legacy/qd65xx.c +2 -2
Index: b/drivers/ide/legacy/qd65xx.c
===================================================================
@@ -195,10 +195,10 @@ static void qd6500_set_pio_mode(ide_driv
 	 * FIXME: use "pio" value
 	 */
 	if (!qd_find_disk_type(drive, &active_time, &recovery_time) &&
-	    drive->driveid->tPIO && (id[ATA_ID_FIELD_VALID] & 2) &&
+	    (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) &&
 	    id[ATA_ID_EIDE_PIO] >= 240) {
 		printk(KERN_INFO "%s: PIO mode%d\n", drive->name,
-				drive->driveid->tPIO);
+			id[ATA_ID_OLD_PIO_MODES] & 0xff);
 		active_time = 110;
 		recovery_time = drive->id[ATA_ID_EIDE_PIO] - 120;
 	}
drivers/ide/pci/cs5530.c +1 -1
Index: b/drivers/ide/pci/cs5530.c
===================================================================
@@ -88,7 +88,7 @@ static u8 cs5530_udma_filter(ide_drive_t
 	if (mate->present == 0)
 		goto out;
 
-	if ((mate->driveid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
+	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
 		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
 		    (mateid[ATA_ID_UDMA_MODES] & 7))
 			goto out;
drivers/ide/pci/it821x.c +2 -2
Index: b/drivers/ide/pci/it821x.c
===================================================================
@@ -470,7 +470,7 @@ static void __devinit it821x_quirkproc(i
 			/* In raid mode the ident block is slightly buggy
 			   We need to set the bits so that the IDE layer knows
 			   LBA28. LBA48 and DMA ar valid */
-			drive->driveid->capability |= 3;      /* LBA28, DMA */
+			id[ATA_ID_CAPABILITY]    |= (3 << 8); /* LBA28, DMA */
 			id[ATA_ID_COMMAND_SET_2] |= 0x0400;   /* LBA48 valid */
 			id[ATA_ID_CFS_ENABLE_2]  |= 0x0400;   /* LBA48 on */
 			/* Reporting logic */
@@ -504,7 +504,7 @@ static void __devinit it821x_quirkproc(i
 		 * IDE core that DMA is supported (it821x hardware
 		 * takes care of DMA mode programming).
 		 */
-		if (drive->driveid->capability & 1) {
+		if (ata_id_has_dma(id)) {
 			id[ATA_ID_MWDMA_MODES] |= 0x0101;
 			drive->current_speed = XFER_MW_DMA_0;
 		}
drivers/ide/pci/pdc202xx_old.c +1 -1
Index: b/drivers/ide/pci/pdc202xx_old.c
===================================================================
@@ -86,7 +86,7 @@ static void pdc202xx_set_mode(ide_drive_
 		 * Prefetch_EN / IORDY_EN / PA[3:0] bits of register A
 		 */
 		AP &= ~0x3f;
-		if (drive->driveid->capability & 4)
+		if (ata_id_iordy_disable(drive->id))
 			AP |= 0x20;	/* set IORDY_EN bit */
 		if (drive->media == ide_disk)
 			AP |= 0x10;	/* set Prefetch_EN bit */
drivers/ide/pci/sc1200.c +1 -1
Index: b/drivers/ide/pci/sc1200.c
===================================================================
@@ -111,7 +111,7 @@ static u8 sc1200_udma_filter(ide_drive_t
 	if (mate->present == 0)
 		goto out;
 
-	if ((mate->driveid->capability & 1) && __ide_dma_bad_drive(mate) == 0) {
+	if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) {
 		if ((mateid[ATA_ID_FIELD_VALID] & 4) &&
 		    (mateid[ATA_ID_UDMA_MODES] & 7))
 			goto out;
include/linux/ide.h +2 -7
Index: b/include/linux/ide.h
===================================================================
@@ -389,11 +389,7 @@ struct ide_drive_s {
 	struct request		*rq;	/* current request */
 	struct ide_drive_s 	*next;	/* circular list of hwgroup drives */
 	void		*driver_data;	/* extra driver data */
-	union {
-		/* identification info */
-		struct hd_driveid	*driveid;
-		u16			*id;
-	};
+	u16			*id;	/* identification info */
 #ifdef CONFIG_IDE_PROC_FS
 	struct proc_dir_entry *proc;	/* /proc/ide/ directory entry */
 	struct ide_settings_s *settings;/* /proc/ide/ drive settings */
@@ -1353,8 +1349,7 @@ extern int ide_set_xfer_rate(ide_drive_t
 
 static inline int ide_dev_has_iordy(u16 *id)
 {
-	return ((id[ATA_ID_FIELD_VALID] & 2) &&
-		(((struct hd_driveid *)id)->capability & 8)) ? 1 : 0;
+	return ((id[ATA_ID_FIELD_VALID] & 2) && ata_id_has_iordy(id)) ? 1 : 0;
 }
 
 static inline int ide_dev_is_sata(u16 *id)
#8 lore raw

PATCH 8/10 ide: use ata_id_current_chs_valid()

In reply to Bartlomiej Zolnierkiewicz

Replace open-coded checks by ata_id_current_chs_valid().

There should be no functional changes caused by this patch.

---
 drivers/ide/ide-probe.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/ide/ide-probe.c +1 -3
Index: b/drivers/ide/ide-probe.c
===================================================================
@@ -69,9 +69,7 @@ static void ide_disk_init_chs(ide_drive_
 	}
 
 	/* Handle logical geometry translation by the drive */
-	if ((id[ATA_ID_FIELD_VALID] & 1) && id[ATA_ID_CUR_CYLS] &&
-	    id[ATA_ID_CUR_HEADS] && id[ATA_ID_CUR_HEADS] <= 16 &&
-	    id[ATA_ID_CUR_SECTORS]) {
+	if (ata_id_current_chs_valid(id)) {
 		drive->cyl  = id[ATA_ID_CUR_CYLS];
 		drive->head = id[ATA_ID_CUR_HEADS];
 		drive->sect = id[ATA_ID_CUR_SECTORS];
#9 lore raw

PATCH 9/10 ide-disk: use ata_id_wcache_enabled()

In reply to Bartlomiej Zolnierkiewicz

Replace open-coded check by ata_id_wcache_enabled() (which also checks validity of word 85).

---
 drivers/ide/ide-disk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-disk.c +1 -1
Index: b/drivers/ide/ide-disk.c
===================================================================
@@ -896,7 +896,7 @@ static void idedisk_setup(ide_drive_t *d
 			 drive->bios_cyl, drive->bios_head, drive->bios_sect);
 
 	/* write cache enabled? */
-	if ((id[ATA_ID_CSFO] & 1) || (id[ATA_ID_CFS_ENABLE_1] & (1 << 5)))
+	if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id))
 		drive->wcache = 1;
 
 	write_cache(drive, 1);
#10 lore raw

PATCH 10/10 ide-disk: use ata_id_hpa_enabled()

In reply to Bartlomiej Zolnierkiewicz

idedisk_supports_hpa() -> ata_id_hpa_enabled().

The latter one also checks validity of words 82 & 85.

---
 drivers/ide/ide-disk.c |   15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/ide/ide-disk.c +2 -13
Index: b/drivers/ide/ide-disk.c
===================================================================
@@ -379,17 +379,6 @@ static unsigned long long sectors_to_MB(
 }
 
 /*
- * Bits 10 of command_set_1 and cfs_enable_1 must be equal,
- * 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 u16 *id)
-{
-	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 u16 *id)
@@ -468,7 +457,7 @@ static void init_idedisk_capacity(ide_dr
 	 * If this drive supports the Host Protected Area feature set,
 	 * then we may need to change our opinion about the drive's capacity.
 	 */
-	int hpa = idedisk_supports_hpa(id);
+	int hpa = ata_id_hpa_enabled(id);
 
 	if (idedisk_supports_lba48(id)) {
 		/* drive speaks 48-bit LBA */
@@ -946,7 +935,7 @@ static int ide_disk_probe(ide_drive_t *d
  */
 static void ide_disk_resume(ide_drive_t *drive)
 {
-	if (idedisk_supports_hpa(drive->id))
+	if (ata_id_hpa_enabled(drive->id))
 		init_idedisk_capacity(drive);
 }