u-boot-brain/common
Stephen Warren 10a37fd7a4 disk: get_device_and_partition() "auto" partition and cleanup
Rework get_device_and_partition() to:
a) Implement a new partition ID of "auto", which requests that U-Boot
   search for the first "bootable" partition, and fall back to the first
   valid partition if none is found. This way, users don't need to
   specify an explicit partition in their commands.
b) Make use of get_device().
c) Add parameter to indicate whether returning a whole device is
   acceptable, or whether a partition is mandatory.
d) Make error-checking of the user's device-/partition-specification
   more complete. In particular, if strtoul() doesn't convert all
   characters, it's an error rather than just ignored.

The resultant device/partition returned by the function will be as
follows, based on whether the disk has a partition table (ptable) or not,
and whether the calling command allows the whole device to be returned
or not.

(D and P are integers, P >= 1)

D
D:
  No ptable:
    !allow_whole_dev: error
    allow_whole_dev: device D
  ptable:
    device D partition 1
D:0
  !allow_whole_dev: error
  allow_whole_dev: device D
D:P
  No ptable: error
  ptable: device D partition P
D:auto
  No ptable:
    !allow_whole_dev: error
    allow_whole_dev: device D
  ptable:
    first partition in device D with bootable flag set.
    If none, first valid paratition in device D.

Note: In order to review this patch, it's probably easiest to simply
look at the file contents post-application, rather than reading the
patch itself.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Rob implemented scanning for bootable partitions. I fixed a
couple of issues there, switched the syntax to ":auto", added the
error-checking rework, and ":0" syntax for the whole device]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
2012-09-25 14:58:48 -07:00
..
bedbug.c common: Move conditional compilation to Makefile 2008-08-13 01:40:38 +02:00
bootstage.c Move bootstage timer out of lib/time.c 2012-04-10 23:35:32 +02:00
cmd_ambapp.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_bdinfo.c dm: sparc: common: Fixup cmd_bdinfo warnings 2012-09-18 12:01:50 -07:00
cmd_bedbug.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_bmp.c cmd_bmp.c: make bmp_display() usable by drivers or board code 2012-05-25 09:15:09 +02:00
cmd_boot.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_bootldr.c Blackfin: bootldr: use common defines 2011-04-08 00:44:27 -04:00
cmd_bootm.c common/cmd_bootm.c: Fix GCC 4.6 warning 2012-05-22 10:12:58 +02:00
cmd_cache.c cmd_cache: use cache/invalidate functions available in common.h 2012-03-06 22:12:54 +01:00
cmd_console.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_cplbinfo.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_cramfs.c cramfs: make cramfs usable without a NOR flash 2011-05-10 22:47:32 +02:00
cmd_dataflash_mmc_mux.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_date.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_dcr.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_df.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_dfu.c dfu:cmd: Support for DFU u-boot command 2012-09-01 16:21:51 +02:00
cmd_diag.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_disk.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_display.c led_display: split led display support into generic and hw-dependent parts 2010-10-12 22:44:33 +02:00
cmd_dtt.c hwmon: Provide dtt_init() 2011-10-22 01:22:21 +02:00
cmd_echo.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_eeprom.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_elf.c bootvx: Clear and disable data cache, and call vxWorks with parameter. 2012-03-18 20:14:05 +01:00
cmd_exit.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_ext2.c ext4fs ls load support 2012-08-09 23:47:43 +02:00
cmd_ext4.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_ext_common.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_fat.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_fdc.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_fdos.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_fdt.c fdt: Check if the FDT address is configured 2012-09-15 09:16:08 -04:00
cmd_fitupd.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_flash.c cfi: Make the flash erase and write operations abortable 2012-09-03 11:24:27 +02:00
cmd_fpga.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_gpio.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_help.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_i2c.c i2c: deblock i2c bus also if accessed before realocation 2012-07-31 07:40:15 +02:00
cmd_ide.c combine block device load commands into common function 2012-09-25 14:43:19 -07:00
cmd_immap.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_irq.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_itest.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_jffs2.c cmd_jffs2: Fix get_part_sector_size_nor() overflow bug 2011-01-19 00:04:43 +01:00
cmd_ldrinfo.c Blackfin: ldrinfo: new command 2011-04-08 00:44:27 -04:00
cmd_led.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_license.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_load.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_log.c cmd_log: print log->v2.con value in the "log info" command 2012-03-30 22:32:50 +02:00
cmd_mac.c cmd_mac: fix help for 'mac read' 2011-07-28 16:41:06 +02:00
cmd_md5sum.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mdio.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mem.c cmd_mem: cmp: convert while() to for() loop 2012-06-19 22:32:11 +02:00
cmd_mfsl.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mii.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_misc.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mmc_spi.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mmc.c mmcinfo: Fix help message 2012-09-05 17:32:42 -05:00
cmd_mp.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mtdparts.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_nand.c Merge branch 'master' of git://git.denx.de/u-boot-arm 2012-09-21 14:53:13 -07:00
cmd_net.c net: Add link-local addressing support 2012-05-23 17:53:08 -05:00
cmd_nvedit.c env: make "env default" selective, check and apply 2012-09-18 12:01:52 -07:00
cmd_onenand.c linux/compat.h: rename from linux/mtd/compat.h 2012-04-30 16:54:51 +02:00
cmd_otp.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_pci.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_pcmcia.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_portio.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_pxe.c Add run_command_list() to run a list of commands 2012-08-09 22:06:03 +02:00
cmd_reginfo.c mpc85xx: Add reginfo command 2010-07-16 10:55:09 -05:00
cmd_reiser.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_sata.c SATA: check for return value from sata functions 2012-05-15 08:31:30 +02:00
cmd_scsi.c combine block device load commands into common function 2012-09-25 14:43:19 -07:00
cmd_setexpr.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_sf.c cmd_sf: add size checking to spi flash commands 2012-04-03 04:34:13 +00:00
cmd_sha1sum.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_source.c Add run_command_list() to run a list of commands 2012-08-09 22:06:03 +02:00
cmd_spi.c cmd_spi: remove superfluous semicolon 2012-08-09 20:41:32 -04:00
cmd_spibootldr.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_spl.c Add cmd_spl command 2012-03-27 22:05:28 +02:00
cmd_strings.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_terminal.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_test.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_time.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_tpm.c Add a cli command to test the TPM device. 2011-12-06 21:30:03 +01:00
cmd_tsi148.c common: tsi148 - fix gcc 4.6 compiler warning 2011-11-16 21:42:17 +01:00
cmd_ubi.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_ubifs.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_universe.c common/cmd_universe.c: Fix GCC 4.6 build warning 2011-11-16 21:04:55 +01:00
cmd_unzip.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_usb.c combine block device load commands into common function 2012-09-25 14:43:19 -07:00
cmd_version.c unify version_string 2011-07-28 17:22:53 +02:00
cmd_ximg.c checkpatch whitespace cleanups 2011-10-22 01:13:35 +02:00
cmd_yaffs2.c u-boot: Update yaffs2 file system 2012-08-09 23:39:18 +02:00
cmd_zfs.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
command.c Add cmd_process() to process commands in one place 2012-03-06 21:09:41 +01:00
console.c Revert "Add board_pre_console_putc to deal with early console output" 2012-03-23 21:27:32 +01:00
ddr_spd.c mpc8xxx: DDR2/DDR3: Clean up DIMM-type switch statements 2011-04-04 09:24:43 -05:00
dlmalloc.c Fix strict-aliasing warning in dlmalloc 2012-09-13 13:32:41 +02:00
dlmalloc.src * Code cleanup: 2003-06-27 21:31:46 +00:00
env_common.c env: make "env default" selective, check and apply 2012-09-18 12:01:52 -07:00
env_dataflash.c env: clean env_dataflash.c checkpatch and code style 2011-11-22 08:39:26 +01:00
env_eeprom.c env: clean env_eeprom.c checkpatch and code style 2011-11-22 08:39:26 +01:00
env_embedded.c Add env vars describing U-Boot target board 2012-07-09 22:44:33 +02:00
env_fat.c Add support for loading and saving the environment to a FAT partition 2012-03-30 22:38:14 +02:00
env_flash.c env: factor out the env_get_char_spec() function 2012-01-05 16:34:10 +01:00
env_mmc.c env_mmc: allow environment to be in an eMMC partition 2012-09-07 13:54:31 -07:00
env_nand.c env_nand: fix incorrect size parameter to ALLOC_CACHE_ALIGN_BUFFER 2012-09-18 12:01:51 -07:00
env_nowhere.c env: factor out the env_get_char_spec() function 2012-01-05 16:34:10 +01:00
env_nvram.c env: factor out the env_get_char_spec() function 2012-01-05 16:34:10 +01:00
env_onenand.c env_onenand: set ONENAND_MAX_ENV_SIZE to CONFIG_ENV_SIZE 2012-08-06 10:38:47 +02:00
env_remote.c powerpc/corenet_ds: Slave module for boot from PCIE 2012-08-23 10:24:15 -05:00
env_sf.c env: factor out the env_get_char_spec() function 2012-01-05 16:34:10 +01:00
exports.c Fix SPI build errors in exports.c 2011-12-07 08:41:22 +01:00
fdt_support.c Fix constness of the fdt void pointer in fdt_getprop_u32_default 2011-11-13 11:21:34 -05:00
flash.c cfi: Make the flash erase and write operations abortable 2012-09-03 11:24:27 +02:00
hush.c hush: Don't parse the contents of a dereferenced var 2012-09-02 20:31:21 +02:00
hwconfig.c Minor Coding Style Cleanup. 2011-02-02 22:36:10 +01:00
image.c Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx 2012-09-25 12:23:55 -07:00
iomux.c stdio/device: rework function naming convention 2009-07-18 00:27:46 +02:00
kallsyms.c Add support for Linux-like kallsysms 2009-06-12 20:45:48 +02:00
kgdb_stubs.c kgdb: add default generic stubs 2010-01-18 00:23:00 +01:00
kgdb.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
lcd.c common lcd: minor coding style changes 2012-07-10 11:35:38 +02:00
lynxkdi.c checkpatch whitespace cleanups 2011-10-22 01:13:35 +02:00
main.c Consider CONFIG_ZERO_BOOTDELAY_CHECK when CONFIG_AUTOBOOT_KEYED is set 2012-08-09 22:40:15 +02:00
Makefile combine block device load commands into common function 2012-09-25 14:43:19 -07:00
memsize.c Revert "memsize: Fix for bug in memory sizing code" 2012-09-21 08:14:05 -07:00
menu.c menu: only timeout when menu is displayed 2012-06-21 22:34:00 +02:00
miiphyutil.c Revert "mii: miiphy register address width change" 2011-12-07 08:35:14 +01:00
modem.c common: move extern char console_buffer[] to common.h 2011-11-22 08:39:25 +01:00
s_record.c Initial revision 2002-08-17 09:36:01 +00:00
serial.c serial: constify serial_assign() 2011-12-05 22:48:10 +01:00
stdio.c stdio: Fix a possible buffer overflow 2011-09-04 23:27:52 +02:00
system_map.c Add support for Linux-like kallsysms 2009-06-12 20:45:48 +02:00
update.c net: tftpput: Rename TFTP to TFTPGET 2011-10-26 21:33:42 +02:00
usb_hub.c usb: do explicit unaligned accesses 2012-09-21 00:05:00 +02:00
usb_kbd.c USB: move keyboard polling into kbd driver 2012-03-03 16:56:29 +01:00
usb_storage.c usb: Optimize USB storage read/write 2012-09-01 16:21:52 +02:00
usb.c usb: check return value of submit_{control, bulk}_msg 2012-07-18 14:43:42 +02:00
xyzModem.c cleanup: Fix typos and misspellings in various files. 2011-07-28 21:27:36 +02:00