[PATCH 3/3] device property: add fwnode_is_compatible() for compatible match

From: Soha Jin
Date: Sun Oct 09 2022 - 12:23:02 EST


fwnode_is_compatible is a shortcut to check if a device is compatible with
a compat string in fwnode property "compatible". This function is similar
to of_device_is_compatible.

Signed-off-by: Soha Jin <soha@xxxxxxxxx>
---
include/linux/property.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/linux/property.h b/include/linux/property.h
index dbe747f3e3be..776e4a8bc379 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -252,6 +252,13 @@ fwnode_property_string_array_count(const struct fwnode_handle *fwnode,
return fwnode_property_read_string_array(fwnode, propname, NULL, 0);
}

+static inline bool fwnode_is_compatible(const struct fwnode_handle *fwnode,
+ const char *compat)
+{
+ return fwnode_property_match_string_nocase(fwnode, "compatible",
+ compat) >= 0;
+}
+
struct software_node;

/**
--
2.30.2