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
...@@ -235,9 +235,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) ...@@ -235,9 +235,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
drive->media = ide_disk; drive->media = ide_disk;
printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" ); printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" );
if (hwif->quirkproc)
drive->quirk_list = hwif->quirkproc(drive);
return; return;
err_misc: err_misc:
...@@ -676,19 +673,18 @@ out: ...@@ -676,19 +673,18 @@ out:
/** /**
* ide_undecoded_slave - look for bad CF adapters * ide_undecoded_slave - look for bad CF adapters
* @hwif: interface * @drive1: drive
* *
* Analyse the drives on the interface and attempt to decide if we * Analyse the drives on the interface and attempt to decide if we
* have the same drive viewed twice. This occurs with crap CF adapters * have the same drive viewed twice. This occurs with crap CF adapters
* and PCMCIA sometimes. * 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 *drive0 = &drive1->hwif->drives[0];
ide_drive_t *drive1 = &hwif->drives[1];
if (drive0->present == 0 || drive1->present == 0) if ((drive1->dn & 1) == 0 || drive0->present == 0)
return; return;
/* If the models don't match they are not the same product */ /* If the models don't match they are not the same product */
...@@ -817,8 +813,12 @@ static void probe_hwif(ide_hwif_t *hwif) ...@@ -817,8 +813,12 @@ static void probe_hwif(ide_hwif_t *hwif)
return; return;
} }
if (hwif->fixup) for (unit = 0; unit < MAX_DRIVES; unit++) {
hwif->fixup(hwif); ide_drive_t *drive = &hwif->drives[unit];
if (drive->present && hwif->quirkproc)
hwif->quirkproc(drive);
}
for (unit = 0; unit < MAX_DRIVES; ++unit) { for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit]; ide_drive_t *drive = &hwif->drives[unit];
......
...@@ -414,8 +414,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) ...@@ -414,8 +414,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
hwif->cds = tmp_hwif->cds; hwif->cds = tmp_hwif->cds;
#endif #endif
hwif->fixup = tmp_hwif->fixup;
hwif->set_pio_mode = tmp_hwif->set_pio_mode; hwif->set_pio_mode = tmp_hwif->set_pio_mode;
hwif->set_dma_mode = tmp_hwif->set_dma_mode; hwif->set_dma_mode = tmp_hwif->set_dma_mode;
hwif->mdma_filter = tmp_hwif->mdma_filter; hwif->mdma_filter = tmp_hwif->mdma_filter;
...@@ -680,7 +678,7 @@ void ide_setup_ports ( hw_regs_t *hw, ...@@ -680,7 +678,7 @@ void ide_setup_ports ( hw_regs_t *hw,
/** /**
* ide_register_hw - register IDE interface * ide_register_hw - register IDE interface
* @hw: hardware registers * @hw: hardware registers
* @fixup: fixup function * @quirkproc: quirkproc function
* @initializing: set while initializing built-in drivers * @initializing: set while initializing built-in drivers
* @hwifp: pointer to returned hwif * @hwifp: pointer to returned hwif
* *
...@@ -690,7 +688,7 @@ void ide_setup_ports ( hw_regs_t *hw, ...@@ -690,7 +688,7 @@ void ide_setup_ports ( hw_regs_t *hw,
* Returns -1 on error. * 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 initializing, ide_hwif_t **hwifp)
{ {
int index, retry = 1; int index, retry = 1;
...@@ -726,7 +724,7 @@ found: ...@@ -726,7 +724,7 @@ found:
memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
hwif->irq = hw->irq; hwif->irq = hw->irq;
hwif->noprobe = 0; hwif->noprobe = 0;
hwif->fixup = fixup; hwif->quirkproc = quirkproc;
hwif->chipset = hw->chipset; hwif->chipset = hw->chipset;
hwif->gendev.parent = hw->dev; hwif->gendev.parent = hw->dev;
hwif->ack_intr = hw->ack_intr; hwif->ack_intr = hw->ack_intr;
......
...@@ -725,15 +725,18 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) ...@@ -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); 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; struct hd_driveid *id = drive->id;
const char **list = quirk_drives; const char **list = quirk_drives;
while (*list) while (*list)
if (strstr(id->model, *list++)) if (strstr(id->model, *list++)) {
return 1; drive->quirk_list = 1;
return 0; return;
}
drive->quirk_list = 0;
} }
static void hpt3xx_maskproc(ide_drive_t *drive, int mask) static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
......
...@@ -431,33 +431,29 @@ static u8 __devinit ata66_it821x(ide_hwif_t *hwif) ...@@ -431,33 +431,29 @@ static u8 __devinit ata66_it821x(ide_hwif_t *hwif)
} }
/** /**
* it821x_fixup - post init callback * it821x_quirkproc - post init callback
* @hwif: interface * @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 * before anything gets attached. It allows drivers to do any
* final tuning that is needed, or fixups to work around bugs. * 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); struct it821x_dev *itdev = ide_get_hwifdata(drive->hwif);
int i; struct hd_driveid *id = drive->id;
u16 *idbits = (u16 *)drive->id;
if(!itdev->smart) { if (!itdev->smart) {
/* /*
* If we are in pass through mode then not much * If we are in pass through mode then not much
* needs to be done, but we do bother to clear the * needs to be done, but we do bother to clear the
* IRQ mask as we may well be in PIO (eg rev 0x10) * IRQ mask as we may well be in PIO (eg rev 0x10)
* for now and we know unmasking is safe on this chipset. * 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; drive->unmask = 1;
} } else {
return;
}
/* /*
* Perform fixups on smart mode. We need to "lose" some * Perform fixups on smart mode. We need to "lose" some
* capabilities the firmware lacks but does not filter, and * capabilities the firmware lacks but does not filter, and
...@@ -465,16 +461,6 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif) ...@@ -465,16 +461,6 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
* in RAID mode. * 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 */ /* Check for RAID v native */
if(strstr(id->model, "Integrated Technology Express")) { if(strstr(id->model, "Integrated Technology Express")) {
/* In raid mode the ident block is slightly buggy /* In raid mode the ident block is slightly buggy
...@@ -537,6 +523,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) ...@@ -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); struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
u8 conf; u8 conf;
hwif->quirkproc = &it821x_quirkproc;
if (idev == NULL) { if (idev == NULL) {
printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
return; return;
...@@ -633,7 +621,6 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha ...@@ -633,7 +621,6 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha
.name = name_str, \ .name = name_str, \
.init_chipset = init_chipset_it821x, \ .init_chipset = init_chipset_it821x, \
.init_hwif = init_hwif_it821x, \ .init_hwif = init_hwif_it821x, \
.fixup = it821x_fixups, \
.host_flags = IDE_HFLAG_BOOTABLE, \ .host_flags = IDE_HFLAG_BOOTABLE, \
.pio_mask = ATA_PIO4, \ .pio_mask = ATA_PIO4, \
} }
......
...@@ -203,14 +203,17 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif) ...@@ -203,14 +203,17 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
return ATA_CBL_PATA80; 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; const char **list, *model = drive->id->model;
for (list = pdc_quirk_drives; *list != NULL; list++) for (list = pdc_quirk_drives; *list != NULL; list++)
if (strstr(model, *list) != NULL) if (strstr(model, *list) != NULL) {
return 2; drive->quirk_list = 2;
return 0; return;
}
drive->quirk_list = 0;
} }
static void pdcnew_reset(ide_drive_t *drive) static void pdcnew_reset(ide_drive_t *drive)
......
...@@ -176,14 +176,17 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif) ...@@ -176,14 +176,17 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
} }
static int pdc202xx_quirkproc (ide_drive_t *drive) static void pdc202xx_quirkproc(ide_drive_t *drive)
{ {
const char **list, *model = drive->id->model; const char **list, *model = drive->id->model;
for (list = pdc_quirk_drives; *list != NULL; list++) for (list = pdc_quirk_drives; *list != NULL; list++)
if (strstr(model, *list) != NULL) if (strstr(model, *list) != NULL) {
return 2; drive->quirk_list = 2;
return 0; return;
}
drive->quirk_list = 0;
} }
static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) static void pdc202xx_old_ide_dma_start(ide_drive_t *drive)
......
...@@ -713,9 +713,6 @@ static int is_dev_seagate_sata(ide_drive_t *drive) ...@@ -713,9 +713,6 @@ static int is_dev_seagate_sata(ide_drive_t *drive)
const char *s = &drive->id->model[0]; const char *s = &drive->id->model[0];
unsigned len; unsigned len;
if (!drive->present)
return 0;
len = strnlen(s, sizeof(drive->id->model)); len = strnlen(s, sizeof(drive->id->model));
if ((len > 4) && (!memcmp(s, "ST", 2))) { if ((len > 4) && (!memcmp(s, "ST", 2))) {
...@@ -730,18 +727,20 @@ static int is_dev_seagate_sata(ide_drive_t *drive) ...@@ -730,18 +727,20 @@ static int is_dev_seagate_sata(ide_drive_t *drive)
} }
/** /**
* siimage_fixup - post probe fixups * sil_quirkproc - post probe fixups
* @hwif: interface to fix up * @drive: drive
* *
* Called after drive probe we use this to decide whether the * Called after drive probe we use this to decide whether the
* Seagate fixup must be applied. This used to be in init_iops but * Seagate fixup must be applied. This used to be in init_iops but
* that can occur before we know what drives are present. * that can occur before we know what drives are present.
*/ */
static void __devinit siimage_fixup(ide_hwif_t *hwif) static void __devinit sil_quirkproc(ide_drive_t *drive)
{ {
ide_hwif_t *hwif = drive->hwif;
/* Try and raise the rqsize */ /* Try and raise the rqsize */
if (!is_sata(hwif) || !is_dev_seagate_sata(&hwif->drives[0])) if (!is_sata(hwif) || !is_dev_seagate_sata(drive))
hwif->rqsize = 128; hwif->rqsize = 128;
} }
...@@ -804,6 +803,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) ...@@ -804,6 +803,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
hwif->set_pio_mode = &sil_set_pio_mode; hwif->set_pio_mode = &sil_set_pio_mode;
hwif->set_dma_mode = &sil_set_dma_mode; hwif->set_dma_mode = &sil_set_dma_mode;
hwif->quirkproc = &sil_quirkproc;
if (sata) { if (sata) {
static int first = 1; static int first = 1;
...@@ -842,7 +842,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif) ...@@ -842,7 +842,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
.init_chipset = init_chipset_siimage, \ .init_chipset = init_chipset_siimage, \
.init_iops = init_iops_siimage, \ .init_iops = init_iops_siimage, \
.init_hwif = init_hwif_siimage, \ .init_hwif = init_hwif_siimage, \
.fixup = siimage_fixup, \
.host_flags = IDE_HFLAG_BOOTABLE, \ .host_flags = IDE_HFLAG_BOOTABLE, \
.pio_mask = ATA_PIO4, \ .pio_mask = ATA_PIO4, \
.mwdma_mask = ATA_MWDMA2, \ .mwdma_mask = ATA_MWDMA2, \
......
...@@ -555,8 +555,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int ...@@ -555,8 +555,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
(d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
hwif->irq = port ? 15 : 14; hwif->irq = port ? 15 : 14;
hwif->fixup = d->fixup;
hwif->host_flags = d->host_flags; hwif->host_flags = d->host_flags;
hwif->pio_mask = d->pio_mask; hwif->pio_mask = d->pio_mask;
......
...@@ -199,7 +199,8 @@ typedef struct hw_regs_s { ...@@ -199,7 +199,8 @@ typedef struct hw_regs_s {
struct hwif_s * ide_find_port(unsigned long); struct hwif_s * ide_find_port(unsigned long);
int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int, struct ide_drive_s;
int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *), int,
struct hwif_s **); struct hwif_s **);
void ide_setup_ports( hw_regs_t *hw, void ide_setup_ports( hw_regs_t *hw,
...@@ -527,15 +528,13 @@ typedef struct hwif_s { ...@@ -527,15 +528,13 @@ typedef struct hwif_s {
/* special host masking for drive selection */ /* special host masking for drive selection */
void (*maskproc)(ide_drive_t *, int); void (*maskproc)(ide_drive_t *, int);
/* check host's drive quirk list */ /* check host's drive quirk list */
int (*quirkproc)(ide_drive_t *); void (*quirkproc)(ide_drive_t *);
/* driver soft-power interface */ /* driver soft-power interface */
int (*busproc)(ide_drive_t *, int); int (*busproc)(ide_drive_t *, int);
#endif #endif
u8 (*mdma_filter)(ide_drive_t *); u8 (*mdma_filter)(ide_drive_t *);
u8 (*udma_filter)(ide_drive_t *); u8 (*udma_filter)(ide_drive_t *);
void (*fixup)(struct hwif_s *);
void (*ata_input_data)(ide_drive_t *, void *, u32); void (*ata_input_data)(ide_drive_t *, void *, u32);
void (*ata_output_data)(ide_drive_t *, void *, u32); void (*ata_output_data)(ide_drive_t *, void *, u32);
...@@ -1108,7 +1107,6 @@ struct ide_port_info { ...@@ -1108,7 +1107,6 @@ struct ide_port_info {
void (*init_iops)(ide_hwif_t *); void (*init_iops)(ide_hwif_t *);
void (*init_hwif)(ide_hwif_t *); void (*init_hwif)(ide_hwif_t *);
void (*init_dma)(ide_hwif_t *, unsigned long); void (*init_dma)(ide_hwif_t *, unsigned long);
void (*fixup)(ide_hwif_t *);
ide_pci_enablebit_t enablebits[2]; ide_pci_enablebit_t enablebits[2];
hwif_chipset_t chipset; hwif_chipset_t chipset;
u8 extra; u8 extra;
...@@ -1203,7 +1201,7 @@ extern void ide_unregister (unsigned int index); ...@@ -1203,7 +1201,7 @@ extern void ide_unregister (unsigned int index);
void ide_register_region(struct gendisk *); void ide_register_region(struct gendisk *);
void ide_unregister_region(struct gendisk *); void ide_unregister_region(struct gendisk *);
void ide_undecoded_slave(ide_hwif_t *); void ide_undecoded_slave(ide_drive_t *);
int ide_device_add(u8 idx[4]); int ide_device_add(u8 idx[4]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment