Esempio n. 1
0
void diag_smd_enable(smd_channel_t *ch, char *src, int mode)
{
	int r = 0;
	static smd_channel_t *_ch = NULL;
	DIAGFWD_INFO("smd_try_open(%s): mode=%d\n", src, mode);

	mutex_lock(&driver->smd_lock);
	diag_smd_function_mode = mode;
	if (mode) {
		if (!driver->ch) {
			r = smd_open(SMDDIAG_NAME, &driver->ch, driver, diag_smd_notify);
			if (!r)
				_ch = driver->ch;
		} else
			_ch = driver->ch;
	} else {
		if (driver->ch) {
			r = smd_close(driver->ch);
			driver->ch = NULL;
			if (!r)
				_ch = driver->ch;
		}
	}
	ch = _ch;
	mutex_unlock(&driver->smd_lock);
	DIAGFWD_INFO("smd_try_open(%s): r=%d _ch=%x\n", src, r, (unsigned int)ch);
}
Esempio n. 2
0
int diagfwd_connect(void)
{
	int err;

	DIAGFWD_INFO("%s\n", __func__);
	if (!driver->usb_connected) {
		err = usb_diag_alloc_req(driver->legacy_ch, N_LEGACY_WRITE,
			N_LEGACY_READ);
		if (err)
			DIAGFWD_ERR("diag: unable to allocate USB requests");
	}

	driver->in_busy_1 = 0;
	driver->in_busy_2 = 0;
	driver->in_busy_qdsp_1 = 0;
	driver->in_busy_qdsp_2 = 0;
#if defined(CONFIG_MACH_MECHA)
	driver->in_busy_mdm_1 = 0;
	driver->in_busy_mdm_2 = 0;
#endif
	/* Poll SMD channels to check for data*/
	queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
	queue_work(driver->diag_wq, &(driver->diag_read_smd_qdsp_work));

#if defined(CONFIG_ARCH_MSM8X60_LTE)
	driver->in_busy_sdio_1 = 0;
	driver->in_busy_sdio_2 = 0;
	if (diag_ch_sdio) {
		if (driver->legacy_ch && !IS_ERR(driver->legacy_ch))
			diagfwd_connect_sdio();
		else
			DIAGFWD_INFO("diag:No data from SDIO without  USB LEGACY ch");

	} else {
		if ((!driver->usb_connected) && driver->mdm_ch && !IS_ERR(driver->mdm_ch))
			diagfwd_connect_sdio();
		else
			DIAGFWD_INFO("diag:No data from SDIO without  USB MDM ch");

		queue_work(driver->diag_sdio_wq, &(driver->diag_read_mdm_work));
	}

#endif
	driver->usb_connected = 1;
	/* Poll USB channel to check for data*/
	queue_work(driver->diag_wq, &(driver->diag_read_work));

	return 0;
}
Esempio n. 3
0
int diagfwd_disconnect_bridge(int process_cable)
{
	DIAGFWD_INFO("diag: In %s, process_cable: %d\n", __func__, process_cable);

	
	if (process_cable) {
		driver->usb_mdm_connected = 0;
		driver->qxdmusb_drop = 1;
		usb_diag_free_req(driver->mdm_ch);
	}

	if (driver->hsic_device_enabled &&
			driver->logging_mode != MEMORY_DEVICE_MODE) {
#if 0
		driver->in_busy_hsic_read_on_device = 1;
		driver->in_busy_hsic_write = 1;
		
		return diag_hsic_close();
#endif
	} else if (driver->diag_smux_enabled &&
			driver->logging_mode == USB_MODE) {
		driver->in_busy_smux = 1;
		driver->lcid = LCID_INVALID;
#if 0
		driver->smux_connected = 0;
#endif
		
		msm_smux_close(LCID_VALID);
	}
	return 0;
}
Esempio n. 4
0
int diagfwd_connect_bridge(int process_cable)
{
	int err;

	DIAGFWD_INFO("DIAG in %s\n", __func__);

	
	if (process_cable) {
		err = usb_diag_alloc_req(driver->mdm_ch, N_MDM_WRITE,
			N_MDM_READ);
		if (err)
			pr_err("diag: unable to alloc USB req on mdm"
				" ch err:%d\n", err);

		driver->qxdmusb_drop = 0;
		driver->usb_mdm_connected = 1;
	}

	if (driver->hsic_device_enabled) {
		driver->in_busy_hsic_read_on_device = 0;
		driver->in_busy_hsic_write = 0;
	} else if (driver->diag_smux_enabled) {
		driver->in_busy_smux = 0;
		diagfwd_connect_smux();
		return 0;
	}

	
	if (driver->hsic_device_enabled) {
		if (!driver->hsic_device_opened) {
			err = diag_bridge_open(&hsic_diag_bridge_ops);
			if (err) {
				pr_err("diag: HSIC channel open error: %d\n",
					err);
			} else {
				pr_debug("diag: opened HSIC channel\n");
				driver->hsic_device_opened = 1;
			}
		} else {
			pr_debug("diag: HSIC channel already open\n");
		}

		if (driver->hsic_device_opened)
			driver->hsic_ch = 1;

		
		if (driver->logging_mode == USB_MODE)
			queue_work(driver->diag_bridge_wq,
					&driver->diag_read_mdm_work);

		
		queue_work(driver->diag_bridge_wq,
				 &driver->diag_read_hsic_work);
	} else {
		
		pr_info("diag: HSIC channel not yet enabled\n");
	}

	return 0;
}
Esempio n. 5
0
static int diag_smd_probe(struct platform_device *pdev)
{
	int r = 0;

	if (pdev->id == SMD_APPS_MODEM) {
		r = smd_open(SMDDIAG_NAME, &driver->ch, driver, diag_smd_notify);
		wmb();
		ch_temp = driver->ch;
		DIAGFWD_INFO("%s: smd_open(%s):%d, ch_temp:%p, driver->ch:%p, &driver->ch:%p\n",
			__func__, SMDDIAG_NAME, r, ch_temp, driver->ch, &driver->ch);
	}
#if defined(CONFIG_MSM_N_WAY_SMD)
	if (pdev->id == SMD_APPS_QDSP) {
#if defined(CONFIG_MACH_MECHA) || defined(CONFIG_ARCH_MSM8X60_LTE)	\
	|| defined(CONFIG_ARCH_MSM8X60) || defined(CONFIG_ARCH_MSM8960)
		r = smd_named_open_on_edge("DIAG", SMD_APPS_QDSP
			, &driver->chqdsp, driver, diag_smd_qdsp_notify);
#else
		r = smd_open("DSP_DIAG", &driver->chqdsp, driver, diag_smd_qdsp_notify);
#endif
	}
#endif
	if (pdev->id == SMD_APPS_WCNSS)
		r = smd_named_open_on_edge("APPS_RIVA_DATA", SMD_APPS_WCNSS
			, &driver->ch_wcnss, driver, diag_smd_wcnss_notify);
	pm_runtime_set_active(&pdev->dev);
	pm_runtime_enable(&pdev->dev);
	pr_debug("diag: open SMD port, Id = %d, r = %d\n", pdev->id, r);
	smd_diag_initialized = 1;

	return 0;
}
Esempio n. 6
0
int diagfwd_disconnect(void)
{

	DIAGFWD_INFO("%s\n", __func__);
	driver->in_busy_1 = 1;
	driver->in_busy_2 = 1;
	driver->in_busy_qdsp_1 = 1;
	driver->in_busy_qdsp_2 = 1;
	driver->debug_flag = 1;
	if (driver->usb_connected)
		usb_diag_free_req(driver->legacy_ch);

#if defined(CONFIG_MACH_MECHA)
	driver->in_busy_mdm_1 = 1;
	driver->in_busy_mdm_2 = 1;
#endif
#if defined(CONFIG_ARCH_MSM8X60_LTE)
	if (diag_ch_sdio) {
		if (driver->legacy_ch && !IS_ERR(driver->legacy_ch))
			diagfwd_disconnect_sdio();
	} else {
		if (driver->usb_connected && driver->mdm_ch && !IS_ERR(driver->mdm_ch))
			diagfwd_disconnect_sdio();
	}
#endif
	driver->usb_connected = 0;
	/* TBD - notify and flow control SMD */
	return 0;
}
static void diag_smd_notify(void *ctxt, unsigned event)
{
	/*printk(KERN_INFO "%s:\n", __func__);*/
	switch (diag_smd_function_mode) {
#ifdef CONFIG_BTPORT
	case SMD_FUNC_OPEN_BT:
				/*BT DUN funciton*/
				DIAGFWD_INFO("%s:bt check me\n", __func__);
				bt_smd_diag_notify(ctxt, event);
				break;
#endif
	case SMD_FUNC_OPEN_DIAG:
				queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
				break;
	case SMD_FUNC_CLOSE:
	default:
				DIAGFWD_INFO("%s:diag smd is closed \n", __func__);
				break;
	}

}
Esempio n. 8
0
static void diag_smd_notify(void *ctxt, unsigned event)
{
	if (diag7k_debug_mask)
		DIAG_INFO("%s event=%d(1:read 2:write) buf:%d:%d\n", __func__, event, driver->in_busy_1, driver->in_busy_2);
	switch (diag_smd_function_mode) {
#ifdef CONFIG_BTPORT
	case SMD_FUNC_OPEN_BT:
				/*BT DUN funciton*/
				DIAGFWD_INFO("%s:bt check me\n", __func__);
				bt_smd_diag_notify(ctxt, event);
				break;
#endif
	case SMD_FUNC_OPEN_DIAG:
				queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
				wake_lock_timeout(&driver->wake_lock, HZ / 2);
				break;
	case SMD_FUNC_CLOSE:
	default:
				DIAGFWD_INFO("%s:diag smd is closed \n", __func__);
				break;
	}

}
Esempio n. 9
0
static void diag_smd_notify(void *ctxt, unsigned event)
{
	if (event == SMD_EVENT_CLOSE) {
		pr_info("diag: clean modem registration\n");
		diag_clear_reg(MODEM_PROC);
		driver->ch = 0;
		return;
	} else if (event == SMD_EVENT_OPEN) {
		if (ch_temp)
			driver->ch = ch_temp;
		else
			DIAGFWD_INFO("%s: smd_open(%s):, ch_temp:%p, driver->ch:%p, &driver->ch:%p\n",
			__func__, SMDDIAG_NAME, ch_temp, driver->ch, &driver->ch);
	}
	queue_work(driver->diag_wq, &(driver->diag_read_smd_work));
}
Esempio n. 10
0
static int diagcharmdm_write(struct file *file, const char __user *buf,
		size_t count, loff_t *ppos)
{

	int err, pkt_type;
	int payload_size;

	if (diag9k_debug_mask)
		DIAG_INFO("%s:%s(parent:%s): tgid=%d\n", __func__,
				current->comm, current->parent->comm, current->tgid);


#ifdef CONFIG_DIAG_OVER_USB
	if (((driver->logging_mode == USB_MODE) && (!driver->usb_connected)) ||
			(driver->logging_mode == NO_LOGGING_MODE)) {
		/*Drop the diag payload */
		return -EIO;
	}
#endif /* DIAG over USB */

	/* Get the packet type F3/log/event/Pkt response */
	err = copy_from_user((&pkt_type), buf, 4);
	/*First 4 bytes indicate the type of payload - ignore these */
	payload_size = count - 4;
	if (pkt_type == USER_SPACE_LOG_TYPE) {
		if (diag9k_debug_mask)
			DIAGFWD_INFO("writing mask file\n");
		if (!mask_request_validate((unsigned char *)buf)) {
			DIAG_ERR("mask request Invalid ..cannot send to modem \n");
			return -EFAULT;
		}
		buf = buf + 4;
		if (driver->sdio_ch) {
			memcpy(buf_9k, buf, payload_size);
			sdio_write(driver->sdio_ch, buf_9k, payload_size);
		}
		return count;
	} else if (pkt_type == USERMODE_DIAGFWD) {
		buf += 4;
		if (driver->sdio_ch) {
			memcpy(buf_9k, buf, payload_size);
			sdio_write(driver->sdio_ch, buf_9k, payload_size);
		}
		return count;
	}
	return 0;
}
Esempio n. 11
0
static int diag_hsic_probe(struct platform_device *pdev)
{
	int err = 0;
	DIAGFWD_INFO("diag: in %s\n", __func__);
	if (!driver->hsic_device_enabled) {
		diagmem_hsic_init(driver);
		INIT_WORK(&(driver->diag_read_hsic_work),
					 diag_read_hsic_work_fn);
		driver->hsic_device_enabled = 1;
	}

	if (driver->usb_mdm_connected || (driver->logging_mode ==
							 MEMORY_DEVICE_MODE)) {
		
		err = diag_bridge_open(&hsic_diag_bridge_ops);
		if (err) {
			pr_err("diag: could not open HSIC, err: %d\n", err);
			driver->hsic_device_opened = 0;
			return err;
		}

		pr_info("diag: opened HSIC channel\n");
		driver->hsic_device_opened = 1;
		driver->hsic_ch = 1;

		driver->in_busy_hsic_read_on_device = 0;
		driver->in_busy_hsic_write = 0;

		if (driver->usb_mdm_connected) {
			
			queue_work(driver->diag_bridge_wq,
					 &driver->diag_read_mdm_work);
		}

		
		queue_work(driver->diag_bridge_wq,
				 &driver->diag_read_hsic_work);
	}

	return err;
}
Esempio n. 12
0
void __diag_smd_send_req(void)
{
	void *buf = NULL;
	int *in_busy_ptr = NULL;
	struct diag_request *write_ptr_modem = NULL;
#if  DIAG_XPST
	int type;
#endif

#ifdef SDQXDM_DEBUG
	static struct timeval t0 = {0, 0}, t1;
	static int full = 0, empty = 0;
	long diff;
#endif

	if (!driver->in_busy_1) {
		buf = driver->buf_in_1;
		write_ptr_modem = driver->write_ptr_1;
		in_busy_ptr = &(driver->in_busy_1);
	} else if (!driver->in_busy_2) {
		buf = driver->buf_in_2;
		write_ptr_modem = driver->write_ptr_2;
		in_busy_ptr = &(driver->in_busy_2);
	}

	if (driver->ch && buf) {
		int r = smd_read_avail(driver->ch);

		if (r > IN_BUF_SIZE) {
			if (r < MAX_IN_BUF_SIZE) {
				DIAGFWD_INFO("\n diag: SMD sending in "
						   "packets upto %d bytes", r);
				buf = krealloc(buf, r, GFP_KERNEL);
			} else {
				DIAGFWD_ERR("\n diag: SMD sending in "
				"packets more than %d bytes", MAX_IN_BUF_SIZE);
				return;
			}
		}
		if (r > 0) {
			if (!buf)
				DIAGFWD_INFO("Out of diagmem for a9\n");
			else {
				/* APPEND_DEBUG('i'); */
				smd_read(driver->ch, buf, r);

				if (diag7k_debug_mask) {
					switch (diag7k_debug_mask) {
					case 1:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from 7K(first 16 bytes)", DUMP_PREFIX_ADDRESS, 16, 1, buf, 16, 1);
						break;
					case 2:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from 7K(first 16 bytes)", DUMP_PREFIX_ADDRESS, 16, 1, buf, 16, 1);
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from 7K(last 16 bytes) ", DUMP_PREFIX_ADDRESS, 16, 1, buf+r-16, 16, 1);
						break;
					default:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from 7K ", DUMP_PREFIX_ADDRESS, 16, 1, buf, r, 1);

					}
				}

#if DIAG_XPST
				type = checkcmd_modem_epst(buf);
				if (type) {
					modem_to_userspace(buf, r, type, 0);
					return;
				}
#endif

#ifdef SDQXDM_DEBUG
				if (full) {
					pr_err("[diag-dbg] buffer become available %d %d, read %d\n", driver->in_busy_1, driver->in_busy_2, r);
					full = 0;
				}
				do_gettimeofday(&t1);
				diff = (t1.tv_sec-t0.tv_sec)*1000 + (t1.tv_usec-t0.tv_usec)/1000;
				if (diff > 1000) {
					pr_err("[diag-dbg] Over time (%ld) %ld.%04ld -> %ld.%04ld empty = %d\n", diff, (long)t0.tv_sec, t0.tv_usec/1000, (long)t1.tv_sec, t1.tv_usec/1000, empty);
				}
				write_ptr_modem->second = t1.tv_sec;
				t0 = t1;
				empty = 0;
#endif

				/* APPEND_DEBUG('j'); */
				write_ptr_modem->length = r;
				*in_busy_ptr = 1;
				diag_device_write(buf, MODEM_DATA,
							 write_ptr_modem);
			}
		}
#ifdef SDQXDM_DEBUG
		else {
			empty++;
		}
#endif
	}
	else {
#ifdef SDQXDM_DEBUG
		if (!full && driver->ch)
			pr_info("[diag-dbg] Buffer full, %d bytes pending.\n", smd_read_avail(driver->ch));
		full = 1;
#endif
		wake_lock_timeout(&driver->wake_lock, HZ);
	}
}
Esempio n. 13
0
static int diagcharmdm_write(struct file *file, const char __user *buf,
			      size_t count, loff_t *ppos)
{

	int err, pkt_type;
	int payload_size;
#if defined(CONFIG_MACH_MECHA)
	int ret = 0;
	unsigned char *tmp_buf = NULL;
#endif
#ifdef DIAG_DEBUG
	DIAG_INFO("%s:%s(parent:%s): tgid=%d\n", __func__,
	current->comm, current->parent->comm, current->tgid);
#endif
#if defined(CONFIG_MACH_MECHA)
	if (!sdio_diag_initialized) {
		DIAG_INFO("sdio diag isn't in embedded mode \n");
		return 0;
	}

	if (driver->logging_mode == MEMORY_DEVICE_MODE) {

		/* Get the packet type F3/log/event/Pkt response */
		err = copy_from_user((&pkt_type), buf, 4);
		/*First 4 bytes indicate the type of payload - ignore these */
		payload_size = count - 4;

		if (pkt_type == MEMORY_DEVICE_LOG_TYPE) {
			if (!mask_request_validate((unsigned char *)buf)) {
				DIAG_ERR("mask request Invalid ..cannot send to modem \n");
				return -EFAULT;
			}

			buf = buf + 4;
			tmp_buf = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
			memcpy(tmp_buf, buf, payload_size);
			msm_sdio_diag_write((void *)tmp_buf, payload_size);
			tmp_buf = NULL;
			return 0;
		}
	}
	return ret;
#else

#ifdef CONFIG_DIAG_OVER_USB
	if (((driver->logging_mode == USB_MODE) && (!driver->usb_connected)) ||
				(driver->logging_mode == NO_LOGGING_MODE)) {
		/*Drop the diag payload */
		return -EIO;
	}
#endif /* DIAG over USB */

	/* Get the packet type F3/log/event/Pkt response */
	err = copy_from_user((&pkt_type), buf, 4);
	/*First 4 bytes indicate the type of payload - ignore these */
	payload_size = count - 4;
	if (pkt_type == MEMORY_DEVICE_LOG_TYPE) {
			DIAGFWD_INFO("writing mask file\n");
		if (!mask_request_validate((unsigned char *)buf)) {
			DIAG_ERR("mask request Invalid ..cannot send to modem \n");
			return -EFAULT;
		}
		buf = buf + 4;
			if (driver->sdio_ch) {
				memcpy(buf_9k, buf, payload_size);
				sdio_write(driver->sdio_ch, buf_9k, payload_size);
			}
		return count;
	} else if(pkt_type == USERMODE_DIAGFWD) {

		buf += 4;

			if (driver->sdio_ch) {
				memcpy(buf_9k, buf, payload_size);
				sdio_write(driver->sdio_ch, buf_9k,payload_size);
			}

		return count;
	}
	return 0;
#endif
}
static int __init diagchar_init(void)
{
	dev_t dev;
	int error;

	DIAG_INFO("diagfwd initializing ..\n");
	driver = kzalloc(sizeof(struct diagchar_dev) + 5, GFP_KERNEL);

	if (driver) {
		driver->used = 0;
		timer_in_progress = 0;
		driver->debug_flag = 1;
		setup_timer(&drain_timer, drain_timer_func, 1234);
		driver->itemsize = itemsize;
		driver->poolsize = poolsize;
		driver->itemsize_hdlc = itemsize_hdlc;
		driver->poolsize_hdlc = poolsize_hdlc;
		driver->itemsize_write_struct = itemsize_write_struct;
		driver->poolsize_write_struct = poolsize_write_struct;
		driver->num_clients = max_clients;
		driver->logging_mode = USB_MODE;
		mutex_init(&driver->diagchar_mutex);
		init_waitqueue_head(&driver->wait_q);
		wake_lock_init(&driver->wake_lock, WAKE_LOCK_SUSPEND, "diagchar");

		INIT_WORK(&(driver->diag_drain_work), diag_drain_work_fn);
		INIT_WORK(&(driver->diag_read_smd_work), diag_read_smd_work_fn);
		INIT_WORK(&(driver->diag_read_smd_cntl_work),
						 diag_read_smd_cntl_work_fn);
		INIT_WORK(&(driver->diag_read_smd_qdsp_work),
			   diag_read_smd_qdsp_work_fn);
		INIT_WORK(&(driver->diag_read_smd_qdsp_cntl_work),
			   diag_read_smd_qdsp_cntl_work_fn);
		INIT_WORK(&(driver->diag_read_smd_wcnss_work),
			diag_read_smd_wcnss_work_fn);
		INIT_WORK(&(driver->diag_read_smd_wcnss_cntl_work),
			diag_read_smd_wcnss_cntl_work_fn);
#if defined(CONFIG_MACH_MECHA)
		INIT_WORK(&(driver->diag_read_smd_mdm_work),
			   sdio_diag_read_data);
		driver->in_busy_mdm_1 = 0;
		driver->in_busy_mdm_2 = 0;
#endif

#ifdef CONFIG_DIAG_SDIO_PIPE
		driver->num_mdmclients = 1;
		init_waitqueue_head(&driver->mdmwait_q);
		spin_lock_init(&driver->diagchar_lock);
		mutex_init(&driver->diagcharmdm_mutex);

		driver->num = 2;
#else
		driver->num = 1;
#endif
		diagfwd_init();
		if (chk_config_get_id() == AO8960_TOOLS_ID) {
			diagfwd_cntl_init();
			DIAGFWD_INFO("CNTL channel was enabled in the platform\n");
		} else
			DIAGFWD_INFO("CNTL channel was not enabled in the platform\n");

		diag_sdio_fn(INIT);
		pr_debug("diagchar initializing ..\n");
		driver->name = ((void *)driver) + sizeof(struct diagchar_dev);
		strlcpy(driver->name, "diag", 4);

		/* Get major number from kernel and initialize */
		error = alloc_chrdev_region(&dev, driver->minor_start,
					    driver->num, driver->name);
		if (!error) {
			driver->major = MAJOR(dev);
			driver->minor_start = MINOR(dev);
		} else {
			printk(KERN_INFO "Major number not allocated\n");
			goto fail;
		}
		driver->cdev = cdev_alloc();

#ifdef CONFIG_DIAG_SDIO_PIPE
		driver->cdev_mdm = cdev_alloc();
#endif
		error = diagchar_setup_cdev(dev);
		if (error)
			goto fail;
	} else {
		printk(KERN_INFO "kzalloc failed\n");
		goto fail;
	}

	DIAG_INFO("diagchar initialized\n");
	return 0;

fail:
	diagchar_cleanup();
	diagfwd_exit();
	diagfwd_cntl_exit();
	diag_sdio_fn(EXIT);
	return -1;
}
Esempio n. 15
0
void diag_process_hdlc(void *data, unsigned len)
{
	struct diag_hdlc_decode_type hdlc;
	int ret, type = 0;
#if HPST_FUN
	unsigned char *buf_9k = NULL;
	int path;
#endif
#ifdef DIAG_DEBUG
	int i;
	DIAGFWD_INFO("\n HDLC decode function, len of data  %d\n", len);
#endif
	hdlc.dest_ptr = driver->hdlc_buf;
	hdlc.dest_size = USB_MAX_OUT_BUF;
	hdlc.src_ptr = data;
	hdlc.src_size = len;
	hdlc.src_idx = 0;
	hdlc.dest_idx = 0;
	hdlc.escaping = 0;

	ret = diag_hdlc_decode(&hdlc);

	if (ret)
		type = diag_process_apps_pkt(driver->hdlc_buf,
							  hdlc.dest_idx - 3);
	else if (driver->debug_flag) {
		DIAGFWD_INFO("Packet dropped due to bad HDLC coding/CRC"
				" errors or partial packet received, packet"
				" length = %d\n", len);
		print_hex_dump(KERN_DEBUG, "Dropped Packet Data: ", DUMP_PREFIX_ADDRESS, 16, 1,
					    data, len, 1);
		driver->debug_flag = 0;
	}
#ifdef CONFIG_DIAG_NO_MODEM
	if (type == 1) { /* implies this packet is NOT meant for apps */
		if (driver->chqdsp)
			smd_write(driver->chqdsp, driver->hdlc_buf,
							 hdlc.dest_idx - 3);
		type = 0;
	}
#endif /* NO MODEM present */

#ifdef DIAG_DEBUG
	printk(KERN_INFO "\n hdlc.dest_idx = %d", hdlc.dest_idx);
	for (i = 0; i < hdlc.dest_idx; i++)
		printk(KERN_DEBUG "\t%x", *(((unsigned char *)
							driver->hdlc_buf)+i));
#endif /* DIAG DEBUG */
	/* ignore 2 bytes for CRC, one for 7E and send */
	if ((driver->ch) && (ret) && (type) && (hdlc.dest_idx > 3)) {
	/*	APPEND_DEBUG('g'); */
#if defined(CONFIG_ARCH_MSM8X60_LTE) || defined(CONFIG_ARCH_MSM8X60)
		smd_write(driver->ch, driver->hdlc_buf, hdlc.dest_idx - 3);
#else //defined(CONFIG_MACH_MECHA)
		smd_write(driver->ch, data, len);
#endif
		if (diag7k_debug_mask)
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", DUMP_PREFIX_ADDRESS, 16,
			       1, data, len, 1);
	/*	APPEND_DEBUG('h'); */
#ifdef DIAG_DEBUG
		printk(KERN_INFO "writing data to SMD, pkt length %d \n", len);
		print_hex_dump(KERN_DEBUG, "Written Packet Data to SMD: ", DUMP_PREFIX_ADDRESS, 16,
			       1, data, len, 1);
#endif /* DIAG DEBUG */
	}

}
Esempio n. 16
0
void __diag_smd_qdsp_send_req(void)
{
	void *buf = NULL;
	int *in_busy_qdsp_ptr = NULL;
	struct diag_request *write_ptr_qdsp = NULL;
#if  DIAG_XPST
	int type;
#endif
	if (!driver->in_busy_qdsp_1) {
		buf = driver->buf_in_qdsp_1;
		write_ptr_qdsp = driver->write_ptr_qdsp_1;
		in_busy_qdsp_ptr = &(driver->in_busy_qdsp_1);
	} else if (!driver->in_busy_qdsp_2) {
		buf = driver->buf_in_qdsp_2;
		write_ptr_qdsp = driver->write_ptr_qdsp_2;
		in_busy_qdsp_ptr = &(driver->in_busy_qdsp_2);
	}

	if (driver->chqdsp && buf) {
		int r = smd_read_avail(driver->chqdsp);

		if (r > IN_BUF_SIZE) {
			if (r < MAX_IN_BUF_SIZE) {
				DIAGFWD_INFO("\n diag: SMD sending in "
						   "packets upto %d bytes", r);
				buf = krealloc(buf, r, GFP_KERNEL);
			} else {
				DIAGFWD_ERR("\n diag: SMD sending in "
				"packets more than %d bytes", MAX_IN_BUF_SIZE);
			return;
		}
		}
		if (r > 0) {
			if (!buf)
				DIAGFWD_INFO("Out of diagmem for QDSP\n");
			else {
				/* APPEND_DEBUG('i'); */
					smd_read(driver->chqdsp, buf, r);

				if (diag7k_debug_mask) {
					switch (diag7k_debug_mask) {
					case 1:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from qdsp(first 16 bytes)", DUMP_PREFIX_ADDRESS, 16, 1, buf, 16, 1);
						break;
					case 2:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from qdsp(first 16 bytes)", DUMP_PREFIX_ADDRESS, 16, 1, buf, 16, 1);
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from qdsp(last 16 bytes) ", DUMP_PREFIX_ADDRESS, 16, 1, buf+r-16, 16, 1);
						break;
					default:
						print_hex_dump(KERN_DEBUG, "Read Packet Data"
						" from qdsp ", DUMP_PREFIX_ADDRESS, 16, 1, buf, r, 1);

					}
				}
#if  DIAG_XPST

		type = checkcmd_modem_epst(buf);
		if (type) {
			modem_to_userspace(buf, r, type, 0);
			return;
		}

#endif
			/* APPEND_DEBUG('j'); */
				write_ptr_qdsp->length = r;
				*in_busy_qdsp_ptr = 1;
				diag_device_write(buf, QDSP_DATA,
							 write_ptr_qdsp);
			}
		}
	}
}
Esempio n. 17
0
int diagfwd_init(void)
{
	diag_debug_buf_idx = 0;
	driver->read_len_legacy = 0;
	if (driver->buf_in_1 == NULL)
		driver->buf_in_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_1 == NULL)
			goto err;
	if (driver->buf_in_2 == NULL)
		driver->buf_in_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_2 == NULL)
			goto err;
	if (driver->buf_in_qdsp_1 == NULL)
		driver->buf_in_qdsp_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_qdsp_1 == NULL)
			goto err;
	if (driver->buf_in_qdsp_2 == NULL)
		driver->buf_in_qdsp_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_qdsp_2 == NULL)
			goto err;
	if (driver->usb_buf_out  == NULL &&
	     (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF,
					 GFP_KERNEL)) == NULL)
		goto err;
	if (driver->hdlc_buf == NULL
	    && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL)
		goto err;
	if (driver->msg_masks == NULL
	    && (driver->msg_masks = kzalloc(MSG_MASK_SIZE,
					     GFP_KERNEL)) == NULL)
		goto err;
	if (driver->log_masks == NULL &&
	    (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL)
		goto err;
	driver->log_masks_length = 8*MAX_EQUIP_ID;
	if (driver->event_masks == NULL &&
	    (driver->event_masks = kzalloc(EVENT_MASK_SIZE,
					    GFP_KERNEL)) == NULL)
		goto err;
	if (driver->client_map == NULL &&
	    (driver->client_map = kzalloc
	     ((driver->num_clients) * sizeof(struct diag_client_map),
		   GFP_KERNEL)) == NULL)
		goto err;
#if defined(CONFIG_MACH_MECHA) //|| defined(CONFIG_ARCH_MSM8X60_LTE)
	if (driver->buf_in_mdm_1 == NULL)
		driver->buf_in_mdm_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_mdm_1 == NULL)
			goto err;
	if (driver->buf_in_mdm_2 == NULL)
		driver->buf_in_mdm_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_mdm_2 == NULL)
			goto err;
