diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2008-05-23 08:49:28 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2008-05-23 08:49:28 +0000 |
commit | c58cbcf88e6e32a3776ac062709146b0a611e090 (patch) | |
tree | 297d755b4b24f534c9f0dc6baaa1204d858b4390 /sys/dev | |
parent | 6947b86a8473a8a6d71156b7eb869fc7ad30e762 (diff) |
Simplify the combination use of pci_mapreg_type()/pci_mapreg_map() as
suggested by dlg@ awhile ago.
ok dlg@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/ciss_pci.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/if_bce.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/if_bge.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_bnx.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_bwi_pci.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_et.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_lge.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_msk.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_myx.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/if_nfe.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_nge.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_sk.c | 13 |
12 files changed, 35 insertions, 109 deletions
diff --git a/sys/dev/pci/ciss_pci.c b/sys/dev/pci/ciss_pci.c index f8d7920f55d..276e466e366 100644 --- a/sys/dev/pci/ciss_pci.c +++ b/sys/dev/pci/ciss_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciss_pci.c,v 1.10 2006/09/20 19:45:16 brad Exp $ */ +/* $OpenBSD: ciss_pci.c,v 1.11 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -101,14 +101,9 @@ ciss_pci_attach(struct device *parent, struct device *self, void *aux) pcireg_t reg; memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, CISS_BAR); - if (memtype != (PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT) && - memtype != (PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT)) { - printf(": wrong BAR type\n"); - return; - } if (pci_mapreg_map(pa, CISS_BAR, memtype, 0, &sc->iot, &sc->ioh, NULL, &size, 0)) { - printf(": can't map controller i/o space\n"); + printf(": can't map controller mem space\n"); return; } sc->dmat = pa->pa_dmat; diff --git a/sys/dev/pci/if_bce.c b/sys/dev/pci/if_bce.c index e1cfa3793d1..981f6eb7eea 100644 --- a/sys/dev/pci/if_bce.c +++ b/sys/dev/pci/if_bce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bce.c,v 1.23 2008/05/14 04:12:57 brad Exp $ */ +/* $OpenBSD: if_bce.c,v 1.24 2008/05/23 08:49:27 brad Exp $ */ /* $NetBSD: if_bce.c,v 1.3 2003/09/29 01:53:02 mrg Exp $ */ /* @@ -248,13 +248,8 @@ bce_attach(struct device *parent, struct device *self, void *aux) * Map control/status registers. */ memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BCE_PCI_BAR0); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, BCE_PCI_BAR0, memtype, 0, &sc->bce_btag, - &sc->bce_bhandle, &memaddr, &memsize, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, BCE_PCI_BAR0, memtype, 0, &sc->bce_btag, + &sc->bce_bhandle, &memaddr, &memsize, 0)) { printf(": unable to find mem space\n"); return; } diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 62bff6f475d..b335db6d7bf 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.232 2008/05/21 22:27:01 kettenis Exp $ */ +/* $OpenBSD: if_bge.c,v 1.233 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -1804,14 +1804,8 @@ bge_attach(struct device *parent, struct device *self, void *aux) DPRINTFN(5, ("pci_mapreg_map\n")); memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BGE_PCI_BAR0); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, BGE_PCI_BAR0, - memtype, 0, &sc->bge_btag, &sc->bge_bhandle, - NULL, &size, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, BGE_PCI_BAR0, memtype, 0, &sc->bge_btag, + &sc->bge_bhandle, NULL, &size, 0)) { printf(": can't find mem space\n"); return; } diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index cc81227856f..479eaaaf899 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.58 2008/02/28 02:02:43 brad Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.59 2008/05/23 08:49:27 brad Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -627,14 +627,8 @@ bnx_attach(struct device *parent, struct device *self, void *aux) * Map control/status registers. */ memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BNX_PCI_BAR0); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, BNX_PCI_BAR0, - memtype, 0, &sc->bnx_btag, &sc->bnx_bhandle, - NULL, &sc->bnx_size, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, BNX_PCI_BAR0, memtype, 0, &sc->bnx_btag, + &sc->bnx_bhandle, NULL, &sc->bnx_size, 0)) { printf(": can't find mem space\n"); return; } diff --git a/sys/dev/pci/if_bwi_pci.c b/sys/dev/pci/if_bwi_pci.c index 33feafe839f..7346df6c09e 100644 --- a/sys/dev/pci/if_bwi_pci.c +++ b/sys/dev/pci/if_bwi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bwi_pci.c,v 1.6 2008/02/14 22:10:02 brad Exp $ */ +/* $OpenBSD: if_bwi_pci.c,v 1.7 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -113,14 +113,8 @@ bwi_pci_attach(struct device *parent, struct device *self, void *aux) /* map control / status registers */ memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, BWI_PCI_BAR0); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, BWI_PCI_BAR0, - memtype, 0, &sc->sc_mem_bt, &sc->sc_mem_bh, - NULL, &psc->psc_mapsize, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, BWI_PCI_BAR0, memtype, 0, &sc->sc_mem_bt, + &sc->sc_mem_bh, NULL, &psc->psc_mapsize, 0)) { printf(": could not map memory space\n"); return; } diff --git a/sys/dev/pci/if_et.c b/sys/dev/pci/if_et.c index 62ba18718ec..5b6ee5891d5 100644 --- a/sys/dev/pci/if_et.c +++ b/sys/dev/pci/if_et.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_et.c,v 1.7 2008/02/08 04:42:05 brad Exp $ */ +/* $OpenBSD: if_et.c,v 1.8 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. * @@ -206,14 +206,8 @@ et_attach(struct device *parent, struct device *self, void *aux) sc->sc_timer = et_timer; memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, ET_PCIR_BAR); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, ET_PCIR_BAR, memtype, 0, &sc->sc_mem_bt, - &sc->sc_mem_bh, NULL, &memsize, 0) == 0) - break; - /* FALLTHROUGH */ - default: + if (pci_mapreg_map(pa, ET_PCIR_BAR, memtype, 0, &sc->sc_mem_bt, + &sc->sc_mem_bh, NULL, &memsize, 0)) { printf(": could not map mem space\n"); return; } diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c index 2050448e419..cc9913b55f6 100644 --- a/sys/dev/pci/if_lge.c +++ b/sys/dev/pci/if_lge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lge.c,v 1.46 2007/11/26 09:28:33 martynas Exp $ */ +/* $OpenBSD: if_lge.c,v 1.47 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -456,14 +456,8 @@ lge_attach(struct device *parent, struct device *self, void *aux) } #else memtype = pci_mapreg_type(pc, pa->pa_tag, LGE_PCI_LOMEM); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, LGE_PCI_LOMEM, - memtype, 0, &sc->lge_btag, &sc->lge_bhandle, - NULL, &size, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, LGE_PCI_LOMEM, memtype, 0, &sc->lge_btag, + &sc->lge_bhandle, NULL, &size, 0)) { printf(": can't map mem space\n"); return; } diff --git a/sys/dev/pci/if_msk.c b/sys/dev/pci/if_msk.c index 4d956f0769f..1549b0767d3 100644 --- a/sys/dev/pci/if_msk.c +++ b/sys/dev/pci/if_msk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_msk.c,v 1.62 2008/03/02 19:16:43 brad Exp $ */ +/* $OpenBSD: if_msk.c,v 1.63 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -1234,15 +1234,9 @@ mskc_attach(struct device *parent, struct device *self, void *aux) /* * Map control/status registers. */ - memtype = pci_mapreg_type(pc, pa->pa_tag, SK_PCI_LOMEM); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, SK_PCI_LOMEM, memtype, 0, &sc->sk_btag, - &sc->sk_bhandle, NULL, &sc->sk_bsize, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, SK_PCI_LOMEM, memtype, 0, &sc->sk_btag, + &sc->sk_bhandle, NULL, &sc->sk_bsize, 0)) { printf(": can't map mem space\n"); return; } diff --git a/sys/dev/pci/if_myx.c b/sys/dev/pci/if_myx.c index 96dab1118fd..8c0fe91c02d 100644 --- a/sys/dev/pci/if_myx.c +++ b/sys/dev/pci/if_myx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_myx.c,v 1.6 2008/01/16 19:30:19 thib Exp $ */ +/* $OpenBSD: if_myx.c,v 1.7 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@openbsd.org> @@ -212,19 +212,10 @@ myx_attach(struct device *parent, struct device *self, void *aux) sc->sc_dmat = pa->pa_dmat; sc->sc_function = pa->pa_function; - memtype = pci_mapreg_type(sc->sc_pc, sc->sc_tag, MYXBAR0); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - break; - default: - printf(": invalid memory type: 0x%x\n", memtype); - return; - } - /* Map the PCI memory space */ + memtype = pci_mapreg_type(sc->sc_pc, sc->sc_tag, MYXBAR0); if (pci_mapreg_map(pa, MYXBAR0, memtype, 0, &sc->sc_memt, - &sc->sc_memh, NULL, &sc->sc_mems, 0) != 0) { + &sc->sc_memh, NULL, &sc->sc_mems, 0)) { printf(": unable to map register memory\n"); return; } diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index c9ddf1382bb..d41d1e8ac76 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfe.c,v 1.78 2008/05/19 01:12:41 fgsch Exp $ */ +/* $OpenBSD: if_nfe.c,v 1.79 2008/05/23 08:49:27 brad Exp $ */ /*- * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> @@ -184,14 +184,8 @@ nfe_attach(struct device *parent, struct device *self, void *aux) pcireg_t memtype; memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, NFE_PCI_BA); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt, - &sc->sc_memh, NULL, &memsize, 0) == 0) - break; - /* FALLTHROUGH */ - default: + if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt, + &sc->sc_memh, NULL, &memsize, 0)) { printf(": could not map mem space\n"); return; } diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index 8d20d4127d7..bf9a030f957 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.57 2007/11/26 09:28:33 martynas Exp $ */ +/* $OpenBSD: if_nge.c,v 1.58 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -782,14 +782,8 @@ nge_attach(parent, self, aux) #else DPRINTFN(5, ("%s: pci_mapreg_map\n", sc->sc_dv.dv_xname)); memtype = pci_mapreg_type(pc, pa->pa_tag, NGE_PCI_LOMEM); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, NGE_PCI_LOMEM, - memtype, 0, &sc->nge_btag, &sc->nge_bhandle, - NULL, &size, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, NGE_PCI_LOMEM, memtype, 0, &sc->nge_btag, + &sc->nge_bhandle, NULL, &size, 0)) { printf(": can't map mem space\n"); return; } diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index 924f330efeb..67ca21f8b1f 100644 --- a/sys/dev/pci/if_sk.c +++ b/sys/dev/pci/if_sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sk.c,v 1.144 2008/03/02 19:16:43 brad Exp $ */ +/* $OpenBSD: if_sk.c,v 1.145 2008/05/23 08:49:27 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -1335,16 +1335,9 @@ skc_attach(struct device *parent, struct device *self, void *aux) /* * Map control/status registers. */ - memtype = pci_mapreg_type(pc, pa->pa_tag, SK_PCI_LOMEM); - switch (memtype) { - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: - case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: - if (pci_mapreg_map(pa, SK_PCI_LOMEM, - memtype, 0, &sc->sk_btag, &sc->sk_bhandle, - NULL, &size, 0) == 0) - break; - default: + if (pci_mapreg_map(pa, SK_PCI_LOMEM, memtype, 0, &sc->sk_btag, + &sc->sk_bhandle, NULL, &size, 0)) { printf(": can't map mem space\n"); return; } |