mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
007cfa13e0
commit
2de5897b5c
@@ -85,6 +85,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char
|
|||||||
return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
|
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,
|
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
|
||||||
const char *prop, const char *nargs_prop,
|
const char *prop, const char *nargs_prop,
|
||||||
unsigned int nargs, unsigned int index,
|
unsigned int nargs, unsigned int index,
|
||||||
|
|||||||
Reference in New Issue
Block a user