Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Sep 2008 23:29:38 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 149978 for review
Message-ID:  <200809172329.m8HNTc8H095714@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=149978

Change 149978 by peter@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809172329.m8HNTc8H095714>