if_sf.c (113545) | if_sf.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 --- 64 unchanged lines hidden (view full) --- 73 * PCI memory mapped mode, the entire register space can be accessed 74 * directly. However in I/O space mode, only 256 bytes are directly 75 * mapped into PCI I/O space. The other registers can be accessed 76 * indirectly using the SF_INDIRECTIO_ADDR and SF_INDIRECTIO_DATA 77 * registers inside the 256-byte I/O window. 78 */ 79 80#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 --- 64 unchanged lines hidden (view full) --- 73 * PCI memory mapped mode, the entire register space can be accessed 74 * directly. However in I/O space mode, only 256 bytes are directly 75 * mapped into PCI I/O space. The other registers can be accessed 76 * indirectly using the SF_INDIRECTIO_ADDR and SF_INDIRECTIO_DATA 77 * registers inside the 256-byte I/O window. 78 */ 79 80#include <sys/cdefs.h> |
81__FBSDID("$FreeBSD: head/sys/dev/sf/if_sf.c 113545 2003-04-16 03:16:57Z mdodd $"); | 81__FBSDID("$FreeBSD: head/sys/dev/sf/if_sf.c 113609 2003-04-17 20:32:06Z njl $"); |
82 83#include <sys/param.h> 84#include <sys/systm.h> 85#include <sys/sockio.h> 86#include <sys/mbuf.h> 87#include <sys/malloc.h> 88#include <sys/kernel.h> 89#include <sys/socket.h> --- 697 unchanged lines hidden (view full) --- 787 ifp->if_baudrate = 10000000; 788 ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; 789 790 /* 791 * Call MI attach routine. 792 */ 793 ether_ifattach(ifp, sc->arpcom.ac_enaddr); 794 | 82 83#include <sys/param.h> 84#include <sys/systm.h> 85#include <sys/sockio.h> 86#include <sys/mbuf.h> 87#include <sys/malloc.h> 88#include <sys/kernel.h> 89#include <sys/socket.h> --- 697 unchanged lines hidden (view full) --- 787 ifp->if_baudrate = 10000000; 788 ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; 789 790 /* 791 * Call MI attach routine. 792 */ 793 ether_ifattach(ifp, sc->arpcom.ac_enaddr); 794 |
795 /* Hook interrupt last to avoid having to lock softc */ |
|
795 error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET, 796 sf_intr, sc, &sc->sf_intrhand); 797 798 if (error) { 799 printf("sf%d: couldn't set up irq\n", unit); | 796 error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET, 797 sf_intr, sc, &sc->sf_intrhand); 798 799 if (error) { 800 printf("sf%d: couldn't set up irq\n", unit); |
801 ether_ifdetach(ifp); |
|
800 goto fail; 801 } 802 803fail: 804 if (error) 805 sf_detach(dev); 806 807 return(error); 808} 809 | 802 goto fail; 803 } 804 805fail: 806 if (error) 807 sf_detach(dev); 808 809 return(error); 810} 811 |
812/* 813 * Shutdown hardware and free up resources. This can be called any 814 * time after the mutex has been initialized. It is called in both 815 * the error case in attach and the normal detach case so it needs 816 * to be careful about only freeing resources that have actually been 817 * allocated. 818 */ |
|
810static int 811sf_detach(dev) 812 device_t dev; 813{ 814 struct sf_softc *sc; 815 struct ifnet *ifp; 816 817 sc = device_get_softc(dev); 818 KASSERT(mtx_initialized(&sc->sf_mtx), ("sf mutex not initialized")); 819 SF_LOCK(sc); 820 ifp = &sc->arpcom.ac_if; 821 | 819static int 820sf_detach(dev) 821 device_t dev; 822{ 823 struct sf_softc *sc; 824 struct ifnet *ifp; 825 826 sc = device_get_softc(dev); 827 KASSERT(mtx_initialized(&sc->sf_mtx), ("sf mutex not initialized")); 828 SF_LOCK(sc); 829 ifp = &sc->arpcom.ac_if; 830 |
831 /* These should only be active if attach succeeded */ |
|
822 if (device_is_alive(dev)) { | 832 if (device_is_alive(dev)) { |
823 if (bus_child_present(dev)) 824 sf_stop(sc); | 833 sf_stop(sc); |
825 ether_ifdetach(ifp); | 834 ether_ifdetach(ifp); |
826 device_delete_child(dev, sc->sf_miibus); 827 bus_generic_detach(dev); | |
828 } | 835 } |
836 if (sc->sf_miibus) 837 device_delete_child(dev, sc->sf_miibus); 838 bus_generic_detach(dev); |
|
829 830 if (sc->sf_intrhand) 831 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand); 832 if (sc->sf_irq) 833 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq); 834 if (sc->sf_res) 835 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res); 836 --- 697 unchanged lines hidden --- | 839 840 if (sc->sf_intrhand) 841 bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand); 842 if (sc->sf_irq) 843 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq); 844 if (sc->sf_res) 845 bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res); 846 --- 697 unchanged lines hidden --- |