Deleted Added
full compact
if_wb.c (113545) if_wb.c (113609)
1/*
2 * Copyright (c) 1997, 1998
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

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

77 * Note: the author of the Linux driver for the Winbond chip alludes
78 * to some sort of flaw in the chip's design that seems to mandate some
79 * drastic workaround which signigicantly impairs transmit performance.
80 * I have no idea what he's on about: transmit performance with all
81 * three of my test boards seems fine.
82 */
83
84#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997, 1998
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

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

77 * Note: the author of the Linux driver for the Winbond chip alludes
78 * to some sort of flaw in the chip's design that seems to mandate some
79 * drastic workaround which signigicantly impairs transmit performance.
80 * I have no idea what he's on about: transmit performance with all
81 * three of my test boards seems fine.
82 */
83
84#include <sys/cdefs.h>
85__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 113545 2003-04-16 03:16:57Z mdodd $");
85__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 113609 2003-04-17 20:32:06Z njl $");
86
87#include "opt_bdg.h"
88
89#include <sys/param.h>
90#include <sys/systm.h>
91#include <sys/sockio.h>
92#include <sys/mbuf.h>
93#include <sys/malloc.h>

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

936 goto fail;
937 }
938
939 /*
940 * Call MI attach routine.
941 */
942 ether_ifattach(ifp, eaddr);
943
86
87#include "opt_bdg.h"
88
89#include <sys/param.h>
90#include <sys/systm.h>
91#include <sys/sockio.h>
92#include <sys/mbuf.h>
93#include <sys/malloc.h>

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

936 goto fail;
937 }
938
939 /*
940 * Call MI attach routine.
941 */
942 ether_ifattach(ifp, eaddr);
943
944 /* Hook interrupt last to avoid having to lock softc */
944 error = bus_setup_intr(dev, sc->wb_irq, INTR_TYPE_NET,
945 wb_intr, sc, &sc->wb_intrhand);
946
947 if (error) {
948 printf("wb%d: couldn't set up irq\n", unit);
945 error = bus_setup_intr(dev, sc->wb_irq, INTR_TYPE_NET,
946 wb_intr, sc, &sc->wb_intrhand);
947
948 if (error) {
949 printf("wb%d: couldn't set up irq\n", unit);
950 ether_ifdetach(ifp);
949 goto fail;
950 }
951
952fail:
953 if (error)
954 wb_detach(dev);
955
956 return(error);
957}
958
951 goto fail;
952 }
953
954fail:
955 if (error)
956 wb_detach(dev);
957
958 return(error);
959}
960
961/*
962 * Shutdown hardware and free up resources. This can be called any
963 * time after the mutex has been initialized. It is called in both
964 * the error case in attach and the normal detach case so it needs
965 * to be careful about only freeing resources that have actually been
966 * allocated.
967 */
959static int
960wb_detach(dev)
961 device_t dev;
962{
963 struct wb_softc *sc;
964 struct ifnet *ifp;
965
966 sc = device_get_softc(dev);
967 KASSERT(mtx_initialized(&sc->wb_mtx), ("wb mutex not initialized"));
968 WB_LOCK(sc);
969 ifp = &sc->arpcom.ac_if;
970
968static int
969wb_detach(dev)
970 device_t dev;
971{
972 struct wb_softc *sc;
973 struct ifnet *ifp;
974
975 sc = device_get_softc(dev);
976 KASSERT(mtx_initialized(&sc->wb_mtx), ("wb mutex not initialized"));
977 WB_LOCK(sc);
978 ifp = &sc->arpcom.ac_if;
979
971 /* Delete any miibus and phy devices attached to this interface */
980 /*
981 * Delete any miibus and phy devices attached to this interface.
982 * This should only be done if attach succeeded.
983 */
972 if (device_is_alive(dev)) {
984 if (device_is_alive(dev)) {
973 if (bus_child_present(dev))
974 wb_stop(sc);
985 wb_stop(sc);
975 ether_ifdetach(ifp);
986 ether_ifdetach(ifp);
976 device_delete_child(dev, sc->wb_miibus);
977 bus_generic_detach(dev);
978 }
987 }
988 if (sc->wb_miibus)
989 device_delete_child(dev, sc->wb_miibus);
990 bus_generic_detach(dev);
979
980 if (sc->wb_intrhand)
981 bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand);
982 if (sc->wb_irq)
983 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->wb_irq);
984 if (sc->wb_res)
985 bus_release_resource(dev, WB_RES, WB_RID, sc->wb_res);
986

--- 893 unchanged lines hidden ---
991
992 if (sc->wb_intrhand)
993 bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand);
994 if (sc->wb_irq)
995 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->wb_irq);
996 if (sc->wb_res)
997 bus_release_resource(dev, WB_RES, WB_RID, sc->wb_res);
998

--- 893 unchanged lines hidden ---