r4697 - developers/werner/wlan-spi/patches

werner at docs.openmoko.org werner at docs.openmoko.org
Tue Oct 7 17:05:10 CEST 2008


Author: werner
Date: 2008-10-07 17:05:10 +0200 (Tue, 07 Oct 2008)
New Revision: 4697

Modified:
   developers/werner/wlan-spi/patches/hif-can-do-async.patch
   developers/werner/wlan-spi/patches/hif-direct-interrupt.patch
   developers/werner/wlan-spi/patches/wlan-spi-hif.patch
Log:
Fix a major memory leak and clean up some old crud.

wlan-spi-hif.patch: 
- drivers/ar6000/hif/hif2.c (MODULE_DEVICE_TABLE): forgot to update the symbol 
  name after copy and paste
- drivers/ar6000/hif/hif2.c (process_request): free requests after processing 
  them, oopsie !
- drivers/ar6000/hif/hif2.c: to avoid confusion with "struct device", variables   of type "struct hif_device" are now called "hif", not "device"

hif-direct-interrupt.patch, hif-can-do-async.patch: updated for above changes



Modified: developers/werner/wlan-spi/patches/hif-can-do-async.patch
===================================================================
--- developers/werner/wlan-spi/patches/hif-can-do-async.patch	2008-10-07 13:14:07 UTC (rev 4696)
+++ developers/werner/wlan-spi/patches/hif-can-do-async.patch	2008-10-07 15:05:10 UTC (rev 4697)
@@ -6,9 +6,9 @@
 
 Index: korig/drivers/ar6000/hif/hif2.c
 ===================================================================
---- korig.orig/drivers/ar6000/hif/hif2.c	2008-10-01 09:34:27.000000000 -0300
-+++ korig/drivers/ar6000/hif/hif2.c	2008-10-01 09:34:39.000000000 -0300
-@@ -282,8 +282,7 @@
+--- korig.orig/drivers/ar6000/hif/hif2.c	2008-10-07 13:00:57.000000000 -0200
++++ korig/drivers/ar6000/hif/hif2.c	2008-10-07 13:01:08.000000000 -0200
+@@ -279,8 +279,7 @@
  			mbs_cfg[i] = HIF_MBOX_START_ADDR(i);
  		break;
  	case HIF_DEVICE_GET_IRQ_PROC_MODE:

Modified: developers/werner/wlan-spi/patches/hif-direct-interrupt.patch
===================================================================
--- developers/werner/wlan-spi/patches/hif-direct-interrupt.patch	2008-10-07 13:14:07 UTC (rev 4696)
+++ developers/werner/wlan-spi/patches/hif-direct-interrupt.patch	2008-10-07 15:05:10 UTC (rev 4697)
@@ -9,8 +9,8 @@
 
 Index: korig/drivers/ar6000/hif/hif2.c
 ===================================================================
---- korig.orig/drivers/ar6000/hif/hif2.c	2008-10-01 09:34:08.000000000 -0300
-+++ korig/drivers/ar6000/hif/hif2.c	2008-10-01 09:34:27.000000000 -0300
+--- korig.orig/drivers/ar6000/hif/hif2.c	2008-10-07 13:00:55.000000000 -0200
++++ korig/drivers/ar6000/hif/hif2.c	2008-10-07 13:00:57.000000000 -0200
 @@ -21,9 +21,13 @@
  #include <linux/list.h>
  #include <linux/wait.h>
@@ -67,7 +67,7 @@
  	sdio_release_host(req->func);
  	status = ret ? A_ERROR : A_OK;
  	if (req->completion)
-@@ -281,7 +302,7 @@
+@@ -278,7 +299,7 @@
  
  /* ========================================================================= */
  
@@ -76,7 +76,7 @@
  
  /*
   * Volatile ought to be good enough to make gcc do the right thing on S3C24xx.
-@@ -396,69 +417,64 @@
+@@ -393,69 +414,64 @@
  /*
   * The code below is for handling interrupts signalled out-of-band.
   */
