ips_pci.c (114902) | ips_pci.c (116852) |
---|---|
1/*- 2 * Copyright (c) 2002 Adaptec Inc. 3 * All rights reserved. 4 * 5 * Written by: David Jeffery 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 2002 Adaptec Inc. 3 * All rights reserved. 4 * 5 * Written by: David Jeffery 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/ips/ips_pci.c 114902 2003-05-11 06:36:49Z scottl $ | 28 * $FreeBSD: head/sys/dev/ips/ips_pci.c 116852 2003-06-26 00:03:59Z scottl $ |
29 */ 30 31 32#include <dev/ips/ips.h> 33static int ips_pci_free(ips_softc_t *sc); 34 35static int ips_pci_probe(device_t dev) 36{ --- 8 unchanged lines hidden (view full) --- 45 return (0); 46 } 47 return(ENXIO); 48} 49 50static int ips_pci_attach(device_t dev) 51{ 52 u_int32_t command; | 29 */ 30 31 32#include <dev/ips/ips.h> 33static int ips_pci_free(ips_softc_t *sc); 34 35static int ips_pci_probe(device_t dev) 36{ --- 8 unchanged lines hidden (view full) --- 45 return (0); 46 } 47 return(ENXIO); 48} 49 50static int ips_pci_attach(device_t dev) 51{ 52 u_int32_t command; |
53 int tval; |
|
53 ips_softc_t *sc; 54 | 54 ips_softc_t *sc; 55 |
56 57 tval = 0; 58 if (resource_int_value(device_get_name(dev), device_get_unit(dev), 59 "disable", &tval) == 0 && tval) { 60 device_printf(dev, "device is disabled\n"); 61 /* but return 0 so the !$)$)*!$*) unit isn't reused */ 62 return (0); 63 } |
|
55 DEVICE_PRINTF(1, dev, "in attach.\n"); 56 sc = (ips_softc_t *)device_get_softc(dev); 57 if(!sc){ 58 printf("how is sc NULL?!\n"); 59 return (ENXIO); 60 } 61 bzero(sc, sizeof(ips_softc_t)); 62 sc->dev = dev; --- 57 unchanged lines hidden (view full) --- 120 /* maxsegsize*/ BUS_SPACE_MAXSIZE_32BIT, 121 /* flags */ 0, 122 &sc->adapter_dmatag) != 0) { 123 printf("IPS can't alloc dma tag\n"); 124 goto error; 125 } 126 if(ips_adapter_init(sc)) 127 goto error; | 64 DEVICE_PRINTF(1, dev, "in attach.\n"); 65 sc = (ips_softc_t *)device_get_softc(dev); 66 if(!sc){ 67 printf("how is sc NULL?!\n"); 68 return (ENXIO); 69 } 70 bzero(sc, sizeof(ips_softc_t)); 71 sc->dev = dev; --- 57 unchanged lines hidden (view full) --- 129 /* maxsegsize*/ BUS_SPACE_MAXSIZE_32BIT, 130 /* flags */ 0, 131 &sc->adapter_dmatag) != 0) { 132 printf("IPS can't alloc dma tag\n"); 133 goto error; 134 } 135 if(ips_adapter_init(sc)) 136 goto error; |
137 sc->configured = 1; |
|
128 return 0; 129error: 130 ips_pci_free(sc); 131 return (ENXIO); 132} 133 134static int ips_pci_free(ips_softc_t *sc) 135{ 136 if(sc->adapter_dmatag) 137 bus_dma_tag_destroy(sc->adapter_dmatag); 138 if(sc->irqcookie) 139 bus_teardown_intr(sc->dev, sc->irqres, sc->irqcookie); 140 if(sc->irqres) 141 bus_release_resource(sc->dev, SYS_RES_IRQ, sc->irqrid, sc->irqres); 142 if(sc->iores) 143 bus_release_resource(sc->dev, sc->iotype, sc->rid, sc->iores); | 138 return 0; 139error: 140 ips_pci_free(sc); 141 return (ENXIO); 142} 143 144static int ips_pci_free(ips_softc_t *sc) 145{ 146 if(sc->adapter_dmatag) 147 bus_dma_tag_destroy(sc->adapter_dmatag); 148 if(sc->irqcookie) 149 bus_teardown_intr(sc->dev, sc->irqres, sc->irqcookie); 150 if(sc->irqres) 151 bus_release_resource(sc->dev, SYS_RES_IRQ, sc->irqrid, sc->irqres); 152 if(sc->iores) 153 bus_release_resource(sc->dev, sc->iotype, sc->rid, sc->iores); |
154 sc->configured = 0; |
|
144 return 0; 145} 146 147static int ips_pci_detach(device_t dev) 148{ 149 ips_softc_t *sc; 150 DEVICE_PRINTF(1, dev, "detaching ServeRaid\n"); 151 sc = (ips_softc_t *) device_get_softc(dev); | 155 return 0; 156} 157 158static int ips_pci_detach(device_t dev) 159{ 160 ips_softc_t *sc; 161 DEVICE_PRINTF(1, dev, "detaching ServeRaid\n"); 162 sc = (ips_softc_t *) device_get_softc(dev); |
152 ips_flush_cache(sc); 153 if(ips_adapter_free(sc)) 154 return EBUSY; 155 ips_pci_free(sc); 156 mtx_destroy(&sc->cmd_mtx); | 163 if (sc->configured) { 164 sc->configured = 0; 165 ips_flush_cache(sc); 166 if(ips_adapter_free(sc)) 167 return EBUSY; 168 ips_pci_free(sc); 169 mtx_destroy(&sc->cmd_mtx); 170 } |
157 return 0; 158} 159 160static int ips_pci_shutdown(device_t dev) 161{ 162 ips_softc_t *sc = (ips_softc_t *) device_get_softc(dev); | 171 return 0; 172} 173 174static int ips_pci_shutdown(device_t dev) 175{ 176 ips_softc_t *sc = (ips_softc_t *) device_get_softc(dev); |
163 ips_flush_cache(sc); | 177 if (sc->configured) { 178 ips_flush_cache(sc); 179 } |
164 return 0; 165} 166 167static device_method_t ips_driver_methods[] = { 168 DEVMETHOD(device_probe, ips_pci_probe), 169 DEVMETHOD(device_attach, ips_pci_attach), 170 DEVMETHOD(device_detach, ips_pci_detach), 171 DEVMETHOD(device_shutdown, ips_pci_shutdown), 172 {0,0} 173}; 174 175static driver_t ips_pci_driver = { 176 "ips", 177 ips_driver_methods, 178 sizeof(ips_softc_t), 179}; 180 181static devclass_t ips_devclass; 182DRIVER_MODULE(ips, pci, ips_pci_driver, ips_devclass, 0, 0); | 180 return 0; 181} 182 183static device_method_t ips_driver_methods[] = { 184 DEVMETHOD(device_probe, ips_pci_probe), 185 DEVMETHOD(device_attach, ips_pci_attach), 186 DEVMETHOD(device_detach, ips_pci_detach), 187 DEVMETHOD(device_shutdown, ips_pci_shutdown), 188 {0,0} 189}; 190 191static driver_t ips_pci_driver = { 192 "ips", 193 ips_driver_methods, 194 sizeof(ips_softc_t), 195}; 196 197static devclass_t ips_devclass; 198DRIVER_MODULE(ips, pci, ips_pci_driver, ips_devclass, 0, 0); |