summaryrefslogtreecommitdiffstats
path: root/include/blk.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-02-29 15:25:52 -0700
committerSimon Glass <sjg@chromium.org>2016-03-14 15:34:50 -0600
commit2a981dc2c62c500110aad297fa70503aec36e689 (patch)
treea2098718e857b136986ee0401a40037b16e51a3a /include/blk.h
parentbcce53d048de7f41078d25e39aa2f26d752d3658 (diff)
downloadtalos-obmc-uboot-2a981dc2c62c500110aad297fa70503aec36e689.tar.gz
talos-obmc-uboot-2a981dc2c62c500110aad297fa70503aec36e689.zip
dm: block: Adjust device calls to go through helpers function
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> Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'include/blk.h')
-rw-r--r--include/blk.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/blk.h b/include/blk.h
index 9c54842961..7b2e5e286f 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
OpenPOWER on IntegriCloud