Hi Sascha<br><br><div class="gmail_quote">On Wed, May 30, 2012 at 7:31 AM, Sascha Hauer <span dir="ltr"><<a href="mailto:s.hauer@pengutronix.de" target="_blank">s.hauer@pengutronix.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Signed-off-by: Sascha Hauer <<a href="mailto:s.hauer@pengutronix.de">s.hauer@pengutronix.de</a>><br>
---<br>
 common/block.c |   26 +++++++++++++-------------<br>
 1 file changed, 13 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/common/block.c b/common/block.c<br>
index 4253fc4..437dc95 100644<br>
--- a/common/block.c<br>
+++ b/common/block.c<br>
@@ -161,7 +161,7 @@ static void *block_get(struct block_device *blk, int block)<br>
        int ret;<br>
<br>
        if (block >= blk->num_blocks)<br>
-               return NULL;<br>
+               return ERR_PTR(-ENXIO);<br>
<br>
        outdata = block_get_cached(blk, block);<br>
        if (outdata)<br>
@@ -169,7 +169,7 @@ static void *block_get(struct block_device *blk, int block)<br>
<br>
        ret = block_cache(blk, block);<br>
        if (ret)<br>
-               return NULL;<br>
+               return ERR_PTR(ret);<br>
<br>
        outdata = block_get_cached(blk, block);<br>
        if (!outdata)<br>
@@ -191,8 +191,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,<br>
                size_t now = BLOCKSIZE(blk) - (offset & mask);<br>
                void *iobuf = block_get(blk, block);<br>
<br>
-               if (!iobuf)<br>
-                       return -EIO;<br>
+               if (IS_ERR(iobuf))<br>
+                       return PTR_ERR(iobuf);<br>
<br>
                now = min(count, now);<br>
<br>
@@ -207,8 +207,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,<br>
        while (blocks) {<br>
                void *iobuf = block_get(blk, block);<br>
<br>
-               if (!iobuf)<br>
-                       return -EIO;<br>
+               if (IS_ERR(iobuf))<br>
+                       return PTR_ERR(iobuf);<br>
<br>
                memcpy(buf, iobuf, BLOCKSIZE(blk));<br>
                buf += BLOCKSIZE(blk);<br>
@@ -220,8 +220,8 @@ static ssize_t block_read(struct cdev *cdev, void *buf, size_t count,<br>
        if (count) {<br>
                void *iobuf = block_get(blk, block);<br>
<br>
-               if (!iobuf)<br>
-                       return -EIO;<br>
+               if (IS_ERR(iobuf))<br>
+                       return PTR_ERR(iobuf);<br>
<br>
                memcpy(buf, iobuf, count);<br>
        }<br>
@@ -244,7 +244,7 @@ static int block_put(struct block_device *blk, const void *buf, int block)<br>
                return -EINVAL;<br>
<br>
        data = block_get(blk, block);<br>
-       if (!data)<br>
+       if (IS_ERR(data))<br>
                BUG();<br>
<br>
        memcpy(data, buf, 1 << blk->blockbits);<br>
@@ -270,8 +270,8 @@ static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,<br>
<br>
                now = min(count, now);<br>
<br>
-               if (!iobuf)<br>
-                       return -EIO;<br>
+               if (IS_ERR(iobuf))<br>
+                       return PTR_ERR(iobuf);<br>
<br>
                memcpy(iobuf + (offset & mask), buf, now);<br>
                ret = block_put(blk, iobuf, block);<br>
@@ -299,8 +299,8 @@ static ssize_t block_write(struct cdev *cdev, const void *buf, size_t count,<br>
        if (count) {<br>
                void *iobuf = block_get(blk, block);<br>
<br>
-               if (!iobuf)<br>
-                       return -EIO;<br>
+               if (IS_ERR(iobuf))<br>
+                       return PTR_ERR(iobuf);<br>
<br>
                memcpy(iobuf, buf, count);<br>
                ret = block_put(blk, iobuf, block);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10<br>
<br>
</font></span></blockquote></div><br><div>Compile and run-time tested; results in a proper error message propagated by the block layer:</div><div><br></div><div><div>imx-esdhc@imx-esdhc0: timeout 1</div><div>mci@mci0: Reading block 2560 failed with -110</div>

<div>block_cache: blk->ops->read returned -110</div></div><div><br></div><div>Therefore:</div><div><br></div><div>Tested-by: Roberto Nibali <<a href="mailto:rnibali@gmail.com">rnibali@gmail.com</a>></div><div>

Acked-by: Roberto Nibali <<a href="mailto:rnibali@gmail.com">rnibali@gmail.com</a>></div><div><br></div><div>Cheers</div><div>Roberto</div>