Commit cbb3ae99 authored by Katja Collier's avatar Katja Collier Committed by Greg Kroah-Hartman

staging: improved comment style in ft1000_debug.c

Replaced C99 style comments with C89 in
"/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c".
Signed-off-by: default avatarKatja Collier <katjacollier@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7580d7fe
//--------------------------------------------------------------------------- /*
// FT1000 driver for Flarion Flash OFDM NIC Device *---------------------------------------------------------------------------
// * FT1000 driver for Flarion Flash OFDM NIC Device
// Copyright (C) 2006 Flarion Technologies, All rights reserved. *
// * 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 * This program is free software; you can redistribute it and/or modify it
// Software Foundation; either version 2 of the License, or (at your option) any * under the terms of the GNU General Public License as published by the Free
// later version. This program is distributed in the hope that it will be useful, * Software Foundation; either version 2 of the License, or (at your option) any
// but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * later version. This program is distributed in the hope that it will be useful,
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// more details. You should have received a copy of the GNU General Public * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// License along with this program; if not, write to the * more details. You should have received a copy of the GNU General Public
// Free Software Foundation, Inc., 59 Temple Place - * License along with this program; if not, write to the
// Suite 330, Boston, MA 02111-1307, USA. * Free Software Foundation, Inc., 59 Temple Place -
//--------------------------------------------------------------------------- * Suite 330, Boston, MA 02111-1307, USA.
// *---------------------------------------------------------------------------
// File: ft1000_chdev.c *
// * File: ft1000_chdev.c
// Description: Custom character device dispatch routines. *
// * Description: Custom character device dispatch routines.
// History: *
// 8/29/02 Whc Ported to Linux. * History:
// 6/05/06 Whc Porting to Linux 2.6.9 * 8/29/02 Whc Ported to Linux.
// * 6/05/06 Whc Porting to Linux 2.6.9
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -44,17 +46,17 @@ static long ft1000_ioctl(struct file *file, unsigned int command, ...@@ -44,17 +46,17 @@ 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); static int ft1000_release (struct inode *inode, struct file *file);
// List to free receive command buffer pool /* List to free receive command buffer pool */
struct list_head freercvpool; struct list_head freercvpool;
// lock to arbitrate free buffer list for receive command data /* lock to arbitrate free buffer list for receive command data */
spinlock_t free_buff_lock; spinlock_t free_buff_lock;
int numofmsgbuf = 0; 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 = static const struct file_operations ft1000fops =
{ {
.unlocked_ioctl = ft1000_ioctl, .unlocked_ioctl = ft1000_ioctl,
...@@ -64,25 +66,27 @@ static const struct file_operations ft1000fops = ...@@ -64,25 +66,27 @@ static const struct file_operations ft1000fops =
.llseek = no_llseek, .llseek = no_llseek,
}; };
//--------------------------------------------------------------------------- /*
// Function: ft1000_get_buffer ---------------------------------------------------------------------------
// * Function: ft1000_get_buffer
// Parameters: *
// * Parameters:
// Returns: *
// * Returns:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist)
{ {
unsigned long flags; unsigned long flags;
struct dpram_blk *ptr; struct dpram_blk *ptr;
spin_lock_irqsave(&free_buff_lock, flags); spin_lock_irqsave(&free_buff_lock, flags);
// Check if buffer is available /* Check if buffer is available */
if ( list_empty(bufflist) ) { if ( list_empty(bufflist) ) {
DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf); DEBUG("ft1000_get_buffer: No more buffer - %d\n", numofmsgbuf);
ptr = NULL; ptr = NULL;
...@@ -91,7 +95,7 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) ...@@ -91,7 +95,7 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist)
numofmsgbuf--; numofmsgbuf--;
ptr = list_entry(bufflist->next, struct dpram_blk, list); ptr = list_entry(bufflist->next, struct dpram_blk, list);
list_del(&ptr->list); list_del(&ptr->list);
//DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); /* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */
} }
spin_unlock_irqrestore(&free_buff_lock, flags); spin_unlock_irqrestore(&free_buff_lock, flags);
...@@ -101,42 +105,46 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist) ...@@ -101,42 +105,46 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist)
//--------------------------------------------------------------------------- /*
// Function: ft1000_free_buffer *---------------------------------------------------------------------------
// * Function: ft1000_free_buffer
// Parameters: *
// * Parameters:
// Returns: *
// * Returns:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist) void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&free_buff_lock, flags); spin_lock_irqsave(&free_buff_lock, flags);
// Put memory back to list /* Put memory back to list */
list_add_tail(&pdpram_blk->list, plist); list_add_tail(&pdpram_blk->list, plist);
numofmsgbuf++; numofmsgbuf++;
//DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); /*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */
spin_unlock_irqrestore(&free_buff_lock, flags); spin_unlock_irqrestore(&free_buff_lock, flags);
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_CreateDevice *---------------------------------------------------------------------------
// * Function: ft1000_CreateDevice
// Parameters: dev - pointer to adapter object *
// * Parameters: dev - pointer to adapter object
// Returns: 0 if successful *
// * Returns: 0 if successful
// Description: Creates a private char device. *
// * Description: Creates a private char device.
// Notes: Only called by init_module(). *
// * Notes: Only called by init_module().
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
int ft1000_create_dev(struct ft1000_usb *dev) int ft1000_create_dev(struct ft1000_usb *dev)
{ {
int result; int result;
...@@ -144,7 +152,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) ...@@ -144,7 +152,7 @@ int ft1000_create_dev(struct ft1000_usb *dev)
struct dentry *dir, *file; struct dentry *dir, *file;
struct ft1000_debug_dirs *tmp; struct ft1000_debug_dirs *tmp;
// make a new device name /* make a new device name */
sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber); sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber);
DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt); DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt);
...@@ -157,7 +165,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) ...@@ -157,7 +165,7 @@ int ft1000_create_dev(struct ft1000_usb *dev)
} }
// register the device /* register the device */
DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName); DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName);
tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL); tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL);
...@@ -186,7 +194,7 @@ int ft1000_create_dev(struct ft1000_usb *dev) ...@@ -186,7 +194,7 @@ int ft1000_create_dev(struct ft1000_usb *dev)
DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName); DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName);
// initialize application information /* initialize application information */
dev->appcnt = 0; dev->appcnt = 0;
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
dev->app_info[i].nTxMsg = 0; dev->app_info[i].nTxMsg = 0;
...@@ -214,16 +222,18 @@ int ft1000_create_dev(struct ft1000_usb *dev) ...@@ -214,16 +222,18 @@ int ft1000_create_dev(struct ft1000_usb *dev)
return result; return result;
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_DestroyDeviceDEBUG *---------------------------------------------------------------------------
// * Function: ft1000_DestroyDeviceDEBUG
// Parameters: dev - pointer to adapter object *
// * Parameters: dev - pointer to adapter object
// Description: Destroys a private char device. *
// * Description: Destroys a private char device.
// Notes: Only called by cleanup_module(). *
// * Notes: Only called by cleanup_module().
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
void ft1000_destroy_dev(struct net_device *netdev) void ft1000_destroy_dev(struct net_device *netdev)
{ {
struct ft1000_info *info = netdev_priv(netdev); struct ft1000_info *info = netdev_priv(netdev);
...@@ -253,7 +263,7 @@ void ft1000_destroy_dev(struct net_device *netdev) ...@@ -253,7 +263,7 @@ void ft1000_destroy_dev(struct net_device *netdev)
DEBUG("%s: unregistered device \"%s\"\n", __func__, DEBUG("%s: unregistered device \"%s\"\n", __func__,
dev->DeviceName); dev->DeviceName);
// Make sure we free any memory reserve for slow Queue /* Make sure we free any memory reserve for slow Queue */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
while (list_empty(&dev->app_info[i].app_sqlist) == 0) { 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); pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
...@@ -264,7 +274,7 @@ void ft1000_destroy_dev(struct net_device *netdev) ...@@ -264,7 +274,7 @@ void ft1000_destroy_dev(struct net_device *netdev)
wake_up_interruptible(&dev->app_info[i].wait_dpram_msg); wake_up_interruptible(&dev->app_info[i].wait_dpram_msg);
} }
// Remove buffer allocated for receive command data /* Remove buffer allocated for receive command data */
if (ft1000_flarion_cnt == 0) { if (ft1000_flarion_cnt == 0) {
while (list_empty(&freercvpool) == 0) { while (list_empty(&freercvpool) == 0) {
ptr = list_entry(freercvpool.next, struct dpram_blk, list); ptr = list_entry(freercvpool.next, struct dpram_blk, list);
...@@ -279,16 +289,18 @@ void ft1000_destroy_dev(struct net_device *netdev) ...@@ -279,16 +289,18 @@ void ft1000_destroy_dev(struct net_device *netdev)
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_open *---------------------------------------------------------------------------
// * Function: ft1000_open
// Parameters: *
// * Parameters:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
static int ft1000_open (struct inode *inode, struct file *file) static int ft1000_open (struct inode *inode, struct file *file)
{ {
struct ft1000_info *info; struct ft1000_info *info;
...@@ -303,20 +315,20 @@ static int ft1000_open (struct inode *inode, struct file *file) ...@@ -303,20 +315,20 @@ static int ft1000_open (struct inode *inode, struct file *file)
DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt ); DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt );
// Check if maximum number of application exceeded /* Check if maximum number of application exceeded */
if (dev->appcnt > MAX_NUM_APP) { if (dev->appcnt > MAX_NUM_APP) {
DEBUG("Maximum number of application exceeded\n"); DEBUG("Maximum number of application exceeded\n");
return -EACCES; return -EACCES;
} }
// Search for available application info block /* Search for available application info block */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if ( (dev->app_info[i].fileobject == NULL) ) { if ( (dev->app_info[i].fileobject == NULL) ) {
break; break;
} }
} }
// Fail due to lack of application info block /* Fail due to lack of application info block */
if (i == MAX_NUM_APP) { if (i == MAX_NUM_APP) {
DEBUG("Could not find an application info block\n"); DEBUG("Could not find an application info block\n");
return -EACCES; return -EACCES;
...@@ -334,16 +346,18 @@ static int ft1000_open (struct inode *inode, struct file *file) ...@@ -334,16 +346,18 @@ static int ft1000_open (struct inode *inode, struct file *file)
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_poll_dev *---------------------------------------------------------------------------
// * Function: ft1000_poll_dev
// Parameters: *
// * Parameters:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
{ {
...@@ -352,21 +366,21 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) ...@@ -352,21 +366,21 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
struct ft1000_usb *dev = info->priv; struct ft1000_usb *dev = info->priv;
int i; int i;
//DEBUG("ft1000_poll_dev called\n"); /* DEBUG("ft1000_poll_dev called\n"); */
if (ft1000_flarion_cnt == 0) { if (ft1000_flarion_cnt == 0) {
DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n"); DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n");
return (-EBADF); return (-EBADF);
} }
// Search for matching file object /* Search for matching file object */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if ( dev->app_info[i].fileobject == &file->f_owner) { 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); /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id); */
break; break;
} }
} }
// Could not find application info block /* Could not find application info block */
if (i == MAX_NUM_APP) { if (i == MAX_NUM_APP) {
DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
return ( -EACCES ); return ( -EACCES );
...@@ -378,21 +392,23 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait) ...@@ -378,21 +392,23 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
} }
poll_wait (file, &dev->app_info[i].wait_dpram_msg, wait); poll_wait (file, &dev->app_info[i].wait_dpram_msg, wait);
//DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); /* DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n"); */
return (0); return (0);
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_ioctl *---------------------------------------------------------------------------
// * Function: ft1000_ioctl
// Parameters: *
// * Parameters:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
static long ft1000_ioctl (struct file *file, unsigned int command, static long ft1000_ioctl (struct file *file, unsigned int command,
unsigned long argument) unsigned long argument)
{ {
...@@ -417,21 +433,21 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -417,21 +433,21 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
unsigned short ledStat=0; unsigned short ledStat=0;
unsigned short conStat=0; unsigned short conStat=0;
//DEBUG("ft1000_ioctl called\n"); /* DEBUG("ft1000_ioctl called\n"); */
if (ft1000_flarion_cnt == 0) { if (ft1000_flarion_cnt == 0) {
DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n"); DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n");
return (-EBADF); return (-EBADF);
} }
//DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */
info = file->private_data; info = file->private_data;
ft1000dev = info->priv; ft1000dev = info->priv;
cmd = _IOC_NR(command); cmd = _IOC_NR(command);
//DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */
// process the command /* process the command */
switch (cmd) { switch (cmd) {
case IOCTL_REGISTER_CMD: case IOCTL_REGISTER_CMD:
DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n"); DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n");
...@@ -441,7 +457,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -441,7 +457,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
break; break;
} }
if (tempword == DSPBCMSGID) { if (tempword == DSPBCMSGID) {
// Search for matching file object /* Search for matching file object */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if (ft1000dev->app_info[i].fileobject == &file->f_owner) { if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
ft1000dev->app_info[i].DspBCMsgFlag = 1; ft1000dev->app_info[i].DspBCMsgFlag = 1;
...@@ -467,20 +483,20 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -467,20 +483,20 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
break; break;
case IOCTL_CONNECT: case IOCTL_CONNECT:
// Connect Message /* Connect Message */
DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n"); DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n");
ConnectionMsg[79] = 0xfc; ConnectionMsg[79] = 0xfc;
card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
break; break;
case IOCTL_DISCONNECT: case IOCTL_DISCONNECT:
// Disconnect Message /* Disconnect Message */
DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n"); DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n");
ConnectionMsg[79] = 0xfd; ConnectionMsg[79] = 0xfd;
card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c); card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
break; break;
case IOCTL_GET_DSP_STAT_CMD: case IOCTL_GET_DSP_STAT_CMD:
//DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */
memset(&get_stat_data, 0, sizeof(get_stat_data)); memset(&get_stat_data, 0, sizeof(get_stat_data));
memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ); memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ);
memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ); memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ);
...@@ -517,7 +533,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -517,7 +533,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
case IOCTL_SET_DPRAM_CMD: case IOCTL_SET_DPRAM_CMD:
{ {
IOCTL_DPRAM_BLK *dpram_data = NULL; IOCTL_DPRAM_BLK *dpram_data = NULL;
//IOCTL_DPRAM_COMMAND dpram_command; /* IOCTL_DPRAM_COMMAND dpram_command; */
u16 qtype; u16 qtype;
u16 msgsz; u16 msgsz;
struct pseudo_hdr *ppseudo_hdr; struct pseudo_hdr *ppseudo_hdr;
...@@ -526,7 +542,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -526,7 +542,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
u16 app_index; u16 app_index;
u16 status; u16 status;
//DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n"); /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/
if (ft1000_flarion_cnt == 0) { if (ft1000_flarion_cnt == 0) {
...@@ -545,12 +561,12 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -545,12 +561,12 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
if (info->CardReady) { if (info->CardReady) {
//DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */
// Get the length field to see how many bytes to copy /* Get the length field to see how many bytes to copy */
result = get_user(msgsz, (__u16 __user *)argp); result = get_user(msgsz, (__u16 __user *)argp);
msgsz = ntohs (msgsz); msgsz = ntohs (msgsz);
//DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */
if (msgsz > MAX_CMD_SQSIZE) { if (msgsz > MAX_CMD_SQSIZE) {
DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz); DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz);
...@@ -568,7 +584,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -568,7 +584,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
result = -EFAULT; result = -EFAULT;
} }
else { else {
// Check if this message came from a registered application /* Check if this message came from a registered application */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if (ft1000dev->app_info[i].fileobject == &file->f_owner) { if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
break; break;
...@@ -582,28 +598,28 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -582,28 +598,28 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
} }
app_index = i; app_index = i;
// Check message qtype type which is the lower byte within qos_class /* Check message qtype type which is the lower byte within qos_class */
qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff; qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
//DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */
if (qtype) { if (qtype) {
} }
else { else {
// Put message into Slow Queue /* Put message into Slow Queue */
// Only put a message into the DPRAM if msg doorbell is available /* Only put a message into the DPRAM if msg doorbell is available */
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
//DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */
if (tempword & FT1000_DB_DPRAM_TX) { if (tempword & FT1000_DB_DPRAM_TX) {
// Suspend for 2ms and try again due to DSP doorbell busy /* Suspend for 2ms and try again due to DSP doorbell busy */
mdelay(2); mdelay(2);
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
if (tempword & FT1000_DB_DPRAM_TX) { if (tempword & FT1000_DB_DPRAM_TX) {
// Suspend for 1ms and try again due to DSP doorbell busy /* Suspend for 1ms and try again due to DSP doorbell busy */
mdelay(1); mdelay(1);
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
if (tempword & FT1000_DB_DPRAM_TX) { if (tempword & FT1000_DB_DPRAM_TX) {
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
if (tempword & FT1000_DB_DPRAM_TX) { if (tempword & FT1000_DB_DPRAM_TX) {
// Suspend for 3ms and try again due to DSP doorbell busy /* Suspend for 3ms and try again due to DSP doorbell busy */
mdelay(3); mdelay(3);
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL); status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
if (tempword & FT1000_DB_DPRAM_TX) { if (tempword & FT1000_DB_DPRAM_TX) {
...@@ -617,11 +633,11 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -617,11 +633,11 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
} }
} }
//DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */
// Make sure we are within the limits of the slow queue memory limitation /* Make sure we are within the limits of the slow queue memory limitation */
if ( (msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ) ) { if ( (msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ) ) {
// Need to put sequence number plus new checksum for message /* Need to put sequence number plus new checksum for message */
pmsg = (u16 *)&dpram_data->pseudohdr; pmsg = (u16 *)&dpram_data->pseudohdr;
ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr = (struct pseudo_hdr *)pmsg;
total_len = msgsz+2; total_len = msgsz+2;
...@@ -629,15 +645,15 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -629,15 +645,15 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
total_len++; total_len++;
} }
// Insert slow queue sequence number /* Insert slow queue sequence number */
ppseudo_hdr->seq_num = info->squeseqnum++; ppseudo_hdr->seq_num = info->squeseqnum++;
ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id; ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id;
// Calculate new checksum /* Calculate new checksum */
ppseudo_hdr->checksum = *pmsg++; ppseudo_hdr->checksum = *pmsg++;
//DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */
for (i=1; i<7; i++) { for (i=1; i<7; i++) {
ppseudo_hdr->checksum ^= *pmsg++; ppseudo_hdr->checksum ^= *pmsg++;
//DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */
} }
pmsg++; pmsg++;
ppseudo_hdr = (struct pseudo_hdr *)pmsg; ppseudo_hdr = (struct pseudo_hdr *)pmsg;
...@@ -666,21 +682,21 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -666,21 +682,21 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
IOCTL_DPRAM_BLK __user *pioctl_dpram; IOCTL_DPRAM_BLK __user *pioctl_dpram;
int msglen; int msglen;
//DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */
if (ft1000_flarion_cnt == 0) { if (ft1000_flarion_cnt == 0) {
return (-EBADF); return (-EBADF);
} }
// Search for matching file object /* Search for matching file object */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if (ft1000dev->app_info[i].fileobject == &file->f_owner) { 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); /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
break; break;
} }
} }
// Could not find application info block /* Could not find application info block */
if (i == MAX_NUM_APP) { if (i == MAX_NUM_APP) {
DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n"); DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
result = -EBADF; result = -EBADF;
...@@ -690,30 +706,30 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -690,30 +706,30 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
result = 0; result = 0;
pioctl_dpram = argp; pioctl_dpram = argp;
if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) { if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
//DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */
spin_lock_irqsave(&free_buff_lock, flags); spin_lock_irqsave(&free_buff_lock, flags);
pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list); pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
list_del(&pdpram_blk->list); list_del(&pdpram_blk->list);
ft1000dev->app_info[i].NumOfMsg--; ft1000dev->app_info[i].NumOfMsg--;
//DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, 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); spin_unlock_irqrestore(&free_buff_lock, flags);
msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ; msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ;
result = get_user(msglen, &pioctl_dpram->total_len); result = get_user(msglen, &pioctl_dpram->total_len);
if (result) if (result)
break; break;
msglen = htons(msglen); msglen = htons(msglen);
//DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */
if(copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) if(copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen))
{ {
DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n"); DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
result = -EFAULT; result = -EFAULT;
break; break;
} }
ft1000_free_buffer(pdpram_blk, &freercvpool); ft1000_free_buffer(pdpram_blk, &freercvpool);
result = msglen; result = msglen;
} }
//DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */
} }
break; break;
...@@ -726,16 +742,18 @@ static long ft1000_ioctl (struct file *file, unsigned int command, ...@@ -726,16 +742,18 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
return result; return result;
} }
//--------------------------------------------------------------------------- /*
// Function: ft1000_release *---------------------------------------------------------------------------
// * Function: ft1000_release
// Parameters: *
// * Parameters:
// Description: *
// * Description:
// Notes: *
// * Notes:
//--------------------------------------------------------------------------- *
*---------------------------------------------------------------------------
*/
static int ft1000_release (struct inode *inode, struct file *file) static int ft1000_release (struct inode *inode, struct file *file)
{ {
struct ft1000_info *info; struct ft1000_info *info;
...@@ -755,10 +773,10 @@ static int ft1000_release (struct inode *inode, struct file *file) ...@@ -755,10 +773,10 @@ static int ft1000_release (struct inode *inode, struct file *file)
return (-EBADF); return (-EBADF);
} }
// Search for matching file object /* Search for matching file object */
for (i=0; i<MAX_NUM_APP; i++) { for (i=0; i<MAX_NUM_APP; i++) {
if ( ft1000dev->app_info[i].fileobject == &file->f_owner) { 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); /* DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
break; break;
} }
} }
...@@ -773,11 +791,10 @@ static int ft1000_release (struct inode *inode, struct file *file) ...@@ -773,11 +791,10 @@ static int ft1000_release (struct inode *inode, struct file *file)
ft1000_free_buffer(pdpram_blk, &freercvpool); ft1000_free_buffer(pdpram_blk, &freercvpool);
} }
// initialize application information /* initialize application information */
ft1000dev->appcnt--; ft1000dev->appcnt--;
DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt); DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt);
ft1000dev->app_info[i].fileobject = NULL; ft1000dev->app_info[i].fileobject = NULL;
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment