summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-07-23 19:14:14 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-07-23 19:14:14 +0000
commit3a56cb009a515688f8972435706ffb119c064d8c (patch)
treed3767e35123103c091a679064ed60f216a33e266 /sys
parent675faf8c91f4f5811eeca89c89b8e7ebd5d1bc02 (diff)
Do not rely on an <ichc>invisible cast</ichc> 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@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hppa/dev/dino.c16
1 files 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;