Message ID | 20230319092641.41917-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 j10csp654074wrt; Sun, 19 Mar 2023 02:43:05 -0700 (PDT) X-Google-Smtp-Source: AK7set9QtoLUcNXyjZ7WcIHaDtCuLo3ApT39E3W+bAGLTvkGx6iGdTDfI4rg2eGAjtHj1+QxezqE X-Received: by 2002:a62:7bc7:0:b0:5ce:ef1b:a86 with SMTP id w190-20020a627bc7000000b005ceef1b0a86mr11340969pfc.2.1679218984705; Sun, 19 Mar 2023 02:43:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679218984; cv=pass; d=google.com; s=arc-20160816; b=UcTDaqTRC3kjyBr8NKkdFaOg3cLF2GpHTROQw1cLQCN5l9DS/ilewkLWWHHR/C+l8g CXmmC8eOCq9LK14i2mHRdd7gts5Rp7ODqZKZyco13HtEEj6DFt6mFPOErQt5HJxNhI1V C/Y3XkGSgc4CNL/by9E75bmS0iFgQaQEhEvfKLFSSHpiyFM+3VD8zncOOB5TViaAD1xl 06run3V0/qyR2GRTt1w5F50IVFnrbVZXSsYzokLa6ligebmNt/9VJ3hCTGcRQ1Q0nGZJ mGViUNGfP3J3ySPrR4SkwLDaE/TDHWnDRQNG0XywGuzYJ3O0JG7OTThThlKJQSYqWk+f t6Kw== 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=f/Ly6n6zozyf6Q7d27WyhzYVqOabq1IPEThi+wvRY2o=; b=pi99D0DebzVqRFDZU0p9y4rcdW8xTjwhz9gGnYApD/PBb13Te5yF6lkKvU1IPvRy6S +fH7nzqWqr0nwhsH2J/CPK5CPvZMj/pEaP7LrJy30q2BHJBFkLE3sz1l+J72Onu22LcX H92AwaJZ3SGQDgTOIO8qD3rokAt4pYpMqkAQaxEuxd5uzrF/ziWEhMEsbbk1zwoMKhL7 WKZNwzjDbNH/0wz30W1eJOzETmYl3E2NDpkvaPxwBGZDO/VfA0Wl2XtaRN2o1QPHHFZT XEViP7Vuce5DjaCnNYwEUhiGkwK45w6zz55s7OYBF2zLl19MB4uGwkfM3wIm5CDKBa51 umIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="gzwR/TQM"; 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 m36-20020a635824000000b0050beec91e30si7080949pgb.768.2023.03.19.02.42.43; Sun, 19 Mar 2023 02:43:04 -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="gzwR/TQM"; 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 S229967AbjCSJ1l (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Sun, 19 Mar 2023 05:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjCSJ1e (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 19 Mar 2023 05:27:34 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2123.outbound.protection.outlook.com [40.107.117.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B4E19F37 for <linux-kernel@vger.kernel.org>; Sun, 19 Mar 2023 02:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DW5WaaAXFBfqRsLtWMFuA8TZxZLbeckBGdlf1q2vTEiC+WyQMJ0SMEi/UhrYGEqZnHWh0WJuLd75Uhe4tz76IxQryYEzd8xZfb6cS/h8ZmHuLRsjzcMdfobzWc6+A/zgOegyH5f6kNPIdWEkUXHtiseREYZgyWgUs/Qi+YccwqwxLs2e8sqOVEwbs4sRTycmG1A951dzYB2MN2sEOX6oUWpa/Q9e97613z8smK/DIuxzS64m2ybsKl4+0UIn83Z9iLqNbXvBN00SrQky+RbpSRxIaT7LRUIvj0/VTSPHMfWB2sCt81QkOmI8dq9/PAmzGE6Id0fJNbkg6zH/ouVHlw== 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=f/Ly6n6zozyf6Q7d27WyhzYVqOabq1IPEThi+wvRY2o=; b=lghzOV8zRDfRQxtR76jse2BgaDPtBqdQYxySm8BK9x4dRXBFDkIy8mzLLWaGlPuWtUwF+CleKHnFTjJ00o9ORIMrW8JLegUyVG0x7fxF2a2eTorKGHfp0urkZFIm5PXlDIITNluAFPPj3lLK9pFZGUQhmX5CmQqlMWN+hWJxbFwlduR+yxDvlqfeTVuegyqGi2CBUKXARubYiSRMS6sM7gOLOVdUujezNabDyt95gG1NCEAjIbHL4qSddNLPpVssxT+pPUljA54kCm9pbZMW00j4L9fw2l+DIh0uOvw9qMYDofj/FuU8hh6KwB/WFAbaf1gKYI4mAiGo9ptz8JEAEw== 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=f/Ly6n6zozyf6Q7d27WyhzYVqOabq1IPEThi+wvRY2o=; b=gzwR/TQMQd58w1aRTywAJ0krwb5HsY3G9q0oGEk/lktczWED6eoLybJrVImGhmlmdXgAGbpbR5BeN2Zp0D5mLy5wQQpPrSgSSH4M0Wh8+5ZXbU6agbIR0RqO8XlhiUmmlD2nLidc8QrKchGeLW9Vcp4eONHOPI+OGe10F+X/M4ra4CPNUEy0sgytwNsGoonZDjlucFw8YHxDiPgQHugqVWEoB5NU3PGeX8tMRCsNXn4xnK7AsyVzn0kZCcvurumnZMLHynjrob1ZV3TD1hpmzvuDGu1LbmXBJ0qksMFLIu+62V6kPw/ExjPP62xtpu4cgBPEIpsKlM627PBjbu1Irw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4012.apcprd06.prod.outlook.com (2603:1096:4:f9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Sun, 19 Mar 2023 09:27:05 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::daf6:5ebb:a93f:1869]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::daf6:5ebb:a93f:1869%9]) with mapi id 15.20.6178.037; Sun, 19 Mar 2023 09:27:05 +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 v2, RESEND 01/10] kobject: introduce kobject_del_and_put() Date: Sun, 19 Mar 2023 17:26:32 +0800 Message-Id: <20230319092641.41917-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0137.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::17) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4012:EE_ X-MS-Office365-Filtering-Correlation-Id: b7655930-280f-42ba-8f6f-08db285c1ac2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T4A+JE7DBnIk8qGoYUz06DM2s7V0aIct6iWwL6ox3Tt0JhBMfBuSmQJ875/Eec3Wg2TmlR7jnGlKy86tAsmTu8zC30xI70OXRrNj/58rVwquYzRUl0kE2EJSaFLlFuzakVnjNjxWYX9ZPV4X8L+LLrp2rgat8ZkQZ484KcGMCVapn3xxGyiUdsvQZW3q80BIq9ccD04fuc5f+LSsz5kCSeJ5bEUWcJ7QVXcxgUHzq66un4HpJyk3UQ1i+cN6Te08clxQfX6qFZ+agrCdowPYZoR3EiA4b7KZssm//9ILGcfBFcZNXDG7+VOPpNPId5qzq+3/fOlLqjN/ZzV8O4oIz4n8iASaplPFh+a68ZfkPjzIlxaEfO/f20Q6kmg5FsYYjZz0Md8BR+gXi+Mk0DZ1VCLXKi2v1BEHOLjNg67+2p+c8y4rrZ0ONhx3L+miPyU43LJ9htN0pYr03ZpsN9I+9NlhCCRECtNErKVNLVvWhtsfqHDc3sIm41cpOKNUx2p69Amz60db5xEByh0Lgw9zlPdlG8slk0qDxXXfsOtE3tl/EuuIPkvRGeX0kYkeNtGCrGb6PVlGkvw/M9D7/cksBGQ8v2yWGYlgYZ0j/vXo++X8jCQrChEblqKgbl/QhkpCaaHJAp97+7+haO6GPxxnpT7k/Nm7lABmF7pr0dG0t2k00k7up4lv7Ksat0/Q9T2iqXR0V+J2Eskd7BvFK0wPQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(346002)(136003)(366004)(396003)(39850400004)(451199018)(52116002)(2616005)(478600001)(6486002)(83380400001)(6666004)(316002)(8676002)(66476007)(66556008)(66946007)(186003)(26005)(6506007)(6512007)(110136005)(1076003)(4326008)(5660300002)(41300700001)(8936002)(38350700002)(38100700002)(2906002)(36756003)(86362001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o4m0N1LlGV7da3PMiuSqsRY6JDc4BuG/MtkZzw1vnKHZdjveDFyP1QeByJm8XcFSP1b7CXpGHK/M11zkZaMndNAYSCbnOfC5E7QXhKy80mogvcK21Xdn40NCPJGwCdA+vHMr+tA/cXtsVL7hz2Em2jo0rWfH67QKMRzBS3nVwJewUbJz4mm+86g8L45HlMBWQ69atd24z/UDKSK69KW/YYidjtSaNAILlWB2SLPVqLduz1VdRmBmTzT6ukBngQSlxxhzJUYR7Y92AsX/Z5GiKq46EMAXmqBHSNBwp7y7J2GVNyEyI+JysXwWj7sc4L8U/BCIhJ2Go/2HHhhRv2n267qKp9eYcykune5kwuLf+YGw7R3Qg/HVCrekA6QuZ+T/XeKJnxvqfRoJer53HI1IJzOByANhKdS7H3tS7UzQ0Dd5kyQmkiytno6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dCCS4jYqGseAljj8yT3JzQ+mgyusFTefhaLv2mmKRAEsfCl7OQ/kBOf/bJsRnAq X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7655930-280f-42ba-8f6f-08db285c1ac2 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2023 09:27:05.5367 (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: JjnrRdtaUQvX3jPVse/tT2/yjMKQHR0eOfAbuNNhdiIQVanJyhpGnirTgdSZi2id6nj9Hv9cn5ov78ciShW5wQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4012 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 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?1760788725847988802?= X-GMAIL-MSGID: =?utf-8?q?1760788725847988802?= |
Series |
[v2,RESEND,01/10] kobject: introduce kobject_del_and_put()
|
|
Commit Message
李扬韬
March 19, 2023, 9:26 a.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>
---
v2:
-add kobject_del_and_put() users
resend patchset to gregkh and Rafael
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); + 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);