cmd: part: Add 'number-format' sub-command

The part number sub-command is very useful for retrieving the partition
index in the u-boot environment.

It can be used for various purposes, such as:
1. Retrieving the UUID of the partition using it's name as explained in
patch [1]:

  part number mmc $mmcdev system_a system_a_index
  part uuid mmc $mmcdev:${system_a_index} system_a_uuid

2. setting the 'root=<somedev>' bootarg, as done in ti's
boot environment [2]:

 "if part number mmc ${mmcdev} system${slot_suffix} " \
       "system_part_number; then " \
               "setenv bootargs_ab " \
               "ro root=/dev/mmcblk${mmcdev}p${system_part_number} "

Unfortunetely, the second snippet is broken, since it currently does:
  root=/dev/mmcblk0p<0xhex_value>

And it should do:
  root=/dev/mmcblk0p<decimal_value>

By introducing a new command, part number-format <hex|dec>, we can
control the output format of part number:

  => part number mmc 0 system_a
  0x7
  => part number-format dec
  => part number mmc 0 system_a
  7

[1] https://www.mail-archive.com/u-boot@lists.denx.de/msg342867.html
[2] https://www.mail-archive.com/u-boot@lists.denx.de/msg316806.html

Bug: https://baylibre.atlassian.net/browse/RITA-65
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
1 file changed