r4740 - developers/werner/wlan-spi/patches-tracking
werner at docs.openmoko.org
werner at docs.openmoko.org
Sun Nov 2 14:03:01 CET 2008
Author: werner
Date: 2008-11-02 14:03:00 +0100 (Sun, 02 Nov 2008)
New Revision: 4740
Added:
developers/werner/wlan-spi/patches-tracking/sdio-add-atheros-ar6k.patch
Modified:
developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch
developers/werner/wlan-spi/patches-tracking/series
Log:
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
Modified: developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch
===================================================================
--- developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch 2008-11-02 09:46:58 UTC (rev 4739)
+++ developers/werner/wlan-spi/patches-tracking/hif-linux-sdio.patch 2008-11-02 13:03:00 UTC (rev 4740)
@@ -11,8 +11,8 @@
Index: ktrack/drivers/ar6000/Makefile
===================================================================
---- ktrack.orig/drivers/ar6000/Makefile 2008-11-02 05:48:42.000000000 -0200
-+++ ktrack/drivers/ar6000/Makefile 2008-11-02 05:48:44.000000000 -0200
+--- ktrack.orig/drivers/ar6000/Makefile 2008-11-02 08:01:22.000000000 -0200
++++ ktrack/drivers/ar6000/Makefile 2008-11-02 08:04:17.000000000 -0200
@@ -21,7 +21,7 @@
htc/htc_recv.o \
htc/htc_services.o \
@@ -25,8 +25,8 @@
Index: ktrack/drivers/ar6000/hif/hif2.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ ktrack/drivers/ar6000/hif/hif2.c 2008-11-02 07:44:12.000000000 -0200
-@@ -0,0 +1,569 @@
++++ ktrack/drivers/ar6000/hif/hif2.c 2008-11-02 11:01:12.000000000 -0200
+@@ -0,0 +1,592 @@
+/*
+ * hif2.c - HIF layer re-implementation for the Linux SDIO stack
+ *
@@ -52,6 +52,7 @@
+#include <linux/spinlock.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio.h>
++#include <linux/mmc/sdio_ids.h>
+#include <asm/gpio.h>
+
+#include "athdefs.h"
@@ -98,9 +99,6 @@
+ */
+
+
-+//#define dev_dbg dev_info
-+#define dev_dbg(dev, ...) ((void) dev)
-+
+#define MBOXES 4
+
+#define HIF_MBOX_BLOCK_SIZE 128
@@ -139,7 +137,6 @@
+};
+
+
-+static HIF_DEVICE hif_device;
+static HTC_CALLBACKS htcCallbacks;
+
+
@@ -196,6 +193,23 @@
+}
+
+
++static void wait_queue_empty(struct hif_device *hif)
++{
++ unsigned long flags;
++ int empty;
++
++ while (1) {
++ spin_lock_irqsave(&hif->queue_lock, flags);
++ empty = list_empty(&hif->queue);
++ spin_unlock_irqrestore(&hif->queue_lock, flags);
++ if (empty)
++ break;
++ else
++ yield();
++ }
++}
++
++
+static int io(void *data)
+{
+ struct hif_device *hif = data;
@@ -204,6 +218,12 @@
+
+ while (1) {
+ while (1) {
++ /*
++ * Since we never use signals here, one might think
++ * that this ought to be TASK_UNINTERRUPTIBLE. However,
++ * such a task would increase the load average and,
++ * worse, it would trigger the softlockup check.
++ */
+ prepare_to_wait(&hif->wait, &wait, TASK_INTERRUPTIBLE);
+ if (kthread_should_stop()) {
+ finish_wait(&hif->wait, &wait);
@@ -406,20 +426,9 @@
+}
+
+
-+/* ----- Device initialization and shutdown (HIF side) --------------------- */
++/* ----- Device configuration (HIF side) ----------------------------------- */
+
+
-+int HIFInit(HTC_CALLBACKS *callbacks)
-+{
-+ BUG_ON(!callbacks);
-+
-+ printk(KERN_INFO "HIFInit\n");
-+ htcCallbacks = *callbacks;
-+
-+ return 0;
-+}
-+
-+
+A_STATUS HIFConfigureDevice(HIF_DEVICE *hif,
+ HIF_DEVICE_CONFIG_OPCODE opcode, void *config, A_UINT32 configLen)
+{
@@ -450,34 +459,31 @@
+}
+
+
-+void HIFShutDownDevice(HIF_DEVICE *hif)
-+{
-+ struct device *dev = HIFGetOSDevice(hif);
++/* ----- Device probe and removal (Linux side) ----------------------------- */
+
-+ dev_dbg(dev, "HIFShutDownDevice\n");
-+}
+
-+
-+/* ----- Device setup and removal (Linux side) ----------------------------- */
-+
-+
+static int sdio_ar6000_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ struct device *dev = &func->dev;
++ struct hif_device *hif;
+ int ret;
+
+ dev_dbg(dev, "sdio_ar6000_probe\n");
+ BUG_ON(!htcCallbacks.deviceInsertedHandler);
+
-+ sdio_set_drvdata(func, &hif_device);
++ hif = kzalloc(sizeof(*hif), GFP_KERNEL);
++ if (!hif)
++ return -ENOMEM;
++
++ sdio_set_drvdata(func, hif);
+ sdio_claim_host(func);
+ sdio_enable_func(func);
+
-+ hif_device.func = func;
-+ INIT_LIST_HEAD(&hif_device.queue);
-+ init_waitqueue_head(&hif_device.wait);
-+ spin_lock_init(&hif_device.queue_lock);
++ hif->func = func;
++ INIT_LIST_HEAD(&hif->queue);
++ init_waitqueue_head(&hif->wait);
++ spin_lock_init(&hif->queue_lock);
+
+ ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
+ if (ret < 0) {
@@ -501,19 +507,19 @@
+
+ sdio_release_host(func);
+
-+ hif_device.io_task = kthread_run(io, &hif_device, "ar6000_io");
-+ if (IS_ERR(hif_device.io_task)) {
++ hif->io_task = kthread_run(io, hif, "ar6000_io");
++ if (IS_ERR(hif->io_task)) {
+ dev_err(dev, "kthread_run(ar6000_io): %d\n", ret);
+ goto out_func_ready;
+ }
+
-+ ret = htcCallbacks.deviceInsertedHandler(&hif_device);
++ ret = htcCallbacks.deviceInsertedHandler(hif);
+ if (ret == A_OK)
+ return 0;
+
+ dev_err(dev, "deviceInsertedHandler: %d\n", ret);
+
-+ ret = kthread_stop(hif_device.io_task);
++ ret = kthread_stop(hif->io_task);
+ if (ret)
+ dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret);
+
@@ -536,23 +542,28 @@
+static void sdio_ar6000_remove(struct sdio_func *func)
+{
+ struct device *dev = &func->dev;
++ HIF_DEVICE *hif = sdio_get_drvdata(func);
+ int ret;
+
-+ ret = kthread_stop(hif_device.io_task);
++ ret = htcCallbacks.deviceRemovedHandler(hif->htc_handle, A_OK);
++ if (ret != A_OK)
++ dev_err(dev, "deviceRemovedHandler: %d\n", ret);
++ wait_queue_empty(hif);
++ ret = kthread_stop(hif->io_task);
+ if (ret)
+ dev_err(dev, "kthread_stop (ar6000_io): %d\n", ret);
+ sdio_claim_host(func);
+ sdio_release_irq(func);
++ sdio_set_drvdata(func, NULL);
+ sdio_disable_func(func);
+ sdio_release_host(func);
-+ /* @@@ remove */
++ kfree(hif);
+}
+
+
-+/* @@@ move these definitions to linux/mmc/sdio_ids.h */
-+#define SDIO_VENDOR_ID_ATHEROS 0x271
-+#define SDIO_DEVICE_ID_ATHEROS_AR6000 0x100
++/* ----- Device registration/unregistration (called by HIF) ---------------- */
+
++
+#define ATHEROS_SDIO_DEVICE(id, offset) \
+ SDIO_DEVICE(SDIO_VENDOR_ID_ATHEROS, SDIO_DEVICE_ID_ATHEROS_##id | (offset))
+
@@ -577,22 +588,34 @@
+};
+
+
-+static int __devinit sdio_ar6000_init(void)
++int HIFInit(HTC_CALLBACKS *callbacks)
+{
-+ printk(KERN_INFO "sdio_ar6000_init\n");
-+ return sdio_register_driver(&sdio_ar6000_driver);
++ int ret;
++
++ BUG_ON(!callbacks);
++
++ printk(KERN_DEBUG "HIFInit\n");
++ htcCallbacks = *callbacks;
++
++ ret = sdio_register_driver(&sdio_ar6000_driver);
++ if (ret) {
++ printk(KERN_ERR
++ "sdio_register_driver(sdio_ar6000_driver): %d\n", ret);
++ return A_ERROR;
++ }
++
++ return 0;
+}
+
+
-+static void __exit sdio_ar6000_exit(void)
++void HIFShutDownDevice(HIF_DEVICE *hif)
+{
-+ printk(KERN_INFO "sdio_ar6000_exit\n");
++ struct device *dev = HIFGetOSDevice(hif);
++
++ dev_dbg(dev, "HIFShutDownDevice\n");
+ sdio_unregister_driver(&sdio_ar6000_driver);
+}
+
+
-+module_init(sdio_ar6000_init);
-+module_exit(sdio_ar6000_exit);
-+
+MODULE_AUTHOR("Werner Almesberger");
+MODULE_LICENSE("GPL v2");
Added: developers/werner/wlan-spi/patches-tracking/sdio-add-atheros-ar6k.patch
===================================================================
--- developers/werner/wlan-spi/patches-tracking/sdio-add-atheros-ar6k.patch (rev 0)
+++ developers/werner/wlan-spi/patches-tracking/sdio-add-atheros-ar6k.patch 2008-11-02 13:03:00 UTC (rev 4740)
@@ -0,0 +1,12 @@
+Index: ktrack/include/linux/mmc/sdio_ids.h
+===================================================================
+--- ktrack.orig/include/linux/mmc/sdio_ids.h 2008-11-02 08:02:38.000000000 -0200
++++ ktrack/include/linux/mmc/sdio_ids.h 2008-11-02 08:02:55.000000000 -0200
+@@ -25,5 +25,7 @@
+
+ #define SDIO_VENDOR_ID_MARVELL 0x02df
+ #define SDIO_DEVICE_ID_MARVELL_LIBERTAS 0x9103
++#define SDIO_VENDOR_ID_ATHEROS 0x0271
++#define SDIO_DEVICE_ID_ATHEROS_AR6000 0x0100
+
+ #endif
Modified: developers/werner/wlan-spi/patches-tracking/series
===================================================================
--- developers/werner/wlan-spi/patches-tracking/series 2008-11-02 09:46:58 UTC (rev 4739)
+++ developers/werner/wlan-spi/patches-tracking/series 2008-11-02 13:03:00 UTC (rev 4740)
@@ -17,6 +17,7 @@
ar6k-without-sdio.patch
gta02-remove-sdio.patch
+sdio-add-atheros-ar6k.patch
hif-linux-sdio.patch
gta02-mmc-spi-bitbang.patch
@@ -31,3 +32,4 @@
# still needs a bit more love ...
#s3c-mmc-sdio-int.patch
+#ecc
More information about the commitlog
mailing list