#endif
#if defined(CONFIG_MACH_MECHA) || defined(CONFIG_ARCH_MSM8X60_LTE)
	if (driver->mdmclient_map == NULL &&
	    (driver->mdmclient_map = kzalloc
	     ((driver->num_mdmclients) * sizeof(struct diag_client_map),
		   GFP_KERNEL)) == NULL)
		goto err;
#endif
	if (driver->buf_tbl == NULL)
			driver->buf_tbl = kzalloc(buf_tbl_size *
			  sizeof(struct diag_write_device), GFP_KERNEL);
	if (driver->buf_tbl == NULL)
		goto err;
#if 0//defined(CONFIG_MACH_MECHA) || defined(CONFIG_ARCH_MSM8X60_LTE)
	if (driver->mdmbuf_tbl == NULL)
			driver->mdmbuf_tbl = kzalloc(buf_tbl_size *
			  sizeof(struct diag_write_device), GFP_KERNEL);
	if (driver->mdmbuf_tbl == NULL)
		goto err;
#endif
	if (driver->data_ready == NULL &&
	     (driver->data_ready = kzalloc(driver->num_clients * sizeof(int)
					 , GFP_KERNEL)) == NULL)
		goto err;
#if defined(CONFIG_MACH_MECHA) || defined(CONFIG_ARCH_MSM8X60_LTE)
	if (driver->mdmdata_ready == NULL &&
	     (driver->mdmdata_ready = kzalloc(driver->num_mdmclients * sizeof(struct
					 diag_client_map), GFP_KERNEL)) == NULL)
		goto err;
