From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D0A6C7618A for ; Sun, 19 Mar 2023 07:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbjCSH7J (ORCPT ); Sun, 19 Mar 2023 03:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjCSH7H (ORCPT ); Sun, 19 Mar 2023 03:59:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EA14193DC for ; Sun, 19 Mar 2023 00:59:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CE010B80ABB for ; Sun, 19 Mar 2023 07:59:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 050ABC433D2; Sun, 19 Mar 2023 07:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1679212739; bh=BTle2lhy5iEW02MGCJY9geeNU3aFSuJScixnDBXcc5c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IVpTgaP9SBppUP8G4gMO5tF64y6PeAuux2X2h1Bbt8D3kzds9VvOBjBl1911PGG6A cDoSuw9tqTBl3GZmNrkkaxubG4kYJ3W8EtiTKTHsWVtC1P7XwnSEaZyPjZld6t1Omr nDx47+cjpV6MvNFia0yDEr6F450gr56OH8ECG5ec= Date: Sun, 19 Mar 2023 08:58:56 +0100 From: Greg Kroah-Hartman To: Yangtao Li Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kobject: introduce kobject_del_and_put() Message-ID: References: <20230318201640.63238-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230318201640.63238-1-frank.li@vivo.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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