Invert logic around nested pmf(9) registrations for readability. XXX: should these pmf(9) calls be moved into MI attach functions XXX: using function pointers for suspend and resume passed via softc?diff -r1.29 -r1.30 src/sys/dev/pci/if_an_pci.c
(tsutsui)
--- src/sys/dev/pci/if_an_pci.c 2009/05/06 10:34:32 1.29
+++ src/sys/dev/pci/if_an_pci.c 2009/09/05 14:13:50 1.30
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_an_pci.c,v 1.29 2009/05/06 10:34:32 cegger Exp $ */ | 1 | /* $NetBSD: if_an_pci.c,v 1.30 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Atsushi Onoe. | 8 | * by Atsushi Onoe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * PCI bus front-end for the Aironet PC4500/PC4800 Wireless LAN Adapter. | 33 | * PCI bus front-end for the Aironet PC4500/PC4800 Wireless LAN Adapter. | |
34 | * Unlike WaveLAN, this adapter attached as PCI device using a PLX 9050 | 34 | * Unlike WaveLAN, this adapter attached as PCI device using a PLX 9050 | |
35 | * PCI to "dumb bus" bridge chip. | 35 | * PCI to "dumb bus" bridge chip. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.29 2009/05/06 10:34:32 cegger Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: if_an_pci.c,v 1.30 2009/09/05 14:13:50 tsutsui Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/mbuf.h> | 43 | #include <sys/mbuf.h> | |
44 | #include <sys/malloc.h> | 44 | #include <sys/malloc.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/socket.h> | 46 | #include <sys/socket.h> | |
47 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> | |
48 | #include <sys/errno.h> | 48 | #include <sys/errno.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | #include <sys/callout.h> | 50 | #include <sys/callout.h> | |
51 | 51 | |||
52 | #include <machine/endian.h> | 52 | #include <machine/endian.h> | |
@@ -158,18 +158,18 @@ an_pci_attach(device_t parent, device_t | @@ -158,18 +158,18 @@ an_pci_attach(device_t parent, device_t | |||
158 | aprint_normal(" at %s", intrstr); | 158 | aprint_normal(" at %s", intrstr); | |
159 | aprint_normal("\n"); | 159 | aprint_normal("\n"); | |
160 | return; | 160 | return; | |
161 | } | 161 | } | |
162 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | 162 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | |
163 | sc->sc_enabled = 1; | 163 | sc->sc_enabled = 1; | |
164 | 164 | |||
165 | if (an_attach(sc) != 0) { | 165 | if (an_attach(sc) != 0) { | |
166 | aprint_error_dev(self, "failed to attach controller\n"); | 166 | aprint_error_dev(self, "failed to attach controller\n"); | |
167 | pci_intr_disestablish(pa->pa_pc, psc->sc_ih); | 167 | pci_intr_disestablish(pa->pa_pc, psc->sc_ih); | |
168 | bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize); | 168 | bus_space_unmap(sc->sc_iot, sc->sc_ioh, iosize); | |
169 | } | 169 | } | |
170 | 170 | |||
171 | if (!pmf_device_register(self, NULL, NULL)) | 171 | if (pmf_device_register(self, NULL, NULL)) | |
172 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
173 | else | |||
174 | pmf_class_network_register(self, &sc->sc_if); | 172 | pmf_class_network_register(self, &sc->sc_if); | |
173 | else | |||
174 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
175 | } | 175 | } |
--- src/sys/dev/pci/if_ath_pci.c 2009/05/06 09:25:15 1.33
+++ src/sys/dev/pci/if_ath_pci.c 2009/09/05 14:13:50 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ath_pci.c,v 1.33 2009/05/06 09:25:15 cegger Exp $ */ | 1 | /* $NetBSD: if_ath_pci.c,v 1.34 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | 4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer, | 11 | * notice, this list of conditions and the following disclaimer, | |
12 | * without modification. | 12 | * without modification. | |
13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
14 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | 14 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | |
@@ -31,27 +31,27 @@ | @@ -31,27 +31,27 @@ | |||
31 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | |
34 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
36 | * THE POSSIBILITY OF SUCH DAMAGES. | 36 | * THE POSSIBILITY OF SUCH DAMAGES. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | #ifdef __FreeBSD__ | 40 | #ifdef __FreeBSD__ | |
41 | __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath_pci.c,v 1.11 2005/01/18 18:08:16 sam Exp $"); | 41 | __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath_pci.c,v 1.11 2005/01/18 18:08:16 sam Exp $"); | |
42 | #endif | 42 | #endif | |
43 | #ifdef __NetBSD__ | 43 | #ifdef __NetBSD__ | |
44 | __KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.33 2009/05/06 09:25:15 cegger Exp $"); | 44 | __KERNEL_RCSID(0, "$NetBSD: if_ath_pci.c,v 1.34 2009/09/05 14:13:50 tsutsui Exp $"); | |
45 | #endif | 45 | #endif | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * PCI/Cardbus front-end for the Atheros Wireless LAN controller driver. | 48 | * PCI/Cardbus front-end for the Atheros Wireless LAN controller driver. | |
49 | */ | 49 | */ | |
50 | 50 | |||
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | #include <sys/systm.h> | 52 | #include <sys/systm.h> | |
53 | #include <sys/mbuf.h> | 53 | #include <sys/mbuf.h> | |
54 | #include <sys/malloc.h> | 54 | #include <sys/malloc.h> | |
55 | #include <sys/kernel.h> | 55 | #include <sys/kernel.h> | |
56 | #include <sys/socket.h> | 56 | #include <sys/socket.h> | |
57 | #include <sys/errno.h> | 57 | #include <sys/errno.h> | |
@@ -250,32 +250,31 @@ ath_pci_attach(device_t parent, device_t | @@ -250,32 +250,31 @@ ath_pci_attach(device_t parent, device_t | |||
250 | goto bad2; | 250 | goto bad2; | |
251 | } | 251 | } | |
252 | 252 | |||
253 | aprint_normal("\n"); | 253 | aprint_normal("\n"); | |
254 | aprint_verbose_dev(self, "interrupting at %s\n", intrstr); | 254 | aprint_verbose_dev(self, "interrupting at %s\n", intrstr); | |
255 | 255 | |||
256 | sc->sc_dmat = pa->pa_dmat; | 256 | sc->sc_dmat = pa->pa_dmat; | |
257 | 257 | |||
258 | ATH_LOCK_INIT(sc); | 258 | ATH_LOCK_INIT(sc); | |
259 | 259 | |||
260 | if (ath_attach(PCI_PRODUCT(pa->pa_id), sc) != 0) | 260 | if (ath_attach(PCI_PRODUCT(pa->pa_id), sc) != 0) | |
261 | goto bad3; | 261 | goto bad3; | |
262 | 262 | |||
263 | if (!pmf_device_register(self, ath_pci_suspend, ath_pci_resume)) | 263 | if (pmf_device_register(self, ath_pci_suspend, ath_pci_resume)) { | |
264 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
265 | else { | |||
266 | pmf_class_network_register(self, &sc->sc_if); | 264 | pmf_class_network_register(self, &sc->sc_if); | |
267 | pmf_device_suspend_self(self); | 265 | pmf_device_suspend_self(self); | |
268 | } | 266 | } else | |
267 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
269 | return; | 268 | return; | |
270 | bad3: | 269 | bad3: | |
271 | ATH_LOCK_DESTROY(sc); | 270 | ATH_LOCK_DESTROY(sc); | |
272 | 271 | |||
273 | pci_intr_disestablish(pc, psc->sc_ih); | 272 | pci_intr_disestablish(pc, psc->sc_ih); | |
274 | bad2: /* XXX */ | 273 | bad2: /* XXX */ | |
275 | bad1: | 274 | bad1: | |
276 | bus_space_unmap(psc->sc_iot, psc->sc_ioh, psc->sc_mapsz); | 275 | bus_space_unmap(psc->sc_iot, psc->sc_ioh, psc->sc_mapsz); | |
277 | bad: /* XXX */ | 276 | bad: /* XXX */ | |
278 | return; | 277 | return; | |
279 | } | 278 | } | |
280 | 279 | |||
281 | static int | 280 | static int |
--- src/sys/dev/pci/if_fxp_pci.c 2009/04/17 15:37:43 1.69
+++ src/sys/dev/pci/if_fxp_pci.c 2009/09/05 14:13:50 1.70
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_fxp_pci.c,v 1.69 2009/04/17 15:37:43 tsutsui Exp $ */ | 1 | /* $NetBSD: if_fxp_pci.c,v 1.70 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * PCI bus front-end for the Intel i82557 fast Ethernet controller | 34 | * PCI bus front-end for the Intel i82557 fast Ethernet controller | |
35 | * driver. Works with Intel Etherexpress Pro 10+, 100B, 100+ cards. | 35 | * driver. Works with Intel Etherexpress Pro 10+, 100B, 100+ cards. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.69 2009/04/17 15:37:43 tsutsui Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.70 2009/09/05 14:13:50 tsutsui Exp $"); | |
40 | 40 | |||
41 | #include "rnd.h" | 41 | #include "rnd.h" | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
44 | #include <sys/systm.h> | 44 | #include <sys/systm.h> | |
45 | #include <sys/mbuf.h> | 45 | #include <sys/mbuf.h> | |
46 | #include <sys/malloc.h> | 46 | #include <sys/malloc.h> | |
47 | #include <sys/kernel.h> | 47 | #include <sys/kernel.h> | |
48 | #include <sys/socket.h> | 48 | #include <sys/socket.h> | |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> | |
50 | #include <sys/errno.h> | 50 | #include <sys/errno.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | 52 | |||
@@ -472,30 +472,30 @@ fxp_pci_attach(device_t parent, device_t | @@ -472,30 +472,30 @@ fxp_pci_attach(device_t parent, device_t | |||
472 | if (intrstr != NULL) | 472 | if (intrstr != NULL) | |
473 | aprint_normal(" at %s", intrstr); | 473 | aprint_normal(" at %s", intrstr); | |
474 | aprint_normal("\n"); | 474 | aprint_normal("\n"); | |
475 | return; | 475 | return; | |
476 | } | 476 | } | |
477 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | 477 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | |
478 | 478 | |||
479 | /* Finish off the attach. */ | 479 | /* Finish off the attach. */ | |
480 | fxp_attach(sc); | 480 | fxp_attach(sc); | |
481 | if (sc->sc_disable != NULL) | 481 | if (sc->sc_disable != NULL) | |
482 | fxp_disable(sc); | 482 | fxp_disable(sc); | |
483 | 483 | |||
484 | /* Add a suspend hook to restore PCI config state */ | 484 | /* Add a suspend hook to restore PCI config state */ | |
485 | if (!pmf_device_register(self, NULL, fxp_pci_resume)) | 485 | if (pmf_device_register(self, NULL, fxp_pci_resume)) | |
486 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
487 | else | |||
488 | pmf_class_network_register(self, &sc->sc_ethercom.ec_if); | 486 | pmf_class_network_register(self, &sc->sc_ethercom.ec_if); | |
487 | else | |||
488 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
489 | } | 489 | } | |
490 | 490 | |||
491 | static int | 491 | static int | |
492 | fxp_pci_enable(struct fxp_softc *sc) | 492 | fxp_pci_enable(struct fxp_softc *sc) | |
493 | { | 493 | { | |
494 | struct fxp_pci_softc *psc = (void *) sc; | 494 | struct fxp_pci_softc *psc = (void *) sc; | |
495 | 495 | |||
496 | #if 0 | 496 | #if 0 | |
497 | printf("%s: going to power state D0\n", device_xname(self)); | 497 | printf("%s: going to power state D0\n", device_xname(self)); | |
498 | #endif | 498 | #endif | |
499 | 499 | |||
500 | /* Bring the device into D0 power state. */ | 500 | /* Bring the device into D0 power state. */ | |
501 | pci_conf_write(psc->psc_pc, psc->psc_tag, | 501 | pci_conf_write(psc->psc_pc, psc->psc_tag, |
--- src/sys/dev/pci/if_gem_pci.c 2009/07/27 18:10:53 1.36
+++ src/sys/dev/pci/if_gem_pci.c 2009/09/05 14:13:50 1.37
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_gem_pci.c,v 1.36 2009/07/27 18:10:53 dyoung Exp $ */ | 1 | /* $NetBSD: if_gem_pci.c,v 1.37 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * | 4 | * | |
5 | * Copyright (C) 2001 Eduardo Horvath. | 5 | * Copyright (C) 2001 Eduardo Horvath. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. | |
29 | * | 29 | * | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * PCI bindings for Apple GMAC, Sun ERI and Sun GEM Ethernet controllers | 33 | * PCI bindings for Apple GMAC, Sun ERI and Sun GEM Ethernet controllers | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: if_gem_pci.c,v 1.36 2009/07/27 18:10:53 dyoung Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: if_gem_pci.c,v 1.37 2009/09/05 14:13:50 tsutsui Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/malloc.h> | 41 | #include <sys/malloc.h> | |
42 | #include <sys/kernel.h> | 42 | #include <sys/kernel.h> | |
43 | #include <sys/socket.h> | 43 | #include <sys/socket.h> | |
44 | #include <sys/errno.h> | 44 | #include <sys/errno.h> | |
45 | #include <sys/device.h> | 45 | #include <sys/device.h> | |
46 | 46 | |||
47 | #include <machine/endian.h> | 47 | #include <machine/endian.h> | |
48 | 48 | |||
49 | #include <uvm/uvm_extern.h> | 49 | #include <uvm/uvm_extern.h> | |
50 | 50 | |||
@@ -389,32 +389,32 @@ gem_pci_attach(device_t parent, device_t | @@ -389,32 +389,32 @@ gem_pci_attach(device_t parent, device_t | |||
389 | #endif /* macppc */ | 389 | #endif /* macppc */ | |
390 | #endif /* __sparc__ */ | 390 | #endif /* __sparc__ */ | |
391 | 391 | |||
392 | if (pci_intr_map(pa, &gsc->gsc_handle) != 0) { | 392 | if (pci_intr_map(pa, &gsc->gsc_handle) != 0) { | |
393 | aprint_error_dev(sc->sc_dev, "unable to map interrupt\n"); | 393 | aprint_error_dev(sc->sc_dev, "unable to map interrupt\n"); | |
394 | return; | 394 | return; | |
395 | } | 395 | } | |
396 | gsc->gsc_pc = pa->pa_pc; | 396 | gsc->gsc_pc = pa->pa_pc; | |
397 | gem_pci_estintr(gsc); | 397 | gem_pci_estintr(gsc); | |
398 | 398 | |||
399 | /* Finish off the attach. */ | 399 | /* Finish off the attach. */ | |
400 | gem_attach(sc, enaddr); | 400 | gem_attach(sc, enaddr); | |
401 | 401 | |||
402 | if (!pmf_device_register1(sc->sc_dev, gem_pci_suspend, gem_pci_resume, | 402 | if (pmf_device_register1(sc->sc_dev, | |
403 | gem_shutdown)) { | 403 | gem_pci_suspend, gem_pci_resume, gem_shutdown)) | |
404 | pmf_class_network_register(sc->sc_dev, &sc->sc_ethercom.ec_if); | |||
405 | else | |||
404 | aprint_error_dev(sc->sc_dev, | 406 | aprint_error_dev(sc->sc_dev, | |
405 | "could not establish power handlers\n"); | 407 | "could not establish power handlers\n"); | |
406 | } else | |||
407 | pmf_class_network_register(sc->sc_dev, &sc->sc_ethercom.ec_if); | |||
408 | } | 408 | } | |
409 | 409 | |||
410 | static bool | 410 | static bool | |
411 | gem_pci_suspend(device_t self PMF_FN_ARGS) | 411 | gem_pci_suspend(device_t self PMF_FN_ARGS) | |
412 | { | 412 | { | |
413 | struct gem_pci_softc *gsc = device_private(self); | 413 | struct gem_pci_softc *gsc = device_private(self); | |
414 | 414 | |||
415 | if (gsc->gsc_ih != NULL) { | 415 | if (gsc->gsc_ih != NULL) { | |
416 | pci_intr_disestablish(gsc->gsc_pc, gsc->gsc_ih); | 416 | pci_intr_disestablish(gsc->gsc_pc, gsc->gsc_ih); | |
417 | gsc->gsc_ih = NULL; | 417 | gsc->gsc_ih = NULL; | |
418 | } | 418 | } | |
419 | 419 | |||
420 | return true; | 420 | return true; |
--- src/sys/dev/pci/if_rtk_pci.c 2009/05/06 09:25:16 1.38
+++ src/sys/dev/pci/if_rtk_pci.c 2009/09/05 14:13:50 1.39
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_rtk_pci.c,v 1.38 2009/05/06 09:25:16 cegger Exp $ */ | 1 | /* $NetBSD: if_rtk_pci.c,v 1.39 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997, 1998 | 4 | * Copyright (c) 1997, 1998 | |
5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | 5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -37,27 +37,27 @@ | @@ -37,27 +37,27 @@ | |||
37 | /* | 37 | /* | |
38 | * Realtek 8129/8139 PCI NIC driver | 38 | * Realtek 8129/8139 PCI NIC driver | |
39 | * | 39 | * | |
40 | * Supports several extremely cheap PCI 10/100 adapters based on | 40 | * Supports several extremely cheap PCI 10/100 adapters based on | |
41 | * the Realtek chipset. Datasheets can be obtained from | 41 | * the Realtek chipset. Datasheets can be obtained from | |
42 | * www.realtek.com.tw. | 42 | * www.realtek.com.tw. | |
43 | * | 43 | * | |
44 | * Written by Bill Paul <wpaul@ctr.columbia.edu> | 44 | * Written by Bill Paul <wpaul@ctr.columbia.edu> | |
45 | * Electrical Engineering Department | 45 | * Electrical Engineering Department | |
46 | * Columbia University, New York City | 46 | * Columbia University, New York City | |
47 | */ | 47 | */ | |
48 | 48 | |||
49 | #include <sys/cdefs.h> | 49 | #include <sys/cdefs.h> | |
50 | __KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.38 2009/05/06 09:25:16 cegger Exp $"); | 50 | __KERNEL_RCSID(0, "$NetBSD: if_rtk_pci.c,v 1.39 2009/09/05 14:13:50 tsutsui Exp $"); | |
51 | 51 | |||
52 | #include <sys/param.h> | 52 | #include <sys/param.h> | |
53 | #include <sys/systm.h> | 53 | #include <sys/systm.h> | |
54 | #include <sys/callout.h> | 54 | #include <sys/callout.h> | |
55 | #include <sys/device.h> | 55 | #include <sys/device.h> | |
56 | #include <sys/sockio.h> | 56 | #include <sys/sockio.h> | |
57 | #include <sys/mbuf.h> | 57 | #include <sys/mbuf.h> | |
58 | #include <sys/malloc.h> | 58 | #include <sys/malloc.h> | |
59 | #include <sys/kernel.h> | 59 | #include <sys/kernel.h> | |
60 | #include <sys/socket.h> | 60 | #include <sys/socket.h> | |
61 | 61 | |||
62 | #include <net/if.h> | 62 | #include <net/if.h> | |
63 | #include <net/if_arp.h> | 63 | #include <net/if_arp.h> | |
@@ -215,20 +215,20 @@ rtk_pci_attach(device_t parent, device_t | @@ -215,20 +215,20 @@ rtk_pci_attach(device_t parent, device_t | |||
215 | aprint_normal(" at %s", intrstr); | 215 | aprint_normal(" at %s", intrstr); | |
216 | aprint_normal("\n"); | 216 | aprint_normal("\n"); | |
217 | return; | 217 | return; | |
218 | } | 218 | } | |
219 | 219 | |||
220 | if (t->rtk_basetype == RTK_8129) | 220 | if (t->rtk_basetype == RTK_8129) | |
221 | sc->sc_quirk |= RTKQ_8129; | 221 | sc->sc_quirk |= RTKQ_8129; | |
222 | 222 | |||
223 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | 223 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | |
224 | 224 | |||
225 | sc->sc_dmat = pa->pa_dmat; | 225 | sc->sc_dmat = pa->pa_dmat; | |
226 | sc->sc_flags |= RTK_ENABLED; | 226 | sc->sc_flags |= RTK_ENABLED; | |
227 | 227 | |||
228 | if (!pmf_device_register(self, NULL, NULL)) | 228 | if (pmf_device_register(self, NULL, NULL)) | |
229 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
230 | else | |||
231 | pmf_class_network_register(self, &sc->ethercom.ec_if); | 229 | pmf_class_network_register(self, &sc->ethercom.ec_if); | |
230 | else | |||
231 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
232 | 232 | |||
233 | rtk_attach(sc); | 233 | rtk_attach(sc); | |
234 | } | 234 | } |
--- src/sys/dev/pci/if_rtw_pci.c 2009/05/06 09:25:16 1.13
+++ src/sys/dev/pci/if_rtw_pci.c 2009/09/05 14:13:50 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_rtw_pci.c,v 1.13 2009/05/06 09:25:16 cegger Exp $ */ | 1 | /* $NetBSD: if_rtw_pci.c,v 1.14 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center; Charles M. Hannum; and David Young. | 9 | * NASA Ames Research Center; Charles M. Hannum; and David Young. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -29,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * PCI bus front-end for the Realtek RTL8180 802.11 MAC/BBP chip. | 34 | * PCI bus front-end for the Realtek RTL8180 802.11 MAC/BBP chip. | |
35 | * | 35 | * | |
36 | * Derived from the ADMtek ADM8211 PCI bus front-end. | 36 | * Derived from the ADMtek ADM8211 PCI bus front-end. | |
37 | * | 37 | * | |
38 | * Derived from the ``Tulip'' PCI bus front-end. | 38 | * Derived from the ``Tulip'' PCI bus front-end. | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
42 | __KERNEL_RCSID(0, "$NetBSD: if_rtw_pci.c,v 1.13 2009/05/06 09:25:16 cegger Exp $"); | 42 | __KERNEL_RCSID(0, "$NetBSD: if_rtw_pci.c,v 1.14 2009/09/05 14:13:50 tsutsui Exp $"); | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/mbuf.h> | 46 | #include <sys/mbuf.h> | |
47 | #include <sys/malloc.h> | 47 | #include <sys/malloc.h> | |
48 | #include <sys/kernel.h> | 48 | #include <sys/kernel.h> | |
49 | #include <sys/socket.h> | 49 | #include <sys/socket.h> | |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> | |
51 | #include <sys/errno.h> | 51 | #include <sys/errno.h> | |
52 | #include <sys/device.h> | 52 | #include <sys/device.h> | |
53 | 53 | |||
54 | #include <machine/endian.h> | 54 | #include <machine/endian.h> | |
55 | 55 | |||
@@ -241,37 +241,35 @@ rtw_pci_attach(device_t parent, device_t | @@ -241,37 +241,35 @@ rtw_pci_attach(device_t parent, device_t | |||
241 | if (intrstr != NULL) | 241 | if (intrstr != NULL) | |
242 | aprint_error(" at %s", intrstr); | 242 | aprint_error(" at %s", intrstr); | |
243 | aprint_error("\n"); | 243 | aprint_error("\n"); | |
244 | return; | 244 | return; | |
245 | } | 245 | } | |
246 | 246 | |||
247 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | 247 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | |
248 | 248 | |||
249 | /* | 249 | /* | |
250 | * Finish off the attach. | 250 | * Finish off the attach. | |
251 | */ | 251 | */ | |
252 | rtw_attach(sc); | 252 | rtw_attach(sc); | |
253 | 253 | |||
254 | if (!pmf_device_register(sc->sc_dev, rtw_pci_suspend, | 254 | if (pmf_device_register(sc->sc_dev, rtw_pci_suspend, rtw_pci_resume)) { | |
255 | rtw_pci_resume)) { | |||
256 | aprint_error_dev(sc->sc_dev, | |||
257 | "couldn't establish power handler\n"); | |||
258 | } else { | |||
259 | pmf_class_network_register(self, &sc->sc_if); | 255 | pmf_class_network_register(self, &sc->sc_if); | |
260 | /* | 256 | /* | |
261 | * Power down the socket. | 257 | * Power down the socket. | |
262 | */ | 258 | */ | |
263 | pmf_device_suspend_self(self); | 259 | pmf_device_suspend_self(self); | |
264 | } | 260 | } else | |
261 | aprint_error_dev(sc->sc_dev, | |||
262 | "couldn't establish power handler\n"); | |||
265 | } | 263 | } | |
266 | 264 | |||
267 | static int | 265 | static int | |
268 | rtw_pci_detach(device_t self, int flags) | 266 | rtw_pci_detach(device_t self, int flags) | |
269 | { | 267 | { | |
270 | struct rtw_pci_softc *psc = device_private(self); | 268 | struct rtw_pci_softc *psc = device_private(self); | |
271 | struct rtw_softc *sc = &psc->psc_rtw; | 269 | struct rtw_softc *sc = &psc->psc_rtw; | |
272 | struct rtw_regs *regs = &sc->sc_regs; | 270 | struct rtw_regs *regs = &sc->sc_regs; | |
273 | int rc; | 271 | int rc; | |
274 | 272 | |||
275 | if ((rc = rtw_detach(sc)) != 0) | 273 | if ((rc = rtw_detach(sc)) != 0) | |
276 | return rc; | 274 | return rc; | |
277 | if (psc->psc_intrcookie != NULL) | 275 | if (psc->psc_intrcookie != NULL) |
--- src/sys/dev/pci/if_wi_pci.c 2009/05/12 08:23:01 1.48
+++ src/sys/dev/pci/if_wi_pci.c 2009/09/05 14:13:50 1.49
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_wi_pci.c,v 1.48 2009/05/12 08:23:01 cegger Exp $ */ | 1 | /* $NetBSD: if_wi_pci.c,v 1.49 2009/09/05 14:13:50 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Hideaki Imaizumi <hiddy@sfc.wide.ad.jp> | 8 | * by Hideaki Imaizumi <hiddy@sfc.wide.ad.jp> | |
9 | * and Ichiro FUKUHARA (ichiro@ichiro.org). | 9 | * and Ichiro FUKUHARA (ichiro@ichiro.org). | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * PCI bus front-end for the Intersil PCI WaveLan. | 34 | * PCI bus front-end for the Intersil PCI WaveLan. | |
35 | * Works with Prism2.5 Mini-PCI wavelan. | 35 | * Works with Prism2.5 Mini-PCI wavelan. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.48 2009/05/12 08:23:01 cegger Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: if_wi_pci.c,v 1.49 2009/09/05 14:13:50 tsutsui Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/mbuf.h> | 43 | #include <sys/mbuf.h> | |
44 | #include <sys/syslog.h> | 44 | #include <sys/syslog.h> | |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> | |
46 | #include <sys/device.h> | 46 | #include <sys/device.h> | |
47 | #include <sys/callout.h> | 47 | #include <sys/callout.h> | |
48 | 48 | |||
49 | #include <net/if.h> | 49 | #include <net/if.h> | |
50 | #include <net/if_ether.h> | 50 | #include <net/if_ether.h> | |
51 | #include <net/if_media.h> | 51 | #include <net/if_media.h> | |
52 | 52 | |||
@@ -363,18 +363,18 @@ wi_pci_attach(device_t parent, device_t | @@ -363,18 +363,18 @@ wi_pci_attach(device_t parent, device_t | |||
363 | } | 363 | } | |
364 | 364 | |||
365 | printf("%s:", device_xname(self)); | 365 | printf("%s:", device_xname(self)); | |
366 | 366 | |||
367 | if (wi_attach(sc, 0) != 0) { | 367 | if (wi_attach(sc, 0) != 0) { | |
368 | aprint_error_dev(self, "failed to attach controller\n"); | 368 | aprint_error_dev(self, "failed to attach controller\n"); | |
369 | pci_intr_disestablish(pa->pa_pc, sc->sc_ih); | 369 | pci_intr_disestablish(pa->pa_pc, sc->sc_ih); | |
370 | return; | 370 | return; | |
371 | } | 371 | } | |
372 | 372 | |||
373 | if (!wpp->wpp_chip) | 373 | if (!wpp->wpp_chip) | |
374 | sc->sc_reset = wi_pci_reset; | 374 | sc->sc_reset = wi_pci_reset; | |
375 | 375 | |||
376 | if (!pmf_device_register(self, NULL, NULL)) | 376 | if (pmf_device_register(self, NULL, NULL)) | |
377 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
378 | else | |||
379 | pmf_class_network_register(self, &sc->sc_if); | 377 | pmf_class_network_register(self, &sc->sc_if); | |
378 | else | |||
379 | aprint_error_dev(self, "couldn't establish power handler\n"); | |||
380 | } | 380 | } |