summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 18:03:30 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-06 18:03:30 -0800
commitd3d0b024348c040f0d6851e2e59fc961677d5169 (patch)
treeab018edaa027ad069c54beb9cb3d0c5b5efc2198 /scripts
parent6ed23fd6c08b3ffa17c1f841098d2fa2ab3a59dd (diff)
parent9d5c627323dcf0983d699d26dd486272fc98bef2 (diff)
downloadlinux-d3d0b024348c040f0d6851e2e59fc961677d5169.tar.gz
linux-d3d0b024348c040f0d6851e2e59fc961677d5169.tar.bz2
linux-d3d0b024348c040f0d6851e2e59fc961677d5169.zip
Merge branch 'amba-modalias' of git://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm
* 'amba-modalias' of git://ftp.arm.linux.org.uk/pub/linux/arm/kernel/git-cur/linux-2.6-arm: sound: aaci: Enable module alias autogeneration for AMBA drivers watchdog: sp805: Enable module alias autogeneration for AMBA drivers fbdev: amba: Enable module alias autogeneration for AMBA drivers serial: pl011: Enable module alias autogeneration for AMBA drivers serial: pl010: Enable module alias autogeneration for AMBA drivers spi: pl022: Enable module alias autogeneration for AMBA drivers rtc: pl031: Enable module alias autogeneration for AMBA drivers rtc: pl030: Enable module alias autogeneration for AMBA drivers mmc: mmci: Enable module alias autogeneration for AMBA drivers input: ambakmi: Enable module alias autogeneration for AMBA drivers gpio: pl061: Enable module alias autogeneration for AMBA drivers dmaengine: pl330: Enable module alias autogeneration for AMBA drivers dmaengine: pl08x: Enable module alias autogeneration for AMBA drivers hwrng: nomadik: Enable module alias autogeneration for AMBA drivers ARM: amba: Auto-generate AMBA driver module aliases during modpost ARM: amba: Move definition of struct amba_id to mod_devicetable.h
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/file2alias.c72
1 files changed, 72 insertions, 0 deletions
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);
}