summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-02-29 15:25:56 -0700
committerSimon Glass <sjg@chromium.org>2016-03-14 15:34:50 -0600
commit7ded959e4d5b93c10a8b57a0a391fb35cefb85ce (patch)
tree84bd5d2819b7b53a2f6d61557aaf35061f35dfb3 /drivers
parent09d71aac7b530f03ec29cc9d5787047460a629ca (diff)
dm: sandbox: Prepare block driver for driver-model conversion
Make a few minor changes to make it easier to add driver-model support. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/sandbox.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 14d3e38ef20..dde9d6845f7 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;