Date: Wed, 17 Sep 2008 23:41:51 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 149980 for review Message-ID: <200809172341.m8HNfp7p067715@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149980 Change 149980 by peter@peter_daintree on 2008/09/17 23:41:35 WIP. attempt to match up acpi devices with their unit hints. Affected files ... .. //depot/projects/hammer/sys/dev/uart/uart_bus_acpi.c#4 edit Differences ... ==== //depot/projects/hammer/sys/dev/uart/uart_bus_acpi.c#4 (text+ko) ==== @@ -41,11 +41,12 @@ #include <dev/uart/uart_bus.h> static int uart_acpi_probe(device_t dev); +static int uart_acpi_attach(device_t dev); static device_method_t uart_acpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, uart_acpi_probe), - DEVMETHOD(device_attach, uart_bus_attach), + DEVMETHOD(device_attach, uart_acpi_attach), DEVMETHOD(device_detach, uart_bus_detach), { 0, 0 } }; @@ -80,4 +81,49 @@ return (ENXIO); } +/* XXX find matching 'port' if it exists. */ +/* + * 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 +uart_acpi_kludge_unit(device_t dev) +{ + devclass_t dc; + int err; + int start; + int unit; + u_int port; + + port = isa_get_port(dev); + if (port == -1) + device_printf(dev, "cannot find start port"); + unit = 0; + start = 0; + while (resource_int_value("uart", unit, "port", &start) == 0 && + start > 0) { + if (start == port) + break; + else + unit++; + } + if (device_get_unit(dev) < unit) { + dc = device_get_devclass(dev); + while (devclass_get_device(dc, unit)) + unit++; + device_printf(dev, "moving to uart%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 +uart_acpi_attach(device_t dev) +{ + + uart_acpi_kludge_unit(dev); + return (uart_bus_attach(dev)); +} + DRIVER_MODULE(uart, acpi, uart_acpi_driver, uart_devclass, 0, 0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809172341.m8HNfp7p067715>