Deleted Added
full compact
if_ste.c (113545) if_ste.c (113609)
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

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
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
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

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
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
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/pci/if_ste.c 113545 2003-04-16 03:16:57Z mdodd $");
34__FBSDID("$FreeBSD: head/sys/pci/if_ste.c 113609 2003-04-17 20:32:06Z njl $");
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/sockio.h>
39#include <sys/mbuf.h>
40#include <sys/malloc.h>
41#include <sys/kernel.h>
42#include <sys/socket.h>

--- 1004 unchanged lines hidden (view full) ---

1047 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
1048
1049 /*
1050 * Tell the upper layer(s) we support long frames.
1051 */
1052 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1053 ifp->if_capabilities |= IFCAP_VLAN_MTU;
1054
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/sockio.h>
39#include <sys/mbuf.h>
40#include <sys/malloc.h>
41#include <sys/kernel.h>
42#include <sys/socket.h>

--- 1004 unchanged lines hidden (view full) ---

1047 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
1048
1049 /*
1050 * Tell the upper layer(s) we support long frames.
1051 */
1052 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1053 ifp->if_capabilities |= IFCAP_VLAN_MTU;
1054
1055 /* Hook interrupt last to avoid having to lock softc */
1055 error = bus_setup_intr(dev, sc->ste_irq, INTR_TYPE_NET,
1056 ste_intr, sc, &sc->ste_intrhand);
1057
1058 if (error) {
1059 printf("ste%d: couldn't set up irq\n", unit);
1056 error = bus_setup_intr(dev, sc->ste_irq, INTR_TYPE_NET,
1057 ste_intr, sc, &sc->ste_intrhand);
1058
1059 if (error) {
1060 printf("ste%d: couldn't set up irq\n", unit);
1061 ether_ifdetach(ifp);
1060 goto fail;
1061 }
1062
1063fail:
1064 if (error)
1065 ste_detach(dev);
1066
1067 return(error);
1068}
1069
1062 goto fail;
1063 }
1064
1065fail:
1066 if (error)
1067 ste_detach(dev);
1068
1069 return(error);
1070}
1071
1072/*
1073 * Shutdown hardware and free up resources. This can be called any
1074 * time after the mutex has been initialized. It is called in both
1075 * the error case in attach and the normal detach case so it needs
1076 * to be careful about only freeing resources that have actually been
1077 * allocated.
1078 */
1070static int
1071ste_detach(dev)
1072 device_t dev;
1073{
1074 struct ste_softc *sc;
1075 struct ifnet *ifp;
1076
1077 sc = device_get_softc(dev);
1078 KASSERT(mtx_initialized(&sc->ste_mtx), ("ste mutex not initialized"));
1079 STE_LOCK(sc);
1080 ifp = &sc->arpcom.ac_if;
1081
1079static int
1080ste_detach(dev)
1081 device_t dev;
1082{
1083 struct ste_softc *sc;
1084 struct ifnet *ifp;
1085
1086 sc = device_get_softc(dev);
1087 KASSERT(mtx_initialized(&sc->ste_mtx), ("ste mutex not initialized"));
1088 STE_LOCK(sc);
1089 ifp = &sc->arpcom.ac_if;
1090
1091 /* These should only be active if attach succeeded */
1082 if (device_is_alive(dev)) {
1092 if (device_is_alive(dev)) {
1083 if (bus_child_present(dev))
1084 ste_stop(sc);
1093 ste_stop(sc);
1085 ether_ifdetach(ifp);
1094 ether_ifdetach(ifp);
1086 device_delete_child(dev, sc->ste_miibus);
1087 bus_generic_detach(dev);
1088 }
1095 }
1096 if (sc->ste_miibus)
1097 device_delete_child(dev, sc->ste_miibus);
1098 bus_generic_detach(dev);
1089
1090 if (sc->ste_intrhand)
1091 bus_teardown_intr(dev, sc->ste_irq, sc->ste_intrhand);
1092 if (sc->ste_irq)
1093 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ste_irq);
1094 if (sc->ste_res)
1095 bus_release_resource(dev, STE_RES, STE_RID, sc->ste_res);
1096

--- 544 unchanged lines hidden ---
1099
1100 if (sc->ste_intrhand)
1101 bus_teardown_intr(dev, sc->ste_irq, sc->ste_intrhand);
1102 if (sc->ste_irq)
1103 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ste_irq);
1104 if (sc->ste_res)
1105 bus_release_resource(dev, STE_RES, STE_RID, sc->ste_res);
1106

--- 544 unchanged lines hidden ---