Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc/dev In awacs(4) and snapper(4), use deviter(...
details: https://anonhg.NetBSD.org/src/rev/e709c849ce18
branches: trunk
changeset: 748775:e709c849ce18
user: dyoung <dyoung%NetBSD.org@localhost>
date: Thu Nov 05 05:37:30 2009 +0000
description:
In awacs(4) and snapper(4), use deviter(9) instead of accessing
alldevs directly.
In pbms(4), delete some unused debugging macros, expand USB
compatibility macros, and add a child-detachment routine. Simplify
pbms(4) deactivation and detachment.
These changes are compile-tested, only.
diffstat:
sys/arch/macppc/dev/awacs.c | 10 +++-
sys/arch/macppc/dev/pbms.c | 88 ++++++++++++++----------------------------
sys/arch/macppc/dev/snapper.c | 10 +++-
3 files changed, 44 insertions(+), 64 deletions(-)
diffs (230 lines):
diff -r d81e801e07b9 -r e709c849ce18 sys/arch/macppc/dev/awacs.c
--- a/sys/arch/macppc/dev/awacs.c Thu Nov 05 04:19:47 2009 +0000
+++ b/sys/arch/macppc/dev/awacs.c Thu Nov 05 05:37:30 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awacs.c,v 1.35 2008/08/27 14:31:46 jmcneill Exp $ */
+/* $NetBSD: awacs.c,v 1.36 2009/11/05 05:37:30 dyoung Exp $ */
/*-
* Copyright (c) 2000 Tsubai Masanari. All rights reserved.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.35 2008/08/27 14:31:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.36 2009/11/05 05:37:30 dyoung Exp $");
#include <sys/param.h>
#include <sys/audioio.h>
@@ -537,18 +537,22 @@
struct awacs_softc *sc = device_private(cookie);
#if NSGSMIX > 0
device_t dv;
+ deviter_t di;
#endif
if (!sc->sc_have_perch)
return 0;
#if NSGSMIX > 0
/* look for sgsmix */
- for (dv = alldevs.tqh_first; dv; dv=dv->dv_list.tqe_next) {
+ for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+ dv != NULL;
+ dv = deviter_next(&di)) {
if (device_is_a(dv, "sgsmix")) {
sc->sc_sgsmix = dv;
break;
}
}
+ deviter_release(&di);
if (sc->sc_sgsmix == NULL)
return 0;
diff -r d81e801e07b9 -r e709c849ce18 sys/arch/macppc/dev/pbms.c
--- a/sys/arch/macppc/dev/pbms.c Thu Nov 05 04:19:47 2009 +0000
+++ b/sys/arch/macppc/dev/pbms.c Thu Nov 05 05:37:30 2009 +0000
@@ -1,4 +1,4 @@
-/* $Id: pbms.c,v 1.8 2009/03/01 10:18:30 aymeric Exp $ */
+/* $Id: pbms.c,v 1.9 2009/11/05 05:37:30 dyoung Exp $ */
/*
* Copyright (c) 2005, Johan Wallén
@@ -132,38 +132,6 @@
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsmousevar.h>
-
-/*
- * Debugging output.
- */
-
-
-/* XXX Should be redone, and its use should be added back. */
-
-#ifdef PBMS_DEBUG
-
-/*
- * Print the error message (preceded by the driver and function)
- * specified by the string literal fmt (followed by newline) if
- * pbmsdebug is greater than n. The macro may only be used in the
- * scope of sc, which must be castable to struct device *. There must
- * be at least one vararg. Do not define PBMS_DEBUG on non-C99
- * compilers.
- */
-
-#define DPRINTFN(n, fmt, ...) \
-do { \
- if (pbmsdebug > (n)) \
- logprintf("%s: %s: " fmt "\n", \
- ((struct device *) sc)->dv_xname, \
- __func__, __VA_ARGS__); \
-} while ( /* CONSTCOND */ 0)
-
-int pbmsdebug = 0;
-
-#endif /* PBMS_DEBUG */
-
-
/*
* Magic numbers.
*/
@@ -266,7 +234,7 @@
int sc_acc[PBMS_SENSORS]; /* Accumulated sensor values. */
unsigned char sc_prev[PBMS_SENSORS]; /* Previous sample. */
unsigned char sc_sample[PBMS_SENSORS]; /* Current sample. */
- struct device *sc_wsmousedev; /* WSMouse device. */
+ device_t sc_wsmousedev; /* WSMouse device. */
int sc_noise; /* Amount of noise. */
int sc_theshold; /* Threshold value. */
int sc_x; /* Virtual position in horizontal
@@ -305,8 +273,14 @@
};
/* This take cares also of the basic device registration. */
-USB_DECLARE_DRIVER(pbms);
-
+int pbms_match(device_t, cfdata_t, void *);
+void pbms_attach(device_t, device_t, void *);
+int pbms_detach(device_t, int);
+void pbms_childdet(device_t, device_t);
+int pbms_activate(device_t, enum devact);
+extern struct cfdriver pbms_cd;
+CFATTACH_DECL2_NEW(pbms, sizeof(struct pbms_softc), pbms_match, pbms_attach,
+ pbms_detach, pbms_activate, NULL, pbms_childdet);
/*
* Basic driver.
@@ -316,7 +290,7 @@
/* Try to match the device at some uhidev. */
int
-pbms_match(struct device *parent, struct cfdata *match, void *aux)
+pbms_match(device_t parent, cfdata_t match, void *aux)
{
struct uhidev_attach_arg *uha = aux;
usb_device_descriptor_t *udd;
@@ -343,7 +317,7 @@
/* Attach the device. */
void
-pbms_attach(struct device *parent, struct device *self, void *aux)
+pbms_attach(device_t parent, device_t self, void *aux)
{
struct wsmousedev_attach_args a;
struct uhidev_attach_arg *uha = aux;
@@ -399,37 +373,35 @@
/* Detach the device. */
-int
-pbms_detach(struct device *self, int flags)
+void
+pbms_childdet(device_t self, device_t child)
{
- struct pbms_softc *sc = (struct pbms_softc *)self;
- int ret;
+ struct pbms_softc *sc = device_private(self);
- /* The wsmouse driver does all the work. */
- ret = 0;
- if (sc->sc_wsmousedev != NULL)
- ret = config_detach(sc->sc_wsmousedev, flags);
+ if (sc->sc_wsmousedev == child)
+ sc->sc_wsmousedev = NULL;
+}
- return ret;
+int
+pbms_detach(device_t self, int flags)
+{
+ /* XXX This could not possibly be sufficient! */
+ return config_detach_children(self, flags);
}
/* Activate the device. */
int
-pbms_activate(device_ptr_t self, enum devact act)
+pbms_activate(device_t self, enum devact act)
{
- struct pbms_softc *sc = (struct pbms_softc *)self;
- int ret;
+ struct pbms_softc *sc = device_private(self);
- if (act == DVACT_DEACTIVATE) {
- ret = 0;
- if (sc->sc_wsmousedev != NULL)
- ret = config_deactivate(sc->sc_wsmousedev);
- sc->sc_status |= PBMS_DYING;
- return ret;
- }
- return EOPNOTSUPP;
+ if (act != DVACT_DEACTIVATE)
+ return EOPNOTSUPP;
+
+ sc->sc_status |= PBMS_DYING;
+ return 0;
}
diff -r d81e801e07b9 -r e709c849ce18 sys/arch/macppc/dev/snapper.c
--- a/sys/arch/macppc/dev/snapper.c Thu Nov 05 04:19:47 2009 +0000
+++ b/sys/arch/macppc/dev/snapper.c Thu Nov 05 05:37:30 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: snapper.c,v 1.32 2009/03/18 16:00:13 cegger Exp $ */
+/* $NetBSD: snapper.c,v 1.33 2009/11/05 05:37:30 dyoung Exp $ */
/* Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp */
/* Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp */
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.32 2009/03/18 16:00:13 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.33 2009/11/05 05:37:30 dyoung Exp $");
#include <sys/param.h>
#include <sys/audioio.h>
@@ -800,16 +800,20 @@
{
struct snapper_softc *sc;
device_t dv;
+ deviter_t di;
struct deq_softc *deq;
sc = device_private(dev);
- TAILQ_FOREACH(dv, &alldevs, dv_list) {
+ for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+ dv != NULL;
+ dv = deviter_next(&di)) {
if (device_is_a(dv, "deq")) {
deq = device_private(dv);
sc->sc_i2c = deq->sc_i2c;
sc->sc_deqaddr = deq->sc_address;
}
}
+ deviter_release(&di);
/* If we don't find a codec, it's not the end of the world;
* we can control the volume in software in this case.
Home |
Main Index |
Thread Index |
Old Index