software node: Fix device_add_software_node()
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Mon, 1 Mar 2021 14:30:12 +0000 (17:30 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 10 Mar 2021 14:25:02 +0000 (15:25 +0100)
commit2a92c90f2ecca4475d6050f2f938a1755a8954cc
tree33e536927813e403369f2ffa9096276a19f1424c
parent8891123f9cbb9c1ee531e5a87fa116f0af685c48
software node: Fix device_add_software_node()

The function device_add_software_node() was meant to
register the node supplied to it, but only if that node
wasn't already registered. Right now the function attempts
to always register the node. That will cause a failure with
nodes that are already registered.

Fixing that by incrementing the reference count of the nodes
that have already been registered, and only registering the
new nodes. Also, clarifying the behaviour in the function
documentation.

Fixes: e68d0119e328 ("software node: Introduce device_add_software_node()")
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/swnode.c
include/linux/property.h