[driver][mtd_nand] Formatting code.|格式化代码。

This commit is contained in:
guozhanxin 2019-06-19 17:14:44 +08:00
parent d8702aa568
commit c421757cc4
2 changed files with 166 additions and 166 deletions

View File

@ -45,71 +45,71 @@ struct rt_mtd_nand_device
rt_uint32_t block_end; /* The end of available block */ rt_uint32_t block_end; /* The end of available block */
/* operations interface */ /* operations interface */
const struct rt_mtd_nand_driver_ops* ops; const struct rt_mtd_nand_driver_ops *ops;
}; };
struct rt_mtd_nand_driver_ops struct rt_mtd_nand_driver_ops
{ {
rt_err_t (*read_id) (struct rt_mtd_nand_device* device); rt_err_t (*read_id)(struct rt_mtd_nand_device *device);
rt_err_t (*read_page)(struct rt_mtd_nand_device* device, rt_err_t (*read_page)(struct rt_mtd_nand_device *device,
rt_off_t page, rt_off_t page,
rt_uint8_t* data, rt_uint32_t data_len, rt_uint8_t *data, rt_uint32_t data_len,
rt_uint8_t * spare, rt_uint32_t spare_len); rt_uint8_t *spare, rt_uint32_t spare_len);
rt_err_t (*write_page)(struct rt_mtd_nand_device * device, rt_err_t (*write_page)(struct rt_mtd_nand_device *device,
rt_off_t page, rt_off_t page,
const rt_uint8_t * data, rt_uint32_t data_len, const rt_uint8_t *data, rt_uint32_t data_len,
const rt_uint8_t * spare, rt_uint32_t spare_len); const rt_uint8_t *spare, rt_uint32_t spare_len);
rt_err_t (*move_page) (struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page); rt_err_t (*move_page)(struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page);
rt_err_t (*erase_block)(struct rt_mtd_nand_device* device, rt_uint32_t block); rt_err_t (*erase_block)(struct rt_mtd_nand_device *device, rt_uint32_t block);
rt_err_t (*check_block)(struct rt_mtd_nand_device* device, rt_uint32_t block); rt_err_t (*check_block)(struct rt_mtd_nand_device *device, rt_uint32_t block);
rt_err_t (*mark_badblock)(struct rt_mtd_nand_device* device, rt_uint32_t block); rt_err_t (*mark_badblock)(struct rt_mtd_nand_device *device, rt_uint32_t block);
}; };
rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device* device); rt_err_t rt_mtd_nand_register_device(const char *name, struct rt_mtd_nand_device *device);
rt_inline rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device* device) rt_inline rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device *device)
{ {
return device->ops->read_id(device); return device->ops->read_id(device);
} }
rt_inline rt_err_t rt_mtd_nand_read( rt_inline rt_err_t rt_mtd_nand_read(
struct rt_mtd_nand_device* device, struct rt_mtd_nand_device *device,
rt_off_t page, rt_off_t page,
rt_uint8_t* data, rt_uint32_t data_len, rt_uint8_t *data, rt_uint32_t data_len,
rt_uint8_t * spare, rt_uint32_t spare_len) rt_uint8_t *spare, rt_uint32_t spare_len)
{ {
return device->ops->read_page(device, page, data, data_len, spare, spare_len); return device->ops->read_page(device, page, data, data_len, spare, spare_len);
} }
rt_inline rt_err_t rt_mtd_nand_write( rt_inline rt_err_t rt_mtd_nand_write(
struct rt_mtd_nand_device* device, struct rt_mtd_nand_device *device,
rt_off_t page, rt_off_t page,
const rt_uint8_t* data, rt_uint32_t data_len, const rt_uint8_t *data, rt_uint32_t data_len,
const rt_uint8_t * spare, rt_uint32_t spare_len) const rt_uint8_t *spare, rt_uint32_t spare_len)
{ {
return device->ops->write_page(device, page, data, data_len, spare, spare_len); return device->ops->write_page(device, page, data, data_len, spare, spare_len);
} }
rt_inline rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device* device, rt_inline rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device *device,
rt_off_t src_page, rt_off_t dst_page) rt_off_t src_page, rt_off_t dst_page)
{ {
return device->ops->move_page(device, src_page, dst_page); return device->ops->move_page(device, src_page, dst_page);
} }
rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device* device, rt_uint32_t block) rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
{ {
return device->ops->erase_block(device, block); return device->ops->erase_block(device, block);
} }
rt_inline rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device* device, rt_uint32_t block) rt_inline rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
{ {
return device->ops->check_block(device, block); return device->ops->check_block(device, block);
} }
rt_inline rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device* device, rt_uint32_t block) rt_inline rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_t block)
{ {
return device->ops->mark_badblock(device, block); return device->ops->mark_badblock(device, block);
} }

