Message ID | 20230318201640.63238-1-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp452542wrt; Sat, 18 Mar 2023 13:50:24 -0700 (PDT) X-Google-Smtp-Source: AK7set+1oa5e/Q19Kxa1crnGeekbarAJjT+AcsjQr9+ESg+33AzwtLwcYTQ5ri5wvdcO0rHSQX4m X-Received: by 2002:a17:902:f945:b0:1a0:49eb:4cb2 with SMTP id kx5-20020a170902f94500b001a049eb4cb2mr10364795plb.13.1679172624527; Sat, 18 Mar 2023 13:50:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679172624; cv=pass; d=google.com; s=arc-20160816; b=HlQKaripcZssgddO9xT5iGXJnB4BC/fdzdsTwNx3nYKhIe+jD2F6WAScnT3FZw7Otj nLndazfiiNQG6SSmbMy3Fc+OBc1mMvG6etIrIdnaRLezWvTsHm3OTY1DhizvQrceQq34 /TBS6K5HTFrs6C9Q3Zbt83N3ytRlALQ2qQZtpMTQOwx1b+fI8CVrg/dzFs7UoQY7rBhv 5BRTM14XKxVHyAczwl441BDOD+kn1t86wkSL7ChaTJquaphr2gHd+dBXLfGt6NIo3AeE eblvZX6EUmLppDfhOsN/MXogfcBg0vM/ebWqofQsYG2KlPeqKbfo9a/mTExo4iiOesd3 3tLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=MNwcOwmhOOXwGP2v58fMFXMsY7+WbcCQ1tbvb704xL4=; b=T8Dwp9FIv5xRnEDceBK82oRlFEO+OFqKmopZLhqKJ70OJiZalQDiGZI4klTZzQmVHq N5c2syjJ9y91ctfAHKXwDHtLzjhiz5gXU0nXHLuiIZhpxQtncSyAd6rOqyA7tPjKIEZf ZG1YXEknQsTIpoW3wPkjTOxomHyUSEfLMShbtQ0AvET46EQHSMQhDFPlea4tm8b3b/O0 AIOm3yluEIgE3304MJ4S8bwBSrzxxXx1CgVvkmhyqFexBFjwt6HcyHMkwrbnDhOZmk5X Nl5Il+4cm0ZLpgHwZ11eOqQ55tL0GfedSQP0XxrVIEJ1m62he69wPkEtAqDVp58hYZaQ a1vQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=PbAontzN; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a1709027b9300b001a1b53ff368si2697111pll.455.2023.03.18.13.50.12; Sat, 18 Mar 2023 13:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=PbAontzN; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjCRURA (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Sat, 18 Mar 2023 16:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbjCRUQ7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 18 Mar 2023 16:16:59 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2116.outbound.protection.outlook.com [40.107.215.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DACB211F9 for <linux-kernel@vger.kernel.org>; Sat, 18 Mar 2023 13:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EWYHyiaEQ6lP4i0uBNrW5MSc9cqsD2Be9RYCTAPYFFRlxEJAX2jEGHi5LPE1uNcUmBJ3p6PhiM0qqvlaKKFEmWh6DqH8zYPdUo4HW7V/ntjM4WzBpXtDfhljaIFCPQHlUgo8o62hF67BLWxfeNNH6gFpKzUmwg09ht+gzrLRN8Uf/fWfoMSXkEX3PtcLyeVN8zSvymuIfVkDNeocZAZ8xLLkYbsfkalK1Y7CFrOFRwH07N2rD/ptuUd213DoNCXAQ4hp96UVAB7tnSsHChC91naPMyvUF6OEOtXTIZ4rSKMT6CkTrgsuDcd9Xi8P1Qd3p0dT8p7PPDsmewd11vMvDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MNwcOwmhOOXwGP2v58fMFXMsY7+WbcCQ1tbvb704xL4=; b=PJYc7iz/7eUQIhnvWwUTYIANSaKd00B+YmjDvVk3gZPG3PYrpNP1qK8Q5KG5XgXhIVYtJu4+DEUzO3hJZ7hrGOEdmBqX6yycsrgzSUYLq0fbkE7bFOezwTjFo2GJ3FU9flBhyPsRiHZdGr3UsI8SN9YmgY1o/a5xi+Cu23Ue5pj2U2E3m/jvNDou5iyyjQ4TPAwccDg9Ete9BS5xCHQhTHC2qDKXq3qs/Hy7HMaycW9Z5vvIQaS/YjwXI8UQsOrfjkCMdFoUifUrOhoBgULuMzJbxKDkKWhGG3Z9xhwanT+RhLnb5YUzPQ99V41QAU+/P+CmccgGKv5OtRMQLHTrLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MNwcOwmhOOXwGP2v58fMFXMsY7+WbcCQ1tbvb704xL4=; b=PbAontzNRqVZatG+YIaQDq+jjC3qdliOwFV8wS0SZlSencwa/p1hX0nGuOmBr3U8rF+P3JXmE/r1lVxmMTgUClRmOvGmbjK9nlP48VV6n9irdQc0ZdrDKqnSEt2+XpwTtEj/gTxbo6PsOYtj6sC5F/Cd5oF5gUI2B2XcOCUsb/yU5ypYHKxy0bND55NniPP6pYtFWuvX0qOQuOAHsBFsFK0TzncDp06ZDTaRsUu71IuDJj122jxxaUF55aFDywnIpSsle/a80pd5tCUE37rRiRUqInsH1lYGk3+tpheJi6WeM/z6J7flnqkYI+KnwrUIZguMT2rLnRG3rkckYQyzyQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) by TY0PR06MB5077.apcprd06.prod.outlook.com (2603:1096:400:1bb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.36; Sat, 18 Mar 2023 20:16:53 +0000 Received: from TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190]) by TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190%2]) with mapi id 15.20.6178.036; Sat, 18 Mar 2023 20:16:50 +0000 From: Yangtao Li <frank.li@vivo.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org> Cc: Yangtao Li <frank.li@vivo.com>, linux-kernel@vger.kernel.org Subject: [PATCH] kobject: introduce kobject_del_and_put() Date: Sun, 19 Mar 2023 04:16:39 +0800 Message-Id: <20230318201640.63238-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI1PR02CA0039.apcprd02.prod.outlook.com (2603:1096:4:1f6::9) To TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB5275:EE_|TY0PR06MB5077:EE_ X-MS-Office365-Filtering-Correlation-Id: 0708801b-b485-40d1-a981-08db27edb51b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mCsvm2QDBX+CIFEV2nsZ7NY0pfSzbx1VJWSPcZqWTtjwWHP2691jVWy8mS/4nvHV9FKl/HcnJaFUDmlFzVe+uhveIZHmT3Jo9Jjr5VOBjPDUuRvO8bJH2X3oMQUqpr9ukvH8pXbD06JH1QbMW+Dh9j8k5WgoYl51MG7oZssvt18Hh+an78S+rj9bUN6YDPP7XDFGikufRvfpzn6UuCTsdAvdQixRynOiP76RxCGuPbtNIW1nUxZUuhRYCnY5vfwhjhC3wIe+oLw4QsBPawUYAesQ6nysnaMWvhel0GJ5kq8HlGE/MEu9wEEoUyWrPl+agjVqZ9bFuwfT30rcpzISqDgz5LtqkiUN4+hhdO3GS22n8ke7YaKKKUGdWfjgrgbwoV+QTQC6HTrUVlh446tj/RtCxSRMvTNT+nfk05Q2MCWlO7xgOZFDKaP2w9gzPELx8wbVnqdJERyXG0U6XaDzpw0TB/7n0CcupFfiP3b0sY/KopZJs1olBf4Nci53FCw2s37CZla0llNhCHPZGo+jy/arBI1exJCJCvPn+GUbgrirs3xdymu1NYCaTBYTfUQBMsVNyBe3Az1AWWau4kfbFRVh9N1WU89frobBujL3pN+wO2favljbb4B9GCwIfhbwPo5qH9O16SuVZBPoXEzFLup/HgUi/X109Bf+Ne+sl2D5pT9DRBSSNn39mU9n93ULOaK2UU7d8Q+/OarQjzTVQg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB5275.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(346002)(39860400002)(366004)(396003)(451199018)(186003)(38100700002)(38350700002)(2616005)(6506007)(6512007)(1076003)(26005)(8936002)(41300700001)(6666004)(5660300002)(83380400001)(86362001)(2906002)(66946007)(8676002)(66476007)(66556008)(52116002)(110136005)(36756003)(4326008)(6486002)(478600001)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TVtP64cwicfH2cL/gGAsFjWxGGSqEnXo3cRq2MDhmgCgUnJTp00bn3tf/VeakoXmLGE5nDj40SHEaoZ279YsXSsa1xSvnrUzt1LgQ6HkyqK8U5+kGu3/ygvhDNXGLTmOwtPjnKYhlUglK10RcqKCVRkcKEsvEoUi7IJi7WJ2rlmoid9LrqAS540qEdrR3DePi3fxNhGcxVdGWsz0f9oVl0pZKWW42f25U0SAp59kWEivaFox2NNAKUA8D1prIlzlNCtJRyunPObpPlTvzF1fnJDZ2XtA3hf8Vu/IDVTgUQ7lFciIBfOiqjPc48n/BAeDENuKgyimsfjKrYUmygf1cgyQYlWIypm19OYK1gLMvvsEave9f/arNXwpw5LfwleDw9Z9rh94beDSb5S7D0LYT5K15N155u031RsmB2eqZSINmd3IhUvQKAbofFJ71cckY1gtOosjdvBb329a4Ef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s3G28uPqiKoLglxj/iOBrHtzczMgvjNDV2op4 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0708801b-b485-40d1-a981-08db27edb51b X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB5275.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2023 20:16:50.4933 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /liUYT4gv/SFGFc2h+m19SS3qXTO3zyxJ8rmczadizDmuJfEsZimGYKRGRUCb4PJF4XYCkT9My/1br7WyzMYmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5077 X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760740114256313289?= X-GMAIL-MSGID: =?utf-8?q?1760740114256313289?= |
Series |
kobject: introduce kobject_del_and_put()
|
|
Commit Message
李扬韬
March 18, 2023, 8:16 p.m. UTC
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(-)
Comments
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
From: Yangtao Li <frank.li@vivo.com> > Sent: 18 March 2023 20:17 > > 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. But why? You are adding an extra function call for no benefit. At best, perhaps, a static inline function. David ... > +void kobject_del_and_put(struct kobject *kobj) > +{ > + kobject_del(kobj); > + kobject_put(kobj); > +} > +EXPORT_SYMBOL_GPL(kobject_del_and_put); > + > static void dynamic_kobj_release(struct kobject *kobj) > { > pr_debug("kobject: (%p): %s\n", kobj, __func__); > @@ -874,8 +888,7 @@ void kset_unregister(struct kset *k) > { > if (!k) > return; > - kobject_del(&k->kobj); > - kobject_put(&k->kobj); > + kobject_del_and_put(&k->kobj); > } > EXPORT_SYMBOL(kset_unregister); > > -- > 2.35.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
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); + static void dynamic_kobj_release(struct kobject *kobj) { pr_debug("kobject: (%p): %s\n", kobj, __func__); @@ -874,8 +888,7 @@ void kset_unregister(struct kset *k) { if (!k) return; - kobject_del(&k->kobj); - kobject_put(&k->kobj); + kobject_del_and_put(&k->kobj); } EXPORT_SYMBOL(kset_unregister);