2010-12-09 10:24:36

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 0/8] Use debugfs for debugging purposes.

Following patches add basic support for debugfs usage instead
character device. Creation of file and directory in debugfs
depend on every device plugged in the system.

Also basic cleanups was made. File operations functionality is not
yet checked and patches will follow.

Marek Belisko (8):
staging: ft1000: Convert char device to debugfs.
staging: ft1000: Fix private data pointer usage.
staging: ft1000: Remove unused pdevobj array.
staging: ft1000: Remove unused variable.
staging: ft1000: Fix camelcase functions and variables.
staging: ft1000: Remove dead code.
staging: ft1000: Remove unused headers.
staging: ft1000: Fix debug messages.

drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 314 +++++++++-------------
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 4 +-
drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 2 +-
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 13 +-
4 files changed, 141 insertions(+), 192 deletions(-)


2010-12-09 10:24:43

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 5/8] staging: ft1000: Fix camelcase functions and variables.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 156 +++++++++++-----------
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 2 +-
drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 2 +-
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 4 +-
4 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 4e5c8a3..85f67e5 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -45,11 +45,11 @@ static int ft1000_flarion_cnt = 0;

//need to looking usage of ft1000Handle

-static int ft1000_ChOpen (struct inode *Inode, struct file *File);
-static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait);
-static long ft1000_ChIoctl(struct file *File, unsigned int Command,
- unsigned long Argument);
-static int ft1000_ChRelease (struct inode *Inode, struct file *File);
+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);
+static int ft1000_release (struct inode *inode, struct file *file);

// List to free receive command buffer pool
struct list_head freercvpool;
@@ -67,10 +67,10 @@ int numofmsgbuf = 0;
//
static struct file_operations ft1000fops =
{
- .unlocked_ioctl = ft1000_ChIoctl,
- .poll = ft1000_ChPoll,
- .open = ft1000_ChOpen,
- .release = ft1000_ChRelease,
+ .unlocked_ioctl = ft1000_ioctl,
+ .poll = ft1000_poll_dev,
+ .open = ft1000_open,
+ .release = ft1000_release,
.llseek = no_llseek,
};

@@ -147,7 +147,7 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist)
// Notes: Only called by init_module().
//
//---------------------------------------------------------------------------
-int ft1000_CreateDevice(struct ft1000_device *dev)
+int ft1000_create_dev(struct ft1000_device *dev)
{
struct ft1000_info *info = netdev_priv(dev->net);
int result;
@@ -265,7 +265,7 @@ fail:
// Notes: Only called by cleanup_module().
//
//---------------------------------------------------------------------------
-void ft1000_DestroyDevice(struct net_device *dev)
+void ft1000_destroy_dev(struct net_device *dev)
{
struct ft1000_info *info = netdev_priv(dev);
int i;
@@ -323,7 +323,7 @@ void ft1000_DestroyDevice(struct net_device *dev)
}

//---------------------------------------------------------------------------
-// Function: ft1000_ChOpen
+// Function: ft1000_open
//
// Parameters:
//
@@ -332,19 +332,19 @@ void ft1000_DestroyDevice(struct net_device *dev)
// Notes:
//
//---------------------------------------------------------------------------
-static int ft1000_ChOpen (struct inode *Inode, struct file *File)
+static int ft1000_open (struct inode *inode, struct file *file)
{
struct ft1000_info *info;
- struct ft1000_device *dev = (struct ft1000_device *)Inode->i_private;
+ struct ft1000_device *dev = (struct ft1000_device *)inode->i_private;
int i,num;

- DEBUG("ft1000_ChOpen called\n");
- num = (MINOR(Inode->i_rdev) & 0xf);
- DEBUG("ft1000_ChOpen: minor number=%d\n", num);
+ DEBUG("ft1000_open called\n");
+ num = (MINOR(inode->i_rdev) & 0xf);
+ DEBUG("ft1000_open: minor number=%d\n", num);

- info = File->private_data = netdev_priv(dev->net);
+ info = file->private_data = netdev_priv(dev->net);

- DEBUG("f_owner = %p number of application = %d\n", (&File->f_owner), info->appcnt );
+ DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), info->appcnt );

// Check if maximum number of application exceeded
if (info->appcnt > MAX_NUM_APP) {
@@ -366,19 +366,19 @@ static int ft1000_ChOpen (struct inode *Inode, struct file *File)
}

info->appcnt++;
- info->app_info[i].fileobject = &File->f_owner;
+ info->app_info[i].fileobject = &file->f_owner;
info->app_info[i].nTxMsg = 0;
info->app_info[i].nRxMsg = 0;
info->app_info[i].nTxMsgReject = 0;
info->app_info[i].nRxMsgMiss = 0;

