From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: <linux-mtd@lists.infradead.org>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 2/3] mtd: untangle error codes and number of partitions
Date: Mon, 30 Nov 2015 18:56:06 +0100 [thread overview]
Message-ID: <20151130185606.0095680e@bbrezillon> (raw)
In-Reply-To: <1447989997-108476-3-git-send-email-computersforpeace@gmail.com>
On Thu, 19 Nov 2015 19:26:36 -0800
Brian Norris <computersforpeace@gmail.com> wrote:
> 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>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.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;
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2015-11-30 17:56 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 ` [PATCH 2/3] mtd: untangle error codes and number of partitions Brian Norris
2015-11-30 17:56 ` Boris Brezillon [this message]
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=20151130185606.0095680e@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.