diff mbox

[14/31] petitboot: Add PS3 reset default option

Message ID 20090708001135.880474041@am.sony.com
State New
Headers show

Commit Message

Geoff Levand July 8, 2009, 12:11 a.m. UTC
Add a --reset-defaults option to the PS3 CUI program.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
---
 ui/common/ps3.c      |    6 ------
 ui/common/ps3.h      |    6 ++++++
 ui/ncurses/ps3-cui.c |   23 ++++++++++++++++-------
 3 files changed, 22 insertions(+), 13 deletions(-)
diff mbox

Patch

--- a/ui/common/ps3.c
+++ b/ui/common/ps3.c
@@ -111,12 +111,6 @@  int ps3_flash_get_values(struct ps3_flas
 	struct ps3_flash_ctx fc;
 	uint64_t tmp;
 
-	/* Set default values. */
-
-	values->default_item = 0;
-	values->timeout = ps3_timeout_forever;
-	values->video_mode = 1;
-
 	result = ps3_flash_open(&fc, "r");
 
 	if (result)
--- a/ui/common/ps3.h
+++ b/ui/common/ps3.h
@@ -52,6 +52,12 @@  struct ps3_flash_values {
 	uint8_t timeout;
 };
 
+static const struct ps3_flash_values ps3_flash_defaults = {
+	.default_item = 0,
+	.video_mode = 1,
+	.timeout = ps3_timeout_forever,
+};
+
 int ps3_flash_get_values(struct ps3_flash_values *values);
 int ps3_flash_set_values(const struct ps3_flash_values *values);
 
--- a/ui/ncurses/ps3-cui.c
+++ b/ui/ncurses/ps3-cui.c
@@ -52,7 +52,8 @@  static void print_usage(void)
 {
 	print_version();
 	printf(
-"Usage: pb-cui [-h, --help] [-l, --log log-file] [-V, --version]\n");
+"Usage: pb-cui [-h, --help] [-l, --log log-file] [-r, --reset-defaults]\n"
+"              [-V, --version]\n");
 }
 
 /**
@@ -68,6 +69,7 @@  enum opt_value {opt_undef = 0, opt_yes, 
 struct opts {
 	enum opt_value show_help;
 	const char *log_file;
+	enum opt_value reset_defaults;
 	enum opt_value show_version;
 };
 
@@ -78,12 +80,13 @@  struct opts {
 static int opts_parse(struct opts *opts, int argc, char *argv[])
 {
 	static const struct option long_options[] = {
-		{"help",    no_argument,       NULL, 'h'},
-		{"log",     required_argument, NULL, 'l'},
-		{"version", no_argument,       NULL, 'V'},
-		{ NULL,     0,                 NULL, 0},
+		{"help",           no_argument,       NULL, 'h'},
+		{"log",            required_argument, NULL, 'l'},
+		{"reset-defaults", no_argument,       NULL, 'r'},
+		{"version",        no_argument,       NULL, 'V'},
+		{ NULL, 0, NULL, 0},
 	};
-	static const char short_options[] = "hl:V";
+	static const char short_options[] = "hl:rV";
 	static const struct opts default_values = {
 		.log_file = "pb-cui.log",
 	};
@@ -104,6 +107,9 @@  static int opts_parse(struct opts *opts,
 		case 'l':
 			opts->log_file = optarg;
 			break;
+		case 'r':
+			opts->reset_defaults = opt_yes;
+			break;
 		case 'V':
 			opts->show_version = opt_yes;
 			break;
@@ -520,7 +526,10 @@  int main(int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
-	ps3.dirty_values = ps3_flash_get_values(&ps3.values);
+	ps3.values = ps3_flash_defaults;
+
+	if (opts.reset_defaults != opt_yes)
+		ps3.dirty_values = ps3_flash_get_values(&ps3.values);
 
 	result = ps3_get_video_mode(&mode);