#endif
	if (driver->table == NULL &&
	     (driver->table = kzalloc(diag_max_registration*
				      sizeof(struct diag_master_table),
				       GFP_KERNEL)) == NULL)
		goto err;
	if (driver->write_ptr_1 == NULL)
		driver->write_ptr_1 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_1 == NULL)
					goto err;
	if (driver->write_ptr_2 == NULL)
		driver->write_ptr_2 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_2 == NULL)
			goto err;
	if (driver->write_ptr_qdsp_1 == NULL)
		driver->write_ptr_qdsp_1 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_qdsp_1 == NULL)
			goto err;
	if (driver->write_ptr_qdsp_2 == NULL)
		driver->write_ptr_qdsp_2 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_qdsp_2 == NULL)
			goto err;
#if defined(CONFIG_MACH_MECHA) //|| defined(CONFIG_ARCH_MSM8X60_LTE)
	if (driver->write_ptr_mdm_1 == NULL)
			driver->write_ptr_mdm_1 = kzalloc(
				sizeof(struct diag_request), GFP_KERNEL);
			if (driver->write_ptr_mdm_1 == NULL)
					goto err;
	if (driver->write_ptr_mdm_2 == NULL)
			driver->write_ptr_mdm_2 = kzalloc(
				sizeof(struct diag_request), GFP_KERNEL);
			if (driver->write_ptr_mdm_2 == NULL)
					goto err;
