Commit b5d8204d authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman
Browse files

staging: ft1000: Logging message neatening



Use a more common logging style.

o Convert DEBUG macros to pr_debug
o Add pr_fmt
o Remove embedded function names from pr_debug
o Convert printks to pr_<level>
o Coalesce formats and align arguments
o Add missing terminating newlines

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ecdd21c7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@

  ---------------------------------------------------------------------------*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#define __KERNEL_SYSCALLS__

#include <linux/module.h>
@@ -316,7 +318,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart,

	file_version = *(long *)pFileStart;
	if (file_version != 6) {
		printk(KERN_ERR "ft1000: unsupported firmware version %ld\n", file_version);
		pr_err("unsupported firmware version %ld\n", file_version);
		Status = FAILURE;
	}

@@ -688,7 +690,7 @@ int card_download(struct net_device *dev, const u8 *pFileStart,
				uiState = STATE_SECTION_PROV;
			} else {
				netdev_dbg(dev,
					   "FT1000:download:Download error: Bad Port IDs in Pseudo Record\n");
					   "Download error: Bad Port IDs in Pseudo Record\n");
				netdev_dbg(dev, "\t Port Source = 0x%2.2x\n",
					   pHdr->portsrc);
				netdev_dbg(dev, "\t Port Destination = 0x%2.2x\n",
+131 −209

File changed.

Preview size limit exceeded, changes collapsed.

+65 −71
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
 *
 *---------------------------------------------------------------------------
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -87,13 +90,13 @@ struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist)
	spin_lock_irqsave(&free_buff_lock, flags);
	/* Check if buffer is available */
	if (list_empty(bufflist)) {
		DEBUG("ft1000_get_buffer:  No more buffer - %d\n", numofmsgbuf);
		pr_debug("No more buffer - %d\n", numofmsgbuf);
		ptr = NULL;
	} else {
		numofmsgbuf--;
		ptr = list_entry(bufflist->next, struct dpram_blk, list);
		list_del(&ptr->list);
		/* DEBUG("ft1000_get_buffer: number of free msg buffers = %d\n", numofmsgbuf); */
		/* pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */
	}
	spin_unlock_irqrestore(&free_buff_lock, flags);

@@ -125,7 +128,7 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist)
	/* Put memory back to list */
	list_add_tail(&pdpram_blk->list, plist);
	numofmsgbuf++;
	/*DEBUG("ft1000_free_buffer: number of free msg buffers = %d\n", numofmsgbuf); */
	/*pr_debug("number of free msg buffers = %d\n", numofmsgbuf); */
	spin_unlock_irqrestore(&free_buff_lock, flags);
}

@@ -153,17 +156,17 @@ int ft1000_create_dev(struct ft1000_usb *dev)
	/* make a new device name */
	sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber);

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

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


	/* register the device */
	DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName);
	pr_debug("\"%s\" debugfs device registration\n", dev->DeviceName);

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

	DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName);
	pr_debug("registered debugfs directory \"%s\"\n", dev->DeviceName);

	/* initialize application information */
	dev->appcnt = 0;
