diff options
| -rw-r--r-- | drivers/of/base.c | 22 | ||||
| -rw-r--r-- | include/linux/of.h | 13 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index bc420d2aa5f5..9095b8290150 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -54,6 +54,28 @@ DEFINE_MUTEX(of_mutex); | |||
| 54 | */ | 54 | */ |
| 55 | DEFINE_RAW_SPINLOCK(devtree_lock); | 55 | DEFINE_RAW_SPINLOCK(devtree_lock); |
| 56 | 56 | ||
| 57 | bool of_node_name_eq(const struct device_node *np, const char *name) | ||
| 58 | { | ||
| 59 | const char *node_name; | ||
| 60 | size_t len; | ||
| 61 | |||
| 62 | if (!np) | ||
| 63 | return false; | ||
| 64 | |||
| 65 | node_name = kbasename(np->full_name); | ||
| 66 | len = strchrnul(node_name, '@') - node_name; | ||
| 67 | |||
| 68 | return (strlen(name) == len) && (strncmp(node_name, name, len) == 0); | ||
| 69 | } | ||
| 70 | |||
| 71 | bool of_node_name_prefix(const struct device_node *np, const char *prefix) | ||
| 72 | { | ||
| 73 | if (!np) | ||
| 74 | return false; | ||
| 75 | |||
| 76 | return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; | ||
| 77 | } | ||
| 78 | |||
| 57 | int of_n_addr_cells(struct device_node *np) | 79 | int of_n_addr_cells(struct device_node *np) |
| 58 | { | 80 | { |
| 59 | u32 cells; | 81 | u32 cells; |
diff --git a/include/linux/of.h b/include/linux/of.h index b99a1a8c2952..688c52dd7b3e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
| @@ -256,6 +256,9 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size) | |||
| 256 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) | 256 | #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags) |
| 257 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) | 257 | #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags) |
| 258 | 258 | ||
| 259 | extern bool of_node_name_eq(const struct device_node *np, const char *name); | ||
| 260 | extern bool of_node_name_prefix(const struct device_node *np, const char *prefix); | ||
| 261 | |||
| 259 | static inline const char *of_node_full_name(const struct device_node *np) | 262 | static inline const char *of_node_full_name(const struct device_node *np) |
| 260 | { | 263 | { |
| 261 | return np ? np->full_name : "<no-node>"; | 264 | return np ? np->full_name : "<no-node>"; |
| @@ -563,6 +566,16 @@ static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode) | |||
| 563 | return NULL; | 566 | return NULL; |
| 564 | } | 567 | } |
| 565 | 568 | ||
| 569 | static inline bool of_node_name_eq(const struct device_node *np, const char *name) | ||
| 570 | { | ||
| 571 | return false; | ||
| 572 | } | ||
| 573 | |||
| 574 | static inline bool of_node_name_prefix(const struct device_node *np, const char *prefix) | ||
| 575 | { | ||
| 576 | return false; | ||
| 577 | } | ||
| 578 | |||
| 566 | static inline const char* of_node_full_name(const struct device_node *np) | 579 | static inline const char* of_node_full_name(const struct device_node *np) |
| 567 | { | 580 | { |
| 568 | return "<no-node>"; | 581 | return "<no-node>"; |
