diff mbox

[1/2] kobject: remove kset from sysfs immediately in kset_unregister()

Message ID 20131008202016.19377.17182.stgit@bhelgaas-glaptop.roam.corp.google.com
State Not Applicable
Headers show

Commit Message

Bjorn Helgaas Oct. 8, 2013, 8:20 p.m. UTC
There's no explicit "unlink from sysfs" interface for ksets, so I think
callers of kset_unregister() expect the kset to be removed from sysfs
immediately, without waiting for the last reference to be released.

This patch makes the sysfs removal happen immediately, so the caller may
create a new kset with the same name as soon as kset_unregister() returns.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 Documentation/kobject.txt |    3 ++-
 lib/kobject.c             |    1 +
 2 files changed, 3 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Greg Kroah-Hartman Dec. 3, 2013, 6:04 p.m. UTC | #1
On Tue, Oct 08, 2013 at 02:20:16PM -0600, Bjorn Helgaas wrote:
> There's no explicit "unlink from sysfs" interface for ksets, so I think
> callers of kset_unregister() expect the kset to be removed from sysfs
> immediately, without waiting for the last reference to be released.
> 
> This patch makes the sysfs removal happen immediately, so the caller may
> create a new kset with the same name as soon as kset_unregister() returns.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

With the PCI MSI attribute change, this patch is no longer needed,
right?

thanks,

greg k-h

> ---
>  Documentation/kobject.txt |    3 ++-
>  lib/kobject.c             |    1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
> index c5182bb..8e8b501 100644
> --- a/Documentation/kobject.txt
> +++ b/Documentation/kobject.txt
> @@ -342,7 +342,8 @@ kset use:
>  
>  When you are finished with the kset, call:
>    void kset_unregister(struct kset *kset);
> -to destroy it.
> +to destroy it.  This removes the kset from sysfs and, after the kset
> +reference count goes to zero, releases it.
>  
>  An example of using a kset can be seen in the
>  samples/kobject/kset-example.c file in the kernel tree.
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 9621751..9098992 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -753,6 +753,7 @@ void kset_unregister(struct kset *k)
>  {
>  	if (!k)
>  		return;
> +	kobject_del(&k->kobj);
>  	kobject_put(&k->kobj);
>  }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index c5182bb..8e8b501 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -342,7 +342,8 @@  kset use:
 
 When you are finished with the kset, call:
   void kset_unregister(struct kset *kset);
-to destroy it.
+to destroy it.  This removes the kset from sysfs and, after the kset
+reference count goes to zero, releases it.
 
 An example of using a kset can be seen in the
 samples/kobject/kset-example.c file in the kernel tree.
diff --git a/lib/kobject.c b/lib/kobject.c
index 9621751..9098992 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -753,6 +753,7 @@  void kset_unregister(struct kset *k)
 {
 	if (!k)
 		return;
+	kobject_del(&k->kobj);
 	kobject_put(&k->kobj);
 }