diff options
| author | Jeff Mahoney <jeffm@suse.com> | 2005-07-06 15:44:41 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-06 15:55:20 -0400 |
| commit | 5e6557722e69840506eb8bc5a1edcdb4e447a917 (patch) | |
| tree | 965d19e55a56d2daaed47711c01a8c27e29e592c | |
| parent | 159f597a8bd0f1d7650d5e580c93a2666c9c26d1 (diff) | |
[PATCH] openfirmware: generate device table for userspace
This converts the usage of struct of_match to struct of_device_id,
similar to pci_device_id. This allows a device table to be generated,
which can be parsed by depmod(8) to generate a map file for module
loading.
In order for hotplug to work with macio devices, patches to
module-init-tools and hotplug must be applied. Those patches are
available at:
ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | arch/ppc/syslib/of_device.c | 15 | ||||
| -rw-r--r-- | arch/ppc64/kernel/of_device.c | 15 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-keywest.c | 7 | ||||
| -rw-r--r-- | drivers/ide/ppc/pmac.c | 12 | ||||
| -rw-r--r-- | drivers/macintosh/macio_asic.c | 4 | ||||
| -rw-r--r-- | drivers/macintosh/mediabay.c | 7 | ||||
| -rw-r--r-- | drivers/macintosh/therm_pm72.c | 9 | ||||
| -rw-r--r-- | drivers/macintosh/therm_windtunnel.c | 6 | ||||
| -rw-r--r-- | drivers/net/bmac.c | 7 | ||||
| -rw-r--r-- | drivers/net/mace.c | 6 | ||||
| -rw-r--r-- | drivers/net/wireless/airport.c | 8 | ||||
| -rw-r--r-- | drivers/scsi/mac53c94.c | 7 | ||||
| -rw-r--r-- | drivers/scsi/mesh.c | 8 | ||||
| -rw-r--r-- | drivers/serial/pmac_zilog.c | 9 | ||||
| -rw-r--r-- | drivers/video/platinumfb.c | 6 | ||||
| -rw-r--r-- | include/asm-ppc/macio.h | 5 | ||||
| -rw-r--r-- | include/asm-ppc/of_device.h | 20 | ||||
| -rw-r--r-- | include/linux/mod_devicetable.h | 11 | ||||
| -rw-r--r-- | scripts/mod/file2alias.c | 22 |
19 files changed, 91 insertions, 93 deletions
diff --git a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c index 49c0e34e2d6..1eb4f726ca9 100644 --- a/arch/ppc/syslib/of_device.c +++ b/arch/ppc/syslib/of_device.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
| 4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
| 5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
| 6 | #include <linux/mod_devicetable.h> | ||
| 6 | #include <asm/errno.h> | 7 | #include <asm/errno.h> |
| 7 | #include <asm/of_device.h> | 8 | #include <asm/of_device.h> |
| 8 | 9 | ||
| @@ -15,20 +16,20 @@ | |||
| 15 | * Used by a driver to check whether an of_device present in the | 16 | * Used by a driver to check whether an of_device present in the |
| 16 | * system is in its list of supported devices. | 17 | * system is in its list of supported devices. |
| 17 | */ | 18 | */ |
| 18 | const struct of_match * of_match_device(const struct of_match *matches, | 19 | const struct of_device_id * of_match_device(const struct of_device_id *matches, |
| 19 | const struct of_device *dev) | 20 | const struct of_device *dev) |
| 20 | { | 21 | { |
| 21 | if (!dev->node) | 22 | if (!dev->node) |
| 22 | return NULL; | 23 | return NULL; |
| 23 | while (matches->name || matches->type || matches->compatible) { | 24 | while (matches->name[0] || matches->type[0] || matches->compatible[0]) { |
| 24 | int match = 1; | 25 | int match = 1; |
| 25 | if (matches->name && matches->name != OF_ANY_MATCH) | 26 | if (matches->name[0]) |
| 26 | match &= dev->node->name | 27 | match &= dev->node->name |
| 27 | && !strcmp(matches->name, dev->node->name); | 28 | && !strcmp(matches->name, dev->node->name); |
| 28 | if (matches->type && matches->type != OF_ANY_MATCH) | 29 | if (matches->type[0]) |
| 29 | match &= dev->node->type | 30 | match &= dev->node->type |
| 30 | && !strcmp(matches->type, dev->node->type); | 31 | && !strcmp(matches->type, dev->node->type); |
| 31 | if (matches->compatible && matches->compatible != OF_ANY_MATCH) | 32 | if (matches->compatible[0]) |
| 32 | match &= device_is_compatible(dev->node, | 33 | match &= device_is_compatible(dev->node, |
| 33 | matches->compatible); | 34 | matches->compatible); |
| 34 | if (match) | 35 | if (match) |
| @@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv) | |||
| 42 | { | 43 | { |
| 43 | struct of_device * of_dev = to_of_device(dev); | 44 | struct of_device * of_dev = to_of_device(dev); |
| 44 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); | 45 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); |
| 45 | const struct of_match * matches = of_drv->match_table; | 46 | const struct of_device_id * matches = of_drv->match_table; |
| 46 | 47 | ||
| 47 | if (!matches) | 48 | if (!matches) |
| 48 | return 0; | 49 | return 0; |
| @@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev) | |||
| 75 | int error = -ENODEV; | 76 | int error = -ENODEV; |
| 76 | struct of_platform_driver *drv; | 77 | struct of_platform_driver *drv; |
| 77 | struct of_device *of_dev; | 78 | struct of_device *of_dev; |
| 78 | const struct of_match *match; | 79 | const struct of_device_id *match; |
| 79 | 80 | ||
| 80 | drv = to_of_platform_driver(dev->driver); | 81 | drv = to_of_platform_driver(dev->driver); |
| 81 | of_dev = to_of_device(dev); | 82 | of_dev = to_of_device(dev); |
diff --git a/arch/ppc64/kernel/of_device.c b/arch/ppc64/kernel/of_device.c index 66bd5ab7c25..b80e81984ba 100644 --- a/arch/ppc64/kernel/of_device.c +++ b/arch/ppc64/kernel/of_device.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
| 4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
| 5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
| 6 | #include <linux/mod_devicetable.h> | ||
| 6 | #include <asm/errno.h> | 7 | #include <asm/errno.h> |
| 7 | #include <asm/of_device.h> | 8 | #include <asm/of_device.h> |
| 8 | 9 | ||
| @@ -15,20 +16,20 @@ | |||
| 15 | * Used by a driver to check whether an of_device present in the | 16 | * Used by a driver to check whether an of_device present in the |
| 16 | * system is in its list of supported devices. | 17 | * system is in its list of supported devices. |
| 17 | */ | 18 | */ |
| 18 | const struct of_match * of_match_device(const struct of_match *matches, | 19 | const struct of_device_id *of_match_device(const struct of_device_id *matches, |
| 19 | const struct of_device *dev) | 20 | const struct of_device *dev) |
| 20 | { | 21 | { |
| 21 | if (!dev->node) | 22 | if (!dev->node) |
| 22 | return NULL; | 23 | return NULL; |
| 23 | while (matches->name || matches->type || matches->compatible) { | 24 | while (matches->name[0] || matches->type[0] || matches->compatible[0]) { |
| 24 | int match = 1; | 25 | int match = 1; |
| 25 | if (matches->name && matches->name != OF_ANY_MATCH) | 26 | if (matches->name[0]) |
| 26 | match &= dev->node->name | 27 | match &= dev->node->name |
| 27 | && !strcmp(matches->name, dev->node->name); | 28 | && !strcmp(matches->name, dev->node->name); |
| 28 | if (matches->type && matches->type != OF_ANY_MATCH) | 29 | if (matches->type[0]) |
| 29 | match &= dev->node->type | 30 | match &= dev->node->type |
| 30 | && !strcmp(matches->type, dev->node->type); | 31 | && !strcmp(matches->type, dev->node->type); |
| 31 | if (matches->compatible && matches->compatible != OF_ANY_MATCH) | 32 | if (matches->compatible[0]) |
| 32 | match &= device_is_compatible(dev->node, | 33 | match &= device_is_compatible(dev->node, |
| 33 | matches->compatible); | 34 | matches->compatible); |
| 34 | if (match) | 35 | if (match) |
| @@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv) | |||
| 42 | { | 43 | { |
| 43 | struct of_device * of_dev = to_of_device(dev); | 44 | struct of_device * of_dev = to_of_device(dev); |
| 44 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); | 45 | struct of_platform_driver * of_drv = to_of_platform_driver(drv); |
| 45 | const struct of_match * matches = of_drv->match_table; | 46 | const struct of_device_id * matches = of_drv->match_table; |
| 46 | 47 | ||
| 47 | if (!matches) | 48 | if (!matches) |
| 48 | return 0; | 49 | return 0; |
| @@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev) | |||
| 75 | int error = -ENODEV; | 76 | int error = -ENODEV; |
| 76 | struct of_platform_driver *drv; | 77 | struct of_platform_driver *drv; |
| 77 | struct of_device *of_dev; | 78 | struct of_device *of_dev; |
| 78 | const struct of_match *match; | 79 | const struct of_device_id *match; |
| 79 | 80 | ||
| 80 | drv = to_of_platform_driver(dev->driver); | 81 | drv = to_of_platform_driver(dev->driver); |
| 81 | of_dev = to_of_device(dev); | 82 | of_dev = to_of_device(dev); |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 363e545fc01..94ae808314f 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
| @@ -698,7 +698,7 @@ dispose_iface(struct device *dev) | |||
| 698 | } | 698 | } |
| 699 | 699 | ||
| 700 | static int | 700 | static int |
| 701 | create_iface_macio(struct macio_dev* dev, const struct of_match *match) | 701 | create_iface_macio(struct macio_dev* dev, const struct of_device_id *match) |
| 702 | { | 702 | { |
| 703 | return create_iface(dev->ofdev.node, &dev->ofdev.dev); | 703 | return create_iface(dev->ofdev.node, &dev->ofdev.dev); |
| 704 | } | 704 | } |
| @@ -710,7 +710,7 @@ dispose_iface_macio(struct macio_dev* dev) | |||
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | static int | 712 | static int |
| 713 | create_iface_of_platform(struct of_device* dev, const struct of_match *match) | 713 | create_iface_of_platform(struct of_device* dev, const struct of_device_id *match) |
| 714 | { | 714 | { |
| 715 | return create_iface(dev->node, &dev->dev); | 715 | return create_iface(dev->node, &dev->dev); |
| 716 | } | 716 | } |
| @@ -721,10 +721,9 @@ dispose_iface_of_platform(struct of_device* dev) | |||
| 721 | return dispose_iface(&dev->dev); | 721 | return dispose_iface(&dev->dev); |
| 722 | } | 722 | } |
| 723 | 723 | ||
| 724 | static struct of_match i2c_keywest_match[] = | 724 | static struct of_device_id i2c_keywest_match[] = |
| 725 | { | 725 | { |
| 726 | { | 726 | { |
| 727 | .name = OF_ANY_MATCH, | ||
| 728 | .type = "i2c", | 727 | .type = "i2c", |
| 729 | .compatible = "keywest" | ||
