lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 6 Nov 2014 15:48:15 +1100
From:	Stephen Rothwell <sfr@...b.auug.org.au>
To:	Arnd Bergmann <arnd@...db.de>, Greg KH <greg@...ah.com>
Cc:	linux-next@...r.kernel.org, linux-kernel@...r.kernel.org,
	Tapasweni Pathak <tapaswenipathak@...il.com>,
	Joe Perches <joe@...ches.com>
Subject: linux-next: manual merge of the y2038 tree with the staging tree

Hi Arnd,

Today's linux-next merge of the y2038 tree got a conflict in
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c between commit
ecdd21c7b982 ("staging: ft1000: Whitespace neatening") from the staging
tree and commit 4115d2b27a50 ("staging: ft1000: Replace timeval and
time_t with time64_t") from the y2038 tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    sfr@...b.auug.org.au

diff --cc drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
index c8d278229940,287c8b3c18fc..000000000000
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
@@@ -391,339 -394,344 +391,429 @@@ static unsigned int ft1000_poll_dev(str
  }
  
  /*
 -*---------------------------------------------------------------------------
 -* Function:    ft1000_ioctl
 -*
 -* Parameters:
 -*
 -* Description:
 -*
 -* Notes:
 -*
 -*---------------------------------------------------------------------------
 -*/
 + *---------------------------------------------------------------------------
 + * Function:    ft1000_ioctl
 + *
 + * Parameters:
 + *
 + * Description:
 + *
 + * Notes:
 + *
 + *---------------------------------------------------------------------------
 + */
  static long ft1000_ioctl(struct file *file, unsigned int command,
 -                           unsigned long argument)
 +			 unsigned long argument)
  {
 -    void __user *argp = (void __user *)argument;
 +	void __user *argp = (void __user *)argument;
  	struct ft1000_info *info;
 -    struct ft1000_usb *ft1000dev;
 -    int result=0;
 -    int cmd;
 -    int i;
 -    u16 tempword;
 -    unsigned long flags;
 +	struct ft1000_usb *ft1000dev;
 +	int result = 0;
 +	int cmd;
 +	int i;
 +	u16 tempword;
 +	unsigned long flags;
- 	struct timeval tv;
+ 	time64_t time;
  	struct IOCTL_GET_VER get_ver_data;
  	struct IOCTL_GET_DSP_STAT get_stat_data;
 -    u8 ConnectionMsg[] = {0x00,0x44,0x10,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x93,0x64,
 -                          0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a,
 -                          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 -                          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 -                          0x00,0x00,0x02,0x37,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x01,0x7f,0x00,
 -                          0x00,0x01,0x00,0x00};
 +	u8 ConnectionMsg[] = {0x00, 0x44, 0x10, 0x20, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x93, 0x64,
 +			      0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a,
 +			      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 +			      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 +			      0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7f, 0x00,
 +			      0x00, 0x01, 0x00, 0x00};
 +
 +	unsigned short ledStat = 0;
 +	unsigned short conStat = 0;
 +
 +	if (ft1000_flarion_cnt == 0) {
 +		pr_debug("called with ft1000_flarion_cnt of zero\n");
 +		return -EBADF;
 +	}
  
 -    unsigned short ledStat=0;
 -    unsigned short conStat=0;
 +	/* pr_debug("command = 0x%x argument = 0x%8x\n", command, (u32)argument); */
  
 -    /* DEBUG("ft1000_ioctl called\n"); */
 +	info = file->private_data;
 +	ft1000dev = info->priv;
 +	cmd = _IOC_NR(command);
 +	/* pr_debug("cmd = 0x%x\n", cmd); */
 +
 +	/* process the command */
 +	switch (cmd) {
 +	case IOCTL_REGISTER_CMD:
 +		pr_debug("IOCTL_FT1000_REGISTER called\n");
 +		result = get_user(tempword, (__u16 __user *)argp);
 +		if (result) {
 +			pr_debug("result = %d failed to get_user\n", result);
 +			break;
 +		}
 +		if (tempword == DSPBCMSGID) {
 +			/* Search for matching file object */
 +			for (i = 0; i < MAX_NUM_APP; i++) {
 +				if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
 +					ft1000dev->app_info[i].DspBCMsgFlag = 1;
 +					pr_debug("Registered for broadcast messages\n");
 +					break;
 +				}
 +			}
 +		}
 +		break;
  
 -    if (ft1000_flarion_cnt == 0) {
 -        DEBUG("FT1000:ft1000_ioctl called when ft1000_flarion_cnt is zero\n");
 -        return (-EBADF);
 -    }
 +	case IOCTL_GET_VER_CMD:
 +		pr_debug("IOCTL_FT1000_GET_VER called\n");
  
 -    /* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */
 +		get_ver_data.drv_ver = FT1000_DRV_VER;
  
++<<<<<<< HEAD
 +		if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) {
 +			pr_debug("copy fault occurred\n");
 +			result = -EFAULT;
 +			break;
 +		}
 +
 +		pr_debug("driver version = 0x%x\n",
 +			 (unsigned int)get_ver_data.drv_ver);
 +
 +		break;
 +	case IOCTL_CONNECT:
 +		/* Connect Message */
 +		pr_debug("IOCTL_FT1000_CONNECT\n");
 +		ConnectionMsg[79] = 0xfc;
 +		result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
 +
 +		break;
 +	case IOCTL_DISCONNECT:
 +		/* Disconnect Message */
 +		pr_debug("IOCTL_FT1000_DISCONNECT\n");
 +		ConnectionMsg[79] = 0xfd;
 +		result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
 +		break;
 +	case IOCTL_GET_DSP_STAT_CMD:
 +		/* pr_debug("IOCTL_FT1000_GET_DSP_STAT\n"); */
 +		memset(&get_stat_data, 0, sizeof(get_stat_data));
 +		memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ);
 +		memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ);
 +		memcpy(get_stat_data.Sku, info->Sku, SKUSZ);
 +		memcpy(get_stat_data.eui64, info->eui64, EUISZ);
 +
 +		if (info->ProgConStat != 0xFF) {
 +			ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
 +			get_stat_data.LedStat = ntohs(ledStat);
 +			pr_debug("LedStat = 0x%x\n", get_stat_data.LedStat);
 +			ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX);
 +			get_stat_data.ConStat = ntohs(conStat);
 +			pr_debug("ConStat = 0x%x\n", get_stat_data.ConStat);
 +		} else {
 +			get_stat_data.ConStat = 0x0f;
 +		}
 +
 +
 +		get_stat_data.nTxPkts = info->stats.tx_packets;
 +		get_stat_data.nRxPkts = info->stats.rx_packets;
 +		get_stat_data.nTxBytes = info->stats.tx_bytes;
 +		get_stat_data.nRxBytes = info->stats.rx_bytes;
