ACPI / property: Extend fwnode_property_* to data-only subnodes
Modify is_acpi_node() to return "true" for ACPI data-only subnodes as well as for ACPI device objects and change the name of to_acpi_node() to to_acpi_device_node() so it is clear that it covers ACPI device objects only. Accordingly, introduce to_acpi_data_node() to cover data-only subnodes in an analogous way. With that, make the fwnode_property_* family of functions work with ACPI data-only subnodes introduced previously. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
parent
263b4c1a64
commit
3a7a2ab839
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
static int acpi_data_get_property_array(struct acpi_device_data *data,
|
||||||
|
const char *name,
|
||||||
|
acpi_object_type type,
|
||||||
|
const union acpi_object **obj);
|
||||||
|
|
||||||
/* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
|
/* ACPI _DSD device properties UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 */
|
||||||
static const u8 prp_uuid[16] = {
|
static const u8 prp_uuid[16] = {
|
||||||
0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d,
|
0x14, 0xd8, 0xff, 0xda, 0xba, 0x6e, 0x8c, 0x4d,
|
||||||
|
@ -191,8 +196,8 @@ static void acpi_init_of_compatible(struct acpi_device *adev)
|
||||||
const union acpi_object *of_compatible;
|
const union acpi_object *of_compatible;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = acpi_dev_get_property_array(adev, "compatible", ACPI_TYPE_STRING,
|
ret = acpi_data_get_property_array(&adev->data, "compatible",
|
||||||
&of_compatible);
|
ACPI_TYPE_STRING, &of_compatible);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = acpi_dev_get_property(adev, "compatible",
|
ret = acpi_dev_get_property(adev, "compatible",
|
||||||
ACPI_TYPE_STRING, &of_compatible);
|
ACPI_TYPE_STRING, &of_compatible);
|
||||||
|
@ -320,8 +325,8 @@ void acpi_free_properties(struct acpi_device *adev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_dev_get_property - return an ACPI property with given name
|
* acpi_data_get_property - return an ACPI property with given name
|
||||||
* @adev: ACPI device to get property
|
* @data: ACPI device deta object to get the property from
|
||||||
* @name: Name of the property
|
* @name: Name of the property
|
||||||
* @type: Expected property type
|
* @type: Expected property type
|
||||||
* @obj: Location to store the property value (if not %NULL)
|
* @obj: Location to store the property value (if not %NULL)
|
||||||
|
@ -330,26 +335,27 @@ void acpi_free_properties(struct acpi_device *adev)
|
||||||
* object at the location pointed to by @obj if found.
|
* object at the location pointed to by @obj if found.
|
||||||
*
|
*
|
||||||
* Callers must not attempt to free the returned objects. These objects will be
|
* Callers must not attempt to free the returned objects. These objects will be
|
||||||
* freed by the ACPI core automatically during the removal of @adev.
|
* freed by the ACPI core automatically during the removal of @data.
|
||||||
*
|
*
|
||||||
* Return: %0 if property with @name has been found (success),
|
* Return: %0 if property with @name has been found (success),
|
||||||
* %-EINVAL if the arguments are invalid,
|
* %-EINVAL if the arguments are invalid,
|
||||||
* %-ENODATA if the property doesn't exist,
|
* %-ENODATA if the property doesn't exist,
|
||||||
* %-EPROTO if the property value type doesn't match @type.
|
* %-EPROTO if the property value type doesn't match @type.
|
||||||
*/
|
*/
|
||||||
int acpi_dev_get_property(struct acpi_device *adev, const char *name,
|
static int acpi_data_get_property(struct acpi_device_data *data,
|
||||||
acpi_object_type type, const union acpi_object **obj)
|
const char *name, acpi_object_type type,
|
||||||
|
const union acpi_object **obj)
|
||||||
{
|
{
|
||||||
const union acpi_object *properties;
|
const union acpi_object *properties;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!adev || !name)
|
if (!data || !name)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!adev->data.pointer || !adev->data.properties)
|
if (!data->pointer || !data->properties)
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
||||||
properties = adev->data.properties;
|
properties = data->properties;
|
||||||
for (i = 0; i < properties->package.count; i++) {
|
for (i = 0; i < properties->package.count; i++) {
|
||||||
const union acpi_object *propname, *propvalue;
|
const union acpi_object *propname, *propvalue;
|
||||||
const union acpi_object *property;
|
const union acpi_object *property;
|
||||||
|
@ -370,11 +376,50 @@ int acpi_dev_get_property(struct acpi_device *adev, const char *name,
|
||||||
}
|
}
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(acpi_dev_get_property);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_dev_get_property_array - return an ACPI array property with given name
|
* acpi_dev_get_property - return an ACPI property with given name.
|
||||||
* @adev: ACPI device to get property
|
* @adev: ACPI device to get the property from.
|
||||||
|
* @name: Name of the property.
|
||||||
|
* @type: Expected property type.
|
||||||
|
* @obj: Location to store the property value (if not %NULL).
|
||||||
|
*/
|
||||||
|
int acpi_dev_get_property(struct acpi_device *adev, const char *name,
|
||||||
|
acpi_object_type type, const union acpi_object **obj)
|
||||||
|
{
|
||||||
|
return adev ? acpi_data_get_property(&adev->data, name, type, obj) : -EINVAL;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(acpi_dev_get_property);
|
||||||
|
|
||||||
|
static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
if (fwnode->type == FWNODE_ACPI) {
|
||||||
|
struct acpi_device *adev = to_acpi_device_node(fwnode);
|
||||||
|
return &adev->data;
|
||||||
|
} else if (fwnode->type == FWNODE_ACPI_DATA) {
|
||||||
|
struct acpi_data_node *dn = to_acpi_data_node(fwnode);
|
||||||
|
return &dn->data;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* acpi_node_prop_get - return an ACPI property with given name.
|
||||||
|
* @fwnode: Firmware node to get the property from.
|
||||||
|
* @propname: Name of the property.
|
||||||
|
* @valptr: Location to store a pointer to the property value (if not %NULL).
|
||||||
|
*/
|
||||||
|
int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
|
||||||
|
void **valptr)
|
||||||
|
{
|
||||||
|
return acpi_data_get_property(acpi_device_data_of_node(fwnode),
|
||||||
|
propname, ACPI_TYPE_ANY,
|
||||||
|
(const union acpi_object **)valptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* acpi_data_get_property_array - return an ACPI array property with given name
|
||||||
|
* @adev: ACPI data object to get the property from
|
||||||
* @name: Name of the property
|
* @name: Name of the property
|
||||||
* @type: Expected type of array elements
|
* @type: Expected type of array elements
|
||||||
* @obj: Location to store a pointer to the property value (if not NULL)
|
* @obj: Location to store a pointer to the property value (if not NULL)
|
||||||
|
@ -383,7 +428,7 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property);
|
||||||
* ACPI object at the location pointed to by @obj if found.
|
* ACPI object at the location pointed to by @obj if found.
|
||||||
*
|
*
|
||||||
* Callers must not attempt to free the returned objects. Those objects will be
|
* Callers must not attempt to free the returned objects. Those objects will be
|
||||||
* freed by the ACPI core automatically during the removal of @adev.
|
* freed by the ACPI core automatically during the removal of @data.
|
||||||
*
|
*
|
||||||
* Return: %0 if array property (package) with @name has been found (success),
|
* Return: %0 if array property (package) with @name has been found (success),
|
||||||
* %-EINVAL if the arguments are invalid,
|
* %-EINVAL if the arguments are invalid,
|
||||||
|
@ -391,14 +436,15 @@ EXPORT_SYMBOL_GPL(acpi_dev_get_property);
|
||||||
* %-EPROTO if the property is not a package or the type of its elements
|
* %-EPROTO if the property is not a package or the type of its elements
|
||||||
* doesn't match @type.
|
* doesn't match @type.
|
||||||
*/
|
*/
|
||||||
int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
|
static int acpi_data_get_property_array(struct acpi_device_data *data,
|
||||||
acpi_object_type type,
|
const char *name,
|
||||||
const union acpi_object **obj)
|
acpi_object_type type,
|
||||||
|
const union acpi_object **obj)
|
||||||
{
|
{
|
||||||
const union acpi_object *prop;
|
const union acpi_object *prop;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
ret = acpi_dev_get_property(adev, name, ACPI_TYPE_PACKAGE, &prop);
|
ret = acpi_data_get_property(data, name, ACPI_TYPE_PACKAGE, &prop);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -413,7 +459,6 @@ int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(acpi_dev_get_property_array);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acpi_dev_get_property_reference - returns handle to the referenced object
|
* acpi_dev_get_property_reference - returns handle to the referenced object
|
||||||
|
@ -518,15 +563,9 @@ int acpi_dev_get_property_reference(struct acpi_device *adev,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(acpi_dev_get_property_reference);
|
EXPORT_SYMBOL_GPL(acpi_dev_get_property_reference);
|
||||||
|
|
||||||
int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
|
static int acpi_data_prop_read_single(struct acpi_device_data *data,
|
||||||
void **valptr)
|
const char *propname,
|
||||||
{
|
enum dev_prop_type proptype, void *val)
|
||||||
return acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY,
|
|
||||||
(const union acpi_object **)valptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
|
||||||
enum dev_prop_type proptype, void *val)
|
|
||||||
{
|
{
|
||||||
const union acpi_object *obj;
|
const union acpi_object *obj;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -535,7 +574,7 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) {
|
if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) {
|
||||||
ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_INTEGER, &obj);
|
ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -560,7 +599,7 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (proptype == DEV_PROP_STRING) {
|
} else if (proptype == DEV_PROP_STRING) {
|
||||||
ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_STRING, &obj);
|
ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -571,6 +610,12 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
||||||
|
enum dev_prop_type proptype, void *val)
|
||||||
|
{
|
||||||
|
return adev ? acpi_data_prop_read_single(&adev->data, propname, proptype, val) : -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val,
|
static int acpi_copy_property_array_u8(const union acpi_object *items, u8 *val,
|
||||||
size_t nval)
|
size_t nval)
|
||||||
{
|
{
|
||||||
|
@ -647,20 +692,22 @@ static int acpi_copy_property_array_string(const union acpi_object *items,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
|
static int acpi_data_prop_read(struct acpi_device_data *data,
|
||||||
enum dev_prop_type proptype, void *val, size_t nval)
|
const char *propname,
|
||||||
|
enum dev_prop_type proptype,
|
||||||
|
void *val, size_t nval)
|
||||||
{
|
{
|
||||||
const union acpi_object *obj;
|
const union acpi_object *obj;
|
||||||
const union acpi_object *items;
|
const union acpi_object *items;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (val && nval == 1) {
|
if (val && nval == 1) {
|
||||||
ret = acpi_dev_prop_read_single(adev, propname, proptype, val);
|
ret = acpi_data_prop_read_single(data, propname, proptype, val);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = acpi_dev_get_property_array(adev, propname, ACPI_TYPE_ANY, &obj);
|
ret = acpi_data_get_property_array(data, propname, ACPI_TYPE_ANY, &obj);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -696,3 +743,28 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
|
||||||
|
enum dev_prop_type proptype, void *val, size_t nval)
|
||||||
|
{
|
||||||
|
return adev ? acpi_data_prop_read(&adev->data, propname, proptype, val, nval) : -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* acpi_node_prop_read - retrieve the value of an ACPI property with given name.
|
||||||
|
* @fwnode: Firmware node to get the property from.
|
||||||
|
* @propname: Name of the property.
|
||||||
|
* @proptype: Expected property type.
|
||||||
|
* @val: Location to store the property value (if not %NULL).
|
||||||
|
* @nval: Size of the array pointed to by @val.
|
||||||
|
*
|
||||||
|
* If @val is %NULL, return the number of array elements comprising the value
|
||||||
|
* of the property. Otherwise, read at most @nval values to the array at the
|
||||||
|
* location pointed to by @val.
|
||||||
|
*/
|
||||||
|
int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
|
||||||
|
enum dev_prop_type proptype, void *val, size_t nval)
|
||||||
|
{
|
||||||
|
return acpi_data_prop_read(acpi_device_data_of_node(fwnode),
|
||||||
|
propname, proptype, val, nval);
|
||||||
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
|
||||||
if (is_of_node(fwnode))
|
if (is_of_node(fwnode))
|
||||||
return of_property_read_bool(to_of_node(fwnode), propname);
|
return of_property_read_bool(to_of_node(fwnode), propname);
|
||||||
else if (is_acpi_node(fwnode))
|
else if (is_acpi_node(fwnode))
|
||||||
return !acpi_dev_prop_get(to_acpi_node(fwnode), propname, NULL);
|
return !acpi_node_prop_get(fwnode, propname, NULL);
|
||||||
|
|
||||||
return !!pset_prop_get(to_pset(fwnode), propname);
|
return !!pset_prop_get(to_pset(fwnode), propname);
|
||||||
}
|
}
|
||||||
|
@ -298,8 +298,8 @@ EXPORT_SYMBOL_GPL(device_property_read_string);
|
||||||
_ret_ = OF_DEV_PROP_READ_ARRAY(to_of_node(_fwnode_), _propname_, \
|
_ret_ = OF_DEV_PROP_READ_ARRAY(to_of_node(_fwnode_), _propname_, \
|
||||||
_type_, _val_, _nval_); \
|
_type_, _val_, _nval_); \
|
||||||
else if (is_acpi_node(_fwnode_)) \
|
else if (is_acpi_node(_fwnode_)) \
|
||||||
_ret_ = acpi_dev_prop_read(to_acpi_node(_fwnode_), _propname_, \
|
_ret_ = acpi_node_prop_read(_fwnode_, _propname_, _proptype_, \
|
||||||
_proptype_, _val_, _nval_); \
|
_val_, _nval_); \
|
||||||
else if (is_pset(_fwnode_)) \
|
else if (is_pset(_fwnode_)) \
|
||||||
_ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \
|
_ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \
|
||||||
_proptype_, _val_, _nval_); \
|
_proptype_, _val_, _nval_); \
|
||||||
|
@ -440,8 +440,8 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
|
||||||
propname, val, nval) :
|
propname, val, nval) :
|
||||||
of_property_count_strings(to_of_node(fwnode), propname);
|
of_property_count_strings(to_of_node(fwnode), propname);
|
||||||
else if (is_acpi_node(fwnode))
|
else if (is_acpi_node(fwnode))
|
||||||
return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
|
return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING,
|
||||||
DEV_PROP_STRING, val, nval);
|
val, nval);
|
||||||
else if (is_pset(fwnode))
|
else if (is_pset(fwnode))
|
||||||
return pset_prop_read_array(to_pset(fwnode), propname,
|
return pset_prop_read_array(to_pset(fwnode), propname,
|
||||||
DEV_PROP_STRING, val, nval);
|
DEV_PROP_STRING, val, nval);
|
||||||
|
@ -470,8 +470,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
|
||||||
if (is_of_node(fwnode))
|
if (is_of_node(fwnode))
|
||||||
return of_property_read_string(to_of_node(fwnode), propname, val);
|
return of_property_read_string(to_of_node(fwnode), propname, val);
|
||||||
else if (is_acpi_node(fwnode))
|
else if (is_acpi_node(fwnode))
|
||||||
return acpi_dev_prop_read(to_acpi_node(fwnode), propname,
|
return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING,
|
||||||
DEV_PROP_STRING, val, 1);
|
val, 1);
|
||||||
|
|
||||||
return pset_prop_read_array(to_pset(fwnode), propname,
|
return pset_prop_read_array(to_pset(fwnode), propname,
|
||||||
DEV_PROP_STRING, val, 1);
|
DEV_PROP_STRING, val, 1);
|
||||||
|
@ -495,7 +495,7 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
|
||||||
} else if (IS_ENABLED(CONFIG_ACPI)) {
|
} else if (IS_ENABLED(CONFIG_ACPI)) {
|
||||||
struct acpi_device *node;
|
struct acpi_device *node;
|
||||||
|
|
||||||
node = acpi_get_next_child(dev, to_acpi_node(child));
|
node = acpi_get_next_child(dev, to_acpi_device_node(child));
|
||||||
if (node)
|
if (node)
|
||||||
return acpi_fwnode_handle(node);
|
return acpi_fwnode_handle(node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2083,11 +2083,11 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
|
||||||
&flags);
|
&flags);
|
||||||
if (!IS_ERR(desc))
|
if (!IS_ERR(desc))
|
||||||
active_low = flags & OF_GPIO_ACTIVE_LOW;
|
active_low = flags & OF_GPIO_ACTIVE_LOW;
|
||||||
} else if (is_acpi_node(fwnode)) {
|
} else if (is_acpi_device_node(fwnode)) {
|
||||||
struct acpi_gpio_info info;
|
struct acpi_gpio_info info;
|
||||||
|
|
||||||
desc = acpi_get_gpiod_by_index(to_acpi_node(fwnode), propname, 0,
|
desc = acpi_get_gpiod_by_index(to_acpi_device_node(fwnode),
|
||||||
&info);
|
propname, 0, &info);
|
||||||
if (!IS_ERR(desc))
|
if (!IS_ERR(desc))
|
||||||
active_low = info.active_low;
|
active_low = info.active_low;
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,16 +424,33 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool is_acpi_node(struct fwnode_handle *fwnode)
|
static inline bool is_acpi_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return fwnode && (fwnode->type == FWNODE_ACPI
|
||||||
|
|| fwnode->type == FWNODE_ACPI_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
|
||||||
{
|
{
|
||||||
return fwnode && fwnode->type == FWNODE_ACPI;
|
return fwnode && fwnode->type == FWNODE_ACPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode)
|
static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
|
||||||
{
|
{
|
||||||
return is_acpi_node(fwnode) ?
|
return is_acpi_device_node(fwnode) ?
|
||||||
container_of(fwnode, struct acpi_device, fwnode) : NULL;
|
container_of(fwnode, struct acpi_device, fwnode) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return fwnode && fwnode->type == FWNODE_ACPI_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return is_acpi_data_node(fwnode) ?
|
||||||
|
container_of(fwnode, struct acpi_data_node, fwnode) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
|
static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
|
||||||
{
|
{
|
||||||
return &adev->fwnode;
|
return &adev->fwnode;
|
||||||
|
|
|
@ -49,7 +49,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
|
||||||
return adev ? adev->handle : NULL;
|
return adev ? adev->handle : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ACPI_COMPANION(dev) to_acpi_node((dev)->fwnode)
|
#define ACPI_COMPANION(dev) to_acpi_device_node((dev)->fwnode)
|
||||||
#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
|
#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
|
||||||
acpi_fwnode_handle(adev) : NULL)
|
acpi_fwnode_handle(adev) : NULL)
|
||||||
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
|
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
|
||||||
|
@ -69,7 +69,7 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
|
||||||
|
|
||||||
static inline bool has_acpi_companion(struct device *dev)
|
static inline bool has_acpi_companion(struct device *dev)
|
||||||
{
|
{
|
||||||
return is_acpi_node(dev->fwnode);
|
return is_acpi_device_node(dev->fwnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void acpi_preset_companion(struct device *dev,
|
static inline void acpi_preset_companion(struct device *dev,
|
||||||
|
@ -461,7 +461,22 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct acpi_device *to_acpi_node(struct fwnode_handle *fwnode)
|
static inline bool is_acpi_device_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct acpi_device *to_acpi_device_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool is_acpi_data_node(struct fwnode_handle *fwnode)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct acpi_data_node *to_acpi_data_node(struct fwnode_handle *fwnode)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -743,17 +758,16 @@ struct acpi_reference_args {
|
||||||
#ifdef CONFIG_ACPI
|
#ifdef CONFIG_ACPI
|
||||||
int acpi_dev_get_property(struct acpi_device *adev, const char *name,
|
int acpi_dev_get_property(struct acpi_device *adev, const char *name,
|
||||||
acpi_object_type type, const union acpi_object **obj);
|
acpi_object_type type, const union acpi_object **obj);
|
||||||
int acpi_dev_get_property_array(struct acpi_device *adev, const char *name,
|
|
||||||
acpi_object_type type,
|
|
||||||
const union acpi_object **obj);
|
|
||||||
int acpi_dev_get_property_reference(struct acpi_device *adev,
|
int acpi_dev_get_property_reference(struct acpi_device *adev,
|
||||||
const char *name, size_t index,
|
const char *name, size_t index,
|
||||||
struct acpi_reference_args *args);
|
struct acpi_reference_args *args);
|
||||||
|
|
||||||
int acpi_dev_prop_get(struct acpi_device *adev, const char *propname,
|
int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
|
||||||
void **valptr);
|
void **valptr);
|
||||||
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
|
||||||
enum dev_prop_type proptype, void *val);
|
enum dev_prop_type proptype, void *val);
|
||||||
|
int acpi_node_prop_read(struct fwnode_handle *fwnode, const char *propname,
|
||||||
|
enum dev_prop_type proptype, void *val, size_t nval);
|
||||||
int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
|
int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
|
||||||
enum dev_prop_type proptype, void *val, size_t nval);
|
enum dev_prop_type proptype, void *val, size_t nval);
|
||||||
|
|
||||||
|
@ -766,13 +780,7 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
|
||||||
{
|
{
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
static inline int acpi_dev_get_property_array(struct acpi_device *adev,
|
|
||||||
const char *name,
|
|
||||||
acpi_object_type type,
|
|
||||||
const union acpi_object **obj)
|
|
||||||
{
|
|
||||||
return -ENXIO;
|
|
||||||
}
|
|
||||||
static inline int acpi_dev_get_property_reference(struct acpi_device *adev,
|
static inline int acpi_dev_get_property_reference(struct acpi_device *adev,
|
||||||
const char *name, const char *cells_name,
|
const char *name, const char *cells_name,
|
||||||
size_t index, struct acpi_reference_args *args)
|
size_t index, struct acpi_reference_args *args)
|
||||||
|
@ -780,6 +788,13 @@ static inline int acpi_dev_get_property_reference(struct acpi_device *adev,
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int acpi_node_prop_get(struct fwnode_handle *fwnode,
|
||||||
|
const char *propname,
|
||||||
|
void **valptr)
|
||||||
|
{
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int acpi_dev_prop_get(struct acpi_device *adev,
|
static inline int acpi_dev_prop_get(struct acpi_device *adev,
|
||||||
const char *propname,
|
const char *propname,
|
||||||
void **valptr)
|
void **valptr)
|
||||||
|
@ -795,6 +810,14 @@ static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
|
||||||
|
const char *propname,
|
||||||
|
enum dev_prop_type proptype,
|
||||||
|
void *val, size_t nval)
|
||||||
|
{
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int acpi_dev_prop_read(struct acpi_device *adev,
|
static inline int acpi_dev_prop_read(struct acpi_device *adev,
|
||||||
const char *propname,
|
const char *propname,
|
||||||
enum dev_prop_type proptype,
|
enum dev_prop_type proptype,
|
||||||
|
|
Loading…
Reference in New Issue