mirror of
				https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
				synced 2025-11-04 07:44:51 +10:00 
			
		
		
		
	Devicetree updates for 4.19-rc2:
A couple of new helper functions in preparation for some tree wide clean-ups. -----BEGIN PGP SIGNATURE----- iQJEBAABCgAuFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAluL3YAQHHJvYmhAa2Vy bmVsLm9yZwAKCRD6+121jbxhwwqqEACsyq81TV/frKj+VJecGxCUwRbotg5aQu2N Dx3Y8JP4fw394Rw78Fh3Q+2gcy5lI3elup5z+LzYE45N0GjhoguF3kBVLacySdq3 VMDLj+AyFae4mCZZ+pBMpZOh+8de0xWSQKxAqj9ejZ1c+uAkdr++6bn7kBHC4yMH i7B3DHg9ZBtC1g3FZgpuZfUTaitje3+RK0NKZBIt9XTGbylwVQqLuIGatMpXyJvc ez4POzZ+miuFK90myIHklI0ARlgB3YR9A9vVeSs4PAo58GomffKbVsdcU6qCIZtw ImkC5bgirIPtGrc2lPRJ86D5bhxVKh3s4LgBEG/dlSSaeyenP8SF479DwC5IM2jt Pff0c5pRrwDkg/7SOq8Cfxn8IZ/N5yao8g7v2iCcSNqAUhSiCNxakks3fCB7yF7K 8X+aoBhwP+nAMWQifpTC9tgEyEJ3ECRK6qLdC9NfFdS52d2iws4rU6IKwumrL1nd qsJSqmsTInsBFx4gh7KYdqZYfAolMKp9P9H5Q4RHuqPg6y6f5zF6KbvKdfZ6+p9k 8rl1p/MFDSNYK/i/s6+kJtRtMMyHUYjabzmeRlkTfWlyBCwtJz6Y+1rtyozNPa11 Q2Wu4kh0tff1ujdsfGlZwj3IsXsJ5nl/X4getJj0hrxRVCueYoF1xbjfyno5kFQi Q9OifJQMag== =AaKv -----END PGP SIGNATURE----- Merge tag 'devicetree-fixes-for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "A couple of new helper functions in preparation for some tree wide clean-ups. I'm sending these new helpers now for rc2 in order to simplify the dependencies on subsequent cleanups across the tree in 4.20" * tag 'devicetree-fixes-for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: of: Add device_type access helper functions of: add node name compare helper functions of: add helper to lookup compatible child node
This commit is contained in:
		
						commit
						fd6868d82b
					
				@ -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;
 | 
			
		||||
@ -719,6 +741,31 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
 | 
			
		||||
}
 | 
			
		||||
EXPORT_SYMBOL(of_get_next_available_child);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * of_get_compatible_child - Find compatible child node
 | 
			
		||||
 * @parent:	parent node
 | 
			
		||||
 * @compatible:	compatible string
 | 
			
		||||
 *
 | 
			
		||||
 * Lookup child node whose compatible property contains the given compatible
 | 
			
		||||
 * string.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns a node pointer with refcount incremented, use of_node_put() on it
 | 
			
		||||
 * when done; or NULL if not found.
 | 
			
		||||
 */
 | 
			
		||||
struct device_node *of_get_compatible_child(const struct device_node *parent,
 | 
			
		||||
				const char *compatible)
 | 
			
		||||
{
 | 
			
		||||
	struct device_node *child;
 | 
			
		||||
 | 
			
		||||
	for_each_child_of_node(parent, child) {
 | 
			
		||||
		if (of_device_is_compatible(child, compatible))
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return child;
 | 
			
		||||
}
 | 
			
		||||
EXPORT_SYMBOL(of_get_compatible_child);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *	of_get_child_by_name - Find the child node by name for a given parent
 | 
			
		||||
 *	@node:	parent node
 | 
			
		||||
 | 
			
		||||
@ -256,6 +256,9 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
 | 
			
		||||
#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
 | 
			
		||||
#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
 | 
			
		||||
 | 
			
		||||
extern bool of_node_name_eq(const struct device_node *np, const char *name);
 | 
			
		||||
extern bool of_node_name_prefix(const struct device_node *np, const char *prefix);
 | 
			
		||||
 | 
			
		||||
static inline const char *of_node_full_name(const struct device_node *np)
 | 
			
		||||
{
 | 
			
		||||
	return np ? np->full_name : "<no-node>";
 | 
			
		||||
@ -290,6 +293,8 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
 | 
			
		||||
extern struct device_node *of_get_next_available_child(
 | 
			
		||||
	const struct device_node *node, struct device_node *prev);
 | 
			
		||||
 | 
			
		||||
extern struct device_node *of_get_compatible_child(const struct device_node *parent,
 | 
			
		||||
					const char *compatible);
 | 
			
		||||
extern struct device_node *of_get_child_by_name(const struct device_node *node,
 | 
			
		||||
					const char *name);
 | 
			
		||||
 | 
			
		||||
@ -561,6 +566,16 @@ static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode)
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool of_node_name_eq(const struct device_node *np, const char *name)
 | 
			
		||||
{
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool of_node_name_prefix(const struct device_node *np, const char *prefix)
 | 
			
		||||
{
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline const char* of_node_full_name(const struct device_node *np)
 | 
			
		||||
{
 | 
			
		||||
	return "<no-node>";
 | 
			
		||||
@ -632,6 +647,12 @@ static inline bool of_have_populated_dt(void)
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline struct device_node *of_get_compatible_child(const struct device_node *parent,
 | 
			
		||||
					const char *compatible)
 | 
			
		||||
{
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline struct device_node *of_get_child_by_name(
 | 
			
		||||
					const struct device_node *node,
 | 
			
		||||
					const char *name)
 | 
			
		||||
@ -967,6 +988,18 @@ static inline struct device_node *of_find_matching_node(
 | 
			
		||||
	return of_find_matching_node_and_match(from, matches, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline const char *of_node_get_device_type(const struct device_node *np)
 | 
			
		||||
{
 | 
			
		||||
	return of_get_property(np, "type", NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline bool of_node_is_type(const struct device_node *np, const char *type)
 | 
			
		||||
{
 | 
			
		||||
	const char *match = of_node_get_device_type(np);
 | 
			
		||||
 | 
			
		||||
	return np && match && type && !strcmp(match, type);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * of_property_count_u8_elems - Count the number of u8 elements in a property
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user