From patchwork Thu Aug 9 11:03:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Milan P. Gandhi" X-Patchwork-Id: 10561183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED401139A for ; Thu, 9 Aug 2018 11:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE7AD29F4E for ; Thu, 9 Aug 2018 11:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D25872A005; Thu, 9 Aug 2018 11:03:11 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 7A92F29F4E for ; Thu, 9 Aug 2018 11:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbeHIN1b (ORCPT ); Thu, 9 Aug 2018 09:27:31 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:38885 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbeHIN1a (ORCPT ); Thu, 9 Aug 2018 09:27:30 -0400 Received: by mail-qt0-f196.google.com with SMTP id w26-v6so5990631qto.5 for ; Thu, 09 Aug 2018 04:03:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=g7zW0Gu0lpcUMczrya2+U3Q4ji4B3XI0IdePiZCxa5w=; b=VEnPlzst3OoHf66Gy92kkpnJb1SR69QATzAXZIO/th3OSdDkh00aDNm+MSpUB3nsg0 wSg0cn0pEeWcAMD6k3KF+H3/fNC7YZqKG3wZ1t2Ano2G7YOZKdnhZgp+AqW0ygH1HXxU gwkjS/p7Xg7+E8Xhj22ldrLGRSJZH2f8uHHlMBciD5xiksBv5OrDahobE6DYgySmVYwM 9vxI5lMqi+W5HvqLKUwJ9LyR76XAvGQdsCdy254OEpiextgDPW7onGBZUgJZo0FvoSmT qupFjkbpZMWalU62ki0yJmicw+FqKvftR3Z/aJiFRbiRxa0IQ/CuwiLMv0OSGZfuThks vCdA== X-Gm-Message-State: AOUpUlG1LRkC88B8oxBZ+zvPnmbUiq6w/Hsh8vySnDCgAHDXBevu9abu S5z6y5Q9RpH4rY2lmaObgxadCZuEvrc= X-Google-Smtp-Source: AA+uWPx1839qEzQS/JH5wDNYr7lFaZGJwgKeZk3FRTXJq5jP5WcLB1h31hg1VMXPV6vf9mmLK7wALw== X-Received: by 2002:a0c:8d8e:: with SMTP id t14-v6mr1310861qvb.32.1533812589882; Thu, 09 Aug 2018 04:03:09 -0700 (PDT) Received: from machine1 ([182.70.104.216]) by smtp.gmail.com with ESMTPSA id r1-v6sm491910qkl.85.2018.08.09.04.03.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 04:03:09 -0700 (PDT) Date: Thu, 9 Aug 2018 16:33:03 +0530 From: "Milan P. Gandhi" To: linux-scsi@vger.kernel.org Subject: [PATCH] Remove extra goto label from nvmet_ns_enable Message-ID: <20180809110303.GA10167@machine1> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently nvmet_ns_enable has two labels viz. out_unlock and out_dev_put, and the reverse call from out_dev_put to out_unlock is little bit confusing. We could simplify it by calling nvmet_ns_dev_disable before. This would eliminate need for 2nd out_dev_put label. Also, this function already initializes ret variable to 0, so there is no need to again initialize it to 0 before out_unlock, hence removing it. Signed-off-by: Milan P. Gandhi --- drivers/nvme/target/core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 9838103f2d62..b40fb6d724b4 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -346,9 +346,10 @@ int nvmet_ns_enable(struct nvmet_ns *ns) ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL); - if (ret) - goto out_dev_put; - + if (ret) { + nvmet_ns_dev_disable(ns); + goto out_unlock; + } if (ns->nsid > subsys->max_nsid) subsys->max_nsid = ns->nsid; @@ -372,13 +373,10 @@ int nvmet_ns_enable(struct nvmet_ns *ns) nvmet_ns_changed(subsys, ns->nsid); ns->enabled = true; - ret = 0; + out_unlock: mutex_unlock(&subsys->lock); return ret; -out_dev_put: - nvmet_ns_dev_disable(ns); - goto out_unlock; } void nvmet_ns_disable(struct nvmet_ns *ns)