| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tulip.c,v 1.180 2012/02/02 19:43:03 tls Exp $ */ | | 1 | /* $NetBSD: tulip.c,v 1.180.8.1 2015/03/05 22:22:53 riz 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; and by Charles M. Hannum. | | 9 | * NASA Ames Research Center; and by Charles M. Hannum. |
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 | * Device driver for the Digital Semiconductor ``Tulip'' (21x4x) | | 34 | * Device driver for the Digital Semiconductor ``Tulip'' (21x4x) |
35 | * Ethernet controller family, and a variety of clone chips. | | 35 | * Ethernet controller family, and a variety of clone chips. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.180 2012/02/02 19:43:03 tls Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.180.8.1 2015/03/05 22:22:53 riz Exp $"); |
40 | | | 40 | |
41 | | | 41 | |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | #include <sys/callout.h> | | 44 | #include <sys/callout.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 | |
| @@ -585,37 +585,42 @@ tlp_activate(device_t self, enum devact | | | @@ -585,37 +585,42 @@ tlp_activate(device_t self, enum devact |
585 | | | 585 | |
586 | /* | | 586 | /* |
587 | * tlp_detach: | | 587 | * tlp_detach: |
588 | * | | 588 | * |
589 | * Detach a Tulip interface. | | 589 | * Detach a Tulip interface. |
590 | */ | | 590 | */ |
591 | int | | 591 | int |
592 | tlp_detach(struct tulip_softc *sc) | | 592 | tlp_detach(struct tulip_softc *sc) |
593 | { | | 593 | { |
594 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 594 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
595 | struct tulip_rxsoft *rxs; | | 595 | struct tulip_rxsoft *rxs; |
596 | struct tulip_txsoft *txs; | | 596 | struct tulip_txsoft *txs; |
597 | device_t self = sc->sc_dev; | | 597 | device_t self = sc->sc_dev; |
598 | int i; | | 598 | int i, s; |
599 | | | 599 | |
600 | /* | | 600 | /* |
601 | * Succeed now if there isn't any work to do. | | 601 | * Succeed now if there isn't any work to do. |
602 | */ | | 602 | */ |
603 | if ((sc->sc_flags & TULIPF_ATTACHED) == 0) | | 603 | if ((sc->sc_flags & TULIPF_ATTACHED) == 0) |
604 | return (0); | | 604 | return (0); |
605 | | | 605 | |
606 | /* Unhook our tick handler. */ | | 606 | s = splnet(); |
607 | if (sc->sc_tick) | | 607 | /* Stop the interface. Callouts are stopped in it. */ |
608 | callout_stop(&sc->sc_tick_callout); | | 608 | tlp_stop(ifp, 1); |
| | | 609 | splx(s); |
| | | 610 | |
| | | 611 | /* Destroy our callouts. */ |
| | | 612 | callout_destroy(&sc->sc_nway_callout); |
| | | 613 | callout_destroy(&sc->sc_tick_callout); |
609 | | | 614 | |
610 | if (sc->sc_flags & TULIPF_HAS_MII) { | | 615 | if (sc->sc_flags & TULIPF_HAS_MII) { |
611 | /* Detach all PHYs */ | | 616 | /* Detach all PHYs */ |
612 | mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); | | 617 | mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); |
613 | } | | 618 | } |
614 | | | 619 | |
615 | /* Delete all remaining media. */ | | 620 | /* Delete all remaining media. */ |
616 | ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); | | 621 | ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); |
617 | | | 622 | |
618 | rnd_detach_source(&sc->sc_rnd_source); | | 623 | rnd_detach_source(&sc->sc_rnd_source); |
619 | | | 624 | |
620 | ether_ifdetach(ifp); | | 625 | ether_ifdetach(ifp); |
621 | if_detach(ifp); | | 626 | if_detach(ifp); |