@@ -241,10 +244,6 @@ void ft1000_destroy_dev(struct net_device *netdev)
	struct list_head *pos, *q;
	struct ft1000_debug_dirs *dir;

	DEBUG("%s called\n", __func__);



	if (dev->DeviceCreated) {
		ft1000_flarion_cnt--;
		list_for_each_safe(pos, q, &dev->nodes.list) {
@@ -256,8 +255,7 @@ void ft1000_destroy_dev(struct net_device *netdev)
				kfree(dir);
			}
		}
		DEBUG("%s: unregistered device \"%s\"\n", __func__,
		      dev->DeviceName);
		pr_debug("unregistered device \"%s\"\n", dev->DeviceName);

		/* Make sure we free any memory reserve for slow Queue */
		for (i = 0; i < MAX_NUM_APP; i++) {
@@ -303,17 +301,17 @@ static int ft1000_open(struct inode *inode, struct file *file)
	struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private;
	int i, num;

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

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

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

	/* Check if maximum number of application exceeded */
	if (dev->appcnt > MAX_NUM_APP) {
		DEBUG("Maximum number of application exceeded\n");
		pr_debug("Maximum number of application exceeded\n");
		return -EACCES;
	}

@@ -326,7 +324,7 @@ static int ft1000_open(struct inode *inode, struct file *file)

	/* Fail due to lack of application info block */
	if (i == MAX_NUM_APP) {
		DEBUG("Could not find an application info block\n");
		pr_debug("Could not find an application info block\n");
		return -EACCES;
	}

@@ -362,33 +360,32 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
	struct ft1000_usb *dev = info->priv;
	int i;

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

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

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

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

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

	return 0;
}
@@ -429,27 +426,25 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
	unsigned short ledStat = 0;
	unsigned short conStat = 0;

	/* DEBUG("ft1000_ioctl called\n"); */

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

	/* DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument); */
	/* pr_debug("command = 0x%x argument = 0x%8x\n", command, (u32)argument); */

	info = file->private_data;
	ft1000dev = info->priv;
	cmd = _IOC_NR(command);
	/* DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd); */
	/* pr_debug("cmd = 0x%x\n", cmd); */

	/* process the command */
	switch (cmd) {
	case IOCTL_REGISTER_CMD:
		DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_REGISTER called\n");
		pr_debug("IOCTL_FT1000_REGISTER called\n");
		result = get_user(tempword, (__u16 __user *)argp);
		if (result) {
			DEBUG("result = %d failed to get_user\n", result);
			pr_debug("result = %d failed to get_user\n", result);
			break;
		}
		if (tempword == DSPBCMSGID) {
@@ -457,7 +452,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
			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");
					pr_debug("Registered for broadcast messages\n");
					break;
				}
			}
@@ -465,34 +460,35 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		break;

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

		DEBUG("FT1000:ft1000_ioctl:driver version = 0x%x\n", (unsigned int)get_ver_data.drv_ver);
		pr_debug("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");
		pr_debug("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");
		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:
		/* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DSP_STAT called\n"); */
		/* 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);
@@ -502,10 +498,10 @@ static long ft1000_ioctl(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_ioctl: LedStat = 0x%x\n", get_stat_data.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);
			DEBUG("FT1000:ft1000_ioctl: ConStat = 0x%x\n", get_stat_data.ConStat);
			pr_debug("ConStat = 0x%x\n", get_stat_data.ConStat);
		} else {
			get_stat_data.ConStat = 0x0f;
		}
@@ -517,13 +513,13 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		get_stat_data.nRxBytes = info->stats.rx_bytes;
		do_gettimeofday(&tv);
		get_stat_data.ConTm = (u32)(tv.tv_sec - info->ConTm);
		DEBUG("Connection Time = %d\n", (int)get_stat_data.ConTm);
		pr_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");
			pr_debug("copy fault occurred\n");
			result = -EFAULT;
			break;
		}
		DEBUG("ft1000_chioctl: GET_DSP_STAT succeed\n");
		pr_debug("GET_DSP_STAT succeed\n");
		break;
	case IOCTL_SET_DPRAM_CMD:
	{
@@ -537,7 +533,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		u16 app_index;
		u16 status;

		/* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_SET_DPRAM called\n");*/
		/* pr_debug("IOCTL_FT1000_SET_DPRAM called\n");*/


		if (ft1000_flarion_cnt == 0)
