Skip to contentSkip to conversation

module-init-tools: generate modules.seriomap

PATCH In review Dmitry Torokhov 2 participants 3 messages Feb 6, 2005 – Feb 7, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module-init-tools: generate modules.seriomap

Hi Rusty,

I have converted serio bus to use ID matching and changed serio drivers to use MODULE_DEVICE_TABLE. Now that Vojtech pulled the changes into his tree it would be nice if official module-init-tools generated the module map so that hotplug scripts could automatically load proper drivers.

Please consider applying the patch below.

Thanks!

Signature · 105 lines
Dmitry

diff -urN module-init-tools-3.1-pre5/depmod.c module-init-tools/depmod.c
--- module-init-tools-3.1-pre5/depmod.c	2004-06-30 23:24:40.000000000 -0500
+++ module-init-tools/depmod.c	2005-01-23 01:16:04.000000000 -0500
@@ -683,6 +683,7 @@
 	{ "modules.ieee1394map", output_ieee1394_table },
 	{ "modules.isapnpmap", output_isapnp_table },
 	{ "modules.inputmap", output_input_table },
+	{ "modules.seriomap", output_serio_table },
 	{ "modules.alias", output_aliases },
 	{ "modules.symbols", output_symbols },
 };
diff -urN module-init-tools-3.1-pre5/depmod.h module-init-tools/depmod.h
--- module-init-tools-3.1-pre5/depmod.h	2003-12-23 21:10:57.000000000 -0500
+++ module-init-tools/depmod.h	2005-01-23 01:17:17.000000000 -0500
@@ -47,6 +47,8 @@
 	void *pnp_card_table;
 	unsigned int input_size;
 	void *input_table;
+	unsigned int serio_size;
+	void *serio_table;
 
 	/* File contents and length. */
 	void *data;
diff -urN module-init-tools-3.1-pre5/moduleops_core.c module-init-tools/moduleops_core.c
--- module-init-tools-3.1-pre5/moduleops_core.c	2004-05-23 22:01:48.000000000 -0500
+++ module-init-tools/moduleops_core.c	2005-01-23 01:43:21.000000000 -0500
@@ -196,6 +196,10 @@
 	module->input_size = PERBIT(INPUT_DEVICE_SIZE);
 	module->input_table = PERBIT(deref_sym)(module->data,
 					"__mod_input_device_table");
+
+	module->serio_size = PERBIT(SERIO_DEVICE_SIZE);
+	module->serio_table = PERBIT(deref_sym)(module->data,
+					"__mod_serio_device_table");
 }
 
 struct module_ops PERBIT(mod_ops) = {
diff -urN module-init-tools-3.1-pre5/tables.c module-init-tools/tables.c
--- module-init-tools-3.1-pre5/tables.c	2003-12-24 00:23:38.000000000 -0500
+++ module-init-tools/tables.c	2005-01-23 01:13:24.000000000 -0500
@@ -340,3 +340,36 @@
 		}
 	}
 }
+
+static void output_serio_entry(struct serio_device_id *serio, char *name, FILE *out)
+{
+	fprintf(out,
+		"%-20s 0x%02x 0x%02x  0x%02x 0x%02x\n",
+		name,
+		serio->type,
+		serio->extra,
+		serio->id,
+		serio->proto);
+}
+
+
+void output_serio_table(struct module *modules, FILE *out)
+{
+	struct module *i;
+
+	fprintf(out, "# serio module       type extra id   proto\n");
+
+	for (i = modules; i; i = i->next) {
+		struct serio_device_id *e;
+		char shortname[strlen(i->pathname) + 1];
+
+		if (!i->serio_table)
+			continue;
+
+		make_shortname(shortname, i->pathname);
+		for (e = i->serio_table; e->type || e->proto; e = (void *)e + i->serio_size)
+			output_serio_entry(e, shortname, out);
+	}
+}
+
+
diff -urN module-init-tools-3.1-pre5/tables.h module-init-tools/tables.h
--- module-init-tools-3.1-pre5/tables.h	2003-12-24 00:18:54.000000000 -0500
+++ module-init-tools/tables.h	2005-01-23 01:21:48.000000000 -0500
@@ -116,6 +116,15 @@
 #define INPUT_DEVICE_SIZE32 (4 + 4 * 2 + 4 + 16 * 4 + 4 + 2 * 4 + 4 + 4 + 4 + 4 * 4 + 4)
 #define INPUT_DEVICE_SIZE64 (8 + 4 * 2 + 8 + 8 * 8 + 8 + 8 + 8 + 8 + 8 + 2 * 8 + 8)
 
+struct serio_device_id {
+	unsigned char type;
+	unsigned char extra;
+	unsigned char id;
+	unsigned char proto;
+};
+#define SERIO_DEVICE_SIZE32 (4 * 1)
+#define SERIO_DEVICE_SIZE64 (4 * 1 + 4)
+
 /* Functions provided by tables.c */
 struct module;
 void output_usb_table(struct module *modules, FILE *out);
@@ -124,5 +133,6 @@
 void output_ccw_table(struct module *modules, FILE *out);
 void output_isapnp_table(struct module *modules, FILE *out);
 void output_input_table(struct module *modules, FILE *out);
+void output_serio_table(struct module *modules, FILE *out);
 
 #endif /* MODINITTOOLS_TABLES_H */
#1 lore raw
Quoted 6 lines · Dmitry Torokhov

Hi Rusty,

I have converted serio bus to use ID matching and changed serio drivers to use MODULE_DEVICE_TABLE. Now that Vojtech pulled the changes into his tree it would be nice if official module-init-tools generated the module map so that hotplug scripts could automatically load proper drivers.

Sure, applied. I would appreciated tests, however: you can download the testsuite from the same place you get module-init-tools. I don't expect you to be able to compile for all endian/size combinations, but I can do that for you.

You should also put the logic into the kernel's scripts/mod/file2alias, which is where this is supposed to go these days (I haven't removed the modules.XXX files, since hotplug has enough deployment problems without me making things worse).

Thanks,
Rusty.

Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman
#2 lore raw
Quoted 9 lines · Rusty Russell
Quoted 6 lines · Dmitry Torokhov

Hi Rusty,

I have converted serio bus to use ID matching and changed serio drivers to use MODULE_DEVICE_TABLE. Now that Vojtech pulled the changes into his tree it would be nice if official module-init-tools generated the module map so that hotplug scripts could automatically load proper drivers.

Sure, applied.

Thanks!

Quoted 4 lines

I would appreciated tests, however: you can download the testsuite from the same place you get module-init-tools. I don't expect you to be able to compile for all endian/size combinations, but I can do that for you.

Ok, I will take a look at it but it will take couple of days...

Quoted 4 lines

You should also put the logic into the kernel's scripts/mod/file2alias, which is where this is supposed to go these days (I haven't removed the modules.XXX files, since hotplug has enough deployment problems without me making things worse).

Oh, I see. I wasn't sure where it should go and FC3 hotplug uses modules.*map so I went that route. What do you think about the patch below then?

I am a little bit confused - is anybody using module aliases at the moment? I could not find anything on my box...

Signature · 116 lines
Dmitry


===================================================================


[email protected], 2005-02-07 00:14:52-05:00, [email protected]
  Input: adjust file2alias utility to export aliases for
         serio drivers (serio:tyNprNidNexN).
         Move serio_device_id from serio.h to mod_devicetable.h
  
  Signed-off-by: Dmitry Torokhov <[email protected]>


 include/linux/mod_devicetable.h |   10 ++++++++++
 include/linux/serio.h           |   10 +---------
 scripts/mod/file2alias.c        |   23 ++++++++++++++++++++++-
 3 files changed, 33 insertions(+), 10 deletions(-)


===================================================================



diff -Nru a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
--- a/include/linux/mod_devicetable.h	2005-02-07 00:15:11 -05:00
+++ b/include/linux/mod_devicetable.h	2005-02-07 00:15:11 -05:00
@@ -165,4 +165,14 @@
 };
 
 
+#define SERIO_ANY	0xff
+
+struct serio_device_id {
+	__u8 type;
+	__u8 extra;
+	__u8 id;
+	__u8 proto;
+};
+
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h	2005-02-07 00:15:11 -05:00
+++ b/include/linux/serio.h	2005-02-07 00:15:11 -05:00
@@ -19,13 +19,7 @@
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/device.h>
-
-struct serio_device_id {
-	unsigned char type;
-	unsigned char extra;
-	unsigned char id;
-	unsigned char proto;
-};
+#include <linux/mod_devicetable.h>
 
 struct serio {
 	void *port_data;
@@ -173,8 +167,6 @@
 #define SERIO_TIMEOUT	1
 #define SERIO_PARITY	2
 #define SERIO_FRAME	4
-
-#define SERIO_ANY	0xff
 
 /*
  * Serio types
diff -Nru a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
--- a/scripts/mod/file2alias.c	2005-02-07 00:15:11 -05:00
+++ b/scripts/mod/file2alias.c	2005-02-07 00:15:11 -05:00
@@ -4,7 +4,7 @@
  *
  * Copyright 2002-2003  Rusty Russell, IBM Corporation
  *           2003       Kai Germaschewski
- *           
+ *
  *
  * This software may be used and distributed according to the terms
  * of the GNU General Public License, incorporated herein by reference.
@@ -181,6 +181,24 @@
 	return 1;
 }
 
+/* Looks like: "serio:tyNprNidNexN" */
+static int do_serio_entry(const char *filename,
+			  struct serio_device_id *id, char *alias)
+{
+	id->type = TO_NATIVE(id->type);
+	id->proto = TO_NATIVE(id->proto);
+	id->id = TO_NATIVE(id->id);
+	id->extra = TO_NATIVE(id->extra);
+
+	strcpy(alias, "serio:");
+	ADD(alias, "ty", id->type != SERIO_ANY, id->type);
+	ADD(alias, "pr", id->proto != SERIO_ANY, id->proto);
+	ADD(alias, "id", id->id != SERIO_ANY, id->id);
+	ADD(alias, "ex", id->extra != SERIO_ANY, id->extra);
+
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -270,6 +288,9 @@
 	else if (sym_is(symname, "__mod_ccw_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
 			 do_ccw_entry, mod);
+	else if (sym_is(symname, "__mod_serio_device_table"))
+		do_table(symval, sym->st_size, sizeof(struct serio_device_id),
+			 do_serio_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
 			 do_pnp_entry, mod);