All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/30] dm: blk: Rename get_device_and_partition()
Date: Sun, 14 Feb 2016 19:16:40 -0700	[thread overview]
Message-ID: <1455502619-16093-12-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1455502619-16093-1-git-send-email-sjg@chromium.org>

Rename this function to blk_get_device_part_str(). This is a better name
because it makes it clear that the function returns a block device and
parses a string.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/disk.c       |  2 +-
 cmd/fat.c        |  4 ++--
 cmd/part.c       |  2 +-
 cmd/reiser.c     |  4 ++--
 cmd/zfs.c        |  4 ++--
 common/env_fat.c |  4 ++--
 disk/part.c      |  2 +-
 fs/fs.c          |  2 +-
 fs/ubifs/ubifs.c |  2 +-
 include/part.h   | 38 ++++++++++++++++++++++++++++++++++++--
 10 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/cmd/disk.c b/cmd/disk.c
index c53c2a2..0883c79 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -38,7 +38,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
 
 	bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
 
-	part = get_device_and_partition(intf, (argc == 3) ? argv[2] : NULL,
+	part = blk_get_device_part_str(intf, (argc == 3) ? argv[2] : NULL,
 					&dev_desc, &info, 1);
 	if (part < 0) {
 		bootstage_error(BOOTSTAGE_ID_IDE_TYPE);
diff --git a/cmd/fat.c b/cmd/fat.c
index 82b9b38..18a1be9 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -77,7 +77,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
 		return 0;
 	}
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
@@ -114,7 +114,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
 	if (argc < 5)
 		return cmd_usage(cmdtp);
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
diff --git a/cmd/part.c b/cmd/part.c
index f05699d..6683ed5 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -37,7 +37,7 @@ static int do_part_uuid(int argc, char * const argv[])
 	if (argc > 3)
 		return CMD_RET_USAGE;
 
-	part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0);
+	part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
 	if (part < 0)
 		return 1;
 
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 1cca5eb..a717956 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -40,7 +40,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc < 3)
 		return CMD_RET_USAGE;
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
@@ -122,7 +122,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 	}
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
diff --git a/cmd/zfs.c b/cmd/zfs.c
index 9076a8a..bb61afd 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -80,7 +80,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 		return 1;
 	}
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
@@ -145,7 +145,7 @@ static int do_zfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc == 4)
 		filename = argv[3];
 
-	part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
+	part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
 
diff --git a/common/env_fat.c b/common/env_fat.c
index e88279e..2f22710 100644
--- a/common/env_fat.c
+++ b/common/env_fat.c
@@ -48,7 +48,7 @@ int saveenv(void)
 	if (err)
 		return err;
 
-	part = get_device_and_partition(FAT_ENV_INTERFACE,
+	part = blk_get_device_part_str(FAT_ENV_INTERFACE,
 					FAT_ENV_DEVICE_AND_PART,
 					&dev_desc, &info, 1);
 	if (part < 0)
@@ -82,7 +82,7 @@ void env_relocate_spec(void)
 	int dev, part;
 	int err;
 
-	part = get_device_and_partition(FAT_ENV_INTERFACE,
+	part = blk_get_device_part_str(FAT_ENV_INTERFACE,
 					FAT_ENV_DEVICE_AND_PART,
 					&dev_desc, &info, 1);
 	if (part < 0)
diff --git a/disk/part.c b/disk/part.c
index 700e505..43a640f 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -511,7 +511,7 @@ cleanup:
 #define PART_UNSPECIFIED -2
 #define PART_AUTO -1
 #define MAX_SEARCH_PARTITIONS 16
-int get_device_and_partition(const char *ifname, const char *dev_part_str,
+int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 			     struct blk_desc **dev_desc,
 			     disk_partition_t *info, int allow_whole_dev)
 {
diff --git a/fs/fs.c b/fs/fs.c
index 8515bea..595ff1f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -213,7 +213,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 	}
 #endif
 
-	part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc,
+	part = blk_get_device_part_str(ifname, dev_part_str, &fs_dev_desc,
 					&fs_partition, 1);
 	if (part < 0)
 		return -1;
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 168ae2b..cdc04c6 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -569,7 +569,7 @@ int ubifs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)
 	}
 
 	/*
-	 * Should never happen since get_device_and_partition() already checks
+	 * Should never happen since blk_get_device_part_str() already checks
 	 * this, but better safe then sorry.
 	 */
 	if (!ubifs_is_mounted()) {
diff --git a/include/part.h b/include/part.h
index d05b48b..465dcdd 100644
--- a/include/part.h
+++ b/include/part.h
@@ -129,7 +129,41 @@ void dev_print(struct blk_desc *dev_desc);
  */
 int blk_get_device_str(const char *ifname, const char *dev_str,
 		       struct blk_desc **dev_desc);
-int get_device_and_partition(const char *ifname, const char *dev_part_str,
+
+/**
+ * blk_get_device_part_str() - Get a block device and partition
+ *
+ * This calls blk_get_device_str() to look up a device. It also looks up
+ * a partition and returns information about it.
+ *
+ * @dev_part_str is in the format:
+ *	<dev>.<hw_part>:<part> where <dev> is the device number,
+ *	<hw_part> is the optional hardware partition number and
+ *	<part> is the partition number
+ *
+ * If ifname is "hostfs" then this function returns the sandbox host block
+ * device.
+ *
+ * If ifname is ubi, then this function returns 0, with @info set to a
+ * special UBI device.
+ *
+ * If @dev_part_str is NULL or empty or "-", then this function looks up
+ * the "bootdevice" environment variable and uses that string instead.
+ *
+ * If the partition string is empty then the first partition is used. If the
+ * partition string is "auto" then the first bootable partition is used.
+ *
+ * @ifname:	Interface name (e.g. "ide", "scsi")
+ * @dev_part_str:	Device and partition string
+ * @dev_desc:	Returns a pointer to the block device on success
+ * @info:	Returns partition information
+ * @allow_whole_dev:	true to allow the user to select partition 0
+ *		(which means the whole device), false to require a valid
+ *		partition number >= 1
+ * @return partition number, or -1 on error
+ *
+ */
+int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 			     struct blk_desc **dev_desc,
 			     disk_partition_t *info, int allow_whole_dev);
 #else
@@ -153,7 +187,7 @@ static inline void dev_print(struct blk_desc *dev_desc) {}
 static inline int blk_get_device_str(const char *ifname, const char *dev_str,
 				     struct blk_desc **dev_desc)
 { return -1; }
-static inline int get_device_and_partition(const char *ifname,
+static inline int blk_get_device_part_str(const char *ifname,
 					   const char *dev_part_str,
 					   struct blk_desc **dev_desc,
 					   disk_partition_t *info,
-- 
2.7.0.rc3.207.g0ac5344

  parent reply	other threads:[~2016-02-15  2:16 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-15  2:16 [U-Boot] [PATCH 00/30] dm: Add driver-model support for block drivers Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 01/30] dm: Drop the block_dev_desc_t typedef Simon Glass
2016-02-16 10:09   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 02/30] dm: pci: Break out the common region display code Simon Glass
2016-02-16 10:09   ` Bin Meng
2016-02-29  4:18     ` Simon Glass
2016-02-17  0:19   ` Stephen Warren
2016-02-15  2:16 ` [U-Boot] [PATCH 03/30] dm: part: Correct a sandbox build warning Simon Glass
2016-02-16 10:09   ` Bin Meng
2016-02-29  4:18     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 04/30] dm: fdtdec: " Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 05/30] dm: part: Drop the common.h header Simon Glass
2016-02-16 10:09   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 06/30] dm: Add a new header for block devices Simon Glass
2016-02-16 10:10   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 07/30] dm: blk: Convert interface type to an enum Simon Glass
2016-02-16 10:10   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 08/30] dm: blk: Add comments to a few functions Simon Glass
2016-02-16 10:10   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 09/30] dm: blk: Rename get_dev() to blk_get_dev() Simon Glass
2016-02-16 10:10   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 10/30] dm: blk: Rename get_device() to blk_get_device_str() Simon Glass
2016-02-16 14:02   ` Bin Meng
2016-02-16 23:14   ` Stephen Warren
2016-02-15  2:16 ` Simon Glass [this message]
2016-02-16 14:02   ` [U-Boot] [PATCH 11/30] dm: blk: Rename get_device_and_partition() Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 12/30] dm: part: Add a cast to avoid a compiler warning Simon Glass
2016-02-16 14:02   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 13/30] dm: sandbox: Enable all partition types Simon Glass
2016-02-15 22:37   ` Tom Rini
2016-02-16 14:02   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 14/30] dm: part: Convert partition API use to linker lists Simon Glass
2016-02-15 22:37   ` Tom Rini
2016-02-16 14:25   ` Bin Meng
2016-02-29  4:18     ` Simon Glass
2016-02-17  6:41   ` Stephen Warren
2016-02-29  4:48     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 15/30] dm: part: Rename some partition functions Simon Glass
2016-02-16 14:25   ` Bin Meng
2016-02-29  4:19     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 16/30] dm: cbfs: Fix handling of invalid type Simon Glass
2016-02-16 14:51   ` Bin Meng
2016-02-29  4:19     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 17/30] dm: sandbox: Enable cbfs and cramfs Simon Glass
2016-02-16 14:51   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 18/30] dm: block: Rename device number member dev to devnum Simon Glass
2016-02-16 14:51   ` Bin Meng
2016-02-16 23:23   ` Stephen Warren
2016-02-29  4:19     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 19/30] dm: block: Adjust device calls to go through helpers function Simon Glass
2016-02-16 14:51   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 20/30] dm: usb: Avoid exceeding available array size for storage devices Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 21/30] dm: usb: Tidy up storage code ready for driver model conversion Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 22/30] dm: blk: Add a block-device uclass Simon Glass
2016-02-17  4:49   ` Bin Meng
2016-02-15  2:16 ` [U-Boot] [PATCH 23/30] dm: sandbox: Prepare block driver for driver-model conversion Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 24/30] dm: sandbox: Add driver-model block-device support for sandbox Simon Glass
2016-02-16 23:34   ` Stephen Warren
2016-02-29  4:19     ` Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 25/30] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 26/30] dm: usb: Unbind old block devices when shutting down USB Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 27/30] dm: sandbox: Switch over to use DM for block devices Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 28/30] dm: sandbox: Drop the pre-DM host implementation Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 29/30] dm: usb: Clean up USB after each test Simon Glass
2016-02-15  2:16 ` [U-Boot] [PATCH 30/30] dm: blk: Add tests for block devices Simon Glass
2016-02-15 22:37 ` [U-Boot] [PATCH 00/30] dm: Add driver-model support for block drivers Tom Rini
2016-02-29  4:19   ` Simon Glass
2016-02-16 23:43 ` Stephen Warren
2016-02-29  4:19   ` Simon Glass

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=1455502619-16093-12-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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.