From: Ondrej Zary <linux@rainbow-software.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org,
Jon Masters <jonathan@jonmasters.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
Greg KH <gregkh@suse.de>
Subject: Re: MODULE_DEVICE_TABLE(isapnp, ...) does nothing
Date: Fri, 18 Dec 2009 20:52:39 +0100 [thread overview]
Message-ID: <200912182052.42477.linux@rainbow-software.org> (raw)
In-Reply-To: <200911231359.54544.rusty@rustcorp.com.au>
On Monday 23 November 2009 04:29:53 Rusty Russell wrote:
> On Mon, 23 Nov 2009 07:31:57 am Ondrej Zary wrote:
> > The problem is that
> > scripts/mod/file2alias.c simply ignores isapnp.
>
> AFAICT it always has, and noone has complained until now. Perhaps
> something was still reading /lib/modules/`uname -r`/modules.isapnpmap?
>
> Two things are required:
> 1) Modify file2alias to add aliases for isapnp. This is pretty easy.
> 2) Expose the isapnp devices in sysfs where udev will match them up
> (/sys/bus/isa/devices/<dev>/modalias I guess?)
>
> The first patches would look something like these. We could mangle the
> PNP names a-la ISAPNP_VENDOR/ISAPNP_DEVICE, but as long as the published
> modalias matches the file2alias result, it doesn't matter.
>
> Jaroslav? Greg? Patches for sysfs welcome...
>
> Thanks,
> Rusty.
> PS. Jon, perhaps the new decade is a good time to kill modules.*map?
>
> isapnp: move definitions to mod_devicetable.h so file2alias can reach them.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h
> --- a/include/linux/isapnp.h
> +++ b/include/linux/isapnp.h
> @@ -43,10 +43,10 @@
> */
>
> #ifdef __KERNEL__
> +#include <linux/mod_devicetable.h>
>
> #define DEVICE_COUNT_COMPATIBLE 4
>
> -#define ISAPNP_ANY_ID 0xffff
> #define ISAPNP_CARD_DEVS 8
>
> #define ISAPNP_CARD_ID(_va, _vb, _vc, _device) \
> @@ -74,12 +74,6 @@ struct isapnp_card_id {
> #define ISAPNP_DEVICE_SINGLE_END \
> .card_vendor = 0, .card_device = 0
>
> -struct isapnp_device_id {
> - unsigned short card_vendor, card_device;
> - unsigned short vendor, function;
> - unsigned long driver_data; /* data private to the driver */
> -};
> -
> #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) &&
> defined(MODULE))
>
> #define __ISAPNP__
> diff --git a/include/linux/mod_devicetable.h
> b/include/linux/mod_devicetable.h --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -474,4 +474,11 @@ struct platform_device_id {
> __attribute__((aligned(sizeof(kernel_ulong_t))));
> };
>
> +#define ISAPNP_ANY_ID 0xffff
> +struct isapnp_device_id {
> + unsigned short card_vendor, card_device;
> + unsigned short vendor, function;
> + kernel_ulong_t driver_data; /* data private to the driver */
> +};
> +
> #endif /* LINUX_MOD_DEVICETABLE_H */
>
>
> isapnp: put aliases in .modinfo so modinfo can find them.
>
> Once isa devices publish a modalias field, I think udev should "Just Work".
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
> --- a/scripts/mod/file2alias.c
> +++ b/scripts/mod/file2alias.c
> @@ -727,6 +727,19 @@ static int do_platform_entry(const char
> return 1;
> }
>
> +/* Format is: isa:cvNcdNvNfN */
> +static int do_isapnp_entry(const char *filename,
> + struct isapnp_device_id *id, char *alias)
> +{
> + strcpy(alias, "isa:");
> + ADD(alias, "cv", id->card_vendor != ISAPNP_ANY_ID, id->card_vendor);
> + ADD(alias, "cd", id->card_device != ISAPNP_ANY_ID, id->card_device);
> + ADD(alias, "v", id->vendor != ISAPNP_ANY_ID, id->vendor);
> + ADD(alias, "f", id->function, id->function);
> + add_wildcard(alias);
> + return 1;
> +}
> +
> /* Ignore any prefix, eg. some architectures prepend _ */
> static inline int sym_is(const char *symbol, const char *name)
> {
> @@ -874,6 +887,10 @@ void handle_moddevtable(struct module *m
> do_table(symval, sym->st_size,
> sizeof(struct platform_device_id), "platform",
> do_platform_entry, mod);
> + else if (sym_is(symname, "__mod_isapnp_device_table"))
> + do_table(symval, sym->st_size,
> + sizeof(struct isapnp_device_id), "isa",
> + do_isapnp_entry, mod);
> free(zeros);
> }
The above patch did not work. However, the patch below works fine (at least
with Debian). It needs your first patch that moves the definitions to
mod_devicetable.h. Verified that aliases for these modules are generated
correctly:
drivers/media/radio/radio-sf16fmi.c
drivers/net/ne.c
drivers/net/3c515.c
drivers/net/smc-ultra.c
drivers/pcmcia/i82365.c
drivers/scsi/aha1542.c
drivers/scsi/aha152x.c
drivers/scsi/sym53c416.c
drivers/scsi/g_NCR5380.c
Tested with RTL8019AS (ne), AVA-1505AE (aha152x) and dtc436e (g_NCR5380)
cards - they now work automatically.
Found that drivers/isdn/hisax/hisax_fcpcipnp.c has broken pnp device table -
wrong type (isapnp instead of pnp) and also ending record missing.
Generate pnp:d aliases for isapnp_device_tables. This allows udev to load
these modules automatically.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
--- linux-source-2.6.32-orig/scripts/mod/file2alias.c 2009-12-03 04:51:21.000000000 +0100
+++ linux-source-2.6.32/scripts/mod/file2alias.c 2009-12-18 20:20:57.000000000 +0100
@@ -727,6 +727,19 @@ static int do_platform_entry(const char
return 1;
}
+/* looks like: "pnp:dD" */
+static int do_isapnp_entry(const char *filename,
+ struct isapnp_device_id *id, char *alias)
+{
+ sprintf(alias, "pnp:d%c%c%c%x%x%x%x*",
+ 'A' + ((id->vendor >> 2) & 0x3f) - 1,
+ 'A' + (((id->vendor & 3) << 3) | ((id->vendor >> 13) & 7)) - 1,
+ 'A' + ((id->vendor >> 8) & 0x1f) - 1,
+ (id->function >> 4) & 0x0f, id->function & 0x0f,
+ (id->function >> 12) & 0x0f, (id->function >> 8) & 0x0f);
+ return 1;
+}
+
/* Ignore any prefix, eg. some architectures prepend _ */
static inline int sym_is(const char *symbol, const char *name)
{
@@ -874,6 +887,10 @@ void handle_moddevtable(struct module *m
do_table(symval, sym->st_size,
sizeof(struct platform_device_id), "platform",
do_platform_entry, mod);
+ else if (sym_is(symname, "__mod_isapnp_device_table"))
+ do_table(symval, sym->st_size,
+ sizeof(struct isapnp_device_id), "isa",
+ do_isapnp_entry, mod);
free(zeros);
}
hisax_fcpcipnp: fix broken isapnp device table.
--- linux-source-2.6.32-orig/drivers/isdn/hisax/hisax_fcpcipnp.c 2009-12-03 04:51:21.000000000 +0100
+++ linux-source-2.6.32/drivers/isdn/hisax/hisax_fcpcipnp.c 2009-12-17 23:55:08.000000000 +0100
@@ -74,9 +74,10 @@ static struct pnp_device_id fcpnp_ids[]
.id = "AVM0900",
.driver_data = (unsigned long) "Fritz!Card PnP",
},
+ { .id = "" }
};
-MODULE_DEVICE_TABLE(isapnp, fcpnp_ids);
+MODULE_DEVICE_TABLE(pnp, fcpnp_ids);
#endif
static int protocol = 2; /* EURO-ISDN Default */
--
Ondrej Zary
next prev parent reply other threads:[~2009-12-18 19:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-22 21:01 MODULE_DEVICE_TABLE(isapnp, ...) does nothing Ondrej Zary
2009-11-23 3:29 ` Rusty Russell
2009-11-23 8:40 ` Takashi Iwai
2009-11-23 14:13 ` Kay Sievers
2009-11-24 7:29 ` Ondrej Zary
2009-11-24 8:57 ` Kay Sievers
2009-11-24 21:23 ` Ondrej Zary
2009-11-25 12:05 ` Kay Sievers
2009-11-25 13:21 ` Ondrej Zary
2009-11-25 14:42 ` Matthieu CASTET
2009-11-25 15:23 ` Kay Sievers
2009-11-23 21:51 ` Rusty Russell
2009-11-24 8:53 ` Kay Sievers
2009-11-24 23:51 ` Rusty Russell
2009-11-25 11:39 ` Kay Sievers
2009-11-25 17:17 ` Ondrej Zary
2009-12-18 19:52 ` Ondrej Zary [this message]
2009-12-21 10:24 ` Rusty Russell
2010-03-22 13:44 ` Ondrej Zary
2010-03-31 3:50 ` Rusty Russell
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=200912182052.42477.linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=gregkh@suse.de \
--cc=jonathan@jonmasters.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=rusty@rustcorp.com.au \
--cc=tiwai@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.