[PATCH rtems6 - v2 09/16] flashdev: Refactor macro name
berndmoessner80 at gmail.com
berndmoessner80 at gmail.com
Sun Jan 7 18:18:43 UTC 2024
From: Bernd Moessner <berndmoessner80 at gmail.com>
The major change in this patch is that it refactors
RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE to become
RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE.
Apart from that this patch fixes comments and aligns function names.
There is no change in the behaviour of the code introduced by this
patch.
Updates #4981
---
cpukit/dev/flash/flashdev.c | 26 +++++-----
cpukit/include/dev/flash/flashdev.h | 15 +++---
cpukit/libmisc/shell/main_flashdev.c | 47 +++++++++++--------
testsuites/libtests/flashdev01/init.c | 9 ++--
.../libtests/flashdev01/test_flashdev.c | 30 ++++++------
5 files changed, 68 insertions(+), 59 deletions(-)
diff --git a/cpukit/dev/flash/flashdev.c b/cpukit/dev/flash/flashdev.c
index 37d42955eb..50915312a0 100644
--- a/cpukit/dev/flash/flashdev.c
+++ b/cpukit/dev/flash/flashdev.c
@@ -108,12 +108,12 @@ static uint32_t rtems_flashdev_ioctl_get_flash_type(
void *arg
);
-static int rtems_flashdev_ioctl_get_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
rtems_flashdev *flash,
void *arg
);
-static int rtems_flashdev_ioctl_get_pageinfo_index(
+static int rtems_flashdev_ioctl_get_pageinfo_by_index(
rtems_flashdev *flash,
void *arg
);
@@ -123,7 +123,7 @@ static int rtems_flashdev_ioctl_get_page_count(
void *arg
);
-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_block_size(
rtems_flashdev *flash,
void *arg
);
@@ -378,16 +378,16 @@ static int rtems_flashdev_ioctl(
err = rtems_flashdev_ioctl_get_flash_type( flash, arg );
break;
case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_OFFSET:
- err = rtems_flashdev_ioctl_get_pageinfo_offset( flash, arg );
+ err = rtems_flashdev_ioctl_get_pageinfo_by_offset( flash, arg );
break;
case RTEMS_FLASHDEV_IOCTL_GET_PAGEINFO_BY_INDEX:
- err = rtems_flashdev_ioctl_get_pageinfo_index( flash, arg );
+ err = rtems_flashdev_ioctl_get_pageinfo_by_index( flash, arg );
break;
case RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT:
err = rtems_flashdev_ioctl_get_page_count( flash, arg );
break;
- case RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE:
- err = rtems_flashdev_ioctl_get_write_block_size( flash, arg );
+ case RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE:
+ err = rtems_flashdev_ioctl_get_min_write_block_size( flash, arg );
break;
default:
err = EINVAL;
@@ -511,7 +511,7 @@ static int rtems_flashdev_do_init(
flash->get_page_info_by_offset = NULL;
flash->get_page_info_by_index = NULL;
flash->get_page_count = NULL;
- flash->get_write_block_size = NULL;
+ flash->get_min_write_block_size = NULL;
flash->region_table = NULL;
return 0;
}
@@ -802,7 +802,7 @@ static uint32_t rtems_flashdev_ioctl_get_flash_type(
}
}
-static int rtems_flashdev_ioctl_get_pageinfo_offset(
+static int rtems_flashdev_ioctl_get_pageinfo_by_offset(
rtems_flashdev *flash,
void *arg
)
@@ -823,7 +823,7 @@ static int rtems_flashdev_ioctl_get_pageinfo_offset(
}
}
-static int rtems_flashdev_ioctl_get_pageinfo_index( rtems_flashdev *flash,
+static int rtems_flashdev_ioctl_get_pageinfo_by_index( rtems_flashdev *flash,
void *arg )
{
rtems_flashdev_ioctl_page_info *page_info;
@@ -854,7 +854,7 @@ static int rtems_flashdev_ioctl_get_page_count( rtems_flashdev *flash, void *arg
}
}
-static int rtems_flashdev_ioctl_get_write_block_size(
+static int rtems_flashdev_ioctl_get_min_write_block_size(
rtems_flashdev *flash,
void *arg
)
@@ -862,10 +862,10 @@ static int rtems_flashdev_ioctl_get_write_block_size(
if ( arg == NULL ) {
rtems_set_errno_and_return_minus_one( EINVAL );
}
- if ( flash->get_write_block_size == NULL ) {
+ if ( flash->get_min_write_block_size == NULL ) {
return 0;
} else {
- return ( *flash->get_write_block_size )( flash, ( (size_t *) arg ) );
+ return ( *flash->get_min_write_block_size )( flash, ( (size_t *) arg ) );
}
}
diff --git a/cpukit/include/dev/flash/flashdev.h b/cpukit/include/dev/flash/flashdev.h
index 51e0486148..6ce00c4ead 100644
--- a/cpukit/include/dev/flash/flashdev.h
+++ b/cpukit/include/dev/flash/flashdev.h
@@ -138,11 +138,11 @@ typedef struct rtems_flashdev rtems_flashdev;
#define RTEMS_FLASHDEV_IOCTL_GET_PAGE_COUNT 9
/**
- * @brief Get the minimum write size supported by the driver.
+ * @brief Get the minimum write block size supported by the driver.
*
- * @param[out] count Integer containing the minimum write size.
+ * @param[out] count Integer containing the minimum write block size.
*/
-#define RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE 10
+#define RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE 10
/**
* @brief The maximum number of region limited file descriptors
@@ -351,17 +351,18 @@ struct rtems_flashdev {
);
/**
- * @brief Call to device driver to return the minimum write size of the
+ * @brief Call to device driver to return the minimum write block size of the
* flash device.
*
- * @param[out] write_block_size The minimum write size of the flash device.
+ * @param[out] min_write_block_size The minimum write block size of the flash
+ * device.
*
* @retval 0 Success.
* @retval non-zero Failed.
*/
- int ( *get_write_block_size )(
+ int ( *get_min_write_block_size )(
rtems_flashdev *flashdev,
- size_t *write_block_size
+ size_t *min_write_block_size
);
/**
diff --git a/cpukit/libmisc/shell/main_flashdev.c b/cpukit/libmisc/shell/main_flashdev.c
index 516c77ae27..8443d8f71d 100644
--- a/cpukit/libmisc/shell/main_flashdev.c
+++ b/cpukit/libmisc/shell/main_flashdev.c
@@ -37,10 +37,17 @@ 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_pg_count(char *dev_path);
-static int flashdev_shell_get_wb_size(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_count(char *dev_path);
+static int flashdev_shell_get_min_write_block_size(char *dev_path);
static int flashdev_shell_ioctl_value(
char *dev_path,
@@ -67,7 +74,7 @@ static const char rtems_flashdev_shell_usage [] =
" -o <address> Print the page information of page at address\n"
" -i <index> Print the page information of page at index\n"
" -p Print the number of pages\n"
- " -b Print the write block size\n"
+ " -b Print the min. write block size\n"
" -h Print this help\n";
@@ -98,23 +105,23 @@ static int rtems_flashdev_shell_main( int argc, char *argv[] ) {
/* Erase */
return flashdev_shell_erase(dev_path, argc, &argv[i]);
case ('t'):
- /* Flash Type */
+ /* Get Flash Type */
return flashdev_shell_get_type(dev_path);
case ('d'):
- /* JEDEC Id */
+ /* Get JEDEC Id */
return flashdev_shell_get_jedec_id(dev_path);
case ('o'):
- /* Page info by offset */
+ /* Get page info by offset */
return flashdev_shell_get_page_by_off(dev_path, argc, &argv[i]);
case ('i'):
- /* Page info by index */
+ /* Get page info by index */
return flashdev_shell_get_page_by_idx(dev_path, argc, &argv[i]);
case ('p'):
- /* Page count */
- return flashdev_shell_get_pg_count(dev_path);
+ /* Get page count */
+ return flashdev_shell_get_page_count(dev_path);
case ('b'):
- /* Write block size */
- return flashdev_shell_get_wb_size(dev_path);
+ /* Get min. write block size */
+ return flashdev_shell_get_min_write_block_size(dev_path);
case ('h'):
default:
/* Help */
@@ -458,7 +465,7 @@ static int flashdev_shell_get_page_by_idx(
);
}
-static int flashdev_shell_get_pg_count( char *dev_path )
+static int flashdev_shell_get_page_count( char *dev_path )
{
uint32_t ret;
int status;
@@ -480,24 +487,24 @@ static int flashdev_shell_get_pg_count( char *dev_path )
return 0;
}
-static int flashdev_shell_get_wb_size( char *dev_path )
+static int flashdev_shell_get_min_write_block_size( char *dev_path )
{
size_t ret;
int status;
- /* Get Write Block Size */
+ /* Get Min Write Block Size */
status = flashdev_shell_ioctl_value(
dev_path,
- RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE,
+ RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE,
&ret
);
- /* Print Write Block Size */
+ /* Print Min Write Block Size */
if (status) {
- printf("Failed to get write block size\n");
+ printf("Failed to get min. write block size\n");
return status;
} else {
- printf("Write block size: 0x%zx\n", ret);
+ printf("Min. write block size: 0x%zx\n", ret);
}
return 0;
}
diff --git a/testsuites/libtests/flashdev01/init.c b/testsuites/libtests/flashdev01/init.c
index 48cb033c04..dead939212 100644
--- a/testsuites/libtests/flashdev01/init.c
+++ b/testsuites/libtests/flashdev01/init.c
@@ -39,7 +39,7 @@
#define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
#define PAGE_COUNT 16
#define PAGE_SIZE 128
-#define WB_SIZE 1
+#define MIN_WRTIE_BLOCK_SIZE 1
const char rtems_test_name[] = "FLASHDEV 1";
@@ -59,7 +59,7 @@ static void run_test(void) {
uint32_t jedec;
int page_count;
int type;
- size_t wb_size;
+ size_t min_write_block_size;
const char flash_path[] = "/dev/flashdev0";
/* Initalize the flash device driver and flashdev */
@@ -134,9 +134,10 @@ static void run_test(void) {
rtems_test_assert(page_count == PAGE_COUNT);
/* Test getting write block size */
- status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_WRITE_BLOCK_SIZE, &wb_size);
+ status = ioctl(fd, RTEMS_FLASHDEV_IOCTL_GET_MIN_WRITE_BLOCK_SIZE,
+ &min_write_block_size);
rtems_test_assert(!status);
- rtems_test_assert(wb_size == WB_SIZE);
+ rtems_test_assert(min_write_block_size == min_write_block_size);
/* Test Regions */
region.offset = 0x400;
diff --git a/testsuites/libtests/flashdev01/test_flashdev.c b/testsuites/libtests/flashdev01/test_flashdev.c
index 9e257863b1..6b147d0f64 100644
--- a/testsuites/libtests/flashdev01/test_flashdev.c
+++ b/testsuites/libtests/flashdev01/test_flashdev.c
@@ -33,7 +33,7 @@
#define TEST_DATA_SIZE (PAGE_SIZE * PAGE_COUNT)
#define PAGE_COUNT 16
#define PAGE_SIZE 128
-#define WB_SIZE 1
+#define MIN_WRITE_BLOCK_SIZE 1
#define MAX_NUM_REGIONS 48
#define BITALLOC_SIZE 32
#define NUM_BITALLOC ((MAX_NUM_REGIONS + BITALLOC_SIZE - 1) / BITALLOC_SIZE)
@@ -49,7 +49,7 @@ typedef struct test_flashdev {
rtems_flashdev_region regions[MAX_NUM_REGIONS];
} test_flashdev;
-int test_flashdev_get_page_by_off(
+int test_flashdev_get_page_by_offset(
rtems_flashdev *flash,
off_t search_offset,
off_t *page_offset,
@@ -68,9 +68,9 @@ int test_flashdev_get_page_count(
int *page_count
);
-int test_flashdev_get_wb_size(
+int test_flashdev_get_min_write_block_size(
rtems_flashdev *flash,
- size_t *write_block_size
+ size_t *min_write_block_size
);
uint32_t test_flashdev_get_jedec_id(
@@ -102,8 +102,8 @@ int test_flashdev_erase(
size_t count
);
-/* Find page info by offset handler */
-int test_flashdev_get_page_by_off(
+/* Get page info by offset handler */
+int test_flashdev_get_page_by_offset(
rtems_flashdev *flash,
off_t search_offset,
off_t *page_offset,
@@ -115,7 +115,7 @@ int test_flashdev_get_page_by_off(
return 0;
}
-/* Find page by index handler */
+/* Get page by index handler */
int test_flashdev_get_page_by_index(
rtems_flashdev *flash,
off_t search_index,
@@ -128,7 +128,7 @@ int test_flashdev_get_page_by_index(
return 0;
}
-/* Page count handler */
+/* Get page count handler */
int test_flashdev_get_page_count(
rtems_flashdev *flash,
int *page_count
@@ -138,17 +138,17 @@ int test_flashdev_get_page_count(
return 0;
}
-/* Write block size handler */
-int test_flashdev_get_wb_size(
+/* Get min. write block size handler */
+int test_flashdev_get_min_write_block_size(
rtems_flashdev *flash,
- size_t *write_block_size
+ size_t *min_write_block_size
)
{
- *write_block_size = WB_SIZE;
+ *min_write_block_size = MIN_WRITE_BLOCK_SIZE;
return 0;
}
-/* JEDEC ID handler, this would normally require a READID
+/* Get JEDEC ID handler, this would normally require a READID
* call to the physical flash device.
*/
uint32_t test_flashdev_get_jedec_id(
@@ -265,10 +265,10 @@ rtems_flashdev* test_flashdev_init(void)
flash->erase = &test_flashdev_erase;
flash->get_jedec_id = &test_flashdev_get_jedec_id;
flash->get_flash_type = &test_flashdev_get_type;
- flash->get_page_info_by_offset = &test_flashdev_get_page_by_off;
+ flash->get_page_info_by_offset = &test_flashdev_get_page_by_offset;
flash->get_page_info_by_index = &test_flashdev_get_page_by_index;
flash->get_page_count = &test_flashdev_get_page_count;
- flash->get_write_block_size = &test_flashdev_get_wb_size;
+ flash->get_min_write_block_size = &test_flashdev_get_min_write_block_size;
flash->region_table = ftable;
return flash;
--
2.34.1
More information about the devel
mailing list