Re: [U-Boot] [PATCH 22/30] km/common: implement setboardid as a command

2011-05-02 Thread Holger Brunck
Hi,

On 04/30/2011 10:25 AM, Wolfgang Denk wrote:
> Dear Valentin Longchamp,
> 
> In message 
> <30d7413306aba80ca4540c3353d884bdffe9a643.1302272395.git.valentin.longch...@keymile.com>
>  you wrote:
>> From: Holger Brunck 
>>
>> Read out board id and HW key from the IVM eeprom and set
>> these values as an environment variable was now done inside the
>> code as a command.
> 
> This begs to ask: and how has it been done so far?  Should this patch
> not remove some old code, then?
> 

Yes it does, we did it previously in the default environment. But this was an
out of tree patch so far. Maybe I should adapt the commit message.

>> +{
>> +unsigned char buf[32];
>> +char *p;
>> +
>> +p = get_local_var("IVM_BoardId");
>> +sprintf((char *)buf, "%s", p);
>> +setenv("boardid", (char *)buf);
>> +p = get_local_var("IVM_HWKey");
>> +sprintf((char *)buf, "%s", p);
>> +setenv("hwkey", (char *)buf);
> 
> get_local_var() will return NULL in some cases. Error handling
> missing.
> 

Ok.

>> +return 0;
> 
> As is, the return 0 makes no sense, but I guess this will change when
> you add error handling.
>

Yes.

Thanks.

Best regards
Holger Brunck
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 22/30] km/common: implement setboardid as a command

2011-04-30 Thread Wolfgang Denk
Dear Valentin Longchamp,

In message 
<30d7413306aba80ca4540c3353d884bdffe9a643.1302272395.git.valentin.longch...@keymile.com>
 you wrote:
> From: Holger Brunck 
> 
> Read out board id and HW key from the IVM eeprom and set
> these values as an environment variable was now done inside the
> code as a command.

This begs to ask: and how has it been done so far?  Should this patch
not remove some old code, then?

> +{
> + unsigned char buf[32];
> + char *p;
> +
> + p = get_local_var("IVM_BoardId");
> + sprintf((char *)buf, "%s", p);
> + setenv("boardid", (char *)buf);
> + p = get_local_var("IVM_HWKey");
> + sprintf((char *)buf, "%s", p);
> + setenv("hwkey", (char *)buf);

get_local_var() will return NULL in some cases. Error handling
missing.

> + return 0;

As is, the return 0 makes no sense, but I guess this will change when
you add error handling.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The Empire didn't encourage its subjects to go far away, in case they
saw things that might disturb them. For the same reason it had  built
a  wall  around  the  entire country, patrolled by the Heavenly Guard
whose main function was to tread heavily on the fingers of any  inha-
bitants who felt they might like to step outside for five minutes for
a breath of fresh air.  - Terry Pratchett, _Mort_
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 22/30] km/common: implement setboardid as a command

2011-04-08 Thread Valentin Longchamp
From: Holger Brunck 

Read out board id and HW key from the IVM eeprom and set
these values as an environment variable was now done inside the
code as a command.

Signed-off-by: Holger Brunck 
Acked-by: Heiko Schocher 
cc: Wolfgang Denk 
cc: Detlev Zundel 
cc: Valentin Longchamp 
Signed-off-by: Valentin Longchamp 
---
 board/keymile/common/common.c |   25 +
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 9ec0022..5704b7f 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -25,6 +25,7 @@
 #if defined(CONFIG_KM82XX)
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -689,3 +690,27 @@ int board_eth_init(bd_t *bis)
 
return -1;
 }
+
+/*
+ * do_setboardid command
+ * read out the board id and the hw key from the intventory EEPROM and set
+ * this values as environment variables.
+ */
+static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
+   char *const argv[])
+{
+   unsigned char buf[32];
+   char *p;
+
+   p = get_local_var("IVM_BoardId");
+   sprintf((char *)buf, "%s", p);
+   setenv("boardid", (char *)buf);
+   p = get_local_var("IVM_HWKey");
+   sprintf((char *)buf, "%s", p);
+   setenv("hwkey", (char *)buf);
+   return 0;
+}
+
+U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", "read out bid and 
"
+"hwkey from IVM and set in environment");
+
-- 
1.7.0.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot