if_rl.c (113545) | if_rl.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 --- 116 unchanged lines hidden (view full) --- 125 * can hang the bus. I'm inclined to blame this on crummy design/construction 126 * on the part of RealTek. Memory mapped mode does appear to work on 127 * uniprocessor systems though. 128 */ 129#define RL_USEIOSPACE 130 131#include <pci/if_rlreg.h> 132 | 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 --- 116 unchanged lines hidden (view full) --- 125 * can hang the bus. I'm inclined to blame this on crummy design/construction 126 * on the part of RealTek. Memory mapped mode does appear to work on 127 * uniprocessor systems though. 128 */ 129#define RL_USEIOSPACE 130 131#include <pci/if_rlreg.h> 132 |
133__FBSDID("$FreeBSD: head/sys/pci/if_rl.c 113545 2003-04-16 03:16:57Z mdodd $"); | 133__FBSDID("$FreeBSD: head/sys/pci/if_rl.c 113609 2003-04-17 20:32:06Z njl $"); |
134 135/* 136 * Various supported device vendors/types and their names. 137 */ 138static struct rl_type rl_devs[] = { 139 { RT_VENDORID, RT_DEVICEID_8129, 140 "RealTek 8129 10/100BaseTX" }, 141 { RT_VENDORID, RT_DEVICEID_8139, --- 917 unchanged lines hidden (view full) --- 1059 1060 callout_handle_init(&sc->rl_stat_ch); 1061 1062 /* 1063 * Call MI attach routine. 1064 */ 1065 ether_ifattach(ifp, eaddr); 1066 | 134 135/* 136 * Various supported device vendors/types and their names. 137 */ 138static struct rl_type rl_devs[] = { 139 { RT_VENDORID, RT_DEVICEID_8129, 140 "RealTek 8129 10/100BaseTX" }, 141 { RT_VENDORID, RT_DEVICEID_8139, --- 917 unchanged lines hidden (view full) --- 1059 1060 callout_handle_init(&sc->rl_stat_ch); 1061 1062 /* 1063 * Call MI attach routine. 1064 */ 1065 ether_ifattach(ifp, eaddr); 1066 |
1067 /* Hook interrupt last to avoid having to lock softc */ |
|
1067 error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET, 1068 rl_intr, sc, &sc->rl_intrhand); 1069 1070 if (error) { 1071 printf("rl%d: couldn't set up irq\n", unit); | 1068 error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET, 1069 rl_intr, sc, &sc->rl_intrhand); 1070 1071 if (error) { 1072 printf("rl%d: couldn't set up irq\n", unit); |
1073 ether_ifdetach(ifp); |
|
1072 goto fail; 1073 } 1074 1075fail: 1076 if (error) 1077 rl_detach(dev); 1078 1079 return (error); 1080} 1081 | 1074 goto fail; 1075 } 1076 1077fail: 1078 if (error) 1079 rl_detach(dev); 1080 1081 return (error); 1082} 1083 |
1084/* 1085 * Shutdown hardware and free up resources. This can be called any 1086 * time after the mutex has been initialized. It is called in both 1087 * the error case in attach and the normal detach case so it needs 1088 * to be careful about only freeing resources that have actually been 1089 * allocated. 1090 */ |
|
1082static int 1083rl_detach(dev) 1084 device_t dev; 1085{ 1086 struct rl_softc *sc; 1087 struct ifnet *ifp; 1088 1089 sc = device_get_softc(dev); 1090 KASSERT(mtx_initialized(&sc->rl_mtx), ("rl mutex not initialized")); 1091 RL_LOCK(sc); 1092 ifp = &sc->arpcom.ac_if; 1093 | 1091static int 1092rl_detach(dev) 1093 device_t dev; 1094{ 1095 struct rl_softc *sc; 1096 struct ifnet *ifp; 1097 1098 sc = device_get_softc(dev); 1099 KASSERT(mtx_initialized(&sc->rl_mtx), ("rl mutex not initialized")); 1100 RL_LOCK(sc); 1101 ifp = &sc->arpcom.ac_if; 1102 |
1103 /* These should only be active if attach succeeded */ |
|
1094 if (device_is_alive(dev)) { | 1104 if (device_is_alive(dev)) { |
1095 if (bus_child_present(dev)) 1096 rl_stop(sc); | 1105 rl_stop(sc); |
1097 ether_ifdetach(ifp); | 1106 ether_ifdetach(ifp); |
1098 device_delete_child(dev, sc->rl_miibus); 1099 bus_generic_detach(dev); | |
1100 } | 1107 } |
1108 if (sc->rl_miibus) 1109 device_delete_child(dev, sc->rl_miibus); 1110 bus_generic_detach(dev); |
|
1101 1102 if (sc->rl_intrhand) 1103 bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand); 1104 if (sc->rl_irq) 1105 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1106 if (sc->rl_res) 1107 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); 1108 --- 805 unchanged lines hidden --- | 1111 1112 if (sc->rl_intrhand) 1113 bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand); 1114 if (sc->rl_irq) 1115 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq); 1116 if (sc->rl_res) 1117 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res); 1118 --- 805 unchanged lines hidden --- |