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 /sys/arch/zaurus/dev | |
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
Diffstat (limited to 'sys/arch/zaurus/dev')
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_scoop.c | 30 |
1 files changed, 29 insertions, 1 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); +} |