コード例 #1
0
ファイル: gp_spi.c プロジェクト: WayWingsDev/Gplus_2159_0801
/**
 * @brief   spi device write
 */
static ssize_t gp_spi_dev_write(struct file *file, const char __user *buf,size_t count, loff_t *oppos)
{
	int ret = 0;
	char *sendBuf = NULL;

	if(NULL == file->private_data){
		DIAG_INFO("gp_spi_writ erro\n");
		return -EINVAL;
	}
	
	sendBuf = (char *)kmalloc(count, GFP_KERNEL);

	if(NULL == sendBuf){
		DIAG_INFO("gp_spi_write alloc fail\n");
		return -ENOMEM;
	}

	if(copy_from_user(sendBuf,buf,count)){
		ret = -EFAULT;
		DIAG_INFO("gp_spi_write copy fail\n");
		goto __erroCopy;
	}

	gp_spi_write((int)file->private_data, sendBuf, count);

	
__erroCopy:
	kfree(sendBuf);
	return ret;
}
コード例 #2
0
static int diagcharmdm_close(struct inode *inode, struct file *file)
{

	int i = 0;

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

	if (driver) {
		mutex_lock(&driver->diagcharmdm_mutex);

		driver->ref_count--;
		/* On Client exit, try to destroy all 3 pools */
		diagmem_exit(driver, POOL_TYPE_COPY);
		diagmem_exit(driver, POOL_TYPE_HDLC);
		diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT);

		for (i = 0; i < driver->num_mdmclients; i++)
			if (driver->mdmclient_map[i].pid == current->tgid) {
				driver->mdmclient_map[i].pid = 0;
				break;
			}

		if (i < driver->num_mdmclients)
			DIAG_INFO("%s:#%d(%d) %s close\n", __func__,
				i, current->tgid, current->comm);
		else
			DIAG_WARNING("%s: nothing close\n", __func__);
		mutex_unlock(&driver->diagcharmdm_mutex);
		return 0;
	}

	return -ENOMEM;
}
コード例 #3
0
ファイル: gp_spi.c プロジェクト: WayWingsDev/Gplus_2159_0801
/**
 * @brief   spi device read
 */
static ssize_t gp_spi_dev_read(struct file *file, char __user *buf,size_t count, loff_t *oppos)
{
	int ret = 0;
	char *recvBuf = NULL;

	if(NULL == file->private_data){
		DIAG_INFO("gp_spi_read erro\n");
		return -EINVAL;
	}
	
	recvBuf = (char *)kmalloc(count, GFP_KERNEL);

	if(NULL == recvBuf){
		DIAG_INFO("gp_spi_read alloc mem fail\n");
		return -ENOMEM;
	}

	gp_spi_read((int)file->private_data, recvBuf, count);

	if(copy_to_user(buf,recvBuf,count)){
		DIAG_INFO("gp_spi_read copy fail\n");
		ret = -EFAULT;
	}

	kfree(recvBuf);

	return ret;
}
コード例 #4
0
ファイル: diagchar_core.c プロジェクト: Snuzzo/htc8960-3.0
static long diagcharmdm_ioctl(struct file *filp,
		unsigned int iocmd, unsigned long ioarg)
{
	int success = -1;

	if (iocmd == DIAG_IOCTL_SWITCH_LOGGING) {
		mutex_lock(&driver->diagcharmdm_mutex);
		driver->logging_mode = (int)ioarg;
		driver->logging_process_id = current->tgid;
		mutex_unlock(&driver->diagcharmdm_mutex);
		if (driver->logging_mode == MEMORY_DEVICE_MODE) {
			DIAG_INFO("diagcharmdm_ioctl enable\n");
			diagfwd_disconnect();
			driver->qxdm2sd_drop = 0;
			driver->in_busy_sdio_1 = 0;
			driver->in_busy_sdio_2 = 0;
			buf_9k = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL);
			if (driver->sdio_ch)
				queue_work(driver->diag_sdio_wq, &(driver->diag_read_sdio_work));

		} else if (driver->logging_mode == USB_MODE) {
			DIAG_INFO("diagcharmdm_ioctl disable\n");
			diagfwd_connect();
			driver->qxdm2sd_drop = 1;

			kfree(buf_9k);
		}
		success = 1;
	}
	return success;
}
コード例 #5
0
static int diagcharmdm_ioctl(struct inode *inode, struct file *filp,
			   unsigned int iocmd, unsigned long ioarg)
{
	int success = -1;

#if defined(CONFIG_MACH_MECHA)
	if (!sdio_diag_initialized) {
		DIAG_INFO("sdio diag isn't in embedded mode \n");
		return 0;
	}
#endif

	if (iocmd == DIAG_IOCTL_SWITCH_LOGGING) {
		mutex_lock(&driver->diagcharmdm_mutex);
		driver->logging_mode = (int)ioarg;
		driver->logging_process_id = current->tgid;
		mutex_unlock(&driver->diagcharmdm_mutex);
		if (driver->logging_mode == MEMORY_DEVICE_MODE) {
			DIAG_INFO("diagcharmdm_ioctl enable\n");
			diagfwd_disconnect();
			driver->qxdm2sd_drop = 0;
#if defined(CONFIG_MACH_MECHA)
			driver->in_busy_mdm_1 = 0;
			driver->in_busy_mdm_2 = 0;
			/* Poll SMD channels to check for data*/
			queue_work(driver->mdm_diag_workqueue, &(driver->diag_read_smd_mdm_work));
#endif
#if defined(CONFIG_ARCH_MSM8X60_LTE)
				driver->in_busy_sdio_1 = 0;
				driver->in_busy_sdio_2 = 0;
				buf_9k = kzalloc(USB_MAX_OUT_BUF, GFP_KERNEL);
				if (driver->sdio_ch)
					queue_work(driver->diag_sdio_wq, &(driver->diag_read_sdio_work));
#endif

		} else if (driver->logging_mode == USB_MODE) {
			DIAG_INFO("diagcharmdm_ioctl disable\n");
			diagfwd_connect();
			driver->qxdm2sd_drop = 1;
#if defined(CONFIG_MACH_MECHA)
			driver->in_busy_mdm_1 = 1;
			driver->in_busy_mdm_2 = 1;
#endif
#if defined(CONFIG_ARCH_MSM8X60_LTE)
			kfree(buf_9k);
#endif

				}
		success = 1;
	}

	return success;


	return 0;

}
コード例 #6
0
static int diagchar_setup_cdev(dev_t devno)
{
	int err;
	struct device	*diagdev;

	cdev_init(driver->cdev, &diagcharfops);

	driver->cdev->owner = THIS_MODULE;
	driver->cdev->ops = &diagcharfops;

	err = cdev_add(driver->cdev, devno, 1);

	if (err) {
		printk(KERN_INFO "diagchar cdev registration failed !\n\n");
		return -1;
	}

	driver->diagchar_class = class_create(THIS_MODULE, "diag");

	if (IS_ERR(driver->diagchar_class)) {
		printk(KERN_ERR "Error creating diagchar class.\n");
		return -1;
	}

	diagdev = device_create(driver->diagchar_class, NULL, devno,
				  (void *)driver, "diag");


	err = 	device_create_file(diagdev, &dev_attr_diag_reg_table);
	if (err)
		DIAG_INFO("dev_attr_diag_reg_table registration failed !\n\n");
	err = 	device_create_file(diagdev, &dev_attr_diag7k_debug_mask);
	if (err)
		DIAG_INFO("dev_attr_diag7k_debug_mask registration failed !\n\n");
	err = 	device_create_file(diagdev, &dev_attr_diag9k_debug_mask);
	if (err)
		DIAG_INFO("dev_attr_diag9k_debug_mask registration failed !\n\n");

#ifdef CONFIG_DIAG_SDIO_PIPE
	cdev_init(driver->cdev_mdm, &diagcharmdmfops);

	driver->cdev_mdm->owner = THIS_MODULE;
	driver->cdev_mdm->ops = &diagcharmdmfops;

	err = cdev_add(driver->cdev_mdm, devno+1, 1);

	if (err) {
		DIAG_ERR("diagchar cdev mdm registration failed !\n\n");
		return -1;
	}

	device_create(driver->diagchar_class, NULL, devno+1, (void *)driver, "diag_mdm");
#endif
	return 0;

}
コード例 #7
0
static void __exit diagchar_exit(void)
{
	DIAG_INFO("diagchar exiting ..\n");
	/* On Driver exit, send special pool type to
	 ensure no memory leaks */
	diagmem_exit(driver, POOL_TYPE_ALL);
	diagfwd_exit();
#if defined(CONFIG_ARCH_MSM8X60_LTE)
	diagfwd_sdio_exit();
#endif
	diagchar_cleanup();
	DIAG_INFO("done diagchar exit\n");
}
コード例 #8
0
static int diagcharmdm_open(struct inode *inode, struct file *file)
{
	int i = 0;
#if defined(CONFIG_MACH_MECHA)
	if (!sdio_diag_initialized) {
		DIAG_INFO("sdio diag isn't in embedded mode \n");
		return 0;
	}
#endif

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

	if (driver) {
		mutex_lock(&driver->diagcharmdm_mutex);

		for (i = 0; i < driver->num_mdmclients; i++)
			if (driver->mdmclient_map[i].pid == 0)
				break;

		if (i < driver->num_mdmclients) {
			driver->mdmclient_map[i].pid = current->tgid;
			strncpy(driver->mdmclient_map[i].name, current->comm, 20);
			driver->mdmclient_map[i].name[19] = '\0';
		} else {
			mutex_unlock(&driver->diagcharmdm_mutex);
			DIAG_INFO("%s:reach max client count\n", __func__);
			for (i = 0; i < driver->num_mdmclients; i++)
				DIAG_WARNING("%d) %s PID=%d", i, driver->
					mdmclient_map[i].name,
					driver->mdmclient_map[i].pid);
			return -ENOMEM;
		}

		driver->mdmdata_ready[i] |= MSG_MASKS_TYPE;
		driver->mdmdata_ready[i] |= EVENT_MASKS_TYPE;
		driver->mdmdata_ready[i] |= LOG_MASKS_TYPE;

#if defined(CONFIG_ARCH_MSM8X60_LTE)
		if (driver->ref_count == 0)
			diagmem_init(driver);
		driver->ref_count++;
#endif
		mutex_unlock(&driver->diagcharmdm_mutex);
		return 0;
	}

	return -ENOMEM;

}
コード例 #9
0
static int diag_sdio_probe(struct platform_device *pdev)
{
	int err;
	if (diag9k_debug_mask)
		DIAG_INFO("%s\n", __func__);

	err = sdio_open("SDIO_DIAG", &driver->sdio_ch, driver,
							 diag_sdio_notify);
	if (err)
		DIAG_ERR("DIAG could not open SDIO channel");
	else {
		DIAG_INFO("DIAG opened SDIO channel");

		if (!strcmp(DIAG_LEGACY, usb_ch_name)) {
			driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver,
				diag_usb_legacy_notifier);
			if (IS_ERR(driver->legacy_ch)) {
				DIAG_ERR("Unable to open USB diag legacy channel\n");
				goto err;
			}
			DIAG_INFO("open USB diag legacy channel\n");
		} else if (!strcmp(DIAG_MDM, usb_ch_name)) {
			driver->legacy_ch = usb_diag_open(DIAG_LEGACY, driver,
				diag_usb_legacy_notifier);
			if (IS_ERR(driver->legacy_ch)) {
				DIAG_ERR("Unable to open USB diag legacy channel\n");
				goto err;
			}
			DIAG_INFO("open USB diag legacy channel\n");

			driver->mdm_ch = usb_diag_open(DIAG_MDM, driver,
				diag_usb_legacy_notifier);
			if (IS_ERR(driver->mdm_ch)) {
				DIAG_ERR("Unable to open USB diag MDM channel\n");
				goto err;
			}
			DIAG_INFO("open USB diag MDM channel\n");
		}
/*		queue_work(driver->diag_sdio_wq, &(driver->diag_read_mdm_work));*/
	}
	if (diag_configured)
		diagfwd_connect();
	driver->in_busy_sdio_1 = 0;
	driver->in_busy_sdio_2 = 0;
	driver->qxdm2sd_drop = 0;
	sdio_diag_initialized = 1;
