mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: barebox@lists.infradead.org
Cc: Lior Amsalem <alior@marvell.com>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Subject: [PATCH 05/12] scripts/kwbimage: make image_boot_mode_id() return -1 on failure
Date: Wed, 15 May 2013 00:32:18 +0200	[thread overview]
Message-ID: <1368570745-23348-6-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1368570745-23348-1-git-send-email-thomas.petazzoni@free-electrons.com>

The function image_boot_mode_id() converts the name of a boot media
into the corresponding Marvell specific code. However, 0 that we
currently used to indicate that the boot media name wasn't found,
could potentially be a valid value. So instead we use -1 to indicate a
failure.

This is also done in preparation to the introduction of
image_nand_ecc_mode_id(), which will convert a NAND ECC mode name into
the corresponding identifier. And in this case 0 is a valid identifier
of a NAND ECC mode, so we cannot use it to indicate a failure. Since
we want image_boot_mode_id() and image_nand_ecc_mode_id() to have a
consistent behavior, we change the former in this commit. The latter
is introduced in the next commit.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 scripts/kwbimage.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 631f131..0127e2b 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -226,14 +226,14 @@ static const char *image_boot_mode_name(unsigned int id)
 	return NULL;
 }
 
-unsigned int image_boot_mode_id(const char *boot_mode_name)
+int image_boot_mode_id(const char *boot_mode_name)
 {
 	int i;
 	for (i = 0; boot_modes[i].name; i++)
 		if (!strcmp(boot_modes[i].name, boot_mode_name))
 			return boot_modes[i].id;
 
-	return 0;
+	return -1;
 }
 
 static const char *image_nand_ecc_mode_name(unsigned int id)
@@ -987,7 +987,7 @@ static int image_create_config_parse_oneline(char *line,
 		char *value = strtok_r(NULL, " ", &saveptr);
 		el->type = IMAGE_CFG_BOOT_FROM;
 		el->bootfrom = image_boot_mode_id(value);
-		if (!el->bootfrom) {
+		if (el->bootfrom < 0) {
 			fprintf(stderr,
 				"Invalid boot media '%s'\n", value);
 			return -1;
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-05-14 22:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 22:32 [PATCH 00/12] Support for Marvell Kirkwood and Dove SoCs Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 01/12] scripts/kwbimage: add a new function image_count_options() Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 02/12] scripts/kwbimage: add a few sanity checks Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 03/12] scripts/kwbimage: make the v0 image creation more flexible Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 04/12] scripts/kwbimage: simplify the v1 image creation Thomas Petazzoni
2013-05-14 22:32 ` Thomas Petazzoni [this message]
2013-05-14 22:32 ` [PATCH 06/12] scripts/kwbimage: add support for NAND ECC and page size header fields Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 07/12] arm: mach-mvebu: rename Armada 370/XP core code Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 08/12] arm: mvebu: initial support for Marvell Dove SoCs Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 09/12] arm: mvebu: add Feroceon CPU type Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 10/12] arm: mvebu: initial support for Marvell Kirkwood SoCs Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 11/12] arm: mvebu: add basic support for SolidRun CuBox Thomas Petazzoni
2013-05-14 22:32 ` [PATCH 12/12] arm: mvebu: add basic support for Globalscale Guruplug board Thomas Petazzoni

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=1368570745-23348-6-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=barebox@lists.infradead.org \
    --cc=ezequiel.garcia@free-electrons.com \
    /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