From patchwork Fri Feb 10 01:28: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: 9565793 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 3C19060572 for ; Fri, 10 Feb 2017 01:29:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DDBA28532 for ; Fri, 10 Feb 2017 01:29:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214B92853B; Fri, 10 Feb 2017 01:29:44 +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 C87BF28532 for ; Fri, 10 Feb 2017 01:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751468AbdBJB3m (ORCPT ); Thu, 9 Feb 2017 20:29:42 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:18628 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbdBJB3h (ORCPT ); Thu, 9 Feb 2017 20:29:37 -0500 X-IronPort-AV: E=Sophos;i="5.33,348,1477929600"; d="scan'208";a="82349567" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 10 Feb 2017 09:29:02 +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 D2.97.57638.D571D985; Thu, 9 Feb 2017 17:29:02 -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; Thu, 9 Feb 2017 17:28:56 -0800 X-AuditID: 0ac94369-26dee9800001e126-05-589d175ddd48 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 89.9F.11415.7571D985; Thu, 9 Feb 2017 17:28:55 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Christoph Hellwig Subject: [PATCH v5 20/22] configfs: Introduce config_item_get_unless_zero() Date: Thu, 9 Feb 2017 17:28:50 -0800 Message-ID: <20170210012852.15735-21-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170210012852.15735-1-bart.vanassche@sandisk.com> References: <20170210012852.15735-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsXCddJ5kW6c+NwIg80bmC1Wrj7KZNG2+gyj RevSt0wOzB73tx9h8th9s4HN4/MmuQDmKC6blNSczLLUIn27BK6M6xtnsxQc4aq4snsacwPj X44uRk4OCQETiUuL/rB0MXJxCAksZZK4+fo4O4SzlVFi17xudpiqqdveMUMkNjJKPJx+mAUk wSZgJPHt/UwwWwTIXt2zjAnEZhYokljz6RxYs7CAt8ThKzsYQWwWARWJw51v2UBsXgEHiV0z J7JCLJCX2NV2EczmBIq/mn0dyOYAWmYvsWOXAcheCYFvLBJ/mpewQvQKSpyc+YQFYpeExMEX L5hBbCEBdYmTS+YzTWAUmoWkbBaSsgWMTKsYxXIzc4pz01MLDE31ihPzUjKLs/WS83M3MULC OHMH490n3ocYBTgYlXh4X9TMiRBiTSwrrsw9xCjBwawkwnufb26EEG9KYmVValF+fFFpTmrx IUZpDhYlcd5zMlMjhATSE0tSs1NTC1KLYLJMHJxSDYyMjm8ZLTaKzI5sKVE0dzh7UX6e1wyl aubiufc7TycG8B23WfSjK8ZEVNBhURxz4BfHhvldexYFLz9colXbaDp1m80nnY9HhF2sm0QZ nDllJ5/YY/U5h7Xx0sNbxaz5MV8NIjMnJT3zuaMkkjH93YSTK2r/HHJ+7hcuLBXAdmincci5 7EOmYkosxRmJhlrMRcWJAK+04JpfAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJMWRmVeSWpSXmKPExsXCtZGTTTdcfG6EwYv5ahYHf7YxWqxcfZTJ om31GUaL1qVvmRxYPO5vP8LksftmA5vHtDXnmTw+b5ILYInisklJzcksSy3St0vgyri+cTZL wRGuiiu7pzE3MP7l6GLk5JAQMJGYuu0dcxcjF4eQwHpGiX9HfzOCJNgEjCS+vZ/JAmKLANmr e5YxgdjMAkUSyzrPsYLYwgLeEoev7ACrZxFQlZjY/4+9i5GDg1fAQWLi5zyI+fISu9ougpVz AoVfzb7OClIiJGAvsWOXwQRG7gWMDKsYxXIzc4pz0zMLDA31ihPzUjKLs/WS83M3MUJ8H7mD 8elE80OMTBycUg2MptPrH+17nFXOekbi+BexTxuqTabsDl8z2325r6Yvi2bKCt7XTrtfnnki uWXKQ5bFmm73MkwS730R9rA+0VY2LW3aNJaZV9cdeFqWPPOdk3fvpD83Fq38UDIhWTv2QPnx 4sOdTMKMDvKfmSp4vmqc1FTZvGLD/ZqcxfKPI69+ezcloq88O/3XGSWW4oxEQy3mouJEACL8 rw+tAQAA 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: 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 {