lkml.org 
[lkml]   [2003]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectfile2alias for pnp (Re: modules.pnpmap output support)
Hi,

the attached is the patch to add pnp entries to file2alias.c.
i moved the definitions of pnp_device_id and pnp_card_device_id into
mod_devicetable.h as other devices do. if you don't like it, i'll try
to revert them and put definitions inside file2alias.c to keep the
changes minimum.

the format of pnp alias is:
pnp:dXXXYYYY
or
pnp:cXXXYYYYdXXXYYYY[dXXXYYYY...]
where XXXYYYY is the pnp id with 7 letters (e.g. CTL0031), c shows the
card id, and d means the device id. multiple device ids will be
listed depending on the driver.
for example,

alias pnp:dYMH0021* opl3sa2
alias pnp:cALS0001d@@@0001d@X@0001d@H@0001* snd_als100

Andrey, would it be feasible for hotplug stuff?

--
Takashi Iwai <tiwai@suse.de> ALSA Developer - www.alsa-project.org
--- linux-2.6.0-test10/scripts/file2alias.c-dist 2003-11-26 17:10:34.000000000 +0100
+++ linux-2.6.0-test10/scripts/file2alias.c 2003-11-26 17:33:54.000000000 +0100
@@ -169,6 +169,28 @@
return 1;
}

+/* looks like: "pnp:dD" */
+static int do_pnp_entry(const char *filename,
+ struct pnp_device_id *id, char *alias)
+{
+ sprintf(alias, "pnp:d%s", id->id);
+ return 1;
+}
+
+/* looks like: "pnp:cCdD..." */
+static int do_pnp_card_entry(const char *filename,
+ struct pnp_card_device_id *id, char *alias)
+{
+ int i;
+ sprintf(alias, "pnp:c%s", id->id);
+ for (i = 0; i < PNP_MAX_DEVICES; i++) {
+ if (! *id->devs[i].id)
+ break;
+ sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
+ }
+ return 1;
+}
+
/* Ignore any prefix, eg. v850 prepends _ */
static inline int sym_is(const char *symbol, const char *name)
{
@@ -235,6 +257,12 @@
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_pnp_device_table"))
+ do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
+ do_pnp_entry, mod);
+ else if (sym_is(symname, "__mod_pnp_card_device_table"))
+ do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
+ do_pnp_card_entry, mod);
}

/* Now add out buffered information to the generated C source */
--- linux-2.6.0-test10/include/linux/pnp.h-dist 2003-11-26 17:23:00.000000000 +0100
+++ linux-2.6.0-test10/include/linux/pnp.h 2003-11-26 17:27:35.000000000 +0100
@@ -12,13 +12,12 @@
#include <linux/device.h>
#include <linux/list.h>
#include <linux/errno.h>
+#include <linux/mod_devicetable.h>

#define PNP_MAX_PORT 8
#define PNP_MAX_MEM 4
#define PNP_MAX_IRQ 2
#define PNP_MAX_DMA 2
-#define PNP_MAX_DEVICES 8
-#define PNP_ID_LEN 8
#define PNP_NAME_LEN 50

struct pnp_protocol;
@@ -279,19 +278,6 @@
struct pnp_id * next;
};

-struct pnp_device_id {
- char id[PNP_ID_LEN];
- unsigned long driver_data; /* data private to the driver */
-};
-
-struct pnp_card_device_id {
- char id[PNP_ID_LEN];
- unsigned long driver_data; /* data private to the driver */
- struct {
- char id[PNP_ID_LEN];
- } devs[PNP_MAX_DEVICES]; /* logical devices */
-};
-
struct pnp_driver {
char * name;
const struct pnp_device_id *id_table;
--- linux-2.6.0-test10/include/linux/mod_devicetable.h-dist 2003-11-26 17:22:57.000000000 +0100
+++ linux-2.6.0-test10/include/linux/mod_devicetable.h 2003-11-26 17:27:34.000000000 +0100
@@ -148,4 +148,20 @@
#define CCW_DEVICE_ID_MATCH_DEVICE_MODEL 0x08


+#define PNP_ID_LEN 8
+#define PNP_MAX_DEVICES 8
+
+struct pnp_device_id {
+ __u8 id[PNP_ID_LEN];
+ kernel_ulong_t driver_data; /* data private to the driver */
+};
+
+struct pnp_card_device_id {
+ __u8 id[PNP_ID_LEN];
+ kernel_ulong_t driver_data; /* data private to the driver */
+ struct {
+ __u8 id[PNP_ID_LEN];
+ } devs[PNP_MAX_DEVICES]; /* logical devices */
+};
+
#endif /* LINUX_MOD_DEVICETABLE_H */
\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2011 Jasper Spaans