summaryrefslogtreecommitdiffstats
path: root/common/block.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-30 06:01:02 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-30 06:01:02 +0200
commit949b03dfb16a48b873831e58f580dec14a91e679 (patch)
tree21ef5e6fb203e819a1e4ce62b26bde588cd4c27f /common/block.c
parent41aba3e7ca3886d78b281aef6dda68fce60227e3 (diff)
downloadbarebox-949b03dfb16a48b873831e58f580dec14a91e679.tar.gz
block: propagate error code from block_get
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/block.c')
-rw-r--r--common/block.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/common/block.c b/common/block.c
index 4253fc4..437dc95 100644
--- a/common/block.c
+++ b/common/block.c
@@ -161,7 +161,7 @@ static void *block_get(struct block_device *blk, int block)
int ret;
if (block >= blk->num_blocks)
- return NULL;
+ return ERR_PTR(-ENXIO);
outdata = block_get_cached(blk, block);
if (outdata)
@@ -169,7 +169,7 @@ static void *block_get(struct block_device *blk, int block)
ret = block_cache(blk, block);
if (ret)
- return NULL;
+ return ERR_PTR(ret);
outdata = block_get_cached(blk, block);
if (!outdata)
@@ -191,8 +191,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,
size_t now = BLOCKSIZE(blk) - (offset & mask);
void *iobuf = block_get(blk, block);
- if (!iobuf)
- return -EIO;
+ if (IS_ERR(iobuf))
+ return PTR_ERR(iobuf);
now = min(count, now);
@@ -207,8 +207,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,
while (blocks) {
void *iobuf = block_get(blk, block);
- if (!iobuf)
- return -EIO;
+ if (IS_ERR(iobuf))
+ return PTR_ERR(iobuf);
memcpy(buf, iobuf, BLOCKSIZE(blk));
buf += BLOCKSIZE(blk);
@@ -220,8 +220,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,
if (count) {
void *iobuf = block_get(blk, block);
- if (!iobuf)
- return -EIO;
+ if (IS_ERR(iobuf))
+ return PTR_ERR(iobuf);
memcpy(buf, iobuf, count);
}
@@ -244,7 +244,7 @@ static int block_put(struct block_device *blk, const void *buf, int block)
return -EINVAL;
data = block_get(blk, block);
- if (!data)
+ if (IS_ERR(data))
BUG();
memcpy(data, buf, 1 << blk->blockbits);
@@ -270,8 +270,8 @@ static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,
now = min(count, now);
- if (!iobuf)
- return -EIO;
+ if (IS_ERR(iobuf))
+ return PTR_ERR(iobuf);
memcpy(iobuf + (offset & mask), buf, now);
ret = block_put(blk, iobuf, block);
@@ -299,8 +299,8 @@ static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,
if (count) {
void *iobuf = block_get(blk, block);
- if (!iobuf)
- return -EIO;
+ if (IS_ERR(iobuf))
+ return PTR_ERR(iobuf);
memcpy(iobuf, buf, count);
ret = block_put(blk, iobuf, block);