if_vr.c (113545) | if_vr.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 --- 44 unchanged lines hidden (view full) --- 53 * The Rhine has a serious flaw in its transmit DMA mechanism: 54 * transmit buffers must be longword aligned. Unfortunately, 55 * FreeBSD doesn't guarantee that mbufs will be filled in starting 56 * at longword boundaries, so we have to do a buffer copy before 57 * transmission. 58 */ 59 60#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 --- 44 unchanged lines hidden (view full) --- 53 * The Rhine has a serious flaw in its transmit DMA mechanism: 54 * transmit buffers must be longword aligned. Unfortunately, 55 * FreeBSD doesn't guarantee that mbufs will be filled in starting 56 * at longword boundaries, so we have to do a buffer copy before 57 * transmission. 58 */ 59 60#include <sys/cdefs.h> |
61__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 113545 2003-04-16 03:16:57Z mdodd $"); | 61__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 113609 2003-04-17 20:32:06Z njl $"); |
62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/sockio.h> 66#include <sys/mbuf.h> 67#include <sys/malloc.h> 68#include <sys/kernel.h> 69#include <sys/socket.h> --- 803 unchanged lines hidden (view full) --- 873 874 callout_handle_init(&sc->vr_stat_ch); 875 876 /* 877 * Call MI attach routine. 878 */ 879 ether_ifattach(ifp, eaddr); 880 | 62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/sockio.h> 66#include <sys/mbuf.h> 67#include <sys/malloc.h> 68#include <sys/kernel.h> 69#include <sys/socket.h> --- 803 unchanged lines hidden (view full) --- 873 874 callout_handle_init(&sc->vr_stat_ch); 875 876 /* 877 * Call MI attach routine. 878 */ 879 ether_ifattach(ifp, eaddr); 880 |
881 /* Hook interrupt last to avoid having to lock softc */ |
|
881 error = bus_setup_intr(dev, sc->vr_irq, INTR_TYPE_NET, 882 vr_intr, sc, &sc->vr_intrhand); 883 884 if (error) { 885 printf("vr%d: couldn't set up irq\n", unit); | 882 error = bus_setup_intr(dev, sc->vr_irq, INTR_TYPE_NET, 883 vr_intr, sc, &sc->vr_intrhand); 884 885 if (error) { 886 printf("vr%d: couldn't set up irq\n", unit); |
887 ether_ifdetach(ifp); |
|
886 goto fail; 887 } 888 889fail: 890 if (error) 891 vr_detach(dev); 892 893 return(error); 894} 895 | 888 goto fail; 889 } 890 891fail: 892 if (error) 893 vr_detach(dev); 894 895 return(error); 896} 897 |
898/* 899 * Shutdown hardware and free up resources. This can be called any 900 * time after the mutex has been initialized. It is called in both 901 * the error case in attach and the normal detach case so it needs 902 * to be careful about only freeing resources that have actually been 903 * allocated. 904 */ |
|
896static int 897vr_detach(dev) 898 device_t dev; 899{ 900 struct vr_softc *sc; 901 struct ifnet *ifp; 902 903 sc = device_get_softc(dev); 904 KASSERT(mtx_initialized(&sc->vr_mtx), ("vr mutex not initialized")); 905 VR_LOCK(sc); 906 ifp = &sc->arpcom.ac_if; 907 | 905static int 906vr_detach(dev) 907 device_t dev; 908{ 909 struct vr_softc *sc; 910 struct ifnet *ifp; 911 912 sc = device_get_softc(dev); 913 KASSERT(mtx_initialized(&sc->vr_mtx), ("vr mutex not initialized")); 914 VR_LOCK(sc); 915 ifp = &sc->arpcom.ac_if; 916 |
917 /* These should only be active if attach succeeded */ |
|
908 if (device_is_alive(dev)) { | 918 if (device_is_alive(dev)) { |
909 if (bus_child_present(dev)) 910 vr_stop(sc); | 919 vr_stop(sc); |
911 ether_ifdetach(ifp); | 920 ether_ifdetach(ifp); |
912 device_delete_child(dev, sc->vr_miibus); 913 bus_generic_detach(dev); | |
914 } | 921 } |
922 if (sc->vr_miibus) 923 device_delete_child(dev, sc->vr_miibus); 924 bus_generic_detach(dev); |
|
915 916 if (sc->vr_intrhand) 917 bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand); 918 if (sc->vr_irq) 919 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq); 920 if (sc->vr_res) 921 bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res); 922 --- 873 unchanged lines hidden --- | 925 926 if (sc->vr_intrhand) 927 bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand); 928 if (sc->vr_irq) 929 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq); 930 if (sc->vr_res) 931 bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res); 932 --- 873 unchanged lines hidden --- |