Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48fb2688 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: remove drive->driveid



* 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.

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 4dde4492
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -101,13 +101,14 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
 */
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.
@@ -118,10 +119,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 */
@@ -133,7 +133,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 */
	}

@@ -403,7 +403,7 @@ static inline int idedisk_supports_lba48(const u16 *id)
{
	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);
}

/*
@@ -456,7 +456,6 @@ static void idedisk_check_hpa(ide_drive_t *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,
@@ -467,13 +466,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 = 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 {
@@ -622,7 +621,7 @@ static int set_multcount(ide_drive_t *drive, int arg)
	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)
@@ -775,8 +774,8 @@ 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,
			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,
+3 −3
Original line number Diff line number Diff line
@@ -649,8 +649,8 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode)
	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 *drive)
	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 */
+2 −18
Original line number Diff line number Diff line
@@ -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 *drive, u8 speed)
#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;

	/*
+2 −2
Original line number Diff line number Diff line
@@ -102,14 +102,14 @@ u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode)
	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)
+11 −11
Original line number Diff line number Diff line
@@ -87,20 +87,20 @@ static void ide_disk_init_chs(ide_drive_t *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;
	}
}
Loading