public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 5/5] cmd_scsi: use common get_device_and_partition function
Date: Tue,  6 Mar 2012 17:41:12 -0600	[thread overview]
Message-ID: <1331077272-25215-6-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1331077272-25215-1-git-send-email-robherring2@gmail.com>

From: Rob Herring <rob.herring@calxeda.com>

Convert scsiboot to use common device and partition parsing function.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 common/cmd_scsi.c |   58 ++++++++++------------------------------------------
 1 files changed, 11 insertions(+), 47 deletions(-)

diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index fa10751..dcf8b84 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -206,64 +206,28 @@ block_dev_desc_t * scsi_get_dev(int dev)
  */
 int do_scsiboot (cmd_tbl_t *cmdtp, int flag, 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;
+	block_dev_desc_t *dev_desc;
 	disk_partition_t info;
 	image_header_t *hdr;
 #if defined(CONFIG_FIT)
 	const void *fit_hdr = NULL;
 #endif
 
-	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)
 		return cmd_usage(cmdtp);
-	}
 
-	if (!boot_device) {
-		puts ("\n** No boot device **\n");
-		return 1;
-	}
-
-	dev = simple_strtoul(boot_device, &ep, 16);
-	printf("booting from dev %d\n",dev);
-	if (scsi_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
-		printf ("\n** Device %d not available\n", dev);
-		return 1;
-	}
+	if (argc > 1)
+		addr = simple_strtoul(argv[1], NULL, 16);
 
-	if (*ep) {
-		if (*ep != ':') {
-			puts ("\n** Invalid boot device, use `dev[:part]' **\n");
-			return 1;
-		}
-		part = simple_strtoul(++ep, NULL, 16);
-	}
-	if (get_partition_info (&scsi_dev_desc[dev], part, &info)) {
-		printf("error reading partinfo\n");
+	part = get_device_and_partition("scsi", (argc == 3) ? argv[2] : NULL,
+					&dev_desc, &info);
+	if (part < 0)
 		return 1;
-	}
-	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);
-		return 1;
-	}
 
+	dev = dev_desc->dev;
 	printf ("\nLoading from SCSI device %d, partition %d: "
 		"Name: %.32s  Type: %.32s\n",
 		dev, part, info.name, info.type);
-- 
1.7.5.4

      parent reply	other threads:[~2012-03-06 23:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06 23:41 [U-Boot] [RFC PATCH 0/5] add bootable partition support Rob Herring
2012-03-06 23:41 ` [U-Boot] [RFC PATCH 1/5] disk/part: check bootable flag for DOS partitions Rob Herring
2012-03-06 23:41 ` [U-Boot] [RFC PATCH 2/5] disk/part: introduce get_device_and_partition Rob Herring
2012-03-06 23:41 ` [U-Boot] [RFC PATCH 3/5] cmd_ext2: use common get_device_and_partition function Rob Herring
2012-03-06 23:41 ` [U-Boot] [RFC PATCH 4/5] cmd_fat: " Rob Herring
2012-03-06 23:41 ` Rob Herring [this message]

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=1331077272-25215-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox