浏览代码

Update sdio.c

ruiqian 7 年之前
父节点
当前提交
465fdfc2ff
共有 1 个文件被更改,包括 26 次插入8 次删除
  1. 26 8
      components/drivers/sdio/sdio.c

+ 26 - 8
components/drivers/sdio/sdio.c

@@ -29,8 +29,8 @@
 #ifndef RT_SDIO_STACK_SIZE
 #ifndef RT_SDIO_STACK_SIZE
 #define RT_SDIO_STACK_SIZE 512
 #define RT_SDIO_STACK_SIZE 512
 #endif
 #endif
-#ifndef RT_SDIO_THREAD_PREORITY
-#define RT_SDIO_THREAD_PREORITY  0x40
+#ifndef RT_SDIO_THREAD_PRIORITY
+#define RT_SDIO_THREAD_PRIORITY  0x40
 #endif
 #endif
 
 
 static rt_list_t sdio_cards;
 static rt_list_t sdio_cards;
@@ -1059,7 +1059,7 @@ static rt_int32_t sdio_irq_thread_create(struct rt_mmcsd_card *card)
         RT_ASSERT(host->sdio_irq_sem != RT_NULL);
         RT_ASSERT(host->sdio_irq_sem != RT_NULL);
 
 
         host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, 
         host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, 
-                             RT_SDIO_STACK_SIZE, RT_SDIO_THREAD_PREORITY, 20);
+                             RT_SDIO_STACK_SIZE, RT_SDIO_THREAD_PRIORITY, 20);
         if (host->sdio_irq_thread != RT_NULL) 
         if (host->sdio_irq_thread != RT_NULL) 
         {
         {
             rt_thread_startup(host->sdio_irq_thread);
             rt_thread_startup(host->sdio_irq_thread);
@@ -1079,7 +1079,7 @@ static rt_int32_t sdio_irq_thread_delete(struct rt_mmcsd_card *card)
     if (!host->sdio_irq_num) 
     if (!host->sdio_irq_num) 
     {
     {
         if (host->flags & MMCSD_SUP_SDIO_IRQ)
         if (host->flags & MMCSD_SUP_SDIO_IRQ)
-                host->ops->enable_sdio_irq(host, 0);
+            host->ops->enable_sdio_irq(host, 0);
         rt_sem_delete(host->sdio_irq_sem);
         rt_sem_delete(host->sdio_irq_sem);
         host->sdio_irq_sem = RT_NULL;
         host->sdio_irq_sem = RT_NULL;
         rt_thread_delete(host->sdio_irq_thread);
         rt_thread_delete(host->sdio_irq_thread);
@@ -1253,6 +1253,16 @@ err:
     return -RT_EIO;
     return -RT_EIO;
 }
 }
 
 
+void sdio_set_drvdata(struct rt_sdio_function *func, void *data)
+{
+    func->priv = data;
+}
+
+void* sdio_get_drvdata(struct rt_sdio_function *func)
+{
+    return func->priv;
+}
+
 rt_int32_t sdio_set_block_size(struct rt_sdio_function *func,
 rt_int32_t sdio_set_block_size(struct rt_sdio_function *func,
                                rt_uint32_t              blksize)
                                rt_uint32_t              blksize)
 {
 {
@@ -1284,16 +1294,24 @@ rt_int32_t sdio_set_block_size(struct rt_sdio_function *func,
 rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card           *card,
 rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card           *card,
                                      const struct rt_sdio_device_id *id)
                                      const struct rt_sdio_device_id *id)
 {
 {
+    rt_uint8_t num = 1;
+    
     if ((id->manufacturer != SDIO_ANY_MAN_ID) && 
     if ((id->manufacturer != SDIO_ANY_MAN_ID) && 
         (id->manufacturer != card->cis.manufacturer))
         (id->manufacturer != card->cis.manufacturer))
         return 0;
         return 0;
-    if ((id->product != SDIO_ANY_PROD_ID) && 
-        (id->product != (card->cis.product | 1)))
-        return 0;
+    
+    while (num <= card->sdio_function_num)
+    {
+        if ((id->product != SDIO_ANY_PROD_ID) && 
+            (id->product == card->sdio_function[num]->product))
+            return 1;
+        num++;
+    }
 
 
-    return 1;
+    return 0;
 }
 }
 
 
+
 static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id)
 static struct rt_mmcsd_card *sdio_match_driver(struct rt_sdio_device_id *id)
 {
 {
     rt_list_t *l;
     rt_list_t *l;