From: qwert Date: Thu, 7 Aug 2008 13:31:50 +0000 (+0000) Subject: Refactor DATAFLASH macro in DATAFLASH_CAST X-Git-Tag: 2.0.0~366 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=76212275e24e8de64e16e5d8158c60cd3150ab32;p=bertos.git Refactor DATAFLASH macro in DATAFLASH_CAST git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1568 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/dataflash.c b/bertos/drv/dataflash.c index 5347d451..554d15b8 100644 --- a/bertos/drv/dataflash.c +++ b/bertos/drv/dataflash.c @@ -287,7 +287,7 @@ static void dataflash_loadPage(DataFlash *fd, dataflash_page_t page_addr) */ static int dataflash_flush(KFile *_fd) { - DataFlash *fd = DATAFLASH(_fd); + DataFlash *fd = DATAFLASH_CAST(_fd); if (fd->page_dirty) { dataflash_cmd(fd, fd->current_page, 0x00, DFO_WRITE_BUFF1_TO_MEM_E); @@ -316,7 +316,7 @@ static int dataflash_close(struct KFile *_fd) */ static KFile *dataflash_reopen(KFile *_fd) { - DataFlash *fd = DATAFLASH(_fd); + DataFlash *fd = DATAFLASH_CAST(_fd); dataflash_close(_fd); fd->current_page = 0; @@ -344,7 +344,7 @@ static KFile *dataflash_reopen(KFile *_fd) */ static size_t dataflash_read(struct KFile *_fd, void *buf, size_t size) { - DataFlash *fd = DATAFLASH(_fd); + DataFlash *fd = DATAFLASH_CAST(_fd); dataflash_offset_t byte_addr; dataflash_page_t page_addr; @@ -394,7 +394,7 @@ static size_t dataflash_read(struct KFile *_fd, void *buf, size_t size) */ static size_t dataflash_write(struct KFile *_fd, const void *_buf, size_t size) { - DataFlash *fd = DATAFLASH(_fd); + DataFlash *fd = DATAFLASH_CAST(_fd); dataflash_offset_t offset; dataflash_page_t new_page; diff --git a/bertos/drv/dataflash.h b/bertos/drv/dataflash.h index ff5b662b..1da6105b 100644 --- a/bertos/drv/dataflash.h +++ b/bertos/drv/dataflash.h @@ -100,7 +100,7 @@ typedef struct DataFlash /** * Convert + ASSERT from generic KFile to DataFlash. */ -INLINE DataFlash * DATAFLASH(KFile *fd) +INLINE DataFlash * DATAFLASH_CAST(KFile *fd) { ASSERT(fd->_type == KFT_DATAFLASH); return (DataFlash *)fd;