From patchwork Thu Jul 21 21:59:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 651468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rwSS051FLz9t0q for ; Fri, 22 Jul 2016 08:02:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=HE1GSTDT; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQM0w-0001Wv-MS; Thu, 21 Jul 2016 22:00:18 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQM0s-0000HH-GL for linux-mtd@lists.infradead.org; Thu, 21 Jul 2016 22:00:15 +0000 Received: by mail-pf0-x244.google.com with SMTP id h186so6071354pfg.2 for ; Thu, 21 Jul 2016 14:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AkN8rz/1lXoHaquIyLQfvYBUowqYGLCzcrrTnXL5UvQ=; b=HE1GSTDTNEzT4vQJEoVxcWEvVEDAEh1uhJqglyQxqkEvGiSY54+89zQoVKCkf+iyY/ 90/4Jfc1cMmSEOlVk7HCGKFesjnJAJis3TZq+UTHw2M1aLov1V/ejbORpNdpuHFQKwY1 nA3hiDiSpmAwRktTlnoTxe91p6c3Iv/b+Pphpqngq1avu6/Na7y/NAyhxgaJtNEci8w+ y3rZruIm3jM4HRXEdUlab4ChwEZWFCTOJsBnOM1mBAguvzcMRRXwyy69fXlIefzbUuzW LziepRtgktTniCLCjgsdlI0MQ5c1uQXlgqgXtMzT2tBK6FLa/vp7dNRkN1tjgkIfn8nK 0a4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AkN8rz/1lXoHaquIyLQfvYBUowqYGLCzcrrTnXL5UvQ=; b=muLuxOnGVXgR2H4CG0Acu8Z+WN77Sdd/ELIpLw+ZYOl6u9qLhj9jTutrJswZ60EvG7 g24uYTRqlphQgcYiPozWX7+nwC80dG+j3BvBBve40Odg3pVRfCeQaye4FkHd/2ay6qWp EjgntYAegjXqsNK24/D/OPTnxRce2lBqZ4bwNLFUCi7y6JkyVZ9+YUELE9pM/8j3qWcd L42zYIJvJ0Yu9jUG106h1t8L1BYxVQ6Dflk9CisECfOYFDXX/5A0caGcyYF8NGugiEgb /ljJpcqvzeuy0Nt3pFMW+/R/0D09MuTpymFjjSB/S+yRH/HvtwB2ddpe5T0+KnS5dyhL dAkQ== X-Gm-Message-State: AEkoout9QGkez2SwXs0t/DgLPLF4NUbjndxfZrj0+XmgL5QeY72jFHNca/UpFlWqKVLw9Q== X-Received: by 10.98.75.219 with SMTP id d88mr737436pfj.91.1469138393907; Thu, 21 Jul 2016 14:59:53 -0700 (PDT) Received: from squirtle.localdomain.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id xs12sm14574609pac.7.2016.07.21.14.59.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 14:59:53 -0700 (PDT) From: Andrey Smirnov To: linux-mtd@lists.infradead.org Subject: [PATCH v3 2/2] mtd: nand: Get rid of needless 'goto' Date: Thu, 21 Jul 2016 14:59:21 -0700 Message-Id: <1469138361-14173-4-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1469138361-14173-1-git-send-email-andrew.smirnov@gmail.com> References: <1469138361-14173-1-git-send-email-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160721_150014_679949_48E6FD4B X-CRM114-Status: GOOD ( 12.26 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (andrew.smirnov[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Andrey Smirnov , Richard Weinberger , linux-kernel@vger.kernel.org, Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Using "goto" and "switch" statement only makes it harder to follow control flow and doesn't bring any advantages. Rewrite the code to avoid using "goto". Signed-off-by: Brian Norris Signed-off-by: Andrey Smirnov --- No changes since v2. drivers/mtd/nand/nand_base.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 93f5432..777152b 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2122,7 +2122,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, static int nand_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { - int ret = -ENOTSUPP; + int ret; ops->retlen = 0; @@ -2133,24 +2133,18 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, return -EINVAL; } - nand_get_device(mtd, FL_READING); - - switch (ops->mode) { - case MTD_OPS_PLACE_OOB: - case MTD_OPS_AUTO_OOB: - case MTD_OPS_RAW: - break; + if (ops->mode != MTD_OPS_PLACE_OOB && + ops->mode != MTD_OPS_AUTO_OOB && + ops->mode != MTD_OPS_RAW) + return -ENOTSUPP; - default: - goto out; - } + nand_get_device(mtd, FL_READING); if (!ops->datbuf) ret = nand_do_read_oob(mtd, from, ops); else ret = nand_do_read_ops(mtd, from, ops); -out: nand_release_device(mtd); return ret; }