err:
	return err;
}
コード例 #10
0
static  int s35390a_init(void)
{
	unsigned char reg1 = 0;
	unsigned int ret = 0;
	
	
	/*Check Frist Start Up*/
	ret = s35390a_check_started(&reg1);
	if( ret != SP_OK ) {
		DIAG_ERROR("[%s]External RTC init fail!\n", __FUNCTION__);
		return ret;
	}

	/*Set 12/24 format*/
	ret = s35390a_set_12or24_format(1);
	if( ret != SP_OK ) {
		DIAG_ERROR("[%s]Set External RTC 12/24 format fail!\n", __FUNCTION__);
		return ret;
	}

	/*Reset External RTC EXT_RTC_ADJ_REG*/
	ret = s35390a_set_adjust(0x82 ); /* +1 ppm */

	ret = s35390a_clear_alarm_int();
	
	DIAG_INFO("External RTC initialize OK!\n");
	return SP_OK;
}
コード例 #11
0
void diag_read_mdm_work_fn(struct work_struct *work)
{
		if (diag9k_debug_mask)
		DIAG_INFO("%s \n", __func__);

	if (driver->sdio_ch) {
		wait_event_interruptible(driver->wait_q, (sdio_write_avail
				(driver->sdio_ch) >= driver->read_len_mdm));
		if (!strcmp(DIAG_MDM, usb_ch_name)) {
			if (driver->sdio_ch && driver->usb_buf_mdm_out &&
						 (driver->read_len_mdm > 0))
				sdio_write(driver->sdio_ch, driver->usb_buf_mdm_out,
							 driver->read_len_mdm);

		} else {
			if (driver->sdio_ch && driver->usb_read_ptr &&
						 (driver->read_len_mdm > 0))
				sdio_write(driver->sdio_ch, driver->usb_buf_out,
							 driver->read_len_mdm);

		}

		APPEND_DEBUG('x');
		if (!strcmp(DIAG_MDM, usb_ch_name)) {
			driver->usb_read_mdm_ptr->buf = driver->usb_buf_mdm_out;
			driver->usb_read_mdm_ptr->length = USB_MAX_OUT_BUF;
			usb_diag_read(driver->mdm_ch, driver->usb_read_mdm_ptr);
		} else {
			driver->usb_read_ptr->buf = driver->usb_buf_out;
			driver->usb_read_ptr->length = USB_MAX_OUT_BUF;
			usb_diag_read(driver->legacy_ch, driver->usb_read_ptr);
		}
		APPEND_DEBUG('y');
	}
}
コード例 #12
0
static int diagchar_setup_cdev(dev_t devno)
{
	int err;
	dev_t tmp_devno;
	struct device	*diagdev;


	tmp_devno = MKDEV(driver->major, driver->minor_start);

	cdev_init(driver->cdev, &diagcharfops);

	driver->cdev->owner = THIS_MODULE;
	driver->cdev->ops = &diagcharfops;

	err = cdev_add(driver->cdev, tmp_devno, 1);

	if (err) {
		DIAG_ERR("diagchar cdev registration failed !\n\n");
		return -1;
	}

	driver->diagchar_class = class_create(THIS_MODULE, "diag");

	if (IS_ERR(driver->diagchar_class)) {
		DIAG_ERR("Error creating diagchar class.\n");
		return -1;
	}

	diagdev = device_create(driver->diagchar_class, NULL, tmp_devno,
				  (void *)driver, "diag");


	err = 	device_create_file(diagdev, &dev_attr_diag_trace);
	if (err)
		DIAG_INFO("dev_attr_diag_trace registration failed !\n\n");

#if defined(CONFIG_MACH_MECHA) || defined(CONFIG_ARCH_MSM8X60_LTE)
	tmp_devno = MKDEV(driver->major, driver->minor_start+1);

	cdev_init(driver->cdev_mdm, &diagcharmdmfops);

	driver->cdev_mdm->owner = THIS_MODULE;
	driver->cdev_mdm->ops = &diagcharmdmfops;

	err = cdev_add(driver->cdev_mdm, tmp_devno, 1);

	if (err) {
		DIAG_ERR("diagchar cdev mdm registration failed !\n\n");
		return -1;
	}

	device_create(driver->diagchar_class, NULL, tmp_devno,
				  (void *)driver, "diag_mdm");
#endif
	return 0;

}
コード例 #13
0
static void diag_remove_sdio_work_fn(struct work_struct *work)
{
	DIAG_INFO("diag: sdio remove called\n");
	/*Disable SDIO channel to prevent further read/write */
	driver->sdio_ch = NULL;
	sdio_diag_initialized = 0;
	driver->in_busy_sdio_1 = 1;
	driver->in_busy_sdio_2 = 1;
}
コード例 #14
0
static int diagcharmdm_open(struct inode *inode, struct file *file)
{
	int i = 0;

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

	if (driver) {
		mutex_lock(&driver->diagcharmdm_mutex);

		for (i = 0; i < driver->num_mdmclients; i++)
			if (driver->mdmclient_map[i].pid == 0)
				break;

		if (i < driver->num_mdmclients) {
			driver->mdmclient_map[i].pid = current->tgid;
			strncpy(driver->mdmclient_map[i].name, current->comm, 20);
			driver->mdmclient_map[i].name[19] = '\0';
		} else {
			mutex_unlock(&driver->diagcharmdm_mutex);
			DIAG_INFO("%s:reach max client count\n", __func__);
			for (i = 0; i < driver->num_clients; i++)
				DIAG_WARNING("%d) %s PID=%d", i, driver->
					mdmclient_map[i].name,
					driver->mdmclient_map[i].pid);
			return -ENOMEM;
		}

		driver->mdmdata_ready[i] |= MSG_MASKS_TYPE;
		driver->mdmdata_ready[i] |= EVENT_MASKS_TYPE;
		driver->mdmdata_ready[i] |= LOG_MASKS_TYPE;

		if (driver->ref_count == 0)
			diagmem_init(driver);
		driver->ref_count++;

		mutex_unlock(&driver->diagcharmdm_mutex);
		return 0;
	}

	return -ENOMEM;

}
コード例 #15
0
static int diagcharmdm_close(struct inode *inode, struct file *file)
{

	int i = 0;
#if defined(CONFIG_MACH_MECHA)
	if (!sdio_diag_initialized) {
		DIAG_INFO("sdio diag isn't in embedded mode \n");
		return 0;
	}
#endif

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

	if (driver) {
		mutex_lock(&driver->diagcharmdm_mutex);

#if defined(CONFIG_ARCH_MSM8X60_LTE)
		driver->ref_count--;
		/* On Client exit, try to destroy all 3 pools */
		diagmem_exit(driver, POOL_TYPE_COPY);
		diagmem_exit(driver, POOL_TYPE_HDLC);
		diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT);

#endif

		for (i = 0; i < driver->num_mdmclients; i++)
			if (driver->mdmclient_map[i].pid == current->tgid) {
				driver->mdmclient_map[i].pid = 0;
				break;
			}

		if (i < driver->num_mdmclients)
			DIAG_INFO("%s:#%d(%d) %s close\n", __func__,
				i, current->tgid, current->comm);
		else
			DIAG_WARNING("%s: nothing close\n", __func__);
		mutex_unlock(&driver->diagcharmdm_mutex);
		return 0;
	}

	return -ENOMEM;
}
コード例 #16
0
void test_serverInit(void)
{
	SYSTEM_STATUS result = STATUS_FAIL;

	printf(">>>>>>>>>>>>>>>>>\n");
	DIAG_INFO("TEST: Server initialization.");
	result = eLibrary_serverInit();
	CU_ASSERT_EQUAL(result, STATUS_OK);
	printf(">>>>>>>>>>>>>>>>>\n");
}
コード例 #17
0
void str_echo(int fd)
{
	ssize_t n = -1;
	char buf[LINELEN_MAX];

	bzero(buf, LINELEN_MAX);

	while (1)
	{
		DIAG_INFO("Server: reading! \n");
		n = read(fd, buf, LINELEN_MAX);
		if (n > 0)
		{
			uint32_t result = 0;
			struct user_info
			{
				char name[20];
				char email[30];
				uint8_t age;
			} user_info_t;


			memcpy(user_info_t.name, buf, 20);
			memcpy(user_info_t.email, buf+20, 30);
			memcpy(&user_info_t.age, buf+50, 1);

			DIAG_INFO("Server - Name: %s; Email: %s; Age: %d.", user_info_t.name, user_info_t.email, user_info_t.age);
//			DIAG_INFO("Server: Received string %s (%d bytes)\n", buf, n);
			write(fd, buf, n);
		}
		else
		{
			DIAG_INFO("Server: EOF or failure by read()");
			break;
		}
	}

	if (n < 0)
	{
		DIAG_INFO("Server: Read failed. Errno = %#x\n", errno);
	}
}
コード例 #18
0
int diagfwd_disconnect_sdio(void)
{
	DIAG_INFO("%s \n", __func__);

	/* Clear variable to Flush remaining data from SDIO channel */
	driver->in_busy_sdio_1 = 0;
	driver->in_busy_sdio_2 = 0;
	if (!strcmp(DIAG_MDM, usb_ch_name)) {
		usb_diag_free_req(driver->mdm_ch);
	}
	return 0;
}
コード例 #19
0
int main(int argc, char ** argv)
{
	int fd_listen, fd_conn;
	struct sockaddr_in srv_addr, clt_addr;
	socklen_t clt_len;
	pid_t pid_child;
	char str_addr[INET_ADDRSTRLEN];

	fd_listen = socket(AF_INET, SOCK_STREAM, 0);
	bzero(&srv_addr, sizeof(srv_addr));

	srv_addr.sin_family = AF_INET;
	srv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	srv_addr.sin_port = htons(9877);

	bind(fd_listen, (struct sockaddr *)&srv_addr, sizeof(srv_addr));
	listen(fd_listen, 10);
	//inet_ntop(AF_INET, &srv_addr.sin_addr.s_addr, str_addr, INET_ADDRSTRLEN);
	DIAG_INFO("Server: Starts.");
	for (;;)
	{
		DIAG_INFO("Server: Listening...");
		clt_len = sizeof(clt_addr);
		fd_conn = accept(fd_listen, (struct sockaddr *)&clt_addr, &clt_len);
		DIAG_INFO("Accepted.");
		if (0 == (pid_child = fork()))
		{
			close(fd_listen);
			str_echo(fd_conn);
			exit(0);
		}

		close(fd_conn);

	}
}
コード例 #20
0
static void diag_sdio_notify(void *ctxt, unsigned event)
{
	if (ril_sdio_dbg_flag)
		DIAG_INFO("%s event=%d(1:read 2:write)%d:%d\n", __func__, event, driver->in_busy_sdio_1, driver->in_busy_sdio_2);

	if (event == SDIO_EVENT_DATA_READ_AVAIL) {
		APPEND_DEBUG('T');
		queue_work(driver->diag_sdio_wq,
				 &(driver->diag_read_sdio_work));
}
	if (event == SDIO_EVENT_DATA_WRITE_AVAIL) {
		APPEND_DEBUG('S');
		wake_up_interruptible(&driver->wait_q);
}
}
コード例 #21
0
ファイル: diagchar_core.c プロジェクト: Snuzzo/htc8960-3.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;
}
コード例 #22
0
static ssize_t diag_dump(struct device *dev,
					struct device_attribute *attr, char *buf)
{
	uint16_t i, p;
	memset(diag_trace, 0x00, sizeof(diag_trace));
	DIAG_INFO("%s: diag_debug_buf_idx=%d\n", __func__, diag_debug_buf_idx);
	for (i = 0, p = 0; i < 1023 ; i++)	{
		if (i == diag_debug_buf_idx)
			p += sprintf(diag_trace+p, "%c",  '*');
		else
			p += sprintf(diag_trace+p, "%c",  diag_debug_buf[i]);
	}
	print_hex_dump(KERN_INFO, "diag_debug_buf:", DUMP_PREFIX_ADDRESS, 16, 1, diag_debug_buf, 1026, 1);

	return sprintf(buf, "%s\n", diag_trace);

}
コード例 #23
0
ファイル: gp_spi.c プロジェクト: WayWingsDev/Gplus_2159_0801
/**
 * @brief   spi device probe
 */
static int gp_spi_probe(struct platform_device *pdev)
{
	int ret = 0;

	gp_spi_data = kzalloc(sizeof(gp_spi_t), GFP_KERNEL);
	if(!gp_spi_data){
		return -ENOMEM;
	}
	memset(gp_spi_data, 0, sizeof(gp_spi_t));

	gp_spi_data->pin_handle = gp_board_pin_func_request(GP_PIN_SPI, GP_BOARD_WAIT_FOREVER);
	if (gp_spi_data->pin_handle < 0) {
		DIAG_ERROR("[%s:%d] Error!\n", __FUNCTION__, __LINE__);
		ret = -EINVAL;
		goto fail_pin;
	}

	gp_spi_data->dev.name = SPI_NAME;
	gp_spi_data->dev.minor  = MISC_DYNAMIC_MINOR;
	gp_spi_data->dev.fops  = &spi_fops;

	gpHalSpiClkEnable(&gp_spi_device.dev, 1);
	
	ret = misc_register(&gp_spi_data->dev);
	if(ret != 0){
		DIAG_ERROR("spi probe register fail\n");
		goto fail_reg;
	}
	
	platform_set_drvdata(pdev,&gp_spi_data);

	init_MUTEX(&gp_spi_data->spi_sem);

	DIAG_INFO("spi probe ok\n");
	return 0;

fail_reg:
	gp_board_pin_func_release(gp_spi_data->pin_handle);
	gpHalSpiClkEnable(&gp_spi_device.dev, 0);

fail_pin:
	kfree(gp_spi_data);

	return ret;
}
コード例 #24
0
/**
*@brief Check started or not
*/
static int s35390a_check_started(unsigned char *pReg)
{
	unsigned char reg1_sts;
	unsigned char reg2_sts;
	int ret = 0;
	int retry = 10;

	/*unsigned char tmp = 0;*/
	ret = s35390a_get_reg(EXT_RTC_STS_REG1, &reg1_sts,1);
	if( ret != SP_OK ) {
		*pReg = 0;
		return ret;
	}
	
	if(((reg1_sts&0x80)==0x80)||((reg1_sts&0x40)==0x40)){	/*poc or boc is 1*/	
		DIAG_INFO("\nExternal RTC first start up!\n\n");
		while(1)	{
			/*Ïò׎̬ŒÄŽæÆ÷1µÄBIT0ÐŽÈë1œøÐÐreset*/
			reg1_sts = reg1_sts|0x01;
			s35390a_set_reg(EXT_RTC_STS_REG1, &reg1_sts, 1);

			#if 0
			/*×ÔÓɌĎæÆ÷£¬Öµ¿É×ÔÓÉÉ趚£¬¿ÉÓÃΪRTC reliableµÄÅбð*/
			tmp = 0xa5;
			halExtRtcRegWrite(EXT_RTC_FREE_REG,&tmp,1);
			#endif
			
			s35390a_get_reg(EXT_RTC_STS_REG2,&reg2_sts, 1);
			if ((reg2_sts&0x80)==0){/*TEST bit is 0*/	
				ret = SP_OK;
				break;
			}
			if( retry < 0 ) {
				ret = SP_FAIL;
				break;
			}
			else {
				retry--;
			}
		}		
	}
	*pReg = reg1_sts;

	return ret;
}
コード例 #25
0
static int diagchar_cleanup(void)
{
	DIAG_INFO("%s:%s(parent:%s): tgid=%d\n", __func__,
	current->comm, current->parent->comm, current->tgid);
	if (driver) {
		if (driver->cdev) {
			/* TODO - Check if device exists before deleting */
			device_destroy(driver->diagchar_class,
				       MKDEV(driver->major,
					     driver->minor_start));
			cdev_del(driver->cdev);
		}
		if (!IS_ERR(driver->diagchar_class))
			class_destroy(driver->diagchar_class);
		wake_lock_destroy(&driver->wake_lock);
		kfree(driver);
	}
	return 0;
}
コード例 #26
0
int diagfwd_connect_sdio(void)
{

	int err;

	DIAG_INFO("%s\n", __func__);

	if (!strcmp(DIAG_MDM, usb_ch_name)) {
		err = usb_diag_alloc_req(driver->mdm_ch, N_MDM_WRITE,
							 N_MDM_READ);
		if (err) {
			DIAG_ERR("diag: unable to alloc USB req on mdm ch");
			return -ENOMEM;
		}
	}

	driver->in_busy_sdio_1 = 0;
	driver->in_busy_sdio_2 = 0;
	/* Poll SDIO channel to check for data*/
	queue_work(driver->diag_sdio_wq, &(driver->diag_read_sdio_work));
	return 0;
}
コード例 #27
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;
	}

}
コード例 #28
0
ファイル: gp_adc.c プロジェクト: WayWingsDev/Gplus_2159_0801
/**
 *@brief  start specified channel ADC conversion
 *@param  handle: handle of the adc client
 *@param  channel: specify which channel as AUX ADC input
 *   This parameter can be one of the following values:
 *     @arg ADC_CHANNEL_TPXP: touch pannle X positive input
 *     @arg ADC_CHANNEL_TPXN: touch pannle X negative input
 *     @arg ADC_CHANNEL_TPYP: touch pannle Y positive input
 *     @arg ADC_CHANNEL_TPYN: touch pannle Y negative input
 *     @arg ADC_CHANNEL_AUX1: AUX1 as ADC input
 *     @arg ADC_CHANNEL_AUX2: AUX2 as ADC input
 *     @arg ADC_CHANNEL_AUX3: AUX3 as ADC input
 *     @arg ADC_CHANNEL_AUX4: AUX4 as ADC input
 *@return 0-OK
 *        -EINVAL invalid parameter
 *        -EAGAIN client have alreay started
 */
