Deleted Added
full compact
if_ral_pci.c (166901) if_ral_pci.c (170530)
1/* $FreeBSD: head/sys/dev/ral/if_ral_pci.c 166901 2007-02-23 12:19:07Z piso $ */
1/* $FreeBSD: head/sys/dev/ral/if_ral_pci.c 170530 2007-06-11 03:36:55Z sam $ */
2
3/*-
4 * Copyright (c) 2005, 2006
5 * Damien Bergamini <damien.bergamini@free.fr>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/cdefs.h>
2
3/*-
4 * Copyright (c) 2005, 2006
5 * Damien Bergamini <damien.bergamini@free.fr>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/cdefs.h>
21__FBSDID("$FreeBSD: head/sys/dev/ral/if_ral_pci.c 166901 2007-02-23 12:19:07Z piso $");
21__FBSDID("$FreeBSD: head/sys/dev/ral/if_ral_pci.c 170530 2007-06-11 03:36:55Z sam $");
22
23/*
24 * PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
25 */
26
27#include <sys/param.h>
28#include <sys/sysctl.h>
29#include <sys/sockio.h>

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

82 void (*shutdown)(void *);
83 void (*suspend)(void *);
84 void (*resume)(void *);
85 void (*intr)(void *);
86
87} ral_rt2560_opns = {
88 rt2560_attach,
89 rt2560_detach,
22
23/*
24 * PCI/Cardbus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
25 */
26
27#include <sys/param.h>
28#include <sys/sysctl.h>
29#include <sys/sockio.h>

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

82 void (*shutdown)(void *);
83 void (*suspend)(void *);
84 void (*resume)(void *);
85 void (*intr)(void *);
86
87} ral_rt2560_opns = {
88 rt2560_attach,
89 rt2560_detach,
90 rt2560_shutdown,
91 rt2560_suspend,
90 rt2560_stop,
91 rt2560_stop,
92 rt2560_resume,
93 rt2560_intr
94
95}, ral_rt2661_opns = {
96 rt2661_attach,
97 rt2661_detach,
98 rt2661_shutdown,
99 rt2661_suspend,

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

187 RF_ACTIVE);
188 if (psc->mem == NULL) {
189 device_printf(dev, "could not allocate memory resource\n");
190 return ENXIO;
191 }
192
193 sc->sc_st = rman_get_bustag(psc->mem);
194 sc->sc_sh = rman_get_bushandle(psc->mem);
92 rt2560_resume,
93 rt2560_intr
94
95}, ral_rt2661_opns = {
96 rt2661_attach,
97 rt2661_detach,
98 rt2661_shutdown,
99 rt2661_suspend,

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

187 RF_ACTIVE);
188 if (psc->mem == NULL) {
189 device_printf(dev, "could not allocate memory resource\n");
190 return ENXIO;
191 }
192
193 sc->sc_st = rman_get_bustag(psc->mem);
194 sc->sc_sh = rman_get_bushandle(psc->mem);
195
195 sc->sc_invalid = 1;
196
196 psc->irq_rid = 0;
197 psc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &psc->irq_rid,
198 RF_ACTIVE | RF_SHAREABLE);
199 if (psc->irq == NULL) {
200 device_printf(dev, "could not allocate interrupt resource\n");
201 return ENXIO;
202 }
203

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

209 * Hook our interrupt after all initialization is complete.
210 */
211 error = bus_setup_intr(dev, psc->irq, INTR_TYPE_NET | INTR_MPSAFE,
212 NULL, psc->sc_opns->intr, psc, &psc->sc_ih);
213 if (error != 0) {
214 device_printf(dev, "could not set up interrupt\n");
215 return error;
216 }
197 psc->irq_rid = 0;
198 psc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &psc->irq_rid,
199 RF_ACTIVE | RF_SHAREABLE);
200 if (psc->irq == NULL) {
201 device_printf(dev, "could not allocate interrupt resource\n");
202 return ENXIO;
203 }
204

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

210 * Hook our interrupt after all initialization is complete.
211 */
212 error = bus_setup_intr(dev, psc->irq, INTR_TYPE_NET | INTR_MPSAFE,
213 NULL, psc->sc_opns->intr, psc, &psc->sc_ih);
214 if (error != 0) {
215 device_printf(dev, "could not set up interrupt\n");
216 return error;
217 }
217
218 sc->sc_invalid = 0;
219
218 return 0;
219}
220
221static int
222ral_pci_detach(device_t dev)
223{
224 struct ral_pci_softc *psc = device_get_softc(dev);
220 return 0;
221}
222
223static int
224ral_pci_detach(device_t dev)
225{
226 struct ral_pci_softc *psc = device_get_softc(dev);
225
227 struct rt2560_softc *sc = &psc->u.sc_rt2560;
228
229 /* check if device was removed */
230 sc->sc_invalid = !bus_child_present(dev);
231
226 (*psc->sc_opns->detach)(psc);
227
228 bus_generic_detach(dev);
229 bus_teardown_intr(dev, psc->irq, psc->sc_ih);
230 bus_release_resource(dev, SYS_RES_IRQ, psc->irq_rid, psc->irq);
231
232 bus_release_resource(dev, SYS_RES_MEMORY, psc->mem_rid, psc->mem);
233

--- 32 unchanged lines hidden ---
232 (*psc->sc_opns->detach)(psc);
233
234 bus_generic_detach(dev);
235 bus_teardown_intr(dev, psc->irq, psc->sc_ih);
236 bus_release_resource(dev, SYS_RES_IRQ, psc->irq_rid, psc->irq);
237
238 bus_release_resource(dev, SYS_RES_MEMORY, psc->mem_rid, psc->mem);
239

--- 32 unchanged lines hidden ---