PERFORCE change 149978 for review

Peter Wemm peter at FreeBSD.org
Wed Sep 17 23:29:39 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=149978

Change 149978 by peter at peter_daintree on 2008/09/17 23:29:09

	Clone another kludge_unit() hack for uart.  uart_puc_kludge_unit().

Affected files ...

.. //depot/projects/hammer/sys/dev/uart/uart_bus_puc.c#4 edit

Differences ...

==== //depot/projects/hammer/sys/dev/uart/uart_bus_puc.c#4 (text+ko) ====

@@ -44,6 +44,7 @@
 #include <dev/uart/uart_bus.h>
 
 static int uart_puc_probe(device_t dev);
+static int uart_puc_attach(device_t dev);
 
 static device_method_t uart_puc_methods[] = {
 	/* Device interface */
@@ -84,4 +85,40 @@
 	return (uart_bus_probe(dev, 0, rclk, 0, 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
+uart_puc_kludge_unit(device_t dev)
+{
+	devclass_t	dc;
+	int		err;
+	int		start;
+	int		unit;
+
+	unit = 0;
+	start = 0;
+	while (resource_int_value("uart", 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 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_bus_attach(device_t dev)
+{
+	
+	uart_puc_kludge_unit(dev);
+	return (uart_bus_attach(dev));
+}
+
 DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0);


More information about the p4-projects mailing list