diff options
author | Simon Glass <sjg@chromium.org> | 2016-02-29 15:25:52 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-03-14 15:34:50 -0600 |
commit | 2a981dc2c62c500110aad297fa70503aec36e689 (patch) | |
tree | a2098718e857b136986ee0401a40037b16e51a3a /include/blk.h | |
parent | bcce53d048de7f41078d25e39aa2f26d752d3658 (diff) |
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.h | 29 |
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 |