diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-11-07 02:57:47 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-11-07 02:57:47 +0000 |
commit | 122c6d25289aaf1ae44207930b4b0660a098558c (patch) | |
tree | 83e03d0a047ee9488d7bf6fb0891f3d61a4ad5d3 /sys/dev | |
parent | c8e59e19f57b8b7a6a10b4531c5600549429472e (diff) |
- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_sf.c | 46 | ||||
-rw-r--r-- | sys/dev/pci/if_sk.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_ste.c | 19 | ||||
-rw-r--r-- | sys/dev/pci/if_tl.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/if_vge.c | 16 | ||||
-rw-r--r-- | sys/dev/pci/if_vr.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/if_wb.c | 82 |
7 files changed, 85 insertions, 110 deletions
diff --git a/sys/dev/pci/if_sf.c b/sys/dev/pci/if_sf.c index fde26e89db2..f13d340c21e 100644 --- a/sys/dev/pci/if_sf.c +++ b/sys/dev/pci/if_sf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sf.c,v 1.33 2005/09/11 19:41:34 mickey Exp $ */ +/* $OpenBSD: if_sf.c,v 1.34 2005/11/07 02:57:45 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -460,7 +460,7 @@ int sf_ioctl(ifp, command, data) struct mii_data *mii; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); @@ -584,7 +584,7 @@ void sf_attach(parent, self, aux) struct device *parent, *self; void *aux; { - int s, i; + int i; const char *intrstr = NULL; u_int32_t command; struct sf_softc *sc = (struct sf_softc *)self; @@ -592,9 +592,7 @@ void sf_attach(parent, self, aux) pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; struct ifnet *ifp; - bus_size_t iosize; - - s = splimp(); + bus_size_t size; /* * Handle power management nonsense. @@ -627,27 +625,18 @@ void sf_attach(parent, self, aux) /* * Map control/status registers. */ - command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); #ifdef SF_USEIOSPACE - if (!(command & PCI_COMMAND_IO_ENABLE)) { - printf(": failed to enable I/O ports\n"); - goto fail; - } if (pci_mapreg_map(pa, SF_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, - &sc->sf_btag, &sc->sf_bhandle, NULL, &iosize, 0)) { + &sc->sf_btag, &sc->sf_bhandle, NULL, &size, 0)) { printf(": can't map I/O space\n"); - goto fail; + return; } #else - if (!(command & PCI_COMMAND_MEM_ENABLE)) { - printf(": failed to enable memory mapping\n"); - goto fail; - } if (pci_mapreg_map(pa, SF_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, - &sc->sf_btag, &sc->sf_bhandle, NULL, &iosize, 0)){ + &sc->sf_btag, &sc->sf_bhandle, NULL, &size, 0)){ printf(": can't map mem space\n"); - goto fail; + return; } #endif @@ -678,14 +667,14 @@ void sf_attach(parent, self, aux) sc->arpcom.ac_enaddr[i] = sf_read_eeprom(sc, SF_EE_NODEADDR + ETHER_ADDR_LEN - i); - printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); + printf(", address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); /* Allocate the descriptor queues. */ sc->sf_ldata_ptr = malloc(sizeof(struct sf_list_data) + 8, M_DEVBUF, M_NOWAIT); if (sc->sf_ldata_ptr == NULL) { - printf("%s: no memory for list buffers!\n", sc->sc_dev.dv_xname); - goto fail_1; + printf(": no memory for list buffers!\n"); + goto fail_2; } sc->sf_ldata = (struct sf_list_data *)sc->sf_ldata_ptr; @@ -725,12 +714,13 @@ void sf_attach(parent, self, aux) ether_ifattach(ifp); shutdownhook_establish(sf_shutdown, sc); + return; + +fail_2: + pci_intr_disestablish(pc, sc->sc_ih); fail_1: - bus_space_unmap(sc->sf_btag, sc->sf_bhandle, iosize); -fail: - splx(s); - return; + bus_space_unmap(sc->sf_btag, sc->sf_bhandle, size); } int sf_init_rx_ring(sc) @@ -1033,7 +1023,7 @@ void sf_init(xsc) struct mii_data *mii; int i, s; - s = splimp(); + s = splnet(); mii = &sc->sc_mii; @@ -1334,7 +1324,7 @@ void sf_stats_update(xsc) u_int32_t *ptr; int i, s; - s = splimp(); + s = splnet(); sc = xsc; ifp = &sc->arpcom.ac_if; diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index 05d7e880088..0a3d95a6ca5 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.85 2005/10/15 23:09:17 brad Exp $ */ +/* $OpenBSD: if_sk.c,v 1.86 2005/11/07 02:57:45 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -915,7 +915,7 @@ sk_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct mii_data *mii; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc_if->arpcom, command, data)) > 0) { splx(s); @@ -2586,7 +2586,7 @@ sk_init(void *xsc_if) DPRINTFN(2, ("sk_init\n")); - s = splimp(); + s = splnet(); if (ifp->if_flags & IFF_RUNNING) { splx(s); diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c index 9ae281c5cbb..b339229cecc 100644 --- a/sys/dev/pci/if_ste.c +++ b/sys/dev/pci/if_ste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ste.c,v 1.33 2005/09/10 23:21:05 brad Exp $ */ +/* $OpenBSD: if_ste.c,v 1.34 2005/11/07 02:57:45 brad Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -197,7 +197,7 @@ int ste_mii_readreg(sc, frame) { int i, ack, s; - s = splimp(); + s = splnet(); /* * Set up frame for RX. @@ -289,7 +289,7 @@ int ste_mii_writereg(sc, frame) { int s; - s = splimp(); + s = splnet(); /* * Set up frame for TX. */ @@ -795,7 +795,7 @@ void ste_stats_update(xsc) struct mii_data *mii; int s; - s = splimp(); + s = splnet(); sc = xsc; ifp = &sc->arpcom.ac_if; @@ -945,8 +945,7 @@ void ste_attach(parent, self, aux) */ if (ste_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, STE_EEADDR_NODE0, 3, 0)) { - printf("%s: failed to read station address\n", - sc->sc_dev.dv_xname); + printf(": failed to read station address\n"); goto fail_2; } @@ -955,8 +954,7 @@ void ste_attach(parent, self, aux) sc->ste_ldata_ptr = malloc(sizeof(struct ste_list_data) + 8, M_DEVBUF, M_DONTWAIT); if (sc->ste_ldata_ptr == NULL) { - printf("%s: no memory for list buffers!\n", - sc->sc_dev.dv_xname); + printf(": no memory for list buffers!\n"); goto fail_2; } @@ -997,7 +995,6 @@ void ste_attach(parent, self, aux) ether_ifattach(ifp); shutdownhook_establish(ste_shutdown, sc); - return; fail_2: @@ -1110,7 +1107,7 @@ void ste_init(xsc) struct mii_data *mii; int i, s; - s = splimp(); + s = splnet(); ste_stop(sc); @@ -1295,7 +1292,7 @@ int ste_ioctl(ifp, command, data) struct mii_data *mii; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); diff --git a/sys/dev/pci/if_tl.c b/sys/dev/pci/if_tl.c index 8c5ccedaa91..960cc67e18c 100644 --- a/sys/dev/pci/if_tl.c +++ b/sys/dev/pci/if_tl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tl.c,v 1.35 2005/09/11 18:17:08 mickey Exp $ */ +/* $OpenBSD: if_tl.c,v 1.36 2005/11/07 02:57:45 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -589,7 +589,7 @@ int tl_mii_readreg(sc, frame) int i, ack, s; int minten = 0; - s = splimp(); + s = splnet(); tl_mii_sync(sc); @@ -686,7 +686,7 @@ int tl_mii_writereg(sc, frame) tl_mii_sync(sc); - s = splimp(); + s = splnet(); /* * Set up frame for TX. */ @@ -1407,7 +1407,7 @@ void tl_stats_update(xsc) u_int32_t *p; int s; - s = splimp(); + s = splnet(); bzero((char *)&tl_stats, sizeof(struct tl_stats)); @@ -1643,7 +1643,7 @@ void tl_init(xsc) struct ifnet *ifp = &sc->arpcom.ac_if; int s; - s = splimp(); + s = splnet(); ifp = &sc->arpcom.ac_if; @@ -1782,7 +1782,7 @@ int tl_ioctl(ifp, command, data) struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c index c7a8e0ff477..7cd6cc8a56e 100644 --- a/sys/dev/pci/if_vge.c +++ b/sys/dev/pci/if_vge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vge.c,v 1.17 2005/10/08 01:58:17 brad Exp $ */ +/* $OpenBSD: if_vge.c,v 1.18 2005/11/07 02:57:45 brad Exp $ */ /* $FreeBSD: if_vge.c,v 1.3 2004/09/11 22:13:25 wpaul Exp $ */ /* * Copyright (c) 2004 @@ -317,7 +317,7 @@ vge_miibus_readreg(struct device *dev, int phy, int reg) if (phy != (CSR_READ_1(sc, VGE_MIICFG) & 0x1F)) return(0); - s = splimp(); + s = splnet(); vge_miipoll_stop(sc); @@ -354,7 +354,7 @@ vge_miibus_writereg(struct device *dev, int phy, int reg, int data) if (phy != (CSR_READ_1(sc, VGE_MIICFG) & 0x1F)) return; - s = splimp(); + s = splnet(); vge_miipoll_stop(sc); /* Specify the register we want to write. */ @@ -1108,12 +1108,6 @@ vge_rxeof(struct vge_softc *sc) (rxctl & VGE_RDCTL_PROTOCSUMOK)) m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; -#ifdef VGE_VLAN - if (rxstat & VGE_RDSTS_VTAG) - VLAN_INPUT_TAG(ifp, m, - ntohs((rxctl & VGE_RDCTL_VLANID)), continue); -#endif - #if NBPFILTER > 0 if (ifp->if_bpf) bpf_mtap(ifp->if_bpf, m); @@ -1199,7 +1193,7 @@ vge_tick(void *xsc) struct mii_data *mii = &sc->sc_mii; int s; - s = splimp(); + s = splnet(); mii_tick(mii); @@ -1735,7 +1729,7 @@ vge_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct ifaddr *ifa = (struct ifaddr *) data; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index 781d78ac09c..f05bec31232 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.48 2005/11/04 16:59:45 brad Exp $ */ +/* $OpenBSD: if_vr.c,v 1.49 2005/11/07 02:57:45 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -596,9 +596,11 @@ vr_reset(sc) printf("%s: reset never completed!\n", sc->sc_dev.dv_xname); else { +#ifdef DEBUG /* Use newer force reset command */ printf("%s: Using force reset command.\n", sc->sc_dev.dv_xname); +#endif VR_SETBIT(sc, VR_MISC_CR1, VR_MISCCR1_FORSRST); } } @@ -760,23 +762,23 @@ vr_attach(parent, self, aux) sc->sc_dmat = pa->pa_dmat; if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct vr_list_data), PAGE_SIZE, 0, &sc->sc_listseg, 1, &rseg, BUS_DMA_NOWAIT)) { - printf("%s: can't alloc list\n", sc->sc_dev.dv_xname); + printf(": can't alloc list\n"); goto fail_2; } if (bus_dmamem_map(sc->sc_dmat, &sc->sc_listseg, rseg, sizeof(struct vr_list_data), &kva, BUS_DMA_NOWAIT)) { - printf("%s: can't map dma buffers (%d bytes)\n", - sc->sc_dev.dv_xname, sizeof(struct vr_list_data)); + printf(": can't map dma buffers (%d bytes)\n", + sizeof(struct vr_list_data)); goto fail_3; } if (bus_dmamap_create(sc->sc_dmat, sizeof(struct vr_list_data), 1, sizeof(struct vr_list_data), 0, BUS_DMA_NOWAIT, &sc->sc_listmap)) { - printf("%s: can't create dma map\n", sc->sc_dev.dv_xname); + printf(": can't create dma map\n"); goto fail_4; } if (bus_dmamap_load(sc->sc_dmat, sc->sc_listmap, kva, sizeof(struct vr_list_data), NULL, BUS_DMA_NOWAIT)) { - printf("%s: can't load dma map\n", sc->sc_dev.dv_xname); + printf(": can't load dma map\n"); goto fail_5; } sc->vr_ldata = (struct vr_list_data *)kva; diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index d877f9d368c..a57d3deda10 100644 --- a/sys/dev/pci/if_wb.c +++ b/sys/dev/pci/if_wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wb.c,v 1.30 2005/09/11 18:17:08 mickey Exp $ */ +/* $OpenBSD: if_wb.c,v 1.31 2005/11/07 02:57:46 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -341,7 +341,7 @@ int wb_mii_readreg(sc, frame) { int i, ack, s; - s = splimp(); + s = splnet(); /* * Set up frame for RX. @@ -437,7 +437,7 @@ int wb_mii_writereg(sc, frame) { int s; - s = splimp(); + s = splnet(); /* * Set up frame for TX. */ @@ -715,15 +715,13 @@ wb_attach(parent, self, aux) pci_intr_handle_t ih; const char *intrstr = NULL; struct ifnet *ifp = &sc->arpcom.ac_if; - bus_size_t iosize; - int s, rseg; + bus_size_t size; + int rseg; pcireg_t command; bus_dma_segment_t seg; bus_dmamap_t dmamap; caddr_t kva; - s = splimp(); - /* * Handle power management nonsense. */ @@ -758,27 +756,18 @@ wb_attach(parent, self, aux) /* * Map control/status registers. */ - command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); #ifdef WB_USEIOSPACE - if (!(command & PCI_COMMAND_IO_ENABLE)) { - printf(": failed to enable I/O ports!\n"); - goto fail; - } if (pci_mapreg_map(pa, WB_PCI_LOIO, PCI_MAPREG_TYPE_IO, 0, - &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)) { + &sc->wb_btag, &sc->wb_bhandle, NULL, &size, 0)) { printf(": can't map i/o space\n"); - goto fail; + return; } #else - if (!(command & PCI_COMMAND_MEM_ENABLE)) { - printf(": failed to enable memory mapping!\n"); - goto fail; - } if (pci_mapreg_map(pa, WB_PCI_LOMEM, PCI_MAPREG_TYPE_MEM, 0, - &sc->wb_btag, &sc->wb_bhandle, NULL, &iosize, 0)){ + &sc->wb_btag, &sc->wb_bhandle, NULL, &size, 0)){ printf(": can't map mem space\n"); - goto fail; + return; } #endif @@ -808,36 +797,28 @@ wb_attach(parent, self, aux) * Get station address from the EEPROM. */ wb_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr, 0, 3, 0); - printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); + printf(", address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); if (bus_dmamem_alloc(pa->pa_dmat, sizeof(struct wb_list_data), PAGE_SIZE, 0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) { - printf("%s: can't alloc list data\n", sc->sc_dev.dv_xname); - goto fail_1; + printf(": can't alloc list data\n"); + goto fail_2; } if (bus_dmamem_map(pa->pa_dmat, &seg, rseg, sizeof(struct wb_list_data), &kva, BUS_DMA_NOWAIT)) { - printf("%s: can't map list data, size %d\n", - sc->sc_dev.dv_xname, sizeof(struct wb_list_data)); - bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail_1; + printf(": can't map list data, size %d\n", + sizeof(struct wb_list_data)); + goto fail_3; } if (bus_dmamap_create(pa->pa_dmat, sizeof(struct wb_list_data), 1, sizeof(struct wb_list_data), 0, BUS_DMA_NOWAIT, &dmamap)) { - printf("%s: can't create dma map\n", sc->sc_dev.dv_xname); - bus_dmamem_unmap(pa->pa_dmat, kva, - sizeof(struct wb_list_data)); - bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail_1; + printf(": can't create dma map\n"); + goto fail_4; } if (bus_dmamap_load(pa->pa_dmat, dmamap, kva, sizeof(struct wb_list_data), NULL, BUS_DMA_NOWAIT)) { - printf("%s: can't load dma map\n", sc->sc_dev.dv_xname); - bus_dmamap_destroy(pa->pa_dmat, dmamap); - bus_dmamem_unmap(pa->pa_dmat, kva, - sizeof(struct wb_list_data)); - bus_dmamem_free(pa->pa_dmat, &seg, rseg); - goto fail_1; + printf(": can't load dma map\n"); + goto fail_5; } sc->wb_ldata = (struct wb_list_data *)kva; bzero(sc->wb_ldata, sizeof(struct wb_list_data)); @@ -878,12 +859,23 @@ wb_attach(parent, self, aux) ether_ifattach(ifp); shutdownhook_establish(wb_shutdown, sc); + return; + +fail_5: + bus_dmamap_destroy(pa->pa_dmat, dmamap); + +fail_4: + bus_dmamem_unmap(pa->pa_dmat, kva, + sizeof(struct wb_list_data)); + +fail_3: + bus_dmamem_free(pa->pa_dmat, &seg, rseg); + +fail_2: + pci_intr_disestablish(pc, sc->sc_ih); fail_1: - bus_space_unmap(sc->wb_btag, sc->wb_bhandle, iosize); -fail: - splx(s); - return; + bus_space_unmap(sc->wb_btag, sc->wb_bhandle, size); } /* @@ -1273,7 +1265,7 @@ wb_tick(xsc) struct wb_softc *sc = xsc; int s; - s = splimp(); + s = splnet(); mii_tick(&sc->sc_mii); splx(s); timeout_add(&sc->wb_tick_tmo, hz); @@ -1474,7 +1466,7 @@ void wb_init(xsc) struct ifnet *ifp = &sc->arpcom.ac_if; int s, i; - s = splimp(); + s = splnet(); /* * Cancel pending I/O and free all RX/TX buffers. @@ -1624,7 +1616,7 @@ int wb_ioctl(ifp, command, data) struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; - s = splimp(); + s = splnet(); if ((error = ether_ioctl(ifp, &sc->arpcom, command, data)) > 0) { splx(s); |