[PATCH] staging: ft100: cleanup ft1000_usb.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



remove unused comments, check for memory leaks, add header.

Signed-off-by: Marek Belisko <marek.belisko@xxxxxxxxx>

---
 drivers/staging/ft1000/ft1000-usb/ft1000_usb.c |  145 +++++++----------------
 1 files changed, 44 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
index 4c1774f..35b655d 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
@@ -1,33 +1,36 @@
-//=====================================================
-// CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved.
-//
-//
-// This file is part of Express Card USB Driver
-//
-// $Id:
-//====================================================
-// 20090926; aelias; removed all compiler warnings; ubuntu 9.04;
2.6.28-15-generic
+/*
+ *  Express Card USB driver (ft1000)
+ *
+ *  Copyright (C) 2007 Qualcomm Inc. All Rights Reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *
+ */
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/usb.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
-#include "ft1000_usb.h"
-
-//#include <linux/sched.h>
-//#include <linux/ptrace.h>
-//#include <linux/slab.h>
-//#include <linux/string.h>
-//#include <linux/timer.h>
-//#include <linux/netdevice.h>
-//#include <linux/ioport.h>
-//#include <linux/delay.h>
-//#include <asm/io.h>
-//#include <asm/system.h>
 #include <linux/kthread.h>
 #include <linux/firmware.h>

+#include "ft1000_usb.h"
+
 MODULE_DESCRIPTION("FT1000 EXPRESS CARD DRIVER");
 MODULE_LICENSE("Dual MPL/GPL");
 MODULE_SUPPORTED_DEVICE("QFT FT1000 Express Cards");
@@ -80,22 +83,9 @@ int ft1000_poll_thread(void *arg)
 			}
 		}
 	}
-	//DEBUG("returned from polling thread\n");
 	return STATUS_SUCCESS;
 }

