From patchwork Wed Jul 8 00:11:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 29561 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 70918B7088 for ; Wed, 8 Jul 2009 10:22:26 +1000 (EST) Received: by ozlabs.org (Postfix) id ADC69DDF91; Wed, 8 Jul 2009 10:20:28 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id AA593DDE0C for ; Wed, 8 Jul 2009 10:20:28 +1000 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9936DDDDFD; Wed, 8 Jul 2009 10:18:20 +1000 (EST) Received: from hera.kernel.org (IDENT:U2FsdGVkX18y/rCoagwyghh4owh46e6mZWw11QfTwK0@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n680IB8b026606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Jul 2009 00:18:11 GMT Received: (from geoff@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n680IBq2026605; Wed, 8 Jul 2009 00:18:11 GMT Message-Id: <20090708001135.880474041@am.sony.com> User-Agent: quilt/0.47-1 Date: Tue, 07 Jul 2009 17:11:48 -0700 From: Geoff Levand To: Jeremy Kerr In-Reply-To: <20090708001134.934244536@am.sony.com> References: <20090708001134.934244536@am.sony.com> Content-Disposition: inline; filename=ps3-reset-defaults.diff X-Virus-Scanned: ClamAV 0.93.3/9541/Tue Jul 7 17:31:53 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Wed, 08 Jul 2009 00:18:12 +0000 (UTC) Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 14/31] petitboot: Add PS3 reset default option X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Add a --reset-defaults option to the PS3 CUI program. Signed-off-by: Geoff Levand --- ui/common/ps3.c | 6 ------ ui/common/ps3.h | 6 ++++++ ui/ncurses/ps3-cui.c | 23 ++++++++++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) --- 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);