From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 7/9] cmd_disk: use common get_device_and_partition function
Date: Thu, 23 Aug 2012 16:31:48 -0500 [thread overview]
Message-ID: <1345757510-6756-8-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1345757510-6756-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
common/cmd_disk.c | 77 +++++++++++++----------------------------------------
1 file changed, 19 insertions(+), 58 deletions(-)
diff --git a/common/cmd_disk.c b/common/cmd_disk.c
index 38420dc..e6676b0 100644
--- a/common/cmd_disk.c
+++ b/common/cmd_disk.c
@@ -1,13 +1,15 @@
#include <common.h>
#include <command.h>
+#include <part.h>
+#if defined(CONFIG_CMD_IDE) || defined(CONFIG_CMD_SCSI) || \
+ defined(CONFIG_USB_STORAGE)
int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
char *const argv[])
{
- char *boot_device = NULL;
- char *ep;
- int dev, part = 0;
- ulong addr, cnt;
+ int dev, part;
+ ulong addr = CONFIG_SYS_LOAD_ADDR;
+ ulong cnt;
disk_partition_t info;
image_header_t *hdr;
block_dev_desc_t *dev_desc;
@@ -17,72 +19,30 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
#endif
bootstage_mark(BOOTSTAGE_ID_IDE_START);
- switch (argc) {
- case 1:
- addr = CONFIG_SYS_LOAD_ADDR;
- boot_device = getenv("bootdevice");
- break;
- case 2:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = getenv("bootdevice");
- break;
- case 3:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = argv[2];
- break;
- default:
+ if (argc > 3) {
bootstage_error(BOOTSTAGE_ID_IDE_ADDR);
return CMD_RET_USAGE;
}
bootstage_mark(BOOTSTAGE_ID_IDE_ADDR);
- if (!boot_device) {
- puts("\n** No boot device **\n");
- bootstage_error(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
- return 1;
- }
- bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
+ if (argc > 1)
+ addr = simple_strtoul(argv[1], NULL, 16);
- dev = simple_strtoul(boot_device, &ep, 16);
+ bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
- dev_desc = get_dev(intf, dev);
- if (dev_desc->type == DEV_TYPE_UNKNOWN) {
- printf("\n** Device %d not available\n", dev);
+ part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL,
+ &dev_desc, &info);
+ if (part < 0) {
bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
return 1;
}
- bootstage_mark(BOOTSTAGE_ID_IDE_TYPE);
-
- if (*ep) {
- if (*ep != ':') {
- puts("\n** Invalid boot device, use `dev[:part]' **\n");
- bootstage_error(BOOTSTAGE_ID_IDE_PART);
- return 1;
- }
- part = simple_strtoul(++ep, NULL, 16);
- }
- bootstage_mark(BOOTSTAGE_ID_IDE_PART);
- if (get_partition_info(dev_desc, part, &info)) {
- bootstage_error(BOOTSTAGE_ID_IDE_PART_INFO);
- return 1;
- }
- bootstage_mark(BOOTSTAGE_ID_IDE_PART_INFO);
-
- if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0)
- &&
- (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)
- ) {
- printf("\n** Invalid partition type \"%.32s\"" " (expect \""
- BOOT_PART_TYPE "\")\n",
- info.type);
- bootstage_error(BOOTSTAGE_ID_IDE_PART_TYPE);
- return 1;
- }
- bootstage_mark(BOOTSTAGE_ID_IDE_PART_TYPE);
+ dev = dev_desc->dev;
+ bootstage_mark(BOOTSTAGE_ID_IDE_TYPE);
- printf("\nLoading from disk device %d, partition %d: "
- "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type);
+ printf("\nLoading from %s device %d, partition %d: "
+ "Name: %.32s Type: %.32s\n", intf, dev, part, info.name,
+ info.type);
debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
info.start, info.size, info.blksz);
@@ -158,4 +118,5 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
return bootm_maybe_autostart(cmdtp, argv[0]);
}
+#endif
--
1.7.9.5
next prev parent reply other threads:[~2012-08-23 21:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 21:31 [U-Boot] [PATCH 0/9] Auto partition selection and fs partition consolidation Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 1/9] combine block device load commands into common function Rob Herring
2012-09-05 23:36 ` Tom Rini
2012-09-05 23:47 ` Rob Herring
2012-09-05 23:50 ` Tom Rini
2012-09-21 14:02 ` [U-Boot] [PATCH v2 " Rob Herring
2012-09-25 23:17 ` Tom Rini
2012-08-23 21:31 ` [U-Boot] [PATCH 2/9] disk/part: check bootable flag for DOS partitions Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 3/9] disk/part: introduce get_device_and_partition Rob Herring
2012-08-23 22:36 ` Stephen Warren
2012-08-24 1:57 ` Rob Herring
2012-08-24 2:51 ` Stephen Warren
2012-09-05 23:53 ` Tom Rini
2012-09-21 14:08 ` [U-Boot] [PATCH v2 " Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 4/9] ext4: remove init_fs/deinit_fs Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 5/9] cmd_extX: use common get_device_and_partition function Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 6/9] cmd_fat: " Rob Herring
2012-08-23 21:31 ` Rob Herring [this message]
2012-08-23 21:31 ` [U-Boot] [PATCH 8/9] cmd_zfs: " Rob Herring
2012-08-23 21:31 ` [U-Boot] [PATCH 9/9] cmd_reiser: " Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345757510-6756-8-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.