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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sakari

On 20/10/2020 11:05, Sakari Ailus wrote:
> Hi Daniel, Andy,
>
> 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.
>>
>> Suggested-by: Andriy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>> Signed-off-by: Daniel Scally <djrscally@xxxxxxxxx>
>> ---
>> Changes in v3:
>> 	- patch introduced.
>>
>>  drivers/base/swnode.c    | 21 +++++++++++++++++++++
>>  include/linux/property.h |  1 +
>>  2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
>> index 010828fc7..f01b1cc61 100644
>> --- a/drivers/base/swnode.c
>> +++ b/drivers/base/swnode.c
>> @@ -727,6 +727,27 @@ void software_node_unregister_nodes(const struct software_node *nodes)
>>  }
>>  EXPORT_SYMBOL_GPL(software_node_unregister_nodes);
>>  
>> +/**
>> + * 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?

Yeah fine by me. We can just use software_node_to_swnode(node->parent)
within software_node_unregister_nodes() to check that children come
after their parents have already been processed. I'll add a patch to do
that in the next version of this series, and another changing the
ordering of software_node_unregister_node_group() as Andy suggests for
consistency.




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux