diff options
author | peter <peter@FreeBSD.org> | 2007-11-30 21:36:12 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2007-11-30 21:36:12 +0000 |
commit | 66c7617de3c3025108ee7548eb6660d637fbbc6a (patch) | |
tree | 2cb1ef6748ad779ac1f546f7080fede3b7071a2c /sys/dev/sio/sio_puc.c | |
parent | e287ae6b7a80814f022c11fbdaf107172bc3add6 (diff) | |
download | FreeBSD-src-66c7617de3c3025108ee7548eb6660d637fbbc6a.zip FreeBSD-src-66c7617de3c3025108ee7548eb6660d637fbbc6a.tar.gz |
Add sio_puc_kludge_unit() to stop sio devices originating from puc
stomping on the units intended for the motherboard sio ports. This is
no real substitute for the not-yet-committed device wiring enhancements.
Code taken from sio's pci attachment.
Diffstat (limited to 'sys/dev/sio/sio_puc.c')
-rw-r--r-- | sys/dev/sio/sio_puc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/dev/sio/sio_puc.c b/sys/dev/sio/sio_puc.c index 0ae0e7d..37691f7 100644 --- a/sys/dev/sio/sio_puc.c +++ b/sys/dev/sio/sio_puc.c @@ -62,6 +62,34 @@ static driver_t sio_puc_driver = { 0, }; +/* + * Don't cut and paste this to other drivers. It is a horrible kludge + * which will fail to work and also be unnecessary in future versions. + */ +static void +sio_puc_kludge_unit(device_t dev) +{ + devclass_t dc; + int err; + int start; + int unit; + + unit = 0; + start = 0; + while (resource_int_value("sio", unit, "port", &start) == 0 && + start > 0) + unit++; + if (device_get_unit(dev) < unit) { + dc = device_get_devclass(dev); + while (devclass_get_device(dc, unit)) + unit++; + device_printf(dev, "moving to sio%d\n", unit); + err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */ + if (err) + device_printf(dev, "error moving device %d\n", err); + } +} + static int sio_puc_attach(device_t dev) { @@ -70,6 +98,7 @@ sio_puc_attach(device_t dev) if (BUS_READ_IVAR(device_get_parent(dev), dev, PUC_IVAR_CLOCK, &rclk) != 0) rclk = DEFAULT_RCLK; + sio_puc_kludge_unit(dev); return (sioattach(dev, 0, rclk)); } |