lkml.org 
[lkml]   [2020]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 05/18] software_node: Alter software_node_unregister_nodes() to unregister the array in reverse order
    Hi Daniel,

    Thank you for the patch.

    On Mon, Nov 30, 2020 at 01:31:16PM +0000, Daniel Scally wrote:
    > Software nodes that are children of another software node should be
    > unregistered before their parent. To allow easy unregistering of an array
    > of software_nodes ordered parent to child, reverse the order in which
    > this function unregisters software_nodes.
    >
    > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    > Signed-off-by: Daniel Scally <djrscally@gmail.com>

    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

    > ---
    > Changes since RFC v3:
    >
    > Switched this functionality from a new function to replacing
    > the existing software_nodes_unregister_nodes()
    >
    > drivers/base/swnode.c | 19 ++++++++++++-------
    > 1 file changed, 12 insertions(+), 7 deletions(-)
    >
    > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
    > index af7930b3679e..d39e1c76d98d 100644
    > --- a/drivers/base/swnode.c
    > +++ b/drivers/base/swnode.c
    > @@ -720,20 +720,25 @@ EXPORT_SYMBOL_GPL(software_node_register_nodes);
    >
    > /**
    > * software_node_unregister_nodes - Unregister an array of software nodes
    > - * @nodes: Zero terminated array of software nodes to be unregistered
    > + * @nodes: Zero terminated array of software nodes to be unregistered. If
    > + * parent pointers are set up in any of the software nodes then the array
    > + * MUST be ordered such that parents come before their children.
    > *
    > * Unregister multiple software nodes at once.
    > *
    > - * NOTE: Be careful using this call if the nodes had parent pointers set up in
    > - * them before registering. If so, it is wiser to remove the nodes
    > - * individually, in the correct order (child before parent) instead of relying
    > - * on the sequential order of the list of nodes in the array.
    > + * NOTE: If you are uncertain whether the array is ordered such that
    > + * parents will be unregistered before their children, it is wiser to
    > + * remove the nodes individually, in the correct order (child before
    > + * parent).
    > */
    > void software_node_unregister_nodes(const struct software_node *nodes)
    > {
    > - int i;
    > + unsigned int i = 0;
    > +
    > + while (nodes[i].name)
    > + i++;
    >
    > - for (i = 0; nodes[i].name; i++)
    > + while (i--)
    > software_node_unregister(&nodes[i]);
    > }
    > EXPORT_SYMBOL_GPL(software_node_unregister_nodes);

    --
    Regards,

    Laurent Pinchart

    \
     
     \ /
      Last update: 2020-11-30 17:17    [W:4.946 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site