diff mbox

[U-Boot] usb gadget ether: Fix warning in is_eth_addr_valid()

Message ID 1351726241-27034-1-git-send-email-trini@ti.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini Oct. 31, 2012, 11:30 p.m. UTC
The gadget ethernet driver needs to keep copies of the MAC address (at
both endpoints) as strings so it needs a custom function for validation
of the MAC.  It was not however performing a totally correct check and
also was emitting a warning about a set but unused variable.  The
solution to both is that after checking the string contents we use the
standard test for a valid MAC.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Tom Rini <trini@ti.com>
---
 drivers/usb/gadget/ether.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Hershberger Nov. 1, 2012, 12:31 a.m. UTC | #1
Hi Tom,

On Wed, Oct 31, 2012 at 6:30 PM, Tom Rini <trini@ti.com> wrote:
> The gadget ethernet driver needs to keep copies of the MAC address (at
> both endpoints) as strings so it needs a custom function for validation
> of the MAC.  It was not however performing a totally correct check and
> also was emitting a warning about a set but unused variable.  The
> solution to both is that after checking the string contents we use the
> standard test for a valid MAC.
>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Marek Vasut <marex@denx.de>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Tom Rini Nov. 4, 2012, 6:30 p.m. UTC | #2
On Wed, Oct 31, 2012 at 07:31:12PM -0500, Joe Hershberger wrote:
> Hi Tom,
> 
> On Wed, Oct 31, 2012 at 6:30 PM, Tom Rini <trini@ti.com> wrote:
> > The gadget ethernet driver needs to keep copies of the MAC address (at
> > both endpoints) as strings so it needs a custom function for validation
> > of the MAC.  It was not however performing a totally correct check and
> > also was emitting a warning about a set but unused variable.  The
> > solution to both is that after checking the string contents we use the
> > standard test for a valid MAC.
> >
> > Cc: Joe Hershberger <joe.hershberger@ni.com>
> > Cc: Marek Vasut <marex@denx.de>
> > Signed-off-by: Tom Rini <trini@ti.com>
> > ---
> 
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 6f7e4cd..7444c1e 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1968,8 +1968,8 @@  static int is_eth_addr_valid(char *str)
 			p = q;
 		}
 
-		if (i == 6) /* it looks ok */
-			return 1;
+		/* Now check the contents. */
+		return is_valid_ether_addr(ea);
 	}
 	return 0;
 }