@@ -553,17 +549,17 @@ static long ft1000_ioctl(struct file *file, unsigned int command,

		if (info->CardReady) {

			/* DEBUG("FT1000:ft1000_ioctl: try to SET_DPRAM \n"); */
			/* pr_debug("try to SET_DPRAM\n"); */

			/* Get the length field to see how many bytes to copy */
			result = get_user(msgsz, (__u16 __user *)argp);
			if (result)
				break;
			msgsz = ntohs(msgsz);
			/* DEBUG("FT1000:ft1000_ioctl: length of message = %d\n", msgsz); */
			/* pr_debug("length of message = %d\n", msgsz); */

			if (msgsz > MAX_CMD_SQSIZE) {
				DEBUG("FT1000:ft1000_ioctl: bad message length = %d\n", msgsz);
				pr_debug("bad message length = %d\n", msgsz);
				result = -EINVAL;
				break;
			}
@@ -574,7 +570,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
				break;

			if (copy_from_user(dpram_data, argp, msgsz+2)) {
				DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
				pr_debug("copy fault occurred\n");
				result = -EFAULT;
			} else {
				/* Check if this message came from a registered application */
@@ -584,7 +580,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
					}
				}
				if (i == MAX_NUM_APP) {
					DEBUG("FT1000:No matching application fileobject\n");
					pr_debug("No matching application fileobject\n");
					result = -EINVAL;
					kfree(dpram_data);
					break;
@@ -593,13 +589,13 @@ static long ft1000_ioctl(struct file *file, unsigned int command,

				/* 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); */
				/* 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);
					/* DEBUG("FT1000_ft1000_ioctl: READ REGISTER tempword=%x\n", tempword); */
					/* 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);
@@ -615,7 +611,7 @@ static long ft1000_ioctl(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_ioctl:Doorbell not available\n");
										pr_debug("Doorbell not available\n");
										result = -ENOTTY;
										kfree(dpram_data);
										break;
@@ -625,7 +621,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
						}
					}

					/*DEBUG("FT1000_ft1000_ioctl: finished reading register\n"); */
					/*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)) {
@@ -642,10 +638,10 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
						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); */
						/* pr_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); */
							/* pr_debug("checksum = 0x%x\n", ppseudo_hdr->checksum); */
						}
						pmsg++;
						ppseudo_hdr = (struct pseudo_hdr *)pmsg;
@@ -659,7 +655,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
				}
			}
		} else {
			DEBUG("FT1000:ft1000_ioctl: Card not ready take messages\n");
			pr_debug("Card not ready take messages\n");
			result = -EACCES;
		}
		kfree(dpram_data);
@@ -672,7 +668,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		struct IOCTL_DPRAM_BLK __user *pioctl_dpram;
		int msglen;

		/* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */
		/* pr_debug("IOCTL_FT1000_GET_DPRAM called\n"); */

		if (ft1000_flarion_cnt == 0)
			return -EBADF;
@@ -680,14 +676,14 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		/* 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); */
				/*pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
				break;
			}
		}

		/* Could not find application info block */
		if (i == MAX_NUM_APP) {
			DEBUG("FT1000:ft1000_ioctl:Could not find application info block\n");
			pr_debug("Could not find application info block\n");
			result = -EBADF;
			break;
		}
@@ -695,21 +691,21 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
		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"); */
			/* 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--;
			/* DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, 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);
			/* DEBUG("FT1000:ft1000_ioctl:msg length = %x\n", msglen); */
			/* pr_debug("msg length = %x\n", msglen); */
			if (copy_to_user(&pioctl_dpram->pseudohdr, pdpram_blk->pbuffer, msglen)) {
				DEBUG("FT1000:ft1000_ioctl: copy fault occurred\n");
				pr_debug("copy fault occurred\n");
				result = -EFAULT;
				break;
			}
@@ -717,12 +713,12 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
			ft1000_free_buffer(pdpram_blk, &freercvpool);
			result = msglen;
		}
		/* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM no message\n"); */
		/* pr_debug("IOCTL_FT1000_GET_DPRAM no message\n"); */
	}
	break;

	default:
		DEBUG("FT1000:ft1000_ioctl:unknown command: 0x%x\n", command);
		pr_debug("unknown command: 0x%x\n", command);
		result = -ENOTTY;
		break;
	}
@@ -750,8 +746,6 @@ static int ft1000_release(struct inode *inode, struct file *file)
	int i;
	struct dpram_blk *pdpram_blk;

	DEBUG("ft1000_release called\n");

	dev = file->private_data;
	info = netdev_priv(dev);
	ft1000dev = info->priv;
@@ -764,7 +758,7 @@ static int ft1000_release(struct inode *inode, struct file *file)
	/* 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); */
			/* pr_debug("Message is for AppId = %d\n", ft1000dev->app_info[i].app_id); */
			break;
		}
	}
@@ -773,7 +767,7 @@ static int ft1000_release(struct inode *inode, struct file *file)
		return 0;

	while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
		DEBUG("Remove and free memory queue up on slow queue\n");
		pr_debug("Remove and free memory queue up on slow queue\n");
		pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
		list_del(&pdpram_blk->list);
		ft1000_free_buffer(pdpram_blk, &freercvpool);
@@ -781,7 +775,7 @@ static int ft1000_release(struct inode *inode, struct file *file)

	/* initialize application information */
	ft1000dev->appcnt--;
	DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt);
	pr_debug("appcnt = %d\n", ft1000dev->appcnt);
	ft1000dev->app_info[i].fileobject = NULL;

	return 0;
+59 −79
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
 * This file is part of Express Card USB Driver
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
@@ -118,10 +120,9 @@ static int check_usb_db(struct ft1000_usb *ft1000dev)
	while (loopcnt < 10) {
		status = ft1000_read_register(ft1000dev, &temp,
					      FT1000_REG_DOORBELL);
		DEBUG("check_usb_db: read FT1000_REG_DOORBELL value is %x\n",
		      temp);
		pr_debug("read FT1000_REG_DOORBELL value is %x\n", temp);
		if (temp & 0x0080) {
			DEBUG("FT1000:Got checkusb doorbell\n");
			pr_debug("Got checkusb doorbell\n");
			status = ft1000_write_register(ft1000dev, 0x0080,
						       FT1000_REG_DOORBELL);
			status = ft1000_write_register(ft1000dev, 0x0100,
@@ -139,12 +140,12 @@ static int check_usb_db(struct ft1000_usb *ft1000dev)
	while (loopcnt < 20) {
		status = ft1000_read_register(ft1000dev, &temp,
					      FT1000_REG_DOORBELL);
		DEBUG("FT1000:check_usb_db:Doorbell = 0x%x\n", temp);
		pr_debug("Doorbell = 0x%x\n", temp);
		if (temp & 0x8000) {
			loopcnt++;
			msleep(10);
		} else	{
			DEBUG("check_usb_db: door bell is cleared, return 0\n");
			pr_debug("door bell is cleared, return 0\n");
			return 0;
		}
	}
@@ -166,12 +167,11 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
		status = ft1000_write_register(ft1000dev,  FT1000_DB_DNLD_RX,
					       FT1000_REG_DOORBELL);
		if (ft1000dev->fcodeldr) {
			DEBUG(" get_handshake: fcodeldr is %d\n",
			      ft1000dev->fcodeldr);
			pr_debug("fcodeldr is %d\n", ft1000dev->fcodeldr);
			ft1000dev->fcodeldr = 0;
			status = check_usb_db(ft1000dev);
			if (status != 0) {
				DEBUG("get_handshake: check_usb_db failed\n");
				pr_debug("check_usb_db failed\n");
				break;
			}
			status = ft1000_write_register(ft1000dev,
@@ -232,13 +232,13 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)
			status = ft1000_read_dpram32(ft1000dev, 0,
						     (u8 *)&(ft1000dev->tempbuf[0]), 64);
			for (temp = 0; temp < 16; temp++) {
				DEBUG("tempbuf %d = 0x%x\n", temp,
				      ft1000dev->tempbuf[temp]);
				pr_debug("tempbuf %d = 0x%x\n",
					 temp, ft1000dev->tempbuf[temp]);
			}
			status = ft1000_read_dpram16(ft1000dev,
						     DWNLD_MAG1_HANDSHAKE_LOC,
						     (u8 *)&handshake, 1);
			DEBUG("handshake from read_dpram16 = 0x%x\n",
			pr_debug("handshake from read_dpram16 = 0x%x\n",
				 handshake);
			if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) {
				handshake = 0;
@@ -409,7 +409,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
			if ((tempbuffer[31] & 0xfe00) == 0xfe00) {
				if (check_buffers(tempbuffer, resultbuffer, 28,
						  0)) {
					DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n");
					pr_debug("DPRAM write failed 1 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
@@ -419,14 +419,14 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,

				if (check_buffers(tempbuffer, resultbuffer, 16,
						  24)) {
					DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n");
					pr_debug("DPRAM write failed 2 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
			} else {
				if (check_buffers(tempbuffer, resultbuffer, 32,
						  0)) {
					DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n");
					pr_debug("DPRAM write failed 3 during bootloading\n");
					usleep_range(9000, 11000);
					break;
				}
@@ -453,7 +453,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
	u16 tempword;
	u16 tempbuffer[64];

	/*DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); */
	/*pr_debug("start word_length = %d\n",(int)word_length); */
	dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
	tempword = *(*pUsFile);
	(*pUsFile)++;
@@ -483,9 +483,9 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
			}
		}

		/*DEBUG("write_blk: loopcnt is %d\n", loopcnt); */
		/*DEBUG("write_blk: bootmode = %d\n", bootmode); */
		/*DEBUG("write_blk: dpram = %x\n", dpram); */
		/*pr_debug("loopcnt is %d\n", loopcnt); */
		/*pr_debug("write_blk: bootmode = %d\n", bootmode); */
		/*pr_debug("write_blk: dpram = %x\n", dpram); */
		if (ft1000dev->bootmode == 0) {
			if (dpram >= 0x3F4)
				status = ft1000_write_dpram32(ft1000dev, dpram,
@@ -497,7 +497,8 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
			status = write_dpram32_and_check(ft1000dev, tempbuffer,
							 dpram);
			if (status != 0) {
				DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]);
				pr_debug("Write failed tempbuffer[31] = 0x%x\n",
					 tempbuffer[31]);
				break;
			}
		}
@@ -508,7 +509,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,

static void usb_dnld_complete(struct urb *urb)
{
	/* DEBUG("****** usb_dnld_complete\n"); */
	/* pr_debug("****** usb_dnld_complete\n"); */
}

/* writes a block of DSP image to DPRAM
@@ -552,18 +553,17 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake,
{
	int status = 0;

	DEBUG("FT1000:STATE_START_DWNLD\n");
	if (ft1000dev->usbboot)
		*hshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY);
	else
		*hshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY);
	if (*hshake == HANDSHAKE_DSP_BL_READY) {
		DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n");
		pr_debug("handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n");
		put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY);
	} else if (*hshake == HANDSHAKE_TIMEOUT_VALUE) {
		status = -ETIMEDOUT;
	} else {
		DEBUG("FT1000:download:Download error: Handshake failed\n");
		pr_debug("Download error: Handshake failed\n");
		status = -ENETRESET;
	}
	*state = STATE_BOOT_DWNLD;
@@ -576,17 +576,17 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,
	long word_length;
	int status = 0;

	/*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/
	word_length = get_request_value(ft1000dev);
	/*DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); */
	/*pr_debug("word_length = 0x%x\n", (int)word_length); */
	/*NdisMSleep (100); */
	if (word_length > MAX_LENGTH) {
		DEBUG("FT1000:download:Download error: Max length exceeded\n");
		pr_debug("Download error: Max length exceeded\n");
		return -1;
	}
	if ((word_length * 2 + (long)c_file) > (long)endpoint) {
		/* Error, beyond boot code range.*/
		DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length);
		pr_debug("Download error: Requested len=%d exceeds BOOT code boundary\n",
			 (int)word_length);
		return -1;
	}
	if (word_length & 0x1)
@@ -595,7 +595,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,

	if (boot_case) {
		status = write_blk(ft1000dev, s_file, c_file, word_length);
		/*DEBUG("write_blk returned %d\n", status); */
		/*pr_debug("write_blk returned %d\n", status); */
	} else {
		status = write_blk_fifo(ft1000dev, s_file, c_file, word_length);
		if (ft1000dev->usbboot == 0)
@@ -641,8 +641,6 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
	struct prov_record *pprov_record;
	struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);

	DEBUG("Entered   scram_dnldr...\n");

	ft1000dev->fcodeldr = 0;
	ft1000dev->usbboot = 0;
	ft1000dev->dspalive = 0xffff;
@@ -674,7 +672,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
			break;

		case STATE_BOOT_DWNLD:
			DEBUG("FT1000:STATE_BOOT_DWNLD\n");
			pr_debug("STATE_BOOT_DWNLD\n");
			ft1000dev->bootmode = 1;
			handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
			if (handshake == HANDSHAKE_REQUEST) {
@@ -684,22 +682,22 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
				request = get_request_type(ft1000dev);
				switch (request) {
				case REQUEST_RUN_ADDRESS:
					DEBUG("FT1000:REQUEST_RUN_ADDRESS\n");
					pr_debug("REQUEST_RUN_ADDRESS\n");
					put_request_value(ft1000dev,
							  loader_code_address);
					break;
				case REQUEST_CODE_LENGTH:
					DEBUG("FT1000:REQUEST_CODE_LENGTH\n");
					pr_debug("REQUEST_CODE_LENGTH\n");
					put_request_value(ft1000dev,
							  loader_code_size);
					break;
				case REQUEST_DONE_BL:
					DEBUG("FT1000:REQUEST_DONE_BL\n");
					pr_debug("REQUEST_DONE_BL\n");
					/* Reposition ptrs to beginning of code section */
					s_file = (u16 *) (boot_end);
					c_file = (u8 *) (boot_end);
					/* DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file); */
					/* DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file); */
					/* pr_debug("download:s_file = 0x%8x\n", (int)s_file); */
					/* pr_debug("FT1000:download:c_file = 0x%8x\n", (int)c_file); */
					state = STATE_CODE_DWNLD;
					ft1000dev->fcodeldr = 1;
					break;
@@ -710,8 +708,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
								      true);
					break;
				default:
					DEBUG
						("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",
					pr_debug("Download error: Bad request type=%d in BOOT download state\n",
						 request);
					status = -1;
					break;
@@ -723,15 +720,14 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					put_handshake(ft1000dev,
						      HANDSHAKE_RESPONSE);
			} else {
				DEBUG
					("FT1000:download:Download error: Handshake failed\n");
				pr_debug("Download error: Handshake failed\n");
				status = -1;
			}

			break;

		case STATE_CODE_DWNLD:
			/* DEBUG("FT1000:STATE_CODE_DWNLD\n"); */
			/* pr_debug("STATE_CODE_DWNLD\n"); */
			ft1000dev->bootmode = 0;
			if (ft1000dev->usbboot)
				handshake =
@@ -751,40 +747,33 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					request = get_request_type(ft1000dev);
				switch (request) {
				case REQUEST_FILE_CHECKSUM:
					DEBUG
						("FT1000:download:image_chksum = 0x%8x\n",
					pr_debug("image_chksum = 0x%8x\n",
						 image_chksum);
					put_request_value(ft1000dev,
							  image_chksum);
					break;
				case REQUEST_RUN_ADDRESS:
					DEBUG
						("FT1000:download:  REQUEST_RUN_ADDRESS\n");
					pr_debug("REQUEST_RUN_ADDRESS\n");
					if (correct_version) {
						DEBUG
							("FT1000:download:run_address = 0x%8x\n",
						pr_debug("run_address = 0x%8x\n",
							 (int)run_address);
						put_request_value(ft1000dev,
								  run_address);
					} else {
						DEBUG
							("FT1000:download:Download error: Got Run address request before image offset request.\n");
						pr_debug("Download error: Got Run address request before image offset request\n");
						status = -1;
						break;
					}
					break;
				case REQUEST_CODE_LENGTH:
					DEBUG
						("FT1000:download:REQUEST_CODE_LENGTH\n");
					pr_debug("REQUEST_CODE_LENGTH\n");
					if (correct_version) {
						DEBUG
							("FT1000:download:run_size = 0x%8x\n",
						pr_debug("run_size = 0x%8x\n",
							 (int)run_size);
						put_request_value(ft1000dev,
								  run_size);
					} else {
						DEBUG
							("FT1000:download:Download error: Got Size request before image offset request.\n");
						pr_debug("Download error: Got Size request before image offset request\n");
						status = -1;
						break;
					}
@@ -801,10 +790,9 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					state = STATE_DONE_DWNLD;
					break;
				case REQUEST_CODE_SEGMENT:
					/* DEBUG("FT1000:download: REQUEST_CODE_SEGMENT - CODELOADER\n"); */
					/* pr_debug("REQUEST_CODE_SEGMENT - CODELOADER\n"); */
					if (!correct_version) {
						DEBUG
							("FT1000:download:Download error: Got Code Segment request before image offset request.\n");
						pr_debug("Download error: Got Code Segment request before image offset request\n");
						status = -1;
						break;
					}
@@ -817,8 +805,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					break;

				case REQUEST_MAILBOX_DATA:
					DEBUG
						("FT1000:download: REQUEST_MAILBOX_DATA\n");
					pr_debug("REQUEST_MAILBOX_DATA\n");
					/* Convert length from byte count to word count. Make sure we round up. */
					word_length =
						(long)(pft1000info->DSPInfoBlklen +
@@ -852,8 +839,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					break;

				case REQUEST_VERSION_INFO:
					DEBUG
						("FT1000:download:REQUEST_VERSION_INFO\n");
					pr_debug("REQUEST_VERSION_INFO\n");
					word_length =
						file_hdr->version_data_size;
					put_request_value(ft1000dev,
@@ -887,8 +873,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					break;

				case REQUEST_CODE_BY_VERSION:
					DEBUG
						("FT1000:download:REQUEST_CODE_BY_VERSION\n");
					pr_debug("REQUEST_CODE_BY_VERSION\n");
					correct_version = false;
					requested_version =
						get_request_value(ft1000dev);
@@ -907,8 +892,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
						if (dsp_img_info->version ==
						    requested_version) {
							correct_version = true;
							DEBUG
								("FT1000:download: correct_version is TRUE\n");
							pr_debug("correct_version is TRUE\n");
							s_file =
								(u16 *) (pFileStart
									 +
@@ -941,8 +925,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
						/*
						 * Error, beyond boot code range.
						 */
						DEBUG
							("FT1000:download:Download error: Bad Version Request = 0x%x.\n",
						pr_debug("Download error: Bad Version Request = 0x%x.\n",
							 (int)requested_version);
						status = -1;
						break;
@@ -950,8 +933,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					break;

				default:
					DEBUG
						("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",
					pr_debug("Download error: Bad request type=%d in CODE download state.\n",
						 request);
					status = -1;
					break;
@@ -963,20 +945,19 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
					put_handshake(ft1000dev,
						      HANDSHAKE_RESPONSE);
			} else {
				DEBUG
					("FT1000:download:Download error: Handshake failed\n");
				pr_debug("Download error: Handshake failed\n");
				status = -1;
			}

			break;

		case STATE_DONE_DWNLD:
			DEBUG("FT1000:download:Code loader is done...\n");
			pr_debug("Code loader is done...\n");
			state = STATE_SECTION_PROV;
			break;

		case STATE_SECTION_PROV:
			DEBUG("FT1000:download:STATE_SECTION_PROV\n");
			pr_debug("STATE_SECTION_PROV\n");
			pseudo_header = (struct pseudo_hdr *)c_file;

			if (pseudo_header->checksum ==
@@ -1031,13 +1012,12 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
				/* Checksum did not compute */
				status = -1;
			}
			DEBUG
				("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n",
			pr_debug("after STATE_SECTION_PROV, state = %d, status= %d\n",
				 state, status);
			break;

		case STATE_DONE_PROV:
			DEBUG("FT1000:download:STATE_DONE_PROV\n");
			pr_debug("STATE_DONE_PROV\n");
			state = STATE_DONE_FILE;
			break;

@@ -1064,7 +1044,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,

	}			/* End while */

	DEBUG("Download exiting with status = 0x%8x\n", status);
	pr_debug("Download exiting with status = 0x%8x\n", status);
	ft1000_write_register(ft1000dev, FT1000_DB_DNLD_TX,
			      FT1000_REG_DOORBELL);

+84 −110

File changed.

Preview size limit exceeded, changes collapsed.

Loading