mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 08/18] bootentries: Add title/description
Date: Fri, 22 Jul 2016 14:44:22 +0200	[thread overview]
Message-ID: <1469191472-14491-9-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1469191472-14491-1-git-send-email-s.hauer@pengutronix.de>

We currently have to special case blspec entries vs. boot scripts
in the common boot code since we want to print different informations
about them. This adds a 'title' and 'description' which can be filled
in with different information by bootscripts and blspec entries and
so we get rid of the special handling.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/boot.c  | 23 ++++++++++-------------
 common/blspec.c  |  9 ++++-----
 include/blspec.h |  4 ++++
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/commands/boot.c b/commands/boot.c
index edf9eab..19f2fb5 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -130,7 +130,8 @@ static int bootscript_create_entry(struct bootentries *bootentries, const char *
 	be = blspec_entry_alloc(bootentries);
 	be->entry.me.type = MENU_ENTRY_NORMAL;
 	be->scriptpath = xstrdup(name);
-	be->entry.me.display = xstrdup(basename(be->scriptpath));
+	be->entry.title = xstrdup(basename(be->scriptpath));
+	be->entry.description = basprintf("script: %s", name);
 
 	return 0;
 }
@@ -273,6 +274,8 @@ static void bootsources_menu(char *entries[], int num_entries)
 		return;
 
 	bootentries_for_each_entry(bootentries, entry) {
+		if (!entry->me.display)
+			entry->me.display = xstrdup(entry->title);
 		entry->me.action = bootsource_action;
 		menu_add_entry(bootentries->menu, &entry->me);
 	}
@@ -305,17 +308,11 @@ static void bootsources_list(char *entries[], int num_entries)
 	if (!bootentries)
 		return;
 
-	printf("  %-20s %-20s  %s\n", "device", "hwdevice", "title");
-	printf("  %-20s %-20s  %s\n", "------", "--------", "-----");
+	printf("%-20s\n", "title");
+	printf("%-20s\n", "------");
 
-	bootentries_for_each_entry(bootentries, entry) {
-		struct blspec_entry *ble = container_of(entry, struct blspec_entry, entry);
-
-		if (ble->scriptpath)
-			printf("%-40s   %s\n", basename(ble->scriptpath), entry->me.display);
-		else
-			printf("%s\n", entry->me.display);
-	}
+	bootentries_for_each_entry(bootentries, entry)
+		printf("%-20s %s\n", entry->title, entry->description);
 
 	blspec_free(bootentries);
 }
@@ -349,11 +346,11 @@ static int boot(const char *name)
 	}
 
 	bootentries_for_each_entry(bootentries, entry) {
-		printf("booting %s\n", entry->me.display);
+		printf("booting %s\n", entry->title);
 		ret = boot_entry(entry);
 		if (!ret)
 			break;
-		printf("booting %s failed: %s\n", entry->me.display, strerror(-ret));
+		printf("booting %s failed: %s\n", entry->title, strerror(-ret));
 	}
 
 	return ret;
diff --git a/common/blspec.c b/common/blspec.c
index d1597f9..dff0928 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -409,11 +409,10 @@ int blspec_scan_directory(struct bootentries *bootentries, const char *root)
 				hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
 		}
 
-		entry->entry.me.display = basprintf("%-20s %-20s  %s",
-						devname ? devname : "",
-						hwdevname ? hwdevname : "",
-						blspec_entry_var_get(entry, "title"));
-
+		entry->entry.title = xstrdup(blspec_entry_var_get(entry, "title"));
+		entry->entry.description = basprintf("blspec entry, device: %s hwdevice: %s",
+						    devname ? devname : "none",
+						    hwdevname ? hwdevname : "none");
 		free(devname);
 		free(hwdevname);
 
diff --git a/include/blspec.h b/include/blspec.h
index aced246..c956f0d 100644
--- a/include/blspec.h
+++ b/include/blspec.h
@@ -12,6 +12,8 @@ struct bootentries {
 struct bootentry {
 	struct list_head list;
 	struct menu_entry me;
+	char *title;
+	char *description;
 };
 
 struct blspec_entry {
@@ -58,6 +60,8 @@ static inline void blspec_entry_free(struct blspec_entry *entry)
 	list_del(&entry->entry.list);
 	of_delete_node(entry->node);
 	free(entry->entry.me.display);
+	free(entry->entry.title);
+	free(entry->entry.description);
 	free(entry->scriptpath);
 	free(entry->configpath);
 	free(entry->rootpath);
-- 
2.8.1


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

  parent reply	other threads:[~2016-07-22 12:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-22 12:44 Sascha Hauer
2016-07-22 12:44 ` [PATCH 01/18] blspec: remove unused blspec_boot_devicename Sascha Hauer
2016-07-22 12:44 ` [PATCH 02/18] blspec: Remove once/default handling Sascha Hauer
2016-07-22 12:44 ` [PATCH 03/18] blspec: remove unused function prototype Sascha Hauer
2016-07-22 12:44 ` [PATCH 04/18] boot: Call blspec_scan_directory() only on strings containing an absolute path Sascha Hauer
2016-07-22 12:44 ` [PATCH 05/18] include: Move bulk of boot.h to bootm.h Sascha Hauer
2016-07-22 12:44 ` [PATCH 06/18] blpec: rename struct lspec -> bootentries Sascha Hauer
2016-07-22 12:44 ` [PATCH 07/18] blspec: factor out a struct bootentry Sascha Hauer
2016-07-22 12:44 ` Sascha Hauer [this message]
2016-07-22 12:44 ` [PATCH 09/18] blspec: separate bootentries from blspec entries Sascha Hauer
2016-07-22 12:44 ` [PATCH 10/18] blspec: Make blspec_boot static Sascha Hauer
2016-07-22 12:44 ` [PATCH 11/18] bootentries: Move menu display string allocation to bootentries_alloc() Sascha Hauer
2016-07-22 12:44 ` [PATCH 12/18] bootentries: Move struct bootentries to include/boot.h Sascha Hauer
2016-07-22 12:44 ` [PATCH 13/18] boot: Use struct bootentries to pass around data Sascha Hauer
2016-07-22 12:44 ` [PATCH 14/18] boot: Move code to common/ Sascha Hauer
2016-07-22 12:44 ` [PATCH 15/18] boot: add single quotes when printing boot target names Sascha Hauer
2016-07-22 12:44 ` [PATCH 16/18] boot command: Explicitly complain when boot target list is empty Sascha Hauer
2016-07-22 12:44 ` [PATCH 17/18] blspec: Turn message back to debug level Sascha Hauer
2016-07-22 12:44 ` [PATCH 18/18] boot: Print a message when a boot target string does not lead to a boot target 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=1469191472-14491-9-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