#endif
	if (driver->usb_read_ptr == NULL)
			driver->usb_read_ptr = kzalloc(
				sizeof(struct diag_request), GFP_KERNEL);
			if (driver->usb_read_ptr == NULL)
				goto err;
	if (driver->pkt_buf == NULL &&
	     (driver->pkt_buf = kzalloc(PKT_SIZE,
					 GFP_KERNEL)) == NULL)
		goto err;
#ifdef CONFIG_DIAG_NO_MODEM
	if (driver->apps_rsp_buf == NULL)
			driver->apps_rsp_buf = kzalloc(150, GFP_KERNEL);
		if (driver->apps_rsp_buf == NULL)
			goto err;
#endif
	driver->diag_wq = create_singlethread_workqueue("diag_wq");
#ifdef CONFIG_DIAG_OVER_USB
	INIT_WORK(&(driver->diag_proc_hdlc_work), diag_process_hdlc_fn);
	INIT_WORK(&(driver->diag_read_work), diag_read_work_fn);
	diag_setup();
#ifndef CONFIG_ARCH_MSM8X60_LTE
	driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver,
			diag_usb_legacy_notifier);
	if (IS_ERR(driver->legacy_ch)) {
		DIAGFWD_ERR("Unable to open USB diag legacy channel\n");
		goto err;
	}
