This is *always* compiled with #define rbus 1, so get rid of the

conditional compilation.

Simplify interrupt (dis)establishment by two source transformations:

-       cardbus_intr_disestablish(cc, cf, ih);
+       Cardbus_intr_disestablish(ct, ih);

-       ih = cardbus_intr_establish(cc, cf, ...);
+       ih = Cardbus_intr_establish(ct, ...);

Tested by Klaus Heinz.
This commit is contained in:
dyoung 2010-03-10 00:21:10 +00:00
parent 5374e24fd8
commit dc1ff0bc8e
3 changed files with 15 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ehci_cardbus.c,v 1.27 2010/02/26 00:57:01 dyoung Exp $ */
/* $NetBSD: ehci_cardbus.c,v 1.28 2010/03/10 00:21:10 dyoung Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ehci_cardbus.c,v 1.27 2010/02/26 00:57:01 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ehci_cardbus.c,v 1.28 2010/03/10 00:21:10 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -153,11 +153,6 @@ ehci_cardbus_attach(device_t parent, device_t self, void *aux)
sc->sc_ct = ct;
sc->sc.sc_bus.dmatag = ca->ca_dmat;
#if rbus
#else
XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
#endif
/* Enable the device. */
csr = Cardbus_conf_read(ct, ca->ca_tag, PCI_COMMAND_STATUS_REG);
Cardbus_conf_write(ct, ca->ca_tag, PCI_COMMAND_STATUS_REG,
@ -169,7 +164,7 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
DPRINTF(("%s: offs=%d\n", devname, sc->sc.sc_offs));
EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
sc->sc_ih = cardbus_intr_establish(cc, cf, ca->ca_intrline,
sc->sc_ih = Cardbus_intr_establish(ct, ca->ca_intrline,
IPL_USB, ehci_intr, sc);
if (sc->sc_ih == NULL) {
printf("%s: couldn't establish interrupt\n", devname);
@ -206,7 +201,7 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
printf("%s: init failed, error=%d\n", devname, r);
/* Avoid spurious interrupts. */
cardbus_intr_disestablish(sc->sc_cc, sc->sc_cf, sc->sc_ih);
Cardbus_intr_disestablish(ct, sc->sc_ih);
sc->sc_ih = NULL;
return;
@ -231,7 +226,7 @@ ehci_cardbus_detach(device_t self, int flags)
if (rv)
return (rv);
if (sc->sc_ih != NULL) {
cardbus_intr_disestablish(sc->sc_cc, sc->sc_cf, sc->sc_ih);
Cardbus_intr_disestablish(ct, sc->sc_ih);
sc->sc_ih = NULL;
}
if (sc->sc.sc_size) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tlp_cardbus.c,v 1.66 2010/02/26 00:57:02 dyoung Exp $ */
/* $NetBSD: if_tlp_cardbus.c,v 1.67 2010/03/10 00:21:10 dyoung Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.66 2010/02/26 00:57:02 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tlp_cardbus.c,v 1.67 2010/03/10 00:21:10 dyoung Exp $");
#include "opt_inet.h"
@ -307,20 +307,12 @@ tlp_cardbus_attach(device_t parent, device_t self,
if (Cardbus_mapreg_map(ct, TULIP_PCI_MMBA,
PCI_MAPREG_TYPE_MEM, 0, &sc->sc_st, &sc->sc_sh, &adr,
&csc->sc_mapsize) == 0) {
#if rbus
#else
(*ct->ct_cf->cardbus_mem_open)(cc, 0, adr, adr+csc->sc_mapsize);
#endif
csc->sc_csr |= PCI_COMMAND_MEM_ENABLE;
csc->sc_bar_reg = TULIP_PCI_MMBA;
csc->sc_bar_val = adr | PCI_MAPREG_TYPE_MEM;
} else if (Cardbus_mapreg_map(ct, TULIP_PCI_IOBA,
PCI_MAPREG_TYPE_IO, 0, &sc->sc_st, &sc->sc_sh, &adr,
&csc->sc_mapsize) == 0) {
#if rbus
#else
(*ct->ct_cf->cardbus_io_open)(cc, 0, adr, adr+csc->sc_mapsize);
#endif
csc->sc_csr |= PCI_COMMAND_IO_ENABLE;
csc->sc_bar_reg = TULIP_PCI_IOBA;
csc->sc_bar_val = adr | PCI_MAPREG_TYPE_IO;
@ -472,7 +464,7 @@ tlp_cardbus_detach(device_t self, int flags)
* Unhook the interrupt handler.
*/
if (csc->sc_ih != NULL)
cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih);
Cardbus_intr_disestablish(ct, csc->sc_ih);
/*
* Release bus space and close window.
@ -489,8 +481,6 @@ tlp_cardbus_enable(struct tulip_softc *sc)
{
struct tulip_cardbus_softc *csc = (void *) sc;
cardbus_devfunc_t ct = csc->sc_ct;
cardbus_chipset_tag_t cc = ct->ct_cc;
cardbus_function_tag_t cf = ct->ct_cf;
/*
* Power on the socket.
@ -505,7 +495,7 @@ tlp_cardbus_enable(struct tulip_softc *sc)
/*
* Map and establish the interrupt.
*/
csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline, IPL_NET,
csc->sc_ih = Cardbus_intr_establish(ct, csc->sc_intrline, IPL_NET,
tlp_intr, sc);
if (csc->sc_ih == NULL) {
aprint_error_dev(sc->sc_dev,
@ -521,11 +511,9 @@ tlp_cardbus_disable(struct tulip_softc *sc)
{
struct tulip_cardbus_softc *csc = (void *) sc;
cardbus_devfunc_t ct = csc->sc_ct;
cardbus_chipset_tag_t cc = ct->ct_cc;
cardbus_function_tag_t cf = ct->ct_cf;
/* Unhook the interrupt handler. */
cardbus_intr_disestablish(cc, cf, csc->sc_ih);
Cardbus_intr_disestablish(ct, csc->sc_ih);
csc->sc_ih = NULL;
/* Power down the socket. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ohci_cardbus.c,v 1.35 2010/02/26 00:57:02 dyoung Exp $ */
/* $NetBSD: ohci_cardbus.c,v 1.36 2010/03/10 00:21:10 dyoung Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ohci_cardbus.c,v 1.35 2010/02/26 00:57:02 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ohci_cardbus.c,v 1.36 2010/03/10 00:21:10 dyoung Exp $");
#include "ehci_cardbus.h"
@ -131,11 +131,6 @@ ohci_cardbus_attach(device_t parent, device_t self, void *aux)
sc->sc_ct = ct;
sc->sc.sc_bus.dmatag = ca->ca_dmat;
#if rbus
#else
XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
#endif
/* Enable the device. */
csr = Cardbus_conf_read(ct, ca->ca_tag,
PCI_COMMAND_STATUS_REG);
@ -147,7 +142,7 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE,
OHCI_ALL_INTRS);
sc->sc_ih = cardbus_intr_establish(cc, cf, ca->ca_intrline,
sc->sc_ih = Cardbus_intr_establish(ct, ca->ca_intrline,
IPL_USB, ohci_intr, sc);
if (sc->sc_ih == NULL) {
printf("%s: couldn't establish interrupt\n", devname);
@ -168,7 +163,7 @@ XXX (ct->ct_cf->cardbus_mem_open)(cc, 0, iob, iob + 0x40);
printf("%s: init failed, error=%d\n", devname, r);
/* Avoid spurious interrupts. */
cardbus_intr_disestablish(sc->sc_cc, sc->sc_cf, sc->sc_ih);
Cardbus_intr_disestablish(ct, sc->sc_ih);
sc->sc_ih = 0;
return;
@ -197,7 +192,7 @@ ohci_cardbus_detach(device_t self, int flags)
if (rv)
return (rv);
if (sc->sc_ih != NULL) {
cardbus_intr_disestablish(sc->sc_cc, sc->sc_cf, sc->sc_ih);
Cardbus_intr_disestablish(ct, sc->sc_ih);
sc->sc_ih = NULL;
}
if (sc->sc.sc_size) {