- 		do_gettimeofday(&tv);
- 		get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm);
++		time = get_seconds();
++		get_stat_data.ConTm = time - info->ConTm;
 +		pr_debug("Connection Time = %d\n", (int)get_stat_data.ConTm);
 +		if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) {
 +			pr_debug("copy fault occurred\n");
 +			result = -EFAULT;
 +			break;
 +		}
 +		pr_debug("GET_DSP_STAT succeed\n");
 +		break;
 +	case IOCTL_SET_DPRAM_CMD:
 +	{
++=======
+ 	info = file->private_data;
+ 	ft1000dev = info->priv;
+     cmd = _IOC_NR(command);
+     /* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */
+ 
+     /* process the command */
+     switch (cmd) {
+     case IOCTL_REGISTER_CMD:
+             DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n");
+             result = get_user(tempword, (__u16 __user*)argp);
+             if (result) {
+                 DEBUG("result = %d failed to get_user\n", result);
+                 break;
+             }
+             if (tempword == DSPBCMSGID) {
+                 /* Search for matching file object */
+                 for (i=0; i<MAX_NUM_APP; i++) {
+                     if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
+                         ft1000dev->app_info[i].DspBCMsgFlag = 1;
+                         DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n");
+                         break;
+                     }
+                 }
+             }
+             break;
+ 
+     case IOCTL_GET_VER_CMD:
+         DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_VER called\n");
+ 
+         get_ver_data.drv_ver = FT1000_DRV_VER;
+ 
+         if (copy_to_user(argp, &get_ver_data, sizeof(get_ver_data))) {
+             DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
+             result = -EFAULT;
+             break;
+         }
+ 
+         DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n",(unsigned int)get_ver_data.drv_ver);
+ 
+         break;
+     case IOCTL_CONNECT:
+         /* Connect Message */
+         DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_CONNECT\n");
+         ConnectionMsg[79] = 0xfc;
+ 			   result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
+ 
+         break;
+     case IOCTL_DISCONNECT:
+         /* Disconnect Message */
+         DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_DISCONNECT\n");
+         ConnectionMsg[79] = 0xfd;
+ 			   result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
+         break;
+     case IOCTL_GET_DSP_STAT_CMD:
+         /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */
+ 	memset(&get_stat_data, 0, sizeof(get_stat_data));
+         memcpy(get_stat_data.DspVer, info->DspVer, DSPVERSZ);
+         memcpy(get_stat_data.HwSerNum, info->HwSerNum, HWSERNUMSZ);
+         memcpy(get_stat_data.Sku, info->Sku, SKUSZ);
+         memcpy(get_stat_data.eui64, info->eui64, EUISZ);
+ 
+             if (info->ProgConStat != 0xFF) {
+                 ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_LED, (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
+                 get_stat_data.LedStat = ntohs(ledStat);
+                 DEBUG("FT1000:ft1000_ioctl: LedStat = 0x%x\n", get_stat_data.LedStat);
+                 ft1000_read_dpram16(ft1000dev, FT1000_MAG_DSP_CON_STATE, (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX);
+                 get_stat_data.ConStat = ntohs(conStat);
+                 DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat);
+             } else {
+                 get_stat_data.ConStat = 0x0f;
+             }
+ 
+ 
+         get_stat_data.nTxPkts = info->stats.tx_packets;
+         get_stat_data.nRxPkts = info->stats.rx_packets;
+         get_stat_data.nTxBytes = info->stats.tx_bytes;
+         get_stat_data.nRxBytes = info->stats.rx_bytes;
 -	time = get_seconds();
 -	get_stat_data.ConTm = time - info->ConTm;
+         DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm);
+         if (copy_to_user(argp, &get_stat_data, sizeof(get_stat_data))) {
+             DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
+             result = -EFAULT;
+             break;
+         }
+         DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n");
+         break;
+     case IOCTL_SET_DPRAM_CMD:
+         {
++>>>>>>> y2038/y2038
  		struct IOCTL_DPRAM_BLK *dpram_data = NULL;
  		/* struct IOCTL_DPRAM_COMMAND dpram_command; */
 -            u16 qtype;
 -            u16 msgsz;
 +		u16 qtype;
 +		u16 msgsz;
  		struct pseudo_hdr *ppseudo_hdr;
 -            u16 *pmsg;
 -            u16 total_len;
 -            u16 app_index;
 -            u16 status;
 -
 -            /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/
 +		u16 *pmsg;
 +		u16 total_len;
 +		u16 app_index;
 +		u16 status;
  
 +		/* pr_debug("IOCTL_FT1000_SET_DPRAM called\n");*/
  
 -            if (ft1000_flarion_cnt == 0) {
 -                return (-EBADF);
 -            }
  
 -            if (ft1000dev->DrvMsgPend) {
 -                return (-ENOTTY);
 -            }
 +		if (ft1000_flarion_cnt == 0)
 +			return -EBADF;
  
 -            if (ft1000dev->fProvComplete == 0) {
 -                return (-EACCES);
 -            }
 +		if (ft1000dev->DrvMsgPend)
 +			return -ENOTTY;
  
 -            ft1000dev->fAppMsgPend = 1;
 +		if (ft1000dev->fProvComplete == 0)
 +			return -EACCES;
  
 -            if (info->CardReady) {
 +		ft1000dev->fAppMsgPend = 1;
  
 -               /* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */
 +		if (info->CardReady) {
  
 -                /* Get the length field to see how many bytes to copy */
 -                result = get_user(msgsz, (__u16 __user *)argp);
 -		if (result)
 -			break;
 -                msgsz = ntohs(msgsz);
 -                /* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */
 +			/* pr_debug("try to SET_DPRAM\n"); */
  
 -                if (msgsz > MAX_CMD_SQSIZE) {
 -                    DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz);
 -                    result = -EINVAL;
 -                    break;
 -                }
 +			/* Get the length field to see how many bytes to copy */
 +			result = get_user(msgsz, (__u16 __user *)argp);
 +			if (result)
 +				break;
 +			msgsz = ntohs(msgsz);
 +			/* pr_debug("length of message = %d\n", msgsz); */
  
 -		result = -ENOMEM;
 -		dpram_data = kmalloc(msgsz + 2, GFP_KERNEL);
 -		if (!dpram_data)
 -			break;
 +			if (msgsz > MAX_CMD_SQSIZE) {
 +				pr_debug("bad message length = %d\n", msgsz);
 +				result = -EINVAL;
 +				break;
 +			}
  
 -                if (copy_from_user(dpram_data, argp, msgsz+2)) {
 -                    DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
 -                    result = -EFAULT;
 -                } else {
 -                    /* Check if this message came from a registered application */
 -                    for (i=0; i<MAX_NUM_APP; i++) {
 -                        if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
 -                            break;
 -                        }
 -                    }
 -                    if (i==MAX_NUM_APP) {
 -                        DEBUG("FT1000:No matching application fileobject\n");
 -                        result = -EINVAL;
 -			kfree(dpram_data);
 -                        break;
 -                    }
 -                    app_index = i;
 -
 -                    /* Check message qtype type which is the lower byte within qos_class */
 -                    qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
 -                    /* DEBUG("FT1000_ft1000_ioctl: qtype = %d\n", qtype); */
 -                    if (qtype) {
 -                    } else {
 -                        /* Put message into Slow Queue */
 -                        /* Only put a message into the DPRAM if msg doorbell is available */
 -                        status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 -                        /* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */
 -                        if (tempword & FT1000_DB_DPRAM_TX) {
 -                            /* Suspend for 2ms and try again due to DSP doorbell busy */
 -                            mdelay(2);
 -                            status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 -                            if (tempword & FT1000_DB_DPRAM_TX) {
 -                                /* Suspend for 1ms and try again due to DSP doorbell busy */
 -                                mdelay(1);
 -                                status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 -                                if (tempword & FT1000_DB_DPRAM_TX) {
 -                                    status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 -                                    if (tempword & FT1000_DB_DPRAM_TX) {
 -                                        /* Suspend for 3ms and try again due to DSP doorbell busy */
 -                                        mdelay(3);
 -                                        status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 -                                        if (tempword & FT1000_DB_DPRAM_TX) {
 -                                            DEBUG("FT1000:ft1000_ioctl:Doorbell not available\n");
 -                                            result = -ENOTTY;
 -						kfree(dpram_data);
 -                                            break;
 -                                        }
 -                                    }
 -                                }
 -                            }
 -                        }
 -
 -                        /*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */
 -
 -                        /* Make sure we are within the limits of the slow queue memory limitation */
 -                        if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) {
 -                            /* Need to put sequence number plus new checksum for message */
 -                            pmsg = (u16 *)&dpram_data->pseudohdr;
 -				ppseudo_hdr = (struct pseudo_hdr *)pmsg;
 -                            total_len = msgsz+2;
 -                            if (total_len & 0x1) {
 -                                total_len++;
 -                            }
 -
 -                            /* Insert slow queue sequence number */
 -                            ppseudo_hdr->seq_num = info->squeseqnum++;
 -                            ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id;
 -                            /* Calculate new checksum */
 -                            ppseudo_hdr->checksum = *pmsg++;
 -                            /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */
 -                            for (i=1; i<7; i++) {
 -                                ppseudo_hdr->checksum ^= *pmsg++;
 -                                /* DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum); */
 -                            }
 -                            pmsg++;
 -				ppseudo_hdr = (struct pseudo_hdr *)pmsg;
 -                           result = card_send_command(ft1000dev,(unsigned short*)dpram_data,total_len+2);
 -
 -
 -                            ft1000dev->app_info[app_index].nTxMsg++;
 -                        } else {
 -                            result = -EINVAL;
 -                        }
 -                    }
 -                }
 -            } else {
 -                DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n");
 -                result = -EACCES;
 -            }
 -	    kfree(dpram_data);
 +			result = -ENOMEM;
 +			dpram_data = kmalloc(msgsz + 2, GFP_KERNEL);
 +			if (!dpram_data)
 +				break;
 +
 +			if (copy_from_user(dpram_data, argp, msgsz+2)) {
 +				pr_debug("copy fault occurred\n");
 +				result = -EFAULT;
 +			} else {
 +				/* Check if this message came from a registered application */
 +				for (i = 0; i < MAX_NUM_APP; i++) {
 +					if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
 +						break;
 +					}
 +				}
 +				if (i == MAX_NUM_APP) {
 +					pr_debug("No matching application fileobject\n");
 +					result = -EINVAL;
 +					kfree(dpram_data);
 +					break;
 +				}
 +				app_index = i;
 +
 +				/* Check message qtype type which is the lower byte within qos_class */
 +				qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
 +				/* pr_debug("qtype = %d\n", qtype); */
 +				if (qtype) {
 +				} else {
 +					/* Put message into Slow Queue */
 +					/* Only put a message into the DPRAM if msg doorbell is available */
 +					status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 +					/* pr_debug("READ REGISTER tempword=%x\n", tempword); */
 +					if (tempword & FT1000_DB_DPRAM_TX) {
 +						/* Suspend for 2ms and try again due to DSP doorbell busy */
 +						mdelay(2);
 +						status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 +						if (tempword & FT1000_DB_DPRAM_TX) {
 +							/* Suspend for 1ms and try again due to DSP doorbell busy */
 +							mdelay(1);
 +							status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 +							if (tempword & FT1000_DB_DPRAM_TX) {
 +								status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 +								if (tempword & FT1000_DB_DPRAM_TX) {
 +									/* Suspend for 3ms and try again due to DSP doorbell busy */
 +									mdelay(3);
 +									status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 +									if (tempword & FT1000_DB_DPRAM_TX) {
 +										pr_debug("Doorbell not available\n");
 +										result = -ENOTTY;
 +										kfree(dpram_data);
 +										break;
 +									}
 +								}
 +							}
 +						}
 +					}
 +
 +					/*pr_debug("finished reading register\n"); */
 +
 +					/* Make sure we are within the limits of the slow queue memory limitation */
 +					if ((msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ)) {
 +						/* Need to put sequence number plus new checksum for message */
 +						pmsg = (u16 *)&dpram_data->pseudohdr;
 +						ppseudo_hdr = (struct pseudo_hdr *)pmsg;
 +						total_len = msgsz+2;
 +						if (total_len & 0x1) {
 +							total_len++;
 +						}
 +
 +						/* Insert slow queue sequence number */
 +						ppseudo_hdr->seq_num = info->squeseqnum++;
 +						ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id;
 +						/* Calculate new checksum */
 +						ppseudo_hdr->checksum = *pmsg++;
 +						/* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */
 +						for (i = 1; i < 7; i++) {
 +							ppseudo_hdr->checksum ^= *pmsg++;
 +							/* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */
 +						}
 +						pmsg++;
 +						ppseudo_hdr = (struct pseudo_hdr *)pmsg;
 +						result = card_send_command(ft1000dev, (unsigned short *)dpram_data, total_len+2);
 +
 +
 +						ft1000dev->app_info[app_index].nTxMsg++;
 +					} else {
 +						result = -EINVAL;
 +					}
 +				}
 +			}
 +		} else {
 +			pr_debug("Card not ready take messages\n");
 +			result = -EACCES;
 +		}
 +		kfree(dpram_data);
  
 -        }
 -        break;
 -    case IOCTL_GET_DPRAM_CMD:
 -        {
 +	}
 +	break;
 +	case IOCTL_GET_DPRAM_CMD:
 +	{
  		struct dpram_blk *pdpram_blk;
  		struct IOCTL_DPRAM_BLK __user *pioctl_dpram;
 -            int msglen;
 -
 -            /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */
 +		int msglen;
  
 -            if (ft1000_flarion_cnt == 0) {
 -                return (-EBADF);
 -            }
 +		/* pr_debug("IOCTL_FT1000_GET_DPRAM called\n"); */
  
 -            /* Search for matching file object */
 -            for (i=0; i<MAX_NUM_APP; i++) {
 -                if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
 -                    /*DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
 -                    break;
 -                }
 -            }
 +		if (ft1000_flarion_cnt == 0)
 +			return -EBADF;
  
 -            /* Could not find application info block */
 -            if (i == MAX_NUM_APP) {
 -                DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
 -                result = -EBADF;
 -                break;
 -            }
 +		/* Search for matching file object */
 +		for (i = 0; i < MAX_NUM_APP; i++) {
 +			if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
 +				/*pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
 +				break;
 +			}
 +		}
  
 -            result = 0;
 -            pioctl_dpram = argp;
 -            if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
 -                /* DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n"); */
 -                spin_lock_irqsave(&free_buff_lock, flags);
 -                pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
 -                list_del(&pdpram_blk->list);
 -                ft1000dev->app_info[i].NumOfMsg--;
 -                /* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */
 -                spin_unlock_irqrestore(&free_buff_lock, flags);
 -                msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ;
 -                result = get_user(msglen, &pioctl_dpram->total_len);
 -		if (result)
 +		/* Could not find application info block */
 +		if (i == MAX_NUM_APP) {
 +			pr_debug("Could not find application info block\n");
 +			result = -EBADF;
  			break;
 -		msglen = htons(msglen);
 -                /* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */
 -                if (copy_to_user (&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) {
 -					DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
 -			result = -EFAULT;
 -			break;
 -				}
 +		}
  
 -                ft1000_free_buffer(pdpram_blk, &freercvpool);
 -                result = msglen;
 -            }
 -            /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */
 -        }
 -        break;
 +		result = 0;
 +		pioctl_dpram = argp;
 +		if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
 +			/* pr_debug("Message detected in slow queue\n"); */
 +			spin_lock_irqsave(&free_buff_lock, flags);
 +			pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
 +			list_del(&pdpram_blk->list);
 +			ft1000dev->app_info[i].NumOfMsg--;
 +			/* pr_debug("NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg); */
 +			spin_unlock_irqrestore(&free_buff_lock, flags);
 +			msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ;
 +			result = get_user(msglen, &pioctl_dpram->total_len);
 +			if (result)
 +				break;
 +			msglen = htons(msglen);
 +			/* pr_debug("msg length = %x\n", msglen); */
 +			if (copy_to_user(&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) {
 +				pr_debug("copy fault occurred\n");
 +				result = -EFAULT;
 +				break;
 +			}
  
 -    default:
 -        DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command);
 -        result = -ENOTTY;
 -        break;
 -    }
 -    ft1000dev->fAppMsgPend = 0;
 -    return result;
 +			ft1000_free_buffer(pdpram_blk, &freercvpool);
 +			result = msglen;
 +		}
 +		/* pr_debug("IOCTL_FT1000_GET_DPRAM no message\n"); */
 +	}
 +	break;
 +
 +	default:
 +		pr_debug("unknown command: 0x%x\n", command);
 +		result = -ENOTTY;
 +		break;
 +	}
 +	ft1000dev->fAppMsgPend = 0;
 +	return result;
  }
  
  /*

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