Browse Source

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
Linus Torvalds 13 years ago
parent
commit
d3d0b02434

+ 4 - 0
drivers/amba/bus.c

@@ -52,6 +52,10 @@ static int amba_uevent(struct device *dev, struct kobj_uevent_env *env)
 	int retval = 0;
 	int retval = 0;
 
 
 	retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid);
 	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;
 	return retval;
 }
 }
 #else
 #else

+ 2 - 0
drivers/char/hw_random/nomadik-rng.c

@@ -95,6 +95,8 @@ static struct amba_id nmk_rng_ids[] = {
 	{0, 0},
 	{0, 0},
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, nmk_rng_ids);
+
 static struct amba_driver nmk_rng_driver = {
 static struct amba_driver nmk_rng_driver = {
 	.drv = {
 	.drv = {
 		.owner = THIS_MODULE,
 		.owner = THIS_MODULE,

+ 2 - 0
drivers/dma/amba-pl08x.c

@@ -2054,6 +2054,8 @@ static struct amba_id pl08x_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl08x_ids);
+
 static struct amba_driver pl08x_amba_driver = {
 static struct amba_driver pl08x_amba_driver = {
 	.drv.name	= DRIVER_NAME,
 	.drv.name	= DRIVER_NAME,
 	.id_table	= pl08x_ids,
 	.id_table	= pl08x_ids,

+ 2 - 0
drivers/dma/pl330.c

@@ -990,6 +990,8 @@ static struct amba_id pl330_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl330_ids);
+
 #ifdef CONFIG_PM_RUNTIME
 #ifdef CONFIG_PM_RUNTIME
 static int pl330_runtime_suspend(struct device *dev)
 static int pl330_runtime_suspend(struct device *dev)
 {
 {

+ 2 - 0
drivers/gpio/gpio-pl061.c

@@ -346,6 +346,8 @@ static struct amba_id pl061_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl061_ids);
+
 static struct amba_driver pl061_gpio_driver = {
 static struct amba_driver pl061_gpio_driver = {
 	.drv = {
 	.drv = {
 		.name	= "pl061_gpio",
 		.name	= "pl061_gpio",

+ 2 - 0
drivers/input/serio/ambakmi.c

@@ -195,6 +195,8 @@ static struct amba_id amba_kmi_idtable[] = {
 	{ 0, 0 }
 	{ 0, 0 }
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, amba_kmi_idtable);
+
 static struct amba_driver ambakmi_driver = {
 static struct amba_driver ambakmi_driver = {
 	.drv		= {
 	.drv		= {
 		.name	= "kmi-pl050",
 		.name	= "kmi-pl050",

+ 2 - 0
drivers/mmc/host/mmci.c

@@ -1502,6 +1502,8 @@ static struct amba_id mmci_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, mmci_ids);
+
 static struct amba_driver mmci_driver = {
 static struct amba_driver mmci_driver = {
 	.drv		= {
 	.drv		= {
 		.name	= DRIVER_NAME,
 		.name	= DRIVER_NAME,

+ 2 - 0
drivers/rtc/rtc-pl030.c

@@ -174,6 +174,8 @@ static struct amba_id pl030_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl030_ids);
+
 static struct amba_driver pl030_driver = {
 static struct amba_driver pl030_driver = {
 	.drv		= {
 	.drv		= {
 		.name	= "rtc-pl030",
 		.name	= "rtc-pl030",

+ 2 - 0
drivers/rtc/rtc-pl031.c

@@ -420,6 +420,8 @@ static struct amba_id pl031_ids[] = {
 	{0, 0},
 	{0, 0},
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl031_ids);
+
 static struct amba_driver pl031_driver = {
 static struct amba_driver pl031_driver = {
 	.drv = {
 	.drv = {
 		.name = "rtc-pl031",
 		.name = "rtc-pl031",

+ 2 - 0
drivers/spi/spi-pl022.c

@@ -2432,6 +2432,8 @@ static struct amba_id pl022_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl022_ids);
+
 static struct amba_driver pl022_driver = {
 static struct amba_driver pl022_driver = {
 	.drv = {
 	.drv = {
 		.name	= "ssp-pl022",
 		.name	= "ssp-pl022",

+ 2 - 0
drivers/tty/serial/amba-pl010.c

@@ -795,6 +795,8 @@ static struct amba_id pl010_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl010_ids);
+
 static struct amba_driver pl010_driver = {
 static struct amba_driver pl010_driver = {
 	.drv = {
 	.drv = {
 		.name	= "uart-pl010",
 		.name	= "uart-pl010",

+ 2 - 0
drivers/tty/serial/amba-pl011.c

@@ -1994,6 +1994,8 @@ static struct amba_id pl011_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, pl011_ids);
+
 static struct amba_driver pl011_driver = {
 static struct amba_driver pl011_driver = {
 	.drv = {
 	.drv = {
 		.name	= "uart-pl011",
 		.name	= "uart-pl011",

+ 2 - 0
drivers/video/amba-clcd.c

@@ -621,6 +621,8 @@ static struct amba_id clcdfb_id_table[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, clcdfb_id_table);
+
 static struct amba_driver clcd_driver = {
 static struct amba_driver clcd_driver = {
 	.drv 		= {
 	.drv 		= {
 		.name	= "clcd-pl11x",
 		.name	= "clcd-pl11x",

+ 2 - 0
drivers/watchdog/sp805_wdt.c

@@ -359,6 +359,8 @@ static struct amba_id sp805_wdt_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, sp805_wdt_ids);
+
 static struct amba_driver sp805_wdt_driver = {
 static struct amba_driver sp805_wdt_driver = {
 	.drv = {
 	.drv = {
 		.name	= MODULE_NAME,
 		.name	= MODULE_NAME,

+ 1 - 6
include/linux/amba/bus.h

@@ -16,6 +16,7 @@
 
 
 #include <linux/clk.h>
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/err.h>
 #include <linux/err.h>
 #include <linux/resource.h>
 #include <linux/resource.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regulator/consumer.h>
@@ -35,12 +36,6 @@ struct amba_device {
 	unsigned int		irq[AMBA_NR_IRQS];
 	unsigned int		irq[AMBA_NR_IRQS];
 };
 };
 
 
-struct amba_id {
-	unsigned int		id;
-	unsigned int		mask;
-	void			*data;
-};
-
 struct amba_driver {
 struct amba_driver {
 	struct device_driver	drv;
 	struct device_driver	drv;
 	int			(*probe)(struct amba_device *, const struct amba_id *);
 	int			(*probe)(struct amba_device *, const struct amba_id *);

+ 18 - 0
include/linux/mod_devicetable.h

@@ -542,4 +542,22 @@ struct isapnp_device_id {
 	kernel_ulong_t driver_data;	/* data private to the driver */
 	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 */
 #endif /* LINUX_MOD_DEVICETABLE_H */

+ 72 - 0
scripts/mod/file2alias.c

@@ -880,6 +880,74 @@ static int do_isapnp_entry(const char *filename,
 	return 1;
 	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 _ */
 /* Ignore any prefix, eg. some architectures prepend _ */
 static inline int sym_is(const char *symbol, const char *name)
 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,
 		do_table(symval, sym->st_size,
 			sizeof(struct isapnp_device_id), "isa",
 			sizeof(struct isapnp_device_id), "isa",
 			do_isapnp_entry, mod);
 			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);
 	free(zeros);
 }
 }
 
 

+ 2 - 0
sound/arm/aaci.c

@@ -1097,6 +1097,8 @@ static struct amba_id aaci_ids[] = {
 	{ 0, 0 },
 	{ 0, 0 },
 };
 };
 
 
+MODULE_DEVICE_TABLE(amba, aaci_ids);
+
 static struct amba_driver aaci_driver = {
 static struct amba_driver aaci_driver = {
 	.drv		= {
 	.drv		= {
 		.name	= DRIVER_NAME,
 		.name	= DRIVER_NAME,