Skip to content

Commit

Permalink
ide: move IRQ clearing from ack_intr() method to clear_irq() method (…
Browse files Browse the repository at this point in the history
…take 2)

There are now two methods that clear the port interrupt: ack_intr() method,
implemented only on M680x0 machines, that is called at the start of ide_intr(),
and clear_irq() method, that is called somewhat later in this function.  In
order to stop this duplication, delegate the task of clearing the interrupt
to clear_irq() method, only leaving to ack_intr() the task of testing for the
port interrupt.

Signed-off-by: Sergei Shtylyov <[email protected]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
  • Loading branch information
Sergei Shtylyov authored and bzolnier committed Jun 15, 2009
1 parent 74414a9 commit eba8999
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
27 changes: 13 additions & 14 deletions drivers/ide/buddha.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,12 @@ static int buddha_ack_intr(ide_hwif_t *hwif)
return 1;
}

static int xsurf_ack_intr(ide_hwif_t *hwif)
static void xsurf_clear_irq(ide_drive_t *drive)
{
unsigned char ch;

ch = z_readb(hwif->io_ports.irq_addr);
/* X-Surf needs a 0 written to IRQ register to ensure ISA bit A11 stays at 0 */
z_writeb(0, hwif->io_ports.irq_addr);
if (!(ch & 0x80))
return 0;
return 1;
/*
* X-Surf needs 0 written to IRQ register to ensure ISA bit A11 stays at 0
*/
z_writeb(0, drive->hwif->io_ports.irq_addr);
}

static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
Expand All @@ -141,6 +137,10 @@ static void __init buddha_setup_ports(struct ide_hw *hw, unsigned long base,
hw->ack_intr = ack_intr;
}

static const struct ide_port_ops xsurf_port_ops = {
.clear_irq = xsurf_clear_irq,
};

static const struct ide_port_info buddha_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
Expand All @@ -161,6 +161,7 @@ static int __init buddha_init(void)
while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
unsigned long board;
struct ide_hw hw[MAX_NUM_HWIFS], *hws[MAX_NUM_HWIFS];
struct ide_port_info d = buddha_port_info;

if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_BUDDHA) {
buddha_num_hwifs = BUDDHA_NUM_HWIFS;
Expand All @@ -171,6 +172,7 @@ static int __init buddha_init(void)
} else if (z->id == ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF) {
buddha_num_hwifs = XSURF_NUM_HWIFS;
type=BOARD_XSURF;
d.port_ops = &xsurf_port_ops;
} else
continue;

Expand Down Expand Up @@ -203,28 +205,25 @@ static int __init buddha_init(void)

for (i = 0; i < buddha_num_hwifs; i++) {
unsigned long base, ctl, irq_port;
ide_ack_intr_t *ack_intr;

if (type != BOARD_XSURF) {
base = buddha_board + buddha_bases[i];
ctl = base + BUDDHA_CONTROL;
irq_port = buddha_board + buddha_irqports[i];
ack_intr = buddha_ack_intr;
} else {
base = buddha_board + xsurf_bases[i];
/* X-Surf has no CS1* (Control/AltStat) */
ctl = 0;
irq_port = buddha_board + xsurf_irqports[i];
ack_intr = xsurf_ack_intr;
}

buddha_setup_ports(&hw[i], base, ctl, irq_port,
ack_intr);
buddha_ack_intr);

hws[i] = &hw[i];
}

ide_host_add(&buddha_port_info, hws, i, NULL);
ide_host_add(&d, hws, i, NULL);
}

return 0;
Expand Down
23 changes: 11 additions & 12 deletions drivers/ide/gayle.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MODULE_PARM_DESC(doubler, "enable support for IDE doublers");
* Check and acknowledge the interrupt status
*/

static int gayle_ack_intr_a4000(ide_hwif_t *hwif)
static int gayle_ack_intr(ide_hwif_t *hwif)
{
unsigned char ch;

Expand All @@ -76,16 +76,12 @@ static int gayle_ack_intr_a4000(ide_hwif_t *hwif)
return 1;
}

static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
static void gayle_a1200_clear_irq(ide_drive_t *drive)
{
unsigned char ch;
ide_hwif_t *hwif = drive->hwif;

ch = z_readb(hwif->io_ports.irq_addr);
if (!(ch & GAYLE_IRQ_IDE))
return 0;
(void)z_readb(hwif->io_ports.status_addr);
z_writeb(0x7c, hwif->io_ports.irq_addr);
return 1;
}

static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
Expand All @@ -108,6 +104,10 @@ static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base,
hw->ack_intr = ack_intr;
}

static const struct ide_port_ops gayle_a1200_port_ops = {
.clear_irq = gayle_a1200_clear_irq,
};

static const struct ide_port_info gayle_port_info = {
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE |
IDE_HFLAG_NO_DMA,
Expand All @@ -123,9 +123,9 @@ static int __init gayle_init(void)
{
unsigned long phys_base, res_start, res_n;
unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr;
int a4000, i, rc;
struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS];
struct ide_port_info d = gayle_port_info;

if (!MACH_IS_AMIGA)
return -ENODEV;
Expand All @@ -148,11 +148,10 @@ static int __init gayle_init(void)
if (a4000) {
phys_base = GAYLE_BASE_4000;
irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_4000);
ack_intr = gayle_ack_intr_a4000;
} else {
phys_base = GAYLE_BASE_1200;
irqport = (unsigned long)ZTWO_VADDR(GAYLE_IRQ_1200);
ack_intr = gayle_ack_intr_a1200;
d.port_ops = &gayle_a1200_port_ops;
}

res_start = ((unsigned long)phys_base) & ~(GAYLE_NEXT_PORT-1);
Expand All @@ -165,12 +164,12 @@ static int __init gayle_init(void)
base = (unsigned long)ZTWO_VADDR(phys_base + i * GAYLE_NEXT_PORT);
ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;

gayle_setup_ports(&hw[i], base, ctrlport, irqport, ack_intr);
gayle_setup_ports(&hw[i], base, ctrlport, irqport, gayle_ack_intr);

hws[i] = &hw[i];
}

rc = ide_host_add(&gayle_port_info, hws, i, NULL);
rc = ide_host_add(&d, hws, i, NULL);
if (rc)
release_mem_region(res_start, res_n);

Expand Down
2 changes: 0 additions & 2 deletions drivers/ide/ide-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,6 @@ void ide_timer_expiry (unsigned long data)
} else if (drive_is_ready(drive)) {
if (drive->waiting_for_dma)
hwif->dma_ops->dma_lost_irq(drive);
if (hwif->ack_intr)
hwif->ack_intr(hwif);
if (hwif->port_ops && hwif->port_ops->clear_irq)
hwif->port_ops->clear_irq(drive);

Expand Down
18 changes: 14 additions & 4 deletions drivers/ide/macide.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ volatile unsigned char *ide_ifr = (unsigned char *) (IDE_BASE + IDE_IFR);

int macide_ack_intr(ide_hwif_t* hwif)
{
if (*ide_ifr & 0x20) {
*ide_ifr &= ~0x20;
if (*ide_ifr & 0x20)
return 1;
}
return 0;
}

static void macide_clear_irq(ide_drive_t *drive)
{
*ide_ifr &= ~0x20;
}

static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
int irq, ide_ack_intr_t *ack_intr)
{
Expand All @@ -78,7 +81,12 @@ static void __init macide_setup_ports(struct ide_hw *hw, unsigned long base,
hw->ack_intr = ack_intr;
}

static const struct ide_port_ops macide_port_ops = {
.clear_irq = macide_clear_irq,
};

static const struct ide_port_info macide_port_info = {
.port_ops = &macide_port_ops,
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
.irq_flags = IRQF_SHARED,
.chipset = ide_generic,
Expand All @@ -97,6 +105,7 @@ static int __init macide_init(void)
unsigned long base;
int irq;
struct ide_hw hw, *hws[] = { &hw };
struct ide_port_info d = macide_port_info;

if (!MACH_IS_MAC)
return -ENODEV;
Expand All @@ -115,6 +124,7 @@ static int __init macide_init(void)
case MAC_IDE_BABOON:
base = BABOON_BASE;
ack_intr = NULL;
d.port_ops = NULL;
irq = IRQ_BABOON_1;
break;
default:
Expand All @@ -126,7 +136,7 @@ static int __init macide_init(void)

macide_setup_ports(&hw, base, irq, ack_intr);

return ide_host_add(&macide_port_info, hws, 1, NULL);
return ide_host_add(&d, hws, 1, NULL);
}

module_init(macide_init);
Expand Down

0 comments on commit eba8999

Please sign in to comment.