mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-881: flashfs: coding style fixes according to OPReview-423
+review OPReview-423
This commit is contained in:
parent
46e9e60e76
commit
ca0910370f
@ -119,30 +119,28 @@ static int32_t PIOS_Flash_Jedec_Validate(struct jedec_flash_dev * flash_dev) {
|
||||
int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num)
|
||||
{
|
||||
struct jedec_flash_dev * flash_dev = PIOS_Flash_Jedec_alloc();
|
||||
if (flash_dev == NULL)
|
||||
if (!flash_dev) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
flash_dev->spi_id = spi_id;
|
||||
flash_dev->slave_num = slave_num;
|
||||
flash_dev->cfg = NULL;
|
||||
|
||||
(void) PIOS_Flash_Jedec_ReadID(flash_dev);
|
||||
uint32_t i = 0;
|
||||
while ((i < pios_flash_jedec_catalog_size) && !flash_dev->cfg)
|
||||
{
|
||||
|
||||
for (uint32_t i = 0; i < pios_flash_jedec_catalog_size; ++i) {
|
||||
const struct pios_flash_jedec_cfg flash_jedec_entry = pios_flash_jedec_catalog[i];
|
||||
|
||||
if ((flash_dev->manufacturer == flash_jedec_entry.expect_manufacturer) &&
|
||||
(flash_dev->memorytype == flash_jedec_entry.expect_memorytype) &&
|
||||
(flash_dev->capacity == flash_jedec_entry.expect_capacity))
|
||||
{
|
||||
if ((flash_dev->manufacturer == flash_jedec_entry.expect_manufacturer)
|
||||
&& (flash_dev->memorytype == flash_jedec_entry.expect_memorytype)
|
||||
&& (flash_dev->capacity == flash_jedec_entry.expect_capacity)) {
|
||||
flash_dev->cfg = &pios_flash_jedec_catalog[i];
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(!flash_dev->cfg)
|
||||
{
|
||||
if (!flash_dev->cfg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -169,12 +169,20 @@ void PIOS_Board_Init(void) {
|
||||
uintptr_t fs_id;
|
||||
switch(bdinfo->board_rev) {
|
||||
case BOARD_REVISION_CC:
|
||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1);
|
||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id);
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 1)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_w25x_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
break;
|
||||
case BOARD_REVISION_CC3D:
|
||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0);
|
||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_accel_id, 0)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PIOS_DEBUG_Assert(0);
|
||||
|
@ -336,13 +336,14 @@ void PIOS_Board_Init(void) {
|
||||
#if defined(PIOS_INCLUDE_FLASH)
|
||||
/* Connect flash to the appropriate interface and configure it */
|
||||
uintptr_t flash_id;
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1))
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_telem_flash_id, 1)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
uintptr_t fs_id;
|
||||
|
||||
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id))
|
||||
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -386,14 +386,20 @@ void PIOS_Board_Init(void) {
|
||||
}
|
||||
/* Connect flash to the appropriate interface and configure it */
|
||||
uintptr_t flash_id;
|
||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0);
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_flash_id, 0)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
#else
|
||||
/* Connect flash to the appropriate interface and configure it */
|
||||
uintptr_t flash_id;
|
||||
PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1);
|
||||
if (PIOS_Flash_Jedec_Init(&flash_id, pios_spi_accel_id, 1)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
#endif
|
||||
uintptr_t fs_id;
|
||||
PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id);
|
||||
if (PIOS_FLASHFS_Logfs_Init(&fs_id, &flashfs_m25p_cfg, &pios_jedec_flash_driver, flash_id)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
/* Initialize UAVObject libraries */
|
||||
EventDispatcherInitialize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user