[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230612161011.86871-3-andriy.shevchenko@linux.intel.com>
Date: Mon, 12 Jun 2023 19:10:10 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-ide@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-acpi@...r.kernel.org
Cc: Hans de Goede <hdegoede@...hat.com>, Jens Axboe <axboe@...nel.dk>,
Damien Le Moal <dlemoal@...nel.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>,
Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>
Subject: [PATCH v3 2/3] device property: Implement device_is_compatible()
Some users want to use the struct device pointer to see if the
device is compatible in terms of Open Firmware specifications,
i.e. if it has a 'compatible' property and it matches to the
given value. Provide inline helper for the users.
Reviewed-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
include/linux/property.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/property.h b/include/linux/property.h
index 3df7e10156d8..0251138c7c88 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -90,6 +90,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char
return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
}
+/**
+ * device_is_compatible - match 'compatible' property of the device with a given string
+ * @dev: Pointer to the struct device
+ * @compat: The string to match 'compatible' property with
+ *
+ * Returns: true if matches, otherwise false.
+ */
+static inline bool device_is_compatible(const struct device *dev, const char *compat)
+{
+ return fwnode_device_is_compatible(dev_fwnode(dev), compat);
+}
+
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
--
2.40.0.1.gaa8946217a0b
Powered by blists - more mailing lists