Add a method to detach child.
Cosmetic: use device_t and accessors. Use aprint_*_dev(). Use PMF_FN_{ARGS,CALL,PROTO}.
This commit is contained in:
parent
c0dffd675b
commit
cd44c43b28
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ehci_pci.c,v 1.34 2008/01/28 00:44:17 jmcneill Exp $ */
|
||||
/* $NetBSD: ehci_pci.c,v 1.35 2008/02/22 23:07:12 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.34 2008/01/28 00:44:17 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.35 2008/02/22 23:07:12 dyoung Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -71,8 +71,8 @@ static void ehci_release_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc,
|
||||
pcitag_t tag);
|
||||
static void ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc,
|
||||
pcitag_t tag);
|
||||
static bool ehci_pci_suspend(device_t);
|
||||
static bool ehci_pci_resume(device_t);
|
||||
static bool ehci_pci_suspend(device_t PMF_FN_PROTO);
|
||||
static bool ehci_pci_resume(device_t PMF_FN_PROTO);
|
||||
|
||||
struct ehci_pci_softc {
|
||||
ehci_softc_t sc;
|
||||
@ -247,8 +247,9 @@ ehci_pci_detach(device_ptr_t self, int flags)
|
||||
return (0);
|
||||
}
|
||||
|
||||
CFATTACH_DECL(ehci_pci, sizeof(struct ehci_pci_softc),
|
||||
ehci_pci_match, ehci_pci_attach, ehci_pci_detach, ehci_activate);
|
||||
CFATTACH_DECL2(ehci_pci, sizeof(struct ehci_pci_softc),
|
||||
ehci_pci_match, ehci_pci_attach, ehci_pci_detach, ehci_activate, NULL,
|
||||
ehci_childdet);
|
||||
|
||||
#ifdef EHCI_DEBUG
|
||||
static void
|
||||
@ -366,21 +367,21 @@ next:
|
||||
}
|
||||
|
||||
static bool
|
||||
ehci_pci_suspend(device_t dv)
|
||||
ehci_pci_suspend(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
struct ehci_pci_softc *sc = device_private(dv);
|
||||
|
||||
ehci_suspend(dv);
|
||||
ehci_suspend(dv PMF_FN_CALL);
|
||||
ehci_release_ownership(&sc->sc, sc->sc_pc, sc->sc_tag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ehci_pci_resume(device_t dv)
|
||||
ehci_pci_resume(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
struct ehci_pci_softc *sc = device_private(dv);
|
||||
|
||||
ehci_get_ownership(&sc->sc, sc->sc_pc, sc->sc_tag);
|
||||
return ehci_resume(dv);
|
||||
return ehci_resume(dv PMF_FN_CALL);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uhci_pci.c,v 1.40 2007/12/09 20:28:13 jmcneill Exp $ */
|
||||
/* $NetBSD: uhci_pci.c,v 1.41 2008/02/22 23:04:52 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.40 2007/12/09 20:28:13 jmcneill Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.41 2008/02/22 23:04:52 dyoung Exp $");
|
||||
|
||||
#include "ehci.h"
|
||||
|
||||
@ -62,7 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhci_pci.c,v 1.40 2007/12/09 20:28:13 jmcneill Exp $
|
||||
#include <dev/usb/uhcireg.h>
|
||||
#include <dev/usb/uhcivar.h>
|
||||
|
||||
static bool uhci_pci_resume(device_t);
|
||||
static bool uhci_pci_resume(device_t PMF_FN_PROTO);
|
||||
|
||||
struct uhci_pci_softc {
|
||||
uhci_softc_t sc;
|
||||
@ -75,8 +75,7 @@ struct uhci_pci_softc {
|
||||
};
|
||||
|
||||
static int
|
||||
uhci_pci_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
uhci_pci_match(device_t parent, struct cfdata *match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
|
||||
|
||||
@ -89,9 +88,9 @@ uhci_pci_match(struct device *parent, struct cfdata *match,
|
||||
}
|
||||
|
||||
static void
|
||||
uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
uhci_pci_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self;
|
||||
struct uhci_pci_softc *sc = device_private(self);
|
||||
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
|
||||
pci_chipset_tag_t pc = pa->pa_pc;
|
||||
pcitag_t tag = pa->pa_tag;
|
||||
@ -99,7 +98,6 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
pci_intr_handle_t ih;
|
||||
pcireg_t csr;
|
||||
const char *vendor;
|
||||
const char *devname = sc->sc.sc_bus.bdev.dv_xname;
|
||||
char devinfo[256];
|
||||
usbd_status r;
|
||||
int s;
|
||||
@ -113,7 +111,7 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
/* Map I/O registers */
|
||||
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
|
||||
&sc->sc.iot, &sc->sc.ioh, NULL, &sc->sc.sc_size)) {
|
||||
aprint_error("%s: can't map i/o space\n", devname);
|
||||
aprint_error_dev(self, "can't map i/o space\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,19 +134,19 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
|
||||
/* Map and establish the interrupt. */
|
||||
if (pci_intr_map(pa, &ih)) {
|
||||
aprint_error("%s: couldn't map interrupt\n", devname);
|
||||
aprint_error_dev(self, "couldn't map interrupt\n");
|
||||
return;
|
||||
}
|
||||
intrstr = pci_intr_string(pc, ih);
|
||||
sc->sc_ih = pci_intr_establish(pc, ih, IPL_USB, uhci_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
aprint_error("%s: couldn't establish interrupt", devname);
|
||||
aprint_error_dev(self, "couldn't establish interrupt");
|
||||
if (intrstr != NULL)
|
||||
aprint_normal(" at %s", intrstr);
|
||||
aprint_normal("\n");
|
||||
return;
|
||||
}
|
||||
aprint_normal("%s: interrupting at %s\n", devname, intrstr);
|
||||
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
|
||||
|
||||
/*
|
||||
* Set LEGSUP register to its default value.
|
||||
@ -188,7 +186,7 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
|
||||
r = uhci_init(&sc->sc);
|
||||
if (r != USBD_NORMAL_COMPLETION) {
|
||||
aprint_error("%s: init failed, error=%d\n", devname, r);
|
||||
aprint_error_dev(self, "init failed, error=%d\n", r);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -205,9 +203,9 @@ uhci_pci_attach(struct device *parent, struct device *self, void *aux)
|
||||
}
|
||||
|
||||
static int
|
||||
uhci_pci_detach(device_ptr_t self, int flags)
|
||||
uhci_pci_detach(device_t self, int flags)
|
||||
{
|
||||
struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self;
|
||||
struct uhci_pci_softc *sc = device_private(self);
|
||||
int rv;
|
||||
|
||||
pmf_device_deregister(self);
|
||||
@ -230,7 +228,7 @@ uhci_pci_detach(device_ptr_t self, int flags)
|
||||
}
|
||||
|
||||
static bool
|
||||
uhci_pci_resume(device_t dv)
|
||||
uhci_pci_resume(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
struct uhci_pci_softc *sc = device_private(dv);
|
||||
|
||||
@ -238,8 +236,9 @@ uhci_pci_resume(device_t dv)
|
||||
pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_LEGSUP,
|
||||
PCI_LEGSUP_USBPIRQDEN);
|
||||
|
||||
return uhci_resume(dv);
|
||||
return uhci_resume(dv PMF_FN_CALL);
|
||||
}
|
||||
|
||||
CFATTACH_DECL(uhci_pci, sizeof(struct uhci_pci_softc),
|
||||
uhci_pci_match, uhci_pci_attach, uhci_pci_detach, uhci_activate);
|
||||
CFATTACH_DECL2(uhci_pci, sizeof(struct uhci_pci_softc),
|
||||
uhci_pci_match, uhci_pci_attach, uhci_pci_detach, uhci_activate,
|
||||
NULL, uhci_childdet);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ehci.c,v 1.131 2008/02/03 10:57:12 drochner Exp $ */
|
||||
/* $NetBSD: ehci.c,v 1.132 2008/02/22 23:07:12 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004,2005 The NetBSD Foundation, Inc.
|
||||
@ -61,7 +61,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.131 2008/02/03 10:57:12 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.132 2008/02/22 23:07:12 dyoung Exp $");
|
||||
|
||||
#include "ohci.h"
|
||||
#include "uhci.h"
|
||||
@ -909,6 +909,15 @@ ehci_poll(struct usbd_bus *bus)
|
||||
ehci_intr1(sc);
|
||||
}
|
||||
|
||||
void
|
||||
ehci_childdet(device_t self, device_t child)
|
||||
{
|
||||
struct ehci_softc *sc = device_private(self);
|
||||
|
||||
KASSERT(sc->sc_child == child);
|
||||
sc->sc_child = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
ehci_detach(struct ehci_softc *sc, int flags)
|
||||
{
|
||||
@ -937,9 +946,9 @@ ehci_detach(struct ehci_softc *sc, int flags)
|
||||
|
||||
|
||||
int
|
||||
ehci_activate(device_ptr_t self, enum devact act)
|
||||
ehci_activate(device_t self, enum devact act)
|
||||
{
|
||||
struct ehci_softc *sc = (struct ehci_softc *)self;
|
||||
struct ehci_softc *sc = device_private(self);
|
||||
int rv = 0;
|
||||
|
||||
switch (act) {
|
||||
@ -966,9 +975,9 @@ ehci_activate(device_ptr_t self, enum devact act)
|
||||
* bus glue needs to call out to it.
|
||||
*/
|
||||
bool
|
||||
ehci_suspend(device_t dv)
|
||||
ehci_suspend(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
ehci_softc_t *sc = (ehci_softc_t *)dv;
|
||||
ehci_softc_t *sc = device_private(dv);
|
||||
int i, s;
|
||||
uint32_t cmd, hcr;
|
||||
|
||||
@ -1017,11 +1026,11 @@ ehci_suspend(device_t dv)
|
||||
}
|
||||
|
||||
bool
|
||||
ehci_resume(device_t dv)
|
||||
ehci_resume(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
ehci_softc_t *sc = (ehci_softc_t *)dv;
|
||||
uint32_t cmd, hcr;
|
||||
ehci_softc_t *sc = device_private(dv);
|
||||
int i;
|
||||
uint32_t cmd, hcr;
|
||||
|
||||
/* restore things in case the bios sucks */
|
||||
EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ehcivar.h,v 1.26 2007/12/09 20:28:23 jmcneill Exp $ */
|
||||
/* $NetBSD: ehcivar.h,v 1.27 2008/02/22 23:07:12 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -159,6 +159,7 @@ typedef struct ehci_softc {
|
||||
usbd_status ehci_init(ehci_softc_t *);
|
||||
int ehci_intr(void *);
|
||||
int ehci_detach(ehci_softc_t *, int);
|
||||
int ehci_activate(device_ptr_t, enum devact);
|
||||
bool ehci_suspend(device_t dv);
|
||||
bool ehci_resume(device_t dv);
|
||||
int ehci_activate(device_t, enum devact);
|
||||
void ehci_childdet(device_t, device_t);
|
||||
bool ehci_suspend(device_t PMF_FN_PROTO);
|
||||
bool ehci_resume(device_t PMF_FN_PROTO);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uhci.c,v 1.214 2008/02/13 00:52:44 smb Exp $ */
|
||||
/* $NetBSD: uhci.c,v 1.215 2008/02/22 23:04:52 dyoung Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -49,7 +49,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.214 2008/02/13 00:52:44 smb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.215 2008/02/22 23:04:52 dyoung Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -554,9 +554,9 @@ uhci_init(uhci_softc_t *sc)
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int
|
||||
uhci_activate(device_ptr_t self, enum devact act)
|
||||
uhci_activate(device_t self, enum devact act)
|
||||
{
|
||||
struct uhci_softc *sc = (struct uhci_softc *)self;
|
||||
struct uhci_softc *sc = device_private(self);
|
||||
int rv = 0;
|
||||
|
||||
switch (act) {
|
||||
@ -572,6 +572,15 @@ uhci_activate(device_ptr_t self, enum devact act)
|
||||
return (rv);
|
||||
}
|
||||
|
||||
void
|
||||
uhci_childdet(device_t self, device_t child)
|
||||
{
|
||||
struct uhci_softc *sc = device_private(self);
|
||||
|
||||
KASSERT(sc->sc_child == child);
|
||||
sc->sc_child = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
uhci_detach(struct uhci_softc *sc, int flags)
|
||||
{
|
||||
@ -705,7 +714,7 @@ uhci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
|
||||
* are almost suspended anyway.
|
||||
*/
|
||||
bool
|
||||
uhci_resume(device_t dv)
|
||||
uhci_resume(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
uhci_softc_t *sc = device_private(dv);
|
||||
int cmd;
|
||||
@ -749,7 +758,7 @@ uhci_resume(device_t dv)
|
||||
}
|
||||
|
||||
bool
|
||||
uhci_suspend(device_t dv)
|
||||
uhci_suspend(device_t dv PMF_FN_ARGS)
|
||||
{
|
||||
uhci_softc_t *sc = device_private(dv);
|
||||
int cmd;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: uhcivar.h,v 1.41 2007/12/09 20:28:24 jmcneill Exp $ */
|
||||
/* $NetBSD: uhcivar.h,v 1.42 2008/02/22 23:04:52 dyoung Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -189,8 +189,9 @@ usbd_status uhci_init(uhci_softc_t *);
|
||||
int uhci_intr(void *);
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
int uhci_detach(uhci_softc_t *, int);
|
||||
int uhci_activate(device_ptr_t, enum devact);
|
||||
bool uhci_resume(device_t);
|
||||
bool uhci_suspend(device_t);
|
||||
void uhci_childdet(device_t, device_t);
|
||||
int uhci_activate(device_t, enum devact);
|
||||
bool uhci_resume(device_t PMF_FN_PROTO);
|
||||
bool uhci_suspend(device_t PMF_FN_PROTO);
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user