lkml.org 
[lkml]   [2019]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 08/16] device property: Introduce fwnode_find_reference()
    Date
    In most cases the references that the drivers look for don't
    have any arguments. This introduces a wrapper function for
    fwnode_property_get_reference_args() that looks for
    references by using only the name and index.

    Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    ---
    drivers/base/property.c | 24 ++++++++++++++++++++++++
    include/linux/property.h | 4 ++++
    2 files changed, 28 insertions(+)

    diff --git a/drivers/base/property.c b/drivers/base/property.c
    index 348b37e64944..81bd01ed4042 100644
    --- a/drivers/base/property.c
    +++ b/drivers/base/property.c
    @@ -484,6 +484,30 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
    }
    EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);

    +/**
    + * fwnode_find_reference - Find named reference to a fwnode_handle
    + * @fwnode: Firmware node where to look for the reference
    + * @name: The name of the reference
    + * @index: Index of the reference
    + *
    + * @index can be used when the named reference holds a table of references.
    + *
    + * Returns pointer to the reference fwnode, or ERR_PTR. Caller is responsible to
    + * call fwnode_handle_put() on the returned fwnode pointer.
    + */
    +struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
    + const char *name,
    + unsigned int index)
    +{
    + struct fwnode_reference_args args;
    + int ret;
    +
    + ret = fwnode_property_get_reference_args(fwnode, name, NULL, 0, index,
    + &args);
    + return ret ? ERR_PTR(ret) : args.fwnode;
    +}
    +EXPORT_SYMBOL_GPL(fwnode_find_reference);
    +
    /**
    * device_remove_properties - Remove properties from a device object.
    * @dev: Device whose properties to remove.
    diff --git a/include/linux/property.h b/include/linux/property.h
    index abcde2f236a0..088d4db7e949 100644
    --- a/include/linux/property.h
    +++ b/include/linux/property.h
    @@ -79,6 +79,10 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
    unsigned int nargs, unsigned int index,
    struct fwnode_reference_args *args);

    +struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
    + const char *name,
    + unsigned int index);
    +
    struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
    struct fwnode_handle *fwnode_get_next_parent(
    struct fwnode_handle *fwnode);
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-05-22 12:52    [W:4.097 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site