#endif
#endif
	mutex_init(&driver->smd_lock);
#ifdef CONFIG_ARCH_MSM8X60_LTE
#if defined(CONFIG_USB_ANDROID_LTE_DIAG)
	diag_ch_sdio = 0;
	diagfwd_sdio_init(DIAG_MDM);
#else
	diag_ch_sdio = 1;
	diagfwd_sdio_init(DIAG_LEGACY);
#endif
#endif
	platform_driver_register(&msm_smd_ch1_driver);

	DIAGFWD_INFO("\n diag_debug_buf %p %p\n", diag_debug_buf, &diag_debug_buf);
	DIAGFWD_INFO("\n diag_debug_buf_idx %p\n", &diag_debug_buf_idx);


#if defined(CONFIG_MACH_MECHA)
	if (sdio_diag_init_enable)
		sdio_diag_init();
#endif
	return diag_ch_sdio;
err:
		DIAGFWD_INFO("\n Could not initialize diag buffers\n");
		kfree(driver->buf_in_1);
		kfree(driver->buf_in_2);
		kfree(driver->buf_in_qdsp_1);
		kfree(driver->buf_in_qdsp_2);
		kfree(driver->usb_buf_out);
		kfree(driver->hdlc_buf);
		kfree(driver->msg_masks);
		kfree(driver->log_masks);
		kfree(driver->event_masks);
		kfree(driver->client_map);
		kfree(driver->buf_tbl);
		kfree(driver->data_ready);
