Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Use deviter(9) instead of accessing alldevs directl...
details: https://anonhg.NetBSD.org/src/rev/6c9bb993dfe8
branches: trunk
changeset: 748803:6c9bb993dfe8
user: dyoung <dyoung%NetBSD.org@localhost>
date: Thu Nov 05 18:11:09 2009 +0000
description:
Use deviter(9) instead of accessing alldevs directly. Untested.
diffstat:
sys/arch/evbppc/obs405/dev/obsled.c | 18 +++++++------
sys/arch/landisk/landisk/autoconf.c | 17 +++++++-----
sys/arch/mipsco/mipsco/autoconf.c | 28 ++++++++++++--------
sys/arch/next68k/dev/nextdma.c | 25 +++++++++++-------
sys/arch/prep/prep/autoconf.c | 49 +++++++++++++++++++++++-------------
sys/arch/x68k/x68k/autoconf.c | 16 +++++++----
sys/arch/zaurus/zaurus/autoconf.c | 33 +++++++++++++++---------
7 files changed, 114 insertions(+), 72 deletions(-)
diffs (truncated from 504 to 300 lines):
diff -r bfef8c9b3b37 -r 6c9bb993dfe8 sys/arch/evbppc/obs405/dev/obsled.c
--- a/sys/arch/evbppc/obs405/dev/obsled.c Thu Nov 05 18:07:19 2009 +0000
+++ b/sys/arch/evbppc/obs405/dev/obsled.c Thu Nov 05 18:11:09 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: obsled.c,v 1.6 2006/03/28 17:38:24 thorpej Exp $ */
+/* $NetBSD: obsled.c,v 1.7 2009/11/05 18:16:00 dyoung Exp $ */
/*
* Copyright (c) 2004 Shigeyuki Fukushima.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obsled.c,v 1.6 2006/03/28 17:38:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obsled.c,v 1.7 2009/11/05 18:16:00 dyoung Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -178,19 +178,21 @@
void
obs266_led_set(int led)
{
- struct device *dp = NULL;
- struct devicelist *dlp = &alldevs;
+ device_t dv;
+ deviter_t di;
/*
* Sarching "obsled" devices from device tree.
* Do you have something better idea?
*/
- for (dp = TAILQ_FIRST(dlp); dp != NULL; dp = TAILQ_NEXT(dp, dv_list)) {
- if (device_is_a(dp, "obsles")) {
- struct obsled_softc *sc = (struct obsled_softc *)dp;
+ for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
+ dv = deviter_next(&di)) {
+ if (device_is_a(dv, "obsles")) {
+ struct obsled_softc *sc = device_private(dv);
sc->sc_led_state =
- (led & (1 << device_unit(dp))) >> device_unit(dp);
+ (led & (1 << device_unit(dv))) >> device_unit(dv);
obsled_set_state(sc);
}
}
+ deviter_release(&di);
}
diff -r bfef8c9b3b37 -r 6c9bb993dfe8 sys/arch/landisk/landisk/autoconf.c
--- a/sys/arch/landisk/landisk/autoconf.c Thu Nov 05 18:07:19 2009 +0000
+++ b/sys/arch/landisk/landisk/autoconf.c Thu Nov 05 18:11:09 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.4 2008/04/28 20:23:26 martin Exp $ */
+/* $NetBSD: autoconf.c,v 1.5 2009/11/05 18:15:17 dyoung Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2008/04/28 20:23:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2009/11/05 18:15:17 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -60,7 +60,7 @@
}
static int
-is_valid_disk(struct device *dv)
+is_valid_disk(device_t dv)
{
const char *name;
@@ -78,7 +78,7 @@
* Return non-zero if disk device matches bootinfo.
*/
static int
-match_bootdisk(struct device *dv, struct btinfo_bootdisk *bid)
+match_bootdisk(device_t dv, struct btinfo_bootdisk *bid)
{
struct vnode *tmpvn;
int error;
@@ -153,7 +153,8 @@
findroot(void)
{
struct btinfo_bootdisk *bid;
- struct device *dv;
+ device_t dv;
+ deviter_t di;
if (booted_device)
return;
@@ -166,8 +167,9 @@
* because lower device numbers are more likely to be the
* boot device.
*/
- for (dv = TAILQ_FIRST(&alldevs); dv != NULL;
- dv = TAILQ_NEXT(dv, dv_list)) {
+ for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+ dv != NULL;
+ dv = deviter_next(&di)) {
if (dv->dv_class != DV_DISK)
continue;
@@ -188,6 +190,7 @@
booted_device = dv;
booted_partition = bid->partition;
}
+ deviter_release(&di);
if (booted_device)
return;
diff -r bfef8c9b3b37 -r 6c9bb993dfe8 sys/arch/mipsco/mipsco/autoconf.c
--- a/sys/arch/mipsco/mipsco/autoconf.c Thu Nov 05 18:07:19 2009 +0000
+++ b/sys/arch/mipsco/mipsco/autoconf.c Thu Nov 05 18:11:09 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.21 2009/03/18 10:22:32 cegger Exp $ */
+/* $NetBSD: autoconf.c,v 1.22 2009/11/05 18:14:21 dyoung Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -85,7 +85,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.21 2009/03/18 10:22:32 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.22 2009/11/05 18:14:21 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -111,7 +111,7 @@
extern int initcpu(void); /*XXX*/
-void findroot(struct device **, int *);
+void findroot(device_t *, int *);
struct mipsco_intrhand intrtab[MAX_INTR_COOKIES];
@@ -154,18 +154,24 @@
* Attempt to find the device from which we were booted.
*/
void
-findroot(struct device **devpp, int *partp)
+findroot(device_t *devpp, int *partp)
{
- struct device *dv;
+ device_t dv;
+ deviter_t di;
- for (dv = TAILQ_FIRST(&alldevs); dv; dv = TAILQ_NEXT(dv, dv_list)) {
+ for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+ dv != NULL;
+ dv = deviter_next(&di)) {
if (device_class(dv) == boot_class &&
/* XXX device_unit() abuse */
- device_unit(dv) == boot_id) {
- *devpp = dv;
- *partp = boot_part;
- return;
- }
+ device_unit(dv) == boot_id)
+ break;
+ }
+ deviter_release(&di);
+ if (dv != NULL) {
+ *devpp = dv;
+ *partp = boot_part;
+ return;
}
/*
diff -r bfef8c9b3b37 -r 6c9bb993dfe8 sys/arch/next68k/dev/nextdma.c
--- a/sys/arch/next68k/dev/nextdma.c Thu Nov 05 18:07:19 2009 +0000
+++ b/sys/arch/next68k/dev/nextdma.c Thu Nov 05 18:11:09 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nextdma.c,v 1.44 2008/12/17 17:12:52 cegger Exp $ */
+/* $NetBSD: nextdma.c,v 1.45 2009/11/05 18:11:09 dyoung Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
* All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nextdma.c,v 1.44 2008/12/17 17:12:52 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nextdma.c,v 1.45 2009/11/05 18:11:09 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -137,17 +137,22 @@
struct nextdma_softc *
nextdma_findchannel(const char *name)
{
- struct device *dev = TAILQ_FIRST(&alldevs);
+ device_t dev;
+ deviter_t di;
- while (dev != NULL) {
- if (!strncmp(dev->dv_xname, "nextdma", 7)) {
- struct nextdma_softc *nsc = (struct nextdma_softc *)dev;
- if (!strcmp (nsc->sc_chan->nd_name, name))
- return (nsc);
+ for (dev = deviter_first(&di, DEVITER_F_ROOT_FIRST);
+ dev != NULL;
+ dev = deviter_next(&di)) {
+ if (strncmp(dev->dv_xname, "nextdma", 7) == 0) {
+ struct nextdma_softc *nsc = device_private(dev);
+ if (strcmp(nsc->sc_chan->nd_name, name) == 0)
+ break;
}
- dev = TAILQ_NEXT(dev, dv_list);
}
- return (NULL);
+ deviter_release(&di);
+ if (dev == NULL)
+ return NULL;
+ return device_private(dev);
}
int
diff -r bfef8c9b3b37 -r 6c9bb993dfe8 sys/arch/prep/prep/autoconf.c
--- a/sys/arch/prep/prep/autoconf.c Thu Nov 05 18:07:19 2009 +0000
+++ b/sys/arch/prep/prep/autoconf.c Thu Nov 05 18:11:09 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.22 2008/04/28 20:23:33 martin Exp $ */
+/* $NetBSD: autoconf.c,v 1.23 2009/11/05 18:12:31 dyoung Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.22 2008/04/28 20:23:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23 2009/11/05 18:12:31 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -253,26 +253,30 @@
static void
build_fwpath(void)
{
- struct device *dev, *d;
+ device_t dev, d;
+ deviter_t di, inner_di;
prop_string_t str1;
/* First, find all the PCI busses */
- TAILQ_FOREACH(dev, &alldevs, dv_list) {
+ for (dev = deviter_first(&di, DEVITER_F_ROOT_FIRST); dev != NULL;
+ dev = deviter_next(&di)) {
if (device_is_a(dev, "pci") || device_is_a(dev, "mainbus") ||
device_is_a(dev, "pcib") || device_is_a(dev, "pceb") ||
device_is_a(dev, "ppb"))
gen_fwpath(dev);
- else
- continue;
}
+ deviter_release(&di);
+
/* Now go find the ISA bus and fix it up */
- TAILQ_FOREACH(dev, &alldevs, dv_list) {
+ for (dev = deviter_first(&di, DEVITER_F_ROOT_FIRST); dev != NULL;
+ dev = deviter_next(&di)) {
if (device_is_a(dev, "isa"))
gen_fwpath(dev);
- else
- continue;
}
- TAILQ_FOREACH(dev, &alldevs, dv_list) {
+ deviter_release(&di);
+
+ for (dev = deviter_first(&di, DEVITER_F_ROOT_FIRST); dev != NULL;
+ dev = deviter_next(&di)) {
/* skip the ones we allready computed above */
if (device_is_a(dev, "pci") || device_is_a(dev, "pcib") ||
device_is_a(dev, "pceb") || device_is_a(dev, "isa") ||
@@ -280,7 +284,9 @@
continue;
/* patch in the properties for the pnpbus */
if (device_is_a(dev, "pnpbus")) {
- TAILQ_FOREACH(d, &alldevs, dv_list) {
+ for (d = deviter_first(&inner_di, DEVITER_F_ROOT_FIRST);
+ d != NULL;
+ d = deviter_next(&inner_di)) {
if (!device_is_a(d, "isa"))
continue;
str1 = prop_dictionary_get(device_properties(d),
@@ -290,9 +296,11 @@
prop_dictionary_set(device_properties(dev),
"prep-fw-path", str1);
}
+ deviter_release(&inner_di);
} else
gen_fwpath(dev);
}
+ deviter_release(&di);
}
Home |
Main Index |
Thread Index |
Old Index