Update to latest KBlock low level API.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 5 Jul 2010 22:20:11 +0000 (22:20 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 5 Jul 2010 22:20:11 +0000 (22:20 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3998 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/io/kblock_file.c
bertos/io/kblock_ram.c

index 69e9e12cd6608629dca4222fd3165bbc037a7625..ae680815ade31890bcd18693a2f3bf405819e18a 100644 (file)
@@ -88,15 +88,6 @@ static int kblockfile_writeBlock(struct KBlock *b, block_idx_t index, const void
        return (fwrite(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF;
 }
 
-static int kblockfile_readBlock(struct KBlock *b, block_idx_t index, void *buf)
-{
-       KBlockFile *f = KBLOCKFILE_CAST(b);
-       ASSERT(buf);
-       ASSERT(index < b->blk_cnt);
-       fseek(f->fp, index * b->blk_size, SEEK_SET);
-       return (fread(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF;
-}
-
 static int kblockfile_error(struct KBlock *b)
 {
        KBlockFile *f = KBLOCKFILE_CAST(b);
@@ -123,14 +114,12 @@ static int kblockfile_close(struct KBlock *b)
 static const KBlockVTable kblockfile_hwbuffered_vt =
 {
        .readDirect = kblockfile_readDirect,
+
        .readBuf = kblockfile_readBuf,
        .writeBuf = kblockfile_writeBuf,
        .load = kblockfile_load,
        .store = kblockfile_store,
        
-       .readBlock = kblock_swReadBlock,
-       .writeBlock = kblock_swWriteBlock,
-
        .error = kblockfile_error,
        .clearerr = kblockfile_claererr,
        .close = kblockfile_close,
@@ -138,15 +127,14 @@ static const KBlockVTable kblockfile_hwbuffered_vt =
 
 static const KBlockVTable kblockfile_swbuffered_vt =
 {
-       .readDirect = kblock_swReadDirect,
+       .readDirect = kblockfile_readDirect,
+       .writeBlock =kblockfile_writeBlock,
+       
        .readBuf = kblock_swReadBuf,
        .writeBuf = kblock_swWriteBuf,
        .load = kblock_swLoad,
        .store = kblock_swStore,
        
-       .readBlock = kblockfile_readBlock,
-       .writeBlock =kblockfile_writeBlock,
-
        .error = kblockfile_error,
        .clearerr = kblockfile_claererr,
        .close = kblockfile_close,
@@ -154,7 +142,7 @@ static const KBlockVTable kblockfile_swbuffered_vt =
 
 static const KBlockVTable kblockfile_unbuffered_vt =
 {
-       .readBlock = kblockfile_readBlock,
+       .readDirect = kblockfile_readDirect,
        .writeBlock =kblockfile_writeBlock,
 
        .error = kblockfile_error,
index 3af08b80626b2f930b0d4dca7bf232e680c6000f..eff9675f721d30f9f34f61537518e21b36d68cfb 100644 (file)
@@ -85,16 +85,6 @@ static int kblockram_writeBlock(struct KBlock *b, block_idx_t index, const void
        return 0;
 }
 
-static int kblockram_readBlock(struct KBlock *b, block_idx_t index, void *buf)
-{
-       KBlockRam *r = KBLOCKRAM_CAST(b);
-       ASSERT(buf);
-       ASSERT(index < b->blk_cnt);
-
-       memcpy(buf, r->membuf + index * r->b.blk_size, r->b.blk_size);
-       return 0;
-}
-
 static int kblockram_dummy(UNUSED_ARG(struct KBlock *,b))
 {
        return 0;
@@ -103,14 +93,12 @@ static int kblockram_dummy(UNUSED_ARG(struct KBlock *,b))
 static const KBlockVTable kblockram_hwbuffered_vt =
 {
        .readDirect = kblockram_readDirect,
+       
        .readBuf = kblockram_readBuf,
        .writeBuf = kblockram_writeBuf,
        .load = kblockram_load,
        .store = kblockram_store,
        
-       .readBlock = kblock_swReadBlock,
-       .writeBlock = kblock_swWriteBlock,
-
        .error = kblockram_dummy,
        .clearerr = kblockram_dummy,
        .close = kblockram_dummy,
@@ -119,15 +107,14 @@ static const KBlockVTable kblockram_hwbuffered_vt =
 
 static const KBlockVTable kblockram_swbuffered_vt =
 {
-       .readDirect = kblock_swReadDirect,
+       .readDirect = kblockram_readDirect,
+       .writeBlock = kblockram_writeBlock,
+       
        .readBuf = kblock_swReadBuf,
        .writeBuf = kblock_swWriteBuf,
        .load = kblock_swLoad,
        .store = kblock_swStore,
-       
-       .readBlock = kblockram_readBlock,
-       .writeBlock = kblockram_writeBlock,
-
+               
        .error = kblockram_dummy,
        .clearerr = kblockram_dummy,
        .close = kblockram_dummy,
@@ -135,7 +122,7 @@ static const KBlockVTable kblockram_swbuffered_vt =
 
 static const KBlockVTable kblockram_unbuffered_vt =
 {
-       .readBlock = kblockram_readBlock,
+       .readDirect = kblockram_readDirect,
        .writeBlock = kblockram_writeBlock,
 
        .error = kblockram_dummy,