diff options
Diffstat (limited to 'drivers/staging/ft1000/ft1000-usb')
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 1204 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 400 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 436 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 60 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 97 | ||||
-rw-r--r-- | drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 4 |
6 files changed, 1069 insertions, 1132 deletions
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index 0f347ab0d300..c8d278229940 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -1,31 +1,34 @@ /* -*--------------------------------------------------------------------------- -* FT1000 driver for Flarion Flash OFDM NIC Device -* -* Copyright (C) 2006 Flarion Technologies, 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., 59 Temple Place - -* Suite 330, Boston, MA 02111-1307, USA. -*--------------------------------------------------------------------------- -* -* File: ft1000_chdev.c -* -* Description: Custom character device dispatch routines. -* -* History: -* 8/29/02 Whc Ported to Linux. -* 6/05/06 Whc Porting to Linux 2.6.9 -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * FT1000 driver for Flarion Flash OFDM NIC Device + * + * Copyright (C) 2006 Flarion Technologies, 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., 59 Temple Place - + * Suite 330, Boston, MA 02111-1307, USA. + *--------------------------------------------------------------------------- + * + * File: ft1000_chdev.c + * + * Description: Custom character device dispatch routines. + * + * History: + * 8/29/02 Whc Ported to Linux. + * 6/05/06 Whc Porting to Linux 2.6.9 + * + *--------------------------------------------------------------------------- + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/module.h> #include <linux/kernel.h> #include <linux/sched.h> @@ -38,12 +41,12 @@ #include <linux/debugfs.h> #include "ft1000_usb.h" -static int ft1000_flarion_cnt = 0; +static int ft1000_flarion_cnt; static int ft1000_open(struct inode *inode, struct file *file); static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait); static long ft1000_ioctl(struct file *file, unsigned int command, - unsigned long argument); + unsigned long argument); static int ft1000_release(struct inode *inode, struct file *file); /* List to free receive command buffer pool */ @@ -55,8 +58,8 @@ spinlock_t free_buff_lock; int numofmsgbuf = 0; /* -* Table of entry-point routines for char device -*/ + * Table of entry-point routines for char device + */ static const struct file_operations ft1000fops = { .unlocked_ioctl = ft1000_ioctl, .poll = ft1000_poll_dev, @@ -66,104 +69,104 @@ static const struct file_operations ft1000fops = { }; /* ---------------------------------------------------------------------------- -* Function: ft1000_get_buffer -* -* Parameters: -* -* Returns: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + --------------------------------------------------------------------------- + * Function: ft1000_get_buffer + * + * Parameters: + * + * Returns: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) { - unsigned long flags; + unsigned long flags; struct dpram_blk *ptr; - spin_lock_irqsave(&free_buff_lock, flags); - /* Check if buffer is available */ - if (list_empty(bufflist)) { - DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf); - ptr = NULL; - } else { - numofmsgbuf--; - ptr = list_entry(bufflist->next, struct dpram_blk, list); - list_del(&ptr->list); - /* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ - } - spin_unlock_irqrestore(&free_buff_lock, flags); - - return ptr; + spin_lock_irqsave(&free_buff_lock, flags); + /* Check if buffer is available */ + if (list_empty(bufflist)) { + pr_debug("No more buffer - %d\n", numofmsgbuf); + ptr = NULL; + } else { + numofmsgbuf--; + ptr = list_entry(bufflist->next, struct dpram_blk, list); + list_del(&ptr->list); + /* pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */ + } + spin_unlock_irqrestore(&free_buff_lock, flags); + + return ptr; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_free_buffer -* -* Parameters: -* -* Returns: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_free_buffer + * + * Parameters: + * + * Returns: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist) { - unsigned long flags; - - spin_lock_irqsave(&free_buff_lock, flags); - /* Put memory back to list */ - list_add_tail(&pdpram_blk->list, plist); - numofmsgbuf++; - /*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */ - spin_unlock_irqrestore(&free_buff_lock, flags); + unsigned long flags; + + spin_lock_irqsave(&free_buff_lock, flags); + /* Put memory back to list */ + list_add_tail(&pdpram_blk->list, plist); + numofmsgbuf++; + /*pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */ + spin_unlock_irqrestore(&free_buff_lock, flags); } /* -*--------------------------------------------------------------------------- -* Function: ft1000_CreateDevice -* -* Parameters: dev - pointer to adapter object -* -* Returns: 0 if successful -* -* Description: Creates a private char device. -* -* Notes: Only called by init_module(). -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_CreateDevice + * + * Parameters: dev - pointer to adapter object + * + * Returns: 0 if successful + * + * Description: Creates a private char device. + * + * Notes: Only called by init_module(). + * + *--------------------------------------------------------------------------- + */ int ft1000_create_dev(struct ft1000_usb *dev) { - int result; - int i; + int result; + int i; struct dentry *dir, *file; struct ft1000_debug_dirs *tmp; - /* make a new device name */ - sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); + /* make a new device name */ + sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); - DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); - DEBUG("DeviceCreated = %x\n", dev->DeviceCreated); + pr_debug("number of instance = %d\n", ft1000_flarion_cnt); + pr_debug("DeviceCreated = %x\n", dev->DeviceCreated); - if (dev->DeviceCreated) { - DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName); - return -EIO; - } + if (dev->DeviceCreated) { + pr_debug("\"%s\" already registered\n", dev->DeviceName); + return -EIO; + } - /* register the device */ - DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); + /* register the device */ + pr_debug("\"%s\" debugfs device registration\n", dev->DeviceName); tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL); if (tmp == NULL) { @@ -178,7 +181,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) } file = debugfs_create_file("device", S_IRUGO | S_IWUSR, dir, - dev, &ft1000fops); + dev, &ft1000fops); if (IS_ERR(file)) { result = PTR_ERR(file); goto debug_file_fail; @@ -189,25 +192,25 @@ int ft1000_create_dev(struct ft1000_usb *dev) tmp->int_number = dev->CardNumber; list_add(&(tmp->list), &(dev->nodes.list)); - DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); - - /* initialize application information */ - dev->appcnt = 0; - for (i=0; i<MAX_NUM_APP; i++) { - dev->app_info[i].nTxMsg = 0; - dev->app_info[i].nRxMsg = 0; - dev->app_info[i].nTxMsgReject = 0; - dev->app_info[i].nRxMsgMiss = 0; - dev->app_info[i].fileobject = NULL; - dev->app_info[i].app_id = i+1; - dev->app_info[i].DspBCMsgFlag = 0; - dev->app_info[i].NumOfMsg = 0; - init_waitqueue_head(&dev->app_info[i].wait_dpram_msg); - INIT_LIST_HEAD(&dev->app_info[i].app_sqlist); - } - - dev->DeviceCreated = TRUE; - ft1000_flarion_cnt++; + pr_debug("registered debugfs directory \"%s\"\n", dev->DeviceName); + + /* initialize application information */ + dev->appcnt = 0; + for (i = 0; i < MAX_NUM_APP; i++) { + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; + dev->app_info[i].fileobject = NULL; + dev->app_info[i].app_id = i+1; + dev->app_info[i].DspBCMsgFlag = 0; + dev->app_info[i].NumOfMsg = 0; + init_waitqueue_head(&dev->app_info[i].wait_dpram_msg); + INIT_LIST_HEAD(&dev->app_info[i].app_sqlist); + } + + dev->DeviceCreated = TRUE; + ft1000_flarion_cnt++; return 0; @@ -220,33 +223,29 @@ fail: } /* -*--------------------------------------------------------------------------- -* Function: ft1000_DestroyDeviceDEBUG -* -* Parameters: dev - pointer to adapter object -* -* Description: Destroys a private char device. -* -* Notes: Only called by cleanup_module(). -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_DestroyDeviceDEBUG + * + * Parameters: dev - pointer to adapter object + * + * Description: Destroys a private char device. + * + * Notes: Only called by cleanup_module(). + * + *--------------------------------------------------------------------------- + */ void ft1000_destroy_dev(struct net_device *netdev) { struct ft1000_info *info = netdev_priv(netdev); struct ft1000_usb *dev = info->priv; - int i; + int i; struct dpram_blk *pdpram_blk; struct dpram_blk *ptr; struct list_head *pos, *q; struct ft1000_debug_dirs *dir; - DEBUG("%s called\n", __func__); - - - - if (dev->DeviceCreated) { - ft1000_flarion_cnt--; + if (dev->DeviceCreated) { + ft1000_flarion_cnt--; list_for_each_safe(pos, q, &dev->nodes.list) { dir = list_entry(pos, struct ft1000_debug_dirs, list); if (dir->int_number == dev->CardNumber) { @@ -256,29 +255,28 @@ void ft1000_destroy_dev(struct net_device *netdev) kfree(dir); } } - DEBUG("%s: unregistered device \"%s\"\n", __func__, - dev->DeviceName); - - /* Make sure we free any memory reserve for slow Queue */ - for (i=0; i<MAX_NUM_APP; i++) { - while (list_empty(&dev->app_info[i].app_sqlist) == 0) { - pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000_free_buffer(pdpram_blk, &freercvpool); - - } - wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); - } - - /* Remove buffer allocated for receive command data */ - if (ft1000_flarion_cnt == 0) { - while (list_empty(&freercvpool) == 0) { - ptr = list_entry(freercvpool.next, struct dpram_blk, list); - list_del(&ptr->list); - kfree(ptr->pbuffer); - kfree(ptr); - } - } + pr_debug("unregistered device \"%s\"\n", dev->DeviceName); + + /* Make sure we free any memory reserve for slow Queue */ + for (i = 0; i < MAX_NUM_APP; i++) { + while (list_empty(&dev->app_info[i].app_sqlist) == 0) { + pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000_free_buffer(pdpram_blk, &freercvpool); + + } + wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); + } + + /* Remove buffer allocated for receive command data */ + if (ft1000_flarion_cnt == 0) { + while (list_empty(&freercvpool) == 0) { + ptr = list_entry(freercvpool.next, struct dpram_blk, list); + list_del(&ptr->list); + kfree(ptr->pbuffer); + kfree(ptr); + } + } dev->DeviceCreated = FALSE; } @@ -286,507 +284,499 @@ void ft1000_destroy_dev(struct net_device *netdev) } /* -*--------------------------------------------------------------------------- -* Function: ft1000_open -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_open + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static int ft1000_open(struct inode *inode, struct file *file) { struct ft1000_info *info; struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private; - int i,num; + int i, num; - DEBUG("%s called\n", __func__); - num = (MINOR(inode->i_rdev) & 0xf); - DEBUG("ft1000_open: minor number=%d\n", num); + num = (MINOR(inode->i_rdev) & 0xf); + pr_debug("minor number=%d\n", num); info = file->private_data = netdev_priv(dev->net); - DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt); - - /* Check if maximum number of application exceeded */ - if (dev->appcnt > MAX_NUM_APP) { - DEBUG("Maximum number of application exceeded\n"); - return -EACCES; - } - - /* Search for available application info block */ - for (i=0; i<MAX_NUM_APP; i++) { - if ((dev->app_info[i].fileobject == NULL)) { - break; - } - } - - /* Fail due to lack of application info block */ - if (i == MAX_NUM_APP) { - DEBUG("Could not find an application info block\n"); - return -EACCES; - } - - dev->appcnt++; - dev->app_info[i].fileobject = &file->f_owner; - dev->app_info[i].nTxMsg = 0; - dev->app_info[i].nRxMsg = 0; - dev->app_info[i].nTxMsgReject = 0; - dev->app_info[i].nRxMsgMiss = 0; + pr_debug("f_owner = %p number of application = %d\n", + &file->f_owner, dev->appcnt); + + /* Check if maximum number of application exceeded */ + if (dev->appcnt > MAX_NUM_APP) { + pr_debug("Maximum number of application exceeded\n"); + return -EACCES; + } + + /* Search for available application info block */ + for (i = 0; i < MAX_NUM_APP; i++) { + if ((dev->app_info[i].fileobject == NULL)) { + break; + } + } + + /* Fail due to lack of application info block */ + if (i == MAX_NUM_APP) { + pr_debug("Could not find an application info block\n"); + return -EACCES; + } + + dev->appcnt++; + dev->app_info[i].fileobject = &file->f_owner; + dev->app_info[i].nTxMsg = 0; + dev->app_info[i].nRxMsg = 0; + dev->app_info[i].nTxMsgReject = 0; + dev->app_info[i].nRxMsgMiss = 0; nonseekable_open(inode, file); - return 0; + return 0; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_poll_dev -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_poll_dev + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) { - struct net_device *netdev = file->private_data; + struct net_device *netdev = file->private_data; struct ft1000_info *info = netdev_priv(netdev); struct ft1000_usb *dev = info->priv; - int i; - - /* DEBUG("ft1000_poll_dev called\n"); */ - if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); - return (-EBADF); - } - - /* Search for matching file object */ - for (i=0; i<MAX_NUM_APP; i++) { - if (dev->app_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); */ - break; - } - } - - /* Could not find application info block */ - if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); - return (-EACCES); - } - - if (list_empty(&dev->app_info[i].app_sqlist) == 0) { - DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n"); - return(POLLIN | POLLRDNORM | POLLPRI); - } - - poll_wait(file, &dev->app_info[i].wait_dpram_msg, wait); - /* DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); */ + int i; + + if (ft1000_flarion_cnt == 0) { + pr_debug("called with ft1000_flarion_cnt value zero\n"); + return -EBADF; + } + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (dev->app_info[i].fileobject == &file->f_owner) { + /* pr_debug("Message is for AppId = %d\n", dev->app_info[i].app_id); */ + break; + } + } + + /* Could not find application info block */ + if (i == MAX_NUM_APP) { + pr_debug("Could not find application info block\n"); + return -EACCES; + } + + if (list_empty(&dev->app_info[i].app_sqlist) == 0) { + pr_debug("Message detected in slow queue\n"); + return(POLLIN | POLLRDNORM | POLLPRI); + } + + poll_wait(file, &dev->app_info[i].wait_dpram_msg, wait); + /* pr_debug("Polling for data from DSP\n"); */ return 0; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_ioctl -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_ioctl + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static long ft1000_ioctl(struct file *file, unsigned int command, - unsigned long argument) + unsigned long argument) { - void __user *argp = (void __user *)argument; + void __user *argp = (void __user *)argument; struct ft1000_info *info; - struct ft1000_usb *ft1000dev; - int result=0; - int cmd; - int i; - u16 tempword; - unsigned long flags; - struct timeval tv; + struct ft1000_usb *ft1000dev; + int result = 0; + int cmd; + int i; + u16 tempword; + unsigned long flags; + struct timeval tv; struct IOCTL_GET_VER get_ver_data; struct IOCTL_GET_DSP_STAT get_stat_data; - u8 ConnectionMsg[] = {0x00,0x44,0x10,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x93,0x64, - 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x02,0x37,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x01,0x7f,0x00, - 0x00,0x01,0x00,0x00}; + u8 ConnectionMsg[] = {0x00, 0x44, 0x10, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x93, 0x64, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7f, 0x00, + 0x00, 0x01, 0x00, 0x00}; + + unsigned short ledStat = 0; + unsigned short conStat = 0; + + if (ft1000_flarion_cnt == 0) { + pr_debug("called with ft1000_flarion_cnt of zero\n"); + return -EBADF; + } - unsigned short ledStat=0; - unsigned short conStat=0; + /* pr_debug("command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ - /* DEBUG("ft1000_ioctl called\n"); */ + info = file->private_data; + ft1000dev = info->priv; + cmd = _IOC_NR(command); + /* pr_debug("cmd = 0x%x\n", cmd); */ + + /* process the command */ + switch (cmd) { + case IOCTL_REGISTER_CMD: + pr_debug("IOCTL_FT1000_REGISTER called\n"); + result = get_user(tempword, (__u16 __user *)argp); + if (result) { + pr_debug("result = %d failed to get_user\n", result); + break; + } + if (tempword == DSPBCMSGID) { + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + ft1000dev->app_info[i].DspBCMsgFlag = 1; + pr_debug("Registered for broadcast messages\n"); + break; + } + } + } + break; - if (ft1000_flarion_cnt == 0) { - DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); - return (-EBADF); - } + case IOCTL_GET_VER_CMD: + pr_debug("IOCTL_FT1000_GET_VER called\n"); - /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */ + get_ver_data.drv_ver = FT1000_DRV_VER; - info = file->private_data; - ft1000dev = info->priv; - cmd = _IOC_NR(command); - /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */ - - /* process the command */ - switch (cmd) { - case IOCTL_REGISTER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n"); - result = get_user(tempword, (__u16 __user*)argp); - if (result) { - DEBUG("result = %d failed to get_user\n", result); - break; - } - if (tempword == DSPBCMSGID) { - /* Search for matching file object */ - for (i=0; i<MAX_NUM_APP; i++) { - if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - ft1000dev->app_info[i].DspBCMsgFlag = 1; - DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n"); - break; - } - } - } - break; - - case IOCTL_GET_VER_CMD: - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_VER called\n"); - - get_ver_data.drv_ver = FT1000_DRV_VER; - - if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; - break; - } - - DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n",(unsigned int)get_ver_data.drv_ver); - - break; - case IOCTL_CONNECT: - /* Connect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n"); - ConnectionMsg[79] = 0xfc; - result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); - - break; - case IOCTL_DISCONNECT: - /* Disconnect Message */ - DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n"); - ConnectionMsg[79] = 0xfd; - result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); - break; - case IOCTL_GET_DSP_STAT_CMD: - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */ - memset(&get_stat_data, 0, sizeof(get_stat_data)); - memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); - memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); - memcpy(get_stat_data.Sku, info->Sku, SKUSZ); - memcpy(get_stat_data.eui64, info->eui64, EUISZ); - - if (info->ProgConStat != 0xFF) { - ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); - get_stat_data.LedStat = ntohs(ledStat); - DEBUG("FT1000:ft1000_ioctl: LedStat = 0x%x\n", get_stat_data.LedStat); - ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); - get_stat_data.ConStat = ntohs(conStat); - DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat); - } else { - get_stat_data.ConStat = 0x0f; - } - - - get_stat_data.nTxPkts = info->stats.tx_packets; - get_stat_data.nRxPkts = info->stats.rx_packets; - get_stat_data.nTxBytes = info->stats.tx_bytes; - get_stat_data.nRxBytes = info->stats.rx_bytes; - do_gettimeofday(&tv); - get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm); - DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm); - if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; - break; - } - DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n"); - break; - case IOCTL_SET_DPRAM_CMD: - { + if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) { + pr_debug("copy fault occurred\n"); + result = -EFAULT; + break; + } + + pr_debug("driver version = 0x%x\n", + (unsigned int)get_ver_data.drv_ver); + + break; + case IOCTL_CONNECT: + /* Connect Message */ + pr_debug("IOCTL_FT1000_CONNECT\n"); + ConnectionMsg[79] = 0xfc; + result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); + + break; + case IOCTL_DISCONNECT: + /* Disconnect Message */ + pr_debug("IOCTL_FT1000_DISCONNECT\n"); + ConnectionMsg[79] = 0xfd; + result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); + break; + case IOCTL_GET_DSP_STAT_CMD: + /* pr_debug("IOCTL_FT1000_GET_DSP_STAT\n"); */ + memset(&get_stat_data, 0, sizeof(get_stat_data)); + memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); + memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); + memcpy(get_stat_data.Sku, info->Sku, SKUSZ); + memcpy(get_stat_data.eui64, info->eui64, EUISZ); + + if (info->ProgConStat != 0xFF) { + ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX); + get_stat_data.LedStat = ntohs(ledStat); + pr_debug("LedStat = 0x%x\n", get_stat_data.LedStat); + ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX); + get_stat_data.ConStat = ntohs(conStat); + pr_debug("ConStat = 0x%x\n", get_stat_data.ConStat); + } else { + get_stat_data.ConStat = 0x0f; + } + + + get_stat_data.nTxPkts = info->stats.tx_packets; + get_stat_data.nRxPkts = info->stats.rx_packets; + get_stat_data.nTxBytes = info->stats.tx_bytes; + get_stat_data.nRxBytes = info->stats.rx_bytes; + do_gettimeofday(&tv); + get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm); + pr_debug("Connection Time = %d\n", (int)get_stat_data.ConTm); + if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) { + pr_debug("copy fault occurred\n"); + result = -EFAULT; + break; + } + pr_debug("GET_DSP_STAT succeed\n"); + break; + case IOCTL_SET_DPRAM_CMD: + { struct IOCTL_DPRAM_BLK *dpram_data = NULL; /* struct IOCTL_DPRAM_COMMAND dpram_command; */ - u16 qtype; - u16 msgsz; + u16 qtype; + u16 msgsz; struct pseudo_hdr *ppseudo_hdr; - u16 *pmsg; - u16 total_len; - u16 app_index; - u16 status; + u16 *pmsg; + u16 total_len; + u16 app_index; + u16 status; - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/ + /* pr_debug("IOCTL_FT1000_SET_DPRAM called\n");*/ - if (ft1000_flarion_cnt == 0) { - return (-EBADF); - } + if (ft1000_flarion_cnt == 0) + return -EBADF; - if (ft1000dev->DrvMsgPend) { - return (-ENOTTY); - } + if (ft1000dev->DrvMsgPend) + return -ENOTTY; - if (ft1000dev->fProvComplete == 0) { - return (-EACCES); - } + if (ft1000dev->fProvComplete == 0) + return -EACCES; - ft1000dev->fAppMsgPend = 1; + ft1000dev->fAppMsgPend = 1; - if (info->CardReady) { + if (info->CardReady) { - /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */ + /* pr_debug("try to SET_DPRAM\n"); */ - /* Get the length field to see how many bytes to copy */ - result = get_user(msgsz, (__u16 __user *)argp); - if (result) - break; - msgsz = ntohs(msgsz); - /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */ - - if (msgsz > MAX_CMD_SQSIZE) { - DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz); - result = -EINVAL; - break; - } - - result = -ENOMEM; - dpram_data = kmalloc(msgsz + 2, GFP_KERNEL); - if (!dpram_data) - break; + /* Get the length field to see how many bytes to copy */ + result = get_user(msgsz, (__u16 __user *)argp); + if (result) + break; + msgsz = ntohs(msgsz); + /* pr_debug("length of message = %d\n", msgsz); */ + + if (msgsz > MAX_CMD_SQSIZE) { + pr_debug("bad message length = %d\n", msgsz); + result = -EINVAL; + break; + } - if (copy_from_user(dpram_data, argp, msgsz+2)) { - DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n"); - result = -EFAULT; - } else { - /* Check if this message came from a registered application */ - for (i=0; i<MAX_NUM_APP; i++) { - if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - break; - } - } - if (i==MAX_NUM_APP) { - DEBUG("FT1000:No matching application fileobject\n"); - result = -EINVAL; - kfree(dpram_data); - break; - } - app_index = i; - - /* Check message qtype type which is the lower byte within qos_class */ - qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; - /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */ - if (qtype) { - } else { - /* Put message into Slow Queue */ - /* Only put a message into the DPRAM if msg doorbell is available */ - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */ - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 2ms and try again due to DSP doorbell busy */ - mdelay(2); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 1ms and try again due to DSP doorbell busy */ - mdelay(1); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - /* Suspend for 3ms and try again due to DSP doorbell busy */ - mdelay(3); - status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); - if (tempword & FT1000_DB_DPRAM_TX) { - DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n"); - result = -ENOTTY; - kfree(dpram_data); - break; - } - } - } - } - } - - /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */ - - /* Make sure we are within the limits of the slow queue memory limitation */ - if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) { - /* Need to put sequence number plus new checksum for message */ - pmsg = (u16 *)&dpram_data->pseudohdr; - ppseudo_hdr = (struct pseudo_hdr *)pmsg; - total_len = msgsz+2; - if (total_len & 0x1) { - total_len++; - } - - /* Insert slow queue sequence number */ - ppseudo_hdr->seq_num = info->squeseqnum++; - ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; - /* Calculate new checksum */ - ppseudo_hdr->checksum = *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ - for (i=1; i<7; i++) { - ppseudo_hdr->checksum ^= *pmsg++; - /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */ - } - pmsg++; - ppseudo_hdr = (struct pseudo_hdr *)pmsg; - result = card_send_command(ft1000dev,(unsigned short*)dpram_data,total_len+2); - - - ft1000dev->app_info[app_index].nTxMsg++; - } else { - result = -EINVAL; - } - } - } - } else { - DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n"); - result = -EACCES; - } - kfree(dpram_data); - - } - break; - case IOCTL_GET_DPRAM_CMD: - { + result = -ENOMEM; + dpram_data = kmalloc(msgsz + 2, GFP_KERNEL); + if (!dpram_data) + break; + + if (copy_from_user(dpram_data, argp, msgsz+2)) { + pr_debug("copy fault occurred\n"); + result = -EFAULT; + } else { + /* Check if this message came from a registered application */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + break; + } + } + if (i == MAX_NUM_APP) { + pr_debug("No matching application fileobject\n"); + result = -EINVAL; + kfree(dpram_data); + break; + } + app_index = i; + + /* Check message qtype type which is the lower byte within qos_class */ + qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; + /* pr_debug("qtype = %d\n", qtype); */ + if (qtype) { + } else { + /* Put message into Slow Queue */ + /* Only put a message into the DPRAM if msg doorbell is available */ + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + /* pr_debug("READ REGISTER tempword=%x\n", tempword); */ + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 2ms and try again due to DSP doorbell busy */ + mdelay(2); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 1ms and try again due to DSP doorbell busy */ + mdelay(1); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + /* Suspend for 3ms and try again due to DSP doorbell busy */ + mdelay(3); + status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); + if (tempword & FT1000_DB_DPRAM_TX) { + pr_debug("Doorbell not available\n"); + result = -ENOTTY; + kfree(dpram_data); + break; + } + } + } + } + } + + /*pr_debug("finished reading register\n"); */ + + /* Make sure we are within the limits of the slow queue memory limitation */ + if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) { + /* Need to put sequence number plus new checksum for message */ + pmsg = (u16 *)&dpram_data->pseudohdr; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; + total_len = msgsz+2; + if (total_len & 0x1) { + total_len++; + } + + /* Insert slow queue sequence number */ + ppseudo_hdr->seq_num = info->squeseqnum++; + ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; + /* Calculate new checksum */ + ppseudo_hdr->checksum = *pmsg++; + /* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + for (i = 1; i < 7; i++) { + ppseudo_hdr->checksum ^= *pmsg++; + /* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */ + } + pmsg++; + ppseudo_hdr = (struct pseudo_hdr *)pmsg; + result = card_send_command(ft1000dev, (unsigned short *)dpram_data, total_len+2); + + + ft1000dev->app_info[app_index].nTxMsg++; + } else { + result = -EINVAL; + } + } + } + } else { + pr_debug("Card not ready take messages\n"); + result = -EACCES; + } + kfree(dpram_data); + + } + break; + case IOCTL_GET_DPRAM_CMD: + { struct dpram_blk *pdpram_blk; struct IOCTL_DPRAM_BLK __user *pioctl_dpram; - int msglen; - - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ - - if (ft1000_flarion_cnt == 0) { - return (-EBADF); - } - - /* Search for matching file object */ - for (i=0; i<MAX_NUM_APP; i++) { - if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ - break; - } - } - - /* Could not find application info block */ - if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); - result = -EBADF; - break; - } - - result = 0; - pioctl_dpram = argp; - if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */ - spin_lock_irqsave(&free_buff_lock, flags); - pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000dev->app_info[i].NumOfMsg--; - /* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ - spin_unlock_irqrestore(&free_buff_lock, flags); - msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; - result = get_user(msglen, &pioctl_dpram->total_len); - if (result) - break; - msglen = htons(msglen); - /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */ - if (copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) { - DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); - result = -EFAULT; + int msglen; + + /* pr_debug("IOCTL_FT1000_GET_DPRAM called\n"); */ + + if (ft1000_flarion_cnt == 0) + return -EBADF; + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + /*pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + break; + } + } + + /* Could not find application info block */ + if (i == MAX_NUM_APP) { + pr_debug("Could not find application info block\n"); + result = -EBADF; break; - } + } + + result = 0; + pioctl_dpram = argp; + if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { + /* pr_debug("Message detected in slow queue\n"); */ + spin_lock_irqsave(&free_buff_lock, flags); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000dev->app_info[i].NumOfMsg--; + /* pr_debug("NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */ + spin_unlock_irqrestore(&free_buff_lock, flags); + msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; + result = get_user(msglen, &pioctl_dpram->total_len); + if (result) + break; + msglen = htons(msglen); + /* pr_debug("msg length = %x\n", msglen); */ + if (copy_to_user(&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) { + pr_debug("copy fault occurred\n"); + result = -EFAULT; + break; + } + + ft1000_free_buffer(pdpram_blk, &freercvpool); + result = msglen; + } + /* pr_debug("IOCTL_FT1000_GET_DPRAM no message\n"); */ + } + break; - ft1000_free_buffer(pdpram_blk, &freercvpool); - result = msglen; - } - /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */ - } - break; - - default: - DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command); - result = -ENOTTY; - break; - } - ft1000dev->fAppMsgPend = 0; - return result; + default: + pr_debug("unknown command: 0x%x\n", command); + result = -ENOTTY; + break; + } + ft1000dev->fAppMsgPend = 0; + return result; } /* -*--------------------------------------------------------------------------- -* Function: ft1000_release -* -* Parameters: -* -* Description: -* -* Notes: -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * Function: ft1000_release + * + * Parameters: + * + * Description: + * + * Notes: + * + *--------------------------------------------------------------------------- + */ static int ft1000_release(struct inode *inode, struct file *file) { struct ft1000_info *info; - struct net_device *dev; - struct ft1000_usb *ft1000dev; - int i; + struct net_device *dev; + struct ft1000_usb *ft1000dev; + int i; struct dpram_blk *pdpram_blk; - DEBUG("ft1000_release called\n"); - - dev = file->private_data; + dev = file->private_data; info = netdev_priv(dev); ft1000dev = info->priv; - if (ft1000_flarion_cnt == 0) { - ft1000dev->appcnt--; - return (-EBADF); - } - - /* Search for matching file object */ - for (i=0; i<MAX_NUM_APP; i++) { - if (ft1000dev->app_info[i].fileobject == &file->f_owner) { - /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ - break; - } - } - - if (i==MAX_NUM_APP) - return 0; - - while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { - DEBUG("Remove and free memory queue up on slow queue\n"); - pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); - list_del(&pdpram_blk->list); - ft1000_free_buffer(pdpram_blk, &freercvpool); - } - - /* initialize application information */ - ft1000dev->appcnt--; - DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt); - ft1000dev->app_info[i].fileobject = NULL; - - return 0; + if (ft1000_flarion_cnt == 0) { + ft1000dev->appcnt--; + return -EBADF; + } + + /* Search for matching file object */ + for (i = 0; i < MAX_NUM_APP; i++) { + if (ft1000dev->app_info[i].fileobject == &file->f_owner) { + /* pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */ + break; + } + } + + if (i == MAX_NUM_APP) + return 0; + + while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { + pr_debug("Remove and free memory queue up on slow queue\n"); + pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); + list_del(&pdpram_blk->list); + ft1000_free_buffer(pdpram_blk, &freercvpool); + } + + /* initialize application information */ + ft1000dev->appcnt--; + pr_debug("appcnt = %d\n", ft1000dev->appcnt); + ft1000dev->app_info[i].fileobject = NULL; + + return 0; } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 37707da09e9c..e8126325877b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1,8 +1,10 @@ /* -* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -* -* This file is part of Express Card USB Driver -*/ + * CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. + * + * This file is part of Express Card USB Driver + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/kernel.h> #include <linux/module.h> @@ -117,17 +119,16 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) while (loopcnt < 10) { status = ft1000_read_register(ft1000dev, &temp, - FT1000_REG_DOORBELL); - DEBUG("check_usb_db: read FT1000_REG_DOORBELL value is %x\n", - temp); + FT1000_REG_DOORBELL); + pr_debug("read FT1000_REG_DOORBELL value is %x\n", temp); if (temp & 0x0080) { - DEBUG("FT1000:Got checkusb doorbell\n"); + pr_debug("Got checkusb doorbell\n"); status = ft1000_write_register(ft1000dev, 0x0080, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); status = ft1000_write_register(ft1000dev, 0x0100, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); status = ft1000_write_register(ft1000dev, 0x8000, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); break; } loopcnt++; @@ -138,13 +139,13 @@ static int check_usb_db(struct ft1000_usb *ft1000dev) loopcnt = 0; while (loopcnt < 20) { status = ft1000_read_register(ft1000dev, &temp, - FT1000_REG_DOORBELL); - DEBUG("FT1000:check_usb_db:Doorbell = 0x%x\n", temp); + FT1000_REG_DOORBELL); + pr_debug("Doorbell = 0x%x\n", temp); if (temp & 0x8000) { loopcnt++; msleep(10); } else { - DEBUG("check_usb_db: door bell is cleared, return 0\n"); + pr_debug("door bell is cleared, return 0\n"); return 0; } } @@ -164,23 +165,22 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) while (loopcnt < 100) { /* Need to clear downloader doorbell if Hartley ASIC */ status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_RX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (ft1000dev->fcodeldr) { - DEBUG(" get_handshake: fcodeldr is %d\n", - ft1000dev->fcodeldr); + pr_debug("fcodeldr is %d\n", ft1000dev->fcodeldr); ft1000dev->fcodeldr = 0; status = check_usb_db(ft1000dev); if (status != 0) { - DEBUG("get_handshake: check_usb_db failed\n"); + pr_debug("check_usb_db failed\n"); break; } status = ft1000_write_register(ft1000dev, - FT1000_DB_DNLD_RX, - FT1000_REG_DOORBELL); + FT1000_DB_DNLD_RX, + FT1000_REG_DOORBELL); } status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); + DWNLD_MAG1_HANDSHAKE_LOC, (u8 *)&handshake, 1); handshake = ntohs(handshake); if (status) @@ -209,12 +209,12 @@ static void put_handshake(struct ft1000_usb *ft1000dev, u16 handshake_value) tempword = (u16)(tempx & 0xffff); status = ft1000_write_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, - tempword, 0); + tempword, 0); tempword = (u16)(tempx >> 16); status = ft1000_write_dpram16(ft1000dev, DWNLD_MAG1_HANDSHAKE_LOC, - tempword, 1); + tempword, 1); status = ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); } static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) @@ -230,27 +230,27 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) while (loopcnt < 100) { if (ft1000dev->usbboot == 2) { status = ft1000_read_dpram32(ft1000dev, 0, - (u8 *)&(ft1000dev->tempbuf[0]), 64); + (u8 *)&(ft1000dev->tempbuf[0]), 64); for (temp = 0; temp < 16; temp++) { - DEBUG("tempbuf %d = 0x%x\n", temp, - ft1000dev->tempbuf[temp]); + pr_debug("tempbuf %d = 0x%x\n", + temp, ft1000dev->tempbuf[temp]); } status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, - (u8 *)&handshake, 1); - DEBUG("handshake from read_dpram16 = 0x%x\n", - handshake); + DWNLD_MAG1_HANDSHAKE_LOC, + (u8 *)&handshake, 1); + pr_debug("handshake from read_dpram16 = 0x%x\n", + handshake); if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) { handshake = 0; } else { handshake = ft1000dev->tempbuf[1]; ft1000dev->dspalive = - ft1000dev->tempbuf[6]; + ft1000dev->tempbuf[6]; } } else { status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_HANDSHAKE_LOC, - (u8 *)&handshake, 1); + DWNLD_MAG1_HANDSHAKE_LOC, + (u8 *)&handshake, 1); } loopcnt++; @@ -281,12 +281,12 @@ static u16 get_request_type(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); } else { tempx = 0; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempword, 1); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempword, 1); tempx |= (tempword << 16); tempx = ntohl(tempx); } @@ -304,7 +304,7 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); + DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx); tempx = ntohl(tempx); } else { if (ft1000dev->usbboot == 2) { @@ -313,8 +313,8 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) } else { tempx = 0; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_TYPE_LOC, - (u8 *)&tempword, 1); + DWNLD_MAG1_TYPE_LOC, + (u8 *)&tempword, 1); } tempx |= (tempword << 16); tempx = ntohl(tempx); @@ -332,14 +332,14 @@ static long get_request_value(struct ft1000_usb *ft1000dev) if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&value); + DWNLD_MAG1_SIZE_LOC, (u8 *)&value); value = ntohl(value); } else { status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 0); + DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 0); value = tempword; status = ft1000_read_dpram16(ft1000dev, - DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 1); + DWNLD_MAG1_SIZE_LOC, (u8 *)&tempword, 1); value |= (tempword << 16); value = ntohl(value); } @@ -369,7 +369,7 @@ static u16 hdr_checksum(struct pseudo_hdr *pHdr) chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^ - usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); + usPtr[4]) ^ usPtr[5]) ^ usPtr[6]); return chksum; } @@ -387,7 +387,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) } static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, - u16 tempbuffer[], u16 dpram) + u16 tempbuffer[], u16 dpram) { int status; u16 resultbuffer[64]; @@ -395,38 +395,38 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, for (i = 0; i < 10; i++) { status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 64); + (u8 *)&tempbuffer[0], 64); if (status == 0) { /* Work around for ASIC bit stuffing problem. */ if ((tempbuffer[31] & 0xfe00) == 0xfe00) { status = ft1000_write_dpram32(ft1000dev, - dpram+12, (u8 *)&tempbuffer[24], - 64); + dpram+12, (u8 *)&tempbuffer[24], + 64); } /* Let's check the data written */ status = ft1000_read_dpram32(ft1000dev, dpram, - (u8 *)&resultbuffer[0], 64); + (u8 *)&resultbuffer[0], 64); if ((tempbuffer[31] & 0xfe00) == 0xfe00) { if (check_buffers(tempbuffer, resultbuffer, 28, - 0)) { - DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); + 0)) { + pr_debug("DPRAM write failed 1 during bootloading\n"); usleep_range(9000, 11000); break; } status = ft1000_read_dpram32(ft1000dev, - dpram+12, - (u8 *)&resultbuffer[0], 64); + dpram+12, + (u8 *)&resultbuffer[0], 64); if (check_buffers(tempbuffer, resultbuffer, 16, - 24)) { - DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); + 24)) { + pr_debug("DPRAM write failed 2 during bootloading\n"); usleep_range(9000, 11000); break; } } else { if (check_buffers(tempbuffer, resultbuffer, 32, - 0)) { - DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); + 0)) { + pr_debug("DPRAM write failed 3 during bootloading\n"); usleep_range(9000, 11000); break; } @@ -445,7 +445,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, * long word_length - length of the buffer to be written to DPRAM */ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, - long word_length) + long word_length) { int status = 0; u16 dpram; @@ -453,7 +453,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, u16 tempword; u16 tempbuffer[64]; - /*DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); */ + /*pr_debug("start word_length = %d\n",(int)word_length); */ dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; tempword = *(*pUsFile); (*pUsFile)++; @@ -483,21 +483,22 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, } } - /*DEBUG("write_blk: loopcnt is %d\n", loopcnt); */ - /*DEBUG("write_blk: bootmode = %d\n", bootmode); */ - /*DEBUG("write_blk: dpram = %x\n", dpram); */ + /*pr_debug("loopcnt is %d\n", loopcnt); */ + /*pr_debug("write_blk: bootmode = %d\n", bootmode); */ + /*pr_debug("write_blk: dpram = %x\n", dpram); */ if (ft1000dev->bootmode == 0) { if (dpram >= 0x3F4) status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 8); + (u8 *)&tempbuffer[0], 8); else status = ft1000_write_dpram32(ft1000dev, dpram, - (u8 *)&tempbuffer[0], 64); + (u8 *)&tempbuffer[0], 64); } else { status = write_dpram32_and_check(ft1000dev, tempbuffer, - dpram); + dpram); if (status != 0) { - DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); + pr_debug("Write failed tempbuffer[31] = 0x%x\n", + tempbuffer[31]); break; } } @@ -508,7 +509,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, static void usb_dnld_complete(struct urb *urb) { - /* DEBUG("****** usb_dnld_complete\n"); */ + /* pr_debug("****** usb_dnld_complete\n"); */ } /* writes a block of DSP image to DPRAM @@ -548,22 +549,21 @@ static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, } static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, - u32 *state) + u32 *state) { int status = 0; - DEBUG("FT1000:STATE_START_DWNLD\n"); if (ft1000dev->usbboot) *hshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); else *hshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY); if (*hshake == HANDSHAKE_DSP_BL_READY) { - DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); + pr_debug("handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); } else if (*hshake == HANDSHAKE_TIMEOUT_VALUE) { status = -ETIMEDOUT; } else { - DEBUG("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -ENETRESET; } *state = STATE_BOOT_DWNLD; @@ -571,22 +571,22 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, } static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, - u8 **c_file, const u8 *endpoint, bool boot_case) + u8 **c_file, const u8 *endpoint, bool boot_case) { long word_length; int status = 0; - /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ word_length = get_request_value(ft1000dev); - /*DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); */ + /*pr_debug("word_length = 0x%x\n", (int)word_length); */ /*NdisMSleep (100); */ if (word_length > MAX_LENGTH) { - DEBUG("FT1000:download:Download error: Max length exceeded\n"); + pr_debug("Download error: Max length exceeded\n"); return -1; } if ((word_length * 2 + (long)c_file) > (long)endpoint) { /* Error, beyond boot code range.*/ - DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length); + pr_debug("Download error: Requested len=%d exceeds BOOT code boundary\n", + (int)word_length); return -1; } if (word_length & 0x1) @@ -595,14 +595,14 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, if (boot_case) { status = write_blk(ft1000dev, s_file, c_file, word_length); - /*DEBUG("write_blk returned %d\n", status); */ + /*pr_debug("write_blk returned %d\n", status); */ } else { status = write_blk_fifo(ft1000dev, s_file, c_file, word_length); if (ft1000dev->usbboot == 0) ft1000dev->usbboot++; if (ft1000dev->usbboot == 1) status |= ft1000_write_dpram16(ft1000dev, - DWNLD_MAG1_PS_HDR_LOC, 0, 0); + DWNLD_MAG1_PS_HDR_LOC, 0, 0); } return status; } @@ -641,8 +641,6 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, struct prov_record *pprov_record; struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net); - DEBUG("Entered scram_dnldr...\n"); - ft1000dev->fcodeldr = 0; ft1000dev->usbboot = 0; ft1000dev->dspalive = 0xffff; @@ -653,7 +651,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, state = STATE_START_DWNLD; - file_hdr = (struct dsp_file_hdr *)pFileStart; + file_hdr = pFileStart; ft1000_write_register(ft1000dev, 0x800, FT1000_REG_MAG_WATERMARK); @@ -674,7 +672,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; case STATE_BOOT_DWNLD: - DEBUG("FT1000:STATE_BOOT_DWNLD\n"); + pr_debug("STATE_BOOT_DWNLD\n"); ft1000dev->bootmode = 1; handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST); if (handshake == HANDSHAKE_REQUEST) { @@ -684,35 +682,34 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, request = get_request_type(ft1000dev); switch (request) { case REQUEST_RUN_ADDRESS: - DEBUG("FT1000:REQUEST_RUN_ADDRESS\n"); + pr_debug("REQUEST_RUN_ADDRESS\n"); put_request_value(ft1000dev, loader_code_address); break; case REQUEST_CODE_LENGTH: - DEBUG("FT1000:REQUEST_CODE_LENGTH\n"); + pr_debug("REQUEST_CODE_LENGTH\n"); put_request_value(ft1000dev, loader_code_size); break; case REQUEST_DONE_BL: - DEBUG("FT1000:REQUEST_DONE_BL\n"); + pr_debug("REQUEST_DONE_BL\n"); /* Reposition ptrs to beginning of code section */ s_file = (u16 *) (boot_end); c_file = (u8 *) (boot_end); - /* DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); */ - /* DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); */ + /* pr_debug("download:s_file = 0x%8x\n", (int)s_file); */ + /* pr_debug("FT1000:download:c_file = 0x%8x\n", (int)c_file); */ state = STATE_CODE_DWNLD; ft1000dev->fcodeldr = 1; break; case REQUEST_CODE_SEGMENT: status = request_code_segment(ft1000dev, - &s_file, &c_file, - (const u8 *)boot_end, - true); - break; + &s_file, &c_file, + (const u8 *)boot_end, + true); + break; default: - DEBUG - ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n", - request); + pr_debug("Download error: Bad request type=%d in BOOT download state\n", + request); status = -1; break; } @@ -723,68 +720,60 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, put_handshake(ft1000dev, HANDSHAKE_RESPONSE); } else { - DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -1; } break; case STATE_CODE_DWNLD: - /* DEBUG("FT1000:STATE_CODE_DWNLD\n"); */ + /* pr_debug("STATE_CODE_DWNLD\n"); */ ft1000dev->bootmode = 0; if (ft1000dev->usbboot) handshake = - get_handshake_usb(ft1000dev, - HANDSHAKE_REQUEST); + get_handshake_usb(ft1000dev, + HANDSHAKE_REQUEST); else handshake = - get_handshake(ft1000dev, HANDSHAKE_REQUEST); + get_handshake(ft1000dev, HANDSHAKE_REQUEST); if (handshake == HANDSHAKE_REQUEST) { /* * Get type associated with the request. */ if (ft1000dev->usbboot) request = - get_request_type_usb(ft1000dev); + get_request_type_usb(ft1000dev); else request = get_request_type(ft1000dev); switch (request) { case REQUEST_FILE_CHECKSUM: - DEBUG - ("FT1000:download:image_chksum = 0x%8x\n", - image_chksum); + pr_debug("image_chksum = 0x%8x\n", + image_chksum); put_request_value(ft1000dev, image_chksum); break; case REQUEST_RUN_ADDRESS: - DEBUG - ("FT1000:download: REQUEST_RUN_ADDRESS\n"); + pr_debug("REQUEST_RUN_ADDRESS\n"); if (correct_version) { - DEBUG - ("FT1000:download:run_address = 0x%8x\n", - (int)run_address); + pr_debug("run_address = 0x%8x\n", + (int)run_address); put_request_value(ft1000dev, run_address); } else { - DEBUG - ("FT1000:download:Download error: Got Run address request before image offset request.\n"); + pr_debug("Download error: Got Run address request before image offset request\n"); status = -1; break; } break; case REQUEST_CODE_LENGTH: - DEBUG - ("FT1000:download:REQUEST_CODE_LENGTH\n"); + pr_debug("REQUEST_CODE_LENGTH\n"); if (correct_version) { - DEBUG - ("FT1000:download:run_size = 0x%8x\n", - (int)run_size); + pr_debug("run_size = 0x%8x\n", + (int)run_size); put_request_value(ft1000dev, run_size); } else { - DEBUG - ("FT1000:download:Download error: Got Size request before image offset request.\n"); + pr_debug("Download error: Got Size request before image offset request\n"); status = -1; break; } @@ -793,69 +782,66 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, ft1000dev->usbboot = 3; /* Reposition ptrs to beginning of provisioning section */ s_file = - (u16 *) (pFileStart + - file_hdr->commands_offset); + (u16 *) (pFileStart + + file_hdr->commands_offset); c_file = - (u8 *) (pFileStart + - file_hdr->commands_offset); + (u8 *) (pFileStart + + file_hdr->commands_offset); state = STATE_DONE_DWNLD; break; case REQUEST_CODE_SEGMENT: - /* DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); */ + /* pr_debug("REQUEST_CODE_SEGMENT - CODELOADER\n"); */ if (!correct_version) { - DEBUG - ("FT1000:download:Download error: Got Code Segment request before image offset request.\n"); + pr_debug("Download error: Got Code Segment request before image offset request\n"); status = -1; break; } status = request_code_segment(ft1000dev, - &s_file, &c_file, - (const u8 *)code_end, - false); + &s_file, &c_file, + (const u8 *)code_end, + false); break; case REQUEST_MAILBOX_DATA: - DEBUG - ("FT1000:download: REQUEST_MAILBOX_DATA\n"); + pr_debug("REQUEST_MAILBOX_DATA\n"); /* Convert length from byte count to word count. Make sure we round up. */ word_length = - (long)(pft1000info->DSPInfoBlklen + - 1) / 2; + (long)(pft1000info->DSPInfoBlklen + + 1) / 2; put_request_value(ft1000dev, word_length); mailbox_data = - (struct drv_msg *)&(pft1000info-> - DSPInfoBlk[0]); + (struct drv_msg *)&(pft1000info-> + DSPInfoBlk[0]); /* * Position ASIC DPRAM auto-increment pointer. */ - data = (u16 *) &mailbox_data->data[0]; - dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; + data = (u16 *)&mailbox_data->data[0]; + dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; if (word_length & 0x1) word_length++; - word_length = (word_length / 2); + word_length = word_length / 2; for (; word_length > 0; word_length--) { /* In words */ templong = *data++; templong |= (*data++ << 16); status = - fix_ft1000_write_dpram32 - (ft1000dev, dpram++, - (u8 *) &templong); + fix_ft1000_write_dpram32 + (ft1000dev, dpram++, + (u8 *)&templong); } break; case REQUEST_VERSION_INFO: - DEBUG - ("FT1000:download:REQUEST_VERSION_INFO\n"); + pr_debug("REQUEST_VERSION_INFO\n"); word_length = - file_hdr->version_data_size; + file_hdr->version_data_size; put_request_value(ft1000dev, word_length); /* @@ -863,15 +849,15 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, */ s_file = - (u16 *) (pFileStart + - file_hdr-> - version_data_offset); + (u16 *) (pFileStart + + file_hdr-> + version_data_offset); - dpram = (u16) DWNLD_MAG1_PS_HDR_LOC; + dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; if (word_length & 0x1) word_length++; - word_length = (word_length / 2); + word_length = word_length / 2; for (; word_length > 0; word_length--) { /* In words */ @@ -879,26 +865,25 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, temp = ntohs(*s_file++); templong |= (temp << 16); status = - fix_ft1000_write_dpram32 - (ft1000dev, dpram++, - (u8 *) &templong); + fix_ft1000_write_dpram32 + (ft1000dev, dpram++, + (u8 *)&templong); } break; case REQUEST_CODE_BY_VERSION: - DEBUG - ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); + pr_debug("REQUEST_CODE_BY_VERSION\n"); correct_version = false; requested_version = - get_request_value(ft1000dev); + get_request_value(ft1000dev); dsp_img_info = - (struct dsp_image_info *)(pFileStart - + - sizeof - (struct - dsp_file_hdr)); + (struct dsp_image_info *)(pFileStart + + + sizeof + (struct + dsp_file_hdr)); for (image = 0; image < file_hdr->nDspImages; @@ -907,30 +892,29 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (dsp_img_info->version == requested_version) { correct_version = true; - DEBUG - ("FT1000:download: correct_version is TRUE\n"); + pr_debug("correct_version is TRUE\n"); s_file = - (u16 *) (pFileStart - + - dsp_img_info-> - begin_offset); + (u16 *) (pFileStart + + + dsp_img_info-> + begin_offset); c_file = - (u8 *) (pFileStart + - dsp_img_info-> - begin_offset); + (u8 *) (pFileStart + + dsp_img_info-> + begin_offset); code_end = - (u8 *) (pFileStart + - dsp_img_info-> - end_offset); + (u8 *) (pFileStart + + dsp_img_info-> + end_offset); run_address = - dsp_img_info-> - run_address; + dsp_img_info-> + run_address; run_size = - dsp_img_info-> - image_size; + dsp_img_info-> + image_size; image_chksum = - (u32) dsp_img_info-> - checksum; + (u32)dsp_img_info-> + checksum; break; } dsp_img_info++; @@ -941,18 +925,16 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* * Error, beyond boot code range. */ - DEBUG - ("FT1000:download:Download error: Bad Version Request = 0x%x.\n", - (int)requested_version); + pr_debug("Download error: Bad Version Request = 0x%x.\n", + (int)requested_version); status = -1; break; } break; default: - DEBUG - ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n", - request); + pr_debug("Download error: Bad request type=%d in CODE download state.\n", + request); status = -1; break; } @@ -963,20 +945,19 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, put_handshake(ft1000dev, HANDSHAKE_RESPONSE); } else { - DEBUG - ("FT1000:download:Download error: Handshake failed\n"); + pr_debug("Download error: Handshake failed\n"); status = -1; } break; case STATE_DONE_DWNLD: - DEBUG("FT1000:download:Code loader is done...\n"); + pr_debug("Code loader is done...\n"); state = STATE_SECTION_PROV; break; case STATE_SECTION_PROV: - DEBUG("FT1000:download:STATE_SECTION_PROV\n"); + pr_debug("STATE_SECTION_PROV\n"); pseudo_header = (struct pseudo_hdr *)c_file; if (pseudo_header->checksum == @@ -990,9 +971,9 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* Get buffer for provisioning data */ pbuffer = - kmalloc((pseudo_header_len + - sizeof(struct pseudo_hdr)), - GFP_ATOMIC); + kmalloc((pseudo_header_len + + sizeof(struct pseudo_hdr)), + GFP_ATOMIC); if (pbuffer) { memcpy(pbuffer, (void *)c_file, (u32) (pseudo_header_len + @@ -1000,20 +981,20 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, pseudo_hdr))); /* link provisioning data */ pprov_record = - kmalloc(sizeof(struct prov_record), - GFP_ATOMIC); + kmalloc(sizeof(struct prov_record), + GFP_ATOMIC); if (pprov_record) { pprov_record->pprov_data = - pbuffer; + pbuffer; list_add_tail(&pprov_record-> list, &pft1000info-> prov_list); /* Move to next entry if available */ c_file = - (u8 *) ((unsigned long) - c_file + - (u32) ((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); + (u8 *) ((unsigned long) + c_file + + (u32) ((pseudo_header_len + 1) & 0xFFFFFFFE) + sizeof(struct pseudo_hdr)); if ((unsigned long)(c_file) - (unsigned long)(pFileStart) >= @@ -1031,13 +1012,12 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, /* Checksum did not compute */ status = -1; } - DEBUG - ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n", - state, status); + pr_debug("after STATE_SECTION_PROV, state = %d, status= %d\n", + state, status); break; case STATE_DONE_PROV: - DEBUG("FT1000:download:STATE_DONE_PROV\n"); + pr_debug("STATE_DONE_PROV\n"); state = STATE_DONE_FILE; break; @@ -1050,21 +1030,21 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; /**** - // Check if Card is present - status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK); - if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) { - break; - } - - status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID); - if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) { - break; - } + // Check if Card is present + status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK); + if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) { + break; + } + + status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID); + if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) { + break; + } ****/ } /* End while */ - DEBUG("Download exiting with status = 0x%8x\n", status); + pr_debug("Download exiting with status = 0x%8x\n", status); ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX, FT1000_REG_DOORBELL); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 2e13e7b7ec10..d12cfc9aa32a 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -1,8 +1,10 @@ /* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -* -* -* This file is part of Express Card USB Driver -*/ + * + * + * This file is part of Express Card USB Driver + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/kernel.h> #include <linux/module.h> @@ -35,16 +37,16 @@ static u8 tempbuffer[1600]; #define MAX_RCV_LOOP 100 /* send a control message via USB interface synchronously -* Parameters: ft1000_usb - device structure -* pipe - usb control message pipe -* request - control request -* requesttype - control message request type -* value - value to be written or 0 -* index - register index -* data - data buffer to hold the read/write values -* size - data size -* timeout - control message time out value -*/ + * Parameters: ft1000_usb - device structure + * pipe - usb control message pipe + * request - control request + * requesttype - control message request type + * value - value to be written or 0 + * index - register index + * data - data buffer to hold the read/write values + * size - data size + * timeout - control message time out value + */ static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe, u8 request, u8 requesttype, u16 value, u16 index, void *data, u16 size, int timeout) @@ -52,7 +54,7 @@ static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe, int ret; if ((ft1000dev == NULL) || (ft1000dev->dev == NULL)) { - DEBUG("ft1000dev or ft1000dev->dev == NULL, failure\n"); + pr_debug("ft1000dev or ft1000dev->dev == NULL, failure\n"); return -ENODEV; } @@ -171,7 +173,7 @@ int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, /* write into DPRAM a number of bytes */ int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, - u8 highlow) + u8 highlow) { int ret = 0; u8 request; @@ -212,7 +214,7 @@ int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, *buffer++ = buf[pos++]; *buffer++ = buf[pos++]; } else { - DEBUG("fix_ft1000_read_dpram32: DPRAM32 Read failed\n"); + pr_debug("DPRAM32 Read failed\n"); *buffer++ = 0; *buffer++ = 0; *buffer++ = 0; @@ -246,7 +248,7 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) buf[pos2++] = *buffer++; ret = ft1000_write_dpram32(ft1000dev, pos1, buf, 16); } else { - DEBUG("fix_ft1000_write_dpram32: DPRAM32 Read failed\n"); + pr_debug("DPRAM32 Read failed\n"); return ret; } @@ -270,8 +272,7 @@ int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer) for (i = 0; i < 16; i++) { if (tempbuffer[i] != resultbuffer[i]) { ret = -1; - DEBUG("%s Failed to write\n", - __func__); + pr_debug("Failed to write\n"); } } } @@ -287,19 +288,19 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) u16 tempword; status = ft1000_write_register(ft1000dev, HOST_INTF_BE, - FT1000_REG_SUP_CTRL); + FT1000_REG_SUP_CTRL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_CTRL); if (value) { - DEBUG("Reset DSP\n"); + pr_debug("Reset DSP\n"); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); tempword |= DSP_RESET_BIT; status = ft1000_write_register(ft1000dev, tempword, FT1000_REG_RESET); } else { - DEBUG("Activate DSP\n"); + pr_debug("Activate DSP\n"); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); tempword |= DSP_ENCRYPTED; @@ -318,18 +319,18 @@ static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value) } /* send a command to ASIC -* Parameters: ft1000_usb - device structure -* ptempbuffer - command buffer -* size - command buffer size -*/ + * Parameters: ft1000_usb - device structure + * ptempbuffer - command buffer + * size - command buffer size + */ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, - int size) + int size) { int ret; unsigned short temp; unsigned char *commandbuf; - DEBUG("card_send_command: enter card_send_command... size=%d\n", size); + pr_debug("enter card_send_command... size=%d\n", size); commandbuf = kmalloc(size + 2, GFP_KERNEL); if (!commandbuf) @@ -355,7 +356,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, return ret; usleep_range(900, 1100); ret = ft1000_write_register(ft1000dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (ret) return ret; usleep_range(900, 1100); @@ -364,7 +365,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer, #if 0 if ((temp & 0x0100) == 0) - DEBUG("card_send_command: Message sent\n"); + pr_debug("Message sent\n"); #endif return ret; } @@ -390,7 +391,7 @@ int dsp_reload(struct ft1000_usb *ft1000dev) status = ft1000_write_register(ft1000dev, tempword, FT1000_REG_RESET); msleep(1000); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_RESET); - DEBUG("Reset Register = 0x%x\n", tempword); + pr_debug("Reset Register = 0x%x\n", tempword); /* Toggle DSP reset */ card_reset_dsp(ft1000dev, 1); @@ -399,13 +400,13 @@ int dsp_reload(struct ft1000_usb *ft1000dev) msleep(1000); status = - ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); + ft1000_write_register(ft1000dev, HOST_INTF_BE, FT1000_REG_SUP_CTRL); /* Let's check for FEFE */ status = - ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX, - (u8 *) &templong, 4); - DEBUG("templong (fefe) = 0x%8x\n", templong); + ft1000_read_dpram32(ft1000dev, FT1000_MAG_DPRAM_FEFE_INDX, + (u8 *)&templong, 4); + pr_debug("templong (fefe) = 0x%8x\n", templong); /* call codeloader */ status = scram_dnldr(ft1000dev, pFileStart, FileLength); @@ -415,8 +416,6 @@ int dsp_reload(struct ft1000_usb *ft1000dev) msleep(1000); - DEBUG("dsp_reload returned\n"); - return 0; } @@ -427,8 +426,6 @@ static void ft1000_reset_asic(struct net_device *dev) struct ft1000_usb *ft1000dev = info->priv; u16 tempword; - DEBUG("ft1000_hw:ft1000_reset_asic called\n"); - /* Let's use the register provided by the Magnemite ASIC to reset the * ASIC and DSP. */ @@ -442,10 +439,10 @@ static void ft1000_reset_asic(struct net_device *dev) /* clear interrupts */ ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR); - DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); ft1000_write_register(ft1000dev, tempword, FT1000_REG_SUP_ISR); ft1000_read_register(ft1000dev, &tempword, FT1000_REG_SUP_ISR); - DEBUG("ft1000_hw: interrupt status register = 0x%x\n", tempword); + pr_debug("interrupt status register = 0x%x\n", tempword); } static int ft1000_reset_card(struct net_device *dev) @@ -455,38 +452,36 @@ static int ft1000_reset_card(struct net_device *dev) u16 tempword; struct prov_record *ptr; - DEBUG("ft1000_hw:ft1000_reset_card called.....\n"); - ft1000dev->fCondResetPend = true; info->CardReady = 0; ft1000dev->fProvComplete = false; /* Make sure we free any memory reserve for provisioning */ while (list_empty(&info->prov_list) == 0) { - DEBUG("ft1000_reset_card:deleting provisioning record\n"); + pr_debug("deleting provisioning record\n"); ptr = - list_entry(info->prov_list.next, struct prov_record, list); + list_entry(info->prov_list.next, struct prov_record, list); list_del(&ptr->list); kfree(ptr->pprov_data); kfree(ptr); } - DEBUG("ft1000_hw:ft1000_reset_card: reset asic\n"); + pr_debug("reset asic\n"); ft1000_reset_asic(dev); - DEBUG("ft1000_hw:ft1000_reset_card: call dsp_reload\n"); + pr_debug("call dsp_reload\n"); dsp_reload(ft1000dev); - DEBUG("dsp reload successful\n"); + pr_debug("dsp reload successful\n"); mdelay(10); /* Initialize DSP heartbeat area */ ft1000_write_dpram16(ft1000dev, FT1000_MAG_HI_HO, ho_mag, FT1000_MAG_HI_HO_INDX); - ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *) &tempword, + ft1000_read_dpram16(ft1000dev, FT1000_MAG_HI_HO, (u8 *)&tempword, FT1000_MAG_HI_HO_INDX); - DEBUG("ft1000_hw:ft1000_reset_card:hi_ho value = 0x%x\n", tempword); + pr_debug("hi_ho value = 0x%x\n", tempword); info->CardReady = 1; @@ -508,8 +503,8 @@ static void ft1000_usb_transmit_complete(struct urb *urb) } /* take an ethernet packet and convert it to a Flarion -* packet prior to sending it to the ASIC Downlink FIFO. -*/ + * packet prior to sending it to the ASIC Downlink FIFO. + */ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) { struct ft1000_info *pInfo = netdev_priv(netdev); @@ -520,14 +515,13 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) struct pseudo_hdr hdr; if (!pInfo->CardReady) { - DEBUG("ft1000_copy_down_pkt::Card Not Ready\n"); + pr_debug("Card Not Ready\n"); return -ENODEV; } count = sizeof(struct pseudo_hdr) + len; if (count > MAX_BUF_SIZE) { - DEBUG("Error:ft1000_copy_down_pkt:Message Size Overflow!\n"); - DEBUG("size = %d\n", count); + pr_debug("Message Size Overflow! size = %d\n", count); return -EINVAL; } @@ -545,7 +539,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) hdr.control = 0x00; hdr.checksum = hdr.length ^ hdr.source ^ hdr.destination ^ - hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; + hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control; memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr)); memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len); @@ -559,12 +553,12 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) pFt1000Dev->tx_buf, count, ft1000_usb_transmit_complete, (void *)pFt1000Dev); - t = (u8 *) pFt1000Dev->tx_urb->transfer_buffer; + t = (u8 *)pFt1000Dev->tx_urb->transfer_buffer; ret = usb_submit_urb(pFt1000Dev->tx_urb, GFP_ATOMIC); if (ret) { - DEBUG("ft1000 failed tx_urb %d\n", ret); + pr_debug("failed tx_urb %d\n", ret); return ret; } pInfo->stats.tx_packets++; @@ -574,9 +568,9 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len) } /* transmit an ethernet packet -* Parameters: skb - socket buffer to be sent -* dev - network device -*/ + * Parameters: skb - socket buffer to be sent + * dev - network device + */ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ft1000_info *pInfo = netdev_priv(dev); @@ -585,30 +579,30 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev) int maxlen, pipe; if (skb == NULL) { - DEBUG("ft1000_hw: ft1000_start_xmit:skb == NULL!!!\n"); + pr_debug("skb == NULL!!!\n"); return NETDEV_TX_OK; } if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); goto err; } pipe = - usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); + usb_sndbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_out_endpointAddr); maxlen = usb_maxpacket(pFt1000Dev->dev, pipe, usb_pipeout(pipe)); - pdata = (u8 *) skb->data; + pdata = (u8 *)skb->data; if (pInfo->mediastate == 0) { /* Drop packet is mediastate is down */ - DEBUG("ft1000_hw:ft1000_start_xmit:mediastate is down\n"); + pr_debug("mediastate is down\n"); goto err; } if ((skb->len < ENET_HEADER_SIZE) || (skb->len > ENET_MAX_SIZE)) { /* Drop packet which has invalid size */ - DEBUG("ft1000_hw:ft1000_start_xmit:invalid ethernet length\n"); + pr_debug("invalid ethernet length\n"); goto err; } @@ -628,7 +622,7 @@ static int ft1000_open(struct net_device *dev) struct ft1000_usb *pFt1000Dev = pInfo->priv; struct timeval tv; - DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); + pr_debug("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber); pInfo->stats.rx_bytes = 0; pInfo->stats.tx_bytes = 0; @@ -676,11 +670,9 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) char card_nr[2]; u8 gCardIndex = 0; - DEBUG("Enter init_ft1000_netdev...\n"); - netdev = alloc_etherdev(sizeof(struct ft1000_info)); if (!netdev) { - DEBUG("init_ft1000_netdev: can not allocate network device\n"); + pr_debug("can not allocate network device\n"); return -ENOMEM; } @@ -690,7 +682,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) dev_alloc_name(netdev, netdev->name); - DEBUG("init_ft1000_netdev: network device name is %s\n", netdev->name); + pr_debug("network device name is %s\n", netdev->name); if (strncmp(netdev->name, "eth", 3) == 0) { card_nr[0] = netdev->name[3]; @@ -702,7 +694,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) } ft1000dev->CardNumber = gCardIndex; - DEBUG("card number = %d\n", ft1000dev->CardNumber); + pr_debug("card number = %d\n", ft1000dev->CardNumber); } else { netdev_err(ft1000dev->net, "ft1000: Invalid device name\n"); ret_val = -ENXIO; @@ -738,7 +730,7 @@ int init_ft1000_netdev(struct ft1000_usb *ft1000dev) ft1000dev->net = netdev; - DEBUG("Initialize free_buff_lock and freercvpool\n"); + pr_debug("Initialize free_buff_lock and freercvpool\n"); spin_lock_init(&free_buff_lock); /* initialize a list of buffers to be use for queuing @@ -790,7 +782,6 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, netdev = ft1000dev->net; pInfo = netdev_priv(ft1000dev->net); - DEBUG("Enter reg_ft1000_netdev...\n"); ft1000_read_register(ft1000dev, &pInfo->AsicID, FT1000_REG_ASIC_ID); @@ -799,23 +790,21 @@ int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, rc = register_netdev(netdev); if (rc) { - DEBUG("reg_ft1000_netdev: could not register network device\n"); + pr_debug("could not register network device\n"); free_netdev(netdev); return rc; } ft1000_create_dev(ft1000dev); - DEBUG("reg_ft1000_netdev returned\n"); - pInfo->CardReady = 1; return 0; } /* take a packet from the FIFO up link and -* convert it into an ethernet packet and deliver it to the IP stack -*/ + * convert it into an ethernet packet and deliver it to the IP stack + */ static int ft1000_copy_up_pkt(struct urb *urb) { struct ft1000_info *info = urb->context; @@ -832,14 +821,14 @@ static int ft1000_copy_up_pkt(struct urb *urb) u16 *chksum; if (ft1000dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); return 0; } /* Read length */ len = urb->transfer_buffer_length; lena = urb->actual_length; - chksum = (u16 *) ft1000dev->rx_buf; + chksum = (u16 *)ft1000dev->rx_buf; tempword = *chksum++; for (i = 1; i < 7; i++) @@ -854,13 +843,13 @@ static int ft1000_copy_up_pkt(struct urb *urb) skb = dev_alloc_skb(len + 12 + 2); if (skb == NULL) { - DEBUG("ft1000_copy_up_pkt: No Network buffers available\n"); + pr_debug("No Network buffers available\n"); info->stats.rx_errors++; ft1000_submit_rx_urb(info); return -1; } - pbuffer = (u8 *) skb_put(skb, len + 12); + pbuffer = (u8 *)skb_put(skb, len + 12); /* subtract the number of bytes read already */ ptemp = pbuffer; @@ -905,7 +894,7 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) struct ft1000_usb *pFt1000Dev = info->priv; if (pFt1000Dev->status & FT1000_STATUS_CLOSING) { - DEBUG("network driver is closed, return\n"); + pr_debug("network driver is closed, return\n"); return -ENODEV; } @@ -914,13 +903,12 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info) usb_rcvbulkpipe(pFt1000Dev->dev, pFt1000Dev->bulk_in_endpointAddr), pFt1000Dev->rx_buf, MAX_BUF_SIZE, - (usb_complete_t) ft1000_copy_up_pkt, info); + (usb_complete_t)ft1000_copy_up_pkt, info); result = usb_submit_urb(pFt1000Dev->rx_urb, GFP_ATOMIC); if (result) { - pr_err("ft1000_submit_rx_urb: submitting rx_urb %d failed\n", - result); + pr_err("submitting rx_urb %d failed\n", result); return result; } @@ -935,7 +923,7 @@ int ft1000_close(struct net_device *net) ft1000dev->status |= FT1000_STATUS_CLOSING; - DEBUG("ft1000_close: pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev); + pr_debug("pInfo=%p, ft1000dev=%p\n", pInfo, ft1000dev); netif_carrier_off(net); netif_stop_queue(net); ft1000dev->status &= ~FT1000_STATUS_CLOSING; @@ -952,7 +940,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev) int status; if (dev->fCondResetPend) { - DEBUG("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n"); + pr_debug("Card is being reset, return FALSE\n"); return TRUE; } /* Mask register is used to check for device presence since it is never @@ -960,7 +948,7 @@ static int ft1000_chkcard(struct ft1000_usb *dev) */ status = ft1000_read_register(dev, &tempword, FT1000_REG_SUP_IMASK); if (tempword == 0) { - DEBUG("ft1000_hw:ft1000_chkcard: IMASK = 0 Card not detected\n"); + pr_debug("IMASK = 0 Card not detected\n"); return FALSE; } /* The system will return the value of 0xffff for the version register @@ -969,17 +957,17 @@ static int ft1000_chkcard(struct ft1000_usb *dev) status = ft1000_read_register(dev, &tempword, FT1000_REG_ASIC_ID); if (tempword != 0x1b01) { dev->status |= FT1000_STATUS_CLOSING; - DEBUG("ft1000_hw:ft1000_chkcard: Version = 0xffff Card not detected\n"); + pr_debug("Version = 0xffff Card not detected\n"); return FALSE; } return TRUE; } /* read a message from the dpram area. -* Input: -* dev - network device structure -* pbuffer - caller supply address to buffer -*/ + * Input: + * dev - network device structure + * pbuffer - caller supply address to buffer + */ static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, int maxsz) { @@ -990,46 +978,45 @@ static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer, u16 tempword; ret = - ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *) &size, - FT1000_MAG_PH_LEN_INDX); + ft1000_read_dpram16(dev, FT1000_MAG_PH_LEN, (u8 *)&size, + FT1000_MAG_PH_LEN_INDX); size = ntohs(size) + PSEUDOSZ; if (size > maxsz) { - DEBUG("FT1000:ft1000_receive_cmd:Invalid command length = %d\n", - size); + pr_debug("Invalid command length = %d\n", size); return FALSE; } - ppseudohdr = (u16 *) pbuffer; + ppseudohdr = (u16 *)pbuffer; ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE, FT1000_REG_DPRAM_ADDR); ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); pbuffer++; ft1000_write_register(dev, FT1000_DPRAM_MAG_RX_BASE + 1, FT1000_REG_DPRAM_ADDR); for (i = 0; i <= (size >> 2); i++) { ret = - ft1000_read_register(dev, pbuffer, - FT1000_REG_MAG_DPDATAL); + ft1000_read_register(dev, pbuffer, + FT1000_REG_MAG_DPDATAL); pbuffer++; ret = - ft1000_read_register(dev, pbuffer, - FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, + FT1000_REG_MAG_DPDATAH); pbuffer++; } /* copy odd aligned word */ ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAL); pbuffer++; ret = - ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); + ft1000_read_register(dev, pbuffer, FT1000_REG_MAG_DPDATAH); pbuffer++; if (size & 0x0001) { /* copy odd byte from fifo */ ret = - ft1000_read_register(dev, &tempword, - FT1000_REG_DPRAM_DATA); + ft1000_read_register(dev, &tempword, + FT1000_REG_DPRAM_DATA); *pbuffer = ntohs(tempword); } /* Check if pseudo header checksum is good @@ -1058,17 +1045,15 @@ static int ft1000_dsp_prov(void *arg) int status; u16 TempShortBuf[256]; - DEBUG("*** DspProv Entered\n"); - while (list_empty(&info->prov_list) == 0) { - DEBUG("DSP Provisioning List Entry\n"); + pr_debug("DSP Provisioning List Entry\n"); /* Check if doorbell is available */ - DEBUG("check if doorbell is cleared\n"); + pr_debug("check if doorbell is cleared\n"); status = - ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); + ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); if (status) { - DEBUG("ft1000_dsp_prov::ft1000_read_register error\n"); + pr_debug("ft1000_read_register error\n"); break; } @@ -1076,7 +1061,7 @@ static int ft1000_dsp_prov(void *arg) mdelay(10); i++; if (i == 10) { - DEBUG("FT1000:ft1000_dsp_prov:message drop\n"); + pr_debug("message drop\n"); return -1; } ft1000_read_register(dev, &tempword, @@ -1084,17 +1069,17 @@ static int ft1000_dsp_prov(void *arg) } if (!(tempword & FT1000_DB_DPRAM_TX)) { - DEBUG("*** Provision Data Sent to DSP\n"); + pr_debug("*** Provision Data Sent to DSP\n"); /* Send provisioning data */ ptr = - list_entry(info->prov_list.next, struct prov_record, - list); - len = *(u16 *) ptr->pprov_data; + list_entry(info->prov_list.next, struct prov_record, + list); + len = *(u16 *)ptr->pprov_data; len = htons(len); len += PSEUDOSZ; - pmsg = (u16 *) ptr->pprov_data; + pmsg = (u16 *)ptr->pprov_data; ppseudo_hdr = (struct pseudo_hdr *)pmsg; /* Insert slow queue sequence number */ ppseudo_hdr->seq_num = info->squeseqnum++; @@ -1109,12 +1094,12 @@ static int ft1000_dsp_prov(void *arg) memcpy(&TempShortBuf[2], ppseudo_hdr, len); status = - ft1000_write_dpram32(dev, 0, - (u8 *) &TempShortBuf[0], - (unsigned short)(len + 2)); + ft1000_write_dpram32(dev, 0, + (u8 *)&TempShortBuf[0], + (unsigned short)(len + 2)); status = - ft1000_write_register(dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + ft1000_write_register(dev, FT1000_DB_DPRAM_TX, + FT1000_REG_DOORBELL); list_del(&ptr->list); kfree(ptr->pprov_data); @@ -1123,7 +1108,7 @@ static int ft1000_dsp_prov(void *arg) usleep_range(9000, 11000); } - DEBUG("DSP Provisioning List Entry finished\n"); + pr_debug("DSP Provisioning List Entry finished\n"); msleep(100); @@ -1158,37 +1143,26 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) status = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size); #ifdef JDEBUG - DEBUG("ft1000_proc_drvmsg:cmdbuffer\n"); - for (i = 0; i < size; i += 5) { - if ((i + 5) < size) - DEBUG("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", cmdbuffer[i], - cmdbuffer[i + 1], cmdbuffer[i + 2], - cmdbuffer[i + 3], cmdbuffer[i + 4]); - else { - for (j = i; j < size; j++) - DEBUG("0x%x ", cmdbuffer[j]); - DEBUG("\n"); - break; - } - } + print_hex_dump_debug("cmdbuffer: ", HEX_DUMP_OFFSET, 16, 1, + cmdbuffer, size, true); #endif pdrvmsg = (struct drv_msg *)&cmdbuffer[2]; msgtype = ntohs(pdrvmsg->type); - DEBUG("ft1000_proc_drvmsg:Command message type = 0x%x\n", msgtype); + pr_debug("Command message type = 0x%x\n", msgtype); switch (msgtype) { case MEDIA_STATE:{ - DEBUG("ft1000_proc_drvmsg:Command message type = MEDIA_STATE"); + pr_debug("Command message type = MEDIA_STATE\n"); pmediamsg = (struct media_msg *)&cmdbuffer[0]; if (info->ProgConStat != 0xFF) { if (pmediamsg->state) { - DEBUG("Media is up\n"); + pr_debug("Media is up\n"); if (info->mediastate == 0) { if (dev->NetDevRegDone) netif_wake_queue(dev->net); info->mediastate = 1; } } else { - DEBUG("Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; if (dev->NetDevRegDone) @@ -1196,7 +1170,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) } } } else { - DEBUG("Media is down\n"); + pr_debug("Media is down\n"); if (info->mediastate == 1) { info->mediastate = 0; info->ConTm = 0; @@ -1205,20 +1179,20 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) break; } case DSP_INIT_MSG:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_INIT_MSG"); + pr_debug("Command message type = DSP_INIT_MSG\n"); pdspinitmsg = (struct dsp_init_msg *)&cmdbuffer[2]; memcpy(info->DspVer, pdspinitmsg->DspVer, DSPVERSZ); - DEBUG("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", - info->DspVer[0], info->DspVer[1], info->DspVer[2], - info->DspVer[3]); + pr_debug("DSPVER = 0x%2x 0x%2x 0x%2x 0x%2x\n", + info->DspVer[0], info->DspVer[1], info->DspVer[2], + info->DspVer[3]); memcpy(info->HwSerNum, pdspinitmsg->HwSerNum, HWSERNUMSZ); memcpy(info->Sku, pdspinitmsg->Sku, SKUSZ); memcpy(info->eui64, pdspinitmsg->eui64, EUISZ); - DEBUG("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", - info->eui64[0], info->eui64[1], info->eui64[2], - info->eui64[3], info->eui64[4], info->eui64[5], - info->eui64[6], info->eui64[7]); + pr_debug("EUI64=%2x.%2x.%2x.%2x.%2x.%2x.%2x.%2x\n", + info->eui64[0], info->eui64[1], info->eui64[2], + info->eui64[3], info->eui64[4], info->eui64[5], + info->eui64[6], info->eui64[7]); dev->net->dev_addr[0] = info->eui64[0]; dev->net->dev_addr[1] = info->eui64[1]; dev->net->dev_addr[2] = info->eui64[2]; @@ -1229,17 +1203,17 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) if (ntohs(pdspinitmsg->length) == (sizeof(struct dsp_init_msg) - 20)) { memcpy(info->ProductMode, pdspinitmsg->ProductMode, - MODESZ); + MODESZ); memcpy(info->RfCalVer, pdspinitmsg->RfCalVer, CALVERSZ); memcpy(info->RfCalDate, pdspinitmsg->RfCalDate, CALDATESZ); - DEBUG("RFCalVer = 0x%2x 0x%2x\n", info->RfCalVer[0], - info->RfCalVer[1]); + pr_debug("RFCalVer = 0x%2x 0x%2x\n", + info->RfCalVer[0], info->RfCalVer[1]); } break; } case DSP_PROVISION:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_PROVISION\n"); + pr_debug("Command message type = DSP_PROVISION\n"); /* kick off dspprov routine to start provisioning * Send provisioning data to DSP @@ -1252,21 +1226,20 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) } else { dev->fProvComplete = true; status = ft1000_write_register(dev, FT1000_DB_HB, - FT1000_REG_DOORBELL); - DEBUG("FT1000:drivermsg:No more DSP provisioning data in dsp image\n"); + FT1000_REG_DOORBELL); + pr_debug("No more DSP provisioning data in dsp image\n"); } - DEBUG("ft1000_proc_drvmsg:DSP PROVISION is done\n"); + pr_debug("DSP PROVISION is done\n"); break; } case DSP_STORE_INFO:{ - DEBUG("ft1000_proc_drvmsg:Command message type = DSP_STORE_INFO"); - DEBUG("FT1000:drivermsg:Got DSP_STORE_INFO\n"); + pr_debug("Command message type = DSP_STORE_INFO"); tempword = ntohs(pdrvmsg->length); info->DSPInfoBlklen = tempword; if (tempword < (MAX_DSP_SESS_REC - 4)) { - pmsg = (u16 *) &pdrvmsg->data[0]; + pmsg = (u16 *)&pdrvmsg->data[0]; for (i = 0; i < ((tempword + 1) / 2); i++) { - DEBUG("FT1000:drivermsg:dsp info data = 0x%x\n", *pmsg); + pr_debug("dsp info data = 0x%x\n", *pmsg); info->DSPInfoBlk[i + 10] = *pmsg++; } } else { @@ -1275,33 +1248,33 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) break; } case DSP_GET_INFO:{ - DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n"); + pr_debug("Got DSP_GET_INFO\n"); /* copy dsp info block to dsp */ dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) break; } } /* Put message into Slow Queue Form Pseudo header */ - pmsg = (u16 *) info->DSPInfoBlk; + pmsg = (u16 *)info->DSPInfoBlk; *pmsg++ = 0; *pmsg++ = htons(info->DSPInfoBlklen + 20 + info->DSPInfoBlklen); ppseudo_hdr = - (struct pseudo_hdr *)(u16 *) &info->DSPInfoBlk[2]; + (struct pseudo_hdr *)(u16 *)&info->DSPInfoBlk[2]; ppseudo_hdr->length = htons(info->DSPInfoBlklen + 4 - + info->DSPInfoBlklen); + + info->DSPInfoBlklen); ppseudo_hdr->source = 0x10; ppseudo_hdr->destination = 0x20; ppseudo_hdr->portdest = 0; @@ -1323,31 +1296,31 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) info->DSPInfoBlk[10] = 0x7200; info->DSPInfoBlk[11] = htons(info->DSPInfoBlklen); status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPInfoBlk[0], - (unsigned short)(info->DSPInfoBlklen + 22)); + (u8 *)&info->DSPInfoBlk[0], + (unsigned short)(info->DSPInfoBlklen + 22)); status = ft1000_write_register(dev, FT1000_DB_DPRAM_TX, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); dev->DrvMsgPend = 0; break; } case GET_DRV_ERR_RPT_MSG:{ - DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n"); + pr_debug("Got GET_DRV_ERR_RPT_MSG\n"); /* copy driver error message to dsp */ dev->DrvMsgPend = 1; /* allow any outstanding ioctl to finish */ mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) { mdelay(10); status = ft1000_read_register(dev, &tempword, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); if (tempword & FT1000_DB_DPRAM_TX) mdelay(10); } if ((tempword & FT1000_DB_DPRAM_TX) == 0) { /* Put message into Slow Queue Form Pseudo header */ - pmsg = (u16 *) &tempbuffer[0]; + pmsg = (u16 *)&tempbuffer[0]; ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr->length = htons(0x0012); ppseudo_hdr->source = 0x10; @@ -1368,7 +1341,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) for (i = 1; i < 7; i++) ppseudo_hdr->checksum ^= *pmsg++; - pmsg = (u16 *) &tempbuffer[16]; + pmsg = (u16 *)&tempbuffer[16]; *pmsg++ = htons(RSP_DRV_ERR_RPT_MSG); *pmsg++ = htons(0x000e); *pmsg++ = htons(info->DSP_TIME[0]); @@ -1384,7 +1357,7 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) *pmsg++ = htons(info->DrvErrNum); status = card_send_command(dev, (unsigned char *)&tempbuffer[0], - (u16)(0x0012 + PSEUDOSZ)); + (u16)(0x0012 + PSEUDOSZ)); if (status) goto out; info->DrvErrNum = 0; @@ -1399,7 +1372,6 @@ static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size) status = 0; out: kfree(cmdbuffer); - DEBUG("return from ft1000_proc_drvmsg\n"); return status; } @@ -1412,32 +1384,32 @@ static int dsp_broadcast_msg_id(struct ft1000_usb *dev) for (i = 0; i < MAX_NUM_APP; i++) { if ((dev->app_info[i].DspBCMsgFlag) - && (dev->app_info[i].fileobject) - && (dev->app_info[i].NumOfMsg - < MAX_MSG_LIMIT)) { + && (dev->app_info[i].fileobject) + && (dev->app_info[i].NumOfMsg + < MAX_MSG_LIMIT)) { pdpram_blk = ft1000_get_buffer(&freercvpool); if (pdpram_blk == NULL) { - DEBUG("Out of memory in free receive command pool\n"); + pr_debug("Out of memory in free receive command pool\n"); dev->app_info[i].nRxMsgMiss++; return -1; } if (ft1000_receive_cmd(dev, pdpram_blk->pbuffer, - MAX_CMD_SQSIZE)) { + MAX_CMD_SQSIZE)) { /* Put message into the * appropriate application block */ dev->app_info[i].nRxMsg++; spin_lock_irqsave(&free_buff_lock, flags); list_add_tail(&pdpram_blk->list, - &dev->app_info[i] .app_sqlist); + &dev->app_info[i] .app_sqlist); dev->app_info[i].NumOfMsg++; spin_unlock_irqrestore(&free_buff_lock, flags); wake_up_interruptible(&dev->app_info[i] - .wait_dpram_msg); + .wait_dpram_msg); } else { dev->app_info[i].nRxMsgMiss++; ft1000_free_buffer(pdpram_blk, &freercvpool); - DEBUG("pdpram_blk::ft1000_get_buffer NULL\n"); + pr_debug("ft1000_get_buffer NULL\n"); return -1; } } @@ -1452,7 +1424,7 @@ static int handle_misc_portid(struct ft1000_usb *dev) pdpram_blk = ft1000_get_buffer(&freercvpool); if (pdpram_blk == NULL) { - DEBUG("Out of memory in free receive command pool\n"); + pr_debug("Out of memory in free receive command pool\n"); return -1; } if (!ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE)) @@ -1461,11 +1433,12 @@ static int handle_misc_portid(struct ft1000_usb *dev) /* Search for correct application block */ for (i = 0; i < MAX_NUM_APP; i++) { if (dev->app_info[i].app_id == ((struct pseudo_hdr *) - pdpram_blk->pbuffer)->portdest) + pdpram_blk->pbuffer)->portdest) break; } if (i == MAX_NUM_APP) { - DEBUG("FT1000:ft1000_parse_dpram_msg: No application matching id = %d\n", ((struct pseudo_hdr *)pdpram_blk->pbuffer)->portdest); + pr_debug("No application matching id = %d\n", + ((struct pseudo_hdr *)pdpram_blk->pbuffer)->portdest); goto exit_failure; } else if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) { goto exit_failure; @@ -1495,26 +1468,26 @@ int ft1000_poll(void *dev_id) u16 portid; if (ft1000_chkcard(dev) == FALSE) { - DEBUG("ft1000_poll::ft1000_chkcard: failed\n"); + pr_debug("failed\n"); return -1; } status = ft1000_read_register(dev, &tempword, FT1000_REG_DOORBELL); if (!status) { if (tempword & FT1000_DB_DPRAM_RX) { status = ft1000_read_dpram16(dev, - 0x200, (u8 *)&data, 0); + 0x200, (u8 *)&data, 0); size = ntohs(data) + 16 + 2; if (size % 4) { modulo = 4 - (size % 4); size = size + modulo; } status = ft1000_read_dpram16(dev, 0x201, - (u8 *)&portid, 1); + (u8 *)&portid, 1); portid &= 0xff; if (size < MAX_CMD_SQSIZE) { switch (portid) { case DRIVERID: - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_DB_DPRAM_RX : portid DRIVERID\n"); status = ft1000_proc_drvmsg(dev, size); if (status != 0) return status; @@ -1527,87 +1500,88 @@ int ft1000_poll(void *dev_id) break; } } else - DEBUG("FT1000:dpc:Invalid total length for SlowQ = %d\n", size); + pr_debug("Invalid total length for SlowQ = %d\n", + size); status = ft1000_write_register(dev, - FT1000_DB_DPRAM_RX, - FT1000_REG_DOORBELL); + FT1000_DB_DPRAM_RX, + FT1000_REG_DOORBELL); } else if (tempword & FT1000_DSP_ASIC_RESET) { /* Let's reset the ASIC from the Host side as well */ status = ft1000_write_register(dev, ASIC_RESET_BIT, - FT1000_REG_RESET); + FT1000_REG_RESET); status = ft1000_read_register(dev, &tempword, - FT1000_REG_RESET); + FT1000_REG_RESET); i = 0; while (tempword & ASIC_RESET_BIT) { status = ft1000_read_register(dev, &tempword, - FT1000_REG_RESET); + FT1000_REG_RESET); usleep_range(9000, 11000); i++; if (i == 100) break; } if (i == 100) { - DEBUG("Unable to reset ASIC\n"); + pr_debug("Unable to reset ASIC\n"); return 0; } usleep_range(9000, 11000); /* Program WMARK register */ status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* clear ASIC reset doorbell */ status = ft1000_write_register(dev, - FT1000_DSP_ASIC_RESET, - FT1000_REG_DOORBELL); + FT1000_DSP_ASIC_RESET, + FT1000_REG_DOORBELL); usleep_range(9000, 11000); } else if (tempword & FT1000_ASIC_RESET_REQ) { - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_ASIC_RESET_REQ\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_ASIC_RESET_REQ\n"); /* clear ASIC reset request from DSP */ status = ft1000_write_register(dev, - FT1000_ASIC_RESET_REQ, - FT1000_REG_DOORBELL); + FT1000_ASIC_RESET_REQ, + FT1000_REG_DOORBELL); status = ft1000_write_register(dev, HOST_INTF_BE, - FT1000_REG_SUP_CTRL); + FT1000_REG_SUP_CTRL); /* copy dsp session record from Adapter block */ status = ft1000_write_dpram32(dev, 0, - (u8 *)&info->DSPSess.Rec[0], 1024); + (u8 *)&info->DSPSess.Rec[0], 1024); status = ft1000_write_register(dev, 0x600, - FT1000_REG_MAG_WATERMARK); + FT1000_REG_MAG_WATERMARK); /* ring doorbell to tell DSP that * ASIC is out of reset * */ status = ft1000_write_register(dev, - FT1000_ASIC_RESET_DSP, - FT1000_REG_DOORBELL); + FT1000_ASIC_RESET_DSP, + FT1000_REG_DOORBELL); } else if (tempword & FT1000_DB_COND_RESET) { - DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); + pr_debug("FT1000_REG_DOORBELL message type: FT1000_DB_COND_RESET\n"); if (!dev->fAppMsgPend) { /* Reset ASIC and DSP */ status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER0, - (u8 *)&(info->DSP_TIME[0]), - FT1000_MAG_DSP_TIMER0_INDX); + FT1000_MAG_DSP_TIMER0, + (u8 *)&(info->DSP_TIME[0]), + FT1000_MAG_DSP_TIMER0_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER1, - (u8 *)&(info->DSP_TIME[1]), - FT1000_MAG_DSP_TIMER1_INDX); + FT1000_MAG_DSP_TIMER1, + (u8 *)&(info->DSP_TIME[1]), + FT1000_MAG_DSP_TIMER1_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER2, - (u8 *)&(info->DSP_TIME[2]), - FT1000_MAG_DSP_TIMER2_INDX); + FT1000_MAG_DSP_TIMER2, + (u8 *)&(info->DSP_TIME[2]), + FT1000_MAG_DSP_TIMER2_INDX); status = ft1000_read_dpram16(dev, - FT1000_MAG_DSP_TIMER3, - (u8 *)&(info->DSP_TIME[3]), - FT1000_MAG_DSP_TIMER3_INDX); + FT1000_MAG_DSP_TIMER3, + (u8 *)&(info->DSP_TIME[3]), + FT1000_MAG_DSP_TIMER3_INDX); info->CardReady = 0; info->DrvErrNum = DSP_CONDRESET_INFO; - DEBUG("ft1000_hw:DSP conditional reset requested\n"); + pr_debug("DSP conditional reset requested\n"); info->ft1000_reset(dev->net); } else { dev->fProvComplete = false; dev->fCondResetPend = true; } ft1000_write_register(dev, FT1000_DB_COND_RESET, - FT1000_REG_DOORBELL); + FT1000_REG_DOORBELL); } } return 0; diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index cb644a58d9f3..e9472bebda0b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -1,30 +1,30 @@ /* -*--------------------------------------------------------------------------- -* FT1000 driver for Flarion Flash OFDM NIC Device -* -* Copyright (C) 2002 Flarion Technologies, 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., 59 Temple Place - -* Suite 330, Boston, MA 02111-1307, USA. -*--------------------------------------------------------------------------- -* -* File: ft1000_ioctl.h -* -* Description: Common structures and defines relating to IOCTL -* -* History: -* 11/5/02 Whc Created. -* -*--------------------------------------------------------------------------- -*/ + *--------------------------------------------------------------------------- + * FT1000 driver for Flarion Flash OFDM NIC Device + * + * Copyright (C) 2002 Flarion Technologies, 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., 59 Temple Place - + * Suite 330, Boston, MA 02111-1307, USA. + *--------------------------------------------------------------------------- + * + * File: ft1000_ioctl.h + * + * Description: Common structures and defines relating to IOCTL + * + * History: + * 11/5/02 Whc Created. + * + *--------------------------------------------------------------------------- + */ #ifndef _FT1000IOCTLH_ #define _FT1000IOCTLH_ @@ -94,8 +94,8 @@ struct IOCTL_DPRAM_COMMAND { } __packed; /* -* Custom IOCTL command codes -*/ + * Custom IOCTL command codes + */ #define FT1000_MAGIC_CODE 'F' #define IOCTL_REGISTER_CMD 0 @@ -106,8 +106,8 @@ struct IOCTL_DPRAM_COMMAND { #define IOCTL_CONNECT 10 #define IOCTL_DISCONNECT 11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, \ - IOCTL_GET_DSP_STAT_CMD, \ +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, \ + IOCTL_GET_DSP_STAT_CMD, \ struct IOCTL_GET_DSP_STAT) #define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, \ struct IOCTL_GET_VER) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index 39be30c0eedf..a6b55f42c07c 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -7,6 +7,9 @@ * $Id: *==================================================== */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/kernel.h> #include <linux/module.h> #include <linux/usb.h> @@ -45,7 +48,7 @@ static int ft1000_poll_thread(void *arg) if (!gPollingfailed) { ret = ft1000_poll(arg); if (ret != 0) { - DEBUG("ft1000_poll_thread: polling failed\n"); + pr_debug("polling failed\n"); gPollingfailed = true; } } @@ -71,9 +74,8 @@ static int ft1000_probe(struct usb_interface *interface, return -ENOMEM; dev = interface_to_usbdev(interface); - DEBUG("ft1000_probe: usb device descriptor info:\n"); - DEBUG("ft1000_probe: number of configuration is %d\n", - dev->descriptor.bNumConfigurations); + pr_debug("usb device descriptor info - number of configuration is %d\n", + dev->descriptor.bNumConfigurations); ft1000dev->dev = dev; ft1000dev->status = 0; @@ -85,60 +87,56 @@ static int ft1000_probe(struct usb_interface *interface, goto err_fw; } - DEBUG("ft1000_probe is called\n"); numaltsetting = interface->num_altsetting; - DEBUG("ft1000_probe: number of alt settings is :%d\n", numaltsetting); + pr_debug("number of alt settings is: %d\n", numaltsetting); iface_desc = interface->cur_altsetting; - DEBUG("ft1000_probe: number of endpoints is %d\n", - iface_desc->desc.bNumEndpoints); - DEBUG("ft1000_probe: descriptor type is %d\n", - iface_desc->desc.bDescriptorType); - DEBUG("ft1000_probe: interface number is %d\n", - iface_desc->desc.bInterfaceNumber); - DEBUG("ft1000_probe: alternatesetting is %d\n", - iface_desc->desc.bAlternateSetting); - DEBUG("ft1000_probe: interface class is %d\n", - iface_desc->desc.bInterfaceClass); - DEBUG("ft1000_probe: control endpoint info:\n"); - DEBUG("ft1000_probe: descriptor0 type -- %d\n", - iface_desc->endpoint[0].desc.bmAttributes); - DEBUG("ft1000_probe: descriptor1 type -- %d\n", - iface_desc->endpoint[1].desc.bmAttributes); - DEBUG("ft1000_probe: descriptor2 type -- %d\n", - iface_desc->endpoint[2].desc.bmAttributes); + pr_debug("number of endpoints is: %d\n", + iface_desc->desc.bNumEndpoints); + pr_debug("descriptor type is: %d\n", iface_desc->desc.bDescriptorType); + pr_debug("interface number is: %d\n", + iface_desc->desc.bInterfaceNumber); + pr_debug("alternatesetting is: %d\n", + iface_desc->desc.bAlternateSetting); + pr_debug("interface class is: %d\n", iface_desc->desc.bInterfaceClass); + pr_debug("control endpoint info:\n"); + pr_debug("descriptor0 type -- %d\n", + iface_desc->endpoint[0].desc.bmAttributes); + pr_debug("descriptor1 type -- %d\n", + iface_desc->endpoint[1].desc.bmAttributes); + pr_debug("descriptor2 type -- %d\n", + iface_desc->endpoint[2].desc.bmAttributes); for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = - (struct usb_endpoint_descriptor *)&iface_desc-> - endpoint[i].desc; - DEBUG("endpoint %d\n", i); - DEBUG("bEndpointAddress=%x, bmAttributes=%x\n", - endpoint->bEndpointAddress, endpoint->bmAttributes); + (struct usb_endpoint_descriptor *)&iface_desc-> + endpoint[i].desc; + pr_debug("endpoint %d\n", i); + pr_debug("bEndpointAddress=%x, bmAttributes=%x\n", + endpoint->bEndpointAddress, endpoint->bmAttributes); if ((endpoint->bEndpointAddress & USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_in_endpointAddr = - endpoint->bEndpointAddress; - DEBUG("ft1000_probe: in: %d\n", - endpoint->bEndpointAddress); + endpoint->bEndpointAddress; + pr_debug("in: %d\n", endpoint->bEndpointAddress); } if (!(endpoint->bEndpointAddress & USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK)) { ft1000dev->bulk_out_endpointAddr = - endpoint->bEndpointAddress; - DEBUG("ft1000_probe: out: %d\n", - endpoint->bEndpointAddress); + endpoint->bEndpointAddress; + pr_debug("out: %d\n", endpoint->bEndpointAddress); } } - DEBUG("bulk_in=%d, bulk_out=%d\n", ft1000dev->bulk_in_endpointAddr, - ft1000dev->bulk_out_endpointAddr); + pr_debug("bulk_in=%d, bulk_out=%d\n", + ft1000dev->bulk_in_endpointAddr, + ft1000dev->bulk_out_endpointAddr); ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev); if (ret < 0) { - pr_err("Error request_firmware().\n"); + pr_err("Error request_firmware()\n"); goto err_fw; } @@ -155,7 +153,7 @@ static int ft1000_probe(struct usb_interface *interface, FileLength = dsp_fw->size; release_firmware(dsp_fw); - DEBUG("ft1000_probe: start downloading dsp image...\n"); + pr_debug("start downloading dsp image...\n"); ret = init_ft1000_netdev(ft1000dev); if (ret) @@ -163,7 +161,7 @@ static int ft1000_probe(struct usb_interface *interface, pft1000info = netdev_priv(ft1000dev->net); - DEBUG("In probe: pft1000info=%p\n", pft1000info); + pr_debug("pft1000info=%p\n", pft1000info); ret = dsp_reload(ft1000dev); if (ret) { pr_err("Problem with DSP image loading\n"); @@ -172,7 +170,7 @@ static int ft1000_probe(struct usb_interface *interface, gPollingfailed = false; ft1000dev->pPollThread = - kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); + kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll"); if (IS_ERR(ft1000dev->pPollThread)) { ret = PTR_ERR(ft1000dev->pPollThread); @@ -187,10 +185,10 @@ static int ft1000_probe(struct usb_interface *interface, goto err_thread; } msleep(100); - DEBUG("ft1000_probe::Waiting for Card Ready\n"); + pr_debug("Waiting for Card Ready\n"); } - DEBUG("ft1000_probe::Card Ready!!!! Registering network device\n"); + pr_debug("Card Ready!!!! Registering network device\n"); ret = reg_ft1000_netdev(ft1000dev, interface); if (ret) @@ -216,24 +214,21 @@ static void ft1000_disconnect(struct usb_interface *interface) struct ft1000_info *pft1000info; struct ft1000_usb *ft1000dev; - DEBUG("ft1000_disconnect is called\n"); - - pft1000info = (struct ft1000_info *) usb_get_intfdata(interface); - DEBUG("In disconnect pft1000info=%p\n", pft1000info); + pft1000info = (struct ft1000_info *)usb_get_intfdata(interface); + pr_debug("In disconnect pft1000info=%p\n", pft1000info); if (pft1000info) { ft1000dev = pft1000info->priv; if (ft1000dev->pPollThread) kthread_stop(ft1000dev->pPollThread); - DEBUG("ft1000_disconnect: threads are terminated\n"); + pr_debug("threads are terminated\n"); if (ft1000dev->net) { - DEBUG("ft1000_disconnect: destroy char driver\n"); + pr_debug("destroy char driver\n"); ft1000_destroy_dev(ft1000dev->net); unregister_netdev(ft1000dev->net); - DEBUG - ("ft1000_disconnect: network device unregistered\n"); + pr_debug("network device unregistered\n"); free_netdev(ft1000dev->net); } @@ -241,7 +236,7 @@ static void ft1000_disconnect(struct usb_interface *interface) usb_free_urb(ft1000dev->rx_urb); usb_free_urb(ft1000dev->tx_urb); - DEBUG("ft1000_disconnect: urb freed\n"); + pr_debug("urb freed\n"); kfree(ft1000dev); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index 8f7ccae57f31..fea60d5651a7 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -28,8 +28,6 @@ struct app_info_block { */ } __packed; -#define DEBUG(args...) pr_info(args) - #define FALSE 0 #define TRUE 1 @@ -137,7 +135,7 @@ extern spinlock_t free_buff_lock; int ft1000_create_dev(struct ft1000_usb *dev); void ft1000_destroy_dev(struct net_device *dev); extern int card_send_command(struct ft1000_usb *ft1000dev, - void *ptempbuffer, int size); + void *ptempbuffer, int size); struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist); void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist); |