diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-09-05 18:21:22 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-09-05 18:21:22 -0400 |
commit | 2c910cb75e1fe6de52d95c8e32caedd1629a33a5 (patch) | |
tree | 94a0eea6f8cde689d11e7583ddd0a930b8785ab4 /drivers/of/base.c | |
parent | 627212c9d49ba2759b699450f5d8f45f73e062fa (diff) | |
parent | b53b1c08a23eb1091982daacb2122f90a7094a77 (diff) |
Merge branch 'uverbs_dev_cleanups' into rdma.git for-next
For dependencies, branch based on rdma.git 'for-rc' of
https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/
Pull 'uverbs_dev_cleanups' from Leon Romanovsky:
====================
Reuse the char device code interfaces to simplify ib_uverbs_device
creation and destruction. As part of this series, we are sending fix to
cleanup path, which was discovered during internal review,
The fix definitely can go to -rc, but it means that this series will be
dependent on rdma-rc.
====================
* branch 'uverbs_dev_cleanups':
RDMA/uverbs: Use device.groups to initialize device attributes
RDMA/uverbs: Use cdev_device_add() instead of cdev_add()
RDMA/core: Depend on device_add() to add device attributes
RDMA/uverbs: Fix error cleanup path of ib_uverbs_add_one()
Resolved conflict in ib_device_unregister_sysfs()
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 466e3c8582f0..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; |
@@ -720,6 +742,31 @@ struct device_node *of_get_next_available_child(const struct device_node *node, | |||
720 | EXPORT_SYMBOL(of_get_next_available_child); | 742 | EXPORT_SYMBOL(of_get_next_available_child); |
721 | 743 | ||
722 | /** | 744 | /** |
745 | * of_get_compatible_child - Find compatible child node | ||
746 | * @parent: parent node | ||
747 | * @compatible: compatible string | ||
748 | * | ||
749 | * Lookup child node whose compatible property contains the given compatible | ||
750 | * string. | ||
751 | * | ||
752 | * Returns a node pointer with refcount incremented, use of_node_put() on it | ||
753 | * when done; or NULL if not found. | ||
754 | */ | ||
755 | struct device_node *of_get_compatible_child(const struct device_node *parent, | ||
756 | const char *compatible) | ||
757 | { | ||
758 | struct device_node *child; | ||
759 | |||
760 | for_each_child_of_node(parent, child) { | ||
761 | if (of_device_is_compatible(child, compatible)) | ||
762 | break; | ||
763 | } | ||
764 | |||
765 | return child; | ||
766 | } | ||
767 | EXPORT_SYMBOL(of_get_compatible_child); | ||
768 | |||
769 | /** | ||
723 | * of_get_child_by_name - Find the child node by name for a given parent | 770 | * of_get_child_by_name - Find the child node by name for a given parent |
724 | * @node: parent node | 771 | * @node: parent node |
725 | * @name: child name to look for. | 772 | * @name: child name to look for. |