diff mbox

[U-Boot,RFC,v2,2/8] net: Rename helper function to be more clear

Message ID 1422923925-5572-3-git-send-email-joe.hershberger@ni.com
State Superseded
Headers show

Commit Message

Joe Hershberger Feb. 3, 2015, 12:38 a.m. UTC
Make it clear that the helper is checking the addr, not setting it.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---

Changes in v2: None

 net/eth.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Simon Glass Feb. 7, 2015, 1:25 a.m. UTC | #1
On 2 February 2015 at 17:38, Joe Hershberger <joe.hershberger@ni.com> wrote:
> Make it clear that the helper is checking the addr, not setting it.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Reviewed-by: Simon Glass <sjg@chromium.org>

> ---
>
> Changes in v2: None
>
>  net/eth.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/net/eth.c b/net/eth.c
> index eac4f7b..65e8c77 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -153,11 +153,6 @@ static void eth_current_changed(void)
>                 setenv("ethact", NULL);
>  }
>
> -static int eth_address_set(unsigned char *addr)
> -{
> -       return memcmp(addr, "\0\0\0\0\0\0", 6);
> -}
> -
>  int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>                    int eth_number)
>  {
> @@ -166,9 +161,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>
>         eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
>
> -       if (eth_address_set(env_enetaddr)) {
> -               if (eth_address_set(dev->enetaddr) &&
> -                               memcmp(dev->enetaddr, env_enetaddr, 6)) {
> +       if (!is_zero_ether_addr(env_enetaddr)) {
> +               if (!is_zero_ether_addr(dev->enetaddr) &&
> +                   memcmp(dev->enetaddr, env_enetaddr, 6)) {
>                         printf("\nWarning: %s MAC addresses don't match:\n",
>                                 dev->name);
>                         printf("Address in SROM is         %pM\n",
> @@ -183,7 +178,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
>                                              dev->enetaddr);
>                 printf("\nWarning: %s using MAC address from net device\n",
>                         dev->name);
> -       } else if (!(eth_address_set(dev->enetaddr))) {
> +       } else if (is_zero_ether_addr(dev->enetaddr)) {
>                 printf("\nError: %s address not set.\n",
>                        dev->name);
>                 return -EINVAL;
> --
> 1.7.11.5
>
diff mbox

Patch

diff --git a/net/eth.c b/net/eth.c
index eac4f7b..65e8c77 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -153,11 +153,6 @@  static void eth_current_changed(void)
 		setenv("ethact", NULL);
 }
 
-static int eth_address_set(unsigned char *addr)
-{
-	return memcmp(addr, "\0\0\0\0\0\0", 6);
-}
-
 int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 		   int eth_number)
 {
@@ -166,9 +161,9 @@  int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 
 	eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
 
-	if (eth_address_set(env_enetaddr)) {
-		if (eth_address_set(dev->enetaddr) &&
-				memcmp(dev->enetaddr, env_enetaddr, 6)) {
+	if (!is_zero_ether_addr(env_enetaddr)) {
+		if (!is_zero_ether_addr(dev->enetaddr) &&
+		    memcmp(dev->enetaddr, env_enetaddr, 6)) {
 			printf("\nWarning: %s MAC addresses don't match:\n",
 				dev->name);
 			printf("Address in SROM is         %pM\n",
@@ -183,7 +178,7 @@  int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 					     dev->enetaddr);
 		printf("\nWarning: %s using MAC address from net device\n",
 			dev->name);
-	} else if (!(eth_address_set(dev->enetaddr))) {
+	} else if (is_zero_ether_addr(dev->enetaddr)) {
 		printf("\nError: %s address not set.\n",
 		       dev->name);
 		return -EINVAL;