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 /arch | |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ppc/syslib/of_device.c | 15 | ||||
-rw-r--r-- | arch/ppc64/kernel/of_device.c | 15 |
2 files changed, 16 insertions, 14 deletions
diff --git a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c index 49c0e34e2d6b..1eb4f726ca9f 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 66bd5ab7c25a..b80e81984ba8 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); |