Subject: move /proc/gio to /proc/bus/gio/devices

From: Guido Guenther <[email-masked]>
Date: Fri, 9 Aug 2002 15:18:32 +0200

Hi,
the patch reformats /proc/gio and moves it to /proc/bus/gio/devices (for
better conformance with other busses). It also changes the format to be
better machine parseable. I discussed this with Ladis and he said it's
o.k. Can it be applied?
The new format is: "Slot DeviceID BaseAddress MapSize". I'd like to see
this in to cleanup the X-Server code.
 -- Guido

Index: arch/mips/sgi-ip22/ip22-gio.c
===================================================================
RCS file: /cvs/linux/arch/mips/sgi-ip22/ip22-gio.c,v
retrieving revision 1.1.2.3
diff -u -u -r1.1.2.3 ip22-gio.c
--- arch/mips/sgi-ip22/ip22-gio.c	2002/08/05 23:53:35	1.1.2.3
+++ arch/mips/sgi-ip22/ip22-gio.c	2002/08/09 13:09:43
@@ -69,14 +69,12 @@
 	int i;
 	char *p = buf;
 
-	p += sprintf(p, "GIO devices found:\n");
 	for (i = 0; i < GIO_NUM_SLOTS; i++) {
 		if (gio_slot[i].flags & GIO_NO_DEVICE)
 			continue;
-		p += sprintf(p, "  Slot %s, DeviceId 0x%02x\n",
-			     gio_slot[i].slot_name, gio_slot[i].device);
-		p += sprintf(p, "    BaseAddr 0x%08lx, MapSize 0x%08x\n",
-			     gio_slot[i].base_addr, gio_slot[i].map_size);
+		p += sprintf(p, "%s 0x%02x 0x%08lx 0x%08x\n",
+				gio_slot[i].slot_name, gio_slot[i].device,
+				gio_slot[i].base_addr, gio_slot[i].map_size);
 	}
 
 	return p - buf;
@@ -84,7 +82,16 @@
 
 void create_gio_proc_entry(void)
 {
-	create_proc_read_entry("gio", 0, NULL, gio_read_proc, NULL);
+	int i;
+
+	for (i = 0; i < GIO_NUM_SLOTS; i++) {
+		/* only create proc entry if we have at least one device */
+		if (! (gio_slot[i].flags & GIO_NO_DEVICE))
+			if( proc_mkdir("bus/gio", NULL) )
+				create_proc_read_entry("bus/gio/devices", 0,
+						NULL, gio_read_proc, NULL);
+			break;
+	}
 }
 
 /**