linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] software node: Allow node addition to already existing device
@ 2021-04-14  7:54 Heikki Krogerus
  2021-04-14  9:13 ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2021-04-14  7:54 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, Pierre-Louis Bossart

If the node is added to an already exiting device, the node
needs to be also linked to the device separately.

This will make sure the reference count is kept in balance
also when the node is injected to a device afterwards.

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fixes: e68d0119e328 ("software node: Introduce device_add_software_node()")
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/base/swnode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 740333629b420..3cc11b813f28c 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -1045,6 +1045,7 @@ int device_add_software_node(struct device *dev, const struct software_node *nod
 	}
 
 	set_secondary_fwnode(dev, &swnode->fwnode);
+	software_node_notify(dev, KOBJ_ADD);
 
 	return 0;
 }
@@ -1118,8 +1119,8 @@ int software_node_notify(struct device *dev, unsigned long action)
 
 	switch (action) {
 	case KOBJ_ADD:
-		ret = sysfs_create_link(&dev->kobj, &swnode->kobj,
-					"software_node");
+		ret = sysfs_create_link_nowarn(&dev->kobj, &swnode->kobj,
+					       "software_node");
 		if (ret)
 			break;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] software node: Allow node addition to already existing device
  2021-04-14  7:54 [PATCH] software node: Allow node addition to already existing device Heikki Krogerus
@ 2021-04-14  9:13 ` Heikki Krogerus
  2021-04-14  9:17   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2021-04-14  9:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Andy Shevchenko, Rafael J. Wysocki, Pierre-Louis Bossart,
	linux-acpi, linux-kernel

+Greg

Sorry about that. Should I resend this?

On Wed, Apr 14, 2021 at 10:54:38AM +0300, Heikki Krogerus wrote:
> If the node is added to an already exiting device, the node
> needs to be also linked to the device separately.
> 
> This will make sure the reference count is kept in balance
> also when the node is injected to a device afterwards.
> 
> Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Fixes: e68d0119e328 ("software node: Introduce device_add_software_node()")
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/base/swnode.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index 740333629b420..3cc11b813f28c 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -1045,6 +1045,7 @@ int device_add_software_node(struct device *dev, const struct software_node *nod
>  	}
>  
>  	set_secondary_fwnode(dev, &swnode->fwnode);
> +	software_node_notify(dev, KOBJ_ADD);
>  
>  	return 0;
>  }
> @@ -1118,8 +1119,8 @@ int software_node_notify(struct device *dev, unsigned long action)
>  
>  	switch (action) {
>  	case KOBJ_ADD:
> -		ret = sysfs_create_link(&dev->kobj, &swnode->kobj,
> -					"software_node");
> +		ret = sysfs_create_link_nowarn(&dev->kobj, &swnode->kobj,
> +					       "software_node");
>  		if (ret)
>  			break;
>  
> -- 
> 2.30.2

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] software node: Allow node addition to already existing device
  2021-04-14  9:13 ` Heikki Krogerus
@ 2021-04-14  9:17   ` Greg Kroah-Hartman
  2021-04-14 11:34     ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-14  9:17 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Andy Shevchenko, Rafael J. Wysocki, Pierre-Louis Bossart,
	linux-acpi, linux-kernel

On Wed, Apr 14, 2021 at 12:13:35PM +0300, Heikki Krogerus wrote:
> +Greg
> 
> Sorry about that. Should I resend this?

No worries, I can pick it up, thanks

`b4` really is nice to use :)

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] software node: Allow node addition to already existing device
  2021-04-14  9:17   ` Greg Kroah-Hartman
@ 2021-04-14 11:34     ` Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2021-04-14 11:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Andy Shevchenko, Rafael J. Wysocki, Pierre-Louis Bossart,
	linux-acpi, linux-kernel

On Wed, Apr 14, 2021 at 11:17:55AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Apr 14, 2021 at 12:13:35PM +0300, Heikki Krogerus wrote:
> > +Greg
> > 
> > Sorry about that. Should I resend this?
> 
> No worries, I can pick it up, thanks
> 
> `b4` really is nice to use :)

Yes, it's a really nice tool.

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-14 11:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  7:54 [PATCH] software node: Allow node addition to already existing device Heikki Krogerus
2021-04-14  9:13 ` Heikki Krogerus
2021-04-14  9:17   ` Greg Kroah-Hartman
2021-04-14 11:34     ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).