diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-03-26 20:18:11 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-03-26 20:18:11 +0000 |
commit | 7388ca4ef4d1f5243b06d1b71402c0dafdc3bf47 (patch) | |
tree | 89451f2dbe8e48b03b1a661a75df88e7f9ea646e | |
parent | 68bb6380285f97641ac34162f4f6bd532de03924 (diff) |
software-driven drive light code, using a timeout. uwe wrote some code
initially that used a disk_busy() hook, but this uses a lot less cpu and
is MD; ok uwe
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_scoop.c | 30 | ||||
-rw-r--r-- | sys/arch/zaurus/zaurus/autoconf.c | 7 |
2 files changed, 35 insertions, 2 deletions
diff --git a/sys/arch/zaurus/dev/zaurus_scoop.c b/sys/arch/zaurus/dev/zaurus_scoop.c index 2b7c2aab960..f88d5a8169b 100644 --- a/sys/arch/zaurus/dev/zaurus_scoop.c +++ b/sys/arch/zaurus/dev/zaurus_scoop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_scoop.c,v 1.13 2007/03/18 20:50:23 uwe Exp $ */ +/* $OpenBSD: zaurus_scoop.c,v 1.14 2007/03/26 20:18:09 deraadt Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -17,8 +17,12 @@ */ #include <sys/param.h> +#include <sys/device.h> +#include <sys/kernel.h> #include <sys/systm.h> #include <sys/conf.h> +#include <sys/disk.h> +#include <sys/timeout.h> #include <sys/gpio.h> #include <machine/bus.h> @@ -59,6 +63,9 @@ void scoop_gpio_pin_write(struct scoop_softc *sc, int, int); void scoop_gpio_pin_ctl(struct scoop_softc *sc, int, int); void scoop0_set_card_power(enum card, int); +struct timeout scoop_checkdisk; +void scoop_timeout(void *); + int scoopmatch(struct device *parent, void *match, void *aux) { @@ -105,6 +112,8 @@ scoopattach(struct device *parent, struct device *self, void *aux) scoop_gpio_pin_write(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_LOW); } + timeout_set(&scoop_checkdisk, scoop_timeout, sc); + printf(": PCMCIA/GPIO controller\n"); } @@ -393,3 +402,22 @@ scoop_resume(void) sc->sc_gpwr); } } + +void +scoop_timeout(void *v) +{ + extern struct disklist_head disklist; + static struct disk *dk; + + if (dk == NULL) { + for (dk = TAILQ_FIRST(&disklist); dk; + dk = TAILQ_NEXT(dk, dk_link)) + if (dk->dk_name && + strcmp(dk->dk_name, "wd0") == 0) + break; + } + + if (dk) + scoop_led_set(SCOOP_LED_GREEN, dk->dk_busy ? 1 : 0); + timeout_add(&scoop_checkdisk, hz/25); +} diff --git a/sys/arch/zaurus/zaurus/autoconf.c b/sys/arch/zaurus/zaurus/autoconf.c index d8f2fbaaadd..5533bbf6292 100644 --- a/sys/arch/zaurus/zaurus/autoconf.c +++ b/sys/arch/zaurus/zaurus/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.6 2006/05/25 22:40:18 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.7 2007/03/26 20:18:10 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.2 2001/09/05 16:17:36 matt Exp $ */ /* @@ -48,6 +48,7 @@ #include <sys/device.h> #include <sys/conf.h> #include <sys/kernel.h> +#include <sys/timeout.h> #include <sys/malloc.h> #include <machine/bootconfig.h> #include <machine/intr.h> @@ -177,6 +178,8 @@ parsedisk(char *str, int len, int defpart, dev_t *devp) void diskconf() { + extern struct timeout scoop_checkdisk; + /* * Configure root, swap, and dump area. This is * currently done by running the same checksum @@ -192,6 +195,8 @@ diskconf() #if 0 dumpconf(); #endif + + timeout_add(&scoop_checkdisk, hz/25); } |