mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 07/11] blspec: make cdev optional
Date: Mon,  4 Nov 2013 15:04:26 +0100	[thread overview]
Message-ID: <1383573870-11325-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1383573870-11325-1-git-send-email-s.hauer@pengutronix.de>

the cdev for a given directory can be determined by get_cdev_by_mountpath().
Use this function and remove the cdev argument from blspec_scan_directory().
Also, export the function to make code possible which boots the bootloader
spec entries found in directories.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c  | 22 +++++++++++++---------
 include/blspec.h |  1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index 20af235..cfefd26 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -138,8 +138,7 @@ static int blspec_have_entry(struct blspec *blspec, const char *path)
  * returns 0 if at least one entry could be successfully loaded, negative
  * error value otherwise.
  */
-static int blspec_scan_directory(struct blspec *blspec, const char *root,
-		struct cdev *cdev)
+int blspec_scan_directory(struct blspec *blspec, const char *root)
 {
 	struct blspec_entry *entry;
 	DIR *dir;
@@ -211,7 +210,7 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 
 		entry->rootpath = xstrdup(root);
 		entry->configpath = configname;
-		entry->cdev = cdev;
+		entry->cdev = get_cdev_by_mountpath(root);
 
 		name = asprintf("%s/%s", dirname, d->d_name);
 		if (entry_default && !strcmp(name, entry_default))
@@ -220,12 +219,17 @@ static int blspec_scan_directory(struct blspec *blspec, const char *root,
 			entry->boot_once = true;
 		free(name);
 
-		devname = xstrdup(dev_name(entry->cdev->dev));
-		if (entry->cdev->dev->parent)
-			hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
+		if (entry->cdev) {
+			devname = xstrdup(dev_name(entry->cdev->dev));
+			if (entry->cdev->dev->parent)
+				hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
+		}
 
-		entry->me.display = asprintf("%-20s %-20s  %s", devname, hwdevname,
+		entry->me.display = asprintf("%-20s %-20s  %s",
+				devname ? devname : "",
+				hwdevname ? hwdevname : "",
 				blspec_entry_var_get(entry, "title"));
+
 		free(devname);
 		free(hwdevname);
 
@@ -277,7 +281,7 @@ static int blspec_scan_cdev(struct blspec *blspec, struct cdev *cdev)
 	if (IS_ERR(rootpath))
 		return PTR_ERR(rootpath);
 
-	ret = blspec_scan_directory(blspec, rootpath, cdev);
+	ret = blspec_scan_directory(blspec, rootpath);
 
 	return ret;
 }
@@ -461,7 +465,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
 	globalvar_add_simple("linux.bootargs.blspec", options);
 
 	pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
-			dev_name(entry->cdev->dev));
+			entry->cdev ? dev_name(entry->cdev->dev) : "none");
 
 	if (entry->boot_once) {
 		char *s = asprintf("%s/once", abspath);
diff --git a/include/blspec.h b/include/blspec.h
index 7b483d3..66d2e84 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -37,6 +37,7 @@ int blspec_scan_devices(struct blspec *blspec);
 
 struct blspec_entry *blspec_entry_default(struct blspec *l);
 int blspec_scan_devicename(struct blspec *blspec, const char *devname);
+int blspec_scan_directory(struct blspec *blspec, const char *root);
 
 #define blspec_for_each_entry(blspec, entry) \
 	list_for_each_entry(entry, &blspec->entries, list)
-- 
1.8.4.rc3


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

  parent reply	other threads:[~2013-11-04 14:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-04 14:04 bootspec work Sascha Hauer
2013-11-04 14:04 ` [PATCH 01/11] kernel-install: Add missing error messages Sascha Hauer
2013-11-04 14:04 ` [PATCH 02/11] blspec: Push device_detect into blspec_scan_device Sascha Hauer
2013-11-04 14:04 ` [PATCH 03/11] blspec: rename _hwdevice functions to _devicename Sascha Hauer
2013-11-04 14:04 ` [PATCH 04/11] blspec: Allow to boot partitions Sascha Hauer
2013-11-04 14:04 ` [PATCH 05/11] blspec: Let scan functions return the number of entries found Sascha Hauer
2013-11-04 14:04 ` [PATCH 06/11] fs: Add function to get cdev by mountpath Sascha Hauer
2013-11-04 14:04 ` Sascha Hauer [this message]
2013-11-04 22:21   ` [PATCH 07/11] blspec: make cdev optional Alexander Aring
2013-11-05  7:39     ` Sascha Hauer
2013-11-05  8:22       ` Alexander Aring
2013-11-04 14:04 ` [PATCH 08/11] boot: Print boot entries in the order they are Sascha Hauer
2013-11-04 14:04 ` [PATCH 09/11] boot command: make more flexible Sascha Hauer
2013-11-04 14:04 ` [PATCH 10/11] blspec: Make error message more clear Sascha Hauer
2013-11-04 14:04 ` [PATCH 11/11] boot command: Add timeout support for menu 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=1383573870-11325-8-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