- nonseekable_open(Inode, File);
+ nonseekable_open(inode, file);
return 0;
}


//---------------------------------------------------------------------------
-// Function: ft1000_ChPoll
+// Function: ft1000_poll_dev
//
// Parameters:
//
@@ -388,15 +388,15 @@ static int ft1000_ChOpen (struct inode *Inode, struct file *File)
//
//---------------------------------------------------------------------------

-static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait)
+static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
{
struct net_device *dev = file->private_data;
struct ft1000_info *info;
int i;

- //DEBUG("ft1000_ChPoll called\n");
+ //DEBUG("ft1000_poll_dev called\n");
if (ft1000_flarion_cnt == 0) {
- DEBUG("FT1000:ft1000_ChPoll called when ft1000_flarion_cnt is zero\n");
+ DEBUG("FT1000:ft1000_poll_dev called when ft1000_flarion_cnt is zero\n");
return (-EBADF);
}

@@ -405,30 +405,30 @@ static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait)
// Search for matching file object
for (i=0; i<MAX_NUM_APP; i++) {
if ( info->app_info[i].fileobject == &file->f_owner) {
- //DEBUG("FT1000:ft1000_ChIoctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+ //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
break;
}
}

// Could not find application info block
if (i == MAX_NUM_APP) {
- DEBUG("FT1000:ft1000_ChIoctl:Could not find application info block\n");
+ DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
return ( -EACCES );
}

if (list_empty(&info->app_info[i].app_sqlist) == 0) {
- DEBUG("FT1000:ft1000_ChPoll:Message detected in slow queue\n");
+ DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n");
return(POLLIN | POLLRDNORM | POLLPRI);
}

poll_wait (file, &info->app_info[i].wait_dpram_msg, wait);
- //DEBUG("FT1000:ft1000_ChPoll:Polling for data from DSP\n");
+ //DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n");

return (0);
}

//---------------------------------------------------------------------------
-// Function: ft1000_ChIoctl
+// Function: ft1000_ioctl
//
// Parameters:
//
@@ -437,10 +437,10 @@ static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait)
// Notes:
//
//---------------------------------------------------------------------------
-static long ft1000_ChIoctl (struct file *File, unsigned int Command,
- unsigned long Argument)
+static long ft1000_ioctl (struct file *file, unsigned int command,
+ unsigned long argument)
{
- void __user *argp = (void __user *)Argument;
+ void __user *argp = (void __user *)argument;
struct net_device *dev;
struct ft1000_info *info;
struct ft1000_device *ft1000dev;
@@ -462,25 +462,25 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
unsigned short ledStat=0;
unsigned short conStat=0;

- //DEBUG("ft1000_ChIoctl called\n");
+ //DEBUG("ft1000_ioctl called\n");

if (ft1000_flarion_cnt == 0) {
- DEBUG("FT1000:ft1000_ChIoctl called when ft1000_flarion_cnt is zero\n");
+ DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n");
return (-EBADF);
}

- //DEBUG("FT1000:ft1000_ChIoctl:Command = 0x%x Argument = 0x%8x\n", Command, (u32)Argument);
+ //DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument);

- dev = File->private_data;
+ dev = file->private_data;
info = netdev_priv(dev);
ft1000dev = info->pFt1000Dev;
- cmd = _IOC_NR(Command);
- //DEBUG("FT1000:ft1000_ChIoctl:cmd = 0x%x\n", cmd);
+ 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_ChIoctl: IOCTL_FT1000_REGISTER called\n");
+ 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);
@@ -489,9 +489,9 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
if (tempword == DSPBCMSGID) {
// Search for matching file object
for (i=0; i<MAX_NUM_APP; i++) {
- if ( info->app_info[i].fileobject == &File->f_owner) {
+ if ( info->app_info[i].fileobject == &file->f_owner) {
info->app_info[i].DspBCMsgFlag = 1;
- DEBUG("FT1000:ft1000_ChIoctl:Registered for broadcast messages\n");
+ DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n");
break;
}
}
@@ -499,34 +499,34 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
break;

case IOCTL_GET_VER_CMD:
- DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_GET_VER called\n");
+ 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_ChIoctl: copy fault occurred\n");
+ DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
result = -EFAULT;
break;
}

- DEBUG("FT1000:ft1000_ChIoctl:driver version = 0x%x\n",(unsigned int)get_ver_data.drv_ver);
+ 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_ChIoctl: IOCTL_FT1000_CONNECT\n");
+ DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n");
ConnectionMsg[79] = 0xfc;
CardSendCommand(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);

break;
case IOCTL_DISCONNECT:
// Disconnect Message
- DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_DISCONNECT\n");
+ DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n");
ConnectionMsg[79] = 0xfd;
CardSendCommand(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
break;
case IOCTL_GET_DSP_STAT_CMD:
- //DEBUG("FT1000:ft1000_ChIoctl: 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));
memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ);
memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ);
@@ -536,10 +536,10 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
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_ChIoctl: LedStat = 0x%x\n", get_stat_data.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_ChIoctl: ConStat = 0x%x\n", get_stat_data.ConStat);
+ DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat);
}
else {
get_stat_data.ConStat = 0x0f;
@@ -554,7 +554,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
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_ChIoctl: copy fault occurred\n");
+ DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
result = -EFAULT;
break;
}
@@ -572,7 +572,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
u16 app_index;
u16 status;

- //DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_SET_DPRAM called\n");
+ //DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");


if (ft1000_flarion_cnt == 0) {
@@ -591,15 +591,15 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,

if (info->CardReady) {

- //DEBUG("FT1000:ft1000_ChIoctl: 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
result = get_user(msgsz, (__u16 __user *)argp);
msgsz = ntohs (msgsz);
- //DEBUG("FT1000:ft1000_ChIoctl: length of message = %d\n", msgsz);
+ //DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz);

if (msgsz > MAX_CMD_SQSIZE) {
- DEBUG("FT1000:ft1000_ChIoctl: bad message length = %d\n", msgsz);
+ DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz);
result = -EINVAL;
break;
}
@@ -609,7 +609,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
if (!dpram_data)
break;

- //if ( copy_from_user(&(dpram_command.dpram_blk), (PIOCTL_DPRAM_BLK)Argument, msgsz+2) ) {
+ //if ( copy_from_user(&(dpram_command.dpram_blk), (PIOCTL_DPRAM_BLK)argument, msgsz+2) ) {
if ( copy_from_user(dpram_data, argp, msgsz+2) ) {
DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
result = -EFAULT;
@@ -624,7 +624,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
#endif
// Check if this message came from a registered application
for (i=0; i<MAX_NUM_APP; i++) {
- if ( info->app_info[i].fileobject == &File->f_owner) {
+ if ( info->app_info[i].fileobject == &file->f_owner) {
break;
}
}
@@ -639,14 +639,14 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
// Check message qtype type which is the lower byte within qos_class
//qtype = ntohs(dpram_command.dpram_blk.pseudohdr.qos_class) & 0xff;
qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
- //DEBUG("FT1000_ft1000_ChIoctl: qtype = %d\n", qtype);
+ //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_ChIoctl: READ REGISTER tempword=%x\n", tempword);
+ //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);
@@ -662,7 +662,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
mdelay(3);
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
if (tempword & FT1000_DB_DPRAM_TX) {
- DEBUG("FT1000:ft1000_ChIoctl:Doorbell not available\n");
+ DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n");
result = -ENOTTY;
kfree(dpram_data);
break;
@@ -672,7 +672,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
}
}

- //DEBUG("FT1000_ft1000_ChIoctl: 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
if ( (msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ) ) {
@@ -719,7 +719,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
}
}
else {
- DEBUG("FT1000:ft1000_ChIoctl: Card not ready take messages\n");
+ DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n");
result = -EACCES;
}
kfree(dpram_data);
@@ -732,7 +732,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
IOCTL_DPRAM_BLK __user *pioctl_dpram;
int msglen;

- //DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_GET_DPRAM called\n");
+ //DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n");

if (ft1000_flarion_cnt == 0) {
return (-EBADF);
@@ -740,15 +740,15 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,

// Search for matching file object
for (i=0; i<MAX_NUM_APP; i++) {
- if ( info->app_info[i].fileobject == &File->f_owner) {
- //DEBUG("FT1000:ft1000_ChIoctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+ if ( info->app_info[i].fileobject == &file->f_owner) {
+ //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
break;
}
}

// Could not find application info block
if (i == MAX_NUM_APP) {
- DEBUG("FT1000:ft1000_ChIoctl:Could not find application info block\n");
+ DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
result = -EBADF;
break;
}
@@ -756,22 +756,22 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
result = 0;
pioctl_dpram = argp;
if (list_empty(&info->app_info[i].app_sqlist) == 0) {
- //DEBUG("FT1000:ft1000_ChIoctl:Message detected in slow queue\n");
+ //DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n");
spin_lock_irqsave(&free_buff_lock, flags);
pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list);
list_del(&pdpram_blk->list);
info->app_info[i].NumOfMsg--;
- //DEBUG("FT1000:ft1000_ChIoctl:NumOfMsg for app %d = %d\n", i, info->app_info[i].NumOfMsg);
+ //DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, info->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_ChIoctl: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))
{
- DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
+ DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
result = -EFAULT;
break;
}
@@ -779,12 +779,12 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
ft1000_free_buffer(pdpram_blk, &freercvpool);
result = msglen;
}
- //DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_GET_DPRAM no message\n");
+ //DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n");
}
break;

