lkml.org 
[lkml]   [2023]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 7/7] of: dynamic: add lifecycle docbook info to node creation functions
    Date
    The existing docbook comments for the functions related to creating
    a devicetree node do not explain the reference count of a newly
    created node, how decrementing the reference count to zero will
    free the associated memory, and the caller's responsibility to
    call of_node_put() on the node. Explain what happens when the
    reference count is decremented to zero.

    Signed-off-by: Frank Rowand <frowand.list@gmail.com>
    ---
    drivers/of/dynamic.c | 3 ++-
    include/linux/of.h | 11 +++++++++++
    2 files changed, 13 insertions(+), 1 deletion(-)

    diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
    index 657a65006056..12aa99018969 100644
    --- a/drivers/of/dynamic.c
    +++ b/drivers/of/dynamic.c
    @@ -443,7 +443,8 @@ struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags)
    * another node. The node data are dynamically allocated and all the node
    * flags have the OF_DYNAMIC & OF_DETACHED bits set.
    *
    - * Return: The newly allocated node or NULL on out of memory error.
    + * Return: The newly allocated node or NULL on out of memory error. Use
    + * of_node_put() on it when done to free the memory allocated for it.
    */
    struct device_node *__of_node_dup(const struct device_node *np,
    const char *full_name)
    diff --git a/include/linux/of.h b/include/linux/of.h
    index 8b9f94386dc3..e20a08c8a8c8 100644
    --- a/include/linux/of.h
    +++ b/include/linux/of.h
    @@ -100,6 +100,17 @@ struct of_reconfig_data {
    struct property *old_prop;
    };

    +/**
    + * of_node_init - initialize a devicetree node
    + * @node: Pointer to device node that has been created by kzalloc()
    + * @phandle_name: Name of property holding a phandle value
    + *
    + * On return the device_node refcount is set to one. Use of_node_put()
    + * on @node when done to free the memory allocated for it. If the node
    + * is NOT a dynamic node the memory will not be freed. The decision of
    + * whether to free the memory will be done by node->release(), which is
    + * of_node_release().
    + */
    /* initialize a node */
    extern struct kobj_type of_node_ktype;
    extern const struct fwnode_operations of_fwnode_ops;
    --
    Frank Rowand <frowand.list@gmail.com>
    \
     
     \ /
      Last update: 2023-03-27 00:20    [W:5.358 / U:0.168 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site