From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/5] bootsource: add support for bootsource instance information
Date: Wed, 3 Apr 2013 08:52:24 +0200 [thread overview]
Message-ID: <1364971945-24352-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1364971945-24352-1-git-send-email-s.hauer@pengutronix.de>
From: Marc Kleine-Budde <mkl@pengutronix.de>
Add a C interface to set and get the bootsource instance:
int bootsource_get_instance(void);
void bootsource_set_instance(int instance);
Also export the shell variable "barebox_loc_instance".
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/bootsource.c | 24 ++++++++++++++++++++++++
include/bootsource.h | 4 ++++
2 files changed, 28 insertions(+)
diff --git a/common/bootsource.c b/common/bootsource.c
index 5f1d40c..7367215 100644
--- a/common/bootsource.c
+++ b/common/bootsource.c
@@ -34,6 +34,7 @@ static const char *bootsource_str[] = {
};
static enum bootsource bootsource = BOOTSOURCE_UNKNOWN;
+static int bootsource_instance = BOOTSOURCE_INSTANCE_UNKNOWN;
void bootsource_set(enum bootsource src)
{
@@ -45,6 +46,20 @@ void bootsource_set(enum bootsource src)
setenv("bootsource", bootsource_str[src]);
}
+void bootsource_set_instance(int instance)
+{
+ char buf[32];
+
+ bootsource_instance = instance;
+
+ if (instance < 0)
+ sprintf(buf, "unknown");
+ else
+ snprintf(buf, sizeof(buf), "%d", instance);
+
+ setenv("bootsource_instance", buf);
+}
+
enum bootsource bootsource_get(void)
{
return bootsource;
@@ -52,10 +67,19 @@ enum bootsource bootsource_get(void)
BAREBOX_MAGICVAR(bootsource, "The source barebox has been booted from");
+int bootsource_get_instance(void)
+{
+ return bootsource_instance;
+}
+
+BAREBOX_MAGICVAR(bootsource_instance, "The instance of the source barebox has been booted from");
+
static int bootsource_init(void)
{
bootsource_set(bootsource);
+ bootsource_set_instance(bootsource_instance);
export("bootsource");
+ export("bootsource_instance");
return 0;
}
diff --git a/include/bootsource.h b/include/bootsource.h
index ecd5938..44b69b1 100644
--- a/include/bootsource.h
+++ b/include/bootsource.h
@@ -13,7 +13,11 @@ enum bootsource {
BOOTSOURCE_HD,
};
+#define BOOTSOURCE_INSTANCE_UNKNOWN -1
+
enum bootsource bootsource_get(void);
+int bootsource_get_instance(void);
void bootsource_set(enum bootsource src);
+void bootsource_set_instance(int instance);
#endif /* __BOOTSOURCE_H__ */
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-04-03 6:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-03 6:52 [PATCH] bootsource Sascha Hauer
2013-04-03 6:52 ` [PATCH 1/5] ARM: i.MX: rename barebox_loc to bootsource Sascha Hauer
2013-04-03 6:52 ` [PATCH 2/5] bootsource: create arch independent bootsource framework Sascha Hauer
2013-04-03 6:52 ` [PATCH 3/5] bootsource: use initcall to export bootsource location to environment Sascha Hauer
2013-04-03 6:52 ` Sascha Hauer [this message]
2013-04-03 8:04 ` [PATCH 4/5] bootsource: add support for bootsource instance information Marc Kleine-Budde
2013-04-03 6:52 ` [PATCH 5/5] ARM: i.MX53: Add " Sascha Hauer
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=1364971945-24352-5-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@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