Changeset 4740


Ignore:
Timestamp:
11/02/08 13:03:00 (8 years ago)
Author:
werner
Message:

More cleanup. Make the ar6k driver work as a module.

sdio-add-atheros-ar6k.patch:

  • moved Atheros and AR6k SDIO IDs to include/linux/mmc/sdio_ids.h

drivers/ar6000/hif/hif2.c:

  • explain why we can't make the io thread TASK_UNINTERRUPTIBLE
  • upon removal, wait for the request queue to drain
  • replaced global static hif_device with dynamic allocation
  • removed redefinition of dev_dbg
  • oops, ar6000_drv.c already has module_init and module_exit. Restructured initialization sequence accordingly.
  • print "HIFInit" only as KERN_DEBUG, not KERN_INFO
Location:
developers/werner/wlan-spi/patches-tracking
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch

    r4739 r4740  
    1212Index: ktrack/drivers/ar6000/Makefile 
    1313=================================================================== 
    14 --- ktrack.orig/drivers/ar6000/Makefile 2008-11-02 05:48:42.000000000 -0200 
    15 +++ ktrack/drivers/ar6000/Makefile      2008-11-02 05:48:44.000000000 -0200 
     14--- ktrack.orig/drivers/ar6000/Makefile 2008-11-02 08:01:22.000000000 -0200 
     15+++ ktrack/drivers/ar6000/Makefile      2008-11-02 08:04:17.000000000 -0200 
    1616@@ -21,7 +21,7 @@ 
    1717                htc/htc_recv.o             \ 
     
    2626=================================================================== 
    2727--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    28 +++ ktrack/drivers/ar6000/hif/hif2.c    2008-11-02 07:44:12.000000000 -0200 
    29 @@ -0,0 +1,569 @@ 
     28+++ ktrack/drivers/ar6000/hif/hif2.c    2008-11-02 11:01:12.000000000 -0200 
     29@@ -0,0 +1,592 @@ 
    3030+/* 
    3131+ * hif2.c - HIF layer re-implementation for the Linux SDIO stack 
     
    5353+#include <linux/mmc/sdio_func.h> 
    5454+#include <linux/mmc/sdio.h> 
     55+#include <linux/mmc/sdio_ids.h> 
    5556+#include <asm/gpio.h> 
    5657+ 
     
    9899+ */ 
    99100+ 
    100 + 
    101 +//#define dev_dbg dev_info 
    102 +#define dev_dbg(dev, ...) ((void) dev) 
    103101+ 
    104102+#define MBOXES                 4 
     
    140138+ 
    141139+ 
    142 +static HIF_DEVICE hif_device; 
    143140+static HTC_CALLBACKS htcCallbacks; 
    144141+ 
     
    197194+ 
    198195+ 
     196+static void wait_queue_empty(struct hif_device *hif) 
     197+{ 
     198+       unsigned long flags; 
     199+       int empty; 
     200+ 
     201+       while (1) { 
     202+               spin_lock_irqsave(&hif->queue_lock, flags); 
     203+               empty = list_empty(&hif->queue); 
     204+               spin_unlock_irqrestore(&hif->queue_lock, flags); 
     205+               if (empty) 
     206+                       break; 
     207+               else 
     208+                       yield(); 
     209+       } 
     210+} 
     211+ 
     212+ 
    199213+static int io(void *data) 
    200214+{ 
     
    205219+       while (1) { 
    206220+               while (1) { 
     221+                       /* 
     222+                        * Since we never use signals here, one might think 
     223+                        * that this ought to be TASK_UNINTERRUPTIBLE. However, 
     224+                        * such a task would increase the load average and, 
     225+                        * worse, it would trigger the softlockup check. 
     226+                        */ 
    207227+                       prepare_to_wait(&hif->wait, &wait, TASK_INTERRUPTIBLE); 
    208228+                       if (kthread_should_stop()) { 
     
    407427+ 
    408428+ 
    409 +/* ----- Device initialization and shutdown (HIF side) --------------------- */ 
    410 + 
    411 + 
    412 +int HIFInit(HTC_CALLBACKS *callbacks) 
    413 +{ 
    414 +       BUG_ON(!callbacks); 
    415 + 
    416 +       printk(KERN_INFO "HIFInit\n"); 
    417 +       htcCallbacks = *callbacks; 
    418 + 
    419 +       return 0; 
    420 +} 
     429+/* ----- Device configuration (HIF side) ----------------------------------- */ 
    421430+ 
    422431+ 
     
    451460+ 
    452461+ 
    453 +void HIFShutDownDevice(HIF_DEVICE *hif) 
    454 +{ 
    455 +       struct device *dev = HIFGetOSDevice(hif); 
    456 + 
    457 +       dev_dbg(dev, "HIFShutDownDevice\n"); 
    458 +} 
    459 + 
    460 + 
    461 +/* ----- Device setup and removal (Linux side) ----------------------------- */ 
     462+/* ----- Device probe and removal (Linux side) ----------------------------- */ 
    462463+ 
    463464+ 
     
    466467+{ 
    467468+       struct device *dev = &func->dev; 
     469+       struct hif_device *hif; 
    468470+       int ret; 
    469471+ 
     
    471473+       BUG_ON(!htcCallbacks.deviceInsertedHandler); 
    472474+ 
    473 +       sdio_set_drvdata(func, &hif_device); 
     475+       hif = kzalloc(sizeof(*hif), GFP_KERNEL); 
     476+       if (!hif) 
     477+               return -ENOMEM; 
     478+ 
     479+       sdio_set_drvdata(func, hif); 
    474480+       sdio_claim_host(func); 
    475481+       sdio_enable_func(func); 
    476482+ 
    477 +       hif_device.func = func; 
    478 +       INIT_LIST_HEAD(&hif_device.queue); 
    479 +       init_waitqueue_head(&hif_device.wait); 
    480 +       spin_lock_init(&hif_device.queue_lock); 
     483+       hif->func = func; 
     484+       INIT_LIST_HEAD(&hif->queue); 
     485+       init_waitqueue_head(&hif->wait); 
     486+       spin_lock_init(&hif->queue_lock); 
    481487+ 
    482488+       ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE); 
     
    502508+       sdio_release_host(func); 
    503509+ 
    504 +       hif_device.io_task = kthread_run(io, &hif_device, "ar6000_io"); 
    505 +       if (IS_ERR(hif_device.io_task)) { 
     510+       hif->io_task = kthread_run(io, hif, "ar6000_io"); 
     511+       if (IS_ERR(hif->io_task)) { 
    506512+               dev_err(dev, "kthread_run(ar6000_io): %d\n", ret); 
    507513+               goto out_func_ready; 
    508514+       } 
    509515+ 
    510 +       ret = htcCallbacks.deviceInsertedHandler(&hif_device); 
     516+       ret = htcCallbacks.deviceInsertedHandler(hif); 
    511517+       if (ret == A_OK) 
    512518+               return 0; 
     
    514520+       dev_err(dev, "deviceInsertedHandler: %d\n", ret); 
    515521+ 
    516 +       ret = kthread_stop(hif_device.io_task); 
     522+       ret = kthread_stop(hif->io_task); 
    517523+       if (ret) 
    518524+               dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret); 
     
    537543+{ 
    538544+       struct device *dev = &func->dev; 
     545+       HIF_DEVICE *hif = sdio_get_drvdata(func); 
    539546+       int ret; 
    540547+ 
    541 +       ret = kthread_stop(hif_device.io_task); 
     548+       ret = htcCallbacks.deviceRemovedHandler(hif->htc_handle, A_OK); 
     549+       if (ret != A_OK) 
     550+               dev_err(dev, "deviceRemovedHandler: %d\n", ret); 
     551+       wait_queue_empty(hif); 
     552+       ret = kthread_stop(hif->io_task); 
    542553+       if (ret) 
    543554+               dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret); 
    544555+       sdio_claim_host(func); 
    545556+       sdio_release_irq(func); 
     557+       sdio_set_drvdata(func, NULL); 
    546558+       sdio_disable_func(func); 
    547559+       sdio_release_host(func); 
    548 +       /* @@@ remove */ 
    549 +} 
    550 + 
    551 + 
    552 +/* @@@ move these definitions to linux/mmc/sdio_ids.h */ 
    553 +#define SDIO_VENDOR_ID_ATHEROS         0x271 
    554 +#define SDIO_DEVICE_ID_ATHEROS_AR6000  0x100 
     560+       kfree(hif); 
     561+} 
     562+ 
     563+ 
     564+/* ----- Device registration/unregistration (called by HIF) ---------------- */ 
     565+ 
    555566+ 
    556567+#define ATHEROS_SDIO_DEVICE(id, offset) \ 
     
    578589+ 
    579590+ 
    580 +static int __devinit sdio_ar6000_init(void) 
    581 +{ 
    582 +       printk(KERN_INFO "sdio_ar6000_init\n"); 
    583 +       return sdio_register_driver(&sdio_ar6000_driver); 
    584 +} 
    585 + 
    586 + 
    587 +static void __exit sdio_ar6000_exit(void) 
    588 +{ 
    589 +       printk(KERN_INFO "sdio_ar6000_exit\n"); 
     591+int HIFInit(HTC_CALLBACKS *callbacks) 
     592+{ 
     593+       int ret; 
     594+ 
     595+       BUG_ON(!callbacks); 
     596+ 
     597+       printk(KERN_DEBUG "HIFInit\n"); 
     598+       htcCallbacks = *callbacks; 
     599+ 
     600+       ret = sdio_register_driver(&sdio_ar6000_driver); 
     601+       if (ret) { 
     602+               printk(KERN_ERR 
     603+                   "sdio_register_driver(sdio_ar6000_driver): %d\n", ret); 
     604+               return A_ERROR; 
     605+       } 
     606+ 
     607+       return 0; 
     608+} 
     609+ 
     610+ 
     611+void HIFShutDownDevice(HIF_DEVICE *hif) 
     612+{ 
     613+       struct device *dev = HIFGetOSDevice(hif); 
     614+ 
     615+       dev_dbg(dev, "HIFShutDownDevice\n"); 
    590616+       sdio_unregister_driver(&sdio_ar6000_driver); 
    591617+} 
    592618+ 
    593 + 
    594 +module_init(sdio_ar6000_init); 
    595 +module_exit(sdio_ar6000_exit); 
    596619+ 
    597620+MODULE_AUTHOR("Werner Almesberger"); 
  • developers/werner/wlan-spi/patches-tracking/series

    r4737 r4740  
    1818ar6k-without-sdio.patch 
    1919gta02-remove-sdio.patch 
     20sdio-add-atheros-ar6k.patch 
    2021hif-linux-sdio.patch 
    2122gta02-mmc-spi-bitbang.patch 
     
    3233# still needs a bit more love ... 
    3334#s3c-mmc-sdio-int.patch 
     35#ecc 
Note: See TracChangeset for help on using the changeset viewer.