[U-Boot] [Patch v4] powerpc/eeprom: cleanup mac command

York Sun yorksun at freescale.com
Sat Oct 15 00:31:40 CEST 2011


Wolfgang,

On Fri, 2011-10-14 at 23:32 +0200, Wolfgang Denk wrote:
> Dear York Sun,
> 
> In message <1313076710-12662-1-git-send-email-yorksun at freescale.com> you wrote:
> > Change the help message to be more helpful. Print argument format.
> > Fix MAX_NUM_PORTS to comply with v1 NXID format. Accept hexadecimal and
> > decimal for port count and index.
> ...
> 
> >  	case 'p':	/* MAC table size */
> > -		e.mac_count = simple_strtoul(argv[2], NULL, 16);
> > +		e.mac_count = simple_strtoul(argv[2], NULL, 0);
> >  		update_crc();
> >  		break;
> > -	case '0' ... '9':	/* "mac 0" through "mac 22" */
> > -		set_mac_address(simple_strtoul(argv[1], NULL, 10), argv[2]);
> > +	case '0' ... '9':	/* "mac 0" through "mac 31" */
> > +		set_mac_address(simple_strtoul(argv[1], NULL, 0), argv[2]);
> 
> These changes silently change the behaviour of the command.  So far,
> an argument line "24" would be parsed as hex number (i. e. result in
> decimal value 36); with this change it suddenly becomes devcimal 24,
> which is quite unexpected.
> 
> There are very few exceptions wher eU-Boot uses and expects decimal
> numbers, and I strongly recommend not to add any new such
> inconsistencies.

Changing back to hex number is not a problem. But it brings a problem
when trying to set mac address to ports 10-15. For example, for port 14,
you may want to use

mac e xxxxxxxx

where 'e' is another defined command. In order to make this work, we
need to use two bytes for cmd.

Back to my current patch, it was from another nice feedback. To accept
both hex and decimal. In order to use hex, you will have to prefix it
with 0x.

Regards,

York





More information about the U-Boot mailing list