diff options
| author | Pawel Moll <pawel.moll@arm.com> | 2014-05-15 11:55:24 -0400 |
|---|---|---|
| committer | Pawel Moll <pawel.moll@arm.com> | 2014-05-15 12:02:14 -0400 |
| commit | c6e126de43e7d4abfd6cf796b40589db3a046167 (patch) | |
| tree | 78db63df172516da22235bed2c30544a69fc20bd /include/linux | |
| parent | d6d211db37e75de2ddc3a4f979038c40df7cc79c (diff) | |
of: Keep track of populated platform devices
In "Device Tree powered" systems, platform devices are usually massively
populated with of_platform_populate() call, executed at some level of
initcalls, either by generic architecture or by platform-specific code.
There are situations though where certain devices must be created (and
bound with drivers) before all the others. This presents a challenge,
as devices created explicitly would be created again by
of_platform_populate().
This patch tries to solve that issue in a generic way, adding a
"populated" flag for a DT node description. Subsequent
of_platform_populate() will skip such nodes (and its children) in
a similar way to the non-available ones.
This patch also adds of_platform_depopulate() as an operation
complementary to the _populate() one. It removes a platform or an amba
device populated from the Device Tree, together with its all children
(leaving, however, devices without associated of_node untouched)
clearing the "populated" flag on the way.
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/of.h | 7 | ||||
| -rw-r--r-- | include/linux/of_platform.h | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 3bad8d106e0e..4c50d0b78b89 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -130,6 +130,12 @@ static inline int of_node_check_flag(struct device_node *n, unsigned long flag) | |||
| 130 | return test_bit(flag, &n->_flags); | 130 | return test_bit(flag, &n->_flags); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static inline int of_node_test_and_set_flag(struct device_node *n, | ||
| 134 | unsigned long flag) | ||
| 135 | { | ||
| 136 | return test_and_set_bit(flag, &n->_flags); | ||
| 137 | } | ||
| 138 | |||
| 133 | static inline void of_node_set_flag(struct device_node *n, unsigned long flag) | 139 | static inline void of_node_set_flag(struct device_node *n, unsigned long flag) |
| 134 | { | 140 | { |
| 135 | set_bit(flag, &n->_flags); | 141 | set_bit(flag, &n->_flags); |
| @@ -197,6 +203,7 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) | |||
| 197 | /* flag descriptions */ | 203 | /* flag descriptions */ |
| 198 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | 204 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ |
| 199 | #define OF_DETACHED 2 /* node has been detached from the device tree */ | 205 | #define OF_DETACHED 2 /* node has been detached from the device tree */ |
| 206 | #define OF_POPULATED 3 /* device already created for the node */ | ||
| 200 | 207 | ||
| 201 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | 208 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) |
| 202 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | 209 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) |
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 05cb4a928252..b1010eeaac0d 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h | |||
| @@ -72,6 +72,7 @@ extern int of_platform_populate(struct device_node *root, | |||
| 72 | const struct of_device_id *matches, | 72 | const struct of_device_id *matches, |
| 73 | const struct of_dev_auxdata *lookup, | 73 | const struct of_dev_auxdata *lookup, |
| 74 | struct device *parent); | 74 | struct device *parent); |
| 75 | extern int of_platform_depopulate(struct device *parent); | ||
| 75 | #else | 76 | #else |
| 76 | static inline int of_platform_populate(struct device_node *root, | 77 | static inline int of_platform_populate(struct device_node *root, |
| 77 | const struct of_device_id *matches, | 78 | const struct of_device_id *matches, |
| @@ -80,6 +81,10 @@ static inline int of_platform_populate(struct device_node *root, | |||
| 80 | { | 81 | { |
| 81 | return -ENODEV; | 82 | return -ENODEV; |
| 82 | } | 83 | } |
| 84 | static inline int of_platform_depopulate(struct device *parent) | ||
| 85 | { | ||
| 86 | return -ENODEV; | ||
| 87 | } | ||
| 83 | #endif | 88 | #endif |
| 84 | 89 | ||
| 85 | #endif /* _LINUX_OF_PLATFORM_H */ | 90 | #endif /* _LINUX_OF_PLATFORM_H */ |
