summaryrefslogtreecommitdiffstats
path: root/common/blspec.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-11-01 10:52:43 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-05 08:37:55 +0100
commit21af7e0005ab6e4be353ade885f0864e48414bc5 (patch)
treebeb60839a5b70e6de8f688dc9a2508d862c3dac2 /common/blspec.c
parentb7a66554dcbc2525b719f7216cb77c2037e6af80 (diff)
downloadbarebox-21af7e0005ab6e4be353ade885f0864e48414bc5.tar.gz
blspec: make cdev optional
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>
Diffstat (limited to 'common/blspec.c')
-rw-r--r--common/blspec.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/common/blspec.c b/common/blspec.c
index 20af235..500eb07 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,9 +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);
-
- return ret;
+ return blspec_scan_directory(blspec, rootpath);
}
/*
@@ -461,7 +463,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);