[v2,RESEND,05/10] ubifs: convert to kobject_del_and_put()

Message ID 20230319092641.41917-5-frank.li@vivo.com
State New
Headers
Series [v2,RESEND,01/10] kobject: introduce kobject_del_and_put() |

Commit Message

李扬韬 March 19, 2023, 9:26 a.m. UTC
  Use kobject_del_and_put() to simplify code.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/ubifs/sysfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Zhihao Cheng March 20, 2023, 2:55 a.m. UTC | #1
Hi Yangtao,
> Use kobject_del_and_put() to simplify code.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/ubifs/sysfs.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/ubifs/sysfs.c b/fs/ubifs/sysfs.c
> index 1c958148bb87..9571718e61a9 100644
> --- a/fs/ubifs/sysfs.c
> +++ b/fs/ubifs/sysfs.c
> @@ -130,8 +130,7 @@ int ubifs_sysfs_register(struct ubifs_info *c)
>   
>   void ubifs_sysfs_unregister(struct ubifs_info *c)
>   {
> -	kobject_del(&c->kobj);
> -	kobject_put(&c->kobj);
> +	kobject_del_and_put(&c->kobj);
>   	wait_for_completion(&c->kobj_unregister);
>   
>   	kfree(c->stats);
> 

Maybe you can send the entire patchset to linux-mtd next time, I can 
only see patch 5 from the maillist. After confirming from other 
website(https://www.spinics.net/lists/kernel/msg4727274.html) I see you 
instroduced the implementation of kobject_del_and_put().

I have no objections if other modules can accept the kobject_del_and_put().
  

Patch

diff --git a/fs/ubifs/sysfs.c b/fs/ubifs/sysfs.c
index 1c958148bb87..9571718e61a9 100644
--- a/fs/ubifs/sysfs.c
+++ b/fs/ubifs/sysfs.c
@@ -130,8 +130,7 @@  int ubifs_sysfs_register(struct ubifs_info *c)
 
 void ubifs_sysfs_unregister(struct ubifs_info *c)
 {
-	kobject_del(&c->kobj);
-	kobject_put(&c->kobj);
+	kobject_del_and_put(&c->kobj);
 	wait_for_completion(&c->kobj_unregister);
 
 	kfree(c->stats);