Skip to content

Commit

Permalink
devices: refactor device ops structure (fix building for new targets)
Browse files Browse the repository at this point in the history
JIRA: RTOS-930
  • Loading branch information
Darchiv committed Sep 27, 2024
1 parent 5a48f1f commit 23534d2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion devices/flash-gr712rc/flashdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ __attribute__((constructor)) static void flashdrv_reg(void)
.init = flashdrv_init,
.done = flashdrv_done,
.ops = &opsFlashGR712RC,
}
};

hal_memset(&fdrv_common, 0, sizeof(fdrv_common));

Expand Down
15 changes: 10 additions & 5 deletions devices/flash-mcxn94x/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,20 @@ static int flashdrv_init(unsigned int minor)

__attribute__((constructor)) static void flashdrv_reg(void)
{
static const dev_handler_t h = {
.init = flashdrv_init,
.done = flashdrv_done,
static const dev_ops_t opsFlashMCXN94X = {
.read = flashdrv_read,
.write = flashdrv_write,
.erase = NULL, /* TODO */
.sync = flashdrv_sync,
.map = flashdrv_map
.map = flashdrv_map,
};

static const dev_t devFlashMCXN94X = {
.name = "flash-mcxn94x",
.init = flashdrv_init,
.done = flashdrv_done,
.ops = &opsFlashMCXN94X,
};

devs_register(DEV_STORAGE, FLASH_NO, &h);
devs_register(DEV_STORAGE, FLASH_NO, &devFlashMCXN94X);
}
15 changes: 10 additions & 5 deletions devices/flash-mps3an536/flashdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,20 @@ static int flashdrv_init(unsigned int minor)

__attribute__((constructor)) static void flashdrv_reg(void)
{
static const dev_handler_t h = {
.init = flashdrv_init,
.done = flashdrv_done,
static const dev_ops_t opsFlashMPS3AN536 = {
.read = flashdrv_read,
.write = flashdrv_write,
.erase = NULL,
.sync = flashdrv_sync,
.map = flashdrv_map
.map = flashdrv_map,
};

static const dev_t devFlashMPS3AN536 = {
.name = "flash-mps3an536",
.init = flashdrv_init,
.done = flashdrv_done,
.ops = &opsFlashMPS3AN536,
};

devs_register(DEV_STORAGE, 1, &h);
devs_register(DEV_STORAGE, 1, &devFlashMPS3AN536);
}
14 changes: 10 additions & 4 deletions devices/uart-cmsdk-apb/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,20 @@ static int uart_init(unsigned int minor)

__attribute__((constructor)) static void uart_reg(void)
{
static const dev_handler_t h = {
.init = uart_init,
.done = uart_done,
static const dev_ops_t opsUartCmsdkApb = {
.read = uart_read,
.write = uart_safeWrite,
.erase = NULL,
.sync = uart_sync,
.map = uart_map,
};

devs_register(DEV_UART, UART_MAX_CNT, &h);
static const dev_t devUartCmsdkApb = {
.name = "uart-cmsdk-apb",
.init = uart_init,
.done = uart_done,
.ops = &opsUartCmsdkApb,
};

devs_register(DEV_UART, UART_MAX_CNT, &devUartCmsdkApb);
}
13 changes: 9 additions & 4 deletions devices/uart-mcxn94x/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,20 @@ static int uart_init(unsigned int minor)

__attribute__((constructor)) static void uart_reg(void)
{
static const dev_handler_t h = {
.init = uart_init,
.done = uart_done,
static const dev_ops_t opsUartMCXN94X = {
.read = uart_read,
.write = uart_safeWrite,
.erase = NULL,
.sync = uart_sync,
.map = uart_map,
};

devs_register(DEV_UART, UART_MAX_CNT, &h);
static const dev_t devUartMCXN94X = {
.name = "uart-mcxn94x",
.init = uart_init,
.done = uart_done,
.ops = &opsUartMCXN94X,
};

devs_register(DEV_UART, UART_MAX_CNT, &devUartMCXN94X);
}

0 comments on commit 23534d2

Please sign in to comment.