From 8922cf83dee93970d8b39c54fddbe208e0efc24b Mon Sep 17 00:00:00 2001 From: miod Date: Wed, 23 Jul 2008 19:14:13 +0000 Subject: [PATCH] Do not rely on an invisible cast to return failure in dino_intr_map(); rather than adding the missing cast, make the intent of the code clearer by explicitenly testing for PCI_INTERRUPT_LINE being ff. While there, enable the out-of-extent-range checks in dino_memmap() and dino_memalloc() even if no option DEBUG, but return failure instead of panicing. discussed with and ok kettenis@ marco@ --- sys/arch/hppa/dev/dino.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/arch/hppa/dev/dino.c b/sys/arch/hppa/dev/dino.c index d77af850be4..b590e69a684 100644 --- a/sys/arch/hppa/dev/dino.c +++ b/sys/arch/hppa/dev/dino.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dino.c,v 1.23 2007/08/28 21:19:17 kettenis Exp $ */ +/* $OpenBSD: dino.c,v 1.24 2008/07/23 19:14:13 miod Exp $ */ /* * Copyright (c) 2003-2005 Michael Shalayeff @@ -371,8 +371,12 @@ dino_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) pcireg_t reg; reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); + + if (PCI_INTERRUPT_LINE(reg) == 0xff) + return (1); + *ihp = PCI_INTERRUPT_LINE(reg) + 1; - return (*ihp == 0); + return (0); } const char * @@ -452,10 +456,12 @@ dino_memmap(void *v, bus_addr_t bpa, bus_size_t size, sbpa = bpa & 0xff800000; reg = sc->io_shadow; reg |= 1 << ((bpa >> 23) & 0x1f); + if (reg & 0x80000001) { #ifdef DEBUG - if (reg & 0x80000001) panic("mapping outside the mem extent range"); #endif + return (EINVAL); + } /* map into the upper bus space, if not yet mapped this 8M */ if (reg != sc->io_shadow) { @@ -541,10 +547,12 @@ dino_memalloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, reg = sc->io_shadow; reg |= 1 << ((*addrp >> 23) & 0x1f); + if (reg & 0x80000001) { #ifdef DEBUG - if (reg & 0x80000001) panic("mapping outside the mem extent range"); #endif + return (EINVAL); + } r->io_addr_en |= reg; sc->io_shadow = reg; -- 2.20.1