Skip to content

Commit

Permalink
ACPI: Constify internal fwnode arguments
Browse files Browse the repository at this point in the history
Constify internal ACPI fwnode arguments in preparation for the same in
fwnode API.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Sakari Ailus authored and Rafael J. Wysocki committed Jul 21, 2017
1 parent 8b9d680 commit 99a8546
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
34 changes: 18 additions & 16 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "internal.h"

static int acpi_data_get_property_array(struct acpi_device_data *data,
static int acpi_data_get_property_array(const struct acpi_device_data *data,
const char *name,
acpi_object_type type,
const union acpi_object **obj);
Expand Down Expand Up @@ -417,7 +417,7 @@ void acpi_free_properties(struct acpi_device *adev)
* %-EINVAL if the property doesn't exist,
* %-EPROTO if the property value type doesn't match @type.
*/
static int acpi_data_get_property(struct acpi_device_data *data,
static int acpi_data_get_property(const struct acpi_device_data *data,
const char *name, acpi_object_type type,
const union acpi_object **obj)
{
Expand Down Expand Up @@ -459,20 +459,21 @@ static int acpi_data_get_property(struct acpi_device_data *data,
* @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,
int acpi_dev_get_property(const 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)
static const struct acpi_device_data *
acpi_device_data_of_node(const struct fwnode_handle *fwnode)
{
if (is_acpi_device_node(fwnode)) {
struct acpi_device *adev = to_acpi_device_node(fwnode);
const struct acpi_device *adev = to_acpi_device_node(fwnode);
return &adev->data;
} else if (is_acpi_data_node(fwnode)) {
struct acpi_data_node *dn = to_acpi_data_node(fwnode);
const struct acpi_data_node *dn = to_acpi_data_node(fwnode);
return &dn->data;
}
return NULL;
Expand All @@ -484,8 +485,8 @@ static struct acpi_device_data *acpi_device_data_of_node(struct fwnode_handle *f
* @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)
int acpi_node_prop_get(const struct fwnode_handle *fwnode,
const char *propname, void **valptr)
{
return acpi_data_get_property(acpi_device_data_of_node(fwnode),
propname, ACPI_TYPE_ANY,
Expand All @@ -511,7 +512,7 @@ int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
* %-EPROTO if the property is not a package or the type of its elements
* doesn't match @type.
*/
static int acpi_data_get_property_array(struct acpi_device_data *data,
static int acpi_data_get_property_array(const struct acpi_device_data *data,
const char *name,
acpi_object_type type,
const union acpi_object **obj)
Expand Down Expand Up @@ -571,13 +572,13 @@ static int acpi_data_get_property_array(struct acpi_device_data *data,
*
* Return: %0 on success, negative error code on failure.
*/
int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *propname, size_t index, size_t num_args,
struct acpi_reference_args *args)
{
const union acpi_object *element, *end;
const union acpi_object *obj;
struct acpi_device_data *data;
const struct acpi_device_data *data;
struct acpi_device *device;
int ret, idx = 0;

Expand Down Expand Up @@ -673,7 +674,7 @@ int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
}
EXPORT_SYMBOL_GPL(__acpi_node_get_property_reference);

static int acpi_data_prop_read_single(struct acpi_device_data *data,
static int acpi_data_prop_read_single(const struct acpi_device_data *data,
const char *propname,
enum dev_prop_type proptype, void *val)
{
Expand Down Expand Up @@ -812,7 +813,7 @@ static int acpi_copy_property_array_string(const union acpi_object *items,
return nval;
}

static int acpi_data_prop_read(struct acpi_device_data *data,
static int acpi_data_prop_read(const struct acpi_device_data *data,
const char *propname,
enum dev_prop_type proptype,
void *val, size_t nval)
Expand Down Expand Up @@ -866,7 +867,7 @@ static int acpi_data_prop_read(struct acpi_device_data *data,
return ret;
}

int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
int acpi_dev_prop_read(const 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;
Expand All @@ -884,8 +885,9 @@ int acpi_dev_prop_read(struct acpi_device *adev, const char *propname,
* 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)
int acpi_node_prop_read(const 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);
Expand Down
40 changes: 22 additions & 18 deletions include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1003,27 +1003,30 @@ struct acpi_reference_args {
};

#ifdef CONFIG_ACPI
int acpi_dev_get_property(struct acpi_device *adev, const char *name,
int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
acpi_object_type type, const union acpi_object **obj);
int __acpi_node_get_property_reference(struct fwnode_handle *fwnode,
int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index, size_t num_args,
struct acpi_reference_args *args);

static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
static inline int acpi_node_get_property_reference(
const struct fwnode_handle *fwnode,
const char *name, size_t index,
struct acpi_reference_args *args)
{
return __acpi_node_get_property_reference(fwnode, name, index,
MAX_ACPI_REFERENCE_ARGS, args);
}

int acpi_node_prop_get(struct fwnode_handle *fwnode, const char *propname,
int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
void **valptr);
int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname,
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_single(struct acpi_device *adev,
const char *propname, enum dev_prop_type proptype,
void *val);
int acpi_node_prop_read(const struct fwnode_handle *fwnode,
const char *propname, enum dev_prop_type proptype,
void *val, size_t nval);
int acpi_dev_prop_read(const struct acpi_device *adev, const char *propname,
enum dev_prop_type proptype, void *val, size_t nval);

struct fwnode_handle *acpi_get_next_subnode(struct fwnode_handle *fwnode,
Expand Down Expand Up @@ -1100,51 +1103,52 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
}

static inline int
__acpi_node_get_property_reference(struct fwnode_handle *fwnode,
__acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index, size_t num_args,
struct acpi_reference_args *args)
{
return -ENXIO;
}

static inline int acpi_node_get_property_reference(struct fwnode_handle *fwnode,
const char *name, size_t index,
struct acpi_reference_args *args)
static inline int
acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
const char *name, size_t index,
struct acpi_reference_args *args)
{
return -ENXIO;
}

static inline int acpi_node_prop_get(struct fwnode_handle *fwnode,
static inline int acpi_node_prop_get(const 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(const struct acpi_device *adev,
const char *propname,
void **valptr)
{
return -ENXIO;
}

static inline int acpi_dev_prop_read_single(struct acpi_device *adev,
static inline int acpi_dev_prop_read_single(const struct acpi_device *adev,
const char *propname,
enum dev_prop_type proptype,
void *val)
{
return -ENXIO;
}

static inline int acpi_node_prop_read(struct fwnode_handle *fwnode,
static inline int acpi_node_prop_read(const 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(const struct acpi_device *adev,
const char *propname,
enum dev_prop_type proptype,
void *val, size_t nval)
Expand Down

0 comments on commit 99a8546

Please sign in to comment.