Commit f01393e4 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: merge ->fixup and ->quirkproc methods



* Assign drive->quirk_list in ->quirkproc implementations:
  - hpt366.c::hpt3xx_quirkproc()
  - pdc202xx_new.c::pdcnew_quirkproc()
  - pdc202xx_old.c::pdc202xx_quirkproc()

* Make ->quirkproc void.

* Move calling ->quirkproc from do_identify() to probe_hwif().

* Convert it821x_fixups() to it821x_quirkproc() in it821x.c.

* Convert siimage_fixup() to sil_quirkproc() in siimage.c, also remove
  no longer needed drive->present check from is_dev_seagate_sata().

* Convert ide_undecoded_slave() to accept 'drive' instead of 'hwif'
  as an argument.  Then convert ide_register_hw() to accept 'quirkproc'
  argument instead of 'fixup' one.

* Remove no longer needed ->fixup method.

Acked-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 6dd9b837
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -235,9 +235,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
	drive->media = ide_disk;
	printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" );

	if (hwif->quirkproc)
		drive->quirk_list = hwif->quirkproc(drive);

	return;

err_misc:
@@ -676,19 +673,18 @@ out:

/**
 *	ide_undecoded_slave	-	look for bad CF adapters
 *	@hwif: interface
 *	@drive1: drive
 *
 *	Analyse the drives on the interface and attempt to decide if we
 *	have the same drive viewed twice. This occurs with crap CF adapters
 *	and PCMCIA sometimes.
 */

void ide_undecoded_slave(ide_hwif_t *hwif)
void ide_undecoded_slave(ide_drive_t *drive1)
{
	ide_drive_t *drive0 = &hwif->drives[0];
	ide_drive_t *drive1 = &hwif->drives[1];
	ide_drive_t *drive0 = &drive1->hwif->drives[0];

	if (drive0->present == 0 || drive1->present == 0)
	if ((drive1->dn & 1) == 0 || drive0->present == 0)
		return;

	/* If the models don't match they are not the same product */
@@ -817,8 +813,12 @@ static void probe_hwif(ide_hwif_t *hwif)
		return;
	}

	if (hwif->fixup)
		hwif->fixup(hwif);
	for (unit = 0; unit < MAX_DRIVES; unit++) {
		ide_drive_t *drive = &hwif->drives[unit];

		if (drive->present && hwif->quirkproc)
			hwif->quirkproc(drive);
	}

	for (unit = 0; unit < MAX_DRIVES; ++unit) {
		ide_drive_t *drive = &hwif->drives[unit];
+3 −5
Original line number Diff line number Diff line
@@ -414,8 +414,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
	hwif->cds			= tmp_hwif->cds;
#endif

	hwif->fixup			= tmp_hwif->fixup;

	hwif->set_pio_mode		= tmp_hwif->set_pio_mode;
	hwif->set_dma_mode		= tmp_hwif->set_dma_mode;
	hwif->mdma_filter		= tmp_hwif->mdma_filter;
@@ -680,7 +678,7 @@ void ide_setup_ports ( hw_regs_t *hw,
/**
 *	ide_register_hw		-	register IDE interface
 *	@hw: hardware registers
 *	@fixup: fixup function
 *	@quirkproc: quirkproc function
 *	@initializing: set while initializing built-in drivers
 *	@hwifp: pointer to returned hwif
 *
@@ -690,7 +688,7 @@ void ide_setup_ports ( hw_regs_t *hw,
 *	Returns -1 on error.
 */

int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
		    int initializing, ide_hwif_t **hwifp)
{
	int index, retry = 1;
@@ -726,7 +724,7 @@ found:
	memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
	hwif->irq = hw->irq;
	hwif->noprobe = 0;
	hwif->fixup = fixup;
	hwif->quirkproc = quirkproc;
	hwif->chipset = hw->chipset;
	hwif->gendev.parent = hw->dev;
	hwif->ack_intr = hw->ack_intr;
+7 −4
Original line number Diff line number Diff line
@@ -725,15 +725,18 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
	hpt3xx_set_mode(drive, XFER_PIO_0 + pio);
}

static int hpt3xx_quirkproc(ide_drive_t *drive)
static void hpt3xx_quirkproc(ide_drive_t *drive)
{
	struct hd_driveid *id	= drive->id;
	const  char **list	= quirk_drives;

	while (*list)
		if (strstr(id->model, *list++))
			return 1;
	return 0;
		if (strstr(id->model, *list++)) {
			drive->quirk_list = 1;
			return;
		}

	drive->quirk_list = 0;
}

static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
+12 −25
Original line number Diff line number Diff line
@@ -431,18 +431,19 @@ static u8 __devinit ata66_it821x(ide_hwif_t *hwif)
}

