From 1e5f9a23430e64fb56d9d5d8e1ca165ba1cfeb75 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 14:40:59 +0100 Subject: [PATCH 01/16] ARM: amba: Move definition of struct amba_id to mod_devicetable.h The general kernel infrastructure for adding module alises during module post processing expects the affected device type identification structures in a common header . This patch simple moves struct amba_id to the common header, and adds the appropriate include in . Signed-off-by: Dave Martin --- include/linux/amba/bus.h | 7 +------ include/linux/mod_devicetable.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index fcbbe71a3cc1..724c69c40bb8 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -35,12 +36,6 @@ struct amba_device { unsigned int irq[AMBA_NR_IRQS]; }; -struct amba_id { - unsigned int id; - unsigned int mask; - void *data; -}; - struct amba_driver { struct device_driver drv; int (*probe)(struct amba_device *, const struct amba_id *); diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 468819cdde87..83ac0713ed0a 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -542,4 +542,22 @@ struct isapnp_device_id { kernel_ulong_t driver_data; /* data private to the driver */ }; +/** + * struct amba_id - identifies a device on an AMBA bus + * @id: The significant bits if the hardware device ID + * @mask: Bitmask specifying which bits of the id field are significant when + * matching. A driver binds to a device when ((hardware device ID) & mask) + * == id. + * @data: Private data used by the driver. + */ +struct amba_id { + unsigned int id; + unsigned int mask; +#ifndef __KERNEL__ + kernel_ulong_t data; +#else + void *data; +#endif +}; + #endif /* LINUX_MOD_DEVICETABLE_H */ From 523817bd22617cd62199ae4ca2a6f5e1aa250654 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 14:44:57 +0100 Subject: [PATCH 02/16] ARM: amba: Auto-generate AMBA driver module aliases during modpost This patch adds the necessary support in file2alias.c to define suitable aliases based on the amba_id table in AMBA driver modules. This should be sufficient to allow such modules to be auto-loaded via udev. The AMBA bus driver's uevent hotplug code is also modified to pass an approriate MODALIAS string in the event. For simplicity, the AMBA ID is treated an an opaque 32-bit numeber. Module alises use patterns as appropriate to describe the value- mask pairs described in the driver's amba_id list. The proposed alias format is (extended regex): ^amba:d(HEX){8}$ Where HEX is a single upper-case HEX digit or a pattern (? or [] expression) matching a single upper-case HEX digit, as expected by udev. "d" is short for "device", following existing alias naming conventions for other device types. This adds some flexibility for unambiguously extending the alias format in the future by adding additional leading and trailing fields, if this turns out to be necessary. Signed-off-by: Dave Martin Acked-by: Pawel Moll --- drivers/amba/bus.c | 4 +++ scripts/mod/file2alias.c | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index bd230e801131..936c98cb2475 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -52,6 +52,10 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env) int retval = 0; retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid); + if (retval) + return retval; + + retval = add_uevent_var(env, "MODALIAS=amba:d%08X", pcdev->periphid); return retval; } #else diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index f936d1fa969d..363ab4666b17 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -880,6 +880,74 @@ static int do_isapnp_entry(const char *filename, return 1; } +/* + * Append a match expression for a single masked hex digit. + * outp points to a pointer to the character at which to append. + * *outp is updated on return to point just after the appended text, + * to facilitate further appending. + */ +static void append_nibble_mask(char **outp, + unsigned int nibble, unsigned int mask) +{ + char *p = *outp; + unsigned int i; + + switch (mask) { + case 0: + *p++ = '?'; + break; + + case 0xf: + p += sprintf(p, "%X", nibble); + break; + + default: + /* + * Dumbly emit a match pattern for all possible matching + * digits. This could be improved in some cases using ranges, + * but it has the advantage of being trivially correct, and is + * often optimal. + */ + *p++ = '['; + for (i = 0; i < 0x10; i++) + if ((i & mask) == nibble) + p += sprintf(p, "%X", i); + *p++ = ']'; + } + + /* Ensure that the string remains NUL-terminated: */ + *p = '\0'; + + /* Advance the caller's end-of-string pointer: */ + *outp = p; +} + +/* + * looks like: "amba:dN" + * + * N is exactly 8 digits, where each is an upper-case hex digit, or + * a ? or [] pattern matching exactly one digit. + */ +static int do_amba_entry(const char *filename, + struct amba_id *id, char *alias) +{ + unsigned int digit; + char *p = alias; + + if ((id->id & id->mask) != id->id) + fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " + "id=0x%08X, mask=0x%08X. Please fix this driver.\n", + filename, id->id, id->mask); + + p += sprintf(alias, "amba:d"); + for (digit = 0; digit < 8; digit++) + append_nibble_mask(&p, + (id->id >> (4 * (7 - digit))) & 0xf, + (id->mask >> (4 * (7 - digit))) & 0xf); + + return 1; +} + /* Ignore any prefix, eg. some architectures prepend _ */ static inline int sym_is(const char *symbol, const char *name) { @@ -1047,6 +1115,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct isapnp_device_id), "isa", do_isapnp_entry, mod); + else if (sym_is(symname, "__mod_amba_device_table")) + do_table(symval, sym->st_size, + sizeof(struct amba_id), "amba", + do_amba_entry, mod); free(zeros); } From 4e3f3d53b8b5d597e36c075e01014e9019a44d55 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:20 +0100 Subject: [PATCH 03/16] hwrng: nomadik: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/char/hw_random/nomadik-rng.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c index 52e08ca3ccd7..3d3c1e6703b4 100644 --- a/drivers/char/hw_random/nomadik-rng.c +++ b/drivers/char/hw_random/nomadik-rng.c @@ -95,6 +95,8 @@ static struct amba_id nmk_rng_ids[] = { {0, 0}, }; +MODULE_DEVICE_TABLE(amba, nmk_rng_ids); + static struct amba_driver nmk_rng_driver = { .drv = { .owner = THIS_MODULE, From 037566df2a9274cec49cab131059e1bac538be08 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:20 +0100 Subject: [PATCH 04/16] dmaengine: pl08x: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin Acked-by: Vinod Koul --- drivers/dma/amba-pl08x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index b7cbd1ab1db1..0698695e8bf9 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c @@ -2054,6 +2054,8 @@ static struct amba_id pl08x_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl08x_ids); + static struct amba_driver pl08x_amba_driver = { .drv.name = DRIVER_NAME, .id_table = pl08x_ids, From e8fa516a4231682204d646df01c7bf3f0cfe4893 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:20 +0100 Subject: [PATCH 05/16] dmaengine: pl330: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin Acked-by: Jassi Brar Acked-by: Vinod Koul --- drivers/dma/pl330.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 571041477ab2..2d8d1b041d95 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -990,6 +990,8 @@ static struct amba_id pl330_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl330_ids); + #ifdef CONFIG_PM_RUNTIME static int pl330_runtime_suspend(struct device *dev) { From 955b678c03645117c4ad5e52c9946a25e3ca3199 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:21 +0100 Subject: [PATCH 06/16] gpio: pl061: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin Acked-by: Grant Likely --- drivers/gpio/gpio-pl061.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 093c90bd3c1d..8efc3dd1286f 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -350,6 +350,8 @@ static struct amba_id pl061_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl061_ids); + static struct amba_driver pl061_gpio_driver = { .drv = { .name = "pl061_gpio", From 2dfff235918276638875a1d094f061083ccd6de8 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:21 +0100 Subject: [PATCH 07/16] input: ambakmi: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin Acked-by: Dmitry Torokhov --- drivers/input/serio/ambakmi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index 12abc50508e5..8407d5b0ced8 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -195,6 +195,8 @@ static struct amba_id amba_kmi_idtable[] = { { 0, 0 } }; +MODULE_DEVICE_TABLE(amba, amba_kmi_idtable); + static struct amba_driver ambakmi_driver = { .drv = { .name = "kmi-pl050", From 9f99835f1121bf81f1323b6267ea2957a179da2b Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:21 +0100 Subject: [PATCH 08/16] mmc: mmci: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/mmc/host/mmci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 50b5f9926f64..05d6a91d0382 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1496,6 +1496,8 @@ static struct amba_id mmci_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, mmci_ids); + static struct amba_driver mmci_driver = { .drv = { .name = DRIVER_NAME, From 66bce5916b8d4c85876e59bb1db55071baea2680 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:21 +0100 Subject: [PATCH 09/16] rtc: pl030: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/rtc/rtc-pl030.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index 1d28d4451dae..02111fee077e 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -174,6 +174,8 @@ static struct amba_id pl030_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl030_ids); + static struct amba_driver pl030_driver = { .drv = { .name = "rtc-pl030", From f5feac2a333b2813a78d5d8749fa0a97cb26acee Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:22 +0100 Subject: [PATCH 10/16] rtc: pl031: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/rtc/rtc-pl031.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index ff1b84bd9bb5..a952c8de1dd7 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -420,6 +420,8 @@ static struct amba_id pl031_ids[] = { {0, 0}, }; +MODULE_DEVICE_TABLE(amba, pl031_ids); + static struct amba_driver pl031_driver = { .drv = { .name = "rtc-pl031", From 7eeac71b9fc9b3de3e0dc24ef34180a0bc0eb2f9 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:22 +0100 Subject: [PATCH 11/16] spi: pl022: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin Acked-by: Grant Likely Acked-by: Linus Walleij --- drivers/spi/spi-pl022.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index f103e470cb63..43abaf22ec47 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2424,6 +2424,8 @@ static struct amba_id pl022_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl022_ids); + static struct amba_driver pl022_driver = { .drv = { .name = "ssp-pl022", From a664a119c05bd5784280b337e781b5e9432c6e12 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:22 +0100 Subject: [PATCH 12/16] serial: pl010: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/tty/serial/amba-pl010.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index efdf92c3a352..0d91a540bf11 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -795,6 +795,8 @@ static struct amba_id pl010_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl010_ids); + static struct amba_driver pl010_driver = { .drv = { .name = "uart-pl010", From 60f7a33b826148fd96cfa8a9e10b84ef444e78fe Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:22 +0100 Subject: [PATCH 13/16] serial: pl011: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/tty/serial/amba-pl011.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 00233af1acc4..6958594f2fc0 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1994,6 +1994,8 @@ static struct amba_id pl011_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, pl011_ids); + static struct amba_driver pl011_driver = { .drv = { .name = "uart-pl011", From 6054f9b83cb62746bc0c002dd56364c262779856 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:23 +0100 Subject: [PATCH 14/16] fbdev: amba: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/video/amba-clcd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 2cda6ba0939b..0a2cce7285be 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -621,6 +621,8 @@ static struct amba_id clcdfb_id_table[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, clcdfb_id_table); + static struct amba_driver clcd_driver = { .drv = { .name = "clcd-pl11x", From 17885b05b31c0d310f859982d2a56f167274547e Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:15:23 +0100 Subject: [PATCH 15/16] watchdog: sp805: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- drivers/watchdog/sp805_wdt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index cc2cfbe33b30..c0a0ecec4d0c 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -359,6 +359,8 @@ static struct amba_id sp805_wdt_ids[] __initdata = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, sp805_wdt_ids); + static struct amba_driver sp805_wdt_driver = { .drv = { .name = MODULE_NAME, From 9d5c627323dcf0983d699d26dd486272fc98bef2 Mon Sep 17 00:00:00 2001 From: Dave Martin Date: Wed, 5 Oct 2011 15:50:36 +0100 Subject: [PATCH 16/16] sound: aaci: Enable module alias autogeneration for AMBA drivers Signed-off-by: Dave Martin --- sound/arm/aaci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index e518d38b1c74..b37b702a3a6a 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -1097,6 +1097,8 @@ static struct amba_id aaci_ids[] = { { 0, 0 }, }; +MODULE_DEVICE_TABLE(amba, aaci_ids); + static struct amba_driver aaci_driver = { .drv = { .name = DRIVER_NAME,