#if defined(CONFIG_MACH_MECHA) //|| defined(CONFIG_ARCH_MSM8X60_LTE)
		kfree(driver->mdmclient_map);
		//kfree(driver->mdmbuf_tbl);
		kfree(driver->mdmdata_ready);
#endif
		kfree(driver->table);
		kfree(driver->pkt_buf);
		kfree(driver->write_ptr_1);
		kfree(driver->write_ptr_2);
		kfree(driver->write_ptr_qdsp_1);
		kfree(driver->write_ptr_qdsp_2);
#if defined(CONFIG_MACH_MECHA) //|| defined(CONFIG_ARCH_MSM8X60_LTE)
		kfree(driver->write_ptr_mdm_1);
		kfree(driver->write_ptr_mdm_2);
#endif
		kfree(driver->usb_read_ptr);
#ifdef CONFIG_DIAG_NO_MODEM
		kfree(driver->apps_rsp_buf);
#endif
		if (driver->diag_wq)
			destroy_workqueue(driver->diag_wq);
		return 0;
}
Esempio n. 18
0
void diagfwd_init(void)
{
	diag_debug_buf_idx = 0;
	driver->read_len_legacy = 0;

	/* FIXME: there should be a better way to know if wcnss enabled */
	if (chk_config_get_id() == AO8960_TOOLS_ID) {
		is_wcnss_used = 1;
		DIAGFWD_INFO("wcnss channel was enabled in the platform\n");
	} else {
		is_wcnss_used = 0;
		DIAGFWD_INFO("wcnss channel was not enabled in the platform\n");
	}

	if (driver->buf_in_1 == NULL) {
		driver->buf_in_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_1 == NULL)
			goto err;
	}
	if (driver->buf_in_2 == NULL) {
		driver->buf_in_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_2 == NULL)
			goto err;
	}
	if (driver->buf_in_qdsp_1 == NULL) {
		driver->buf_in_qdsp_1 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_qdsp_1 == NULL)
			goto err;
	}
	if (driver->buf_in_qdsp_2 == NULL) {
		driver->buf_in_qdsp_2 = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_qdsp_2 == NULL)
			goto err;
	}
	if (is_wcnss_used && driver->buf_in_wcnss == NULL) {
		driver->buf_in_wcnss = kzalloc(IN_BUF_SIZE, GFP_KERNEL);
		if (driver->buf_in_wcnss == NULL)
			goto err;
	}
	if (driver->usb_buf_out  == NULL &&
	     (driver->usb_buf_out = kzalloc(USB_MAX_OUT_BUF,
					 GFP_KERNEL)) == NULL)
		goto err;
	if (driver->hdlc_buf == NULL
	    && (driver->hdlc_buf = kzalloc(HDLC_MAX, GFP_KERNEL)) == NULL)
		goto err;
	if (driver->user_space_data == NULL)
		driver->user_space_data = kzalloc(USER_SPACE_DATA, GFP_KERNEL);
		if (driver->user_space_data == NULL)
			goto err;
	if (driver->msg_masks == NULL
	    && (driver->msg_masks = kzalloc(MSG_MASK_SIZE,
					     GFP_KERNEL)) == NULL)
		goto err;
	if (driver->log_masks == NULL &&
	    (driver->log_masks = kzalloc(LOG_MASK_SIZE, GFP_KERNEL)) == NULL)
		goto err;
	driver->log_masks_length = 8*MAX_EQUIP_ID;
	if (driver->event_masks == NULL &&
	    (driver->event_masks = kzalloc(EVENT_MASK_SIZE,
					    GFP_KERNEL)) == NULL)
		goto err;
	if (driver->client_map == NULL &&
	    (driver->client_map = kzalloc
	     ((driver->num_clients) * sizeof(struct diag_client_map),
		   GFP_KERNEL)) == NULL)
		goto err;
