diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index a24ca61294eb5b30b32a72ffc431151dc8e44fa1..917c789f953dfb280f6f00895ce1fcf7ae2484ec 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1121,6 +1121,14 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode, return 0; } +static bool acpi_fwnode_device_is_available(struct fwnode_handle *fwnode) +{ + if (!is_acpi_device_node(fwnode)) + return false; + + return acpi_device_is_present(to_acpi_device_node(fwnode)); +} + static bool acpi_fwnode_property_present(struct fwnode_handle *fwnode, const char *propname) { @@ -1216,6 +1224,7 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, } const struct fwnode_operations acpi_fwnode_ops = { + .device_is_available = acpi_fwnode_device_is_available, .property_present = acpi_fwnode_property_present, .property_read_int_array = acpi_fwnode_property_read_int_array, .property_read_string_array = acpi_fwnode_property_read_string_array, diff --git a/drivers/base/property.c b/drivers/base/property.c index e1a58ac8840ea8d0d345a7607c9503a06cb75796..b979f8a2f4fbc2d519ebd070f2f19f3ff9a15e58 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1021,6 +1021,16 @@ void fwnode_handle_put(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(fwnode_handle_put); +/** + * fwnode_device_is_available - check if a device is available for use + * @fwnode: Pointer to the fwnode of the device. + */ +bool fwnode_device_is_available(struct fwnode_handle *fwnode) +{ + return fwnode_call_int_op(fwnode, device_is_available); +} +EXPORT_SYMBOL_GPL(fwnode_device_is_available); + /** * device_get_child_node_count - return the number of child nodes for device * @dev: Device to cound the child nodes for diff --git a/drivers/of/property.c b/drivers/of/property.c index e859e41e33f3a4ac2c091999c154d79d2c914a52..c96389b7c6b32c64ee4a16270c8c87d9fadb1883 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -775,6 +775,11 @@ static void of_fwnode_put(struct fwnode_handle *fwnode) of_node_put(to_of_node(fwnode)); } +static bool of_fwnode_device_is_available(struct fwnode_handle *fwnode) +{ + return of_device_is_available(to_of_node(fwnode)); +} + static bool of_fwnode_property_present(struct fwnode_handle *fwnode, const char *propname) { @@ -895,6 +900,7 @@ static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode, const struct fwnode_operations of_fwnode_ops = { .get = of_fwnode_get, .put = of_fwnode_put, + .device_is_available = of_fwnode_device_is_available, .property_present = of_fwnode_property_present, .property_read_int_array = of_fwnode_property_read_int_array, .property_read_string_array = of_fwnode_property_read_string_array, diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index e315d867d631c584861c94921c92fcc5e5f73558..9ab37541918929d5d1db6b409615df305f07c727 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -66,6 +66,7 @@ struct fwnode_endpoint { struct fwnode_operations { void (*get)(struct fwnode_handle *fwnode); void (*put)(struct fwnode_handle *fwnode); + bool (*device_is_available)(struct fwnode_handle *fwnode); bool (*property_present)(struct fwnode_handle *fwnode, const char *propname); int (*property_read_int_array)(struct fwnode_handle *fwnode, diff --git a/include/linux/property.h b/include/linux/property.h index 2f482616a2f22e2e26192a0a47a1c1b22d2bf015..7be014af78ed7ecd45b3dc9e26da20d028ed1145 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -51,6 +51,7 @@ int device_property_read_string(struct device *dev, const char *propname, int device_property_match_string(struct device *dev, const char *propname, const char *string); +bool fwnode_device_is_available(struct fwnode_handle *fwnode); bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, const char *propname, u8 *val,