diff mbox

[U-Boot] net: eth_common: Don't use %pM when USE_TINY_PRINTF is enabled

Message ID 20170331094703.13024-1-vigneshr@ti.com
State Superseded
Delegated to: Joe Hershberger
Headers show

Commit Message

Raghavendra, Vignesh March 31, 2017, 9:47 a.m. UTC
Tiny printf doesn't support %pM, so when CONFIG_USE_TINY_PRINTF is
enabled use %x to manually print MAC address.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 net/eth_common.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Joe Hershberger April 2, 2017, 5:47 p.m. UTC | #1
On Fri, Mar 31, 2017 at 4:47 AM, Vignesh R <vigneshr@ti.com> wrote:
> Tiny printf doesn't support %pM, so when CONFIG_USE_TINY_PRINTF is
> enabled use %x to manually print MAC address.
>
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
>  net/eth_common.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/net/eth_common.c b/net/eth_common.c
> index 58fa29577102..cd67a21585c6 100644
> --- a/net/eth_common.c
> +++ b/net/eth_common.c
> @@ -37,7 +37,14 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
>         if (eth_getenv_enetaddr(name, (uchar *)buf))
>                 return -EEXIST;
>
> +#ifndef CONFIG_USE_TINY_PRINTF

Use positive logic. Switch these cases around.

>         sprintf(buf, "%pM", enetaddr);
> +#else
> +       sprintf(buf, "%x:%x:%x:%x:%x:%x", (unsigned int)enetaddr[0],
> +               (unsigned int)enetaddr[1], (unsigned int)enetaddr[2],
> +               (unsigned int)enetaddr[3], (unsigned int)enetaddr[4],
> +               (unsigned int)enetaddr[5]);
> +#endif
>
>         return setenv(name, buf);
>  }
> --
> 2.11.0
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Raghavendra, Vignesh April 3, 2017, 5:48 a.m. UTC | #2
On Sunday 02 April 2017 11:17 PM, Joe Hershberger wrote:
> On Fri, Mar 31, 2017 at 4:47 AM, Vignesh R <vigneshr@ti.com> wrote:
>> Tiny printf doesn't support %pM, so when CONFIG_USE_TINY_PRINTF is
>> enabled use %x to manually print MAC address.
>>
>> Signed-off-by: Vignesh R <vigneshr@ti.com>
>> ---
>>  net/eth_common.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/net/eth_common.c b/net/eth_common.c
>> index 58fa29577102..cd67a21585c6 100644
>> --- a/net/eth_common.c
>> +++ b/net/eth_common.c
>> @@ -37,7 +37,14 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
>>         if (eth_getenv_enetaddr(name, (uchar *)buf))
>>                 return -EEXIST;
>>
>> +#ifndef CONFIG_USE_TINY_PRINTF
> 
> Use positive logic. Switch these cases around.

Ok, posted version 2 with this change. Thanks!

> 
>>         sprintf(buf, "%pM", enetaddr);
>> +#else
>> +       sprintf(buf, "%x:%x:%x:%x:%x:%x", (unsigned int)enetaddr[0],
>> +               (unsigned int)enetaddr[1], (unsigned int)enetaddr[2],
>> +               (unsigned int)enetaddr[3], (unsigned int)enetaddr[4],
>> +               (unsigned int)enetaddr[5]);
>> +#endif
>>
>>         return setenv(name, buf);
>>  }
>> --
>> 2.11.0
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> https://lists.denx.de/listinfo/u-boot
diff mbox

Patch

diff --git a/net/eth_common.c b/net/eth_common.c
index 58fa29577102..cd67a21585c6 100644
--- a/net/eth_common.c
+++ b/net/eth_common.c
@@ -37,7 +37,14 @@  int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
 	if (eth_getenv_enetaddr(name, (uchar *)buf))
 		return -EEXIST;
 
+#ifndef CONFIG_USE_TINY_PRINTF
 	sprintf(buf, "%pM", enetaddr);
+#else
+	sprintf(buf, "%x:%x:%x:%x:%x:%x", (unsigned int)enetaddr[0],
+		(unsigned int)enetaddr[1], (unsigned int)enetaddr[2],
+		(unsigned int)enetaddr[3], (unsigned int)enetaddr[4],
+		(unsigned int)enetaddr[5]);
+#endif
 
 	return setenv(name, buf);
 }