From: Brian Norris <computersforpeace@gmail.com>
To: <linux-mtd@lists.infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 2/3] mtd: untangle error codes and number of partitions
Date: Thu, 19 Nov 2015 19:26:36 -0800 [thread overview]
Message-ID: <1447989997-108476-3-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1447989997-108476-1-git-send-email-computersforpeace@gmail.com>
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 <computersforpeace@gmail.com>
---
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;
--
2.6.0.rc2.230.g3dd15c0
next prev parent reply other threads:[~2015-11-20 3:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 3:26 [PATCH 0/3] mtd: support cleanup callback for partition parsers Brian Norris
2015-11-20 3:26 ` [PATCH 1/3] mtd: rename MTD parser get/put Brian Norris
2015-11-30 17:55 ` Boris Brezillon
2015-11-20 3:26 ` Brian Norris [this message]
2015-11-30 17:56 ` [PATCH 2/3] mtd: untangle error codes and number of partitions Boris Brezillon
2015-11-20 3:26 ` [PATCH 3/3] mtd: support a cleanup callback for partition parsers Brian Norris
2015-11-30 18:36 ` Boris Brezillon
2015-11-30 23:53 ` Brian Norris
2015-12-01 12:37 ` Boris Brezillon
2015-12-02 3:12 ` Brian Norris
2015-12-02 8:55 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447989997-108476-3-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=linus.walleij@linaro.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).