From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dirk Behme Date: Sat, 21 Apr 2012 07:46:00 +0200 Subject: [U-Boot] [PATCH V3] i.MX6Q: mx6qsabrelite: Add keypress support to alter boot flow In-Reply-To: <1334604834-8489-1-git-send-email-eric.nelson@boundarydevices.com> References: <1334604834-8489-1-git-send-email-eric.nelson@boundarydevices.com> Message-ID: <4F924998.2010603@googlemail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Eric, On 16.04.2012 21:33, Eric Nelson wrote: > Uses the 'magic_keys' idiom as described in doc/README.kbd: > http://lists.denx.de/pipermail/u-boot/2012-April/122502.html > > Signed-off-by: Eric Nelson > --- > V2 based on suggestion by Wolfgang to follow prior implementations. > V3 fixes style issues highlighted by Marek Vasut. > > board/freescale/mx6qsabrelite/mx6qsabrelite.c | 121 ++++++++++++++++++++++++- > include/configs/mx6qsabrelite.h | 3 + > 2 files changed, 122 insertions(+), 2 deletions(-) > > diff --git a/board/freescale/mx6qsabrelite/mx6qsabrelite.c b/board/freescale/mx6qsabrelite/mx6qsabrelite.c > index 1d09a72..3684216 100644 > --- a/board/freescale/mx6qsabrelite/mx6qsabrelite.c > +++ b/board/freescale/mx6qsabrelite/mx6qsabrelite.c ... > +#ifdef CONFIG_PREBOOT > +static char const kbd_magic_prefix[] = "key_magic"; > +static char const kbd_command_prefix[] = "key_cmd"; > + > +static void preboot_keys(void) > +{ > + int i, numpressed; mx6qsabrelite.c: In function 'preboot_keys': mx6qsabrelite.c:408: warning: unused variable 'i' > + char keypress[ARRAY_SIZE(buttons)+1]; > + numpressed = read_keys(keypress); > + if (numpressed) { > + char *kbd_magic_keys = getenv("magic_keys"); > + char *suffix; > + /* > + * loop over all magic keys > + */ > + for (suffix = kbd_magic_keys; *suffix; ++suffix) { > + char *keys; > + char magic[sizeof(kbd_magic_prefix) + 1]; > + sprintf(magic, "%s%c", kbd_magic_prefix, *suffix); > + keys = getenv(magic); > + if (keys) { > + if (!strcmp(keys, keypress)) > + break; > + } > + } > + if (*suffix) { > + char cmd_name[sizeof(kbd_command_prefix) + 1]; > + char *cmd; > + sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix); > + cmd = getenv(cmd_name); > + if (cmd) { > + setenv("preboot", cmd); > + return; > + } > + } > + } > +} > +#endif > + > +int misc_init_r(void) > +{ > +#ifdef CONFIG_PREBOOT > + preboot_keys(); > +#endif > +} mx6qsabrelite.c: In function 'misc_init_r': mx6qsabrelite.c:446: warning: control reaches end of non-void function Best regards Dirk