From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Yangtao Li <frank.li@vivo.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kobject: introduce kobject_del_and_put()
Date: Sun, 19 Mar 2023 08:58:56 +0100 [thread overview]
Message-ID: <ZBbAwC6PQ1ZELlyW@kroah.com> (raw)
In-Reply-To: <20230318201640.63238-1-frank.li@vivo.com>
On Sun, Mar 19, 2023 at 04:16:39AM +0800, Yangtao Li wrote:
> There are plenty of using kobject_del() and kobject_put() together
> in the kernel tree. This patch wraps these two calls in a single helper.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> include/linux/kobject.h | 1 +
> lib/kobject.c | 17 +++++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index bdab370a24f4..782d4bd119f8 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -111,6 +111,7 @@ extern struct kobject *kobject_get(struct kobject *kobj);
> extern struct kobject * __must_check kobject_get_unless_zero(
> struct kobject *kobj);
> extern void kobject_put(struct kobject *kobj);
> +extern void kobject_del_and_put(struct kobject *kobj);
>
> extern const void *kobject_namespace(const struct kobject *kobj);
> extern void kobject_get_ownership(const struct kobject *kobj,
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 6e2f0bee3560..8c0293e37214 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -731,6 +731,20 @@ void kobject_put(struct kobject *kobj)
> }
> EXPORT_SYMBOL(kobject_put);
>
> +/**
> + * kobject_del_and_put() - Delete kobject.
> + * @kobj: object.
> + *
> + * Unlink kobject from hierarchy and decrement the refcount.
> + * If refcount is 0, call kobject_cleanup().
> + */
> +void kobject_del_and_put(struct kobject *kobj)
> +{
> + kobject_del(kobj);
> + kobject_put(kobj);
> +}
> +EXPORT_SYMBOL_GPL(kobject_del_and_put);
We can't add exports or new functions like this without real users at
the same time, otherwise the export will quickly be removed.
So can you submit this as part of a patch series that actually uses it
so we can see if it's really even needed?
thanks,
greg k-h
next prev parent reply other threads:[~2023-03-19 7:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-18 20:16 [PATCH] kobject: introduce kobject_del_and_put() Yangtao Li
2023-03-19 7:58 ` Greg Kroah-Hartman [this message]
2023-03-19 22:22 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZBbAwC6PQ1ZELlyW@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=frank.li@vivo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox