From: Bernd Moessner <berndmoessne...@gmail.com> --- cpukit/dev/flash/flashdev.c | 43 +++++++++++++------ cpukit/include/dev/flash/flashdev.h | 3 +- cpukit/libmisc/shell/main_flashdev.c | 10 ++++- testsuites/libtests/flashdev01/init.c | 17 ++++++-- .../libtests/flashdev01/test_flashdev.h | 7 ++- 5 files changed, 60 insertions(+), 20 deletions(-)
diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c index ee01b8b447..ee06007a53 100644 --- a/cpukit/dev/flash/flashdev.c +++ b/cpukit/dev/flash/flashdev.c @@ -415,7 +415,9 @@ static off_t rtems_flashdev_get_partition_offset( ) { /* Region is already checked to be defined */ - assert( rtems_flashdev_get_active_partition_index( iop ) != RTEMS_FLASHDEV_PARTITION_UNDEFINED ); + assert( rtems_flashdev_get_active_partition_index( iop ) != + RTEMS_FLASHDEV_PARTITION_UNDEFINED ); + rtems_flashdev_partition *table = flash->partition_table; return table[ rtems_flashdev_get_active_partition_index( iop ) ].offset; } @@ -426,7 +428,9 @@ static size_t rtems_flashdev_get_partition_size( ) { /* Region is already checked to be defined */ - assert( rtems_flashdev_get_active_partition_index( iop ) != RTEMS_FLASHDEV_PARTITION_UNDEFINED ); + assert( rtems_flashdev_get_active_partition_index( iop ) != + RTEMS_FLASHDEV_PARTITION_UNDEFINED ); + rtems_flashdev_partition *table = flash->partition_table; return table[ rtems_flashdev_get_active_partition_index( iop ) ].size; } @@ -557,7 +561,8 @@ static int rtems_flashdev_open( ) { int ret = rtems_filesystem_default_open( iop, path, oflag, mode ); - rtems_flashdev_mark_partition_defined(iop, RTEMS_FLASHDEV_PARTITION_UNDEFINED); + rtems_flashdev_mark_partition_defined(iop, + RTEMS_FLASHDEV_PARTITION_UNDEFINED); return ret; } @@ -700,8 +705,8 @@ static bool rtems_flashdev_is_a_partition_active( rtems_libio_t *iop ) { - return (rtems_flashdev_get_active_partition_index( iop ) - != RTEMS_FLASHDEV_PARTITION_UNDEFINED); + return (rtems_flashdev_get_active_partition_index( iop ) != + RTEMS_FLASHDEV_PARTITION_UNDEFINED); } static bool rtems_flashdev_is_partition_defined( @@ -719,7 +724,8 @@ static int rtems_flashdev_activate_partition( ) { if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;} - iop->data0 = set_bit(iop->data0, partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS); + iop->data0 = set_bit( iop->data0, + partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS); return 0; } @@ -729,7 +735,8 @@ static int rtems_flashdev_deactivate_partition( ) { if(!rtems_flashdev_is_partition_defined(iop, partition_idx)){return -1;} - iop->data0 = clear_bit(iop->data0, partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS); + iop->data0 = clear_bit( iop->data0, + partition_idx + RTEMS_FLASHDEV_MAX_PARTITIONS); return 0; } @@ -834,7 +841,9 @@ rtems_flashdev *rtems_flashdev_alloc_and_init( size_t size ) flash = calloc( 1, size ); if ( NULL != flash ) { int rv; - rtems_flashdev_partition * table = calloc( RTEMS_FLASHDEV_MAX_PARTITIONS, sizeof(rtems_flashdev_partition)); + rtems_flashdev_partition * table = calloc( RTEMS_FLASHDEV_MAX_PARTITIONS, + sizeof(rtems_flashdev_partition)); + rv = rtems_flashdev_do_init( flash, rtems_flashdev_destroy_and_free ); if ( (rv != 0) || (table == NULL) ) { rtems_recursive_mutex_destroy( &flash->mutex ); @@ -943,7 +952,10 @@ static int rtems_flashdev_ioctl_erase( } new_offset = erase_args_1->offset; - status = rtems_flashdev_get_abs_addr(flash, iop, erase_args_1->size, &new_offset); + status = rtems_flashdev_get_abs_addr( flash, + iop, + erase_args_1->size, + &new_offset); if ( status < 0 ) { return status; } @@ -986,7 +998,10 @@ static int rtems_flashdev_ioctl_create_partition( } /* New partition to allocate and space to allocate partition */ - return rtems_flashdev_create_partition( iop, table, partition_idx, partition_in ); + return rtems_flashdev_create_partition( iop, + table, + partition_idx, + partition_in ); } static int rtems_flashdev_ioctl_delete_partition( @@ -1039,7 +1054,10 @@ static int rtems_flashdev_ioctl_resize_partition( } else { - ret = rtems_flashdev_create_partition( iop, flash->partition_table, partition_idx, &storage); + ret = rtems_flashdev_create_partition( iop, + flash->partition_table, + partition_idx, + &storage ); if (ret >= 0) { rtems_flashdev_activate_partition(iop, partition_idx); @@ -1139,7 +1157,8 @@ static int rtems_flashdev_ioctl_get_pageinfo_by_index( rtems_flashdev *flash, } } -static int rtems_flashdev_ioctl_get_page_count( rtems_flashdev *flash, void *arg ) +static int rtems_flashdev_ioctl_get_page_count( rtems_flashdev *flash, + void *arg ) { if ( arg == NULL ) { rtems_set_errno_and_return_minus_one( EINVAL ); diff --git a/cpukit/include/dev/flash/flashdev.h b/cpukit/include/dev/flash/flashdev.h index d1ffd30583..7d7a70f5bc 100644 --- a/cpukit/include/dev/flash/flashdev.h +++ b/cpukit/include/dev/flash/flashdev.h @@ -165,7 +165,8 @@ typedef enum { RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET, /** - * @brief Get the size and address of nth flash page where n is index passed in. + * @brief Get the size and address of nth flash page where n is index + * passed in. * * The index ignores the region limiting. * diff --git a/cpukit/libmisc/shell/main_flashdev.c b/cpukit/libmisc/shell/main_flashdev.c index 2b703a88ec..e2e6bc02b2 100644 --- a/cpukit/libmisc/shell/main_flashdev.c +++ b/cpukit/libmisc/shell/main_flashdev.c @@ -37,8 +37,14 @@ static int flashdev_shell_write(char *dev_path, int argc, char *argv[]); static int flashdev_shell_erase(char *dev_path, int argc, char *argv[]); static int flashdev_shell_get_type(char *dev_path); static int flashdev_shell_get_jedec_id(char *dev_path); -static int flashdev_shell_get_page_by_off(char *dev_path, int argc, char *argv[]); -static int flashdev_shell_get_page_by_idx(char *dev_path, int argc, char *argv[]); +static int flashdev_shell_get_page_by_off(char *dev_path, + int argc, + char *argv[] +); +static int flashdev_shell_get_page_by_idx(char *dev_path, + int argc, + char *argv[] +); static int flashdev_shell_get_pg_count(char *dev_path); static int flashdev_shell_get_min_write_size(char *dev_path); static int flashdev_shell_get_erase_size(char *dev_path); diff --git a/testsuites/libtests/flashdev01/init.c b/testsuites/libtests/flashdev01/init.c index 33cbb8bad8..7005ef272e 100644 --- a/testsuites/libtests/flashdev01/init.c +++ b/testsuites/libtests/flashdev01/init.c @@ -73,7 +73,10 @@ static void run_test(void) { for ( int loop = 0; loop <= 2; loop++) { /* Initalize the flash device driver and flashdev */ - flash = test_flashdev_init(page_size_in, page_count_in, min_write_size_in[loop], ERASE_SIZE); + flash = test_flashdev_init( page_size_in, + page_count_in, + min_write_size_in[loop], + ERASE_SIZE); rtems_test_assert(flash != NULL); /* Register the flashdev as a device */ @@ -172,9 +175,12 @@ static void run_test(void) { rtems_test_assert(page_count == PAGE_COUNT); /* Test getting min write size */ - status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE, &min_write_size_out); + status = ioctl( fd, RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_SIZE, + &min_write_size_out); rtems_test_assert(!status); - rtems_test_assert(0 == memcmp(&min_write_size_out, &min_write_size_in[loop] , sizeof(size_t))); + rtems_test_assert(0 == memcmp(&min_write_size_out, + &min_write_size_in[loop], + sizeof(size_t))); /* Close the file handle */ status = fclose(file); @@ -188,7 +194,10 @@ static void run_test(void) { } /* Initalize the flash device driver and flashdev */ - flash = test_flashdev_init(page_size_in, page_count_in, min_write_size_in[1], ERASE_SIZE); + flash = test_flashdev_init( page_size_in, + page_count_in, + min_write_size_in[1], + ERASE_SIZE); rtems_test_assert(flash != NULL); /* Register the flashdev as a device */ diff --git a/testsuites/libtests/flashdev01/test_flashdev.h b/testsuites/libtests/flashdev01/test_flashdev.h index b02a5deed1..2867b8c993 100644 --- a/testsuites/libtests/flashdev01/test_flashdev.h +++ b/testsuites/libtests/flashdev01/test_flashdev.h @@ -31,7 +31,12 @@ #include <dev/flash/flashdev.h> -rtems_flashdev* test_flashdev_init(size_t page_size, size_t page_count, size_t min_write_size, size_t erase_size); +rtems_flashdev* test_flashdev_init( + size_t page_size, + size_t page_count, + size_t min_write_size, + size_t erase_size +); void test_flashdev_deinit(rtems_flashdev* flash); -- 2.34.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel