Skip to content

Commit 2294b3a

Browse files
Sakari Ailusrafaeljw
authored andcommitted
device property: Introduce fwnode_device_is_available()
Add fwnode_device_is_available() to tell whether the device corresponding to a certain fwnode_handle is available for use. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 3b27d00 commit 2294b3a

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

drivers/acpi/property.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,14 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
11211121
return 0;
11221122
}
11231123

1124+
static bool acpi_fwnode_device_is_available(struct fwnode_handle *fwnode)
1125+
{
1126+
if (!is_acpi_device_node(fwnode))
1127+
return false;
1128+
1129+
return acpi_device_is_present(to_acpi_device_node(fwnode));
1130+
}
1131+
11241132
static bool acpi_fwnode_property_present(struct fwnode_handle *fwnode,
11251133
const char *propname)
11261134
{
@@ -1216,6 +1224,7 @@ static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
12161224
}
12171225

12181226
const struct fwnode_operations acpi_fwnode_ops = {
1227+
.device_is_available = acpi_fwnode_device_is_available,
12191228
.property_present = acpi_fwnode_property_present,
12201229
.property_read_int_array = acpi_fwnode_property_read_int_array,
12211230
.property_read_string_array = acpi_fwnode_property_read_string_array,

drivers/base/property.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,16 @@ void fwnode_handle_put(struct fwnode_handle *fwnode)
10211021
}
10221022
EXPORT_SYMBOL_GPL(fwnode_handle_put);
10231023

1024+
/**
1025+
* fwnode_device_is_available - check if a device is available for use
1026+
* @fwnode: Pointer to the fwnode of the device.
1027+
*/
1028+
bool fwnode_device_is_available(struct fwnode_handle *fwnode)
1029+
{
1030+
return fwnode_call_int_op(fwnode, device_is_available);
1031+
}
1032+
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
1033+
10241034
/**
10251035
* device_get_child_node_count - return the number of child nodes for device
10261036
* @dev: Device to cound the child nodes for

drivers/of/property.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,11 @@ static void of_fwnode_put(struct fwnode_handle *fwnode)
775775
of_node_put(to_of_node(fwnode));
776776
}
777777

778+
static bool of_fwnode_device_is_available(struct fwnode_handle *fwnode)
779+
{
780+
return of_device_is_available(to_of_node(fwnode));
781+
}
782+
778783
static bool of_fwnode_property_present(struct fwnode_handle *fwnode,
779784
const char *propname)
780785
{
@@ -895,6 +900,7 @@ static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
895900
const struct fwnode_operations of_fwnode_ops = {
896901
.get = of_fwnode_get,
897902
.put = of_fwnode_put,
903+
.device_is_available = of_fwnode_device_is_available,
898904
.property_present = of_fwnode_property_present,
899905
.property_read_int_array = of_fwnode_property_read_int_array,
900906
.property_read_string_array = of_fwnode_property_read_string_array,

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct fwnode_endpoint {
6666
struct fwnode_operations {
6767
void (*get)(struct fwnode_handle *fwnode);
6868
void (*put)(struct fwnode_handle *fwnode);
69+
bool (*device_is_available)(struct fwnode_handle *fwnode);
6970
bool (*property_present)(struct fwnode_handle *fwnode,
7071
const char *propname);
7172
int (*property_read_int_array)(struct fwnode_handle *fwnode,

include/linux/property.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ int device_property_read_string(struct device *dev, const char *propname,
5151
int device_property_match_string(struct device *dev,
5252
const char *propname, const char *string);
5353

54+
bool fwnode_device_is_available(struct fwnode_handle *fwnode);
5455
bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname);
5556
int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
5657
const char *propname, u8 *val,

0 commit comments

Comments
 (0)