/**
 *	it821x_fixup	-	post init callback
 *	@hwif: interface
 *	it821x_quirkproc	-	post init callback
 *	@drive: drive
 *
 *	This callback is run after the drives have been probed but
 *	This callback is run after the drive has been probed but
 *	before anything gets attached. It allows drivers to do any
 *	final tuning that is needed, or fixups to work around bugs.
 */

static void __devinit it821x_fixups(ide_hwif_t *hwif)
static void __devinit it821x_quirkproc(ide_drive_t *drive)
{
	struct it821x_dev *itdev = ide_get_hwifdata(hwif);
	int i;
	struct it821x_dev *itdev = ide_get_hwifdata(drive->hwif);
	struct hd_driveid *id = drive->id;
	u16 *idbits = (u16 *)drive->id;

	if (!itdev->smart) {
		/*
@@ -451,13 +452,8 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
		 *	IRQ mask as we may well be in PIO (eg rev 0x10)
		 *	for now and we know unmasking is safe on this chipset.
		 */
		for (i = 0; i < 2; i++) {
			ide_drive_t *drive = &hwif->drives[i];
			if(drive->present)
		drive->unmask = 1;
		}
		return;
	}
	} else {
	/*
	 *	Perform fixups on smart mode. We need to "lose" some
	 *	capabilities the firmware lacks but does not filter, and
@@ -465,16 +461,6 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
	 *	in RAID mode.
	 */

	for(i = 0; i < 2; i++) {
		ide_drive_t *drive = &hwif->drives[i];
		struct hd_driveid *id;
		u16 *idbits;

		if(!drive->present)
			continue;
		id = drive->id;
		idbits = (u16 *)drive->id;

		/* Check for RAID v native */
		if(strstr(id->model, "Integrated Technology Express")) {
			/* In raid mode the ident block is slightly buggy
@@ -537,6 +523,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
	struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
	u8 conf;

	hwif->quirkproc = &it821x_quirkproc;

	if (idev == NULL) {
		printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
		return;
@@ -633,7 +621,6 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha
		.name		= name_str,		\
		.init_chipset	= init_chipset_it821x,	\
		.init_hwif	= init_hwif_it821x,	\
		.fixup	 	= it821x_fixups,	\
		.host_flags	= IDE_HFLAG_BOOTABLE,	\
		.pio_mask	= ATA_PIO4,		\
	}
+7 −4
Original line number Diff line number Diff line
@@ -203,14 +203,17 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
		return ATA_CBL_PATA80;
}

static int pdcnew_quirkproc(ide_drive_t *drive)
static void pdcnew_quirkproc(ide_drive_t *drive)
{
	const char **list, *model = drive->id->model;

	for (list = pdc_quirk_drives; *list != NULL; list++)
		if (strstr(model, *list) != NULL)
			return 2;
	return 0;
		if (strstr(model, *list) != NULL) {
			drive->quirk_list = 2;
			return;
		}

	drive->quirk_list = 0;
}

static void pdcnew_reset(ide_drive_t *drive)
Loading