View File

@ -101,25 +101,25 @@ rt_err_t rt_mtd_nand_register_device(const char *name,
static void mtd_dump_hex(const rt_uint8_t *ptr, rt_size_t buflen) static void mtd_dump_hex(const rt_uint8_t *ptr, rt_size_t buflen)
{ {
unsigned char *buf = (unsigned char*)ptr; unsigned char *buf = (unsigned char *)ptr;
int i, j; int i, j;
for (i=0; i<buflen; i+=16) for (i = 0; i < buflen; i += 16)
{ {
rt_kprintf("%06x: ", i); rt_kprintf("%06x: ", i);
for (j=0; j<16; j++) for (j = 0; j < 16; j++)
if (i+j < buflen) if (i + j < buflen)
rt_kprintf("%02x ", buf[i+j]); rt_kprintf("%02x ", buf[i + j]);
else else
rt_kprintf(" "); rt_kprintf(" ");
rt_kprintf(" "); rt_kprintf(" ");
for (j=0; j<16; j++) for (j = 0; j < 16; j++)
if (i+j < buflen) if (i + j < buflen)
rt_kprintf("%c", __is_print(buf[i+j]) ? buf[i+j] : '.'); rt_kprintf("%c", __is_print(buf[i + j]) ? buf[i + j] : '.');
rt_kprintf("\n"); rt_kprintf("\n");
} }
} }
int mtd_nandid(const char* name) int mtd_nandid(const char *name)
{ {
struct rt_mtd_nand_device *nand; struct rt_mtd_nand_device *nand;
nand = RT_MTD_NAND_DEVICE(rt_device_find(name)); nand = RT_MTD_NAND_DEVICE(rt_device_find(name));
@ -133,7 +133,7 @@ int mtd_nandid(const char* name)
} }
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nandid, nand_id, read ID - nandid(name)); FINSH_FUNCTION_EXPORT_ALIAS(mtd_nandid, nand_id, read ID - nandid(name));
int mtd_nand_read(const char* name, int block, int page) int mtd_nand_read(const char *name, int block, int page)
{ {
rt_err_t result; rt_err_t result;
rt_uint8_t *page_ptr; rt_uint8_t *page_ptr;
@ -171,7 +171,7 @@ int mtd_nand_read(const char* name, int block, int page)
} }
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_read, nand_read, read page in nand - nand_read(name, block, page)); FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_read, nand_read, read page in nand - nand_read(name, block, page));
int mtd_nand_readoob(const char* name, int block, int page) int mtd_nand_readoob(const char *name, int block, int page)
{ {
struct rt_mtd_nand_device *nand; struct rt_mtd_nand_device *nand;
rt_uint8_t *oob_ptr; rt_uint8_t *oob_ptr;
@ -201,7 +201,7 @@ int mtd_nand_readoob(const char* name, int block, int page)
} }
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_readoob, nand_readoob, read spare data in nand - nand_readoob(name, block, page)); FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_readoob, nand_readoob, read spare data in nand - nand_readoob(name, block, page));
int mtd_nand_write(const char* name, int block, int page) int mtd_nand_write(const char *name, int block, int page)
{ {
rt_err_t result; rt_err_t result;
rt_uint8_t *page_ptr; rt_uint8_t *page_ptr;
@ -249,7 +249,7 @@ int mtd_nand_write(const char* name, int block, int page)
} }
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_write, nand_write, write dump data to nand - nand_write(name, block, page)); FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_write, nand_write, write dump data to nand - nand_write(name, block, page));
int mtd_nand_erase(const char* name, int block) int mtd_nand_erase(const char *name, int block)
{ {
struct rt_mtd_nand_device *nand; struct rt_mtd_nand_device *nand;
nand = RT_MTD_NAND_DEVICE(rt_device_find(name)); nand = RT_MTD_NAND_DEVICE(rt_device_find(name));
@ -263,7 +263,7 @@ int mtd_nand_erase(const char* name, int block)
} }
FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_erase, nand_erase, nand_erase(name, block)); FINSH_FUNCTION_EXPORT_ALIAS(mtd_nand_erase, nand_erase, nand_erase(name, block));
int mtd_nand_erase_all(const char* name) int mtd_nand_erase_all(const char *name)
{ {
rt_uint32_t index = 0; rt_uint32_t index = 0;
struct rt_mtd_nand_device *nand; struct rt_mtd_nand_device *nand;