[U-Boot] [PATCH] net/fm: call fm_port_to_index() with proper checks

2014-05-10 Thread Marian Rotariu
Some of the fm_port_to_index() callers did not check for -1 return value and
used -1 as an array index.

Change-Id: Ibdee52d6abc9019cade1a01dca911da89bcc760b
Signed-off-by: Marian Rotariu 
Reviewed-on: http://git.am.freescale.net:8181/11711
Tested-by: Review Code-CDREVIEW 
Reviewed-by: Madalin-Cristian Bucur 
Reviewed-by: Shengzhou Liu 
Reviewed-by: Prabhakar Kushwaha 
---
 drivers/net/fm/fm.h   |3 ++-
 drivers/net/fm/init.c |6 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm/fm.h b/drivers/net/fm/fm.h
index 43de114..316e06e 100644
--- a/drivers/net/fm/fm.h
+++ b/drivers/net/fm/fm.h
@@ -143,6 +143,7 @@ struct fm_eth {
 #define MAX_RXBUF_LOG2 11
 #define MAX_RXBUF_LEN  (1 << MAX_RXBUF_LOG2)
 
-#define PORT_IS_ENABLED(port)  fm_info[fm_port_to_index(port)].enabled
+#define PORT_IS_ENABLED(port)  (fm_port_to_index(port) == -1 ? \
+   0 : fm_info[fm_port_to_index(port)].enabled)
 
 #endif /* __FM_H__ */
diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c
index cd787f4..ff04695 100644
--- a/drivers/net/fm/init.c
+++ b/drivers/net/fm/init.c
@@ -147,6 +147,9 @@ void fm_disable_port(enum fm_port port)
 {
int i = fm_port_to_index(port);
 
+   if (i == -1)
+   return;
+
fm_info[i].enabled = 0;
fman_disable_port(port);
 }
@@ -155,6 +158,9 @@ void fm_enable_port(enum fm_port port)
 {
int i = fm_port_to_index(port);
 
+   if (i == -1)
+   return;
+
fm_info[i].enabled = 1;
fman_enable_port(port);
 }
-- 
1.7.10.4


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


Re: [U-Boot] [PATCH u-boot sunxi 3/4] sunxi: Implement reset_cpu

2014-05-10 Thread Hans de Goede
Hi,

On 03/24/2014 12:53 AM, Henrik Nordström wrote:
> sön 2014-03-16 klockan 14:53 +0100 skrev Hans de Goede:
>>  void reset_cpu(ulong addr)
>>  {
>> +static const struct sunxi_wdog *wdog =
>> + &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
>> +
>> +/* Set the watchdog for its shortest interval (.5s) and wait */
>> +writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
>> +writel(WDT_CTRL_RESTART, &wdog->ctl);
>> +while (1);
> 
> This code is incomplete and do not reload the watchdog if already
> running. wdog->ctl is locked by a magic key. Should use
> 
> writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
> 
> where
> 
> #define WDT_CTRL_KEY  (0x0a57 << 1)
> 
> Unfortunatley Allwinner kindly omitted this little detail from the User
> Manual.
> 
> Found out while trying to use the watchdog as a watchdog and not only
> reset. Asked Tom while he still was at Allwinner and got clarification
> on how to use the watchdog control register.

Thanks, I'm currently working on v2 of this series and I've included this
fix.

Regards,

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


Re: [U-Boot] [PATCH v4 1/3] usb:gadget:f_thor: code cleanup in function download_tail()

2014-05-10 Thread Marek Vasut
On Friday, May 09, 2014 at 10:35:54 AM, Lukasz Majewski wrote:
> Hi Przemyslaw, Marek,
> 
> > Hello Marek,
> > 
> > On 04/28/2014 06:57 PM, Przemyslaw Marczak wrote:
> > > In thor's download_tail() function, dfu_get_entity() is called
> > > before each dfu_write() call and the returned entity pointers
> > > are the same. So dfu_get_entity() can be called just once and
> > > this patch changes this.
> > > 
> > > Signed-off-by: Przemyslaw Marczak 
> > > Cc: Lukasz Majewski 
> > > Cc: Marek Vasut 
> > > Cc: Heiko Schocher 
> > > Cc: Tom Rini 
> > > 
> > > ---
> > > Changes v2:
> > > - separate fix and cleanup into two commits
> > > 
> > > Changes v3:
> > > - download_tail(): add exit label
> > > 
> > > Changes v4:
> > > - none
> > 
> > I've checked the u-boot-usb/master tree and I found that one commit
> > of this patch set is missed, because it is v3 (there was only two
> > commits). Could you please apply the patch set version 4?
> 
> I've discussed this issue with Przemek, and we agreed that Przemek will
> prepare diff patch between version 3, which is already in mainline and
> version 4.
> 
> Then, after ML review, I will pull them to u-boot-dfu branch.
> 
> Marek, does it work for you?

Yes, thanks.

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