mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
of: add node name compare helper functions
In preparation to remove device_node.name pointer, add helper functions for node name comparisons which are a common pattern throughout the kernel. Cc: Frank Rowand <[email protected]> Signed-off-by: Rob Herring <[email protected]>
This commit is contained in:
parent
36156f9241
commit
f42b0e18f2
2 changed files with 35 additions and 0 deletions
|
|
@ -54,6 +54,28 @@ DEFINE_MUTEX(of_mutex);
|
|||
*/
|
||||
DEFINE_RAW_SPINLOCK(devtree_lock);
|
||||
|
||||
bool of_node_name_eq(const struct device_node *np, const char *name)
|
||||
{
|
||||
const char *node_name;
|
||||
size_t len;
|
||||
|
||||
if (!np)
|
||||
return false;
|
||||
|
||||
node_name = kbasename(np->full_name);
|
||||
len = strchrnul(node_name, '@') - node_name;
|
||||
|
||||
return (strlen(name) == len) && (strncmp(node_name, name, len) == 0);
|
||||
}
|
||||
|
||||
bool of_node_name_prefix(const struct device_node *np, const char *prefix)
|
||||
{
|
||||
if (!np)
|
||||
return false;
|
||||
|
||||
return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0;
|
||||
}
|
||||
|
||||
int of_n_addr_cells(struct device_node *np)
|
||||
{
|
||||
u32 cells;
|
||||
|
|
|
|||
Loading…
Reference in a new issue