@@ -91,21 +91,21 @@
 -static void sdio_ar6000_irq(struct sdio_func *func)
 +static void sdio_ar6000_work(struct work_struct *work)
  {
--	HIF_DEVICE *device = sdio_get_drvdata(func);
-+	HIF_DEVICE *device = container_of(work, struct hif_device, work);
-+	struct device *dev = HIFGetOSDevice(device);
+-	HIF_DEVICE *hif = sdio_get_drvdata(func);
++	HIF_DEVICE *hif = container_of(work, struct hif_device, work);
++	struct device *dev = HIFGetOSDevice(hif);
 +	A_STATUS status;
-+
-+	dev_dbg(dev, "sdio_ar6000_work-> %p\n", htcCallbacks.dsrHandler);
  
 -	printk(KERN_DEBUG "sdio_ar6000_irq -> %p\n", htcCallbacks.dsrHandler);
 -	BUG();
++	dev_dbg(dev, "sdio_ar6000_work-> %p\n", htcCallbacks.dsrHandler);
++
 +	/* absorb the usual initial stray interrupt */
-+	if (!device->htc_handle) {
-+		HIFAckInterrupt(device);
++	if (!hif->htc_handle) {
++		HIFAckInterrupt(hif);
 +		return;
 +	}
-+	status = htcCallbacks.dsrHandler(device->htc_handle);
++	status = htcCallbacks.dsrHandler(hif->htc_handle);
 +	BUG_ON(status != A_OK);
  }
  
@@ -113,10 +113,10 @@
 -static void sdio_ar6000_poll(void *context)
 +static irqreturn_t sdio_ar6000_irq(int irq, void *arg)
  {
--	HIF_DEVICE *device = context;
+-	HIF_DEVICE *hif = context;
 -	A_STATUS status;
-+	HIF_DEVICE *device = arg;
-+	struct device *dev = HIFGetOSDevice(device);
++	HIF_DEVICE *hif = arg;
++	struct device *dev = HIFGetOSDevice(hif);
  
 -	while (1) {
 -		yield();
@@ -124,66 +124,65 @@
 -			continue;
 -		if (!atomic_add_unless(&mask, 1, 1))
 -			continue;
--		status = htcCallbacks.dsrHandler(device->htc_handle);
+-		status = htcCallbacks.dsrHandler(hif->htc_handle);
 -		BUG_ON(status != A_OK);
 -	}
 +	dev_dbg(dev, "sdio_ar6000_irq\n");
-+	disable_irq(device->irq);
-+	if (!schedule_work(&device->work))
++	disable_irq(hif->irq);
++	if (!schedule_work(&hif->work))
 +		dev_err(dev, "work already queued");
 +	return IRQ_HANDLED;
  }
  
  
- void HIFAckInterrupt(HIF_DEVICE *device)
+ void HIFAckInterrupt(HIF_DEVICE *hif)
  {
- 	struct device *dev = HIFGetOSDevice(device);
+ 	struct device *dev = HIFGetOSDevice(hif);
 -	int ret;
  
 -	ret = atomic_dec_return(&mask);
 -	BUG_ON(ret < 0);
 -	dev_dbg(dev, "HIFAckInterrupt (%d)\n", ret);
 +	dev_dbg(dev, "HIFAckInterrupt)\n");
-+	enable_irq(device->irq);
++	enable_irq(hif->irq);
  }
  
  
- void HIFUnMaskInterrupt(HIF_DEVICE *device)
+ void HIFUnMaskInterrupt(HIF_DEVICE *hif)
  {
- 	struct device *dev = HIFGetOSDevice(device);
+ 	struct device *dev = HIFGetOSDevice(hif);
 -	int ret;
  
 -	ret = atomic_dec_return(&mask);
 -	BUG_ON(ret < 0);
 -	dev_dbg(dev, "HIFUnMaskInterrupt (%d)\n", ret);
 +	dev_dbg(dev, "HIFUnMaskInterrupt)\n");
-+	enable_irq(device->irq);
++	enable_irq(hif->irq);
  }
  
  
- void HIFMaskInterrupt(HIF_DEVICE *device)
+ void HIFMaskInterrupt(HIF_DEVICE *hif)
  {
- 	struct device *dev = HIFGetOSDevice(device);
+ 	struct device *dev = HIFGetOSDevice(hif);
 -	int ret;
  
 -	ret = atomic_inc_return(&mask);
 -	BUG_ON(ret > 1);
 -	dev_dbg(dev, "HIFMaskInterrupt (%d)\n", ret);
 +	dev_dbg(dev, "HIFMaskInterrupt\n");
-+	disable_irq(device->irq);
++	disable_irq(hif->irq);
  }
  #endif
  
-@@ -506,7 +522,7 @@
+@@ -503,6 +519,7 @@
  	struct device *dev = &func->dev;
  	int ret;
  	struct task_struct *task;
--
 +	u8 bus;
  
  	dev_dbg(dev, "sdio_ar6000_probe\n");
  	BUG_ON(!htcCallbacks.deviceInsertedHandler);
-@@ -524,11 +540,46 @@
+@@ -520,11 +537,46 @@
  		dev_err(dev, "sdio_set_block_size returns %d\n", ret);
  		/* @@@ cleanup */
  	}
