From e4dd86a1b73feaa67334bdd0a9590d8273679feb Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 21:41:43 +0800 Subject: [PATCH 1/6] [DRIVER][SDIO] Add components initializer. --- components/drivers/include/drivers/mmcsd_core.h | 4 ++-- components/drivers/sdio/block_dev.c | 7 +++++-- components/drivers/sdio/mmcsd_core.c | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/drivers/include/drivers/mmcsd_core.h b/components/drivers/include/drivers/mmcsd_core.h index e474fa28a8..36d71efeb2 100644 --- a/components/drivers/include/drivers/mmcsd_core.h +++ b/components/drivers/include/drivers/mmcsd_core.h @@ -247,9 +247,9 @@ void mmcsd_change(struct rt_mmcsd_host *host); void mmcsd_detect(void *param); struct rt_mmcsd_host *mmcsd_alloc_host(void); void mmcsd_free_host(struct rt_mmcsd_host *host); -void rt_mmcsd_core_init(void); +int rt_mmcsd_core_init(void); -void rt_mmcsd_blk_init(void); +int rt_mmcsd_blk_init(void); rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card); void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card); diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index c986556879..c42c485eaf 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -479,8 +479,11 @@ void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card) * @deprecated since 2.1.0, this function does not need to be invoked * in the system initialization. */ -void rt_mmcsd_blk_init(void) +int rt_mmcsd_blk_init(void) { - /* nothing */ + /* nothing */ + return 0; } +INIT_PREV_EXPORT(rt_mmcsd_blk_init); + diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 02063efdd2..2466ce627d 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -726,7 +726,7 @@ void mmcsd_free_host(struct rt_mmcsd_host *host) rt_free(host); } -void rt_mmcsd_core_init(void) +int rt_mmcsd_core_init(void) { rt_err_t ret; @@ -751,3 +751,5 @@ void rt_mmcsd_core_init(void) rt_sdio_init(); } +INIT_PREV_EXPORT(rt_mmcsd_core_init); + From 222edd25c0b05506f79b7c00b8cbe4b8df21ddb1 Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 21:42:31 +0800 Subject: [PATCH 2/6] [BSP][AT91SAM9260] update sdio drivers. --- bsp/at91sam9260/applications/application.c | 3 --- bsp/at91sam9260/drivers/at91_mci.c | 3 ++- bsp/at91sam9260/drivers/at91_mci.h | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bsp/at91sam9260/applications/application.c b/bsp/at91sam9260/applications/application.c index cbb1899ad0..5800ba53d2 100644 --- a/bsp/at91sam9260/applications/application.c +++ b/bsp/at91sam9260/applications/application.c @@ -73,9 +73,6 @@ int main(void) #endif #ifdef RT_USING_SDIO - rt_mmcsd_core_init(); - rt_mmcsd_blk_init(); - at91_mci_init(); timeout = 0; while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2)) { diff --git a/bsp/at91sam9260/drivers/at91_mci.c b/bsp/at91sam9260/drivers/at91_mci.c index fdfdcf459c..25d408810c 100644 --- a/bsp/at91sam9260/drivers/at91_mci.c +++ b/bsp/at91sam9260/drivers/at91_mci.c @@ -834,7 +834,7 @@ static void mci_gpio_init() #endif } -rt_int32_t at91_mci_init(void) +int at91_mci_init(void) { struct rt_mmcsd_host *host; struct at91_mci *mci; @@ -903,6 +903,7 @@ err: return -RT_ENOMEM; } +INIT_DEVICE_EXPORT(at91_mci_init); #include "finsh.h" FINSH_FUNCTION_EXPORT(at91_mci_init, at91sam9260 sd init); diff --git a/bsp/at91sam9260/drivers/at91_mci.h b/bsp/at91sam9260/drivers/at91_mci.h index 2591f20c98..4e3bae9999 100644 --- a/bsp/at91sam9260/drivers/at91_mci.h +++ b/bsp/at91sam9260/drivers/at91_mci.h @@ -119,6 +119,6 @@ #define AT91_MCI_IDR 0x48 /* Interrupt Disable Register */ #define AT91_MCI_IMR 0x4c /* Interrupt Mask Register */ -extern rt_int32_t at91_mci_init(void); +extern int at91_mci_init(void); #endif From db41e7e30e6cf0c5e9ca4158947ec4eac4b4d695 Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 21:43:02 +0800 Subject: [PATCH 3/6] [BSP][DM365] update mmcsd driver. --- bsp/dm365/applications/application.c | 3 --- bsp/dm365/drivers/mmcsd.c | 5 ++++- bsp/dm365/drivers/mmcsd.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bsp/dm365/applications/application.c b/bsp/dm365/applications/application.c index 375a96935f..897f5ef149 100644 --- a/bsp/dm365/applications/application.c +++ b/bsp/dm365/applications/application.c @@ -67,9 +67,6 @@ int main(void) #endif #ifdef RT_USING_SDIO - rt_mmcsd_core_init(); - rt_mmcsd_blk_init(); - rt_hw_mmcsd_init(); timeout = 0; while ((rt_device_find("sd0") == RT_NULL) && (timeout++ < RT_TICK_PER_SECOND*2)) { diff --git a/bsp/dm365/drivers/mmcsd.c b/bsp/dm365/drivers/mmcsd.c index e459fbbd3b..00a1c045ea 100644 --- a/bsp/dm365/drivers/mmcsd.c +++ b/bsp/dm365/drivers/mmcsd.c @@ -1388,7 +1388,7 @@ static void rt_hw_edma_init(void) ** µ÷ÓÃÄ£¿é: ÎÞ ** ********************************************************************************************************/ -rt_int32_t rt_hw_mmcsd_init(void) +int rt_hw_mmcsd_init(void) { struct clk *clk; struct mmc_dm365_host *dm365_host; @@ -1477,3 +1477,6 @@ err: return -RT_ENOMEM; } + +INIT_DEVICE_EXPORT(rt_hw_mmcsd_init); + diff --git a/bsp/dm365/drivers/mmcsd.h b/bsp/dm365/drivers/mmcsd.h index cb33a43c72..71fb93649d 100644 --- a/bsp/dm365/drivers/mmcsd.h +++ b/bsp/dm365/drivers/mmcsd.h @@ -140,6 +140,6 @@ typedef struct { volatile rt_uint32_t MMCFIFOCTL; }mmcsd_regs_t; -extern rt_int32_t rt_hw_mmcsd_init(void); +extern int rt_hw_mmcsd_init(void); #endif From ce12bdd1bb0ae2bc614688333bebd6d945e645be Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 22:17:38 +0800 Subject: [PATCH 4/6] [BSP] update sdio driver for components init. --- bsp/fh8620/platform/fh8620/iot_cam/board.c | 4 ---- bsp/x1000/applications/mnt.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/bsp/fh8620/platform/fh8620/iot_cam/board.c b/bsp/fh8620/platform/fh8620/iot_cam/board.c index f7c9ebdcb1..8e45b9be90 100644 --- a/bsp/fh8620/platform/fh8620/iot_cam/board.c +++ b/bsp/fh8620/platform/fh8620/iot_cam/board.c @@ -584,10 +584,6 @@ void rt_board_driver_init(){ #ifdef RT_USING_SDIO #ifndef RT_USING_WIFI_MARVEL - rt_mmcsd_core_init(); - rt_kprintf("MMC CORE initialized!\n"); - rt_mmcsd_blk_init(); - rt_kprintf("MMC BLK initialized!\n"); rt_hw_mmc_init(); rt_kprintf("MMC initialized!\n"); rt_thread_delay(RT_TICK_PER_SECOND*2); diff --git a/bsp/x1000/applications/mnt.c b/bsp/x1000/applications/mnt.c index 4e09a6e2a0..df6be29b40 100644 --- a/bsp/x1000/applications/mnt.c +++ b/bsp/x1000/applications/mnt.c @@ -30,9 +30,6 @@ int mnt_init(void) { #ifdef RT_USING_SDIO - rt_mmcsd_core_init(); - rt_mmcsd_blk_init(); - jz47xx_sdio_init(); rt_thread_delay(RT_TICK_PER_SECOND * 1); From 86b9875d5eea034d96206b464e28cd6e8e6460b0 Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 22:22:09 +0800 Subject: [PATCH 5/6] [BSP] update sdio driver. --- bsp/imxrt1052-evk/drivers/drv_sdio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/bsp/imxrt1052-evk/drivers/drv_sdio.c b/bsp/imxrt1052-evk/drivers/drv_sdio.c index e80fef691f..33a9c81f89 100644 --- a/bsp/imxrt1052-evk/drivers/drv_sdio.c +++ b/bsp/imxrt1052-evk/drivers/drv_sdio.c @@ -554,9 +554,6 @@ err: int imxrt_mci_init(void) { - - rt_mmcsd_core_init(); - rt_mmcsd_blk_init(); /* initilize sd card */ _imxrt_mci_init(); From ed90b9d415763e22323f11755b63d32141842fb1 Mon Sep 17 00:00:00 2001 From: weety Date: Sun, 5 Nov 2017 22:36:46 +0800 Subject: [PATCH 6/6] [RTSERVICE] Add rt_list_for_each_entry_safe macros definition. --- include/rtservice.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/rtservice.h b/include/rtservice.h index 2c6682076d..2bf1fbe1d6 100644 --- a/include/rtservice.h +++ b/include/rtservice.h @@ -141,6 +141,19 @@ rt_inline unsigned int rt_list_len(const rt_list_t *l) &pos->member != (head); \ pos = rt_list_entry(pos->member.next, typeof(*pos), member)) +/** + * rt_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop cursor. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ +#define rt_list_for_each_entry_safe(pos, n, head, member) \ + for (pos = rt_list_entry((head)->next, typeof(*pos), member), \ + n = rt_list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = rt_list_entry(n->member.next, typeof(*n), member)) + /** * rt_list_first_entry - get the first element from a list * @ptr: the list head to take the element from.