* [U-Boot] [PATCH v2 02/32] dm: pci: Break out the common region display code
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 03/32] dm: part: Correct a sandbox build warning Simon Glass
` (31 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Each region is displayed in almost the same way. Break out this common code
into its own function.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Fix use of pci_mem instead of pci_prefetch
- Remove 0x prefix for addresses
drivers/pci/pci_auto_common.c | 51 +++++++++++++++----------------------------
1 file changed, 17 insertions(+), 34 deletions(-)
diff --git a/drivers/pci/pci_auto_common.c b/drivers/pci/pci_auto_common.c
index 85c419e..677f094 100644
--- a/drivers/pci/pci_auto_common.c
+++ b/drivers/pci/pci_auto_common.c
@@ -62,6 +62,17 @@ int pciauto_region_allocate(struct pci_region *res, pci_size_t size,
return -1;
}
+static void pciauto_show_region(const char *name, struct pci_region *region)
+{
+ pciauto_region_init(region);
+ debug("PCI Autoconfig: Bus %s region: [%llx-%llx],\n"
+ "\t\tPhysical Memory [%llx-%llxx]\n", name,
+ (unsigned long long)region->bus_start,
+ (unsigned long long)(region->bus_start + region->size - 1),
+ (unsigned long long)region->phys_start,
+ (unsigned long long)(region->phys_start + region->size - 1));
+}
+
void pciauto_config_init(struct pci_controller *hose)
{
int i;
@@ -91,38 +102,10 @@ void pciauto_config_init(struct pci_controller *hose)
}
- if (hose->pci_mem) {
- pciauto_region_init(hose->pci_mem);
-
- debug("PCI Autoconfig: Bus Memory region: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory [%llx-%llxx]\n",
- (u64)hose->pci_mem->bus_start,
- (u64)(hose->pci_mem->bus_start + hose->pci_mem->size - 1),
- (u64)hose->pci_mem->phys_start,
- (u64)(hose->pci_mem->phys_start + hose->pci_mem->size - 1));
- }
-
- if (hose->pci_prefetch) {
- pciauto_region_init(hose->pci_prefetch);
-
- debug("PCI Autoconfig: Bus Prefetchable Mem: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory [%llx-%llx]\n",
- (u64)hose->pci_prefetch->bus_start,
- (u64)(hose->pci_prefetch->bus_start +
- hose->pci_prefetch->size - 1),
- (u64)hose->pci_prefetch->phys_start,
- (u64)(hose->pci_prefetch->phys_start +
- hose->pci_prefetch->size - 1));
- }
-
- if (hose->pci_io) {
- pciauto_region_init(hose->pci_io);
-
- debug("PCI Autoconfig: Bus I/O region: [0x%llx-0x%llx],\n"
- "\t\tPhysical Memory: [%llx-%llx]\n",
- (u64)hose->pci_io->bus_start,
- (u64)(hose->pci_io->bus_start + hose->pci_io->size - 1),
- (u64)hose->pci_io->phys_start,
- (u64)(hose->pci_io->phys_start + hose->pci_io->size - 1));
- }
+ if (hose->pci_mem)
+ pciauto_show_region("Memory", hose->pci_mem);
+ if (hose->pci_prefetch)
+ pciauto_show_region("Prefetchable Mem", hose->pci_prefetch);
+ if (hose->pci_io)
+ pciauto_show_region("I/O", hose->pci_io);
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 03/32] dm: part: Correct a sandbox build warning
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 02/32] dm: pci: Break out the common region display code Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 04/32] dm: fdtdec: " Simon Glass
` (30 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Adjust the cast to avoid a warning when stdint.h is used.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
disk/part_efi.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/disk/part_efi.c b/disk/part_efi.c
index db5e7ed..7bd840f 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -658,11 +658,13 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
gpt_part_size = le64_to_cpu(gpt_e[i].ending_lba) -
le64_to_cpu(gpt_e[i].starting_lba) + 1;
debug("size(LBA) - GPT: %8llu, ENV: %8llu ",
- gpt_part_size, (u64) partitions[i].size);
+ (unsigned long long)gpt_part_size,
+ (unsigned long long)partitions[i].size);
if (le64_to_cpu(gpt_part_size) != partitions[i].size) {
error("Partition %s size: %llu does not match %llu!\n",
- efi_str, gpt_part_size, (u64) partitions[i].size);
+ efi_str, (unsigned long long)gpt_part_size,
+ (unsigned long long)partitions[i].size);
return -1;
}
@@ -678,12 +680,12 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
/* Check if GPT and ENV start LBAs match */
debug("start LBA - GPT: %8llu, ENV: %8llu\n",
le64_to_cpu(gpt_e[i].starting_lba),
- (u64) partitions[i].start);
+ (unsigned long long)partitions[i].start);
if (le64_to_cpu(gpt_e[i].starting_lba) != partitions[i].start) {
error("Partition %s start: %llu does not match %llu!\n",
efi_str, le64_to_cpu(gpt_e[i].starting_lba),
- (u64) partitions[i].start);
+ (unsigned long long)partitions[i].start);
return -1;
}
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 04/32] dm: fdtdec: Correct a sandbox build warning
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 02/32] dm: pci: Break out the common region display code Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 03/32] dm: part: Correct a sandbox build warning Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 05/32] dm: part: Drop the common.h header Simon Glass
` (29 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Adjust the cast to avoid a warning when stdint.h is used.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
lib/fdtdec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index b361a25..0cb255f 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -123,9 +123,10 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
if (sizep) {
*sizep = fdtdec_get_number(prop_size, ns);
- debug("addr=%08llx, size=%llx\n", (u64)addr, (u64)*sizep);
+ debug("addr=%08llx, size=%llx\n", (unsigned long long)addr,
+ (unsigned long long)*sizep);
} else {
- debug("addr=%08llx\n", (u64)addr);
+ debug("addr=%08llx\n", (unsigned long long)addr);
}
return addr;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 05/32] dm: part: Drop the common.h header
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (2 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 04/32] dm: fdtdec: " Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 06/32] dm: Add a new header for block devices Simon Glass
` (28 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
We should not include <common.h> in header files. Each C file should include
it if needed.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
include/part.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/part.h b/include/part.h
index d1e9d0f..140c9b6 100644
--- a/include/part.h
+++ b/include/part.h
@@ -8,7 +8,6 @@
#define _PART_H
#include <ide.h>
-#include <common.h>
struct blk_desc {
int if_type; /* type of the interface */
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 06/32] dm: Add a new header for block devices
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (3 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 05/32] dm: part: Drop the common.h header Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 07/32] dm: blk: Convert interface type to an enum Simon Glass
` (27 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
At present block devices are tied up with partitions. But not all block
devices have partitions within them. They are in fact separate concepts.
Create a separate blk.h header file for block devices.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
include/blk.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/ide.h | 12 ++--------
include/part.h | 49 +---------------------------------------
3 files changed, 74 insertions(+), 58 deletions(-)
create mode 100644 include/blk.h
diff --git a/include/blk.h b/include/blk.h
new file mode 100644
index 0000000..1e8334c
--- /dev/null
+++ b/include/blk.h
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef BLK_H
+#define BLK_H
+
+#ifdef CONFIG_SYS_64BIT_LBA
+typedef uint64_t lbaint_t;
+#define LBAFlength "ll"
+#else
+typedef ulong lbaint_t;
+#define LBAFlength "l"
+#endif
+#define LBAF "%" LBAFlength "x"
+#define LBAFU "%" LBAFlength "u"
+
+/* Interface types: */
+#define IF_TYPE_UNKNOWN 0
+#define IF_TYPE_IDE 1
+#define IF_TYPE_SCSI 2
+#define IF_TYPE_ATAPI 3
+#define IF_TYPE_USB 4
+#define IF_TYPE_DOC 5
+#define IF_TYPE_MMC 6
+#define IF_TYPE_SD 7
+#define IF_TYPE_SATA 8
+#define IF_TYPE_HOST 9
+#define IF_TYPE_MAX 10 /* Max number of IF_TYPE_* supported */
+
+struct blk_desc {
+ int if_type; /* type of the interface */
+ int dev; /* device number */
+ unsigned char part_type; /* partition type */
+ unsigned char target; /* target SCSI ID */
+ unsigned char lun; /* target LUN */
+ unsigned char hwpart; /* HW partition, e.g. for eMMC */
+ unsigned char type; /* device type */
+ unsigned char removable; /* removable device */
+#ifdef CONFIG_LBA48
+ /* device can use 48bit addr (ATA/ATAPI v7) */
+ unsigned char lba48;
+#endif
+ lbaint_t lba; /* number of blocks */
+ unsigned long blksz; /* block size */
+ int log2blksz; /* for convenience: log2(blksz) */
+ char vendor[40+1]; /* IDE model, SCSI Vendor */
+ char product[20+1]; /* IDE Serial no, SCSI product */
+ char revision[8+1]; /* firmware revision */
+ unsigned long (*block_read)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt,
+ void *buffer);
+ unsigned long (*block_write)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt,
+ const void *buffer);
+ unsigned long (*block_erase)(struct blk_desc *block_dev,
+ lbaint_t start,
+ lbaint_t blkcnt);
+ void *priv; /* driver private struct pointer */
+};
+
+#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
+#define PAD_TO_BLOCKSIZE(size, blk_desc) \
+ (PAD_SIZE(size, blk_desc->blksz))
+
+#endif
diff --git a/include/ide.h b/include/ide.h
index 2407393..a4e65cf 100644
--- a/include/ide.h
+++ b/include/ide.h
@@ -8,6 +8,8 @@
#ifndef _IDE_H
#define _IDE_H
+#include <blk.h>
+
#define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
@@ -26,16 +28,6 @@ extern ulong ide_bus_offset[];
void ide_led(uchar led, uchar status);
#endif /* CONFIG_IDE_LED */
-#ifdef CONFIG_SYS_64BIT_LBA
-typedef uint64_t lbaint_t;
-#define LBAFlength "ll"
-#else
-typedef ulong lbaint_t;
-#define LBAFlength "l"
-#endif
-#define LBAF "%" LBAFlength "x"
-#define LBAFU "%" LBAFlength "u"
-
/*
* Function Prototypes
*/
diff --git a/include/part.h b/include/part.h
index 140c9b6..2599998 100644
--- a/include/part.h
+++ b/include/part.h
@@ -7,61 +7,14 @@
#ifndef _PART_H
#define _PART_H
+#include <blk.h>
#include <ide.h>
-struct blk_desc {
- int if_type; /* type of the interface */
- int dev; /* device number */
- unsigned char part_type; /* partition type */
- unsigned char target; /* target SCSI ID */
- unsigned char lun; /* target LUN */
- unsigned char hwpart; /* HW partition, e.g. for eMMC */
- unsigned char type; /* device type */
- unsigned char removable; /* removable device */
-#ifdef CONFIG_LBA48
- unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
-#endif
- lbaint_t lba; /* number of blocks */
- unsigned long blksz; /* block size */
- int log2blksz; /* for convenience: log2(blksz) */
- char vendor [40+1]; /* IDE model, SCSI Vendor */
- char product[20+1]; /* IDE Serial no, SCSI product */
- char revision[8+1]; /* firmware revision */
- unsigned long (*block_read)(struct blk_desc *block_dev,
- lbaint_t start,
- lbaint_t blkcnt,
- void *buffer);
- unsigned long (*block_write)(struct blk_desc *block_dev,
- lbaint_t start,
- lbaint_t blkcnt,
- const void *buffer);
- unsigned long (*block_erase)(struct blk_desc *block_dev,
- lbaint_t start,
- lbaint_t blkcnt);
- void *priv; /* driver private struct pointer */
-};
-
-#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
-#define PAD_TO_BLOCKSIZE(size, blk_desc) \
- (PAD_SIZE(size, blk_desc->blksz))
#define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
((x & 0xffff0000) ? 16 : 0))
#define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
-/* Interface types: */
-#define IF_TYPE_UNKNOWN 0
-#define IF_TYPE_IDE 1
-#define IF_TYPE_SCSI 2
-#define IF_TYPE_ATAPI 3
-#define IF_TYPE_USB 4
-#define IF_TYPE_DOC 5
-#define IF_TYPE_MMC 6
-#define IF_TYPE_SD 7
-#define IF_TYPE_SATA 8
-#define IF_TYPE_HOST 9
-#define IF_TYPE_MAX 10 /* Max number of IF_TYPE_* supported */
-
/* Part types */
#define PART_TYPE_UNKNOWN 0x00
#define PART_TYPE_MAC 0x01
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 06/32] dm: Add a new header for block devices
2016-02-29 22:25 ` [U-Boot] [PATCH v2 06/32] dm: Add a new header for block devices Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> At present block devices are tied up with partitions. But not all block
> devices have partitions within them. They are in fact separate concepts.
>
> Create a separate blk.h header file for block devices.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
> include/blk.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/ide.h | 12 ++--------
> include/part.h | 49 +---------------------------------------
> 3 files changed, 74 insertions(+), 58 deletions(-)
> create mode 100644 include/blk.h
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 07/32] dm: blk: Convert interface type to an enum
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (4 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 06/32] dm: Add a new header for block devices Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 08/32] dm: blk: Add comments to a few functions Simon Glass
` (26 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Since these are sequentially numbered it makes sense to use an enum. It
avoids having to maintain the maximum value, and provides a type we can use
if it is useful.
In fact the maximum value is not used. Rename it to COUNT, since MAX suggests
it is the maximum valid value, but it is not.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add a missing word 'is' to the commit message
- Rename the enum to 'if_type' instead of 'if_type_t'
include/blk.h | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/include/blk.h b/include/blk.h
index 1e8334c..fd54520 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -19,20 +19,23 @@ typedef ulong lbaint_t;
#define LBAFU "%" LBAFlength "u"
/* Interface types: */
-#define IF_TYPE_UNKNOWN 0
-#define IF_TYPE_IDE 1
-#define IF_TYPE_SCSI 2
-#define IF_TYPE_ATAPI 3
-#define IF_TYPE_USB 4
-#define IF_TYPE_DOC 5
-#define IF_TYPE_MMC 6
-#define IF_TYPE_SD 7
-#define IF_TYPE_SATA 8
-#define IF_TYPE_HOST 9
-#define IF_TYPE_MAX 10 /* Max number of IF_TYPE_* supported */
+enum if_type {
+ IF_TYPE_UNKNOWN = 0,
+ IF_TYPE_IDE,
+ IF_TYPE_SCSI,
+ IF_TYPE_ATAPI,
+ IF_TYPE_USB,
+ IF_TYPE_DOC,
+ IF_TYPE_MMC,
+ IF_TYPE_SD,
+ IF_TYPE_SATA,
+ IF_TYPE_HOST,
+
+ IF_TYPE_COUNT, /* Number of interface types */
+};
struct blk_desc {
- int if_type; /* type of the interface */
+ enum if_type if_type; /* type of the interface */
int dev; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 07/32] dm: blk: Convert interface type to an enum
2016-02-29 22:25 ` [U-Boot] [PATCH v2 07/32] dm: blk: Convert interface type to an enum Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Since these are sequentially numbered it makes sense to use an enum. It
> avoids having to maintain the maximum value, and provides a type we can use
> if it is useful.
>
> In fact the maximum value is not used. Rename it to COUNT, since MAX suggests
> it is the maximum valid value, but it is not.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Add a missing word 'is' to the commit message
> - Rename the enum to 'if_type' instead of 'if_type_t'
>
> include/blk.h | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 08/32] dm: blk: Add comments to a few functions
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (5 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 07/32] dm: blk: Convert interface type to an enum Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 09/32] dm: blk: Rename get_dev() to blk_get_dev() Simon Glass
` (25 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
The block interface is not well documented in the code. Pick two important
functions and add comments.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
include/part.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/include/part.h b/include/part.h
index 2599998..4e70d8d 100644
--- a/include/part.h
+++ b/include/part.h
@@ -53,12 +53,42 @@ typedef struct disk_partition {
/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
+/**
+ * get_dev() - get a pointer to a block device given its type and number
+ *
+ * Each interface allocates its own devices and typically struct blk_desc is
+ * contained with the interface's data structure. There is no global
+ * numbering for block devices, so the interface name must be provided.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev: Device number (0 for first device on that interface, 1 for
+ * second, etc.
+ * @return pointer to the block device, or NULL if not available, or an
+ * error occurred.
+ */
struct blk_desc *get_dev(const char *ifname, int dev);
struct blk_desc *ide_get_dev(int dev);
struct blk_desc *sata_get_dev(int dev);
struct blk_desc *scsi_get_dev(int dev);
struct blk_desc *usb_stor_get_dev(int dev);
struct blk_desc *mmc_get_dev(int dev);
+
+/**
+ * mmc_select_hwpart() - Select the MMC hardware partiion on an MMC device
+ *
+ * MMC devices can support partitioning at the hardware level. This is quite
+ * separate from the normal idea of software-based partitions. MMC hardware
+ * partitions must be explicitly selected. Once selected only the region of
+ * the device covered by that partition is accessible.
+ *
+ * The MMC standard provides for two boot partitions (numbered 1 and 2),
+ * rpmb (3), and up to 4 addition general-purpose partitions (4-7).
+ *
+ * @dev_num: Block device number (struct blk_desc->dev value)
+ * @hwpart: Hardware partition number to select. 0 means the raw device,
+ * 1 is the first partition, 2 is the second, etc.
+ * @return 0 if OK, other value for an error
+ */
int mmc_select_hwpart(int dev_num, int hwpart);
struct blk_desc *systemace_get_dev(int dev);
struct blk_desc *mg_disk_get_dev(int dev);
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 09/32] dm: blk: Rename get_dev() to blk_get_dev()
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (6 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 08/32] dm: blk: Add comments to a few functions Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 10/32] dm: blk: Rename get_device() to blk_get_device_by_str() Simon Glass
` (24 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
The current name is too generic. Add a 'blk_' prefix to aid searching and
make its purpose clearer.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
api/api_storage.c | 12 +++++++-----
cmd/gpt.c | 2 +-
cmd/read.c | 2 +-
common/fb_mmc.c | 4 ++--
disk/part.c | 4 ++--
include/part.h | 6 +++---
6 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/api/api_storage.c b/api/api_storage.c
index 225a6cf..8c30c56 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -106,7 +106,7 @@ static int dev_stor_get(int type, int first, int *more, struct device_info *di)
struct blk_desc *dd;
if (first) {
- di->cookie = (void *)get_dev(specs[type].name, 0);
+ di->cookie = (void *)blk_get_dev(specs[type].name, 0);
if (di->cookie == NULL)
return 0;
else
@@ -119,7 +119,8 @@ static int dev_stor_get(int type, int first, int *more, struct device_info *di)
} else {
for (i = 0; i < specs[type].max_dev; i++)
- if (di->cookie == (void *)get_dev(specs[type].name, i)) {
+ if (di->cookie ==
+ (void *)blk_get_dev(specs[type].name, i)) {
/* previous cookie found -- advance to the
* next device, if possible */
@@ -129,7 +130,8 @@ static int dev_stor_get(int type, int first, int *more, struct device_info *di)
break;
}
- di->cookie = (void *)get_dev(specs[type].name, i);
+ di->cookie = (void *)blk_get_dev(
+ specs[type].name, i);
if (di->cookie == NULL)
return 0;
else
@@ -174,7 +176,7 @@ static int dev_stor_type(struct blk_desc *dd)
for (i = ENUM_IDE; i < ENUM_MAX; i++)
for (j = 0; j < specs[i].max_dev; j++)
- if (dd == get_dev(specs[i].name, j))
+ if (dd == blk_get_dev(specs[i].name, j))
return i;
return ENUM_MAX;
@@ -313,7 +315,7 @@ static int dev_stor_is_valid(int type, struct blk_desc *dd)
int i;
for (i = 0; i < specs[type].max_dev; i++)
- if (dd == get_dev(specs[type].name, i))
+ if (dd == blk_get_dev(specs[type].name, i))
if (dd->type != DEV_TYPE_UNKNOWN)
return 1;
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 881367c..8ffaef3 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -418,7 +418,7 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("'%s' is not a number\n", argv[3]);
return CMD_RET_USAGE;
}
- blk_dev_desc = get_dev(argv[2], dev);
+ blk_dev_desc = blk_get_dev(argv[2], dev);
if (!blk_dev_desc) {
printf("%s: %s dev %d NOT available\n",
__func__, argv[2], dev);
diff --git a/cmd/read.c b/cmd/read.c
index 6a1e1d9..12ac1659 100644
--- a/cmd/read.c
+++ b/cmd/read.c
@@ -39,7 +39,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
part = (int)simple_strtoul(++ep, NULL, 16);
}
- dev_desc = get_dev(argv[1], dev);
+ dev_desc = blk_get_dev(argv[1], dev);
if (dev_desc == NULL) {
printf("Block device %s %d not supported\n", argv[1], dev);
return 1;
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index fd43085..4324f58 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -106,7 +106,7 @@ void fb_mmc_flash_write(const char *cmd, unsigned int session_id,
/* initialize the response buffer */
response_str = response;
- dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+ dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
error("invalid mmc device\n");
fastboot_fail(response_str, "invalid mmc device");
@@ -179,7 +179,7 @@ void fb_mmc_erase(const char *cmd, char *response)
/* initialize the response buffer */
response_str = response;
- dev_desc = get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+ dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
error("invalid mmc device");
fastboot_fail(response_str, "invalid mmc device");
diff --git a/disk/part.c b/disk/part.c
index 7f98d89..2466c3e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -101,7 +101,7 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
return NULL;
}
-struct blk_desc *get_dev(const char *ifname, int dev)
+struct blk_desc *blk_get_dev(const char *ifname, int dev)
{
return get_dev_hwpart(ifname, dev, 0);
}
@@ -111,7 +111,7 @@ struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
return NULL;
}
-struct blk_desc *get_dev(const char *ifname, int dev)
+struct blk_desc *blk_get_dev(const char *ifname, int dev)
{
return NULL;
}
diff --git a/include/part.h b/include/part.h
index 4e70d8d..ddc4422 100644
--- a/include/part.h
+++ b/include/part.h
@@ -54,7 +54,7 @@ typedef struct disk_partition {
/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
/**
- * get_dev() - get a pointer to a block device given its type and number
+ * blk_get_dev() - get a pointer to a block device given its type and number
*
* Each interface allocates its own devices and typically struct blk_desc is
* contained with the interface's data structure. There is no global
@@ -66,7 +66,7 @@ typedef struct disk_partition {
* @return pointer to the block device, or NULL if not available, or an
* error occurred.
*/
-struct blk_desc *get_dev(const char *ifname, int dev);
+struct blk_desc *blk_get_dev(const char *ifname, int dev);
struct blk_desc *ide_get_dev(int dev);
struct blk_desc *sata_get_dev(int dev);
struct blk_desc *scsi_get_dev(int dev);
@@ -107,7 +107,7 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
struct blk_desc **dev_desc,
disk_partition_t *info, int allow_whole_dev);
#else
-static inline struct blk_desc *get_dev(const char *ifname, int dev)
+static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
static inline struct blk_desc *ide_get_dev(int dev) { return NULL; }
static inline struct blk_desc *sata_get_dev(int dev) { return NULL; }
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 09/32] dm: blk: Rename get_dev() to blk_get_dev()
2016-02-29 22:25 ` [U-Boot] [PATCH v2 09/32] dm: blk: Rename get_dev() to blk_get_dev() Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> The current name is too generic. Add a 'blk_' prefix to aid searching and
> make its purpose clearer.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
> api/api_storage.c | 12 +++++++-----
> cmd/gpt.c | 2 +-
> cmd/read.c | 2 +-
> common/fb_mmc.c | 4 ++--
> disk/part.c | 4 ++--
> include/part.h | 6 +++---
> 6 files changed, 16 insertions(+), 14 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 10/32] dm: blk: Rename get_device() to blk_get_device_by_str()
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (7 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 09/32] dm: blk: Rename get_dev() to blk_get_dev() Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 11/32] dm: blk: Rename get_device_and_partition() Simon Glass
` (23 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
The current name is too generic. The function returns a block device based
on a provided string. Rename it to aid searching and make its purpose
clearer. Also add a few comments.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- Rename to blk_get_device_by_str()
cmd/part.c | 6 +++---
cmd/unzip.c | 2 +-
cmd/usb_mass_storage.c | 2 +-
disk/part.c | 6 +++---
include/part.h | 34 ++++++++++++++++++++++++++++++----
test/dm/usb.c | 2 +-
6 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/cmd/part.c b/cmd/part.c
index a572aab..dd32d50 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -81,7 +81,7 @@ static int do_part_list(int argc, char * const argv[])
return CMD_RET_USAGE;
}
- ret = get_device(argv[0], argv[1], &desc);
+ ret = blk_get_device_by_str(argv[0], argv[1], &desc);
if (ret < 0)
return 1;
@@ -128,7 +128,7 @@ static int do_part_start(int argc, char * const argv[])
part = simple_strtoul(argv[2], NULL, 0);
- ret = get_device(argv[0], argv[1], &desc);
+ ret = blk_get_device_by_str(argv[0], argv[1], &desc);
if (ret < 0)
return 1;
@@ -162,7 +162,7 @@ static int do_part_size(int argc, char * const argv[])
part = simple_strtoul(argv[2], NULL, 0);
- ret = get_device(argv[0], argv[1], &desc);
+ ret = blk_get_device_by_str(argv[0], argv[1], &desc);
if (ret < 0)
return 1;
diff --git a/cmd/unzip.c b/cmd/unzip.c
index 5be1566..a8bcb1f 100644
--- a/cmd/unzip.c
+++ b/cmd/unzip.c
@@ -53,7 +53,7 @@ static int do_gzwrite(cmd_tbl_t *cmdtp, int flag,
if (argc < 5)
return CMD_RET_USAGE;
- ret = get_device(argv[1], argv[2], &bdev);
+ ret = blk_get_device_by_str(argv[1], argv[2], &bdev);
if (ret < 0)
return CMD_RET_FAILURE;
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 03b7e21..59bb4ee 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -69,7 +69,7 @@ static int ums_init(const char *devtype, const char *devnums)
if (!devnum)
break;
- ret = get_device(devtype, devnum, &block_dev);
+ ret = blk_get_device_by_str(devtype, devnum, &block_dev);
if (ret < 0)
goto cleanup;
diff --git a/disk/part.c b/disk/part.c
index 2466c3e..2e7adbc 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -449,8 +449,8 @@ int get_partition_info(struct blk_desc *dev_desc, int part,
return -1;
}
-int get_device(const char *ifname, const char *dev_hwpart_str,
- struct blk_desc **dev_desc)
+int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
+ struct blk_desc **dev_desc)
{
char *ep;
char *dup_str = NULL;
@@ -598,7 +598,7 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str,
}
/* Look up the device */
- dev = get_device(ifname, dev_str, dev_desc);
+ dev = blk_get_device_by_str(ifname, dev_str, dev_desc);
if (dev < 0)
goto cleanup;
diff --git a/include/part.h b/include/part.h
index ddc4422..6ca87d0 100644
--- a/include/part.h
+++ b/include/part.h
@@ -101,8 +101,34 @@ int get_partition_info(struct blk_desc *dev_desc, int part,
void print_part(struct blk_desc *dev_desc);
void init_part(struct blk_desc *dev_desc);
void dev_print(struct blk_desc *dev_desc);
-int get_device(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc);
+
+/**
+ * blk_get_device_by_str() - Get a block device given its interface/hw partition
+ *
+ * Each interface allocates its own devices and typically struct blk_desc is
+ * contained with the interface's data structure. There is no global
+ * numbering for block devices, so the interface name must be provided.
+ *
+ * The hardware parition is not related to the normal software partitioning
+ * of a device - each hardware partition is effectively a separately
+ * accessible block device. When a hardware parition is selected on MMC the
+ * other hardware partitions become inaccessible. The same block device is
+ * used to access all hardware partitions, but its capacity may change when a
+ * different hardware partition is selected.
+ *
+ * When a hardware partition number is given, the block device switches to
+ * that hardware partition.
+ *
+ * @ifname: Interface name (e.g. "ide", "scsi")
+ * @dev_str: Device and optional hw partition. This can either be a string
+ * containing the device number (e.g. "2") or the device number
+ * and hardware partition number (e.g. "2.4") for devices that
+ * support it (currently only MMC).
+ * @dev_desc: Returns a pointer to the block device on success
+ * @return block device number (local to the interface), or -1 on error
+ */
+int blk_get_device_by_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,
struct blk_desc **dev_desc,
disk_partition_t *info, int allow_whole_dev);
@@ -124,8 +150,8 @@ static inline int get_partition_info(struct blk_desc *dev_desc, int part,
static inline void print_part(struct blk_desc *dev_desc) {}
static inline void init_part(struct blk_desc *dev_desc) {}
static inline void dev_print(struct blk_desc *dev_desc) {}
-static inline int get_device(const char *ifname, const char *dev_str,
- struct blk_desc **dev_desc)
+static inline int blk_get_device_by_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,
const char *dev_part_str,
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 25cde68..0996185 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -45,7 +45,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
state_set_skip_delays(true);
ut_assertok(usb_init());
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev));
- ut_assertok(get_device("usb", "0", &dev_desc));
+ ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));
/* Read a few blocks and look for the string we expect */
ut_asserteq(512, dev_desc->blksz);
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 10/32] dm: blk: Rename get_device() to blk_get_device_by_str()
2016-02-29 22:25 ` [U-Boot] [PATCH v2 10/32] dm: blk: Rename get_device() to blk_get_device_by_str() Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> The current name is too generic. The function returns a block device based
> on a provided string. Rename it to aid searching and make its purpose
> clearer. Also add a few comments.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2:
> - Rename to blk_get_device_by_str()
>
> cmd/part.c | 6 +++---
> cmd/unzip.c | 2 +-
> cmd/usb_mass_storage.c | 2 +-
> disk/part.c | 6 +++---
> include/part.h | 34 ++++++++++++++++++++++++++++++----
> test/dm/usb.c | 2 +-
> 6 files changed, 39 insertions(+), 13 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 11/32] dm: blk: Rename get_device_and_partition()
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (8 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 10/32] dm: blk: Rename get_device() to blk_get_device_by_str() Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 12/32] dm: part: Add a cast to avoid a compiler warning Simon Glass
` (22 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
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>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- Rename to blk_get_device_by_str()
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 | 42 ++++++++++++++++++++++++++++++++++++++----
10 files changed, 51 insertions(+), 17 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 dd32d50..415b38a 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 2e7adbc..255ee79 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 6ca87d0..6197101 100644
--- a/include/part.h
+++ b/include/part.h
@@ -129,9 +129,43 @@ void dev_print(struct blk_desc *dev_desc);
*/
int blk_get_device_by_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,
- struct blk_desc **dev_desc,
- disk_partition_t *info, int allow_whole_dev);
+
+/**
+ * blk_get_device_part_str() - Get a block device and partition
+ *
+ * This calls blk_get_device_by_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
static inline struct blk_desc *blk_get_dev(const char *ifname, int dev)
{ return NULL; }
@@ -153,7 +187,7 @@ static inline void dev_print(struct blk_desc *dev_desc) {}
static inline int blk_get_device_by_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
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 11/32] dm: blk: Rename get_device_and_partition()
2016-02-29 22:25 ` [U-Boot] [PATCH v2 11/32] dm: blk: Rename get_device_and_partition() Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> 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>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2:
> - Rename to blk_get_device_by_str()
>
> 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 | 42 ++++++++++++++++++++++++++++++++++++++----
> 10 files changed, 51 insertions(+), 17 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 12/32] dm: part: Add a cast to avoid a compiler warning
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (9 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 11/32] dm: blk: Rename get_device_and_partition() Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 13/32] dm: sandbox: Enable all partition types Simon Glass
` (21 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
In part_amiga.c the name is unsigned but bcpl_strcpy() requires a signed
pointer. Add a cast to fix the warning.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- Fix 'by' which should be 'but' in the commit message
disk/part_amiga.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 008941c..5702c95 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -304,7 +304,7 @@ int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
info->start = g->low_cyl * g->block_per_track * g->surfaces;
info->size = (g->high_cyl - g->low_cyl + 1) * g->block_per_track * g->surfaces - 1;
info->blksz = rdb.block_bytes;
- bcpl_strcpy(info->name, p->drive_name);
+ bcpl_strcpy((char *)info->name, p->drive_name);
disk_type = g->dos_type;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 13/32] dm: sandbox: Enable all partition types
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (10 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 12/32] dm: part: Add a cast to avoid a compiler warning Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 14/32] dm: part: Convert partition API use to linker lists Simon Glass
` (20 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
It is useful to have sandbox build as much code as possible to avoid having
to build every board to detect build errors. Also we may add tests for some
more partition types at some point.
Enable all partition types in sandbox.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- Sort the CONFIG_..._PARTITION options in the header file
include/configs/sandbox.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 4bffd8d..786bb11 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -53,8 +53,11 @@
#define CONFIG_CMD_GPT
#define CONFIG_PARTITION_UUIDS
-#define CONFIG_EFI_PARTITION
+#define CONFIG_AMIGA_PARTITION
#define CONFIG_DOS_PARTITION
+#define CONFIG_EFI_PARTITION
+#define CONFIG_ISO_PARTITION
+#define CONFIG_MAC_PARTITION
/*
* Size of malloc() pool, before and after relocation
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 13/32] dm: sandbox: Enable all partition types
2016-02-29 22:25 ` [U-Boot] [PATCH v2 13/32] dm: sandbox: Enable all partition types Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> It is useful to have sandbox build as much code as possible to avoid having
> to build every board to detect build errors. Also we may add tests for some
> more partition types at some point.
>
> Enable all partition types in sandbox.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2:
> - Sort the CONFIG_..._PARTITION options in the header file
>
> include/configs/sandbox.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 14/32] dm: part: Convert partition API use to linker lists
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (11 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 13/32] dm: sandbox: Enable all partition types Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:52 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 15/32] dm: part: Rename some partition functions Simon Glass
` (19 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
We can use linker lists instead of explicitly declaring each function.
This makes the code shorter by avoiding switch() statements and lots of
header file declarations.
While this does clean up the code it introduces a few code issues with SPL.
SPL never needs to print partition information since this all happens from
commands. SPL mostly doesn't need to obtain information about a partition
either, except in a few cases. Add these cases so that the code will be
dropped from each partition driver when not needed. This avoids code bloat.
I think this is still a win, since it is not a bad thing to be explicit
about which features are used in SPL. But others may like to weigh in.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in v2:
- Reorder the linker list so that EFI comes before DOS, and add a comment
disk/part.c | 184 +++++++++++++++++-------------------------------------
disk/part_amiga.c | 16 +++--
disk/part_dos.c | 9 ++-
disk/part_efi.c | 15 ++++-
disk/part_iso.c | 16 +++--
disk/part_mac.c | 16 +++--
include/part.h | 79 ++++++++++++++---------
7 files changed, 162 insertions(+), 173 deletions(-)
diff --git a/disk/part.c b/disk/part.c
index 255ee79..978b85c 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <command.h>
+#include <errno.h>
#include <ide.h>
#include <malloc.h>
#include <part.h>
@@ -58,6 +59,22 @@ static const struct block_drvr block_drvr[] = {
DECLARE_GLOBAL_DATA_PTR;
#ifdef HAVE_BLOCK_DEVICE
+static struct part_driver *part_driver_lookup_type(int part_type)
+{
+ struct part_driver *drv =
+ ll_entry_start(struct part_driver, part_driver);
+ const int n_ents = ll_entry_count(struct part_driver, part_driver);
+ struct part_driver *entry;
+
+ for (entry = drv; entry != drv + n_ents; entry++) {
+ if (part_type == entry->part_type)
+ return entry;
+ }
+
+ /* Not found */
+ return NULL;
+}
+
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
{
const struct block_drvr *drvr = block_drvr;
@@ -252,53 +269,31 @@ void dev_print (struct blk_desc *dev_desc)
void init_part(struct blk_desc *dev_desc)
{
-#ifdef CONFIG_ISO_PARTITION
- if (test_part_iso(dev_desc) == 0) {
- dev_desc->part_type = PART_TYPE_ISO;
- return;
- }
-#endif
+ struct part_driver *drv =
+ ll_entry_start(struct part_driver, part_driver);
+ const int n_ents = ll_entry_count(struct part_driver, part_driver);
+ struct part_driver *entry;
-#ifdef CONFIG_MAC_PARTITION
- if (test_part_mac(dev_desc) == 0) {
- dev_desc->part_type = PART_TYPE_MAC;
- return;
- }
-#endif
-
-/* must be placed before DOS partition detection */
-#ifdef CONFIG_EFI_PARTITION
- if (test_part_efi(dev_desc) == 0) {
- dev_desc->part_type = PART_TYPE_EFI;
- return;
- }
-#endif
-
-#ifdef CONFIG_DOS_PARTITION
- if (test_part_dos(dev_desc) == 0) {
- dev_desc->part_type = PART_TYPE_DOS;
- return;
- }
-#endif
-
-#ifdef CONFIG_AMIGA_PARTITION
- if (test_part_amiga(dev_desc) == 0) {
- dev_desc->part_type = PART_TYPE_AMIGA;
- return;
- }
-#endif
dev_desc->part_type = PART_TYPE_UNKNOWN;
+ for (entry = drv; entry != drv + n_ents; entry++) {
+ int ret;
+
+ ret = entry->test(dev_desc);
+ debug("%s: try '%s': ret=%d\n", __func__, entry->name, ret);
+ if (!ret) {
+ dev_desc->part_type = entry->part_type;
+ break;
+ }
+ }
}
-
+static void print_part_header(const char *type, struct blk_desc *dev_desc)
+{
#if defined(CONFIG_MAC_PARTITION) || \
defined(CONFIG_DOS_PARTITION) || \
defined(CONFIG_ISO_PARTITION) || \
defined(CONFIG_AMIGA_PARTITION) || \
defined(CONFIG_EFI_PARTITION)
-
-static void print_part_header(const char *type, struct blk_desc *dev_desc)
-{
puts ("\nPartition Map for ");
switch (dev_desc->if_type) {
case IF_TYPE_IDE:
@@ -331,54 +326,24 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
}
printf (" device %d -- Partition Type: %s\n\n",
dev_desc->dev, type);
-}
-
#endif /* any CONFIG_..._PARTITION */
+}
void print_part(struct blk_desc *dev_desc)
{
+ struct part_driver *drv;
- switch (dev_desc->part_type) {
-#ifdef CONFIG_MAC_PARTITION
- case PART_TYPE_MAC:
- PRINTF ("## Testing for valid MAC partition ##\n");
- print_part_header ("MAC", dev_desc);
- print_part_mac (dev_desc);
- return;
-#endif
-#ifdef CONFIG_DOS_PARTITION
- case PART_TYPE_DOS:
- PRINTF ("## Testing for valid DOS partition ##\n");
- print_part_header ("DOS", dev_desc);
- print_part_dos (dev_desc);
- return;
-#endif
-
-#ifdef CONFIG_ISO_PARTITION
- case PART_TYPE_ISO:
- PRINTF ("## Testing for valid ISO Boot partition ##\n");
- print_part_header ("ISO", dev_desc);
- print_part_iso (dev_desc);
- return;
-#endif
-
-#ifdef CONFIG_AMIGA_PARTITION
- case PART_TYPE_AMIGA:
- PRINTF ("## Testing for a valid Amiga partition ##\n");
- print_part_header ("AMIGA", dev_desc);
- print_part_amiga (dev_desc);
- return;
-#endif
-
-#ifdef CONFIG_EFI_PARTITION
- case PART_TYPE_EFI:
- PRINTF ("## Testing for valid EFI partition ##\n");
- print_part_header ("EFI", dev_desc);
- print_part_efi (dev_desc);
+ drv = part_driver_lookup_type(dev_desc->part_type);
+ if (!drv) {
+ printf("## Unknown partition table type %x\n",
+ dev_desc->part_type);
return;
-#endif
}
- puts ("## Unknown partition table\n");
+
+ PRINTF("## Testing for valid %s partition ##\n", drv->name);
+ print_part_header(drv->name, dev_desc);
+ if (drv->print)
+ drv->print(dev_desc);
}
#endif /* HAVE_BLOCK_DEVICE */
@@ -387,6 +352,7 @@ int get_partition_info(struct blk_desc *dev_desc, int part,
disk_partition_t *info)
{
#ifdef HAVE_BLOCK_DEVICE
+ struct part_driver *drv;
#ifdef CONFIG_PARTITION_UUIDS
/* The common case is no UUID support */
@@ -396,53 +362,19 @@ int get_partition_info(struct blk_desc *dev_desc, int part,
info->type_guid[0] = 0;
#endif
- switch (dev_desc->part_type) {
-#ifdef CONFIG_MAC_PARTITION
- case PART_TYPE_MAC:
- if (get_partition_info_mac(dev_desc, part, info) == 0) {
- PRINTF("## Valid MAC partition found ##\n");
- return 0;
- }
- break;
-#endif
-
-#ifdef CONFIG_DOS_PARTITION
- case PART_TYPE_DOS:
- if (get_partition_info_dos(dev_desc, part, info) == 0) {
- PRINTF("## Valid DOS partition found ##\n");
- return 0;
- }
- break;
-#endif
-
-#ifdef CONFIG_ISO_PARTITION
- case PART_TYPE_ISO:
- if (get_partition_info_iso(dev_desc, part, info) == 0) {
- PRINTF("## Valid ISO boot partition found ##\n");
- return 0;
- }
- break;
-#endif
-
-#ifdef CONFIG_AMIGA_PARTITION
- case PART_TYPE_AMIGA:
- if (get_partition_info_amiga(dev_desc, part, info) == 0) {
- PRINTF("## Valid Amiga partition found ##\n");
- return 0;
- }
- break;
-#endif
-
-#ifdef CONFIG_EFI_PARTITION
- case PART_TYPE_EFI:
- if (get_partition_info_efi(dev_desc, part, info) == 0) {
- PRINTF("## Valid EFI partition found ##\n");
- return 0;
- }
- break;
-#endif
- default:
- break;
+ drv = part_driver_lookup_type(dev_desc->part_type);
+ if (!drv) {
+ debug("## Unknown partition table type %x\n",
+ dev_desc->part_type);
+ return -EPROTONOSUPPORT;
+ }
+ if (!drv->get_info) {
+ PRINTF("## Driver %s does not have the get_info() method\n");
+ return -ENOSYS;
+ }
+ if (drv->get_info(dev_desc, part, info) == 0) {
+ PRINTF("## Valid %s partition found ##\n", drv->name);
+ return 0;
}
#endif /* HAVE_BLOCK_DEVICE */
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 5702c95..0f569f0 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -207,7 +207,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
* Test if the given partition has an Amiga partition table/Rigid
* Disk block
*/
-int test_part_amiga(struct blk_desc *dev_desc)
+static int test_part_amiga(struct blk_desc *dev_desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *bootcode;
@@ -291,8 +291,8 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
/*
* Get info about a partition
*/
-int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
- disk_partition_t *info)
+static int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info)
{
struct partition_block *p = find_partition(dev_desc, part-1);
struct amiga_part_geometry *g;
@@ -319,7 +319,7 @@ int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
return 0;
}
-void print_part_amiga(struct blk_desc *dev_desc)
+static void print_part_amiga(struct blk_desc *dev_desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *boot;
@@ -379,4 +379,12 @@ void print_part_amiga(struct blk_desc *dev_desc)
}
}
+U_BOOT_PART_TYPE(amiga) = {
+ .name = "AMIGA",
+ .part_type = PART_TYPE_AMIGA,
+ .get_info = get_partition_info_amiga,
+ .print = print_part_amiga,
+ .test = test_part_amiga,
+};
+
#endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index ea0315c..7567ed3 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer)
}
-int test_part_dos(struct blk_desc *dev_desc)
+static int test_part_dos(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
@@ -295,5 +295,12 @@ int get_partition_info_dos(struct blk_desc *dev_desc, int part,
return get_partition_info_extended(dev_desc, 0, 0, 1, part, info, 0);
}
+U_BOOT_PART_TYPE(dos) = {
+ .name = "DOS",
+ .part_type = PART_TYPE_DOS,
+ .get_info = part_get_info_ptr(get_partition_info_dos),
+ .print = part_print_ptr(print_part_dos),
+ .test = test_part_dos,
+};
#endif
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 7bd840f..3471b75 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -319,7 +319,7 @@ int get_partition_info_efi_by_name(struct blk_desc *dev_desc,
return -2;
}
-int test_part_efi(struct blk_desc *dev_desc)
+static int test_part_efi(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
@@ -953,4 +953,17 @@ static int is_pte_valid(gpt_entry * pte)
return 1;
}
}
+
+/*
+ * Add an 'a_' prefix so it comes before 'dos' in the linker list. We need to
+ * check EFI first, since a DOS partition is often used as a 'protective MBR'
+ * with EFI.
+ */
+U_BOOT_PART_TYPE(a_efi) = {
+ .name = "EFI",
+ .part_type = PART_TYPE_EFI,
+ .get_info = part_get_info_ptr(get_partition_info_efi),
+ .print = part_print_ptr(print_part_efi),
+ .test = test_part_efi,
+};
#endif
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 2984df5..1d72d23 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -217,14 +217,13 @@ found:
return 0;
}
-int get_partition_info_iso(struct blk_desc *dev_desc, int part_num,
- disk_partition_t *info)
+static int get_partition_info_iso(struct blk_desc *dev_desc, int part_num,
+ disk_partition_t *info)
{
return(get_partition_info_iso_verb(dev_desc, part_num, info, 1));
}
-
-void print_part_iso(struct blk_desc *dev_desc)
+static void print_part_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
int i;
@@ -241,11 +240,18 @@ void print_part_iso(struct blk_desc *dev_desc)
} while (get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
}
-int test_part_iso(struct blk_desc *dev_desc)
+static int test_part_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
return(get_partition_info_iso_verb(dev_desc,0,&info,0));
}
+U_BOOT_PART_TYPE(iso) = {
+ .name = "ISO",
+ .part_type = PART_TYPE_ISO,
+ .get_info = get_partition_info_iso,
+ .print = print_part_iso,
+ .test = test_part_iso,
+};
#endif
diff --git a/disk/part_mac.c b/disk/part_mac.c
index ae83495..3fb3b16 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -40,7 +40,7 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
/*
* Test for a valid MAC partition
*/
-int test_part_mac(struct blk_desc *dev_desc)
+static int test_part_mac(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
@@ -64,8 +64,7 @@ int test_part_mac(struct blk_desc *dev_desc)
return (0);
}
-
-void print_part_mac(struct blk_desc *dev_desc)
+static void print_part_mac(struct blk_desc *dev_desc)
{
ulong i, n;
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
@@ -214,8 +213,8 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
/* NOTREACHED */
}
-int get_partition_info_mac(struct blk_desc *dev_desc, int part,
- disk_partition_t *info)
+static int get_partition_info_mac(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
@@ -238,4 +237,11 @@ int get_partition_info_mac(struct blk_desc *dev_desc, int part,
return (0);
}
+U_BOOT_PART_TYPE(mac) = {
+ .name = "MAC",
+ .part_type = PART_TYPE_MAC,
+ .get_info = get_partition_info_mac,
+ .print = print_part_mac,
+ .test = test_part_mac,
+};
#endif
diff --git a/include/part.h b/include/part.h
index 6197101..544b056 100644
--- a/include/part.h
+++ b/include/part.h
@@ -195,43 +195,62 @@ static inline int blk_get_device_part_str(const char *ifname,
{ *dev_desc = NULL; return -1; }
#endif
-#ifdef CONFIG_MAC_PARTITION
-/* disk/part_mac.c */
-int get_partition_info_mac(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-void print_part_mac(struct blk_desc *dev_desc);
-int test_part_mac(struct blk_desc *dev_desc);
+/*
+ * We don't support printing partition information in SPL and only support
+ * getting partition information in a few cases.
+ */
+#ifdef CONFIG_SPL_BUILD
+# define part_print_ptr(x) NULL
+# if defined(CONFIG_SPL_EXT_SUPPORT) || \
+ defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+# define part_get_info_ptr(x) x
+# else
+# define part_get_info_ptr(x) NULL
+# endif
+#else
+#define part_print_ptr(x) x
+#define part_get_info_ptr(x) x
#endif
-#ifdef CONFIG_DOS_PARTITION
-/* disk/part_dos.c */
-int get_partition_info_dos(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-void print_part_dos(struct blk_desc *dev_desc);
-int test_part_dos(struct blk_desc *dev_desc);
-#endif
-#ifdef CONFIG_ISO_PARTITION
-/* disk/part_iso.c */
-int get_partition_info_iso(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-void print_part_iso(struct blk_desc *dev_desc);
-int test_part_iso(struct blk_desc *dev_desc);
-#endif
+struct part_driver {
+ const char *name;
+ int part_type;
-#ifdef CONFIG_AMIGA_PARTITION
-/* disk/part_amiga.c */
-int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-void print_part_amiga(struct blk_desc *dev_desc);
-int test_part_amiga(struct blk_desc *dev_desc);
-#endif
+ /**
+ * get_info() - Get information about a partition
+ *
+ * @dev_desc: Block device descriptor
+ * @part: Partition number (1 = first)
+ * @info: Returns partition information
+ */
+ int (*get_info)(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info);
+
+ /**
+ * print() - Print partition information
+ *
+ * @dev_desc: Block device descriptor
+ */
+ void (*print)(struct blk_desc *dev_desc);
+
+ /**
+ * test() - Test if a device contains this partition type
+ *
+ * @dev_desc: Block device descriptor
+ * @return 0 if the block device appears to contain this partition
+ * type, -ve if not
+ */
+ int (*test)(struct blk_desc *dev_desc);
+};
+
+/* Declare a new U-Boot partition 'driver' */
+#define U_BOOT_PART_TYPE(__name) \
+ ll_entry_declare(struct part_driver, __name, part_driver)
#ifdef CONFIG_EFI_PARTITION
#include <part_efi.h>
/* disk/part_efi.c */
-int get_partition_info_efi(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
/**
* get_partition_info_efi_by_name() - Find the specified GPT partition table entry
*
@@ -243,8 +262,6 @@ int get_partition_info_efi(struct blk_desc *dev_desc, int part,
*/
int get_partition_info_efi_by_name(struct blk_desc *dev_desc,
const char *name, disk_partition_t *info);
-void print_part_efi(struct blk_desc *dev_desc);
-int test_part_efi(struct blk_desc *dev_desc);
/**
* write_gpt_table() - Write the GUID Partition Table to disk
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 14/32] dm: part: Convert partition API use to linker lists
2016-02-29 22:25 ` [U-Boot] [PATCH v2 14/32] dm: part: Convert partition API use to linker lists Simon Glass
@ 2016-03-13 1:52 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> We can use linker lists instead of explicitly declaring each function.
> This makes the code shorter by avoiding switch() statements and lots of
> header file declarations.
>
> While this does clean up the code it introduces a few code issues with SPL.
> SPL never needs to print partition information since this all happens from
> commands. SPL mostly doesn't need to obtain information about a partition
> either, except in a few cases. Add these cases so that the code will be
> dropped from each partition driver when not needed. This avoids code bloat.
>
> I think this is still a win, since it is not a bad thing to be explicit
> about which features are used in SPL. But others may like to weigh in.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
>
> Changes in v2:
> - Reorder the linker list so that EFI comes before DOS, and add a comment
>
> disk/part.c | 184 +++++++++++++++++-------------------------------------
> disk/part_amiga.c | 16 +++--
> disk/part_dos.c | 9 ++-
> disk/part_efi.c | 15 ++++-
> disk/part_iso.c | 16 +++--
> disk/part_mac.c | 16 +++--
> include/part.h | 79 ++++++++++++++---------
> 7 files changed, 162 insertions(+), 173 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 15/32] dm: part: Rename some partition functions
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (12 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 14/32] dm: part: Convert partition API use to linker lists Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 16/32] dm: cbfs: Fix handling of invalid type Simon Glass
` (18 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Rename three partition functions so that they start with part_. This makes
it clear what they relate to.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
board/cm5200/fwupdate.c | 2 +-
cmd/ide.c | 6 +++---
cmd/mmc.c | 2 +-
cmd/part.c | 8 ++++----
cmd/read.c | 2 +-
cmd/sata.c | 6 +++---
cmd/scsi.c | 6 +++---
cmd/usb.c | 4 ++--
common/fb_mmc.c | 10 +++++-----
common/spl/spl_ext.c | 6 ++----
common/spl/spl_mmc.c | 2 +-
common/usb_storage.c | 2 +-
disk/part.c | 12 ++++++------
disk/part_amiga.c | 4 ++--
disk/part_dos.c | 19 +++++++++----------
disk/part_efi.c | 10 +++++-----
disk/part_iso.c | 17 +++++++++--------
disk/part_mac.c | 4 ++--
drivers/block/pata_bfin.c | 2 +-
drivers/block/sandbox.c | 2 +-
drivers/block/systemace.c | 2 +-
drivers/dfu/dfu_mmc.c | 2 +-
drivers/mmc/mmc.c | 2 +-
fs/fat/fat.c | 2 +-
include/part.h | 21 ++++++++++-----------
25 files changed, 76 insertions(+), 79 deletions(-)
diff --git a/board/cm5200/fwupdate.c b/board/cm5200/fwupdate.c
index d5064c1..2ed90de 100644
--- a/board/cm5200/fwupdate.c
+++ b/board/cm5200/fwupdate.c
@@ -117,7 +117,7 @@ static int load_rescue_image(ulong addr)
/* Detect partition */
for (partno = -1, i = 0; i < 6; i++) {
- if (get_partition_info(stor_dev, i, &info) == 0) {
+ if (part_get_info(stor_dev, i, &info) == 0) {
if (fat_register_device(stor_dev, i) == 0) {
/* Check if rescue image is present */
FW_DEBUG("Looking for firmware directory '%s'"
diff --git a/cmd/ide.c b/cmd/ide.c
index 06202c5..01b91b5 100644
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -137,7 +137,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
++ok;
if (dev)
putc('\n');
- print_part(&ide_dev_desc[dev]);
+ part_print(&ide_dev_desc[dev]);
}
}
if (!ok) {
@@ -171,7 +171,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
int dev = (int) simple_strtoul(argv[2], NULL, 10);
if (ide_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
- print_part(&ide_dev_desc[dev]);
+ part_print(&ide_dev_desc[dev]);
} else {
printf("\nIDE device %d not available\n",
dev);
@@ -435,7 +435,7 @@ void ide_init(void)
if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
/* initialize partition type */
- init_part(&ide_dev_desc[i]);
+ part_init(&ide_dev_desc[i]);
if (curr_device < 0)
curr_device = i;
}
diff --git a/cmd/mmc.c b/cmd/mmc.c
index ab59e7f..fb4382e 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -433,7 +433,7 @@ static int do_mmc_part(cmd_tbl_t *cmdtp, int flag,
mmc_dev = mmc_get_dev(curr_device);
if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) {
- print_part(mmc_dev);
+ part_print(mmc_dev);
return CMD_RET_SUCCESS;
}
diff --git a/cmd/part.c b/cmd/part.c
index 415b38a..414031e 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -92,7 +92,7 @@ static int do_part_list(int argc, char * const argv[])
for (p = 1; p < 128; p++) {
char t[5];
- int r = get_partition_info(desc, p, &info);
+ int r = part_get_info(desc, p, &info);
if (r != 0)
continue;
@@ -107,7 +107,7 @@ static int do_part_list(int argc, char * const argv[])
return 0;
}
- print_part(desc);
+ part_print(desc);
return 0;
}
@@ -132,7 +132,7 @@ static int do_part_start(int argc, char * const argv[])
if (ret < 0)
return 1;
- err = get_partition_info(desc, part, &info);
+ err = part_get_info(desc, part, &info);
if (err)
return 1;
@@ -166,7 +166,7 @@ static int do_part_size(int argc, char * const argv[])
if (ret < 0)
return 1;
- err = get_partition_info(desc, part, &info);
+ err = part_get_info(desc, part, &info);
if (err)
return 1;
diff --git a/cmd/read.c b/cmd/read.c
index 12ac1659..f8d766a 100644
--- a/cmd/read.c
+++ b/cmd/read.c
@@ -50,7 +50,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
cnt = simple_strtoul(argv[5], NULL, 16);
if (part != 0) {
- if (get_partition_info(dev_desc, part, &part_info)) {
+ if (part_get_info(dev_desc, part, &part_info)) {
printf("Cannot find partition %d\n", part);
return 1;
}
diff --git a/cmd/sata.c b/cmd/sata.c
index a1faf2d..8b1f19c 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -52,7 +52,7 @@ int __sata_initialize(void)
rc = scan_sata(i);
if (!rc && (sata_dev_desc[i].lba > 0) &&
(sata_dev_desc[i].blksz > 0))
- init_part(&sata_dev_desc[i]);
+ part_init(&sata_dev_desc[i]);
}
}
sata_curr_device = 0;
@@ -131,7 +131,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
++ok;
if (dev)
putc ('\n');
- print_part(&sata_dev_desc[dev]);
+ part_print(&sata_dev_desc[dev]);
}
}
if (!ok) {
@@ -164,7 +164,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int dev = (int)simple_strtoul(argv[2], NULL, 10);
if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
- print_part(&sata_dev_desc[dev]);
+ part_print(&sata_dev_desc[dev]);
} else {
printf("\nSATA device %d not available\n", dev);
rc = 1;
diff --git a/cmd/scsi.c b/cmd/scsi.c
index dff811b..de0651c 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -156,7 +156,7 @@ void scsi_scan(int mode)
scsi_dev_desc[scsi_max_devs].log2blksz =
LOG2(scsi_dev_desc[scsi_max_devs].blksz);
scsi_dev_desc[scsi_max_devs].type=perq;
- init_part(&scsi_dev_desc[scsi_max_devs]);
+ part_init(&scsi_dev_desc[scsi_max_devs]);
removable:
if(mode==1) {
printf (" Device %d: ", scsi_max_devs);
@@ -301,7 +301,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (dev)
printf("\n");
debug ("print_part of %x\n",dev);
- print_part(&scsi_dev_desc[dev]);
+ part_print(&scsi_dev_desc[dev]);
}
}
if (!ok)
@@ -329,7 +329,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (strncmp(argv[1],"part",4) == 0) {
int dev = (int)simple_strtoul(argv[2], NULL, 10);
if(scsi_dev_desc[dev].type != DEV_TYPE_UNKNOWN) {
- print_part(&scsi_dev_desc[dev]);
+ part_print(&scsi_dev_desc[dev]);
}
else {
printf ("\nSCSI device %d not available\n", dev);
diff --git a/cmd/usb.c b/cmd/usb.c
index 5f3b06a..53fd6ad 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -727,7 +727,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (devno)
printf("\n");
debug("print_part of %x\n", devno);
- print_part(stor_dev);
+ part_print(stor_dev);
}
}
} else {
@@ -737,7 +737,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
stor_dev->type != DEV_TYPE_UNKNOWN) {
ok++;
debug("print_part of %x\n", devno);
- print_part(stor_dev);
+ part_print(stor_dev);
}
}
if (!ok) {
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 4324f58..d5c9135 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -25,12 +25,12 @@ struct fb_mmc_sparse {
struct blk_desc *dev_desc;
};
-static int get_partition_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
+static int part_get_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
const char *name, disk_partition_t *info)
{
int ret;
- ret = get_partition_info_efi_by_name(dev_desc, name, info);
+ ret = part_get_info_efi_by_name(dev_desc, name, info);
if (ret) {
/* strlen("fastboot_partition_alias_") + 32(part_name) + 1 */
char env_alias_name[25 + 32 + 1];
@@ -41,7 +41,7 @@ static int get_partition_info_efi_by_name_or_alias(struct blk_desc *dev_desc,
strncat(env_alias_name, name, 32);
aliased_part_name = getenv(env_alias_name);
if (aliased_part_name != NULL)
- ret = get_partition_info_efi_by_name(dev_desc,
+ ret = part_get_info_efi_by_name(dev_desc,
aliased_part_name, info);
}
return ret;
@@ -131,7 +131,7 @@ void fb_mmc_flash_write(const char *cmd, unsigned int session_id,
printf("........ success\n");
fastboot_okay(response_str, "");
return;
- } else if (get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info)) {
+ } else if (part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info)) {
error("cannot find partition: '%s'\n", cmd);
fastboot_fail(response_str, "cannot find partition");
return;
@@ -186,7 +186,7 @@ void fb_mmc_erase(const char *cmd, char *response)
return;
}
- ret = get_partition_info_efi_by_name_or_alias(dev_desc, cmd, &info);
+ ret = part_get_info_efi_by_name_or_alias(dev_desc, cmd, &info);
if (ret) {
error("cannot find partition: '%s'", cmd);
fastboot_fail(response_str, "cannot find partition");
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index d29d229..b77dbf4 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -22,8 +22,7 @@ int spl_load_image_ext(struct blk_desc *block_dev,
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
- if (get_partition_info(block_dev,
- partition, &part_info)) {
+ if (part_get_info(block_dev, partition, &part_info)) {
printf("spl: no partition table found\n");
return -1;
}
@@ -71,8 +70,7 @@ int spl_load_image_ext_os(struct blk_desc *block_dev, int partition)
disk_partition_t part_info = {};
__maybe_unused char *file;
- if (get_partition_info(block_dev,
- partition, &part_info)) {
+ if (part_get_info(block_dev, partition, &part_info)) {
printf("spl: no partition table found\n");
return -1;
}
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index c27a250..5204f52 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -122,7 +122,7 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
disk_partition_t info;
int err;
- err = get_partition_info(&mmc->block_dev, partition, &info);
+ err = part_get_info(&mmc->block_dev, partition, &info);
if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: partition error\n");
diff --git a/common/usb_storage.c b/common/usb_storage.c
index ca5aeea..e105a95 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -1374,7 +1374,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
debug(" address %d\n", dev_desc->target);
debug("partype: %d\n", dev_desc->part_type);
- init_part(dev_desc);
+ part_init(dev_desc);
debug("partype: %d\n", dev_desc->part_type);
return 1;
diff --git a/disk/part.c b/disk/part.c
index 978b85c..9a78cce 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -267,7 +267,7 @@ void dev_print (struct blk_desc *dev_desc)
#ifdef HAVE_BLOCK_DEVICE
-void init_part(struct blk_desc *dev_desc)
+void part_init(struct blk_desc *dev_desc)
{
struct part_driver *drv =
ll_entry_start(struct part_driver, part_driver);
@@ -329,7 +329,7 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
#endif /* any CONFIG_..._PARTITION */
}
-void print_part(struct blk_desc *dev_desc)
+void part_print(struct blk_desc *dev_desc)
{
struct part_driver *drv;
@@ -348,7 +348,7 @@ void print_part(struct blk_desc *dev_desc)
#endif /* HAVE_BLOCK_DEVICE */
-int get_partition_info(struct blk_desc *dev_desc, int part,
+int part_get_info(struct blk_desc *dev_desc, int part,
disk_partition_t *info)
{
#ifdef HAVE_BLOCK_DEVICE
@@ -432,7 +432,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
* already loaded.
*/
if(hwpart != 0)
- init_part(*dev_desc);
+ part_init(*dev_desc);
#endif
cleanup:
@@ -607,7 +607,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
* other than "auto", use that partition number directly.
*/
if (part != PART_AUTO) {
- ret = get_partition_info(*dev_desc, part, info);
+ ret = part_get_info(*dev_desc, part, info);
if (ret) {
printf("** Invalid partition %d **\n", part);
goto cleanup;
@@ -619,7 +619,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
*/
part = 0;
for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
- ret = get_partition_info(*dev_desc, p, info);
+ ret = part_get_info(*dev_desc, p, info);
if (ret)
continue;
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 0f569f0..d323b4b 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -291,7 +291,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
/*
* Get info about a partition
*/
-static int get_partition_info_amiga(struct blk_desc *dev_desc, int part,
+static int part_get_info_amiga(struct blk_desc *dev_desc, int part,
disk_partition_t *info)
{
struct partition_block *p = find_partition(dev_desc, part-1);
@@ -382,7 +382,7 @@ static void print_part_amiga(struct blk_desc *dev_desc)
U_BOOT_PART_TYPE(amiga) = {
.name = "AMIGA",
.part_type = PART_TYPE_AMIGA,
- .get_info = get_partition_info_amiga,
+ .get_info = part_get_info_amiga,
.print = print_part_amiga,
.test = test_part_amiga,
};
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 7567ed3..4a56391 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -167,11 +167,10 @@ static void print_partition_extended(struct blk_desc *dev_desc,
/* Print a partition that is relative to its Extended partition table
*/
-static int get_partition_info_extended(struct blk_desc *dev_desc,
- lbaint_t ext_part_sector,
- lbaint_t relative, int part_num,
- int which_part, disk_partition_t *info,
- unsigned int disksig)
+static int part_get_info_extended(struct blk_desc *dev_desc,
+ lbaint_t ext_part_sector, lbaint_t relative,
+ int part_num, int which_part,
+ disk_partition_t *info, unsigned int disksig)
{
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
dos_partition_t *pt;
@@ -259,7 +258,7 @@ static int get_partition_info_extended(struct blk_desc *dev_desc,
lbaint_t lba_start
= le32_to_int (pt->start4) + relative;
- return get_partition_info_extended (dev_desc, lba_start,
+ return part_get_info_extended(dev_desc, lba_start,
ext_part_sector == 0 ? lba_start : relative,
part_num, which_part, info, disksig);
}
@@ -289,16 +288,16 @@ void print_part_dos(struct blk_desc *dev_desc)
print_partition_extended(dev_desc, 0, 0, 1, 0);
}
-int get_partition_info_dos(struct blk_desc *dev_desc, int part,
- disk_partition_t *info)
+int part_get_info_dos(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info)
{
- return get_partition_info_extended(dev_desc, 0, 0, 1, part, info, 0);
+ return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0);
}
U_BOOT_PART_TYPE(dos) = {
.name = "DOS",
.part_type = PART_TYPE_DOS,
- .get_info = part_get_info_ptr(get_partition_info_dos),
+ .get_info = part_get_info_ptr(part_get_info_dos),
.print = part_print_ptr(print_part_dos),
.test = test_part_dos,
};
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 3471b75..209a671 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -237,8 +237,8 @@ void print_part_efi(struct blk_desc *dev_desc)
return;
}
-int get_partition_info_efi(struct blk_desc *dev_desc, int part,
- disk_partition_t *info)
+int part_get_info_efi(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info)
{
ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
gpt_entry *gpt_pte = NULL;
@@ -300,13 +300,13 @@ int get_partition_info_efi(struct blk_desc *dev_desc, int part,
return 0;
}
-int get_partition_info_efi_by_name(struct blk_desc *dev_desc,
+int part_get_info_efi_by_name(struct blk_desc *dev_desc,
const char *name, disk_partition_t *info)
{
int ret;
int i;
for (i = 1; i < GPT_ENTRY_NUMBERS; i++) {
- ret = get_partition_info_efi(dev_desc, i, info);
+ ret = part_get_info_efi(dev_desc, i, info);
if (ret != 0) {
/* no more entries in table */
return -1;
@@ -962,7 +962,7 @@ static int is_pte_valid(gpt_entry * pte)
U_BOOT_PART_TYPE(a_efi) = {
.name = "EFI",
.part_type = PART_TYPE_EFI,
- .get_info = part_get_info_ptr(get_partition_info_efi),
+ .get_info = part_get_info_ptr(part_get_info_efi),
.print = part_print_ptr(print_part_efi),
.test = test_part_efi,
};
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 1d72d23..a1cf358 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -46,8 +46,8 @@ static inline unsigned short le16_to_int(unsigned char *le16)
/* only boot records will be listed as valid partitions */
-int get_partition_info_iso_verb(struct blk_desc *dev_desc, int part_num,
- disk_partition_t *info, int verb)
+int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
+ disk_partition_t *info, int verb)
{
int i,offset,entry_num;
unsigned short *chksumbuf;
@@ -217,17 +217,18 @@ found:
return 0;
}
-static int get_partition_info_iso(struct blk_desc *dev_desc, int part_num,
+static int part_get_info_iso(struct blk_desc *dev_desc, int part_num,
disk_partition_t *info)
{
- return(get_partition_info_iso_verb(dev_desc, part_num, info, 1));
+ return part_get_info_iso_verb(dev_desc, part_num, info, 1);
}
static void print_part_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
int i;
- if(get_partition_info_iso_verb(dev_desc,0,&info,0)==-1) {
+
+ if (part_get_info_iso_verb(dev_desc, 0, &info, 0) == -1) {
printf("** No boot partition found on device %d **\n",dev_desc->dev);
return;
}
@@ -237,20 +238,20 @@ static void print_part_iso(struct blk_desc *dev_desc)
printf(" %2d " LBAFU " " LBAFU " %6ld %.32s\n",
i, info.start, info.size, info.blksz, info.type);
i++;
- } while (get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
+ } while (part_get_info_iso_verb(dev_desc, i, &info, 0) != -1);
}
static int test_part_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
- return(get_partition_info_iso_verb(dev_desc,0,&info,0));
+ return part_get_info_iso_verb(dev_desc, 0, &info, 0);
}
U_BOOT_PART_TYPE(iso) = {
.name = "ISO",
.part_type = PART_TYPE_ISO,
- .get_info = get_partition_info_iso,
+ .get_info = part_get_info_iso,
.print = print_part_iso,
.test = test_part_iso,
};
diff --git a/disk/part_mac.c b/disk/part_mac.c
index 3fb3b16..6192723 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -213,7 +213,7 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
/* NOTREACHED */
}
-static int get_partition_info_mac(struct blk_desc *dev_desc, int part,
+static int part_get_info_mac(struct blk_desc *dev_desc, int part,
disk_partition_t *info)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
@@ -240,7 +240,7 @@ static int get_partition_info_mac(struct blk_desc *dev_desc, int part,
U_BOOT_PART_TYPE(mac) = {
.name = "MAC",
.part_type = PART_TYPE_MAC,
- .get_info = get_partition_info_mac,
+ .get_info = part_get_info_mac,
.print = print_part_mac,
.test = test_part_mac,
};
diff --git a/drivers/block/pata_bfin.c b/drivers/block/pata_bfin.c
index c2673bd..26569d7 100644
--- a/drivers/block/pata_bfin.c
+++ b/drivers/block/pata_bfin.c
@@ -965,7 +965,7 @@ int scan_sata(int dev)
/* Probe device and set xfer mode */
bfin_ata_identify(ap, dev%PATA_DEV_NUM_PER_PORT);
bfin_ata_set_Feature_cmd(ap, dev%PATA_DEV_NUM_PER_PORT);
- init_part(&sata_dev_desc[dev]);
+ part_init(&sata_dev_desc[dev]);
return 0;
}
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index dd21400..093e133 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -98,7 +98,7 @@ int host_dev_bind(int dev, char *filename)
blk_dev->block_write = host_block_write;
blk_dev->dev = dev;
blk_dev->part_type = PART_TYPE_UNKNOWN;
- init_part(blk_dev);
+ part_init(blk_dev);
return 0;
}
diff --git a/drivers/block/systemace.c b/drivers/block/systemace.c
index ea18c0d..b921dcd 100644
--- a/drivers/block/systemace.c
+++ b/drivers/block/systemace.c
@@ -124,7 +124,7 @@ struct blk_desc *systemace_get_dev(int dev)
*/
ace_writew(width == 8 ? 0 : 0x0001, 0);
- init_part(&systemace_dev);
+ part_init(&systemace_dev);
}
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index bfac91a..faece88 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -355,7 +355,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
int mmcdev = second_arg;
int mmcpart = third_arg;
- if (get_partition_info(blk_dev, mmcpart, &partinfo) != 0) {
+ if (part_get_info(blk_dev, mmcpart, &partinfo) != 0) {
error("Couldn't find part #%d on mmc device #%d\n",
mmcpart, mmcdev);
return -ENODEV;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b19b328..94afbb1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1495,7 +1495,7 @@ static int mmc_startup(struct mmc *mmc)
mmc->block_dev.revision[0] = 0;
#endif
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
- init_part(&mmc->block_dev);
+ part_init(&mmc->block_dev);
#endif
return 0;
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 2cef3bd..47f077d 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -97,7 +97,7 @@ int fat_register_device(struct blk_desc *dev_desc, int part_no)
cur_dev = NULL;
/* Read the partition table, if present */
- if (get_partition_info(dev_desc, part_no, &info)) {
+ if (part_get_info(dev_desc, part_no, &info)) {
if (part_no != 0) {
printf("** Partition %d not valid on device %d **\n",
part_no, dev_desc->dev);
diff --git a/include/part.h b/include/part.h
index 544b056..6d8f520 100644
--- a/include/part.h
+++ b/include/part.h
@@ -96,10 +96,9 @@ struct blk_desc *host_get_dev(int dev);
int host_get_dev_err(int dev, struct blk_desc **blk_devp);
/* disk/part.c */
-int get_partition_info(struct blk_desc *dev_desc, int part,
- disk_partition_t *info);
-void print_part(struct blk_desc *dev_desc);
-void init_part(struct blk_desc *dev_desc);
+int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);
+void part_print(struct blk_desc *dev_desc);
+void part_init(struct blk_desc *dev_desc);
void dev_print(struct blk_desc *dev_desc);
/**
@@ -179,10 +178,10 @@ static inline struct blk_desc *systemace_get_dev(int dev) { return NULL; }
static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }
static inline struct blk_desc *host_get_dev(int dev) { return NULL; }
-static inline int get_partition_info(struct blk_desc *dev_desc, int part,
- disk_partition_t *info) { return -1; }
-static inline void print_part(struct blk_desc *dev_desc) {}
-static inline void init_part(struct blk_desc *dev_desc) {}
+static inline int part_get_info(struct blk_desc *dev_desc, int part,
+ disk_partition_t *info) { return -1; }
+static inline void part_print(struct blk_desc *dev_desc) {}
+static inline void part_init(struct blk_desc *dev_desc) {}
static inline void dev_print(struct blk_desc *dev_desc) {}
static inline int blk_get_device_by_str(const char *ifname, const char *dev_str,
struct blk_desc **dev_desc)
@@ -252,7 +251,7 @@ struct part_driver {
#include <part_efi.h>
/* disk/part_efi.c */
/**
- * get_partition_info_efi_by_name() - Find the specified GPT partition table entry
+ * part_get_info_efi_by_name() - Find the specified GPT partition table entry
*
* @param dev_desc - block device descriptor
* @param gpt_name - the specified table entry name
@@ -260,8 +259,8 @@ struct part_driver {
*
* @return - '0' on match, '-1' on no match, otherwise error
*/
-int get_partition_info_efi_by_name(struct blk_desc *dev_desc,
- const char *name, disk_partition_t *info);
+int part_get_info_efi_by_name(struct blk_desc *dev_desc,
+ const char *name, disk_partition_t *info);
/**
* write_gpt_table() - Write the GUID Partition Table to disk
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 15/32] dm: part: Rename some partition functions
2016-02-29 22:25 ` [U-Boot] [PATCH v2 15/32] dm: part: Rename some partition functions Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Rename three partition functions so that they start with part_. This makes
> it clear what they relate to.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
> board/cm5200/fwupdate.c | 2 +-
> cmd/ide.c | 6 +++---
> cmd/mmc.c | 2 +-
> cmd/part.c | 8 ++++----
> cmd/read.c | 2 +-
> cmd/sata.c | 6 +++---
> cmd/scsi.c | 6 +++---
> cmd/usb.c | 4 ++--
> common/fb_mmc.c | 10 +++++-----
> common/spl/spl_ext.c | 6 ++----
> common/spl/spl_mmc.c | 2 +-
> common/usb_storage.c | 2 +-
> disk/part.c | 12 ++++++------
> disk/part_amiga.c | 4 ++--
> disk/part_dos.c | 19 +++++++++----------
> disk/part_efi.c | 10 +++++-----
> disk/part_iso.c | 17 +++++++++--------
> disk/part_mac.c | 4 ++--
> drivers/block/pata_bfin.c | 2 +-
> drivers/block/sandbox.c | 2 +-
> drivers/block/systemace.c | 2 +-
> drivers/dfu/dfu_mmc.c | 2 +-
> drivers/mmc/mmc.c | 2 +-
> fs/fat/fat.c | 2 +-
> include/part.h | 21 ++++++++++-----------
> 25 files changed, 76 insertions(+), 79 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 16/32] dm: cbfs: Fix handling of invalid type
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (13 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 15/32] dm: part: Rename some partition functions Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 17/32] dm: sandbox: Enable cbfs and cramfs Simon Glass
` (17 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
The comment for file_cbfs_type() says that it returns 0 for an invalid type.
The code appears to check for -1, except that it uses an unsigned variable
to store the type. This results in a warning on 64-bit machines.
Adjust it to make the meaning clearer. Continue to handle the -1 case since
it may be needed.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Bring the 'case 0' from a later patch into this one
cmd/cbfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 35d8a7a..779e9c0 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -103,7 +103,7 @@ int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
printf(" size type name\n");
printf("------------------------------------------\n");
while (file) {
- u32 type = file_cbfs_type(file);
+ int type = file_cbfs_type(file);
char *type_name = NULL;
const char *filename = file_cbfs_name(file);
@@ -140,7 +140,8 @@ int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
case CBFS_COMPONENT_CMOS_LAYOUT:
type_name = "cmos layout";
break;
- case -1UL:
+ case -1:
+ case 0:
type_name = "null";
break;
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 16/32] dm: cbfs: Fix handling of invalid type
2016-02-29 22:25 ` [U-Boot] [PATCH v2 16/32] dm: cbfs: Fix handling of invalid type Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> The comment for file_cbfs_type() says that it returns 0 for an invalid type.
> The code appears to check for -1, except that it uses an unsigned variable
> to store the type. This results in a warning on 64-bit machines.
>
> Adjust it to make the meaning clearer. Continue to handle the -1 case since
> it may be needed.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Bring the 'case 0' from a later patch into this one
>
> cmd/cbfs.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 17/32] dm: sandbox: Enable cbfs and cramfs
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (14 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 16/32] dm: cbfs: Fix handling of invalid type Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 18/32] dm: block: Rename device number member dev to devnum Simon Glass
` (16 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Enable these two filesystems to provide better build coverage in sandbox.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
include/configs/sandbox.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 786bb11..f73d040 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -44,6 +44,9 @@
#define CONFIG_CMD_FAT
#define CONFIG_CMD_EXT4
#define CONFIG_CMD_EXT4_WRITE
+#define CONFIG_CMD_CBFS
+#define CONFIG_CMD_CRAMFS
+#define CONFIG_CRAMFS_CMDLINE
#define CONFIG_CMD_PART
#define CONFIG_DOS_PARTITION
#define CONFIG_HOST_MAX_DEVICES 4
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 18/32] dm: block: Rename device number member dev to devnum
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (15 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 17/32] dm: sandbox: Enable cbfs and cramfs Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 19/32] dm: block: Adjust device calls to go through helpers function Simon Glass
` (15 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
This is a device number, and we want to use 'dev' to mean a driver model
device. Rename the member.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- Fix rebase error in cmd/cbfs.c
board/sunxi/board.c | 4 ++--
cmd/disk.c | 2 +-
cmd/fat.c | 4 ++--
cmd/ide.c | 12 ++++++------
cmd/mmc_spi.c | 4 ++--
cmd/reiser.c | 4 ++--
cmd/sata.c | 6 +++---
cmd/scsi.c | 6 +++---
cmd/usb_mass_storage.c | 2 +-
cmd/zfs.c | 2 +-
common/env_fat.c | 4 ++--
common/fb_mmc.c | 4 ++--
common/usb_storage.c | 6 +++---
disk/part.c | 8 ++------
disk/part_dos.c | 29 +++++++++++++++++------------
disk/part_efi.c | 4 ++--
disk/part_iso.c | 39 ++++++++++++++++++++-------------------
disk/part_mac.c | 22 +++++++++++-----------
drivers/block/sandbox.c | 6 +++---
drivers/block/systemace.c | 2 +-
drivers/mmc/arm_pl180_mmci.c | 2 +-
drivers/mmc/mmc.c | 8 ++++----
drivers/mmc/mmc_write.c | 4 ++--
drivers/mmc/mxsmmc.c | 24 ++++++++++++------------
drivers/mmc/omap_hsmmc.c | 4 ++--
drivers/mmc/sdhci.c | 2 +-
fs/fat/fat.c | 4 ++--
include/blk.h | 2 +-
28 files changed, 111 insertions(+), 109 deletions(-)
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 15b7af6..80eae9c 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -337,8 +337,8 @@ int board_mmc_init(bd_t *bis)
if (!sunxi_mmc_has_egon_boot_signature(mmc0) &&
sunxi_mmc_has_egon_boot_signature(mmc1)) {
/* Booting from emmc / mmc2, swap */
- mmc0->block_dev.dev = 1;
- mmc1->block_dev.dev = 0;
+ mmc0->block_dev.devnum = 1;
+ mmc1->block_dev.devnum = 0;
}
#endif
diff --git a/cmd/disk.c b/cmd/disk.c
index 0883c79..27ed115 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -45,7 +45,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
return 1;
}
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
bootstage_mark(BOOTSTAGE_ID_IDE_TYPE);
printf("\nLoading from %s device %d, partition %d: "
diff --git a/cmd/fat.c b/cmd/fat.c
index 18a1be9..4e20746 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -81,7 +81,7 @@ static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
if (part < 0)
return 1;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, &info) != 0) {
printf("\n** Unable to use %s %d:%d for fatinfo **\n",
argv[1], dev, part);
@@ -118,7 +118,7 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
if (part < 0)
return 1;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, &info) != 0) {
printf("\n** Unable to use %s %d:%d for fatwrite **\n",
diff --git a/cmd/ide.c b/cmd/ide.c
index 01b91b5..dfd5548 100644
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -418,7 +418,7 @@ void ide_init(void)
int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
ide_dev_desc[i].if_type = IF_TYPE_IDE;
- ide_dev_desc[i].dev = i;
+ ide_dev_desc[i].devnum = i;
ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
ide_dev_desc[i].blksz = 0;
ide_dev_desc[i].log2blksz =
@@ -551,7 +551,7 @@ static void ide_ident(struct blk_desc *dev_desc)
#endif
int device;
- device = dev_desc->dev;
+ device = dev_desc->devnum;
printf(" Device %d: ", device);
ide_led(DEVICE_LED(device), 1); /* LED on */
@@ -716,7 +716,7 @@ static void ide_ident(struct blk_desc *dev_desc)
ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
ulong n = 0;
unsigned char c;
unsigned char pwrsave = 0; /* power save */
@@ -842,7 +842,7 @@ IDE_READ_E:
ulong ide_write(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
const void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
ulong n = 0;
unsigned char c;
@@ -1308,7 +1308,7 @@ static void atapi_inquiry(struct blk_desc *dev_desc)
unsigned char c;
int device;
- device = dev_desc->dev;
+ device = dev_desc->devnum;
dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */
dev_desc->block_read = atapi_read;
@@ -1397,7 +1397,7 @@ static void atapi_inquiry(struct blk_desc *dev_desc)
ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
ulong n = 0;
unsigned char ccb[12]; /* Command descriptor block */
ulong cnt;
diff --git a/cmd/mmc_spi.c b/cmd/mmc_spi.c
index a2138b8..0c44d06 100644
--- a/cmd/mmc_spi.c
+++ b/cmd/mmc_spi.c
@@ -72,8 +72,8 @@ static int do_mmc_spi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("Failed to create MMC Device\n");
return 1;
}
- printf("%s: %d at %u:%u hz %u mode %u\n", mmc->cfg->name, mmc->block_dev.dev,
- bus, cs, speed, mode);
+ printf("%s: %d at %u:%u hz %u mode %u\n", mmc->cfg->name,
+ mmc->block_dev.devnum, bus, cs, speed, mode);
mmc_init(mmc);
return 0;
diff --git a/cmd/reiser.c b/cmd/reiser.c
index a717956..cbdad36 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -48,7 +48,7 @@ int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
filename = argv[3];
}
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
reiserfs_set_blk_dev(dev_desc, &info);
@@ -126,7 +126,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (part < 0)
return 1;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
printf("Loading file \"%s\" from %s device %d%c%c\n",
filename, argv[1], dev,
diff --git a/cmd/sata.c b/cmd/sata.c
index 8b1f19c..c8de9a3 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -21,13 +21,13 @@ struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
static unsigned long sata_bread(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, void *dst)
{
- return sata_read(block_dev->dev, start, blkcnt, dst);
+ return sata_read(block_dev->devnum, start, blkcnt, dst);
}
static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, const void *buffer)
{
- return sata_write(block_dev->dev, start, blkcnt, buffer);
+ return sata_write(block_dev->devnum, start, blkcnt, buffer);
}
int __sata_initialize(void)
@@ -38,7 +38,7 @@ int __sata_initialize(void)
for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc));
sata_dev_desc[i].if_type = IF_TYPE_SATA;
- sata_dev_desc[i].dev = i;
+ sata_dev_desc[i].devnum = i;
sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
sata_dev_desc[i].type = DEV_TYPE_HARDDISK;
sata_dev_desc[i].lba = 0;
diff --git a/cmd/scsi.c b/cmd/scsi.c
index de0651c..951d1e5 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -99,7 +99,7 @@ void scsi_scan(int mode)
scsi_dev_desc[i].revision[0]=0;
scsi_dev_desc[i].removable = false;
scsi_dev_desc[i].if_type=IF_TYPE_SCSI;
- scsi_dev_desc[i].dev=i;
+ scsi_dev_desc[i].devnum = i;
scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
scsi_dev_desc[i].block_read=scsi_read;
scsi_dev_desc[i].block_write = scsi_write;
@@ -379,7 +379,7 @@ int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks = 0;
@@ -446,7 +446,7 @@ static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr,
static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks;
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index 59bb4ee..14eed98 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -100,7 +100,7 @@ static int ums_init(const char *devtype, const char *devnums)
ums[ums_count].block_dev = *block_dev;
printf("UMS: LUN %d, dev %d, hwpart %d, sector %#x, count %#x\n",
- ums_count, ums[ums_count].block_dev.dev,
+ ums_count, ums[ums_count].block_dev.devnum,
ums[ums_count].block_dev.hwpart,
ums[ums_count].start_sector,
ums[ums_count].num_sectors);
diff --git a/cmd/zfs.c b/cmd/zfs.c
index bb61afd..93067a9 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -84,7 +84,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
if (part < 0)
return 1;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
printf("Loading file \"%s\" from %s device %d%c%c\n",
filename, argv[1], dev,
part ? ':' : ' ', part ? part + '0' : ' ');
diff --git a/common/env_fat.c b/common/env_fat.c
index 2f22710..75616d4 100644
--- a/common/env_fat.c
+++ b/common/env_fat.c
@@ -54,7 +54,7 @@ int saveenv(void)
if (part < 0)
return 1;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, &info) != 0) {
printf("\n** Unable to use %s %d:%d for saveenv **\n",
FAT_ENV_INTERFACE, dev, part);
@@ -88,7 +88,7 @@ void env_relocate_spec(void)
if (part < 0)
goto err_env_relocate;
- dev = dev_desc->dev;
+ dev = dev_desc->devnum;
if (fat_set_blk_dev(dev_desc, &info) != 0) {
printf("\n** Unable to use %s %d:%d for loading the env **\n",
FAT_ENV_INTERFACE, dev, part);
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index d5c9135..da7949f 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -86,7 +86,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
blks = dev_desc->block_write(dev_desc, info->start, blkcnt, buffer);
if (blks != blkcnt) {
- error("failed writing to device %d\n", dev_desc->dev);
+ error("failed writing to device %d\n", dev_desc->devnum);
fastboot_fail(response_str, "failed writing to device");
return;
}
@@ -207,7 +207,7 @@ void fb_mmc_erase(const char *cmd, char *response)
blks = dev_desc->block_erase(dev_desc, blks_start, blks_size);
if (blks != blks_size) {
- error("failed erasing from device %d", dev_desc->dev);
+ error("failed erasing from device %d", dev_desc->devnum);
fastboot_fail(response_str, "failed erasing from device");
return;
}
diff --git a/common/usb_storage.c b/common/usb_storage.c
index e105a95..60531e2 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -192,7 +192,7 @@ static int usb_stor_probe_device(struct usb_device *dev)
blkdev = &usb_dev_desc[usb_max_devs];
memset(blkdev, '\0', sizeof(struct blk_desc));
blkdev->if_type = IF_TYPE_USB;
- blkdev->dev = usb_max_devs;
+ blkdev->devnum = usb_max_devs;
blkdev->part_type = PART_TYPE_UNKNOWN;
blkdev->target = 0xff;
blkdev->type = DEV_TYPE_UNKNOWN;
@@ -1029,7 +1029,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks;
@@ -1100,7 +1100,7 @@ retry_it:
static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer)
{
- int device = block_dev->dev;
+ int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks;
diff --git a/disk/part.c b/disk/part.c
index 9a78cce..2a46050 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -108,7 +108,7 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
return dev_desc;
if (!select_hwpart)
return NULL;
- ret = select_hwpart(dev_desc->dev, hwpart);
+ ret = select_hwpart(dev_desc->devnum, hwpart);
if (ret < 0)
return NULL;
return dev_desc;
@@ -325,7 +325,7 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
break;
}
printf (" device %d -- Partition Type: %s\n\n",
- dev_desc->dev, type);
+ dev_desc->devnum, type);
#endif /* any CONFIG_..._PARTITION */
}
@@ -457,10 +457,6 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
int part;
disk_partition_t tmpinfo;
-#if defined CONFIG_SANDBOX && defined CONFIG_CMD_UBIFS
-#error Only one of CONFIG_SANDBOX and CONFIG_CMD_UBIFS may be selected
-#endif
-
#ifdef CONFIG_SANDBOX
/*
* Special-case a pseudo block device "hostfs", to allow access to the
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 4a56391..5f8d949 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -114,7 +114,7 @@ static void print_partition_extended(struct blk_desc *dev_desc,
if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
(ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
- dev_desc->dev, ext_part_sector);
+ dev_desc->devnum, ext_part_sector);
return;
}
i=test_block_type(buffer);
@@ -180,7 +180,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
(ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
- dev_desc->dev, ext_part_sector);
+ dev_desc->devnum, ext_part_sector);
return -1;
}
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
@@ -215,24 +215,29 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
case IF_TYPE_IDE:
case IF_TYPE_SATA:
case IF_TYPE_ATAPI:
- sprintf ((char *)info->name, "hd%c%d",
- 'a' + dev_desc->dev, part_num);
+ sprintf((char *)info->name, "hd%c%d",
+ 'a' + dev_desc->devnum,
+ part_num);
break;
case IF_TYPE_SCSI:
- sprintf ((char *)info->name, "sd%c%d",
- 'a' + dev_desc->dev, part_num);
+ sprintf((char *)info->name, "sd%c%d",
+ 'a' + dev_desc->devnum,
+ part_num);
break;
case IF_TYPE_USB:
- sprintf ((char *)info->name, "usbd%c%d",
- 'a' + dev_desc->dev, part_num);
+ sprintf((char *)info->name, "usbd%c%d",
+ 'a' + dev_desc->devnum,
+ part_num);
break;
case IF_TYPE_DOC:
- sprintf ((char *)info->name, "docd%c%d",
- 'a' + dev_desc->dev, part_num);
+ sprintf((char *)info->name, "docd%c%d",
+ 'a' + dev_desc->devnum,
+ part_num);
break;
default:
- sprintf ((char *)info->name, "xx%c%d",
- 'a' + dev_desc->dev, part_num);
+ sprintf((char *)info->name, "xx%c%d",
+ 'a' + dev_desc->devnum,
+ part_num);
break;
}
/* sprintf(info->type, "%d, pt->sys_ind); */
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 209a671..ae8cd7e 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -356,7 +356,7 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
/* Write MBR sector to the MMC device */
if (dev_desc->block_write(dev_desc, 0, 1, p_mbr) != 1) {
printf("** Can't write to device %d **\n",
- dev_desc->dev);
+ dev_desc->devnum);
return -1;
}
@@ -410,7 +410,7 @@ int write_gpt_table(struct blk_desc *dev_desc,
return 0;
err:
- printf("** Can't write to device %d **\n", dev_desc->dev);
+ printf("** Can't write to device %d **\n", dev_desc->devnum);
return -1;
}
diff --git a/disk/part_iso.c b/disk/part_iso.c
index a1cf358..c78ae21 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -68,13 +68,13 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if(ppr->desctype!=0x01) {
if(verb)
printf ("** First descriptor is NOT a primary desc on %d:%d **\n",
- dev_desc->dev, part_num);
+ dev_desc->devnum, part_num);
return (-1);
}
if(strncmp((char *)ppr->stand_ident,"CD001",5)!=0) {
if(verb)
printf ("** Wrong ISO Ident: %s on %d:%d **\n",
- ppr->stand_ident,dev_desc->dev, part_num);
+ ppr->stand_ident, dev_desc->devnum, part_num);
return (-1);
}
lastsect= ((ppr->firstsek_LEpathtab1_LE & 0x000000ff)<<24) +
@@ -92,7 +92,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if(ppr->desctype==0xff) {
if(verb)
printf ("** No valid boot catalog found on %d:%d **\n",
- dev_desc->dev, part_num);
+ dev_desc->devnum, part_num);
return (-1);
}
}
@@ -100,7 +100,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if(strncmp(pbr->ident_str,"EL TORITO SPECIFICATION",23)!=0) {
if(verb)
printf ("** Wrong El Torito ident: %s on %d:%d **\n",
- pbr->ident_str,dev_desc->dev, part_num);
+ pbr->ident_str, dev_desc->devnum, part_num);
return (-1);
}
bootaddr=le32_to_int(pbr->pointer);
@@ -108,7 +108,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
if (dev_desc->block_read(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
if(verb)
printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
- bootaddr,dev_desc->dev, part_num);
+ bootaddr, dev_desc->devnum, part_num);
return (-1);
}
chksum=0;
@@ -117,21 +117,21 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
chksum+=((chksumbuf[i] &0xff)<<8)+((chksumbuf[i] &0xff00)>>8);
if(chksum!=0) {
if(verb)
- printf ("** Checksum Error in booting catalog validation entry on %d:%d **\n",
- dev_desc->dev, part_num);
+ printf("** Checksum Error in booting catalog validation entry on %d:%d **\n",
+ dev_desc->devnum, part_num);
return (-1);
}
if((pve->key[0]!=0x55)||(pve->key[1]!=0xAA)) {
if(verb)
printf ("** Key 0x55 0xAA error on %d:%d **\n",
- dev_desc->dev, part_num);
+ dev_desc->devnum, part_num);
return(-1);
}
#ifdef CHECK_FOR_POWERPC_PLATTFORM
if(pve->platform!=0x01) {
if(verb)
printf ("** No PowerPC platform CD on %d:%d **\n",
- dev_desc->dev, part_num);
+ dev_desc->devnum, part_num);
return(-1);
}
#endif
@@ -144,23 +144,23 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
case IF_TYPE_SATA:
case IF_TYPE_ATAPI:
sprintf ((char *)info->name, "hd%c%d",
- 'a' + dev_desc->dev, part_num);
+ 'a' + dev_desc->devnum, part_num);
break;
case IF_TYPE_SCSI:
sprintf ((char *)info->name, "sd%c%d",
- 'a' + dev_desc->dev, part_num);
+ 'a' + dev_desc->devnum, part_num);
break;
case IF_TYPE_USB:
sprintf ((char *)info->name, "usbd%c%d",
- 'a' + dev_desc->dev, part_num);
+ 'a' + dev_desc->devnum, part_num);
break;
case IF_TYPE_DOC:
sprintf ((char *)info->name, "docd%c%d",
- 'a' + dev_desc->dev, part_num);
+ 'a' + dev_desc->devnum, part_num);
break;
default:
sprintf ((char *)info->name, "xx%c%d",
- 'a' + dev_desc->dev, part_num);
+ 'a' + dev_desc->devnum, part_num);
break;
}
/* the bootcatalog (including validation Entry) is limited to 2048Bytes
@@ -184,7 +184,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
else {
if(verb)
printf ("** Partition %d not found on device %d **\n",
- part_num,dev_desc->dev);
+ part_num, dev_desc->devnum);
return(-1);
}
}
@@ -192,13 +192,13 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
* searched w/o succsess */
if(verb)
printf ("** Partition %d not found on device %d **\n",
- part_num,dev_desc->dev);
+ part_num, dev_desc->devnum);
return(-1);
found:
if(pide->boot_ind!=0x88) {
if(verb)
- printf ("** Partition %d is not bootable on device %d **\n",
- part_num,dev_desc->dev);
+ printf("** Partition %d is not bootable on device %d **\n",
+ part_num, dev_desc->devnum);
return (-1);
}
switch(pide->boot_media) {
@@ -229,7 +229,8 @@ static void print_part_iso(struct blk_desc *dev_desc)
int i;
if (part_get_info_iso_verb(dev_desc, 0, &info, 0) == -1) {
- printf("** No boot partition found on device %d **\n",dev_desc->dev);
+ printf("** No boot partition found on device %d **\n",
+ dev_desc->devnum);
return;
}
printf("Part Start Sect x Size Type\n");
diff --git a/disk/part_mac.c b/disk/part_mac.c
index 6192723..07bbc19 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -108,14 +108,14 @@ static void print_part_mac(struct blk_desc *dev_desc)
printf ("%4ld: ", i);
if (dev_desc->block_read(dev_desc, i, 1, (ulong *)mpart) != 1) {
printf ("** Can't read Partition Map on %d:%ld **\n",
- dev_desc->dev, i);
+ dev_desc->devnum, i);
return;
}
if (mpart->signature != MAC_PARTITION_MAGIC) {
- printf ("** Bad Signature on %d:%ld - "
- "expected 0x%04x, got 0x%04x\n",
- dev_desc->dev, i, MAC_PARTITION_MAGIC, mpart->signature);
+ printf("** Bad Signature on %d:%ld - expected 0x%04x, got 0x%04x\n",
+ dev_desc->devnum, i, MAC_PARTITION_MAGIC,
+ mpart->signature);
return;
}
@@ -184,14 +184,14 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
*/
if (dev_desc->block_read(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
printf ("** Can't read Partition Map on %d:%d **\n",
- dev_desc->dev, n);
+ dev_desc->devnum, n);
return (-1);
}
if (pdb_p->signature != MAC_PARTITION_MAGIC) {
- printf ("** Bad Signature on %d:%d: "
- "expected 0x%04x, got 0x%04x\n",
- dev_desc->dev, n, MAC_PARTITION_MAGIC, pdb_p->signature);
+ printf("** Bad Signature on %d:%d: expected 0x%04x, got 0x%04x\n",
+ dev_desc->devnum, n, MAC_PARTITION_MAGIC,
+ pdb_p->signature);
return (-1);
}
@@ -200,9 +200,9 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
if ((part < 1) || (part > pdb_p->map_count)) {
printf ("** Invalid partition %d:%d [%d:1...%d:%d only]\n",
- dev_desc->dev, part,
- dev_desc->dev,
- dev_desc->dev, pdb_p->map_count);
+ dev_desc->devnum, part,
+ dev_desc->devnum,
+ dev_desc->devnum, pdb_p->map_count);
return (-1);
}
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 093e133..14d3e38 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -26,7 +26,7 @@ static unsigned long host_block_read(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
void *buffer)
{
- int dev = block_dev->dev;
+ int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
if (!host_dev)
@@ -48,7 +48,7 @@ static unsigned long host_block_write(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
const void *buffer)
{
- int dev = block_dev->dev;
+ int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
if (os_lseek(host_dev->fd,
start * host_dev->blk_dev.blksz,
@@ -96,7 +96,7 @@ int host_dev_bind(int dev, char *filename)
blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
blk_dev->block_read = host_block_read;
blk_dev->block_write = host_block_write;
- blk_dev->dev = dev;
+ blk_dev->devnum = dev;
blk_dev->part_type = PART_TYPE_UNKNOWN;
part_init(blk_dev);
diff --git a/drivers/block/systemace.c b/drivers/block/systemace.c
index b921dcd..09fe834 100644
--- a/drivers/block/systemace.c
+++ b/drivers/block/systemace.c
@@ -111,7 +111,7 @@ struct blk_desc *systemace_get_dev(int dev)
not yet initialized. In that case, fill it in. */
if (systemace_dev.blksz == 0) {
systemace_dev.if_type = IF_TYPE_UNKNOWN;
- systemace_dev.dev = 0;
+ systemace_dev.devnum = 0;
systemace_dev.part_type = PART_TYPE_UNKNOWN;
systemace_dev.type = DEV_TYPE_HARDDISK;
systemace_dev.blksz = 512;
diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index 5ef7ff7..8f2694f 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -375,7 +375,7 @@ int arm_pl180_mmci_init(struct pl180_mmc_host *host)
if (mmc == NULL)
return -1;
- debug("registered mmc interface number is:%d\n", mmc->block_dev.dev);
+ debug("registered mmc interface number is:%d\n", mmc->block_dev.devnum);
return 0;
}
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 94afbb1..8b2e606 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -182,7 +182,7 @@ struct mmc *find_mmc_device(int dev_num)
list_for_each(entry, &mmc_devices) {
m = list_entry(entry, struct mmc, link);
- if (m->block_dev.dev == dev_num)
+ if (m->block_dev.devnum == dev_num)
return m;
}
@@ -237,7 +237,7 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt, void *dst)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
int err;
lbaint_t cur, blocks_todo = blkcnt;
@@ -1556,7 +1556,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
mmc->dsr = 0xffffffff;
/* Setup the universal parts of the block interface just once */
mmc->block_dev.if_type = IF_TYPE_MMC;
- mmc->block_dev.dev = cur_dev_num++;
+ mmc->block_dev.devnum = cur_dev_num++;
mmc->block_dev.removable = 1;
mmc->block_dev.block_read = mmc_bread;
mmc->block_dev.block_write = mmc_bwrite;
@@ -1728,7 +1728,7 @@ void print_mmc_devices(char separator)
else
mmc_type = NULL;
- printf("%s: %d", m->cfg->name, m->block_dev.dev);
+ printf("%s: %d", m->cfg->name, m->block_dev.devnum);
if (mmc_type)
printf(" (%s)", mmc_type);
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index 54e60db..7b186f8 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -68,7 +68,7 @@ err_out:
unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
lbaint_t blkcnt)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
int err = 0;
u32 start_rem, blkcnt_rem;
struct mmc *mmc = find_mmc_device(dev_num);
@@ -174,7 +174,7 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t start,
ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
const void *src)
{
- int dev_num = block_dev->dev;
+ int dev_num = block_dev->devnum;
lbaint_t cur, blocks_todo = blkcnt;
int err;
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index 31fb3ab..9fa87d5 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -142,7 +142,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
uint32_t ctrl0;
int ret;
- debug("MMC%d: CMD%d\n", mmc->block_dev.dev, cmd->cmdidx);
+ debug("MMC%d: CMD%d\n", mmc->block_dev.devnum, cmd->cmdidx);
/* Check bus busy */
timeout = MXSMMC_MAX_TIMEOUT;
@@ -157,13 +157,13 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
}
if (!timeout) {
- printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.dev);
+ printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.devnum);
return TIMEOUT;
}
/* See if card is present */
if (!mxsmmc_cd(priv)) {
- printf("MMC%d: No card detected!\n", mmc->block_dev.dev);
+ printf("MMC%d: No card detected!\n", mmc->block_dev.devnum);
return NO_CARD_ERR;
}
@@ -200,9 +200,9 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (data->flags & MMC_DATA_READ) {
ctrl0 |= SSP_CTRL0_READ;
} else if (priv->mmc_is_wp &&
- priv->mmc_is_wp(mmc->block_dev.dev)) {
+ priv->mmc_is_wp(mmc->block_dev.devnum)) {
printf("MMC%d: Can not write a locked card!\n",
- mmc->block_dev.dev);
+ mmc->block_dev.devnum);
return UNUSABLE_ERR;
}
@@ -243,21 +243,21 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (!timeout) {
printf("MMC%d: Command %d busy\n",
- mmc->block_dev.dev, cmd->cmdidx);
+ mmc->block_dev.devnum, cmd->cmdidx);
return TIMEOUT;
}
/* Check command timeout */
if (reg & SSP_STATUS_RESP_TIMEOUT) {
printf("MMC%d: Command %d timeout (status 0x%08x)\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return TIMEOUT;
}
/* Check command errors */
if (reg & (SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR)) {
printf("MMC%d: Command %d error (status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return COMM_ERR;
}
@@ -279,14 +279,14 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
if (ret) {
printf("MMC%d: Data timeout with command %d "
"(status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return ret;
}
} else {
ret = mxsmmc_send_cmd_dma(priv, data);
if (ret) {
printf("MMC%d: DMA transfer failed\n",
- mmc->block_dev.dev);
+ mmc->block_dev.devnum);
return ret;
}
}
@@ -297,7 +297,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
(SSP_STATUS_TIMEOUT | SSP_STATUS_DATA_CRC_ERR |
SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW)) {
printf("MMC%d: Data error with command %d (status 0x%08x)!\n",
- mmc->block_dev.dev, cmd->cmdidx, reg);
+ mmc->block_dev.devnum, cmd->cmdidx, reg);
return COMM_ERR;
}
@@ -330,7 +330,7 @@ static void mxsmmc_set_ios(struct mmc *mmc)
SSP_CTRL0_BUS_WIDTH_MASK, priv->buswidth);
debug("MMC%d: Set %d bits bus width\n",
- mmc->block_dev.dev, mmc->bus_width);
+ mmc->block_dev.devnum, mmc->bus_width);
}
static int mxsmmc_init(struct mmc *mmc)
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index 5038a9f..5f2db3b 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -177,11 +177,11 @@ static unsigned char mmc_board_init(struct mmc *mmc)
#if defined(CONFIG_OMAP44XX) && defined(CONFIG_TWL6030_POWER)
/* PBIAS config needed for MMC1 only */
- if (mmc->block_dev.dev == 0)
+ if (mmc->block_dev.devnum == 0)
omap4_vmmc_pbias_config(mmc);
#endif
#if defined(CONFIG_OMAP54XX) && defined(CONFIG_PALMAS_POWER)
- if (mmc->block_dev.dev == 0)
+ if (mmc->block_dev.devnum == 0)
omap5_pbias_config(mmc);
#endif
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 8586d89..ef7e615 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -137,7 +137,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
int trans_bytes = 0, is_aligned = 1;
u32 mask, flags, mode;
unsigned int time = 0, start_addr = 0;
- int mmc_dev = mmc->block_dev.dev;
+ int mmc_dev = mmc->block_dev.devnum;
unsigned start = get_timer(0);
/* Timeout unit - ms */
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 47f077d..f87ddd7 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -100,7 +100,7 @@ int fat_register_device(struct blk_desc *dev_desc, int part_no)
if (part_get_info(dev_desc, part_no, &info)) {
if (part_no != 0) {
printf("** Partition %d not valid on device %d **\n",
- part_no, dev_desc->dev);
+ part_no, dev_desc->devnum);
return -1;
}
@@ -1284,7 +1284,7 @@ int file_fat_detectfs(void)
printf("Unknown");
}
- printf("\n Device %d: ", cur_dev->dev);
+ printf("\n Device %d: ", cur_dev->devnum);
dev_print(cur_dev);
#endif
diff --git a/include/blk.h b/include/blk.h
index fd54520..9c54842 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -36,7 +36,7 @@ enum if_type {
struct blk_desc {
enum if_type if_type; /* type of the interface */
- int dev; /* device number */
+ int devnum; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
unsigned char lun; /* target LUN */
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 18/32] dm: block: Rename device number member dev to devnum
2016-02-29 22:25 ` [U-Boot] [PATCH v2 18/32] dm: block: Rename device number member dev to devnum Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> This is a device number, and we want to use 'dev' to mean a driver model
> device. Rename the member.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2:
> - Fix rebase error in cmd/cbfs.c
>
> board/sunxi/board.c | 4 ++--
> cmd/disk.c | 2 +-
> cmd/fat.c | 4 ++--
> cmd/ide.c | 12 ++++++------
> cmd/mmc_spi.c | 4 ++--
> cmd/reiser.c | 4 ++--
> cmd/sata.c | 6 +++---
> cmd/scsi.c | 6 +++---
> cmd/usb_mass_storage.c | 2 +-
> cmd/zfs.c | 2 +-
> common/env_fat.c | 4 ++--
> common/fb_mmc.c | 4 ++--
> common/usb_storage.c | 6 +++---
> disk/part.c | 8 ++------
> disk/part_dos.c | 29 +++++++++++++++++------------
> disk/part_efi.c | 4 ++--
> disk/part_iso.c | 39 ++++++++++++++++++++-------------------
> disk/part_mac.c | 22 +++++++++++-----------
> drivers/block/sandbox.c | 6 +++---
> drivers/block/systemace.c | 2 +-
> drivers/mmc/arm_pl180_mmci.c | 2 +-
> drivers/mmc/mmc.c | 8 ++++----
> drivers/mmc/mmc_write.c | 4 ++--
> drivers/mmc/mxsmmc.c | 24 ++++++++++++------------
> drivers/mmc/omap_hsmmc.c | 4 ++--
> drivers/mmc/sdhci.c | 2 +-
> fs/fat/fat.c | 4 ++--
> include/blk.h | 2 +-
> 28 files changed, 111 insertions(+), 109 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 19/32] dm: block: Adjust device calls to go through helpers function
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (16 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 18/32] dm: block: Rename device number member dev to devnum Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 20/32] dm: usb: Avoid exceeding available array size for storage devices Simon Glass
` (14 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
To ease conversion to driver model, add helper functions which deal with
calling each block device method. With driver model we can reimplement these
functions with the same arguments.
Use inline functions to avoid increasing code size on some boards.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
cmd/disk.c | 6 +++---
cmd/ide.c | 4 ++--
cmd/read.c | 2 +-
cmd/usb.c | 6 ++----
common/fb_mmc.c | 5 +++--
disk/part_amiga.c | 9 ++++-----
disk/part_dos.c | 8 +++-----
disk/part_efi.c | 34 +++++++++++++++-------------------
disk/part_iso.c | 6 +++---
disk/part_mac.c | 9 ++++-----
fs/ext4/dev.c | 23 ++++++++++-------------
fs/ext4/ext4_common.c | 27 +++++++++------------------
fs/fat/fat.c | 6 +++---
fs/fat/fat_write.c | 5 ++---
include/blk.h | 29 +++++++++++++++++++++++++++++
test/dm/usb.c | 2 +-
16 files changed, 94 insertions(+), 87 deletions(-)
diff --git a/cmd/disk.c b/cmd/disk.c
index 27ed115..e0219f8 100644
--- a/cmd/disk.c
+++ b/cmd/disk.c
@@ -56,7 +56,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
", Block Size: %ld\n",
info.start, info.size, info.blksz);
- if (dev_desc->block_read(dev_desc, info.start, 1, (ulong *)addr) != 1) {
+ if (blk_dread(dev_desc, info.start, 1, (ulong *)addr) != 1) {
printf("** Read error on %d:%d\n", dev, part);
bootstage_error(BOOTSTAGE_ID_IDE_PART_READ);
return 1;
@@ -100,8 +100,8 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
cnt /= info.blksz;
cnt -= 1;
- if (dev_desc->block_read(dev_desc, info.start + 1, cnt,
- (ulong *)(addr + info.blksz)) != cnt) {
+ if (blk_dread(dev_desc, info.start + 1, cnt,
+ (ulong *)(addr + info.blksz)) != cnt) {
printf("** Read error on %d:%d\n", dev, part);
bootstage_error(BOOTSTAGE_ID_IDE_READ);
return 1;
diff --git a/cmd/ide.c b/cmd/ide.c
index dfd5548..c4c08c8 100644
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <blk.h>
#include <config.h>
#include <watchdog.h>
#include <command.h>
@@ -203,8 +204,7 @@ int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
#endif
dev_desc = &ide_dev_desc[curr_device];
- n = dev_desc->block_read(dev_desc, blk, cnt,
- (ulong *)addr);
+ n = blk_dread(dev_desc, blk, cnt, (ulong *)addr);
/* flush cache after read */
flush_cache(addr,
cnt * ide_dev_desc[curr_device].blksz);
diff --git a/cmd/read.c b/cmd/read.c
index f8d766a..61d8ce7 100644
--- a/cmd/read.c
+++ b/cmd/read.c
@@ -66,7 +66,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
- if (dev_desc->block_read(dev_desc, offset + blk, cnt, addr) < 0) {
+ if (blk_read(dev_desc, offset + blk, cnt, addr) < 0) {
printf("Error reading blocks\n");
return 1;
}
diff --git a/cmd/usb.c b/cmd/usb.c
index 53fd6ad..9ed5dc6 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -759,8 +759,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("\nUSB read: device %d block # %ld, count %ld"
" ... ", usb_stor_curr_dev, blk, cnt);
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
- n = stor_dev->block_read(stor_dev, blk, cnt,
- (ulong *)addr);
+ n = blk_dread(stor_dev, blk, cnt, (ulong *)addr);
printf("%ld blocks read: %s\n", n,
(n == cnt) ? "OK" : "ERROR");
if (n == cnt)
@@ -781,8 +780,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("\nUSB write: device %d block # %ld, count %ld"
" ... ", usb_stor_curr_dev, blk, cnt);
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
- n = stor_dev->block_write(stor_dev, blk, cnt,
- (ulong *)addr);
+ n = blk_dwrite(stor_dev, blk, cnt, (ulong *)addr);
printf("%ld blocks write: %s\n", n,
(n == cnt) ? "OK" : "ERROR");
if (n == cnt)
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index da7949f..e3abcc8 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -6,6 +6,7 @@
#include <config.h>
#include <common.h>
+#include <blk.h>
#include <errno.h>
#include <fastboot.h>
#include <fb_mmc.h>
@@ -58,7 +59,7 @@ static int fb_mmc_sparse_write(struct sparse_storage *storage,
struct blk_desc *dev_desc = sparse->dev_desc;
int ret;
- ret = dev_desc->block_write(dev_desc, offset, size, data);
+ ret = blk_dwrite(dev_desc, offset, size, data);
if (!ret)
return -EIO;
@@ -84,7 +85,7 @@ static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
puts("Flashing Raw Image\n");
- blks = dev_desc->block_write(dev_desc, info->start, blkcnt, buffer);
+ blks = blk_dwrite(dev_desc, info->start, blkcnt, buffer);
if (blks != blkcnt) {
error("failed writing to device %d\n", dev_desc->devnum);
fastboot_fail(response_str, "failed writing to device");
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index d323b4b..4a67689 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -140,7 +140,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
for (i=0; i<limit; i++)
{
- ulong res = dev_desc->block_read(dev_desc, i, 1, (ulong *)block_buffer);
+ ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer);
if (res == 1)
{
struct rigid_disk_block *trdb = (struct rigid_disk_block *)block_buffer;
@@ -182,7 +182,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
for (i = 0; i < limit; i++)
{
- ulong res = dev_desc->block_read(dev_desc, i, 1, (ulong *)block_buffer);
+ ulong res = blk_dread(dev_desc, i, 1, (ulong *)block_buffer);
if (res == 1)
{
struct bootcode_block *boot = (struct bootcode_block *)block_buffer;
@@ -258,8 +258,7 @@ static struct partition_block *find_partition(struct blk_desc *dev_desc,
while (block != 0xFFFFFFFF)
{
- ulong res = dev_desc->block_read(dev_desc, block, 1,
- (ulong *)block_buffer);
+ ulong res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer);
if (res == 1)
{
p = (struct partition_block *)block_buffer;
@@ -355,7 +354,7 @@ static void print_part_amiga(struct blk_desc *dev_desc)
PRINTF("Trying to load block #0x%X\n", block);
- res = dev_desc->block_read(dev_desc, block, 1, (ulong *)block_buffer);
+ res = blk_dread(dev_desc, block, 1, (ulong *)block_buffer);
if (res == 1)
{
p = (struct partition_block *)block_buffer;
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 5f8d949..0ed1374 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -91,7 +91,7 @@ static int test_part_dos(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
- if (dev_desc->block_read(dev_desc, 0, 1, (ulong *)buffer) != 1)
+ if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1)
return -1;
if (test_block_type(buffer) != DOS_MBR)
@@ -111,8 +111,7 @@ static void print_partition_extended(struct blk_desc *dev_desc,
dos_partition_t *pt;
int i;
- if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
- (ulong *)buffer) != 1) {
+ if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
dev_desc->devnum, ext_part_sector);
return;
@@ -177,8 +176,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
int i;
int dos_type;
- if (dev_desc->block_read(dev_desc, ext_part_sector, 1,
- (ulong *)buffer) != 1) {
+ if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) {
printf ("** Can't read partition table on %d:" LBAFU " **\n",
dev_desc->devnum, ext_part_sector);
return -1;
diff --git a/disk/part_efi.c b/disk/part_efi.c
index ae8cd7e..b20907b 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -324,7 +324,7 @@ static int test_part_efi(struct blk_desc *dev_desc)
ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
/* Read legacy MBR from block 0 and validate it */
- if ((dev_desc->block_read(dev_desc, 0, 1, (ulong *)legacymbr) != 1)
+ if ((blk_dread(dev_desc, 0, 1, (ulong *)legacymbr) != 1)
|| (is_pmbr_valid(legacymbr) != 1)) {
return -1;
}
@@ -354,7 +354,7 @@ static int set_protective_mbr(struct blk_desc *dev_desc)
p_mbr->partition_record[0].nr_sects = (u32) dev_desc->lba - 1;
/* Write MBR sector to the MMC device */
- if (dev_desc->block_write(dev_desc, 0, 1, p_mbr) != 1) {
+ if (blk_dwrite(dev_desc, 0, 1, p_mbr) != 1) {
printf("** Can't write to device %d **\n",
dev_desc->devnum);
return -1;
@@ -386,24 +386,21 @@ int write_gpt_table(struct blk_desc *dev_desc,
gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
/* Write the First GPT to the block right after the Legacy MBR */
- if (dev_desc->block_write(dev_desc, 1, 1, gpt_h) != 1)
+ if (blk_dwrite(dev_desc, 1, 1, gpt_h) != 1)
goto err;
- if (dev_desc->block_write(dev_desc, 2, pte_blk_cnt, gpt_e)
+ if (blk_dwrite(dev_desc, 2, pte_blk_cnt, gpt_e)
!= pte_blk_cnt)
goto err;
prepare_backup_gpt_header(gpt_h);
- if (dev_desc->block_write(dev_desc,
- (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
- + 1,
- pte_blk_cnt, gpt_e) != pte_blk_cnt)
+ if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->last_usable_lba)
+ + 1, pte_blk_cnt, gpt_e) != pte_blk_cnt)
goto err;
- if (dev_desc->block_write(dev_desc,
- (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
- gpt_h) != 1)
+ if (blk_dwrite(dev_desc, (lbaint_t)le64_to_cpu(gpt_h->my_lba), 1,
+ gpt_h) != 1)
goto err;
debug("GPT successfully written to block device!\n");
@@ -739,7 +736,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
/* write MBR */
lba = 0; /* MBR is always at 0 */
cnt = 1; /* MBR (1 block) */
- if (dev_desc->block_write(dev_desc, lba, cnt, buf) != cnt) {
+ if (blk_dwrite(dev_desc, lba, cnt, buf) != cnt) {
printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
__func__, "MBR", cnt, lba);
return 1;
@@ -748,7 +745,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
/* write Primary GPT */
lba = GPT_PRIMARY_PARTITION_TABLE_LBA;
cnt = 1; /* GPT Header (1 block) */
- if (dev_desc->block_write(dev_desc, lba, cnt, gpt_h) != cnt) {
+ if (blk_dwrite(dev_desc, lba, cnt, gpt_h) != cnt) {
printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
__func__, "Primary GPT Header", cnt, lba);
return 1;
@@ -756,7 +753,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
lba = le64_to_cpu(gpt_h->partition_entry_lba);
cnt = gpt_e_blk_cnt;
- if (dev_desc->block_write(dev_desc, lba, cnt, gpt_e) != cnt) {
+ if (blk_dwrite(dev_desc, lba, cnt, gpt_e) != cnt) {
printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
__func__, "Primary GPT Entries", cnt, lba);
return 1;
@@ -767,7 +764,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
/* write Backup GPT */
lba = le64_to_cpu(gpt_h->partition_entry_lba);
cnt = gpt_e_blk_cnt;
- if (dev_desc->block_write(dev_desc, lba, cnt, gpt_e) != cnt) {
+ if (blk_dwrite(dev_desc, lba, cnt, gpt_e) != cnt) {
printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
__func__, "Backup GPT Entries", cnt, lba);
return 1;
@@ -775,7 +772,7 @@ int write_mbr_and_gpt_partitions(struct blk_desc *dev_desc, void *buf)
lba = le64_to_cpu(gpt_h->my_lba);
cnt = 1; /* GPT Header (1 block) */
- if (dev_desc->block_write(dev_desc, lba, cnt, gpt_h) != cnt) {
+ if (blk_dwrite(dev_desc, lba, cnt, gpt_h) != cnt) {
printf("%s: failed writing '%s' (%d blks at 0x" LBAF ")\n",
__func__, "Backup GPT Header", cnt, lba);
return 1;
@@ -845,7 +842,7 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
}
/* Read GPT Header from device */
- if (dev_desc->block_read(dev_desc, (lbaint_t)lba, 1, pgpt_head) != 1) {
+ if (blk_dread(dev_desc, (lbaint_t)lba, 1, pgpt_head) != 1) {
printf("*** ERROR: Can't read GPT header ***\n");
return 0;
}
@@ -913,8 +910,7 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *dev_desc,
/* Read GPT Entries from device */
blk = le64_to_cpu(pgpt_head->partition_entry_lba);
blk_cnt = BLOCK_CNT(count, dev_desc);
- if (dev_desc->block_read(dev_desc, blk, (lbaint_t)blk_cnt, pte)
- != blk_cnt) {
+ if (blk_dread(dev_desc, blk, (lbaint_t)blk_cnt, pte) != blk_cnt) {
printf("*** ERROR: Can't read GPT Entries ***\n");
free(pte);
return NULL;
diff --git a/disk/part_iso.c b/disk/part_iso.c
index c78ae21..76eab39 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -63,7 +63,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
/* the first sector (sector 0x10) must be a primary volume desc */
blkaddr=PVD_OFFSET;
- if (dev_desc->block_read(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
+ if (blk_dread(dev_desc, PVD_OFFSET, 1, (ulong *)tmpbuf) != 1)
return -1;
if(ppr->desctype!=0x01) {
if(verb)
@@ -85,7 +85,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
PRINTF(" Lastsect:%08lx\n",lastsect);
for(i=blkaddr;i<lastsect;i++) {
PRINTF("Reading block %d\n", i);
- if (dev_desc->block_read(dev_desc, i, 1, (ulong *)tmpbuf) != 1)
+ if (blk_dread(dev_desc, i, 1, (ulong *)tmpbuf) != 1)
return -1;
if(ppr->desctype==0x00)
break; /* boot entry found */
@@ -105,7 +105,7 @@ int part_get_info_iso_verb(struct blk_desc *dev_desc, int part_num,
}
bootaddr=le32_to_int(pbr->pointer);
PRINTF(" Boot Entry at: %08lX\n",bootaddr);
- if (dev_desc->block_read(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
+ if (blk_dread(dev_desc, bootaddr, 1, (ulong *)tmpbuf) != 1) {
if(verb)
printf ("** Can't read Boot Entry at %lX on %d:%d **\n",
bootaddr, dev_desc->devnum, part_num);
diff --git a/disk/part_mac.c b/disk/part_mac.c
index 07bbc19..ce57b57 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -53,8 +53,7 @@ static int test_part_mac(struct blk_desc *dev_desc)
n = 1; /* assuming at least one partition */
for (i=1; i<=n; ++i) {
- if ((dev_desc->block_read(dev_desc, i, 1,
- (ulong *)mpart) != 1) ||
+ if ((blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) ||
(mpart->signature != MAC_PARTITION_MAGIC) ) {
return (-1);
}
@@ -106,7 +105,7 @@ static void print_part_mac(struct blk_desc *dev_desc)
char c;
printf ("%4ld: ", i);
- if (dev_desc->block_read(dev_desc, i, 1, (ulong *)mpart) != 1) {
+ if (blk_dread(dev_desc, i, 1, (ulong *)mpart) != 1) {
printf ("** Can't read Partition Map on %d:%ld **\n",
dev_desc->devnum, i);
return;
@@ -153,7 +152,7 @@ static void print_part_mac(struct blk_desc *dev_desc)
static int part_mac_read_ddb(struct blk_desc *dev_desc,
mac_driver_desc_t *ddb_p)
{
- if (dev_desc->block_read(dev_desc, 0, 1, (ulong *)ddb_p) != 1) {
+ if (blk_dread(dev_desc, 0, 1, (ulong *)ddb_p) != 1) {
printf ("** Can't read Driver Desriptor Block **\n");
return (-1);
}
@@ -182,7 +181,7 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
* partition 1 first since this is the only way to
* know how many partitions we have.
*/
- if (dev_desc->block_read(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
+ if (blk_dread(dev_desc, n, 1, (ulong *)pdb_p) != 1) {
printf ("** Can't read Partition Map on %d:%d **\n",
dev_desc->devnum, n);
return (-1);
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c
index 3eef66f..ee84d3f 100644
--- a/fs/ext4/dev.c
+++ b/fs/ext4/dev.c
@@ -24,6 +24,7 @@
*/
#include <common.h>
+#include <blk.h>
#include <config.h>
#include <memalign.h>
#include <ext4fs.h>
@@ -76,9 +77,8 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
if (byte_offset != 0) {
int readlen;
/* read first part which isn't aligned with start of sector */
- if (ext4fs_blk_desc->block_read(ext4fs_blk_desc,
- part_info->start + sector,
- 1, (void *)sec_buf) != 1) {
+ if (blk_dread(ext4fs_blk_desc, part_info->start + sector, 1,
+ (void *)sec_buf) != 1) {
printf(" ** ext2fs_devread() read error **\n");
return 0;
}
@@ -100,17 +100,15 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
ALLOC_CACHE_ALIGN_BUFFER(u8, p, ext4fs_blk_desc->blksz);
block_len = ext4fs_blk_desc->blksz;
- ext4fs_blk_desc->block_read(ext4fs_blk_desc,
- part_info->start + sector,
- 1, (void *)p);
+ blk_dread(ext4fs_blk_desc, part_info->start + sector, 1,
+ (void *)p);
memcpy(buf, p, byte_len);
return 1;
}
- if (ext4fs_blk_desc->block_read(ext4fs_blk_desc,
- part_info->start + sector,
- block_len >> log2blksz, (void *)buf)
- != block_len >> log2blksz) {
+ if (blk_dread(ext4fs_blk_desc, part_info->start + sector,
+ block_len >> log2blksz, (void *)buf) !=
+ block_len >> log2blksz) {
printf(" ** %s read error - block\n", __func__);
return 0;
}
@@ -121,9 +119,8 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
if (byte_len != 0) {
/* read rest of data which are not in whole sector */
- if (ext4fs_blk_desc->block_read(ext4fs_blk_desc,
- part_info->start + sector,
- 1, (void *)sec_buf) != 1) {
+ if (blk_dread(ext4fs_blk_desc, part_info->start + sector, 1,
+ (void *)sec_buf) != 1) {
printf("* %s read error - last part\n", __func__);
return 0;
}
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index 294a46e..84fba76 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -81,29 +81,20 @@ void put_ext4(uint64_t off, void *buf, uint32_t size)
}
if (remainder) {
- if (fs->dev_desc->block_read) {
- fs->dev_desc->block_read(fs->dev_desc,
- startblock, 1, sec_buf);
- temp_ptr = sec_buf;
- memcpy((temp_ptr + remainder),
- (unsigned char *)buf, size);
- fs->dev_desc->block_write(fs->dev_desc,
- startblock, 1, sec_buf);
- }
+ blk_dread(fs->dev_desc, startblock, 1, sec_buf);
+ temp_ptr = sec_buf;
+ memcpy((temp_ptr + remainder), (unsigned char *)buf, size);
+ blk_dwrite(fs->dev_desc, startblock, 1, sec_buf);
} else {
if (size >> log2blksz != 0) {
- fs->dev_desc->block_write(fs->dev_desc,
- startblock,
- size >> log2blksz,
- (unsigned long *)buf);
+ blk_dwrite(fs->dev_desc, startblock, size >> log2blksz,
+ (unsigned long *)buf);
} else {
- fs->dev_desc->block_read(fs->dev_desc,
- startblock, 1, sec_buf);
+ blk_dread(fs->dev_desc, startblock, 1, sec_buf);
temp_ptr = sec_buf;
memcpy(temp_ptr, buf, size);
- fs->dev_desc->block_write(fs->dev_desc,
- startblock, 1,
- (unsigned long *)sec_buf);
+ blk_dwrite(fs->dev_desc, startblock, 1,
+ (unsigned long *)sec_buf);
}
}
}
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index f87ddd7..600a90e 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <blk.h>
#include <config.h>
#include <exports.h>
#include <fat.h>
@@ -48,11 +49,10 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
{
ulong ret;
- if (!cur_dev || !cur_dev->block_read)
+ if (!cur_dev)
return -1;
- ret = cur_dev->block_read(cur_dev, cur_part_info.start + block,
- nr_blocks, buf);
+ ret = blk_dread(cur_dev, cur_part_info.start + block, nr_blocks, buf);
if (nr_blocks && ret == 0)
return -1;
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 5ed324c..baa85ec 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -32,7 +32,7 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
{
ulong ret;
- if (!cur_dev || !cur_dev->block_write)
+ if (!cur_dev)
return -1;
if (cur_part_info.start + block + nr_blocks >
@@ -41,8 +41,7 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
return -1;
}
- ret = cur_dev->block_write(cur_dev, cur_part_info.start + block,
- nr_blocks, buf);
+ ret = blk_dwrite(cur_dev, cur_part_info.start + block, nr_blocks, buf);
if (nr_blocks && ret == 0)
return -1;
diff --git a/include/blk.h b/include/blk.h
index 9c54842..7b2e5e2 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -71,4 +71,33 @@ struct blk_desc {
#define PAD_TO_BLOCKSIZE(size, blk_desc) \
(PAD_SIZE(size, blk_desc->blksz))
+/*
+ * These functions should take struct udevice instead of struct blk_desc,
+ * but this is convenient for migration to driver model. Add a 'd' prefix
+ * to the function operations, so that blk_read(), etc. can be reserved for
+ * functions with the correct arguments.
+ */
+static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ /*
+ * We could check if block_read is NULL and return -ENOSYS. But this
+ * bloats the code slightly (cause some board to fail to build), and
+ * it would be an error to try an operation that does not exist.
+ */
+ return block_dev->block_read(block_dev, start, blkcnt, buffer);
+}
+
+static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ return block_dev->block_write(block_dev, start, blkcnt, buffer);
+}
+
+static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ return block_dev->block_erase(block_dev, start, blkcnt);
+}
+
#endif
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 0996185..2d20354 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -50,7 +50,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
/* Read a few blocks and look for the string we expect */
ut_asserteq(512, dev_desc->blksz);
memset(cmp, '\0', sizeof(cmp));
- ut_asserteq(2, dev_desc->block_read(dev_desc, 0, 2, cmp));
+ ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
ut_assertok(strcmp(cmp, "this is a test"));
return 0;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 19/32] dm: block: Adjust device calls to go through helpers function
2016-02-29 22:25 ` [U-Boot] [PATCH v2 19/32] dm: block: Adjust device calls to go through helpers function Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> To ease conversion to driver model, add helper functions which deal with
> calling each block device method. With driver model we can reimplement these
> functions with the same arguments.
>
> Use inline functions to avoid increasing code size on some boards.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
> cmd/disk.c | 6 +++---
> cmd/ide.c | 4 ++--
> cmd/read.c | 2 +-
> cmd/usb.c | 6 ++----
> common/fb_mmc.c | 5 +++--
> disk/part_amiga.c | 9 ++++-----
> disk/part_dos.c | 8 +++-----
> disk/part_efi.c | 34 +++++++++++++++-------------------
> disk/part_iso.c | 6 +++---
> disk/part_mac.c | 9 ++++-----
> fs/ext4/dev.c | 23 ++++++++++-------------
> fs/ext4/ext4_common.c | 27 +++++++++------------------
> fs/fat/fat.c | 6 +++---
> fs/fat/fat_write.c | 5 ++---
> include/blk.h | 29 +++++++++++++++++++++++++++++
> test/dm/usb.c | 2 +-
> 16 files changed, 94 insertions(+), 87 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 20/32] dm: usb: Avoid exceeding available array size for storage devices
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (17 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 19/32] dm: block: Adjust device calls to go through helpers function Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-02-29 23:00 ` Marek Vasut
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 21/32] dm: usb: Tidy up storage code ready for driver model conversion Simon Glass
` (13 subsequent siblings)
32 siblings, 2 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
The limit on storage devices is USB_MAX_STOR_DEV but we use one extra
element while probing to see if a device is a storage device. Avoid this,
since it causes memory corruption.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
common/usb_storage.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 60531e2..f2d2ad9 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -176,6 +176,13 @@ static int usb_stor_probe_device(struct usb_device *dev)
if (dev == NULL)
return -ENOENT; /* no more devices available */
+ /* We don't have space to even probe if we hit the maximum */
+ if (usb_max_devs == USB_MAX_STOR_DEV) {
+ printf("max USB Storage Device reached: %d stopping\n",
+ usb_max_devs);
+ return -ENOSPC;
+ }
+
debug("\n\nProbing for storage\n");
if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
/* OK, it's a storage device. Iterate over its LUNs
@@ -210,13 +217,6 @@ static int usb_stor_probe_device(struct usb_device *dev)
}
}
- /* if storage device */
- if (usb_max_devs == USB_MAX_STOR_DEV) {
- printf("max USB Storage Device reached: %d stopping\n",
- usb_max_devs);
- return -ENOSPC;
- }
-
return 0;
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 21/32] dm: usb: Tidy up storage code ready for driver model conversion
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (18 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 20/32] dm: usb: Avoid exceeding available array size for storage devices Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-02-29 23:02 ` Marek Vasut
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 22/32] dm: blk: Add a block-device uclass Simon Glass
` (12 subsequent siblings)
32 siblings, 2 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Adjust a few things so that the addition of driver-models support involved
adding code rather than also changing it. This makes the patches easier to
review.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
common/usb_storage.c | 117 +++++++++++++++++++++++++++------------------------
1 file changed, 61 insertions(+), 56 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index f2d2ad9..0475123 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -142,6 +142,7 @@ static void usb_show_progress(void)
*/
int usb_stor_info(void)
{
+ int count = 0;
int i;
if (usb_max_devs > 0) {
@@ -152,7 +153,11 @@ int usb_stor_info(void)
return 0;
}
- printf("No storage devices, perhaps not 'usb start'ed..?\n");
+ if (!count) {
+ printf("No storage devices, perhaps not 'usb start'ed..?\n");
+ return 1;
+ }
+
return 1;
}
@@ -171,9 +176,12 @@ static unsigned int usb_get_max_lun(struct us_data *us)
return (len > 0) ? *result : 0;
}
-static int usb_stor_probe_device(struct usb_device *dev)
+static int usb_stor_probe_device(struct usb_device *udev)
{
- if (dev == NULL)
+ int lun, max_lun;
+ int start;
+
+ if (udev == NULL)
return -ENOENT; /* no more devices available */
/* We don't have space to even probe if we hit the maximum */
@@ -184,36 +192,36 @@ static int usb_stor_probe_device(struct usb_device *dev)
}
debug("\n\nProbing for storage\n");
- if (usb_storage_probe(dev, 0, &usb_stor[usb_max_devs])) {
- /* OK, it's a storage device. Iterate over its LUNs
- * and populate `usb_dev_desc'.
- */
- int lun, max_lun, start = usb_max_devs;
-
- max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]);
- for (lun = 0;
- lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV;
- lun++) {
- struct blk_desc *blkdev;
-
- blkdev = &usb_dev_desc[usb_max_devs];
- memset(blkdev, '\0', sizeof(struct blk_desc));
- blkdev->if_type = IF_TYPE_USB;
- blkdev->devnum = usb_max_devs;
- blkdev->part_type = PART_TYPE_UNKNOWN;
- blkdev->target = 0xff;
- blkdev->type = DEV_TYPE_UNKNOWN;
- blkdev->block_read = usb_stor_read;
- blkdev->block_write = usb_stor_write;
- blkdev->lun = lun;
- blkdev->priv = dev;
-
- if (usb_stor_get_info(dev, &usb_stor[start],
- &usb_dev_desc[usb_max_devs]) ==
- 1) {
- usb_max_devs++;
- debug("%s: Found device %p\n", __func__, dev);
- }
+ if (!usb_storage_probe(udev, 0, &usb_stor[usb_max_devs]))
+ return 0;
+
+ /*
+ * OK, it's a storage device. Iterate over its LUNs and populate
+ * usb_dev_desc'
+ */
+ start = usb_max_devs;
+
+ max_lun = usb_get_max_lun(&usb_stor[usb_max_devs]);
+ for (lun = 0; lun <= max_lun && usb_max_devs < USB_MAX_STOR_DEV;
+ lun++) {
+ struct blk_desc *blkdev;
+
+ blkdev = &usb_dev_desc[usb_max_devs];
+ memset(blkdev, '\0', sizeof(struct blk_desc));
+ blkdev->if_type = IF_TYPE_USB;
+ blkdev->devnum = usb_max_devs;
+ blkdev->part_type = PART_TYPE_UNKNOWN;
+ blkdev->target = 0xff;
+ blkdev->type = DEV_TYPE_UNKNOWN;
+ blkdev->block_read = usb_stor_read;
+ blkdev->block_write = usb_stor_write;
+ blkdev->lun = lun;
+ blkdev->priv = udev;
+
+ if (usb_stor_get_info(udev, &usb_stor[start],
+ &usb_dev_desc[usb_max_devs]) == 1) {
+ usb_max_devs++;
+ debug("%s: Found device %p\n", __func__, udev);
}
}
@@ -1029,36 +1037,33 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer)
{
- int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks;
- struct usb_device *dev;
+ struct usb_device *udev;
struct us_data *ss;
int retry;
ccb *srb = &usb_ccb;
if (blkcnt == 0)
return 0;
-
- device &= 0xff;
/* Setup device */
- debug("\nusb_read: dev %d\n", device);
- dev = usb_dev_desc[device].priv;
- if (!dev) {
+ debug("\nusb_read: udev %d\n", block_dev->devnum);
+ udev = usb_dev_desc[block_dev->devnum].priv;
+ if (!udev) {
debug("%s: No device\n", __func__);
return 0;
}
- ss = (struct us_data *)dev->privptr;
+ ss = (struct us_data *)udev->privptr;
usb_disable_asynch(1); /* asynch transfer not allowed */
- srb->lun = usb_dev_desc[device].lun;
+ srb->lun = block_dev->lun;
buf_addr = (uintptr_t)buffer;
start = blknr;
blks = blkcnt;
- debug("\nusb_read: dev %d startblk " LBAF ", blccnt " LBAF
- " buffer %" PRIxPTR "\n", device, start, blks, buf_addr);
+ debug("\nusb_read: dev %d startblk " LBAF ", blccnt " LBAF " buffer %"
+ PRIxPTR "\n", block_dev->devnum, start, blks, buf_addr);
do {
/* XXX need some comment here */
@@ -1071,7 +1076,7 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
retry_it:
if (smallblks == USB_MAX_XFER_BLK)
usb_show_progress();
- srb->datalen = usb_dev_desc[device].blksz * smallblks;
+ srb->datalen = block_dev->blksz * smallblks;
srb->pdata = (unsigned char *)buf_addr;
if (usb_read_10(srb, ss, start, smallblks)) {
debug("Read ERROR\n");
@@ -1100,11 +1105,10 @@ retry_it:
static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer)
{
- int device = block_dev->devnum;
lbaint_t start, blks;
uintptr_t buf_addr;
unsigned short smallblks;
- struct usb_device *dev;
+ struct usb_device *udev;
struct us_data *ss;
int retry;
ccb *srb = &usb_ccb;
@@ -1112,23 +1116,24 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
if (blkcnt == 0)
return 0;
- device &= 0xff;
/* Setup device */
- debug("\nusb_write: dev %d\n", device);
- dev = usb_dev_desc[device].priv;
- if (!dev)
+ debug("\nusb_read: udev %d\n", block_dev->devnum);
+ udev = usb_dev_desc[block_dev->devnum].priv;
+ if (!udev) {
+ debug("%s: No device\n", __func__);
return 0;
- ss = (struct us_data *)dev->privptr;
+ }
+ ss = (struct us_data *)udev->privptr;
usb_disable_asynch(1); /* asynch transfer not allowed */
- srb->lun = usb_dev_desc[device].lun;
+ srb->lun = block_dev->lun;
buf_addr = (uintptr_t)buffer;
start = blknr;
blks = blkcnt;
- debug("\nusb_write: dev %d startblk " LBAF ", blccnt " LBAF
- " buffer %" PRIxPTR "\n", device, start, blks, buf_addr);
+ debug("\nusb_write: dev %d startblk " LBAF ", blccnt " LBAF " buffer %"
+ PRIxPTR "\n", block_dev->devnum, start, blks, buf_addr);
do {
/* If write fails retry for max retry count else
@@ -1143,7 +1148,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
retry_it:
if (smallblks == USB_MAX_XFER_BLK)
usb_show_progress();
- srb->datalen = usb_dev_desc[device].blksz * smallblks;
+ srb->datalen = block_dev->blksz * smallblks;
srb->pdata = (unsigned char *)buf_addr;
if (usb_write_10(srb, ss, start, smallblks)) {
debug("Write ERROR\n");
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 22/32] dm: blk: Add a block-device uclass
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (19 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 21/32] dm: usb: Tidy up storage code ready for driver model conversion Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 23/32] dm: sandbox: Prepare block driver for driver-model conversion Simon Glass
` (11 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Add a uclass for block devices. These provide block-oriented data access,
supporting reading, writing and erasing of whole blocks.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
drivers/block/Kconfig | 11 +++
drivers/block/Makefile | 2 +
drivers/block/blk-uclass.c | 175 +++++++++++++++++++++++++++++++++++++++++++++
include/blk.h | 145 +++++++++++++++++++++++++++++++++++++
include/dm/uclass-id.h | 1 +
5 files changed, 334 insertions(+)
create mode 100644 drivers/block/blk-uclass.c
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 990f768..f35c4d4 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,3 +1,14 @@
+config BLK
+ bool "Support block devices"
+ depends on DM
+ help
+ Enable support for block devices, such as SCSI, MMC and USB
+ flash sticks. These provide a block-level interface which permits
+ reading, writing and (in some cases) erasing blocks. Block
+ devices often have a partition table which allows the device to
+ be partitioned into several areas, called 'partitions' in U-Boot.
+ A filesystem can be placed in each partition.
+
config DISK
bool "Support disk controllers with driver model"
depends on DM
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 5eb87e0..b5c7ae1 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -5,6 +5,8 @@
# SPDX-License-Identifier: GPL-2.0+
#
+obj-$(CONFIG_BLK) += blk-uclass.o
+
obj-$(CONFIG_DISK) += disk-uclass.o
obj-$(CONFIG_SCSI_AHCI) += ahci.o
obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
new file mode 100644
index 0000000..49df2a6
--- /dev/null
+++ b/drivers/block/blk-uclass.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <blk.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+
+int blk_first_device(int if_type, struct udevice **devp)
+{
+ struct blk_desc *desc;
+ int ret;
+
+ ret = uclass_first_device(UCLASS_BLK, devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return -ENODEV;
+ do {
+ desc = dev_get_uclass_platdata(*devp);
+ if (desc->if_type == if_type)
+ return 0;
+ ret = uclass_next_device(devp);
+ if (ret)
+ return ret;
+ } while (*devp);
+
+ return -ENODEV;
+}
+
+int blk_next_device(struct udevice **devp)
+{
+ struct blk_desc *desc;
+ int ret, if_type;
+
+ desc = dev_get_uclass_platdata(*devp);
+ if_type = desc->if_type;
+ do {
+ ret = uclass_next_device(devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return -ENODEV;
+ desc = dev_get_uclass_platdata(*devp);
+ if (desc->if_type == if_type)
+ return 0;
+ } while (1);
+}
+
+int blk_get_device(int if_type, int devnum, struct udevice **devp)
+{
+ struct uclass *uc;
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get(UCLASS_BLK, &uc);
+ if (ret)
+ return ret;
+ uclass_foreach_dev(dev, uc) {
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
+ if_type, devnum, dev->name, desc->if_type, desc->devnum);
+ if (desc->if_type == if_type && desc->devnum == devnum) {
+ *devp = dev;
+ return device_probe(dev);
+ }
+ }
+
+ return -ENODEV;
+}
+
+unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->read)
+ return -ENOSYS;
+
+ return ops->read(dev, start, blkcnt, buffer);
+}
+
+unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->write)
+ return -ENOSYS;
+
+ return ops->write(dev, start, blkcnt, buffer);
+}
+
+unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ struct udevice *dev = block_dev->bdev;
+ const struct blk_ops *ops = blk_get_ops(dev);
+
+ if (!ops->erase)
+ return -ENOSYS;
+
+ return ops->erase(dev, start, blkcnt);
+}
+
+int blk_prepare_device(struct udevice *dev)
+{
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ part_init(desc);
+
+ return 0;
+}
+
+int blk_create_device(struct udevice *parent, const char *drv_name,
+ const char *name, int if_type, int devnum, int blksz,
+ lbaint_t size, struct udevice **devp)
+{
+ struct blk_desc *desc;
+ struct udevice *dev;
+ int ret;
+
+ ret = device_bind_driver(parent, drv_name, name, &dev);
+ if (ret)
+ return ret;
+ desc = dev_get_uclass_platdata(dev);
+ desc->if_type = if_type;
+ desc->blksz = blksz;
+ desc->lba = size / blksz;
+ desc->part_type = PART_TYPE_UNKNOWN;
+ desc->bdev = dev;
+ desc->devnum = devnum;
+ *devp = dev;
+
+ return 0;
+}
+
+int blk_unbind_all(int if_type)
+{
+ struct uclass *uc;
+ struct udevice *dev, *next;
+ int ret;
+
+ ret = uclass_get(UCLASS_BLK, &uc);
+ if (ret)
+ return ret;
+ uclass_foreach_dev_safe(dev, next, uc) {
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ if (desc->if_type == if_type) {
+ ret = device_remove(dev);
+ if (ret)
+ return ret;
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+UCLASS_DRIVER(blk) = {
+ .id = UCLASS_BLK,
+ .name = "blk",
+ .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
+};
diff --git a/include/blk.h b/include/blk.h
index 7b2e5e2..e83c144 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -34,7 +34,15 @@ enum if_type {
IF_TYPE_COUNT, /* Number of interface types */
};
+/*
+ * With driver model (CONFIG_BLK) this is uclass platform data, accessible
+ * with dev_get_uclass_platdata(dev)
+ */
struct blk_desc {
+ /*
+ * TODO: With driver model we should be able to use the parent
+ * device's uclass instead.
+ */
enum if_type if_type; /* type of the interface */
int devnum; /* device number */
unsigned char part_type; /* partition type */
@@ -53,6 +61,9 @@ struct blk_desc {
char vendor[40+1]; /* IDE model, SCSI Vendor */
char product[20+1]; /* IDE Serial no, SCSI product */
char revision[8+1]; /* firmware revision */
+#ifdef CONFIG_BLK
+ struct udevice *bdev;
+#else
unsigned long (*block_read)(struct blk_desc *block_dev,
lbaint_t start,
lbaint_t blkcnt,
@@ -65,12 +76,145 @@ struct blk_desc {
lbaint_t start,
lbaint_t blkcnt);
void *priv; /* driver private struct pointer */
+#endif
};
#define BLOCK_CNT(size, blk_desc) (PAD_COUNT(size, blk_desc->blksz))
#define PAD_TO_BLOCKSIZE(size, blk_desc) \
(PAD_SIZE(size, blk_desc->blksz))
+#ifdef CONFIG_BLK
+struct udevice;
+
+/* Operations on block devices */
+struct blk_ops {
+ /**
+ * read() - read from a block device
+ *
+ * @dev: Device to read from
+ * @start: Start block number to read (0=first)
+ * @blkcnt: Number of blocks to read
+ * @buffer: Destination buffer for data read
+ * @return number of blocks read, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*read)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer);
+
+ /**
+ * write() - write to a block device
+ *
+ * @dev: Device to write to
+ * @start: Start block number to write (0=first)
+ * @blkcnt: Number of blocks to write
+ * @buffer: Source buffer for data to write
+ * @return number of blocks written, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*write)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer);
+
+ /**
+ * erase() - erase a section of a block device
+ *
+ * @dev: Device to (partially) erase
+ * @start: Start block number to erase (0=first)
+ * @blkcnt: Number of blocks to erase
+ * @return number of blocks erased, or -ve error number (see the
+ * IS_ERR_VALUE() macro
+ */
+ unsigned long (*erase)(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt);
+};
+
+#define blk_get_ops(dev) ((struct blk_ops *)(dev)->driver->ops)
+
+/*
+ * These functions should take struct udevice instead of struct blk_desc,
+ * but this is convenient for migration to driver model. Add a 'd' prefix
+ * to the function operations, so that blk_read(), etc. can be reserved for
+ * functions with the correct arguments.
+ */
+unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer);
+unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer);
+unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
+ lbaint_t blkcnt);
+
+/**
+ * blk_get_device() - Find and probe a block device ready for use
+ *
+ * @if_type: Interface type (enum if_type_t)
+ * @devnum: Device number (specific to each interface type)
+ * @devp: the device, if found
+ * @return - if found, -ENODEV if no device found, or other -ve error value
+ */
+int blk_get_device(int if_type, int devnum, struct udevice **devp);
+
+/**
+ * blk_first_device() - Find the first device for a given interface
+ *
+ * The device is probed ready for use
+ *
+ * @devnum: Device number (specific to each interface type)
+ * @devp: the device, if found
+ * @return 0 if found, -ENODEV if no device, or other -ve error value
+ */
+int blk_first_device(int if_type, struct udevice **devp);
+
+/**
+ * blk_next_device() - Find the next device for a given interface
+ *
+ * This can be called repeatedly after blk_first_device() to iterate through
+ * all devices of the given interface type.
+ *
+ * The device is probed ready for use
+ *
+ * @devp: On entry, the previous device returned. On exit, the next
+ * device, if found
+ * @return 0 if found, -ENODEV if no device, or other -ve error value
+ */
+int blk_next_device(struct udevice **devp);
+
+/**
+ * blk_create_device() - Create a new block device
+ *
+ * @parent: Parent of the new device
+ * @drv_name: Driver name to use for the block device
+ * @name: Name for the device
+ * @if_type: Interface type (enum if_type_t)
+ * @devnum: Device number, specific to the interface type
+ * @blksz: Block size of the device in bytes (typically 512)
+ * @size: Total size of the device in bytes
+ * @devp: the new device (which has not been probed)
+ */
+int blk_create_device(struct udevice *parent, const char *drv_name,
+ const char *name, int if_type, int devnum, int blksz,
+ lbaint_t size, struct udevice **devp);
+
+/**
+ * blk_prepare_device() - Prepare a block device for use
+ *
+ * This reads partition information from the device if supported.
+ *
+ * @dev: Device to prepare
+ * @return 0 if ok, -ve on error
+ */
+int blk_prepare_device(struct udevice *dev);
+
+/**
+ * blk_unbind_all() - Unbind all device of the given interface type
+ *
+ * The devices are removed and then unbound.
+ *
+ * @if_type: Interface type to unbind
+ * @return 0 if OK, -ve on error
+ */
+int blk_unbind_all(int if_type);
+
+#else
+#include <errno.h>
/*
* These functions should take struct udevice instead of struct blk_desc,
* but this is convenient for migration to driver model. Add a 'd' prefix
@@ -99,5 +243,6 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
{
return block_dev->block_erase(block_dev, start, blkcnt);
}
+#endif /* !CONFIG_BLK */
#endif
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 3bea308..37c4176 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -26,6 +26,7 @@ enum uclass_id {
/* U-Boot uclasses start here - in alphabetical order */
UCLASS_ADC, /* Analog-to-digital converter */
+ UCLASS_BLK, /* Block device */
UCLASS_CLK, /* Clock source, e.g. used by peripherals */
UCLASS_CPU, /* CPU, typically part of an SoC */
UCLASS_CROS_EC, /* Chrome OS EC */
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 22/32] dm: blk: Add a block-device uclass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 22/32] dm: blk: Add a block-device uclass Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Add a uclass for block devices. These provide block-oriented data access,
> supporting reading, writing and erasing of whole blocks.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
> drivers/block/Kconfig | 11 +++
> drivers/block/Makefile | 2 +
> drivers/block/blk-uclass.c | 175 +++++++++++++++++++++++++++++++++++++++++++++
> include/blk.h | 145 +++++++++++++++++++++++++++++++++++++
> include/dm/uclass-id.h | 1 +
> 5 files changed, 334 insertions(+)
> create mode 100644 drivers/block/blk-uclass.c
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 23/32] dm: sandbox: Prepare block driver for driver-model conversion
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (20 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 22/32] dm: blk: Add a block-device uclass Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 24/32] dm: sandbox: Add driver-model block-device support for sandbox Simon Glass
` (10 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Make a few minor changes to make it easier to add driver-model support.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
drivers/block/sandbox.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 14d3e38..dde9d68 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -31,16 +31,15 @@ static unsigned long host_block_read(struct blk_desc *block_dev,
if (!host_dev)
return -1;
- if (os_lseek(host_dev->fd,
- start * host_dev->blk_dev.blksz,
- OS_SEEK_SET) == -1) {
- printf("ERROR: Invalid position\n");
+
+ if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
+ -1) {
+ printf("ERROR: Invalid block %lx\n", start);
return -1;
}
- ssize_t len = os_read(host_dev->fd, buffer,
- blkcnt * host_dev->blk_dev.blksz);
+ ssize_t len = os_read(host_dev->fd, buffer, blkcnt * block_dev->blksz);
if (len >= 0)
- return len / host_dev->blk_dev.blksz;
+ return len / block_dev->blksz;
return -1;
}
@@ -50,16 +49,15 @@ static unsigned long host_block_write(struct blk_desc *block_dev,
{
int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
- if (os_lseek(host_dev->fd,
- start * host_dev->blk_dev.blksz,
- OS_SEEK_SET) == -1) {
- printf("ERROR: Invalid position\n");
+
+ if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
+ -1) {
+ printf("ERROR: Invalid block %lx\n", start);
return -1;
}
- ssize_t len = os_write(host_dev->fd, buffer, blkcnt *
- host_dev->blk_dev.blksz);
+ ssize_t len = os_write(host_dev->fd, buffer, blkcnt * block_dev->blksz);
if (len >= 0)
- return len / host_dev->blk_dev.blksz;
+ return len / block_dev->blksz;
return -1;
}
@@ -103,9 +101,9 @@ int host_dev_bind(int dev, char *filename)
return 0;
}
-int host_get_dev_err(int dev, struct blk_desc **blk_devp)
+int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
{
- struct host_block_dev *host_dev = find_host_device(dev);
+ struct host_block_dev *host_dev = find_host_device(devnum);
if (!host_dev)
return -ENODEV;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 24/32] dm: sandbox: Add driver-model block-device support for sandbox
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (21 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 23/32] dm: sandbox: Prepare block driver for driver-model conversion Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:25 ` [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
` (9 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Update the host driver to support driver model for block devices. A future
commit will remove the old code, but for now it is useful to be able to use
it both with and without CONFIG_BLK.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Use snprintf() to avoid overflow
cmd/host.c | 9 +++-
drivers/block/sandbox.c | 118 +++++++++++++++++++++++++++++++++++++++++++++-
include/sandboxblockdev.h | 2 +
3 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/cmd/host.c b/cmd/host.c
index ee219ce..8d84415 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -5,6 +5,7 @@
*/
#include <common.h>
+#include <dm.h>
#include <fs.h>
#include <part.h>
#include <sandboxblockdev.h>
@@ -80,7 +81,13 @@ static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc,
continue;
}
- struct host_block_dev *host_dev = blk_dev->priv;
+ struct host_block_dev *host_dev;
+
+#ifdef CONFIG_BLK
+ host_dev = dev_get_priv(blk_dev->bdev);
+#else
+ host_dev = blk_dev->priv;
+#endif
printf("%12lu %s\n", (unsigned long)blk_dev->lba,
host_dev->filename);
}
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index dde9d68..6d41508 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -4,14 +4,20 @@
* SPDX-License-Identifier: GPL-2.0+
*/
-#include <config.h>
#include <common.h>
+#include <blk.h>
+#include <dm.h>
+#include <fdtdec.h>
#include <part.h>
#include <os.h>
#include <malloc.h>
#include <sandboxblockdev.h>
#include <asm/errno.h>
+#include <dm/device-internal.h>
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifndef CONFIG_BLK
static struct host_block_dev host_devices[CONFIG_HOST_MAX_DEVICES];
static struct host_block_dev *find_host_device(int dev)
@@ -21,7 +27,17 @@ static struct host_block_dev *find_host_device(int dev)
return NULL;
}
+#endif
+
+#ifdef CONFIG_BLK
+static unsigned long host_block_read(struct udevice *dev,
+ unsigned long start, lbaint_t blkcnt,
+ void *buffer)
+{
+ struct host_block_dev *host_dev = dev_get_priv(dev);
+ struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+#else
static unsigned long host_block_read(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
void *buffer)
@@ -31,6 +47,7 @@ static unsigned long host_block_read(struct blk_desc *block_dev,
if (!host_dev)
return -1;
+#endif
if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
-1) {
@@ -43,12 +60,21 @@ static unsigned long host_block_read(struct blk_desc *block_dev,
return -1;
}
+#ifdef CONFIG_BLK
+static unsigned long host_block_write(struct udevice *dev,
+ unsigned long start, lbaint_t blkcnt,
+ const void *buffer)
+{
+ struct host_block_dev *host_dev = dev_get_priv(dev);
+ struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+#else
static unsigned long host_block_write(struct blk_desc *block_dev,
unsigned long start, lbaint_t blkcnt,
const void *buffer)
{
int dev = block_dev->devnum;
struct host_block_dev *host_dev = find_host_device(dev);
+#endif
if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
-1) {
@@ -61,6 +87,70 @@ static unsigned long host_block_write(struct blk_desc *block_dev,
return -1;
}
+#ifdef CONFIG_BLK
+int host_dev_bind(int devnum, char *filename)
+{
+ struct host_block_dev *host_dev;
+ struct udevice *dev;
+ char dev_name[20], *str, *fname;
+ int ret, fd;
+
+ /* Remove and unbind the old device, if any */
+ ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ if (ret == 0) {
+ ret = device_remove(dev);
+ if (ret)
+ return ret;
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ } else if (ret != -ENODEV) {
+ return ret;
+ }
+
+ if (!filename)
+ return 0;
+
+ snprintf(dev_name, sizeof(dev_name), "host%d", devnum);
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+ fname = strdup(filename);
+ if (!fname) {
+ free(str);
+ return -ENOMEM;
+ }
+
+ fd = os_open(filename, OS_O_RDWR);
+ if (fd == -1) {
+ printf("Failed to access host backing file '%s'\n", filename);
+ ret = -ENOENT;
+ goto err;
+ }
+ ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str,
+ IF_TYPE_HOST, devnum, 512,
+ os_lseek(fd, 0, OS_SEEK_END), &dev);
+ if (ret)
+ goto err_file;
+ ret = device_probe(dev);
+ if (ret) {
+ device_unbind(dev);
+ goto err_file;
+ }
+
+ host_dev = dev_get_priv(dev);
+ host_dev->fd = fd;
+ host_dev->filename = fname;
+
+ return blk_prepare_device(dev);
+err_file:
+ os_close(fd);
+err:
+ free(fname);
+ free(str);
+ return ret;
+}
+#else
int host_dev_bind(int dev, char *filename)
{
struct host_block_dev *host_dev = find_host_device(dev);
@@ -100,9 +190,19 @@ int host_dev_bind(int dev, char *filename)
return 0;
}
+#endif
int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
{
+#ifdef CONFIG_BLK
+ struct udevice *dev;
+ int ret;
+
+ ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+ if (ret)
+ return ret;
+ *blk_devp = dev_get_uclass_platdata(dev);
+#else
struct host_block_dev *host_dev = find_host_device(devnum);
if (!host_dev)
@@ -112,6 +212,8 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
return -ENOENT;
*blk_devp = &host_dev->blk_dev;
+#endif
+
return 0;
}
@@ -124,3 +226,17 @@ struct blk_desc *host_get_dev(int dev)
return blk_dev;
}
+
+#ifdef CONFIG_BLK
+static const struct blk_ops sandbox_host_blk_ops = {
+ .read = host_block_read,
+ .write = host_block_write,
+};
+
+U_BOOT_DRIVER(sandbox_host_blk) = {
+ .name = "sandbox_host_blk",
+ .id = UCLASS_BLK,
+ .ops = &sandbox_host_blk_ops,
+ .priv_auto_alloc_size = sizeof(struct host_block_dev),
+};
+#endif
diff --git a/include/sandboxblockdev.h b/include/sandboxblockdev.h
index 59f9519..5174f45 100644
--- a/include/sandboxblockdev.h
+++ b/include/sandboxblockdev.h
@@ -8,7 +8,9 @@
#define __SANDBOX_BLOCK_DEV__
struct host_block_dev {
+#ifndef CONFIG_BLK
struct blk_desc blk_dev;
+#endif
char *filename;
int fd;
};
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 24/32] dm: sandbox: Add driver-model block-device support for sandbox
2016-02-29 22:25 ` [U-Boot] [PATCH v2 24/32] dm: sandbox: Add driver-model block-device support for sandbox Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Update the host driver to support driver model for block devices. A future
> commit will remove the old code, but for now it is useful to be able to use
> it both with and without CONFIG_BLK.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Use snprintf() to avoid overflow
>
> cmd/host.c | 9 +++-
> drivers/block/sandbox.c | 118 +++++++++++++++++++++++++++++++++++++++++++++-
> include/sandboxblockdev.h | 2 +
> 3 files changed, 127 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (22 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 24/32] dm: sandbox: Add driver-model block-device support for sandbox Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-02-29 23:04 ` Marek Vasut
` (2 more replies)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 26/32] dm: usb: Unbind old block devices when shutting down USB Simon Glass
` (8 subsequent siblings)
32 siblings, 3 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
Update this code to support CONFIG_BLK. Each USB storage device can have
one or more block devices as children, each one representing a LUN
(logical unit) of the USB device.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
common/usb_storage.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 135 insertions(+), 6 deletions(-)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 0475123..1472824 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -43,6 +43,7 @@
#include <asm/byteorder.h>
#include <asm/processor.h>
#include <dm/device-internal.h>
+#include <dm/lists.h>
#include <part.h>
#include <usb.h>
@@ -67,7 +68,9 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
+#ifndef CONFIG_BLK
static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV];
+#endif
struct us_data;
typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
@@ -108,7 +111,9 @@ struct us_data {
#define USB_MAX_XFER_BLK 20
#endif
+#ifndef CONFIG_BLK
static struct us_data usb_stor[USB_MAX_STOR_DEV];
+#endif
#define USB_STOR_TRANSPORT_GOOD 0
#define USB_STOR_TRANSPORT_FAILED -1
@@ -118,16 +123,33 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
struct blk_desc *dev_desc);
int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
struct us_data *ss);
+#ifdef CONFIG_BLK
+static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, void *buffer);
+static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, const void *buffer);
+#else
static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer);
static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer);
+#endif
void uhci_show_temp_int_td(void);
#ifdef CONFIG_PARTITIONS
struct blk_desc *usb_stor_get_dev(int index)
{
+#ifdef CONFIG_BLK
+ struct udevice *dev;
+ int ret;
+
+ ret = blk_get_device(IF_TYPE_USB, index, &dev);
+ if (ret)
+ return NULL;
+ return dev_get_uclass_platdata(dev);
+#else
return (index < usb_max_devs) ? &usb_dev_desc[index] : NULL;
+#endif
}
#endif
@@ -143,6 +165,19 @@ static void usb_show_progress(void)
int usb_stor_info(void)
{
int count = 0;
+#ifdef CONFIG_BLK
+ struct udevice *dev;
+
+ for (blk_first_device(IF_TYPE_USB, &dev);
+ dev;
+ blk_next_device(&dev)) {
+ struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+ printf(" Device %d: ", desc->devnum);
+ dev_print(desc);
+ count++;
+ }
+#else
int i;
if (usb_max_devs > 0) {
@@ -152,7 +187,7 @@ int usb_stor_info(void)
}
return 0;
}
-
+#endif
if (!count) {
printf("No storage devices, perhaps not 'usb start'ed..?\n");
return 1;
@@ -179,11 +214,63 @@ static unsigned int usb_get_max_lun(struct us_data *us)
static int usb_stor_probe_device(struct usb_device *udev)
{
int lun, max_lun;
+
+#ifdef CONFIG_BLK
+ struct us_data *data;
+ char dev_name[30], *str;
+ int ret;
+#else
int start;
if (udev == NULL)
return -ENOENT; /* no more devices available */
+#endif
+
+ debug("\n\nProbing for storage\n");
+#ifdef CONFIG_BLK
+ /*
+ * We store the us_data in the mass storage device's platdata. It
+ * is shared by all LUNs (block devices) attached to this mass storage
+ * device.
+ */
+ data = dev_get_platdata(udev->dev);
+ if (!usb_storage_probe(udev, 0, data))
+ return 0;
+ max_lun = usb_get_max_lun(data);
+ for (lun = 0; lun <= max_lun; lun++) {
+ struct blk_desc *blkdev;
+ struct udevice *dev;
+
+ snprintf(dev_name, sizeof(dev_name), "%s.lun%d",
+ udev->dev->name, lun);
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+ ret = blk_create_device(udev->dev, "usb_storage_blk", str,
+ IF_TYPE_USB, usb_max_devs, 512, 0, &dev);
+ if (ret) {
+ debug("Cannot bind driver\n");
+ return ret;
+ }
+
+ blkdev = dev_get_uclass_platdata(dev);
+ blkdev->target = 0xff;
+ blkdev->lun = lun;
+ ret = usb_stor_get_info(udev, data, blkdev);
+ if (ret == 1)
+ ret = blk_prepare_device(dev);
+ if (!ret) {
+ usb_max_devs++;
+ debug("%s: Found device %p\n", __func__, udev);
+ } else {
+ debug("usb_stor_get_info: Invalid device\n");
+ ret = device_unbind(dev);
+ if (ret)
+ return ret;
+ }
+ }
+#else
/* We don't have space to even probe if we hit the maximum */
if (usb_max_devs == USB_MAX_STOR_DEV) {
printf("max USB Storage Device reached: %d stopping\n",
@@ -191,7 +278,6 @@ static int usb_stor_probe_device(struct usb_device *udev)
return -ENOSPC;
}
- debug("\n\nProbing for storage\n");
if (!usb_storage_probe(udev, 0, &usb_stor[usb_max_devs]))
return 0;
@@ -220,10 +306,14 @@ static int usb_stor_probe_device(struct usb_device *udev)
if (usb_stor_get_info(udev, &usb_stor[start],
&usb_dev_desc[usb_max_devs]) == 1) {
+ debug("partype: %d\n", blkdev->part_type);
+ part_init(blkdev);
+ debug("partype: %d\n", blkdev->part_type);
usb_max_devs++;
debug("%s: Found device %p\n", __func__, udev);
}
}
+#endif
return 0;
}
@@ -1034,8 +1124,13 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
}
#endif /* CONFIG_USB_BIN_FIXUP */
+#ifdef CONFIG_BLK
+static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, void *buffer)
+#else
static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer)
+#endif
{
lbaint_t start, blks;
uintptr_t buf_addr;
@@ -1044,16 +1139,25 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
struct us_data *ss;
int retry;
ccb *srb = &usb_ccb;
+#ifdef CONFIG_BLK
+ struct blk_desc *block_dev;
+#endif
if (blkcnt == 0)
return 0;
/* Setup device */
+#ifdef CONFIG_BLK
+ block_dev = dev_get_uclass_platdata(dev);
+ udev = dev_get_parent_priv(dev_get_parent(dev));
+ debug("\nusb_read: udev %d\n", block_dev->devnum);
+#else
debug("\nusb_read: udev %d\n", block_dev->devnum);
udev = usb_dev_desc[block_dev->devnum].priv;
if (!udev) {
debug("%s: No device\n", __func__);
return 0;
}
+#endif
ss = (struct us_data *)udev->privptr;
usb_disable_asynch(1); /* asynch transfer not allowed */
@@ -1102,8 +1206,13 @@ retry_it:
return blkcnt;
}
+#ifdef CONFIG_BLK
+static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr,
+ lbaint_t blkcnt, const void *buffer)
+#else
static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer)
+#endif
{
lbaint_t start, blks;
uintptr_t buf_addr;
@@ -1112,17 +1221,26 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
struct us_data *ss;
int retry;
ccb *srb = &usb_ccb;
+#ifdef CONFIG_BLK
+ struct blk_desc *block_dev;
+#endif
if (blkcnt == 0)
return 0;
/* Setup device */
+#ifdef CONFIG_BLK
+ block_dev = dev_get_uclass_platdata(dev);
+ udev = dev_get_parent_priv(dev_get_parent(dev));
+ debug("\nusb_read: udev %d\n", block_dev->devnum);
+#else
debug("\nusb_read: udev %d\n", block_dev->devnum);
udev = usb_dev_desc[block_dev->devnum].priv;
if (!udev) {
debug("%s: No device\n", __func__);
return 0;
}
+#endif
ss = (struct us_data *)udev->privptr;
usb_disable_asynch(1); /* asynch transfer not allowed */
@@ -1377,11 +1495,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
dev_desc->log2blksz = LOG2(dev_desc->blksz);
dev_desc->type = perq;
debug(" address %d\n", dev_desc->target);
- debug("partype: %d\n", dev_desc->part_type);
-
- part_init(dev_desc);
- debug("partype: %d\n", dev_desc->part_type);
return 1;
}
@@ -1409,6 +1523,9 @@ U_BOOT_DRIVER(usb_mass_storage) = {
.id = UCLASS_MASS_STORAGE,
.of_match = usb_mass_storage_ids,
.probe = usb_mass_storage_probe,
+#ifdef CONFIG_BLK
+ .platdata_auto_alloc_size = sizeof(struct us_data),
+#endif
};
UCLASS_DRIVER(usb_mass_storage) = {
@@ -1425,5 +1542,17 @@ static const struct usb_device_id mass_storage_id_table[] = {
};
U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table);
+#endif
+#ifdef CONFIG_BLK
+static const struct blk_ops usb_storage_ops = {
+ .read = usb_stor_read,
+ .write = usb_stor_write,
+};
+
+U_BOOT_DRIVER(usb_storage_blk) = {
+ .name = "usb_storage_blk",
+ .id = UCLASS_BLK,
+ .ops = &usb_storage_ops,
+};
#endif
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-02-29 22:25 ` [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
@ 2016-02-29 23:04 ` Marek Vasut
2016-03-13 1:53 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-03-14 18:01 ` Stephen Warren
2 siblings, 1 reply; 68+ messages in thread
From: Marek Vasut @ 2016-02-29 23:04 UTC (permalink / raw)
To: u-boot
On 02/29/2016 11:25 PM, Simon Glass wrote:
> Update this code to support CONFIG_BLK. Each USB storage device can have
> one or more block devices as children, each one representing a LUN
> (logical unit) of the USB device.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
> common/usb_storage.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 135 insertions(+), 6 deletions(-)
>
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 0475123..1472824 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -43,6 +43,7 @@
> #include <asm/byteorder.h>
> #include <asm/processor.h>
> #include <dm/device-internal.h>
> +#include <dm/lists.h>
>
> #include <part.h>
> #include <usb.h>
> @@ -67,7 +68,9 @@ static __u32 CBWTag;
>
> static int usb_max_devs; /* number of highest available usb device */
>
> +#ifndef CONFIG_BLK
> static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV];
> +#endif
You might want to use __maybe_unused to avoid the ifdef, do you think it
makes sense ?
> struct us_data;
> typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
Other than that:
Reviewed-by: Marek Vasut <marex@denx.de>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-02-29 23:04 ` Marek Vasut
@ 2016-03-13 1:53 ` Simon Glass
2016-03-13 17:41 ` Marek Vasut
0 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
Hi Marek,
On 29 February 2016 at 16:04, Marek Vasut <marex@denx.de> wrote:
> On 02/29/2016 11:25 PM, Simon Glass wrote:
>> Update this code to support CONFIG_BLK. Each USB storage device can have
>> one or more block devices as children, each one representing a LUN
>> (logical unit) of the USB device.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v2: None
>>
>> common/usb_storage.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++---
>> 1 file changed, 135 insertions(+), 6 deletions(-)
>>
>> diff --git a/common/usb_storage.c b/common/usb_storage.c
>> index 0475123..1472824 100644
>> --- a/common/usb_storage.c
>> +++ b/common/usb_storage.c
>> @@ -43,6 +43,7 @@
>> #include <asm/byteorder.h>
>> #include <asm/processor.h>
>> #include <dm/device-internal.h>
>> +#include <dm/lists.h>
>>
>> #include <part.h>
>> #include <usb.h>
>> @@ -67,7 +68,9 @@ static __u32 CBWTag;
>>
>> static int usb_max_devs; /* number of highest available usb device */
>>
>> +#ifndef CONFIG_BLK
>> static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV];
>> +#endif
>
> You might want to use __maybe_unused to avoid the ifdef, do you think it
> makes sense ?
This is something that should not exist when driver model is used. So
I'd rather have it explicit so it is obvious that it can be removed
with the driver-model conversion is done.
>
>> struct us_data;
>> typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
>
> Other than that:
>
> Reviewed-by: Marek Vasut <marex@denx.de>
>
> --
> Best regards,
> Marek Vasut
Regards,
Simon
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-03-13 1:53 ` Simon Glass
@ 2016-03-13 17:41 ` Marek Vasut
0 siblings, 0 replies; 68+ messages in thread
From: Marek Vasut @ 2016-03-13 17:41 UTC (permalink / raw)
To: u-boot
On 03/13/2016 02:53 AM, Simon Glass wrote:
> Hi Marek,
>
> On 29 February 2016 at 16:04, Marek Vasut <marex@denx.de> wrote:
>> On 02/29/2016 11:25 PM, Simon Glass wrote:
>>> Update this code to support CONFIG_BLK. Each USB storage device can have
>>> one or more block devices as children, each one representing a LUN
>>> (logical unit) of the USB device.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>> Changes in v2: None
>>>
>>> common/usb_storage.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++---
>>> 1 file changed, 135 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/common/usb_storage.c b/common/usb_storage.c
>>> index 0475123..1472824 100644
>>> --- a/common/usb_storage.c
>>> +++ b/common/usb_storage.c
>>> @@ -43,6 +43,7 @@
>>> #include <asm/byteorder.h>
>>> #include <asm/processor.h>
>>> #include <dm/device-internal.h>
>>> +#include <dm/lists.h>
>>>
>>> #include <part.h>
>>> #include <usb.h>
>>> @@ -67,7 +68,9 @@ static __u32 CBWTag;
>>>
>>> static int usb_max_devs; /* number of highest available usb device */
>>>
>>> +#ifndef CONFIG_BLK
>>> static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV];
>>> +#endif
>>
>> You might want to use __maybe_unused to avoid the ifdef, do you think it
>> makes sense ?
>
> This is something that should not exist when driver model is used. So
> I'd rather have it explicit so it is obvious that it can be removed
> with the driver-model conversion is done.
OK fine.
>>
>>> struct us_data;
>>> typedef int (*trans_cmnd)(ccb *cb, struct us_data *data);
>>
>> Other than that:
>>
>> Reviewed-by: Marek Vasut <marex@denx.de>
>>
>> --
>> Best regards,
>> Marek Vasut
>
> Regards,
> Simon
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-02-29 22:25 ` [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
2016-02-29 23:04 ` Marek Vasut
@ 2016-03-13 1:53 ` Simon Glass
2016-03-14 18:01 ` Stephen Warren
2 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Update this code to support CONFIG_BLK. Each USB storage device can have
> one or more block devices as children, each one representing a LUN
> (logical unit) of the USB device.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
> common/usb_storage.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 135 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs
2016-02-29 22:25 ` [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
2016-02-29 23:04 ` Marek Vasut
2016-03-13 1:53 ` Simon Glass
@ 2016-03-14 18:01 ` Stephen Warren
2 siblings, 0 replies; 68+ messages in thread
From: Stephen Warren @ 2016-03-14 18:01 UTC (permalink / raw)
To: u-boot
On 02/29/2016 03:25 PM, Simon Glass wrote:
> Update this code to support CONFIG_BLK. Each USB storage device can have
> one or more block devices as children, each one representing a LUN
> (logical unit) of the USB device.
Note that I accidentally tested some other patches in the wrong place
today, and found that this patch prevents my USB SD card reader from
working when attached to Jetson TK1. I get:
U-Boot 2016.03-rc3-00056-gb3601815cf72 (Mar 14 2016 - 11:54:53 -0600)
TEGRA124
Model: NVIDIA Jetson TK1
Board: NVIDIA Jetson TK1
DRAM: 2 GiB
MMC: Tegra SD/MMC: 0, Tegra SD/MMC: 1
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
Tegra124 (Jetson TK1) # usb start
starting USB...
USB0: USB EHCI 1.10
USB1: USB EHCI 1.10
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 1 for devices... Device NOT ready
Request Sense returned 02 3A 00
### ERROR ### Please RESET the board ###
(The Request Sense error happens even in the passing cases, but in those
cases the overall "usb start" operation succeeds, and then USB storage
access does actually work. I guess my reader is a little slow to
initialize or something).
The patch immediately before this one works fine.
Can you reproduce this? If not, let me know and I'll investigate further.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 26/32] dm: usb: Unbind old block devices when shutting down USB
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (23 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 25/32] dm: usb: Convert USB storage to use driver-model for block devs Simon Glass
@ 2016-02-29 22:25 ` Simon Glass
2016-02-29 23:05 ` Marek Vasut
2016-02-29 22:26 ` [U-Boot] [PATCH v2 27/32] dm: sandbox: Switch over to use DM for block devices Simon Glass
` (7 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:25 UTC (permalink / raw)
To: u-boot
We don't want old block devices hanging around since they can still appear
visible in some way.
Possibly we should unbind all devices which don't cause problems by being
unbound. Most likely we can remove everything except USB controllers, hubs
and emulators. We can consider that later.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
drivers/usb/host/usb-uclass.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 50538e0..69c9a50 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -159,7 +159,11 @@ int usb_stop(void)
if (ret && !err)
err = ret;
}
-
+#ifdef CONFIG_BLK
+ ret = blk_unbind_all(IF_TYPE_USB);
+ if (ret && !err)
+ err = ret;
+#endif
#ifdef CONFIG_SANDBOX
struct udevice *dev;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 26/32] dm: usb: Unbind old block devices when shutting down USB
2016-02-29 22:25 ` [U-Boot] [PATCH v2 26/32] dm: usb: Unbind old block devices when shutting down USB Simon Glass
@ 2016-02-29 23:05 ` Marek Vasut
0 siblings, 0 replies; 68+ messages in thread
From: Marek Vasut @ 2016-02-29 23:05 UTC (permalink / raw)
To: u-boot
On 02/29/2016 11:25 PM, Simon Glass wrote:
> We don't want old block devices hanging around since they can still appear
> visible in some way.
OK
> Possibly we should unbind all devices which don't cause problems by being
> unbound. Most likely we can remove everything except USB controllers, hubs
> and emulators. We can consider that later.
Can you please expand on this bit of the commit message ? It's not very
clear.
Thanks!
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
> drivers/usb/host/usb-uclass.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
> index 50538e0..69c9a50 100644
> --- a/drivers/usb/host/usb-uclass.c
> +++ b/drivers/usb/host/usb-uclass.c
> @@ -159,7 +159,11 @@ int usb_stop(void)
> if (ret && !err)
> err = ret;
> }
> -
> +#ifdef CONFIG_BLK
> + ret = blk_unbind_all(IF_TYPE_USB);
> + if (ret && !err)
> + err = ret;
> +#endif
> #ifdef CONFIG_SANDBOX
> struct udevice *dev;
>
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 27/32] dm: sandbox: Switch over to use DM for block devices
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (24 preceding siblings ...)
2016-02-29 22:25 ` [U-Boot] [PATCH v2 26/32] dm: usb: Unbind old block devices when shutting down USB Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-02-29 22:26 ` [U-Boot] [PATCH v2 28/32] dm: sandbox: Drop the pre-DM host implementation Simon Glass
` (6 subsequent siblings)
32 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
Now that the drivers used by sandbox support CONFIG_BLK, we can switch
sandbox over to use driver model for block devices.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
configs/sandbox_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 02534bf..d69c9fc 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -28,6 +28,7 @@ CONFIG_SPL_SYSCON=y
CONFIG_DEVRES=y
CONFIG_ADC=y
CONFIG_ADC_SANDBOX=y
+CONFIG_BLK=y
CONFIG_CLK=y
CONFIG_SANDBOX_GPIO=y
CONFIG_SYS_I2C_SANDBOX=y
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 28/32] dm: sandbox: Drop the pre-DM host implementation
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (25 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 27/32] dm: sandbox: Switch over to use DM for block devices Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-02-29 22:26 ` [U-Boot] [PATCH v2 29/32] dm: usb: Clean up USB after each test Simon Glass
` (5 subsequent siblings)
32 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
Driver model is used for host device block devices now, so we don't need the
old code. Remove it.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
drivers/block/sandbox.c | 90 -------------------------------------------------
1 file changed, 90 deletions(-)
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 6d41508..2d340ef 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -17,19 +17,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifndef CONFIG_BLK
-static struct host_block_dev host_devices[CONFIG_HOST_MAX_DEVICES];
-
-static struct host_block_dev *find_host_device(int dev)
-{
- if (dev >= 0 && dev < CONFIG_HOST_MAX_DEVICES)
- return &host_devices[dev];
-
- return NULL;
-}
-#endif
-
-#ifdef CONFIG_BLK
static unsigned long host_block_read(struct udevice *dev,
unsigned long start, lbaint_t blkcnt,
void *buffer)
@@ -37,18 +24,6 @@ static unsigned long host_block_read(struct udevice *dev,
struct host_block_dev *host_dev = dev_get_priv(dev);
struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
-#else
-static unsigned long host_block_read(struct blk_desc *block_dev,
- unsigned long start, lbaint_t blkcnt,
- void *buffer)
-{
- int dev = block_dev->devnum;
- struct host_block_dev *host_dev = find_host_device(dev);
-
- if (!host_dev)
- return -1;
-#endif
-
if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
-1) {
printf("ERROR: Invalid block %lx\n", start);
@@ -60,21 +35,12 @@ static unsigned long host_block_read(struct blk_desc *block_dev,
return -1;
}
-#ifdef CONFIG_BLK
static unsigned long host_block_write(struct udevice *dev,
unsigned long start, lbaint_t blkcnt,
const void *buffer)
{
struct host_block_dev *host_dev = dev_get_priv(dev);
struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
-#else
-static unsigned long host_block_write(struct blk_desc *block_dev,
- unsigned long start, lbaint_t blkcnt,
- const void *buffer)
-{
- int dev = block_dev->devnum;
- struct host_block_dev *host_dev = find_host_device(dev);
-#endif
if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
-1) {
@@ -87,7 +53,6 @@ static unsigned long host_block_write(struct blk_desc *block_dev,
return -1;
}
-#ifdef CONFIG_BLK
int host_dev_bind(int devnum, char *filename)
{
struct host_block_dev *host_dev;
@@ -150,51 +115,9 @@ err:
free(str);
return ret;
}
-#else
-int host_dev_bind(int dev, char *filename)
-{
- struct host_block_dev *host_dev = find_host_device(dev);
-
- if (!host_dev)
- return -1;
- if (host_dev->blk_dev.priv) {
- os_close(host_dev->fd);
- host_dev->blk_dev.priv = NULL;
- }
- if (host_dev->filename)
- free(host_dev->filename);
- if (filename && *filename) {
- host_dev->filename = strdup(filename);
- } else {
- host_dev->filename = NULL;
- return 0;
- }
-
- host_dev->fd = os_open(host_dev->filename, OS_O_RDWR);
- if (host_dev->fd == -1) {
- printf("Failed to access host backing file '%s'\n",
- host_dev->filename);
- return 1;
- }
-
- struct blk_desc *blk_dev = &host_dev->blk_dev;
- blk_dev->if_type = IF_TYPE_HOST;
- blk_dev->priv = host_dev;
- blk_dev->blksz = 512;
- blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
- blk_dev->block_read = host_block_read;
- blk_dev->block_write = host_block_write;
- blk_dev->devnum = dev;
- blk_dev->part_type = PART_TYPE_UNKNOWN;
- part_init(blk_dev);
-
- return 0;
-}
-#endif
int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
{
-#ifdef CONFIG_BLK
struct udevice *dev;
int ret;
@@ -202,17 +125,6 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
if (ret)
return ret;
*blk_devp = dev_get_uclass_platdata(dev);
-#else
- struct host_block_dev *host_dev = find_host_device(devnum);
-
- if (!host_dev)
- return -ENODEV;
-
- if (!host_dev->blk_dev.priv)
- return -ENOENT;
-
- *blk_devp = &host_dev->blk_dev;
-#endif
return 0;
}
@@ -227,7 +139,6 @@ struct blk_desc *host_get_dev(int dev)
return blk_dev;
}
-#ifdef CONFIG_BLK
static const struct blk_ops sandbox_host_blk_ops = {
.read = host_block_read,
.write = host_block_write,
@@ -239,4 +150,3 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
.ops = &sandbox_host_blk_ops,
.priv_auto_alloc_size = sizeof(struct host_block_dev),
};
-#endif
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 29/32] dm: usb: Clean up USB after each test
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (26 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 28/32] dm: sandbox: Drop the pre-DM host implementation Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:26 ` [U-Boot] [PATCH v2 30/32] dm: blk: Add tests for block devices Simon Glass
` (4 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
The USB subsystem has a few counters that need to be reset since they are
stored in static variables rather than driver-model data. An example is
usb_max_devs. Ultimately we should move this data into the USB uclass.
For now, make sure that USB is reset after each test, so that the counters
go back to zero.
Note: this is not a perfect solution: It a USB test fails it will exit
immediately and leave USB un-reset. The impact here is that it may cause
subsequence test failures in the same run.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None
test/dm/usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 2d20354..b46ae60 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -52,6 +52,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
memset(cmp, '\0', sizeof(cmp));
ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
ut_assertok(strcmp(cmp, "this is a test"));
+ ut_assertok(usb_stop());
return 0;
}
@@ -67,6 +68,7 @@ static int dm_test_usb_multi(struct unit_test_state *uts)
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &dev));
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 1, &dev));
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 2, &dev));
+ ut_assertok(usb_stop());
return 0;
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 29/32] dm: usb: Clean up USB after each test
2016-02-29 22:26 ` [U-Boot] [PATCH v2 29/32] dm: usb: Clean up USB after each test Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:26, Simon Glass <sjg@chromium.org> wrote:
> The USB subsystem has a few counters that need to be reset since they are
> stored in static variables rather than driver-model data. An example is
> usb_max_devs. Ultimately we should move this data into the USB uclass.
>
> For now, make sure that USB is reset after each test, so that the counters
> go back to zero.
>
> Note: this is not a perfect solution: It a USB test fails it will exit
> immediately and leave USB un-reset. The impact here is that it may cause
> subsequence test failures in the same run.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
> test/dm/usb.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 30/32] dm: blk: Add tests for block devices
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (27 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 29/32] dm: usb: Clean up USB after each test Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-02-29 22:26 ` [U-Boot] [PATCH v2 31/32] part: Rename test_part_xx() and print_part_xx() Simon Glass
` (3 subsequent siblings)
32 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
Add some tests to check that block devices work as expected.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Rename to blk_get_device_by_str()
test/dm/Makefile | 1 +
test/dm/blk.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
create mode 100644 test/dm/blk.c
diff --git a/test/dm/Makefile b/test/dm/Makefile
index fd0198f..df2d71f 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o
# subsystem you must add sandbox tests here.
obj-$(CONFIG_UT_DM) += core.o
ifneq ($(CONFIG_SANDBOX),)
+obj-$(CONFIG_BLK) += blk.o
obj-$(CONFIG_CLK) += clk.o
obj-$(CONFIG_DM_ETH) += eth.o
obj-$(CONFIG_DM_GPIO) += gpio.o
diff --git a/test/dm/blk.c b/test/dm/blk.c
new file mode 100644
index 0000000..f4ea32e
--- /dev/null
+++ b/test/dm/blk.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <usb.h>
+#include <asm/state.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Test that block devices can be created */
+static int dm_test_blk_base(struct unit_test_state *uts)
+{
+ struct udevice *blk, *usb_blk, *dev;
+
+ /* Make sure there are no block devices */
+ ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &blk));
+
+ /* Create two, one the parent of the other */
+ ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
+ IF_TYPE_HOST, 1, 512, 1024, &blk));
+ ut_assertok(blk_create_device(blk, "usb_storage_blk", "test",
+ IF_TYPE_USB, 3, 512, 1024, &usb_blk));
+
+ /* Check we can find them */
+ ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
+ ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
+ ut_asserteq_ptr(blk, dev);
+
+ ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_USB, 0, &dev));
+ ut_assertok(blk_get_device(IF_TYPE_USB, 3, &dev));
+ ut_asserteq_ptr(usb_blk, dev);
+
+ /* Check we can iterate */
+ ut_assertok(blk_first_device(IF_TYPE_HOST, &dev));
+ ut_asserteq_ptr(blk, dev);
+ ut_asserteq(-ENODEV, blk_next_device(&dev));
+
+ ut_assertok(blk_first_device(IF_TYPE_USB, &dev));
+ ut_asserteq_ptr(usb_blk, dev);
+ ut_asserteq(-ENODEV, blk_next_device(&dev));
+
+ return 0;
+}
+DM_TEST(dm_test_blk_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int count_blk_devices(void)
+{
+ struct udevice *blk;
+ struct uclass *uc;
+ int count = 0;
+ int ret;
+
+ ret = uclass_get(UCLASS_BLK, &uc);
+ if (ret)
+ return ret;
+
+ uclass_foreach_dev(blk, uc)
+ count++;
+
+ return count;
+}
+
+/* Test that block devices work correctly with USB */
+static int dm_test_blk_usb(struct unit_test_state *uts)
+{
+ struct udevice *usb_dev, *dev;
+ struct blk_desc *dev_desc;
+
+ /* Get a flash device */
+ state_set_skip_delays(true);
+ ut_assertok(usb_init());
+ ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &usb_dev));
+ ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));
+
+ /* The parent should be a block device */
+ ut_assertok(blk_get_device(IF_TYPE_USB, 0, &dev));
+ ut_asserteq_ptr(usb_dev, dev_get_parent(dev));
+
+ /* Check we have one block device for each mass storage device */
+ ut_asserteq(3, count_blk_devices());
+
+ /* Now go around again, making sure the old devices were unbound */
+ ut_assertok(usb_stop());
+ ut_assertok(usb_init());
+ ut_asserteq(3, count_blk_devices());
+ ut_assertok(usb_stop());
+
+ return 0;
+}
+DM_TEST(dm_test_blk_usb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 31/32] part: Rename test_part_xx() and print_part_xx()
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (28 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 30/32] dm: blk: Add tests for block devices Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-02-29 22:26 ` [U-Boot] [PATCH v2 32/32] Drop CONFIG_CRAMFS_CMDLINE Simon Glass
` (2 subsequent siblings)
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
Rename these functions so that part_ is at the start. This more clearly
identifies these functions as partition functions.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add new patch to rename test_part_xx() and print_part_xx()
disk/part_amiga.c | 22 +++++++++++-----------
disk/part_dos.c | 8 ++++----
disk/part_efi.c | 8 ++++----
disk/part_iso.c | 8 ++++----
disk/part_mac.c | 8 ++++----
5 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 4a67689..d4316b8 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -207,27 +207,27 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
* Test if the given partition has an Amiga partition table/Rigid
* Disk block
*/
-static int test_part_amiga(struct blk_desc *dev_desc)
+static int part_test_amiga(struct blk_desc *dev_desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *bootcode;
- PRINTF("test_part_amiga: Testing for an Amiga RDB partition\n");
+ PRINTF("part_test_amiga: Testing for an Amiga RDB partition\n");
rdb = get_rdisk(dev_desc);
if (rdb)
{
bootcode = get_bootcode(dev_desc);
if (bootcode)
- PRINTF("test_part_amiga: bootable Amiga disk\n");
+ PRINTF("part_test_amiga: bootable Amiga disk\n");
else
- PRINTF("test_part_amiga: non-bootable Amiga disk\n");
+ PRINTF("part_test_amiga: non-bootable Amiga disk\n");
return 0;
}
else
{
- PRINTF("test_part_amiga: no RDB found\n");
+ PRINTF("part_test_amiga: no RDB found\n");
return -1;
}
@@ -318,7 +318,7 @@ static int part_get_info_amiga(struct blk_desc *dev_desc, int part,
return 0;
}
-static void print_part_amiga(struct blk_desc *dev_desc)
+static void part_print_amiga(struct blk_desc *dev_desc)
{
struct rigid_disk_block *rdb;
struct bootcode_block *boot;
@@ -329,14 +329,14 @@ static void print_part_amiga(struct blk_desc *dev_desc)
rdb = get_rdisk(dev_desc);
if (!rdb)
{
- PRINTF("print_part_amiga: no rdb found\n");
+ PRINTF("part_print_amiga: no rdb found\n");
return;
}
- PRINTF("print_part_amiga: Scanning partition list\n");
+ PRINTF("part_print_amiga: Scanning partition list\n");
block = rdb->partition_list;
- PRINTF("print_part_amiga: partition list at 0x%x\n", block);
+ PRINTF("part_print_amiga: partition list at 0x%x\n", block);
printf("Summary: DiskBlockSize: %d\n"
" Cylinders : %d\n"
@@ -382,8 +382,8 @@ U_BOOT_PART_TYPE(amiga) = {
.name = "AMIGA",
.part_type = PART_TYPE_AMIGA,
.get_info = part_get_info_amiga,
- .print = print_part_amiga,
- .test = test_part_amiga,
+ .print = part_print_amiga,
+ .test = part_test_amiga,
};
#endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 0ed1374..511917a 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -87,7 +87,7 @@ static int test_block_type(unsigned char *buffer)
}
-static int test_part_dos(struct blk_desc *dev_desc)
+static int part_test_dos(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
@@ -285,7 +285,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
return -1;
}
-void print_part_dos(struct blk_desc *dev_desc)
+void part_print_dos(struct blk_desc *dev_desc)
{
printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n");
print_partition_extended(dev_desc, 0, 0, 1, 0);
@@ -301,8 +301,8 @@ U_BOOT_PART_TYPE(dos) = {
.name = "DOS",
.part_type = PART_TYPE_DOS,
.get_info = part_get_info_ptr(part_get_info_dos),
- .print = part_print_ptr(print_part_dos),
- .test = test_part_dos,
+ .print = part_print_ptr(part_print_dos),
+ .test = part_test_dos,
};
#endif
diff --git a/disk/part_efi.c b/disk/part_efi.c
index b20907b..77bdfcb 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -176,7 +176,7 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h)
* Public Functions (include/part.h)
*/
-void print_part_efi(struct blk_desc *dev_desc)
+void part_print_efi(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz);
gpt_entry *gpt_pte = NULL;
@@ -319,7 +319,7 @@ int part_get_info_efi_by_name(struct blk_desc *dev_desc,
return -2;
}
-static int test_part_efi(struct blk_desc *dev_desc)
+static int part_test_efi(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
@@ -959,7 +959,7 @@ U_BOOT_PART_TYPE(a_efi) = {
.name = "EFI",
.part_type = PART_TYPE_EFI,
.get_info = part_get_info_ptr(part_get_info_efi),
- .print = part_print_ptr(print_part_efi),
- .test = test_part_efi,
+ .print = part_print_ptr(part_print_efi),
+ .test = part_test_efi,
};
#endif
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 76eab39..b83983b 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -223,7 +223,7 @@ static int part_get_info_iso(struct blk_desc *dev_desc, int part_num,
return part_get_info_iso_verb(dev_desc, part_num, info, 1);
}
-static void print_part_iso(struct blk_desc *dev_desc)
+static void part_print_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
int i;
@@ -242,7 +242,7 @@ static void print_part_iso(struct blk_desc *dev_desc)
} while (part_get_info_iso_verb(dev_desc, i, &info, 0) != -1);
}
-static int test_part_iso(struct blk_desc *dev_desc)
+static int part_test_iso(struct blk_desc *dev_desc)
{
disk_partition_t info;
@@ -253,7 +253,7 @@ U_BOOT_PART_TYPE(iso) = {
.name = "ISO",
.part_type = PART_TYPE_ISO,
.get_info = part_get_info_iso,
- .print = print_part_iso,
- .test = test_part_iso,
+ .print = part_print_iso,
+ .test = part_test_iso,
};
#endif
diff --git a/disk/part_mac.c b/disk/part_mac.c
index ce57b57..3952b8d 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -40,7 +40,7 @@ static int part_mac_read_pdb(struct blk_desc *dev_desc, int part,
/*
* Test for a valid MAC partition
*/
-static int test_part_mac(struct blk_desc *dev_desc)
+static int part_test_mac(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
ALLOC_CACHE_ALIGN_BUFFER(mac_partition_t, mpart, 1);
@@ -63,7 +63,7 @@ static int test_part_mac(struct blk_desc *dev_desc)
return (0);
}
-static void print_part_mac(struct blk_desc *dev_desc)
+static void part_print_mac(struct blk_desc *dev_desc)
{
ulong i, n;
ALLOC_CACHE_ALIGN_BUFFER(mac_driver_desc_t, ddesc, 1);
@@ -240,7 +240,7 @@ U_BOOT_PART_TYPE(mac) = {
.name = "MAC",
.part_type = PART_TYPE_MAC,
.get_info = part_get_info_mac,
- .print = print_part_mac,
- .test = test_part_mac,
+ .print = part_print_mac,
+ .test = part_test_mac,
};
#endif
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 31/32] part: Rename test_part_xx() and print_part_xx()
2016-02-29 22:26 ` [U-Boot] [PATCH v2 31/32] part: Rename test_part_xx() and print_part_xx() Simon Glass
@ 2016-03-13 1:53 ` Simon Glass
0 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:53 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:26, Simon Glass <sjg@chromium.org> wrote:
> Rename these functions so that part_ is at the start. This more clearly
> identifies these functions as partition functions.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Add new patch to rename test_part_xx() and print_part_xx()
>
> disk/part_amiga.c | 22 +++++++++++-----------
> disk/part_dos.c | 8 ++++----
> disk/part_efi.c | 8 ++++----
> disk/part_iso.c | 8 ++++----
> disk/part_mac.c | 8 ++++----
> 5 files changed, 27 insertions(+), 27 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread
* [U-Boot] [PATCH v2 32/32] Drop CONFIG_CRAMFS_CMDLINE
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (29 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 31/32] part: Rename test_part_xx() and print_part_xx() Simon Glass
@ 2016-02-29 22:26 ` Simon Glass
2016-03-13 1:53 ` Simon Glass
2016-03-01 19:29 ` [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Stephen Warren
2016-03-13 1:52 ` Simon Glass
32 siblings, 1 reply; 68+ messages in thread
From: Simon Glass @ 2016-02-29 22:26 UTC (permalink / raw)
To: u-boot
This option doesn't do anything. Drop it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
cmd/cramfs.c | 5 -----
include/configs/UCP1020.h | 1 -
include/configs/km/keymile-common.h | 1 -
include/configs/sandbox.h | 1 -
4 files changed, 8 deletions(-)
diff --git a/cmd/cramfs.c b/cmd/cramfs.c
index 270701b..c103491 100644
--- a/cmd/cramfs.c
+++ b/cmd/cramfs.c
@@ -29,7 +29,6 @@
# define DEBUGF(fmt, args...)
#endif
-#ifdef CONFIG_CRAMFS_CMDLINE
#include <flash.h>
#ifdef CONFIG_SYS_NO_FLASH
@@ -201,7 +200,3 @@ U_BOOT_CMD(
"[ directory ]\n"
" - list files in a directory.\n"
);
-
-#endif /* #ifdef CONFIG_CRAMFS_CMDLINE */
-
-/***************************************************/
diff --git a/include/configs/UCP1020.h b/include/configs/UCP1020.h
index 2354009..c21af1c 100644
--- a/include/configs/UCP1020.h
+++ b/include/configs/UCP1020.h
@@ -495,7 +495,6 @@
#define CONFIG_CMD_REGINFO
#define CONFIG_CMD_ERRATA
#define CONFIG_CMD_CRAMFS
-#define CONFIG_CRAMFS_CMDLINE
/*
* USB
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h
index 91b29b3..5edc8f6 100644
--- a/include/configs/km/keymile-common.h
+++ b/include/configs/km/keymile-common.h
@@ -83,7 +83,6 @@
#define CONFIG_MTD_CONCAT
#define CONFIG_CMD_CRAMFS
-#define CONFIG_CRAMFS_CMDLINE
#ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
#define CONFIG_KM_DEF_ENV_BOOTPARAMS \
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index f73d040..b7090c8 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -46,7 +46,6 @@
#define CONFIG_CMD_EXT4_WRITE
#define CONFIG_CMD_CBFS
#define CONFIG_CMD_CRAMFS
-#define CONFIG_CRAMFS_CMDLINE
#define CONFIG_CMD_PART
#define CONFIG_DOS_PARTITION
#define CONFIG_HOST_MAX_DEVICES 4
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (30 preceding siblings ...)
2016-02-29 22:26 ` [U-Boot] [PATCH v2 32/32] Drop CONFIG_CRAMFS_CMDLINE Simon Glass
@ 2016-03-01 19:29 ` Stephen Warren
2016-03-13 1:52 ` Simon Glass
32 siblings, 0 replies; 68+ messages in thread
From: Stephen Warren @ 2016-03-01 19:29 UTC (permalink / raw)
To: u-boot
On 02/29/2016 03:25 PM, Simon Glass wrote:
> Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
> and causes 80-column violations, rename it to struct blk_desc.
The series,
Tested-by: Stephen Warren <swarren@nvidia.com>
^ permalink raw reply [flat|nested] 68+ messages in thread* [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef
2016-02-29 22:25 [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Simon Glass
` (31 preceding siblings ...)
2016-03-01 19:29 ` [U-Boot] [PATCH v2 01/32] dm: Drop the block_dev_desc_t typedef Stephen Warren
@ 2016-03-13 1:52 ` Simon Glass
32 siblings, 0 replies; 68+ messages in thread
From: Simon Glass @ 2016-03-13 1:52 UTC (permalink / raw)
To: u-boot
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long
> and causes 80-column violations, rename it to struct blk_desc.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
> api/api.c | 2 +-
> api/api_storage.c | 14 ++---
> board/cm5200/fwupdate.c | 2 +-
> board/mpl/pip405/README | 4 +-
> cmd/disk.c | 2 +-
> cmd/fat.c | 4 +-
> cmd/gpt.c | 8 +--
> cmd/host.c | 4 +-
> cmd/ide.c | 22 ++++----
> cmd/mmc.c | 2 +-
> cmd/part.c | 8 +--
> cmd/read.c | 4 +-
> cmd/reiser.c | 4 +-
> cmd/sata.c | 10 ++--
> cmd/scsi.c | 12 ++---
> cmd/unzip.c | 2 +-
> cmd/usb.c | 2 +-
> cmd/usb_mass_storage.c | 6 +--
> cmd/zfs.c | 4 +-
> common/env_fat.c | 4 +-
> common/fb_mmc.c | 12 ++---
> common/spl/spl_ext.c | 6 +--
> common/spl/spl_fat.c | 8 +--
> common/spl/spl_sata.c | 2 +-
> common/spl/spl_usb.c | 2 +-
> common/usb_storage.c | 22 ++++----
> disk/part.c | 28 +++++-----
> disk/part_amiga.c | 14 ++---
> disk/part_dos.c | 19 +++----
> disk/part_efi.c | 38 ++++++-------
> disk/part_iso.c | 10 ++--
> disk/part_mac.c | 19 ++++---
> drivers/block/dwc_ahsata.c | 4 +-
> drivers/block/sandbox.c | 12 ++---
> drivers/block/systemace.c | 8 +--
> drivers/dfu/dfu_mmc.c | 2 +-
> drivers/mmc/mmc.c | 4 +-
> drivers/mmc/mmc_private.h | 8 +--
> drivers/mmc/mmc_write.c | 4 +-
> fs/ext4/dev.c | 53 +++++++++---------
> fs/ext4/ext4fs.c | 2 +-
> fs/fat/fat.c | 6 +--
> fs/fs.c | 6 +--
> fs/reiserfs/dev.c | 33 +++++-------
> fs/sandbox/sandboxfs.c | 4 +-
> fs/ubifs/ubifs.c | 2 +-
> fs/zfs/dev.c | 35 ++++++------
> fs/zfs/zfs.c | 2 +-
> include/common.h | 2 +-
> include/ext4fs.h | 6 +--
> include/fat.h | 4 +-
> include/ide.h | 6 +--
> include/mmc.h | 2 +-
> include/part.h | 130 ++++++++++++++++++++++++---------------------
> include/reiserfs.h | 2 +-
> include/sandboxblockdev.h | 2 +-
> include/sandboxfs.h | 2 +-
> include/sata.h | 2 +-
> include/spl.h | 10 ++--
> include/systemace.h | 2 +-
> include/ubifs_uboot.h | 2 +-
> include/usb.h | 2 +-
> include/usb_mass_storage.h | 2 +-
> include/zfs_common.h | 4 +-
> lib/gunzip.c | 2 +-
> test/dm/usb.c | 2 +-
> 66 files changed, 338 insertions(+), 331 deletions(-)
Applied to u-boot-dm/next.
^ permalink raw reply [flat|nested] 68+ messages in thread