@@ -232,8 +231,8 @@
  	    SDIO_CCCR_IF, &ret);
 Index: korig/drivers/spi/spi_bitbang.c
 ===================================================================
---- korig.orig/drivers/spi/spi_bitbang.c	2008-10-01 09:18:09.000000000 -0300
-+++ korig/drivers/spi/spi_bitbang.c	2008-10-01 09:34:27.000000000 -0300
+--- korig.orig/drivers/spi/spi_bitbang.c	2008-10-07 13:00:55.000000000 -0200
++++ korig/drivers/spi/spi_bitbang.c	2008-10-07 13:00:57.000000000 -0200
 @@ -323,6 +323,9 @@
  			 * selected ...)
  			 */

Modified: developers/werner/wlan-spi/patches/wlan-spi-hif.patch
===================================================================
--- developers/werner/wlan-spi/patches/wlan-spi-hif.patch	2008-10-07 13:14:07 UTC (rev 4696)
+++ developers/werner/wlan-spi/patches/wlan-spi-hif.patch	2008-10-07 15:05:10 UTC (rev 4697)
@@ -13,8 +13,8 @@
 
 Index: korig/drivers/ar6000/Makefile
 ===================================================================
---- korig.orig/drivers/ar6000/Makefile	2008-09-04 02:02:08.000000000 -0300
-+++ korig/drivers/ar6000/Makefile	2008-09-04 02:44:29.000000000 -0300
+--- korig.orig/drivers/ar6000/Makefile	2008-10-07 13:00:30.000000000 -0200
++++ korig/drivers/ar6000/Makefile	2008-10-07 13:00:32.000000000 -0200
 @@ -21,7 +21,7 @@
                 htc/htc_recv.o       	   \
                 htc/htc_services.o          \
@@ -27,8 +27,8 @@
 Index: korig/drivers/ar6000/hif/hif2.c
 ===================================================================
 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
-+++ korig/drivers/ar6000/hif/hif2.c	2008-09-04 02:52:58.000000000 -0300
-@@ -0,0 +1,629 @@
++++ korig/drivers/ar6000/hif/hif2.c	2008-10-07 13:00:43.000000000 -0200
+@@ -0,0 +1,625 @@
 +/*
 + * hif2.c - HIF layer re-implementation for the Linux SDIO stack
 + *
@@ -145,61 +145,62 @@
 +	status = ret ? A_ERROR : A_OK;
 +	if (req->completion)
 +		req->completion(req->context, status);
++	kfree(req);
 +	return status;
 +}
 +
 +
-+static void enqueue_request(struct hif_device *device, struct hif_request *req)
++static void enqueue_request(struct hif_device *hif, struct hif_request *req)
 +{
 +	unsigned long flags;
 +
 +	dev_dbg(&req->func->dev, "enqueue_request(req %p)\n", req);
-+	spin_lock_irqsave(&device->queue_lock, flags);
-+	list_add_tail(&req->list, &device->queue);
-+	spin_unlock_irqrestore(&device->queue_lock, flags);
-+	wake_up(&device->wait);
++	spin_lock_irqsave(&hif->queue_lock, flags);
++	list_add_tail(&req->list, &hif->queue);
++	spin_unlock_irqrestore(&hif->queue_lock, flags);
++	wake_up(&hif->wait);
 +}
 +
 +
-+static struct hif_request *dequeue_request(struct hif_device *device)
++static struct hif_request *dequeue_request(struct hif_device *hif)
 +{
 +	struct hif_request *req;
 +	unsigned long flags;
 +
-+	spin_lock_irqsave(&device->queue_lock, flags);
-+	if (list_empty(&device->queue))
++	spin_lock_irqsave(&hif->queue_lock, flags);
++	if (list_empty(&hif->queue))
 +		req = NULL;
 +	else {
-+		req = list_first_entry(&device->queue,
++		req = list_first_entry(&hif->queue,
 +		    struct hif_request, list);
 +		list_del(&req->list);
 +	}
-+	spin_unlock_irqrestore(&device->queue_lock, flags);
++	spin_unlock_irqrestore(&hif->queue_lock, flags);
 +	return req;
 +}
 +
 +
 +static int io(void *data)
 +{
-+	struct hif_device *device = data;
++	struct hif_device *hif = data;
 +	DECLARE_WAITQUEUE(wait, current);
 +	struct hif_request *req;
 +
 +	while (1) {
-+		add_wait_queue(&device->wait, &wait);
++		add_wait_queue(&hif->wait, &wait);
 +		while (1) {
 +			set_current_state(TASK_INTERRUPTIBLE);
 +			if (signal_pending(current)) {
 +				req = NULL;
 +				break;
 +			}
-+			req = dequeue_request(device);
++			req = dequeue_request(hif);
 +			if (req)
 +				break;
 +			schedule();
 +		}
 +		set_current_state(TASK_RUNNING);
-+		remove_wait_queue(&device->wait, &wait);
++		remove_wait_queue(&hif->wait, &wait);
 +
 +		if (!req)
 +			break;
@@ -210,16 +211,15 @@
 +}
 +
 +
-+A_STATUS HIFReadWrite(HIF_DEVICE *device, A_UINT32 address, A_UCHAR *buffer,
++A_STATUS HIFReadWrite(HIF_DEVICE *hif, A_UINT32 address, A_UCHAR *buffer,
 +    A_UINT32 length, A_UINT32 request, void *context)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +	struct hif_request *req;
-+	A_STATUS status;
 +
 +	dev_dbg(dev, "HIFReadWrite(device %p, address 0x%x, buffer %p, "
 +	    "length %d, request 0x%x, context %p)\n",
-+	    device, address, buffer, length, request, context);
++	    hif, address, buffer, length, request, context);
 +
 +	BUG_ON(!(request & (HIF_SYNCHRONOUS | HIF_ASYNCHRONOUS)));
 +	BUG_ON(!(request & (HIF_BYTE_BASIS | HIF_BLOCK_BASIS)));
@@ -241,7 +241,7 @@
 +		return A_ERROR;
 +	}
 +
-+	req->func = device->func;
++	req->func = hif->func;
 +	req->addr = address;
 +	req->buf = buffer;
 +	req->len = length;
@@ -258,24 +258,21 @@
 +			req->write = sdio_memcpy_toio;
 +	}
 +
-+	if (!(request & HIF_ASYNCHRONOUS)) {
-+		status = process_request(req);
-+		kfree(req);
-+		return status;
-+	}
++	if (!(request & HIF_ASYNCHRONOUS))
++		return process_request(req);
 +
 +	req->completion = htcCallbacks.rwCompletionHandler;
 +	req->context = context;
-+	enqueue_request(device, req);
++	enqueue_request(hif, req);
 +
 +	return A_OK;
 +}
 +
 +
-+A_STATUS HIFConfigureDevice(HIF_DEVICE *device,
++A_STATUS HIFConfigureDevice(HIF_DEVICE *hif,
 +    HIF_DEVICE_CONFIG_OPCODE opcode, void *config, A_UINT32 configLen)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +	HIF_DEVICE_IRQ_PROCESSING_MODE *ipm_cfg = config;
 +	A_UINT32 *mbs_cfg = config;
 +	int i;
@@ -302,9 +299,9 @@
 +}
 +
 +
-+void HIFShutDownDevice(HIF_DEVICE *device)
++void HIFShutDownDevice(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +
 +	dev_dbg(dev, "HIFShutDownDevice\n");
 +}
@@ -328,21 +325,21 @@
 +
 +static void ar6000_do_irq(struct sdio_func *func)
 +{
-+	HIF_DEVICE *device = sdio_get_drvdata(func);
-+	struct device *dev = HIFGetOSDevice(device);
++	HIF_DEVICE *hif = sdio_get_drvdata(func);
++	struct device *dev = HIFGetOSDevice(hif);
 +	A_STATUS status;
 +
 +	dev_dbg(dev, "ar6000_do_irq -> %p\n", htcCallbacks.dsrHandler);
 +
-+	status = htcCallbacks.dsrHandler(device->htc_handle);
++	status = htcCallbacks.dsrHandler(hif->htc_handle);
 +	BUG_ON(status != A_OK);
 +}
 +
 +
 +static void sdio_ar6000_irq(struct sdio_func *func)
 +{
-+	HIF_DEVICE *device = sdio_get_drvdata(func);
-+	struct device *dev = HIFGetOSDevice(device);
++	HIF_DEVICE *hif = sdio_get_drvdata(func);
++	struct device *dev = HIFGetOSDevice(hif);
 +
 +	dev_dbg(dev, "sdio_ar6000_irq\n");
 +
@@ -373,25 +370,25 @@
 +}
 +
 +
-+void HIFAckInterrupt(HIF_DEVICE *device)
++void HIFAckInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +
 +	dev_dbg(dev, "HIFAckInterrupt\n");
 +	/* do nothing */
 +}
 +
 +
-+void HIFUnMaskInterrupt(HIF_DEVICE *device)
++void HIFUnMaskInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +
 +	dev_dbg(dev, "HIFUnMaskInterrupt\n");
 +	do {
 +		masked = 1;
 +		if (pending) {
 +			pending = 0;
-+			ar6000_do_irq(device->func);
++			ar6000_do_irq(hif->func);
 +			/* We may take an interrupt before unmasking and thus
 +			   get it pending. In this case, we just loop back. */
 +		}
@@ -401,9 +398,9 @@
 +}
 +
 +
-+void HIFMaskInterrupt(HIF_DEVICE *device)
++void HIFMaskInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +
 +	dev_dbg(dev, "HIFMaskInterrupt\n");
 +	/*
@@ -436,7 +433,7 @@
 +
 +static void sdio_ar6000_irq(struct sdio_func *func)
 +{
-+	HIF_DEVICE *device = sdio_get_drvdata(func);
++	HIF_DEVICE *hif = sdio_get_drvdata(func);
 +
 +	printk(KERN_DEBUG "sdio_ar6000_irq -> %p\n", htcCallbacks.dsrHandler);
 +	BUG();
@@ -445,7 +442,7 @@
 +
 +static void sdio_ar6000_poll(void *context)
 +{
-+	HIF_DEVICE *device = context;
++	HIF_DEVICE *hif = context;
 +	A_STATUS status;
 +
 +	while (1) {
@@ -454,15 +451,15 @@
 +			continue;
 +		if (!atomic_add_unless(&mask, 1, 1))
 +			continue;
-+		status = htcCallbacks.dsrHandler(device->htc_handle);
++		status = htcCallbacks.dsrHandler(hif->htc_handle);
 +		BUG_ON(status != A_OK);
 +	}
 +}
 +
 +
-+void HIFAckInterrupt(HIF_DEVICE *device)
++void HIFAckInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +	int ret;
 +
 +	ret = atomic_dec_return(&mask);
@@ -471,9 +468,9 @@
 +}
 +
 +
-+void HIFUnMaskInterrupt(HIF_DEVICE *device)
++void HIFUnMaskInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +	int ret;
 +
 +	ret = atomic_dec_return(&mask);
@@ -482,9 +479,9 @@
 +}
 +
 +
-+void HIFMaskInterrupt(HIF_DEVICE *device)
++void HIFMaskInterrupt(HIF_DEVICE *hif)
 +{
-+	struct device *dev = HIFGetOSDevice(device);
++	struct device *dev = HIFGetOSDevice(hif);
 +	int ret;
 +
 +	ret = atomic_inc_return(&mask);
@@ -498,17 +495,17 @@
 +
 +/* ----- Some stuff needed for Atheros' API -------------------------------- */
 +
-+struct device *HIFGetOSDevice(HIF_DEVICE *device)
++struct device *HIFGetOSDevice(HIF_DEVICE *hif)
 +{
-+	return &device->func->dev;
++	return &hif->func->dev;
 +}
 +
 +
 +void HIFSetHandle(void *hif_handle, void *handle)
 +{
-+	HIF_DEVICE *device = (HIF_DEVICE *) hif_handle;
++	HIF_DEVICE *hif = (HIF_DEVICE *) hif_handle;
 +
-+	device->htc_handle = handle;
++	hif->htc_handle = handle;
 +}
 +
 +
@@ -538,7 +535,6 @@
 +	int ret;
 +	struct task_struct *task;
 +
-+
 +	dev_dbg(dev, "sdio_ar6000_probe\n");
 +	BUG_ON(!htcCallbacks.deviceInsertedHandler);
 +
@@ -628,7 +624,7 @@
 +	{ /* end: all zeroes */			},
 +};
 +
-+MODULE_DEVICE_TABLE(sdio, sdio_uart_ids);
++MODULE_DEVICE_TABLE(sdio, sdio_ar6000_ids);
 +
 +
 +static struct sdio_driver sdio_ar6000_driver = {




More information about the commitlog mailing list