From patchwork Wed Feb 8 22:25:05 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: 9563641 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 55D1760236 for ; Wed, 8 Feb 2017 22:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A2D628530 for ; Wed, 8 Feb 2017 22:28:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F16228533; Wed, 8 Feb 2017 22:28:05 +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 C0F4428531 for ; Wed, 8 Feb 2017 22:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751149AbdBHW2C (ORCPT ); Wed, 8 Feb 2017 17:28:02 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:63858 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbdBHW2A (ORCPT ); Wed, 8 Feb 2017 17:28:00 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618230" Received: from unknown (HELO milsmgep14.sandisk.com) ([63.163.107.225]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:25 +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 B8.72.18895.DCA9B985; Wed, 8 Feb 2017 14:25:18 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Wed, 8 Feb 2017 14:25:11 -0800 X-AuditID: 0ac94371-0fadb980000049cf-05-589b9acd75ca Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id A9.42.18148.8CA9B985; Wed, 8 Feb 2017 14:25:12 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , Christoph Hellwig Subject: [PATCH v4 35/37] configfs: Introduce config_item_get_unless_zero() Date: Wed, 8 Feb 2017 14:25:05 -0800 Message-ID: <20170208222507.25715-36-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208222507.25715-1-bart.vanassche@sandisk.com> References: <20170208222507.25715-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsXCddJ5ke65WbMjDPZs4rJYufook0Xr0rdM Dkweu282sHl83iQXwBTFZZOSmpNZllqkb5fAlXF942yWgiNcFVd2T2NuYPzL0cXIySEhYCLx qfcNWxcjF4eQwFImieb/mxghnO2MEisfbmaCqbpx9i8zRGIjo8T/1adYQRJsAkYS397PZAGx RQQMJH73XgDq5uBgFnCS2L4pCyQsLOAt0TrtKVgJi4CKxNeVZ9hBbF4BB4klS2ayQcyXl9jV dhFsJCdQfMLLZ4wgtpCAvcSrA1/ADpIQeM4isfZAOxNEs6DEyZlPwIYyC0hIHHzxghmiQV3i 5JL5TBMYhWYhKZuFpGwBI9MqRrHczJzi3PTUAkMTveLEvJTM4my95PzcTYyQkC3cwfj6tvch RgEORiUe3gvWsyOEWBPLiitzDzFKcDArifCmTAMK8aYkVlalFuXHF5XmpBYfYpTmYFES582S nRohJJCeWJKanZpakFoEk2Xi4JRqYFywYW1TrWBLpce7mbISP7O03p6Rjd337PzWs1kbVI5U f9m5y2D76rCb+9bMs+tyXZBSsN1GzWW7zItnkTarPtRsOeMxc1c4/40NWWrStbolXNa+KxV0 FC0Ond3YULu0d41SqtWmxnLuuoUXN+XFcOez/jsUZLPOrORBypwc++4ZfYFpC+IfHlZiKc5I NNRiLipOBAALZrlyVQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIJMWRmVeSWpSXmKPExsXCtZGTTffErNkRBl97GC0O/mxjtFi5+iiT RevSt0wOzB67bzaweUxbc57J4/MmuQDmKC6blNSczLLUIn27BK6M6xtnsxQc4aq4snsacwPj X44uRk4OCQETiRtn/zJ3MXJxCAmsZ5Q4OqGbCSTBJmAk8e39TBYQW0TAQOJ37wVGEJtZwEmi /V4HO4gtLOAt0TrtKVgNi4CqxPSJ+9i6GDk4eAUcJE7fiISYLy+xq+0iK4jNCRSe8PIZ2Bgh AXuJVwe+ME5g5F7AyLCKUSw3M6c4Nz2zwNBIrzgxLyWzOFsvOT93EyPE01E7GK9PND/EyMTB KdXA6PLrBLe8od2xz7rf7upFfBZcb7k7QGKe06lTNrMv8uvYCGt++TX5/4T3Ez5WLqrdX2/y mrPJTYt77bF7e7aHNkvZ/NvxjKd1T7HvseVO8zXXXUr5z3Q/L0lJnvmj5B2l4ivhJuck3Rae Zz/g+d2L6WSPpGLngb65IrcYZ0pOUzzBp9rkVNr0VYmlOCPRUIu5qDgRANnlVMakAQAA 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 {