From patchwork Fri Nov 20 03:26:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 546785 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 4F0D3140778 for ; Fri, 20 Nov 2015 14:29:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ZwDweI8P; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzcM3-0000g1-8k; Fri, 20 Nov 2015 03:27:19 +0000 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzcLt-0000Ze-Sk for linux-mtd@lists.infradead.org; Fri, 20 Nov 2015 03:27:11 +0000 Received: by pabfh17 with SMTP id fh17so105136831pab.0 for ; Thu, 19 Nov 2015 19:26:48 -0800 (PST) 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=LR3hfOiJGScL229iEk8MuXLiN1JdwPP2Jfp8XhFO86Y=; b=ZwDweI8Pr/oUtD4H/psqBkEBI2Qth/BMwPSLrbaDx3t4GFBlFjvl8Lc3g86zJw9GxN U6v8lcfVoOFPk5HBXcsL61tsEjBYYAuBCkU9NQaiGv/5W7q7CW+OJ0nAG8iN3Y49jQP0 3ZOcZSFQj80LWMeNxVEQoarYlEwJmCtyDUGySSZx/cHh4IKQTt/7dKy0mzJFXmZYP0mF VTK4vKUZ1sXPqhrGXVsh6vYJYAZ0lxZDApy6tt6kZuHoH5Gl1bl8tvbh1b00pdfve1nS ECZDMw64ms2lYBR1qIsX7cuxw/4PWLIGESvpjDwv29YlxBTAKF/7EVAYptcnm3GOJaTN xn3g== X-Received: by 10.98.18.22 with SMTP id a22mr247818pfj.54.1447990008890; Thu, 19 Nov 2015 19:26:48 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id ez1sm13588302pab.6.2015.11.19.19.26.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 19:26:48 -0800 (PST) From: Brian Norris To: Subject: [PATCH 2/3] mtd: untangle error codes and number of partitions Date: Thu, 19 Nov 2015 19:26:36 -0800 Message-Id: <1447989997-108476-3-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1447989997-108476-1-git-send-email-computersforpeace@gmail.com> References: <1447989997-108476-1-git-send-email-computersforpeace@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151119_192710_073218_377D4FCE X-CRM114-Status: GOOD ( 11.80 ) 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:c03:0:0:0:231 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 (computersforpeace[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 , Linus Walleij , Brian Norris MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We're going to need to know how many partitions were registered, so let's disentangle the 'ret' and 'nr_parts' variables, so that nr_parts always represents the number of partitions we're registering. Signed-off-by: Brian Norris Reviewed-by: Boris Brezillon --- drivers/mtd/mtdcore.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 62f83b050978..c8d54948bbc1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -592,23 +592,25 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, struct mtd_partition *real_parts = NULL; ret = parse_mtd_partitions(mtd, types, &real_parts, parser_data); - if (ret <= 0 && nr_parts && parts) { + if (ret > 0) { + nr_parts = ret; + } else if (ret <= 0 && nr_parts && parts) { real_parts = kmemdup(parts, sizeof(*parts) * nr_parts, GFP_KERNEL); if (!real_parts) ret = -ENOMEM; else - ret = nr_parts; + ret = 0; } /* Didn't come up with either parsed OR fallback partitions */ if (ret < 0) { pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n", ret); /* Don't abort on errors; we can still use unpartitioned MTD */ - ret = 0; + nr_parts = 0; } - ret = mtd_add_device_partitions(mtd, real_parts, ret); + ret = mtd_add_device_partitions(mtd, real_parts, nr_parts); if (ret) goto out;