mirror of https://gitee.com/openkylin/linux.git
software node: Allow register and unregister software node groups
Sometimes it's more convenient to register a set of individual software nodes grouped together. Add couple of functions for that. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
This commit is contained in:
parent
96489ae170
commit
02094d5487
|
@ -726,6 +726,54 @@ void software_node_unregister_nodes(const struct software_node *nodes)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(software_node_unregister_nodes);
|
||||
|
||||
/**
|
||||
* software_node_register_node_group - Register a group of software nodes
|
||||
* @node_group: NULL terminated array of software node pointers to be registered
|
||||
*
|
||||
* Register multiple software nodes at once.
|
||||
*/
|
||||
int software_node_register_node_group(const struct software_node **node_group)
|
||||
{
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
if (!node_group)
|
||||
return 0;
|
||||
|
||||
for (i = 0; node_group[i]; i++) {
|
||||
ret = software_node_register(node_group[i]);
|
||||
if (ret) {
|
||||
software_node_unregister_node_group(node_group);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(software_node_register_node_group);
|
||||
|
||||
/**
|
||||
* software_node_unregister_node_group - Unregister a group of software nodes
|
||||
* @node_group: NULL terminated array of software node pointers to be unregistered
|
||||
*
|
||||
* Unregister multiple software nodes at once.
|
||||
*/
|
||||
void software_node_unregister_node_group(const struct software_node **node_group)
|
||||
{
|
||||
struct swnode *swnode;
|
||||
unsigned int i;
|
||||
|
||||
if (!node_group)
|
||||
return;
|
||||
|
||||
for (i = 0; node_group[i]; i++) {
|
||||
swnode = software_node_to_swnode(node_group[i]);
|
||||
if (swnode)
|
||||
fwnode_remove_software_node(&swnode->fwnode);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(software_node_unregister_node_group);
|
||||
|
||||
/**
|
||||
* software_node_register - Register static software node
|
||||
* @node: The software node to be registered
|
||||
|
|
|
@ -440,6 +440,9 @@ software_node_find_by_name(const struct software_node *parent,
|
|||
int software_node_register_nodes(const struct software_node *nodes);
|
||||
void software_node_unregister_nodes(const struct software_node *nodes);
|
||||
|
||||
int software_node_register_node_group(const struct software_node **node_group);
|
||||
void software_node_unregister_node_group(const struct software_node **node_group);
|
||||
|
||||
int software_node_register(const struct software_node *node);
|
||||
|
||||
int software_node_notify(struct device *dev, unsigned long action);
|
||||
|
|
Loading…
Reference in New Issue