Skip to contentSkip to conversation

problem with register_hw_with_fixup

DISCUSSION Stefan Althoefer 2 participants 2 messages Jan 23, 2007 libata

lore
Share & tools
lore
#0 lore raw

hi,

I'm currently developing a ide driver for an embedded ARM device. The device hardware is somewhat wired, as all IDE access must be done 16bit, even the control bytes. I therefore need special access functions.

I do this to register special IN/OUT functions:

-----%<---some code delete for brevity------------- void empca400_fixup(
ide_hwif_t *hwif
)

{
    hwif->mmio = 2;
    hwif->OUTB = &empca400_ide_outb;
    hwif->OUTBSYNC = &empca400_ide_outbsync;
    hwif->OUTW = &empca400_ide_outw;
    hwif->OUTSW = &empca400_ide_outsw;
    :
}

static int __init empca400ide_init(void)

{
	:

        memset(&hw, 0, sizeof(hw));

        base = 0x56000000;
        aux  = base + 0x10;

        vbase = (unsigned long) ioremap(base, 0x10);
        vaux  = vbase + 0x20;

        for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
                hw.io_ports[i] = (unsigned long)vbase;
                vbase += 4;
        }
        hw.io_ports[IDE_CONTROL_OFFSET] = vaux + (6 * 0x2);
        hw.irq = 20;  /* GPIO3 = IRQ20 */
        hw.dma = NO_DMA;
        hw.chipset = ide_generic;

        ret = ide_register_hw_with_fixup(&hw, &hwif, empca400_fixup);

	:
}

-----------------------------------------------------

However, in probe_hwif_init_with_fixup() I find this sequence:

-----%<-----------------
int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))

{
	probe_hwif(hwif);

	if (fixup)
		fixup(hwif);

-------------------------

fixup() gets called after probe_hwif, hence my special function pointers will not be installed in time.

Shouldn't probe_hwif_init_with_fixup() call the fixup() first? If not, what is fixup() good for, and how can I get my function pointers registered before probe_hwif()?

mfg

Signature · 7 lines
----------------------
Stefan Althöfer ([email protected])
Janz Automationssysteme AG
  - Automation Intelligence -
Member of the Janz company group
Im Doerener Feld 8
33100 Paderborn - Germany
#1 lore raw
Quoted 6 lines · On Tue, 23 Jan 2007 09:51:52 +0100 Stefan Althoefer <[email protected]> wrote:

hi,

I'm currently developing a ide driver for an embedded ARM device. The device hardware is somewhat wired, as all IDE access must be done 16bit, even the control bytes. I therefore need special access functions.

For new drivers you should really be looking at drivers/ata

Quoted 9 lines

However, in probe_hwif_init_with_fixup() I find this sequence:

-----%<-----------------
int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))

{
	probe_hwif(hwif);

	if (fixup)
		fixup(hwif);
Quoted 4 lines

-------------------------

fixup() gets called after probe_hwif, hence my special function pointers will not be installed in time.

fixup is intended for doing drive level fixups and was added fairly recently to deal with things like IT8212 in RAID mode and some PCMCIA decode problems which run after the probe.

There isn't a good way to handle this with the old IDE layer. PMac does it by walking the hwif array itself (without any proper locking). Adding the call you need might be a good idea, but moving fixup will break things.

Alan