-//---------------------------------------------------------------------------
-// Function:    ft1000_probe
-//
-// Parameters:  struct usb_interface *interface  - passed by USB core
-//              struct usb_device_id *id         - passed by USB core
-// Returns:     0 - success
-//
-// Description: This function is invoked when the express card is plugged in
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
 static int ft1000_probe(struct usb_interface *interface,
 			const struct usb_device_id *id)
 {
@@ -117,7 +107,6 @@ static int ft1000_probe(struct usb_interface *interface,

 	memset(ft1000dev, 0, sizeof(*ft1000dev));

-	//get usb device
 	dev = interface_to_usbdev(interface);
 	DEBUG("ft1000_probe: usb device descriptor info:\n");
 	DEBUG("ft1000_probe: number of configuration is %d\n",
@@ -184,7 +173,7 @@ static int ft1000_probe(struct usb_interface *interface,
 	ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev);
 	if (ret < 0) {
 		printk("Error reading firmware. ret:%d\n", ret);	
-		return -ENOMEM;
+		return -EIO;
 	}	
 	
 	size = max_t(uint, dsp_fw->size, 4096);
@@ -192,31 +181,28 @@ static int ft1000_probe(struct usb_interface *interface,
 	
 	if (!pFileStart) {
 		release_firmware(dsp_fw);
-		return -ENOMEM;
+		goto err_mem;
 	}

 	memcpy(pFileStart, dsp_fw->data, dsp_fw->size);
 	FileLength = dsp_fw->size;
 	release_firmware(dsp_fw);

-	//download dsp image
 	DEBUG("ft1000_probe: start downloading dsp image...\n");
 	init_ft1000_netdev(ft1000dev);
 	pft1000info = (FT1000_INFO *) netdev_priv(ft1000dev->net);

-//    DEBUG("In probe: pft1000info=%x\n", pft1000info);
          // aelias [-] reason: warning: format ???%x??? expects type
???unsigned int???, but argument 2 has type ???struct FT1000_INFO *???
-	DEBUG("In probe: pft1000info=%x\n", (unsigned int)pft1000info);	//
aelias [+] reason: up
+	DEBUG("In probe: pft1000info=%x\n", (unsigned int)pft1000info);	

 	dsp_reload(ft1000dev);
-	gPollingfailed = FALSE;	//mbelian
+	gPollingfailed = FALSE;	
 	pft1000info->pPollThread =
 	    kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll");
-	msleep(500);		//mbelian
+	msleep(500);	

 	if (pft1000info->DSP_loading) {
-		DEBUG
-		    ("ERROR!!!! RETURN FROM ft1000_probe **********************\n");
-		return 0;
+		DEBUG("ERROR!!!! RETURN FROM ft1000_probe\n");
+		goto err_busy;
 	}

 	while (!pft1000info->CardReady) {
@@ -224,36 +210,28 @@ static int ft1000_probe(struct usb_interface *interface,
 			if (pft1000info->pPollThread) {
 				kthread_stop(pft1000info->pPollThread);
 			}
-			return 0;
+			goto err_busy;
 		}
 		msleep(100);
 		DEBUG("ft1000_probe::Waiting for Card Ready\n");
 	}

-	//initialize network device
 	DEBUG("ft1000_probe::Card Ready!!!! Registering network device\n");

 	reg_ft1000_netdev(ft1000dev, interface);

 	pft1000info->NetDevRegDone = 1;

-	ft1000InitProc(ft1000dev->net);	// +mbelian
+	ft1000InitProc(ft1000dev->net);

 	return 0;
+err_busy:
+	kfree(pFileStart);
+	return -EBUSY;
+err_mem:
+	return -ENOMEM;
 }

-//---------------------------------------------------------------------------
-// Function:    ft1000_disconnect
-//
-// Parameters:  struct usb_interface *interface  - passed by USB core
-//
-// Returns:     0 - success
-//
-// Description: This function is invoked when the express card is plugged out
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
 static void ft1000_disconnect(struct usb_interface *interface)
 {
 	FT1000_INFO *pft1000info;
@@ -261,11 +239,10 @@ static void ft1000_disconnect(struct
usb_interface *interface)
 	DEBUG("ft1000_disconnect is called\n");

 	pft1000info = (PFT1000_INFO) usb_get_intfdata(interface);
-//    DEBUG("In disconnect pft1000info=%x\n", pft1000info);     //
aelias [-] reason: warning: format ???%x??? expects type ???unsigned
int???, but argument 2 has type ???struct FT1000_INFO *???
-	DEBUG("In disconnect pft1000info=%x\n", (unsigned
int)pft1000info);	// aelias [+] reason: up
+	DEBUG("In disconnect pft1000info=%x\n", (unsigned int)pft1000info);

 	if (pft1000info) {
-		ft1000CleanupProc(pft1000info);	//+mbelian
+		ft1000CleanupProc(pft1000info);
 		if (pft1000info->pPollThread) {
 			kthread_stop(pft1000info->pPollThread);
 		}
@@ -275,14 +252,10 @@ static void ft1000_disconnect(struct
usb_interface *interface)
 		if (pft1000info->pFt1000Dev->net) {
 			DEBUG("ft1000_disconnect: destroy char driver\n");
 			ft1000_DestroyDevice(pft1000info->pFt1000Dev->net);
-			//DEBUG("ft1000_disconnect: calling ft1000_close\n");
-			//ft1000_close(pft1000info->pFt1000Dev->net);
-			//DEBUG("ft1000_disconnect: ft1000_close is called\n");
 			unregister_netdev(pft1000info->pFt1000Dev->net);
 			DEBUG
 			    ("ft1000_disconnect: network device unregisterd\n");
 			free_netdev(pft1000info->pFt1000Dev->net);
-
 		}

 		usb_free_urb(pft1000info->pFt1000Dev->rx_urb);
@@ -290,40 +263,22 @@ static void ft1000_disconnect(struct
usb_interface *interface)

 		DEBUG("ft1000_disconnect: urb freed\n");

-		kfree(pft1000info->pFt1000Dev);	//+mbelian
+		kfree(pft1000info->pFt1000Dev);
 	}
-	//terminate other kernel threads
-	//in multiple instances case, first find the device
-	//in the link list
-    /**if (pPollThread)
-    {
-        kthread_stop(pPollThread);
-        DEBUG("Polling thread is killed \n");
-    }**/
+
+	if (pFileStart)
+		kfree(pFileStart);

 	return;
 }

 static struct usb_driver ft1000_usb_driver = {
-	//.owner =    THIS_MODULE,
 	.name = "ft1000usb",
 	.probe = ft1000_probe,
 	.disconnect = ft1000_disconnect,
 	.id_table = id_table,
 };

-//---------------------------------------------------------------------------
-// Function:    usb_ft1000_init
-//
-// Parameters:  none
-//
-// Returns:     0 - success
-//
-// Description: The entry point of the module, register the usb driver
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
 static int __init usb_ft1000_init(void)
 {
 	int ret = 0;
@@ -337,18 +292,6 @@ static int __init usb_ft1000_init(void)
 	return ret;
 }

-//---------------------------------------------------------------------------
-// Function:    usb_ft1000_exit
-//
-// Parameters:
-//
-// Returns:
-//
-// Description: Moudle unload function, deregister usb driver
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
 static void __exit usb_ft1000_exit(void)
 {
 	DEBUG("Deregister the driver\n");
-- 
1.7.1
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux