Skip to content

Commit fe88941

Browse files
Sakari Ailusrkhuangtao
authored andcommitted
UPSTREAM: 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> (cherry picked from commit 2294b3af05e9b3fe0b84a78971e709037bd7593c) Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com> Signed-off-by: Marc Herbert <marc.herbert@intel.com> Conflicts: include/linux/property.h (purely contextual; dev_fwnode() was added by I41bf4db9d04eeb91) BUG=b:64133998 TEST=media device topology shows subdevs registered successfully TEST=no camera regression Change-Id: I0cd566e2d1cbadbb2fdfe99592fe8ae1ab5589d5 Reviewed-on: https://chromium-review.googlesource.com/693678 Commit-Ready: Tomasz Figa <tfiga@chromium.org> Tested-by: Hyungwoo Yang <hyungwoo.yang@intel.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
1 parent 339a6f7 commit fe88941

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

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
@@ -948,6 +948,16 @@ void fwnode_handle_put(struct fwnode_handle *fwnode)
948948
}
949949
EXPORT_SYMBOL_GPL(fwnode_handle_put);
950950

951+
/**
952+
* fwnode_device_is_available - check if a device is available for use
953+
* @fwnode: Pointer to the fwnode of the device.
954+
*/
955+
bool fwnode_device_is_available(struct fwnode_handle *fwnode)
956+
{
957+
return fwnode_call_int_op(fwnode, device_is_available);
958+
}
959+
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
960+
951961
/**
952962
* device_get_child_node_count - return the number of child nodes for device
953963
* @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
@@ -65,6 +65,7 @@ struct fwnode_endpoint {
6565
struct fwnode_operations {
6666
void (*get)(struct fwnode_handle *fwnode);
6767
void (*put)(struct fwnode_handle *fwnode);
68+
bool (*device_is_available)(struct fwnode_handle *fwnode);
6869
bool (*property_present)(struct fwnode_handle *fwnode,
6970
const char *propname);
7071
int (*property_read_int_array)(struct fwnode_handle *fwnode,

include/linux/property.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ enum dev_dma_attr {
3333
DEV_DMA_COHERENT,
3434
};
3535

36-
struct fwnode_handle *dev_fwnode(struct device *dev);
37-
3836
bool device_property_present(struct device *dev, const char *propname);
3937
int device_property_read_u8_array(struct device *dev, const char *propname,
4038
u8 *val, size_t nval);
@@ -51,6 +49,9 @@ int device_property_read_string(struct device *dev, const char *propname,
5149
int device_property_match_string(struct device *dev,
5250
const char *propname, const char *string);
5351

52+
struct fwnode_handle *dev_fwnode(struct device *dev);
53+
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)