Re: [RFC PATCH v3 1/9] software_node: Add helper function to unregister arrays of software_nodes ordered parent to child

From: Heikki Krogerus
Date: Tue Oct 20 2020 - 07:04:54 EST


On Tue, Oct 20, 2020 at 02:01:55PM +0300, Andy Shevchenko wrote:
> On Tue, Oct 20, 2020 at 01:05:10PM +0300, Sakari Ailus wrote:
> > On Mon, Oct 19, 2020 at 11:58:55PM +0100, 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, add a helper function to loop
> > > over and unregister nodes in such an array in reverse order.
>
> ...
>
> > > + * software_node_unregister_nodes_reverse - Unregister an array of software
> > > + * nodes in reverse order.
> > > + * @nodes: Array of software nodes to be unregistered.
> > > + *
> > > + * NOTE: The same warning applies as with software_node_unregister_nodes.
> > > + * Unless you are _sure_ that the array of nodes is ordered parent to child
> > > + * it is wiser to remove them individually in the correct order.
> >
> > Could the default order in software_node_unregister_nodes() be reversed
> > instead? There are no users so this should be easy to change.
> >
> > Doing this only one way may require enforcing the registration order in
> > software_node_register_nodes(), but the end result would be safer.
> >
> > What do you think?
>
> Will work for me (I would also hear Heikki).

Sounds reasonable to me.

thanks,

--
heikki