int gp_adc_start(int handle, unsigned int channel)
{
	struct gp_adc_client_s *client = (struct gp_adc_client_s *)handle;
	gp_adc_device_t *dev = (gp_adc_device_t *)client->dev;

	//printk("[%s] enter\n", __func__);
	if (NULL==dev || NULL==client) {
		DIAG_ERROR("%s: failed to find adc or client\n", __func__);
		return -EINVAL;
	}

	/*only one touch screen client can be started*/
	if (client->is_ts && dev->ts) {
		DIAG_INFO("adc touchscreen client already started!\n");
		return -EAGAIN;
	}

	if ( get_open_count(dev) == 0 )
		gp_adc_en(1); /* enable ADC */

	dev->open_cnt++;
	if (client->is_ts) { /*ts client*/
		dev->ts = client;
		/* Work around for adc auto mode */
		gpHalAdcStartConv(MODE_AUX, 0x7);

		/* if it is touch panel mode, enable interrupt */
		gpHalAdcSetIntEn(ADC_INTPNL | ADC_INTPENUP | ADC_INTPENDN, ADC_INTPNL);
		gpHalAdcStartConv(MODE_TP_AUTO, 0);
	} else {
		gpHalAdcSetIntEn(ADC_INTAUX, ADC_INTAUX);
		gp_adc_start_aux(handle, channel);
	}

	return 0;
}
コード例 #29
0
static void diag_smd_qdsp_notify(void *ctxt, unsigned event)
{
	if (diag7k_debug_mask)
		DIAG_INFO("%s event=%d(1:read 2:write)\n", __func__, event);
	queue_work(driver->diag_wq, &(driver->diag_read_smd_qdsp_work));
}
コード例 #30
0
/**
 * @brief   i2c device release
 */
static void gp_i2c_device_release(struct device *dev)
{
	DIAG_INFO("remove i2c device ok\n");
}