#ifdef CONFIG_DIAG_SDIO_PIPE
	if (driver->mdmclient_map == NULL &&
	    (driver->mdmclient_map = kzalloc
	     ((driver->num_mdmclients) * sizeof(struct diag_client_map),
		   GFP_KERNEL)) == NULL)
		goto err;
#endif
	if (driver->buf_tbl == NULL)
			driver->buf_tbl = kzalloc(buf_tbl_size *
			  sizeof(struct diag_write_device), GFP_KERNEL);
	if (driver->buf_tbl == NULL)
		goto err;
	if (driver->data_ready == NULL &&
	     (driver->data_ready = kzalloc(driver->num_clients * sizeof(int)
							, GFP_KERNEL)) == NULL)
		goto err;
#ifdef CONFIG_DIAG_SDIO_PIPE
	if (driver->mdmdata_ready == NULL &&
	     (driver->mdmdata_ready = kzalloc(driver->num_mdmclients * sizeof(struct
					 diag_client_map), GFP_KERNEL)) == NULL)
		goto err;
#endif
	if (driver->table == NULL &&
	     (driver->table = kzalloc(diag_max_registration*
		      sizeof(struct diag_master_table),
		       GFP_KERNEL)) == NULL)
		goto err;
	if (driver->write_ptr_1 == NULL) {
		driver->write_ptr_1 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_1 == NULL)
			goto err;
	}
	if (driver->write_ptr_2 == NULL) {
		driver->write_ptr_2 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_2 == NULL)
			goto err;
	}
	if (driver->write_ptr_qdsp_1 == NULL) {
		driver->write_ptr_qdsp_1 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_qdsp_1 == NULL)
			goto err;
	}
	if (driver->write_ptr_qdsp_2 == NULL) {
		driver->write_ptr_qdsp_2 = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_qdsp_2 == NULL)
			goto err;
	}
	if (driver->write_ptr_wcnss == NULL) {
		driver->write_ptr_wcnss = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->write_ptr_wcnss == NULL)
			goto err;
	}
	if (driver->usb_read_ptr == NULL) {
		driver->usb_read_ptr = kzalloc(
			sizeof(struct diag_request), GFP_KERNEL);
		if (driver->usb_read_ptr == NULL)
			goto err;
	}
	if (driver->pkt_buf == NULL &&
	     (driver->pkt_buf = kzalloc(PKT_SIZE,
			 GFP_KERNEL)) == NULL)
		goto err;
	if (driver->apps_rsp_buf == NULL) {
			driver->apps_rsp_buf = kzalloc(500, GFP_KERNEL);
		if (driver->apps_rsp_buf == NULL)
			goto err;
	}
	driver->diag_wq = create_singlethread_workqueue("diag_wq");
