Re: [PATCH 4/6] staging/ft1000-usb: fix problems found by sparse

From: Belisko Marek
Date: Mon Oct 04 2010 - 09:16:23 EST


I couldn't apply this patch with git. After manual patching it produce
compilation errors.
Did you test it?

On Thu, Sep 30, 2010 at 10:24 AM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> In the original code, address space annotations are missing,
> which hides a possible unchecked user pointer access.
>
> Two functions use a lot of stack space.
>
> Extern declarations are all in the wrong place, which leads
> to type differences between caller and callee in some cases.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> Âdrivers/staging/ft1000/ft1000-usb/ft1000_chdev.c  |  36 ++++-----
> Â.../staging/ft1000/ft1000-usb/ft1000_download.c  Â|  41 ++++-----
> Âdrivers/staging/ft1000/ft1000-usb/ft1000_hw.c   Â|  89 ++++++++------------
> Âdrivers/staging/ft1000/ft1000-usb/ft1000_proc.c  Â|  Â2 +-
> Âdrivers/staging/ft1000/ft1000-usb/ft1000_usb.c   |  21 +----
> Âdrivers/staging/ft1000/ft1000-usb/ft1000_usb.h   |  41 +++++++++-
> Â6 files changed, 110 insertions(+), 120 deletions(-)
>
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> index 282deeb..46e72e4 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> @@ -41,13 +41,9 @@
> Â#include "ft1000_usb.h"
> Â//#include "ft1000_ioctl.h"
>
> -void ft1000_DestroyDevice(struct net_device *dev);
> -u16 ft1000_read_dpram16(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, u8 highlow);
> -u16 ft1000_read_register(struct ft1000_device *ft1000dev, short* Data, u16 nRegIndx);
> +static int ft1000_flarion_cnt = 0;
>
> -extern inline u16 ft1000_asic_read (struct net_device *dev, u16 offset);
> -extern inline void ft1000_asic_write (struct net_device *dev, u16 offset, u16 value);
> -extern void CardSendCommand(struct ft1000_device *ft1000dev, unsigned short *ptempbuffer, int size);
> +//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);
> @@ -55,12 +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);
>
> -static int ft1000_flarion_cnt = 0;
> -
> -//need to looking usage of ft1000Handle
> -
> -
> -
> Â// Global pointer to device object
> Âstatic struct ft1000_device *pdevobj[MAX_NUM_CARDS + 2];
> Â//static devfs_handle_t ft1000Handle[MAX_NUM_CARDS];
> @@ -326,7 +316,7 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
> Â Â Â Â info->app_info[i].nRxMsg = 0;
> Â Â Â Â info->app_info[i].nTxMsgReject = 0;
> Â Â Â Â info->app_info[i].nRxMsgMiss = 0;
> - Â Â Â Âinfo->app_info[i].fileobject = 0;
> + Â Â Â Âinfo->app_info[i].fileobject = NULL;
> Â Â Â Â info->app_info[i].app_id = i+1;
> Â Â Â Â info->app_info[i].DspBCMsgFlag = 0;
> Â Â Â Â info->app_info[i].NumOfMsg = 0;
> @@ -539,6 +529,7 @@ static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait)
> Âstatic long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned long Argument)
> Â{
> + Â Âvoid __user *argp = (void __user *)Argument;
> Â Â struct net_device *dev;
> Â Â PFT1000_INFO info;
> Â Â struct ft1000_device *ft1000dev;
> @@ -579,7 +570,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â switch (cmd) {
> Â Â case IOCTL_REGISTER_CMD:
> Â Â Â Â Â Â DEBUG("FT1000:ft1000_ChIoctl: IOCTL_FT1000_REGISTER called\n");
> - Â Â Â Â Â Âresult = get_user(tempword, (unsigned short *)Argument);
> + Â Â Â Â Â Âresult = get_user(tempword, (__u16 __user*)argp);
> Â Â Â Â Â Â if (result) {
> Â Â Â Â Â Â Â Â DEBUG("result = %d failed to get_user\n", result);
> Â Â Â Â Â Â Â Â break;
> @@ -601,7 +592,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
>
> Â Â Â Â get_ver_data.drv_ver = FT1000_DRV_VER;
>
> - Â Â Â Âif (copy_to_user((PIOCTL_GET_VER)Argument, &get_ver_data, sizeof(get_ver_data)) ) {
> + Â Â Â Âif (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data)) ) {
> Â Â Â Â Â Â DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
> Â Â Â Â Â Â result = -EFAULT;
> Â Â Â Â Â Â break;
> @@ -651,7 +642,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â 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((PIOCTL_GET_DSP_STAT)Argument, &get_stat_data, sizeof(get_stat_data)) ) {
> + Â Â Â Âif (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data)) ) {
> Â Â Â Â Â Â DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
> Â Â Â Â Â Â result = -EFAULT;
> Â Â Â Â Â Â break;
> @@ -692,7 +683,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â Â Â Â Â//DEBUG("FT1000:ft1000_ChIoctl: try to SET_DPRAM \n");
>
> Â Â Â Â Â Â Â Â // Get the length field to see how many bytes to copy
> - Â Â Â Â Â Â Â Âresult = get_user(msgsz, (unsigned short *)Argument);
> + Â Â Â Â Â Â Â Âresult = get_user(msgsz, (__u16 __user *)argp);
> Â Â Â Â Â Â Â Â msgsz = ntohs (msgsz);
> Â Â Â Â Â Â Â Â //DEBUG("FT1000:ft1000_ChIoctl: length of message = %d\n", msgsz);
>
> @@ -708,7 +699,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
>
> Â Â Â Â Â Â Â Â //if ( copy_from_user(&(dpram_command.dpram_blk), (PIOCTL_DPRAM_BLK)Argument, msgsz+2) ) {
> - Â Â Â Â Â Â Â Âif ( copy_from_user(&dpram_data, (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;
> Â Â Â Â Â Â Â Â }
> @@ -852,7 +843,7 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â Â Â }
>
> Â Â Â Â Â Â result = 0;
> - Â Â Â Â Â Âpioctl_dpram = (PIOCTL_DPRAM_BLK)Argument;
> + Â Â Â Â Â Âpioctl_dpram = argp;
> Â Â Â Â Â Â if (list_empty(&info->app_info[i].app_sqlist) == 0) {
> Â Â Â Â Â Â Â Â //DEBUG("FT1000:ft1000_ChIoctl:Message detected in slow queue\n");
> Â Â Â Â Â Â Â Â spin_lock_irqsave(&free_buff_lock, flags);
> @@ -862,7 +853,10 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
> Â Â Â Â Â Â Â Â //DEBUG("FT1000:ft1000_ChIoctl: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;
> - Â Â Â Â Â Â Â Âpioctl_dpram->total_len = htons(msglen); /* XXX exploit here */
> + Â Â Â Â Â Â Â Âresult = get_user(msglen, &pioctl_dpram->total_len);
> + Â Â Â Â Â Â Â if (result)
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â msglen = htons(msglen);
> Â Â Â Â Â Â Â Â //DEBUG("FT1000:ft1000_ChIoctl:msg length = %x\n", msglen);
> Â Â Â Â Â Â Â Â if(copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen))
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â{
> @@ -935,7 +929,7 @@ static int ft1000_ChRelease (struct inode *Inode, struct file *File)
> Â Â // initialize application information
> Â Â info->appcnt--;
> Â Â DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, info->appcnt);
> - Â Âinfo->app_info[i].fileobject = 0;
> + Â Âinfo->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 c71a1f4..ba07d5d 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c
> @@ -133,15 +133,6 @@ typedef struct _DSP_IMAGE_INFO_V6 {
> Â} DSP_IMAGE_INFO_V6, *PDSP_IMAGE_INFO_V6;
>
>
> -u16 ft1000_read_register(struct ft1000_device *ft1000dev, short* Data, u16 nRegIndx);
> -u16 ft1000_write_register(struct ft1000_device *ft1000dev, USHORT value, u16 nRegIndx);
> -u16 ft1000_read_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, USHORT cnt);
> -u16 ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, USHORT cnt);
> -u16 ft1000_read_dpram16(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, u8 highlow);
> -u16 ft1000_write_dpram16(struct ft1000_device *ft1000dev, USHORT indx, USHORT value, u8 highlow);
> -u16 fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer);
> -u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer);
> -
> Â//---------------------------------------------------------------------------
> Â// Function: Â Âgetfw
> Â//
> @@ -154,7 +145,7 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHA
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -char *getfw (char *fn, int *pimgsz)
> +char *getfw (char *fn, size_t *pimgsz)
> Â{
> Â Â struct file *fd;
> Â Â mm_segment_t fs = get_fs();
> @@ -190,7 +181,7 @@ char *getfw (char *fn, int *pimgsz)
> Â Â Â Â return NULL;
> Â Â }
> Â Â pos = 0;
> - Â Âif (vfs_read(fd, pfwimg, fwimgsz, &pos) != fwimgsz) {
> + Â Âif (vfs_read(fd, (void __user __force*)pfwimg, fwimgsz, &pos) != fwimgsz) {
> Â Â Â Âvfree(pfwimg);
> Â Â Â ÂDEBUG("FT1000:%s:failed to read firmware image\n",__FUNCTION__);
> Â Â Â Âfilp_close(fd, current->files);
> @@ -216,7 +207,7 @@ char *getfw (char *fn, int *pimgsz)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -ULONG check_usb_db (struct ft1000_device *ft1000dev)
> +static ULONG check_usb_db (struct ft1000_device *ft1000dev)
> Â{
>  Âint        loopcnt;
> Â ÂUSHORT Â Â Â Â Â Âtemp;
> @@ -295,7 +286,7 @@ ULONG check_usb_db (struct ft1000_device *ft1000dev)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -USHORT get_handshake(struct ft1000_device *ft1000dev, USHORT expected_value)
> +static USHORT get_handshake(struct ft1000_device *ft1000dev, USHORT expected_value)
> Â{
> Â ÂUSHORT Â Â Â Â Â Âhandshake;
>  Âint        loopcnt;
> @@ -406,7 +397,7 @@ USHORT get_handshake(struct ft1000_device *ft1000dev, USHORT expected_value)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -void put_handshake(struct ft1000_device *ft1000dev,USHORT handshake_value)
> +static void put_handshake(struct ft1000_device *ft1000dev,USHORT handshake_value)
> Â{
> Â Â ULONG tempx;
> Â Â USHORT tempword;
> @@ -442,7 +433,7 @@ void put_handshake(struct ft1000_device *ft1000dev,USHORT handshake_value)
>
> Â}
>
> -USHORT get_handshake_usb(struct ft1000_device *ft1000dev, USHORT expected_value)
> +static USHORT get_handshake_usb(struct ft1000_device *ft1000dev, USHORT expected_value)
> Â{
> Â ÂUSHORT Â Â Â Â Â Âhandshake;
>  Âint        loopcnt;
> @@ -482,7 +473,7 @@ USHORT get_handshake_usb(struct ft1000_device *ft1000dev, USHORT expected_value)
> Â Âreturn HANDSHAKE_TIMEOUT_VALUE;
> Â}
>
> -void put_handshake_usb(struct ft1000_device *ft1000dev,USHORT handshake_value)
> +static void put_handshake_usb(struct ft1000_device *ft1000dev,USHORT handshake_value)
> Â{
> Â Âint i;
>
> @@ -501,7 +492,7 @@ void put_handshake_usb(struct ft1000_device *ft1000dev,USHORT handshake_value)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -USHORT get_request_type(struct ft1000_device *ft1000dev)
> +static USHORT get_request_type(struct ft1000_device *ft1000dev)
> Â{
> Â ÂUSHORT Â request_type;
> Â ÂULONG Â Âstatus;
> @@ -533,7 +524,7 @@ USHORT get_request_type(struct ft1000_device *ft1000dev)
>
> Â}
>
> -USHORT get_request_type_usb(struct ft1000_device *ft1000dev)
> +static USHORT get_request_type_usb(struct ft1000_device *ft1000dev)
> Â{
> Â ÂUSHORT Â request_type;
> Â ÂULONG Â Âstatus;
> @@ -577,7 +568,7 @@ USHORT get_request_type_usb(struct ft1000_device *ft1000dev)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -long get_request_value(struct ft1000_device *ft1000dev)
> +static long get_request_value(struct ft1000_device *ft1000dev)
> Â{
> Â ÂULONG Â Â value;
> Â ÂUSHORT Â tempword;
> @@ -605,7 +596,8 @@ long get_request_value(struct ft1000_device *ft1000dev)
>
> Â}
>
> -long get_request_value_usb(struct ft1000_device *ft1000dev)
> +#if 0
> +static long get_request_value_usb(struct ft1000_device *ft1000dev)
> Â{
> Â ÂULONG Â Â value;
> Â ÂUSHORT Â tempword;
> @@ -633,6 +625,7 @@ long get_request_value_usb(struct ft1000_device *ft1000dev)
> Â Âreturn value;
>
> Â}
> +#endif
>
> Â//---------------------------------------------------------------------------
> Â// Function: Â Âput_request_value
> @@ -647,7 +640,7 @@ long get_request_value_usb(struct ft1000_device *ft1000dev)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -void put_request_value(struct ft1000_device *ft1000dev, long lvalue)
> +static void put_request_value(struct ft1000_device *ft1000dev, long lvalue)
> Â{
> Â ÂULONG Â Âtempx;
> Â ÂULONG Â Âstatus;
> @@ -675,7 +668,7 @@ void put_request_value(struct ft1000_device *ft1000dev, long lvalue)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -USHORT hdr_checksum(PPSEUDO_HDR pHdr)
> +static USHORT hdr_checksum(PPSEUDO_HDR pHdr)
> Â{
> Â ÂUSHORT Â *usPtr = (USHORT *)pHdr;
> Â ÂUSHORT Â chksum;
> @@ -705,7 +698,7 @@ USHORT hdr_checksum(PPSEUDO_HDR pHdr)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -ULONG write_blk (struct ft1000_device *ft1000dev, USHORT **pUsFile, UCHAR **pUcFile, long word_length)
> +static ULONG write_blk (struct ft1000_device *ft1000dev, USHORT **pUsFile, UCHAR **pUcFile, long word_length)
> Â{
> Â ÂULONG Status = STATUS_SUCCESS;
> Â ÂUSHORT dpram;
> @@ -861,7 +854,7 @@ static void usb_dnld_complete (struct urb *urb)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -ULONG write_blk_fifo (struct ft1000_device *ft1000dev, USHORT **pUsFile, UCHAR **pUcFile, long word_length)
> +static ULONG write_blk_fifo (struct ft1000_device *ft1000dev, USHORT **pUsFile, UCHAR **pUcFile, long word_length)
> Â{
> Â ÂULONG Status = STATUS_SUCCESS;
> Â Âint byte_length;
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
> index 4c3b1db..44395c0 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
> @@ -35,24 +35,12 @@
>
> Â//#define JDEBUG
>
> -
> -extern void *pFileStart;
> -extern ULONG FileLength;
> -
> -
> -extern int numofmsgbuf;
> -
> -
> -int ft1000_poll_thread(void *arg);
> -
> +static int ft1000_reset(struct net_device *ft1000dev);
> +static int ft1000_submit_rx_urb(PFT1000_INFO info);
> Âstatic void ft1000_hbchk(u_long data);
> -int ft1000_reset(struct net_device *ft1000dev);
> Âstatic int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev);
> Âstatic int ft1000_open (struct net_device *dev);
> -int ft1000_close (struct net_device *dev);
> Âstatic struct net_device_stats *ft1000_netdev_stats(struct net_device *dev);
> -u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, ULONG ÂFileLength);
> -int ft1000_submit_rx_urb(PFT1000_INFO info);
> Âstatic struct timer_list poll_timer[MAX_NUM_CARDS];
> Âstatic int ft1000_chkcard (struct ft1000_device *dev);
> Â/*
> @@ -67,21 +55,11 @@ static const struct net_device_ops ft1000net_ops = {
> Â//Jim
>
> Âstatic u8 tempbuffer[1600];
> -int gCardIndex;
> +static int gCardIndex;
>
> Â#define MAX_RCV_LOOP Â 100
>
>
> -extern struct list_head freercvpool;
> -extern spinlock_t free_buff_lock; Â // lock to arbitrate free buffer list for receive command data
> -
> -//end of Jim
> -
> -extern int ft1000_CreateDevice(struct ft1000_device *dev);
> -extern PDPRAM_BLK ft1000_get_buffer (struct list_head *bufflist);
> -extern void ft1000_free_buffer (PDPRAM_BLK pdpram_blk, struct list_head *plist);
> -
> -
> Âstatic int atoi(const char *s)
> Â{
> Â Â Â Â int k = 0;
> @@ -207,7 +185,7 @@ static int ft1000_control(struct ft1000_device *ft1000dev,unsigned int pipe,
> Â//
> Â//---------------------------------------------------------------------------
>
> -u16 ft1000_read_register(struct ft1000_device *ft1000dev, short* Data, u16 nRegIndx)
> +u16 ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, u16 nRegIndx)
> Â{
> Â Â u16 ret = STATUS_SUCCESS;
>
> @@ -472,20 +450,20 @@ u16 ft1000_write_dpram16(struct ft1000_device *ft1000dev, USHORT indx, USHORT va
> Â//---------------------------------------------------------------------------
> Âu16 fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer)
> Â{
> - Â ÂUCHAR tempbuffer[16];
> + Â ÂUCHAR buf[16];
> Â Â USHORT pos;
> Â Â u16 ret = STATUS_SUCCESS;
>
> Â Â //DEBUG("fix_ft1000_read_dpram32: indx: %d Â\n", indx);
> Â Â pos = (indx / 4)*4;
> - Â Âret = ft1000_read_dpram32(ft1000dev, pos, (PUCHAR)&tempbuffer[0], 16);
> + Â Âret = ft1000_read_dpram32(ft1000dev, pos, buf, 16);
> Â Â if (ret == STATUS_SUCCESS)
> Â Â {
> Â Â Â Â pos = (indx % 4)*4;
> - Â Â Â Â*buffer++ = tempbuffer[pos++];
> - Â Â Â Â*buffer++ = tempbuffer[pos++];
> - Â Â Â Â*buffer++ = tempbuffer[pos++];
> - Â Â Â Â*buffer++ = tempbuffer[pos++];
> + Â Â Â Â*buffer++ = buf[pos++];
> + Â Â Â Â*buffer++ = buf[pos++];
> + Â Â Â Â*buffer++ = buf[pos++];
> + Â Â Â Â*buffer++ = buf[pos++];
> Â Â }
> Â Â else
> Â Â {
> @@ -524,7 +502,7 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHA
> Â Â USHORT pos1;
> Â Â USHORT pos2;
> Â Â USHORT i;
> - Â ÂUCHAR tempbuffer[32];
> + Â ÂUCHAR buf[32];
> Â Â UCHAR resultbuffer[32];
> Â Â PUCHAR pdata;
> Â Â u16 ret Â= STATUS_SUCCESS;
> @@ -533,15 +511,15 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHA
>
> Â Â pos1 = (indx / 4)*4;
> Â Â pdata = buffer;
> - Â Âret = ft1000_read_dpram32(ft1000dev, pos1, (PUCHAR)&tempbuffer[0], 16);
> + Â Âret = ft1000_read_dpram32(ft1000dev, pos1, buf, 16);
> Â Â if (ret == STATUS_SUCCESS)
> Â Â {
> Â Â Â Â pos2 = (indx % 4)*4;
> - Â Â Â Âtempbuffer[pos2++] = *buffer++;
> - Â Â Â Âtempbuffer[pos2++] = *buffer++;
> - Â Â Â Âtempbuffer[pos2++] = *buffer++;
> - Â Â Â Âtempbuffer[pos2++] = *buffer++;
> - Â Â Â Âret = ft1000_write_dpram32(ft1000dev, pos1, (PUCHAR)&tempbuffer[0], 16);
> + Â Â Â Âbuf[pos2++] = *buffer++;
> + Â Â Â Âbuf[pos2++] = *buffer++;
> + Â Â Â Âbuf[pos2++] = *buffer++;
> + Â Â Â Âbuf[pos2++] = *buffer++;
> + Â Â Â Âret = ft1000_write_dpram32(ft1000dev, pos1, buf, 16);
> Â Â }
> Â Â else
> Â Â {
> @@ -556,7 +534,7 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHA
> Â Â Â Â buffer = pdata;
> Â Â Â Â for (i=0; i<16; i++)
> Â Â Â Â {
> - Â Â Â Â Â Âif (tempbuffer[i] != resultbuffer[i]){
> + Â Â Â Â Â Âif (buf[i] != resultbuffer[i]){
>
> Â Â Â Â Â Â Â Â ret = STATUS_FAILURE;
> Â Â Â Â Â Â }
> @@ -596,7 +574,7 @@ u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHA
> Â//
> Â// ÂReturns: Â ÂNone
> Â//-----------------------------------------------------------------------
> -void card_reset_dsp (struct ft1000_device *ft1000dev, BOOLEAN value)
> +static void card_reset_dsp (struct ft1000_device *ft1000dev, BOOLEAN value)
> Â{
> Â Â u16 status = STATUS_SUCCESS;
> Â Â USHORT tempword;
> @@ -645,7 +623,7 @@ void card_reset_dsp (struct ft1000_device *ft1000dev, BOOLEAN value)
> Â// Notes:
> Â//
> Â//---------------------------------------------------------------------------
> -void CardSendCommand(struct ft1000_device *ft1000dev, unsigned char *ptempbuffer, int size)
> +void CardSendCommand(struct ft1000_device *ft1000dev, void *ptempbuffer, int size)
> Â{
> Â Â unsigned short temp;
> Â Â unsigned char *commandbuf;
> @@ -1202,7 +1180,7 @@ u16 reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *int
> Â Âreturn STATUS_SUCCESS;
> Â}
>
> -int ft1000_reset(struct net_device *dev)
> +static int ft1000_reset(struct net_device *dev)
> Â{
> Â Â ft1000_reset_card(dev);
> Â Â return 0;
> @@ -1432,7 +1410,7 @@ static inline u16 ft1000_read_fifo_len (struct net_device *dev)
> Â// Â Â Â Â Â Â ÂSUCCESS
> Â//
> Â//---------------------------------------------------------------------------
> -int ft1000_copy_down_pkt (struct net_device *netdev, u8 *packet, u16 len)
> +static int ft1000_copy_down_pkt (struct net_device *netdev, u8 *packet, u16 len)
> Â{
> Â Â FT1000_INFO *pInfo = netdev_priv(netdev);
> Â Â struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
> @@ -1658,7 +1636,7 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
> Â// Â Â Â Â Â Â ÂSUCCESS
> Â//
> Â//---------------------------------------------------------------------------
> -int ft1000_copy_up_pkt (struct urb *urb)
> +static int ft1000_copy_up_pkt (struct urb *urb)
> Â{
> Â Â PFT1000_INFO info = urb->context;
> Â Â struct ft1000_device *ft1000dev = info->pFt1000Dev;
> @@ -1774,7 +1752,7 @@ int ft1000_copy_up_pkt (struct urb *urb)
> Â// Â Â Â Â Â Â ÂSUCCESS
> Â//
> Â//---------------------------------------------------------------------------
> -int ft1000_submit_rx_urb(PFT1000_INFO info)
> +static int ft1000_submit_rx_urb(PFT1000_INFO info)
> Â{
> Â Â int result;
> Â Â struct ft1000_device *pFt1000Dev = info->pFt1000Dev;
> @@ -2102,7 +2080,7 @@ static void ft1000_hbchk(u_long data)
> Â// Â Â Â Â Â= 1 (successful)
> Â//
> Â//---------------------------------------------------------------------------
> -BOOLEAN ft1000_receive_cmd (struct ft1000_device *dev, u16 *pbuffer, int maxsz, u16 *pnxtph) {
> +static BOOLEAN ft1000_receive_cmd (struct ft1000_device *dev, u16 *pbuffer, int maxsz, u16 *pnxtph) {
> Â Â u16 size, ret;
> Â Â u16 *ppseudohdr;
> Â Â int i;
> @@ -2175,7 +2153,7 @@ BOOLEAN ft1000_receive_cmd (struct ft1000_device *dev, u16 *pbuffer, int maxsz,
> Â}
>
>
> -int ft1000_dsp_prov(void *arg)
> +static int ft1000_dsp_prov(void *arg)
> Â{
> Â Â struct ft1000_device *dev = (struct ft1000_device *)arg;
> Â Â Â ÂFT1000_INFO *info = (FT1000_INFO *) netdev_priv (dev->net);
> @@ -2263,7 +2241,7 @@ int ft1000_dsp_prov(void *arg)
> Â}
>
>
> -int ft1000_proc_drvmsg (struct ft1000_device *dev, u16 size) {
> +static int ft1000_proc_drvmsg (struct ft1000_device *dev, u16 size) {
> Â Â Â ÂFT1000_INFO *info = (FT1000_INFO *) netdev_priv (dev->net);
> Â Â u16 msgtype;
> Â Â u16 tempword;
> @@ -2281,9 +2259,11 @@ int ft1000_proc_drvmsg (struct ft1000_device *dev, u16 size) {
> Â Â } convert;
>
>
> - Â Âchar cmdbuffer[1600];
> + Â Âchar *cmdbuffer = kmalloc(1600, GFP_KERNEL);
> + Â Âif (!cmdbuffer)
> + Â Â Â return STATUS_FAILURE;
>
> - Â Âstatus = ft1000_read_dpram32(dev, 0x200, (PUCHAR)&cmdbuffer[0], size);
> + Â Âstatus = ft1000_read_dpram32(dev, 0x200, cmdbuffer, size);
>
>
> Â Â //if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword))
> @@ -2388,7 +2368,7 @@ int ft1000_proc_drvmsg (struct ft1000_device *dev, u16 size) {
> Â Â Â Â Â Â Â Â Â Âinfo->fProvComplete = 0;
> Â Â Â Â Â Â Â Â Â Âstatus = ft1000_dsp_prov(dev);
> Â Â Â Â Â Â Â Â Â Âif (status != STATUS_SUCCESS)
> - Â Â Â Â Â Â Â Â Â Â Â return status;
> + Â Â Â Â Â Â Â Â Â Â Â goto out;
> Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â else {
> Â Â Â Â Â Â Â Â Â Â info->fProvComplete = 1;
> @@ -2537,8 +2517,11 @@ int ft1000_proc_drvmsg (struct ft1000_device *dev, u16 size) {
>
> Â Â }
>
> + Â Âstatus = STATUS_SUCCESS;
> +out:
> + Â Âkfree(cmdbuffer);
> Â Â DEBUG("return from ft1000_proc_drvmsg\n");
> - Â Âreturn STATUS_SUCCESS;
> + Â Âreturn status;
> Â}
>
>
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
> index 80faba5..d1ef396 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
> @@ -42,7 +42,7 @@ u16 ft1000_read_dpram16 (struct ft1000_device *ft1000dev, USHORT indx,
> Â Â Â Â Â Â Â Â Â Â Â Â PUCHAR buffer, u8 highlow);
>
>
> -int
> +static int
> Âft1000ReadProc (char *page, char **start, off_t off, int count, int *eof,
> Â Â Â Â Â Â Â Âvoid *data)
> Â{
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> index f708c09..4aef1c4 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> @@ -33,7 +33,7 @@ MODULE_SUPPORTED_DEVICE("QFT FT1000 Express Cards");
>
>
> Âvoid *pFileStart;
> -ULONG FileLength;
> +size_t FileLength;
>
> Â#define VENDOR_ID 0x1291 Â /* Qualcomm vendor id */
> Â#define PRODUCT_ID 0x11 Â Â/* fake product id */
> @@ -46,24 +46,7 @@ static struct usb_device_id id_table[] = {
>
> ÂMODULE_DEVICE_TABLE (usb, id_table);
>
> -extern Âstruct ft1000_device *pdevobj[MAX_NUM_CARDS+2];
> -
> -char *getfw (char *fn, int *pimgsz);
> -
> -int ft1000_close(struct net_device *net);
> -void dsp_reload (struct ft1000_device *ft1000dev);
> -u16 init_ft1000_netdev(struct ft1000_device *ft1000dev);
> -u16 reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
> -int ft1000_poll(void* dev_id);
> -void ft1000_DestroyDevice(struct net_device *dev);
> -u16 ft1000_read_dpram16(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, u8 highlow);
> -u16 ft1000_read_register(struct ft1000_device *ft1000dev, short* Data, u16 nRegIndx);
> -BOOLEAN gPollingfailed = FALSE;
> -
> -void ft1000InitProc(struct net_device *dev);
> -void ft1000CleanupProc(FT1000_INFO *info);
> -int ft1000_poll_thread(void *arg);
> -
> +static BOOLEAN gPollingfailed = FALSE;
> Âint ft1000_poll_thread(void *arg)
> Â{
> Â Â int ret = STATUS_SUCCESS;
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
> index a64d468..b0ab918 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
> @@ -102,7 +102,7 @@ typedef struct _PROV_RECORD {
>
> Â#define UCHAR Â Â Â Â Â Â Â u8
> Â#define USHORT Â Â Â Â Â Â Âu16
> -#define ULONG Â Â Â Â Â Â Â u32
> +#define ULONG Â Â Â Â Â Â Â u32 /* WTF ??? */
> Â#define BOOLEAN Â Â Â Â Â Â u8
> Â#define PULONG Â Â Â Â Â Â Âu32 *
> Â#define PUSHORT Â Â Â Â Â Â u16 *
> @@ -152,7 +152,6 @@ typedef struct _PROV_RECORD {
>
> Â#define CIS_NET_ADDR_OFFSET 0xff0
>
> -#define MEM_TAG 'FLRN'
> Â// MAGNEMITE specific
>
> Â#define FT1000_REG_MAG_UFDR Â Â Â Â Â Â0x0000 Â// Uplink FIFO Data Register.
> @@ -605,5 +604,43 @@ typedef struct _DPRAM_BLK {
> Â Â u16 *pbuffer;
> Â} __attribute__ ((packed)) DPRAM_BLK, *PDPRAM_BLK;
>
> +u16 ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, u16 nRegIndx);
> +u16 ft1000_write_register(struct ft1000_device *ft1000dev, USHORT value, u16 nRegIndx);
> +u16 ft1000_read_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, USHORT cnt);
> +u16 ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, USHORT cnt);
> +u16 ft1000_read_dpram16(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer, u8 highlow);
> +u16 ft1000_write_dpram16(struct ft1000_device *ft1000dev, USHORT indx, USHORT value, u8 highlow);
> +u16 fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer);
> +u16 fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, USHORT indx, PUCHAR buffer);
> +
> +extern void *pFileStart;
> +extern size_t FileLength;
> +extern int numofmsgbuf;
> +
> +int ft1000_close (struct net_device *dev);
> +u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, ULONG ÂFileLength);
> +
> +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);
> +extern void CardSendCommand(struct ft1000_device *ft1000dev, void *ptempbuffer, int size);
> +
> +PDPRAM_BLK ft1000_get_buffer (struct list_head *bufflist);
> +void ft1000_free_buffer (PDPRAM_BLK pdpram_blk, struct list_head *plist);
> +
> +char *getfw (char *fn, size_t *pimgsz);
> +
> +void dsp_reload(struct ft1000_device *ft1000dev);
> +u16 init_ft1000_netdev(struct ft1000_device *ft1000dev);
> +struct usb_interface;
> +u16 reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
> +int ft1000_poll(void* dev_id);
> +
> +void ft1000InitProc(struct net_device *dev);
> +void ft1000CleanupProc(FT1000_INFO *info);
> +
> +
>
> Â#endif
> --
> 1.7.1
>
>

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/