From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Mon, 18 Nov 2013 11:57:41 +0100 Subject: [U-Boot] [PATCH 3/5] i.MX6: nitrogen6x/sabrelite: override set_board_name() In-Reply-To: <1384708667-22489-4-git-send-email-eric.nelson@boundarydevices.com> References: <1384708667-22489-1-git-send-email-eric.nelson@boundarydevices.com> <1384708667-22489-4-git-send-email-eric.nelson@boundarydevices.com> Message-ID: <5289F2A5.2020201@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Eric, On 17/11/2013 18:17, Eric Nelson wrote: > Since the nitrogen6x board file auto-detects Nitrogen6x and > SABRE Lite boards, override set_board_name to produce one > of two values for board_name. > > Signed-off-by: Eric Nelson > --- > board/boundary/nitrogen6x/nitrogen6x.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c > index 616ad55..aa9717a 100644 > --- a/board/boundary/nitrogen6x/nitrogen6x.c > +++ b/board/boundary/nitrogen6x/nitrogen6x.c > @@ -756,9 +756,14 @@ int board_init(void) > return 0; > } > > +static inline int is_n6x(void) > +{ > + return gpio_get_value(WL12XX_WL_IRQ_GP); > +} > + > int checkboard(void) > { > - if (gpio_get_value(WL12XX_WL_IRQ_GP)) > + if (is_n6x()) > puts("Board: Nitrogen6X\n"); > else > puts("Board: SABRE Lite\n"); > @@ -766,6 +771,13 @@ int checkboard(void) > return 0; > } > > +void set_board_name(void) > +{ > + char *old = getenv("board_name"); Agree on the name: board_name was already introduced in u-boot. > + if (!old) > + setenv("board_name", is_n6x() ? "nitrogen6x" : "sabrelite"); I have a major question: if it is possible to detect at runtime, as you have already implemented, which is the board where code is running, why is it possible to override it for the operator ? I agree that forcing environment variables inside code is bad, but in this case it is a hardware related stuff. It is like to the processor type or the serial-id of the processor (variable dieid# on OMAP). Overriding seems weird. Best regards, Stefano Babic -- ===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================