default:
- DEBUG("FT1000:ft1000_ChIoctl:unknown command: 0x%x\n", Command);
+ DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command);
result = -ENOTTY;
break;
}
@@ -793,7 +793,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
}

//---------------------------------------------------------------------------
-// Function: ft1000_ChRelease
+// Function: ft1000_release
//
// Parameters:
//
@@ -802,16 +802,16 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
// Notes:
//
//---------------------------------------------------------------------------
-static int ft1000_ChRelease (struct inode *Inode, struct file *File)
+static int ft1000_release (struct inode *inode, struct file *file)
{
struct ft1000_info *info;
struct net_device *dev;
int i;
struct dpram_blk *pdpram_blk;

- DEBUG("ft1000_ChRelease called\n");
+ DEBUG("ft1000_release called\n");

- dev = File->private_data;
+ dev = file->private_data;
info = netdev_priv(dev);

if (ft1000_flarion_cnt == 0) {
@@ -821,8 +821,8 @@ static int ft1000_ChRelease (struct inode *Inode, struct file *File)

// Search for matching file object
for (i=0; i<MAX_NUM_APP; i++) {
- if ( info->app_info[i].fileobject == &File->f_owner) {
- //DEBUG("FT1000:ft1000_ChIoctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+ if ( info->app_info[i].fileobject == &file->f_owner) {
+ //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
break;
}
}
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 69f920f..7456787 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -952,7 +952,7 @@ int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *int


//Create character device, implemented by Jim
- ft1000_CreateDevice(ft1000dev);
+ ft1000_create_dev(ft1000dev);

DEBUG ("reg_ft1000_netdev returned\n");

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
index d71ac30..7dfed41 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
@@ -231,7 +231,7 @@ static void ft1000_disconnect(struct usb_interface *interface)

if (pft1000info->pFt1000Dev->net) {
DEBUG("ft1000_disconnect: destroy char driver\n");
- ft1000_DestroyDevice(pft1000info->pFt1000Dev->net);
+ ft1000_destroy_dev(pft1000info->pFt1000Dev->net);
unregister_netdev(pft1000info->pFt1000Dev->net);
DEBUG
("ft1000_disconnect: network device unregisterd\n");
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index 2c89d14..045ef30 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -579,8 +579,8 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLeng
extern struct list_head freercvpool;
extern spinlock_t free_buff_lock; // lock to arbitrate free buffer list for receive command data

-int ft1000_CreateDevice(struct ft1000_device *dev);
-void ft1000_DestroyDevice(struct net_device *dev);
+int ft1000_create_dev(struct ft1000_device *dev);
+void ft1000_destroy_dev(struct net_device *dev);
extern void CardSendCommand(struct ft1000_device *ft1000dev, void *ptempbuffer, int size);

struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);
--
1.7.1

2010-12-09 10:24:39

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 2/8] staging: ft1000: Fix private data pointer usage.

Assign private data pointer to device for usage in file operations.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 1238b77..8b735e4 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -347,12 +347,15 @@ void ft1000_DestroyDevice(struct net_device *dev)
static int ft1000_ChOpen (struct inode *Inode, struct file *File)
{
struct ft1000_info *info;
+ struct ft1000_device *dev = (struct ft1000_device *)Inode->i_private;
int i,num;

DEBUG("ft1000_ChOpen called\n");
num = (MINOR(Inode->i_rdev) & 0xf);
DEBUG("ft1000_ChOpen: minor number=%d\n", num);

+ info = File->private_data = netdev_priv(dev->net);
+
for (i=0; i<5; i++)
DEBUG("pdevobj[%d]=%p\n", i, pdevobj[i]); //aelias [+] reason: down

@@ -393,8 +396,6 @@ static int ft1000_ChOpen (struct inode *Inode, struct file *File)
info->app_info[i].nTxMsgReject = 0;
info->app_info[i].nRxMsgMiss = 0;

- File->private_data = pdevobj[num]->net;
-
nonseekable_open(Inode, File);
return 0;
}
--
1.7.1

2010-12-09 10:24:46

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 8/8] staging: ft1000: Fix debug messages.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index d249c8a..da76f11 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -148,18 +148,18 @@ int ft1000_create_dev(struct ft1000_device *dev)
// make a new device name
sprintf(info->DeviceName, "%s%d", "FT1000_", info->CardNumber);

- DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
+ DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt);
DEBUG("DeviceCreated = %x\n", info->DeviceCreated);

if (info->DeviceCreated)
{
- DEBUG("ft1000_CreateDevice: \"%s\" already registered\n", info->DeviceName);
+ DEBUG("%s: \"%s\" already registered\n", __func__, info->DeviceName);
return -EIO;
}


// register the device
- DEBUG("ft1000_CreateDevice: \"%s\" device registration\n", info->DeviceName);
+ DEBUG("%s: \"%s\" debugfs device registration\n", __func__, info->DeviceName);

tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL);
if (tmp == NULL) {
@@ -185,7 +185,7 @@ int ft1000_create_dev(struct ft1000_device *dev)
tmp->int_number = info->CardNumber;
list_add(&(tmp->list), &(info->nodes.list));

- DEBUG("ft1000_CreateDevice: registered char device \"%s\"\n", info->DeviceName);
+ DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, info->DeviceName);

// initialize application information
info->appcnt = 0;
@@ -234,7 +234,7 @@ void ft1000_destroy_dev(struct net_device *dev)
struct list_head *pos, *q;
struct ft1000_debug_dirs *dir;

- DEBUG("ft1000_chdev:ft1000_DestroyDevice called\n");
+ DEBUG("%s called\n", __func__);



@@ -250,7 +250,7 @@ void ft1000_destroy_dev(struct net_device *dev)
kfree(dir);
}
}
- DEBUG("ft1000_DestroyDevice: unregistered device \"%s\"\n",
+ DEBUG("%s: unregistered device \"%s\"\n", __func__,
info->DeviceName);

// Make sure we free any memory reserve for slow Queue
@@ -295,7 +295,7 @@ static int ft1000_open (struct inode *inode, struct file *file)
struct ft1000_device *dev = (struct ft1000_device *)inode->i_private;
int i,num;

- DEBUG("ft1000_open called\n");
+ DEBUG("%s called\n", __func__);
num = (MINOR(inode->i_rdev) & 0xf);
DEBUG("ft1000_open: minor number=%d\n", num);

--
1.7.1

2010-12-09 10:25:07

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 6/8] staging: ft1000: Remove dead code.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 61 +---------------------
1 files changed, 1 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 85f67e5..58aee36 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -39,12 +39,9 @@
#include <linux/unistd.h>
#include <linux/debugfs.h>
#include "ft1000_usb.h"
-//#include "ft1000_ioctl.h"

static int ft1000_flarion_cnt = 0;

-//need to looking usage of ft1000Handle
-
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,
@@ -59,9 +56,6 @@ spinlock_t free_buff_lock;

int numofmsgbuf = 0;

-// Global variable to indicate that all provisioning data is sent to DSP
-//bool fProvComplete;
-
//
// Table of entry-point routines for char device
//
@@ -198,29 +192,6 @@ int ft1000_create_dev(struct ft1000_device *dev)
DEBUG("ft1000_CreateDevice: registered char device \"%s\"\n", info->DeviceName);

// initialize application information
-
-// if (ft1000_flarion_cnt == 0) {
-//
-// DEBUG("Initialize free_buff_lock and freercvpool\n");
-// spin_lock_init(&free_buff_lock);
-//
-// // initialize a list of buffers to be use for queuing up receive command data
-// INIT_LIST_HEAD (&freercvpool);
-//
-// // create list of free buffers
-// for (i=0; i<NUM_OF_FREE_BUFFERS; i++) {
-// // Get memory for DPRAM_DATA link list
-// pdpram_blk = kmalloc ( sizeof(struct dpram_blk), GFP_KERNEL );
-// // Get a block of memory to store command data
-// pdpram_blk->pbuffer = kmalloc ( MAX_CMD_SQSIZE, GFP_KERNEL );
-// // link provisioning data
-// list_add_tail (&pdpram_blk->list, &freercvpool);
-// }
-// numofmsgbuf = NUM_OF_FREE_BUFFERS;
-// }
-
-
- // initialize application information
info->appcnt = 0;
for (i=0; i<MAX_NUM_APP; i++) {
info->app_info[i].nTxMsg = 0;
@@ -235,13 +206,6 @@ int ft1000_create_dev(struct ft1000_device *dev)
INIT_LIST_HEAD (&info->app_info[i].app_sqlist);
}

-
-
-
-// ft1000Handle[info->CardNumber] = devfs_register(NULL, info->DeviceName, DEVFS_FL_AUTO_DEVNUM, 0, 0,
-// S_IFCHR | S_IRUGO | S_IWUGO, &ft1000fops, NULL);
-
-
info->DeviceCreated = TRUE;
ft1000_flarion_cnt++;

@@ -313,9 +277,6 @@ void ft1000_destroy_dev(struct net_device *dev)
kfree(ptr);
}
}
-
-// devfs_unregister(ft1000Handle[info->CardNumber]);
-
info->DeviceCreated = FALSE;
}

@@ -609,19 +570,11 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
if (!dpram_data)
break;

- //if ( copy_from_user(&(dpram_command.dpram_blk), (PIOCTL_DPRAM_BLK)argument, msgsz+2) ) {
if ( copy_from_user(dpram_data, argp, msgsz+2) ) {
DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
result = -EFAULT;
}
else {
-#if 0
- // whc - for debugging only
- ptr = (char *)&dpram_data;
- for (i=0; i<msgsz; i++) {
- DEBUG(1,"FT1000:ft1000_ChIoctl: data %d = 0x%x\n", i, *ptr++);
- }
-#endif
// Check if this message came from a registered application
for (i=0; i<MAX_NUM_APP; i++) {
if ( info->app_info[i].fileobject == &file->f_owner) {
@@ -637,7 +590,6 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
app_index = i;

// Check message qtype type which is the lower byte within qos_class
- //qtype = ntohs(dpram_command.dpram_blk.pseudohdr.qos_class) & 0xff;
qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
//DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype);
if (qtype) {
@@ -677,7 +629,6 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
// 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_command.dpram_blk.pseudohdr;
pmsg = (u16 *)&dpram_data->pseudohdr;
ppseudo_hdr = (struct pseudo_hdr *)pmsg;
total_len = msgsz+2;
@@ -697,17 +648,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
}
pmsg++;
ppseudo_hdr = (struct pseudo_hdr *)pmsg;
-#if 0
- ptr = dpram_data;
- DEBUG("FT1000:ft1000_ChIoctl: Command Send\n");
- for (i=0; i<total_len; i++) {
- DEBUG("FT1000:ft1000_ChIoctl: data %d = 0x%x\n", i, *ptr++);
- }
-#endif
- //dpram_command.extra = 0;
-
- //CardSendCommand(ft1000dev,(unsigned char*)&dpram_command,total_len+2);
- CardSendCommand(ft1000dev,(unsigned short*)dpram_data,total_len+2);
+ CardSendCommand(ft1000dev,(unsigned short*)dpram_data,total_len+2);


info->app_info[app_index].nTxMsg++;
--
1.7.1

2010-12-09 10:25:05

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 7/8] staging: ft1000: Remove unused headers.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 58aee36..d249c8a 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -27,16 +27,12 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
-#include <linux/signal.h>
#include <linux/errno.h>
#include <linux/poll.h>
#include <linux/netdevice.h>
#include <linux/delay.h>

-#include <linux/fs.h>
-#include <linux/kmod.h>
#include <linux/ioctl.h>
-#include <linux/unistd.h>
#include <linux/debugfs.h>
#include "ft1000_usb.h"

--
1.7.1

2010-12-09 10:24:38

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 1/8] staging: ft1000: Convert char device to debugfs.

Character device was used only for debugging purposes.
Convert it to debugfs functionality. For every plugged device
create new directory with one file.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 68 +++++++++++++++------
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 1 +
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 8 +++
3 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 1aec926..1238b77 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -37,7 +37,7 @@
#include <linux/kmod.h>
#include <linux/ioctl.h>
#include <linux/unistd.h>
-
+#include <linux/debugfs.h>
#include "ft1000_usb.h"
//#include "ft1000_ioctl.h"

@@ -156,9 +156,11 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
struct ft1000_info *info = netdev_priv(dev->net);
int result;
int i;
+ struct dentry *dir, *file;
+ struct ft1000_debug_dirs *tmp;

// make a new device name
- sprintf(info->DeviceName, "%s%d", "FT100", info->CardNumber);
+ sprintf(info->DeviceName, "%s%d", "FT1000_", info->CardNumber);

DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
DEBUG("DeviceCreated = %x\n", info->DeviceCreated);
@@ -179,21 +181,31 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
DEBUG("ft1000_CreateDevice: \"%s\" device registration\n", info->DeviceName);
info->DeviceMajor = 0;

- result = register_chrdev(info->DeviceMajor, info->DeviceName, &ft1000fops);
- if (result < 0)
- {
- DEBUG("ft1000_CreateDevice: unable to get major %d\n", info->DeviceMajor);
- return result;
- }
+ tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL);
+ if (tmp == NULL) {
+ result = -1;
+ goto fail;
+ }

