public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Rusty Russell <rusty@rustcorp.com.au>,
	Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] add module device table support for ccw devices
Date: Wed, 7 May 2003 14:46:19 +0200	[thread overview]
Message-ID: <200305071446.19880.arnd@arndb.de> (raw)

The recent addition of ieee1394 device table support reminded me that
I had this patch around for a long time. It adds module aliases
to device drivers for s390 ccw devices.

	Arnd <><

Index: ./include/asm-s390/ccwdev.h
===================================================================
RCS file: /home/cvs/linux-2.5/include/asm-s390/ccwdev.h,v
retrieving revision 1.37
diff -u -r1.37 ccwdev.h
--- ./include/asm-s390/ccwdev.h	27 Mar 2003 14:39:43 -0000	1.37
+++ ./include/asm-s390/ccwdev.h	7 May 2003 11:48:06 -0000
@@ -11,38 +11,11 @@
 #define _S390_CCWDEV_H_
 
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 /* structs from asm/cio.h */
 struct irb;
 struct ccw1;
-
-/* the id is used to identify what hardware a device driver supports. It 
- * is used both by the ccw subsystem driver for probing and from
- * user space for automatic module loading.
- *
- * References:
- *   - struct usb_device_id (include/linux/usb.h)
- *   - devreg_hc_t (include/linux/s390dyn.h)
- *   - chandev_model_info (drivers/s390/misc/chandev.c)
- */
-struct ccw_device_id {
-	__u16	match_flags;	/* which fields to match against */
-
-	__u16	cu_type;	/* control unit type     */
-	__u16	dev_type;	/* device type           */
-	__u8	cu_model;	/* control unit model    */
-	__u8	dev_model;	/* device model          */
-
-	unsigned long driver_info;
-};
-
-enum match_flag {
-	CCW_DEVICE_ID_MATCH_CU_TYPE      = 0x01,
-	CCW_DEVICE_ID_MATCH_CU_MODEL     = 0x02,
-	CCW_DEVICE_ID_MATCH_DEVICE_TYPE  = 0x04,
-	CCW_DEVICE_ID_MATCH_DEVICE_MODEL = 0x08,
-	/* CCW_DEVICE_ID_MATCH_ANY	     = 0x10, */
-};
 
 /* simplified initializers for struct ccw_device:
  * CCW_DEVICE and CCW_DEVICE_DEVTYPE initialize one
Index: ./include/linux/mod_devicetable.h
===================================================================
RCS file: /home/cvs/linux-2.5/include/linux/mod_devicetable.h,v
retrieving revision 1.2
diff -u -r1.2 mod_devicetable.h
--- ./include/linux/mod_devicetable.h	6 May 2003 09:41:26 -0000	1.2
+++ ./include/linux/mod_devicetable.h	7 May 2003 11:48:06 -0000
@@ -130,4 +130,22 @@
 #define USB_DEVICE_ID_MATCH_INT_SUBCLASS	0x0100
 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL	0x0200
 
+/* s390 CCW devices */
+struct ccw_device_id {
+	__u16	match_flags;	/* which fields to match against */
+
+	__u16	cu_type;	/* control unit type     */
+	__u16	dev_type;	/* device type           */
+	__u8	cu_model;	/* control unit model    */
+	__u8	dev_model;	/* device model          */
+
+	kernel_ulong_t driver_info;
+};
+
+#define CCW_DEVICE_ID_MATCH_CU_TYPE		0x01,
+#define CCW_DEVICE_ID_MATCH_CU_MODEL		0x02,
+#define CCW_DEVICE_ID_MATCH_DEVICE_TYPE		0x04,
+#define CCW_DEVICE_ID_MATCH_DEVICE_MODEL	0x08,
+
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
Index: scripts/file2alias.c
===================================================================
RCS file: /home/cvs/linux-2.5/scripts/file2alias.c,v
retrieving revision 1.3
diff -u -r1.3 file2alias.c
--- scripts/file2alias.c	6 May 2003 09:41:41 -0000	1.3
+++ scripts/file2alias.c	7 May 2003 11:48:06 -0000
@@ -147,6 +147,28 @@
 	return 1;
 }
 
+/* looks like: "ccw:tNmNdtNdmN" */ 
+static int do_ccw_entry(const char *filename,
+			struct ccw_device_id *id, char *alias)
+{
+	id->match_flags = TO_NATIVE(id->match_flags);
+	id->cu_type = TO_NATIVE(id->cu_type);
+	id->cu_model = TO_NATIVE(id->cu_model);
+	id->dev_type = TO_NATIVE(id->dev_type);
+	id->dev_model = TO_NATIVE(id->dev_model);
+
+	strcpy(alias, "ccw:");
+	ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
+	    id->cu_type);
+	ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
+	    id->cu_model);
+	ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
+	    id->dev_type);
+	ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
+	    id->dev_model);
+	return 1;
+}
+
 /* Ignore any prefix, eg. v850 prepends _ */
 static inline int sym_is(const char *symbol, const char *name)
 {
@@ -210,6 +232,9 @@
 	else if (sym_is(symname, "__mod_ieee1394_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
 			 do_ieee1394_entry, mod);
+	else if (sym_is(symname, "__mod_ccw_device_table"))
+		do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
+			 do_ccw_entry, mod);
 }
 
 /* Now add out buffered information to the generated C source */


                 reply	other threads:[~2003-05-07 12:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200305071446.19880.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=kai@tp1.ruhr-uni-bochum.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox