From patchwork Wed Feb 15 00:25:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9573133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 08899600F6 for ; Wed, 15 Feb 2017 00:27:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0E3F205D6 for ; Wed, 15 Feb 2017 00:27:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5F5328438; Wed, 15 Feb 2017 00:27:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFF69205D6 for ; Wed, 15 Feb 2017 00:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbdBOA1b (ORCPT ); Tue, 14 Feb 2017 19:27:31 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:50689 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbdBOA12 (ORCPT ); Tue, 14 Feb 2017 19:27:28 -0500 X-IronPort-AV: E=Sophos;i="5.35,163,1483977600"; d="scan'208";a="81774872" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2017 08:43:12 +0800 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 5A.E4.57638.B20A3A85; Tue, 14 Feb 2017 16:26:19 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 14 Feb 2017 16:26:15 -0800 X-AuditID: 0ac94369-26dee9800001e126-71-58a3a02b20a2 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 3B.7D.11415.720A3A85; Tue, 14 Feb 2017 16:26:15 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Joel Becker , Christoph Hellwig Subject: [PATCH v6 11/33] configfs: Introduce config_item_get_unless_zero() Date: Tue, 14 Feb 2017 16:25:50 -0800 Message-ID: <20170215002612.14566-12-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215002612.14566-1-bart.vanassche@sandisk.com> References: <20170215002612.14566-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsXCddJ5ka72gsURBrvu21isXH2UyeLkuW8s Fm2rzzBatC59y+TA4vH0YpDH/e1HmDx232xg8/i8SS6AJYrLJiU1J7MstUjfLoEro//aFLaC V1wVJyeENTDO4+xi5OSQEDCR+PmwiaWLkYtDSGApk8ScHTPZIJxtjBIvLn1mhKk6+7+NGSKx kVHi26f7bCAJNgEjiW/vZ7KA2CJA9uqeZUwgRcwC0xgl/q09ww6SEBbwlng7dT5YA4uAqsSn SzfBpvIKOEg0Tl/IArFBXmJX20VWEJsTKD5jx0mgOAfQNnuJR2esQWZKCDSxSsw9vpsdoldQ 4uTMJ2C9zAISEgdfvGAGsYUE1CVOLpnPNIFRaBaSsllIyhYwMq1iFMvNzCnOTU8tMDTVK07M S8ksztZLzs/dxAgJ7MwdjHefeB9iFOBgVOLhPSG7OEKINbGsuDL3EKMEB7OSCC9bPVCINyWx siq1KD++qDQntfgQozQHi5I47zmZqRFCAumJJanZqakFqUUwWSYOTqkGxrq5BX+cjHlO8DJ3 effsEZm7/UTPxc/X9U8xrlmqcedn0x3xjxs1V68X5Wx5mCDA8PW73Z0pb+fK79d8oceavutD 6W+9pQn18yunJX+VPtB1cSZPSmYX81mXXbMM125ViCyoM2Ssu/G35mbhkZoUpkOXqyf8fr3s xM8PGy2OqR4p7fgd4FgQdkSJpTgj0VCLuag4EQB7pC5haAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMJMWRmVeSWpSXmKPExsXCtZGTTVd9weIIg2V/RS0O/mxjtFi5+iiT xclz31gs2lafYbRoXfqWyYHV4+nFII/7248weey+2cDmMW3NeSaPz5vkAlijuGxSUnMyy1KL 9O0SuDL6r01hK3jFVXFyQlgD4zzOLkZODgkBE4mz/9uYQWwhgfWMEku2VYDYbAJGEt/ez2QB sUWA7NU9y5i6GLk4mAWmMUrcW/UfLCEs4C3xdup8NhCbRUBV4tOlm4wgNq+Ag8ST92+ZIBbI S+xqu8gKYnMCxWfsOAnUywG0zF7i0RnrCYzcCxgZVjGK5WbmFOemZxYYGuoVJ+alZBZn6yXn 525ihARD5A7GpxPNDzEycXBKNTDejT7rZVndXb5Z6k7Y1I1fTy89lXJmpaJpXr/UNTVx8e23 1xYsm6s18eatUL+5RfO3Hs9ZyG1UeMGuk++XcvPj3/4rhI2FryZ/MA+zUwn7Gmwder5FeHv3 rRsJHQqur9NnvbdY7FpQy5i3Ijt1+XGRaYfW67MntCir/RB94SBi1t5aPuPryTAlluKMREMt 5qLiRACahB0BtgEAAA== MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Bart Van Assche Cc: Joel Becker Cc: Christoph Hellwig --- fs/configfs/item.c | 6 ++++++ include/linux/configfs.h | 1 + 2 files changed, 7 insertions(+) diff --git a/fs/configfs/item.c b/fs/configfs/item.c index 8b2a994042dd..e3501b9bbb60 100644 --- a/fs/configfs/item.c +++ b/fs/configfs/item.c @@ -138,6 +138,12 @@ struct config_item *config_item_get(struct config_item *item) } EXPORT_SYMBOL(config_item_get); +struct config_item *config_item_get_unless_zero(struct config_item *item) +{ + return item && kref_get_unless_zero(&item->ci_kref) ? item : NULL; +} +EXPORT_SYMBOL(config_item_get_unless_zero); + static void config_item_cleanup(struct config_item *item) { struct config_item_type *t = item->ci_type; diff --git a/include/linux/configfs.h b/include/linux/configfs.h index 2319b8c108e8..406e16dabc28 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h @@ -75,6 +75,7 @@ extern void config_item_init_type_name(struct config_item *item, struct config_item_type *type); extern struct config_item * config_item_get(struct config_item *); +extern struct config_item * config_item_get_unless_zero(struct config_item *); extern void config_item_put(struct config_item *); struct config_item_type {