Skip to content

Commit 2de5897

Browse files
andy-shevgregkh
authored andcommitted
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. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Message-ID: <20230609154900.43024-3-andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 007cfa1 commit 2de5897

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

include/linux/property.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char
8585
return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
8686
}
8787

88+
/**
89+
* device_is_compatible - match 'compatible' property of the device with a given string
90+
* @dev: Pointer to the struct device
91+
* @compat: The string to match 'compatible' property with
92+
*
93+
* Returns: true if matches, otherwise false.
94+
*/
95+
static inline bool device_is_compatible(const struct device *dev, const char *compat)
96+
{
97+
return fwnode_device_is_compatible(dev_fwnode(dev), compat);
98+
}
99+
88100
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
89101
const char *prop, const char *nargs_prop,
90102
unsigned int nargs, unsigned int index,

0 commit comments

Comments
 (0)