- DEBUG("ft1000_CreateDevice: registered char device \"%s\"\n", info->DeviceName);
+ dir = debugfs_create_dir(info->DeviceName, 0);
+ if (IS_ERR(dir)) {
+ result = PTR_ERR(dir);
+ goto debug_dir_fail;
+ }

- // save a dynamic device major number
- if (info->DeviceMajor == 0)
- {
- info->DeviceMajor = result;
- DEBUG("ft1000_PcdCreateDevice: device major = %d\n", info->DeviceMajor);
- }
+ file = debugfs_create_file("device", S_IRUGO | S_IWUGO, dir,
+ NULL, &ft1000fops);
+ if (IS_ERR(file)) {
+ result = PTR_ERR(file);
+ goto debug_file_fail;
+ }
+
+ tmp->dent = dir;
+ tmp->file = file;
+ tmp->int_number = info->CardNumber;
+ list_add(&(tmp->list), &(info->nodes.list));
+
+ DEBUG("ft1000_CreateDevice: registered char device \"%s\"\n", info->DeviceName);

// initialize application information

@@ -243,7 +255,14 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
info->DeviceCreated = TRUE;
ft1000_flarion_cnt++;

- return result;
+ return 0;
+
+debug_file_fail:
+ debugfs_remove(dir);
+debug_dir_fail:
+ kfree(tmp);
+fail:
+ return result;
}

//---------------------------------------------------------------------------
@@ -259,10 +278,11 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
void ft1000_DestroyDevice(struct net_device *dev)
{
struct ft1000_info *info = netdev_priv(dev);
- int result = 0;
int i;
struct dpram_blk *pdpram_blk;
struct dpram_blk *ptr;
+ struct list_head *pos, *q;
+ struct ft1000_debug_dirs *dir;

DEBUG("ft1000_chdev:ft1000_DestroyDevice called\n");

@@ -271,9 +291,17 @@ void ft1000_DestroyDevice(struct net_device *dev)
if (info->DeviceCreated)
{
ft1000_flarion_cnt--;
- unregister_chrdev(info->DeviceMajor, info->DeviceName);
- DEBUG("ft1000_DestroyDevice: unregistered device \"%s\", result = %d\n",
- info->DeviceName, result);
+ list_for_each_safe(pos, q, &info->nodes.list) {
+ dir = list_entry(pos, struct ft1000_debug_dirs, list);
+ if (dir->int_number == info->CardNumber) {
+ debugfs_remove(dir->file);
+ debugfs_remove(dir->dent);
+ list_del(pos);
+ kfree(dir);
+ }
+ }
+ DEBUG("ft1000_DestroyDevice: unregistered device \"%s\"\n",
+ info->DeviceName);

// Make sure we free any memory reserve for slow Queue
for (i=0; i<MAX_NUM_APP; i++) {
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 1ca01e2..22536da 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -851,6 +851,7 @@ u16 init_ft1000_netdev(struct ft1000_device *ft1000dev)

INIT_LIST_HEAD(&pInfo->prov_list);

+ INIT_LIST_HEAD(&pInfo->nodes.list);
//mbelian
#ifdef HAVE_NET_DEVICE_OPS
netdev->netdev_ops = &ftnet_ops;
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index a07db26..5bead63 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -473,6 +473,13 @@ struct ft1000_device
// struct net_device_stats stats; //mbelian
} __attribute__ ((packed));

+struct ft1000_debug_dirs {
+ struct list_head list;
+ struct dentry *dent;
+ struct dentry *file;
+ int int_number;
+};
+
struct ft1000_info {
struct ft1000_device *pFt1000Dev;
struct net_device_stats stats;
@@ -508,6 +515,7 @@ struct ft1000_info {
u8 CardNumber;
u8 DeviceName[15];
int DeviceMajor;
+ struct ft1000_debug_dirs nodes;
int registered;
int mediastate;
int dhcpflg;
--
1.7.1

2010-12-09 10:25:51

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 4/8] staging: ft1000: Remove unused variable.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 1 -
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 1 -
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 1 -
3 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 0871e43..4e5c8a3 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -170,7 +170,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)

// register the device
DEBUG("ft1000_CreateDevice: \"%s\" device registration\n", info->DeviceName);
- info->DeviceMajor = 0;

tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL);
if (tmp == NULL) {
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 22536da..69f920f 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -835,7 +835,6 @@ u16 init_ft1000_netdev(struct ft1000_device *ft1000dev)
pInfo->mediastate = 0;
pInfo->fifo_cnt = 0;
pInfo->DeviceCreated = FALSE;
- pInfo->DeviceMajor = 0;
pInfo->CurrentInterruptEnableMask = ISR_DEFAULT_MASK;
pInfo->InterruptsEnabled = FALSE;
pInfo->CardReady = 0;
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index 5bead63..2c89d14 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -514,7 +514,6 @@ struct ft1000_info {
int NetDevRegDone;
u8 CardNumber;
u8 DeviceName[15];
- int DeviceMajor;
struct ft1000_debug_dirs nodes;
int registered;
int mediastate;
--
1.7.1

2010-12-09 10:26:00

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 3/8] staging: ft1000: Remove unused pdevobj array.

We don't need to store pointer to device in some local
array because we always pass to debugfs correct device pointer.
So remove it.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 23 ----------------------
1 files changed, 0 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 8b735e4..0871e43 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -51,10 +51,6 @@ static long ft1000_ChIoctl(struct file *File, unsigned int Command,
unsigned long Argument);
static int ft1000_ChRelease (struct inode *Inode, struct file *File);

-// Global pointer to device object
-static struct ft1000_device *pdevobj[MAX_NUM_CARDS + 2];
-//static devfs_handle_t ft1000Handle[MAX_NUM_CARDS];
-
// List to free receive command buffer pool
struct list_head freercvpool;

@@ -165,11 +161,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
DEBUG("DeviceCreated = %x\n", info->DeviceCreated);

- //save the device info to global array
- pdevobj[info->CardNumber] = dev;
-
- DEBUG("ft1000_CreateDevice: ******SAVED pdevobj[%d]=%p\n", info->CardNumber, pdevobj[info->CardNumber]); //aelias [+] reason:up
-
if (info->DeviceCreated)
{
DEBUG("ft1000_CreateDevice: \"%s\" already registered\n", info->DeviceName);
@@ -327,8 +318,6 @@ void ft1000_DestroyDevice(struct net_device *dev)
// devfs_unregister(ft1000Handle[info->CardNumber]);

info->DeviceCreated = FALSE;
-
- pdevobj[info->CardNumber] = NULL;
}


@@ -356,18 +345,6 @@ static int ft1000_ChOpen (struct inode *Inode, struct file *File)

info = File->private_data = netdev_priv(dev->net);

- for (i=0; i<5; i++)
- DEBUG("pdevobj[%d]=%p\n", i, pdevobj[i]); //aelias [+] reason: down
-
- if ( pdevobj[num] != NULL )
- //info = (struct ft1000_info *)(pdevobj[num]->net->priv);
- info = netdev_priv(pdevobj[num]->net);
- else
- {
- DEBUG("ft1000_ChOpen: can not find device object %d\n", num);
- return -1;
- }
-
DEBUG("f_owner = %p number of application = %d\n", (&File->f_owner), info->appcnt );

// Check if maximum number of application exceeded
--
1.7.1

2010-12-09 10:43:50

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/8] staging: ft1000: Convert char device to debugfs.

> + file = debugfs_create_file("device", S_IRUGO | S_IWUGO, dir,
^^^^^^^
> + NULL, &ft1000fops);

Don't make this world writeable.

regards,
dan carpenter

2010-12-10 17:36:23

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH 1/8] staging: ft1000: Convert char device to debugfs.

On Thu, Dec 09, 2010 at 01:43:36PM +0300, Dan Carpenter wrote:
> > + file = debugfs_create_file("device", S_IRUGO | S_IWUGO, dir,
> ^^^^^^^
> > + NULL, &ft1000fops);
>
> Don't make this world writeable.

we should probably make checkpatch catch this.




Exporting world writable sysfs/debugfs files is usually a bad thing.
Warn about it.

Signed-off-by: Dave Jones <[email protected]>

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3c7fc0..5075005 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2892,6 +2892,11 @@ sub process {
ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
}
}
+
+ if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
+ $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
+ WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
+ }
}

# If we have no input at all, then there is nothing to report on

2010-12-10 18:10:35

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 1/8] staging: ft1000: Convert char device to debugfs.

On Fri, Dec 10, 2010 at 12:35:33PM -0500, Dave Jones wrote:
> On Thu, Dec 09, 2010 at 01:43:36PM +0300, Dan Carpenter wrote:
> > > + file = debugfs_create_file("device", S_IRUGO | S_IWUGO, dir,
> > ^^^^^^^
> > > + NULL, &ft1000fops);
> >
> > Don't make this world writeable.
>
> we should probably make checkpatch catch this.
>
>
>
>
> Exporting world writable sysfs/debugfs files is usually a bad thing.
> Warn about it.
>
> Signed-off-by: Dave Jones <[email protected]>

Acked-by: Greg Kroah-Hartman <[email protected]>