#ifdef CONFIG_DIAG_OVER_USB
	INIT_WORK(&(driver->diag_proc_hdlc_work), diag_process_hdlc_fn);
	INIT_WORK(&(driver->diag_read_work), diag_read_work_fn);
	driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver,
			diag_usb_legacy_notifier);
	if (IS_ERR(driver->legacy_ch)) {
		printk(KERN_ERR "Unable to open USB diag legacy channel\n");
		goto err;
	}
#endif
#if DIAG_XPST
	mutex_init(&driver->smd_lock);
#endif
	platform_driver_register(&msm_smd_ch1_driver);
	platform_driver_register(&diag_smd_lite_driver);

	return;
err:
		pr_err("diag: Could not initialize diag buffers");
		kfree(driver->buf_in_1);
		kfree(driver->buf_in_2);
		kfree(driver->buf_in_qdsp_1);
		kfree(driver->buf_in_qdsp_2);
		kfree(driver->buf_in_wcnss);
		kfree(driver->usb_buf_out);
		kfree(driver->hdlc_buf);
		kfree(driver->msg_masks);
		kfree(driver->log_masks);
		kfree(driver->event_masks);
		kfree(driver->client_map);
		kfree(driver->buf_tbl);
		kfree(driver->data_ready);
		kfree(driver->table);
		kfree(driver->pkt_buf);
		kfree(driver->write_ptr_1);
		kfree(driver->write_ptr_2);
		kfree(driver->write_ptr_qdsp_1);
		kfree(driver->write_ptr_qdsp_2);
		kfree(driver->write_ptr_wcnss);
		kfree(driver->usb_read_ptr);
		kfree(driver->apps_rsp_buf);
		kfree(driver->user_space_data);
		if (driver->diag_wq)
			destroy_workqueue(driver->diag_wq);
}
Esempio n. 19
0
void diagfwd_bridge_init(void)
{
	int ret;

	DIAGFWD_INFO("diag: in %s\n", __func__);
	driver->diag_bridge_wq = create_singlethread_workqueue(
							"diag_bridge_wq");
	driver->read_len_mdm = 0;
	driver->write_len_mdm = 0;
	driver->num_hsic_buf_tbl_entries = 0;
	spin_lock_init(&driver->hsic_spinlock);
	if (driver->usb_buf_mdm_out  == NULL)
		driver->usb_buf_mdm_out = kzalloc(USB_MAX_OUT_BUF,
							 GFP_KERNEL);
	if (driver->usb_buf_mdm_out == NULL)
		goto err;
	
	if (driver->write_ptr_mdm == NULL)
		driver->write_ptr_mdm = kzalloc(
		sizeof(struct diag_request), GFP_KERNEL);
	if (driver->write_ptr_mdm == NULL)
		goto err;
	if (driver->usb_read_mdm_ptr == NULL)
		driver->usb_read_mdm_ptr = kzalloc(
		sizeof(struct diag_request), GFP_KERNEL);
	if (driver->usb_read_mdm_ptr == NULL)
		goto err;

	if (driver->hsic_buf_tbl == NULL)
		driver->hsic_buf_tbl = kzalloc(NUM_HSIC_BUF_TBL_ENTRIES *
				sizeof(struct diag_write_device), GFP_KERNEL);
	if (driver->hsic_buf_tbl == NULL)
		goto err;

	driver->count_hsic_pool = 0;
	driver->count_hsic_write_pool = 0;

	driver->qxdmusb_drop = 1;

	driver->itemsize_hsic = READ_HSIC_BUF_SIZE;
	driver->poolsize_hsic = N_MDM_WRITE;
	driver->itemsize_hsic_write = sizeof(struct diag_request);
	driver->poolsize_hsic_write = N_MDM_WRITE;

#ifdef CONFIG_DIAG_OVER_USB
	INIT_WORK(&(driver->diag_read_mdm_work), diag_read_mdm_work_fn);
#endif
	INIT_WORK(&(driver->diag_disconnect_work), diag_disconnect_work_fn);
	INIT_WORK(&(driver->diag_usb_read_complete_work),
			diag_usb_read_complete_fn);
#ifdef CONFIG_DIAG_OVER_USB
	driver->mdm_ch = usb_diag_open(DIAG_MDM, driver,
						 diagfwd_bridge_notifier);
	if (IS_ERR(driver->mdm_ch)) {
		pr_err("diag: Unable to open USB diag MDM channel\n");
		goto err;
	}
#endif
	
	ret = platform_driver_register(&msm_hsic_ch_driver);
	if (ret)
		pr_err("diag: could not register HSIC device, ret: %d\n", ret);
	
	ret = platform_driver_register(&msm_diagfwd_smux_driver);
	if (ret)
		pr_err("diag: could not register SMUX device, ret: %d\n", ret);

	return;
err:
	pr_err("diag: Could not initialize for bridge forwarding\n");
	kfree(driver->usb_buf_mdm_out);
	kfree(driver->hsic_buf_tbl);
	kfree(driver->write_ptr_mdm);
	kfree(driver->usb_read_mdm_ptr);
	if (driver->diag_bridge_wq)
		destroy_workqueue(driver->diag_bridge_wq);

	return;
}