X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fio%2Fkblock.h;h=8d68c8e9eca3cd496d7f676ea2f72ca93daa143d;hb=30a088bc2641f3e11c414dd32c672242099a9f5b;hp=7775d7b87f14f9f28df7c014b89f6f3e15fb2bda;hpb=09befbcd1ee296ad30790e303adec8dc1a104f07;p=bertos.git diff --git a/bertos/io/kblock.h b/bertos/io/kblock.h index 7775d7b8..8d68c8e9 100644 --- a/bertos/io/kblock.h +++ b/bertos/io/kblock.h @@ -66,7 +66,7 @@ typedef int (* kblock_load_t) (struct KBlock *b, block_idx_t index); typedef int (* kblock_store_t) (struct KBlock *b, block_idx_t index); typedef int (* kblock_error_t) (struct KBlock *b); -typedef int (* kblock_clearerr_t) (struct KBlock *b); +typedef void (* kblock_clearerr_t) (struct KBlock *b); typedef int (* kblock_close_t) (struct KBlock *b); /* \} */ @@ -202,16 +202,27 @@ INLINE int kblock_error(struct KBlock *b) * * \param b KBlock device. * - * \return 0 on success, EOF on errors. * * \sa kblock_error() */ -INLINE int kblock_clearerr(struct KBlock *b) +INLINE void kblock_clearerr(struct KBlock *b) { KB_ASSERT_METHOD(b, clearerr); - return b->priv.vt->clearerr(b); + b->priv.vt->clearerr(b); } + +/** + * Flush the cache (if any) to the device. + * + * This function will write any pending modifications to the device. + * If the device does not have a cache, this function will do nothing. + * + * \return 0 if all is OK, EOF on errors. + * \sa kblock_read(), kblock_write(), kblock_buffered(). + */ +int kblock_flush(struct KBlock *b); + /** * Close the device. * @@ -222,7 +233,7 @@ INLINE int kblock_clearerr(struct KBlock *b) INLINE int kblock_close(struct KBlock *b) { KB_ASSERT_METHOD(b, close); - return b->priv.vt->close(b); + return kblock_flush(b) | b->priv.vt->close(b); } /** @@ -331,19 +342,6 @@ size_t kblock_read(struct KBlock *b, block_idx_t idx, void *buf, size_t offset, */ size_t kblock_write(struct KBlock *b, block_idx_t idx, const void *buf, size_t offset, size_t size); - -/** - * Flush the cache (if any) to the device. - * - * This function will write any pending modifications to the device. - * If the device does not have a cache, this function will do nothing. - * - * \return 0 if all is OK, EOF on errors. - * \sa kblock_read(), kblock_write(), kblock_buffered(). - */ -int kblock_flush(struct KBlock *b); - - /** * Copy one block to another. *