software/drivers/sd8887/src/bluetooth/bt/bt_proc.c
/**
 *  @brief This function handle the generic file open
 *
 *  @param inode   A pointer to inode structure
 *  @param file    A pointer to file structure
 *  @return	BT_STATUS_SUCCESS or other error no.
 */
@brief This function handle the generic file open
@param inode   A pointer to inode structure
@param file    A pointer to file structure
@return     BT_STATUS_SUCCESS or other error no.
@brief This function handle the generic file open @param inode A pointer to inode structure @param file A pointer to file structure @return BT_STATUS_SUCCESS or other error no .
static int
proc_open(struct inode *inode, struct file *file)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
	struct proc_private_data *priv = PDE_DATA(inode);
#else
	struct proc_private_data *priv = PDE(inode)->data;
#endif
	struct proc_data *pdata;
	int i;
	char *p;
	u32 val = 0;
	ENTER();
	priv->pbt->adapter->skb_pending =
		skb_queue_len(&priv->pbt->adapter->tx_queue);
	file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL);
	if (file->private_data == NULL) {
		PRINTM(ERROR, "BT: Can not alloc mem for proc_data\n");
		LEAVE();
		return -ENOMEM;
	}
	pdata = (struct proc_data *)file->private_data;
	pdata->pbt = priv->pbt;
	pdata->rdbuf = kmalloc(priv->bufsize, GFP_KERNEL);
	if (pdata->rdbuf == NULL) {
		PRINTM(ERROR, "BT: Can not alloc mem for rdbuf\n");
		kfree(file->private_data);
		LEAVE();
		return -ENOMEM;
	}
	if (priv->fileflag == DEFAULT_FILE_PERM) {
		pdata->wrbuf = kzalloc(priv->bufsize, GFP_KERNEL);
		if (pdata->wrbuf == NULL) {
			PRINTM(ERROR, "BT: Can not alloc mem for wrbuf\n");
			kfree(pdata->rdbuf);
			kfree(file->private_data);
			return -ENOMEM;
		}
		pdata->maxwrlen = priv->bufsize;
		pdata->on_close = proc_on_close;
	}
	p = pdata->rdbuf;
	for (i = 0; i < priv->num_items; i++) {
		if (priv->pdata[i].size == 1)
			val = *((u8 *)priv->pdata[i].addr);
		else if (priv->pdata[i].size == 2)
			val = *((u16 *) priv->pdata[i].addr);
		else if (priv->pdata[i].size == 4)
			val = *((u32 *)priv->pdata[i].addr);
		if (priv->pdata[i].flag & SHOW_INT)
			p += sprintf(p, "%s=%d\n", priv->pdata[i].name, val);
		else if (priv->pdata[i].flag & SHOW_HEX)
			p += sprintf(p, "%s=0x%x\n", priv->pdata[i].name, val);
		else if (priv->pdata[i].flag & SHOW_STRING) {
			if (!strncmp
			    (priv->pdata[i].name, "sdcmd52rw",
			     strlen("sdcmd52rw"))) {
				sd_read_cmd52_val(priv->pbt);
				form_cmd52_string(priv->pbt);
			}
			p += sprintf(p, "%s=%s\n", priv->pdata[i].name,
				     (char *)priv->pdata[i].addr);
		}
	}
	pdata->rdlen = strlen(pdata->rdbuf);
	LEAVE();
	return BT_STATUS_SUCCESS;
}
static int proc_open ( struct inode * inode , struct file * file ) { #if LINUX_VERSION_CODE >= KERNEL_VERSION ( 3 , 10 , 0 ) struct proc_private_data * priv = PDE_DATA ( inode ) ; #else struct proc_private_data * priv = PDE ( inode ) -> data ; #endif struct proc_data * pdata ; int i ; char * p ; u32 val = 0 ; ENTER ( ) ; priv -> pbt -> adapter -> skb_pending = skb_queue_len ( & priv -> pbt -> adapter -> tx_queue ) ; file -> private_data = kzalloc ( sizeof ( struct proc_data ) , GFP_KERNEL ) ; if ( file -> private_data == NULL ) { PRINTM ( ERROR , " \n " ) ; LEAVE ( ) ; return - ENOMEM ; } pdata = ( struct proc_data * ) file -> private_data ; pdata -> pbt = priv -> pbt ; pdata -> rdbuf = kmalloc ( priv -> bufsize , GFP_KERNEL ) ; if ( pdata -> rdbuf == NULL ) { PRINTM ( ERROR , " \n " ) ; kfree ( file -> private_data ) ; LEAVE ( ) ; return - ENOMEM ; } if ( priv -> fileflag == DEFAULT_FILE_PERM ) { pdata -> wrbuf = kzalloc ( priv -> bufsize , GFP_KERNEL ) ; if ( pdata -> wrbuf == NULL ) { PRINTM ( ERROR , " \n " ) ; kfree ( pdata -> rdbuf ) ; kfree ( file -> private_data ) ; return - ENOMEM ; } pdata -> maxwrlen = priv -> bufsize ; pdata -> on_close = proc_on_close ; } p = pdata -> rdbuf ; for ( i = 0 ; i < priv -> num_items ; i ++ ) { if ( priv -> pdata [ i ] . size == 1 ) val = * ( ( u8 * ) priv -> pdata [ i ] . addr ) ; else if ( priv -> pdata [ i ] . size == 2 ) val = * ( ( u16 * ) priv -> pdata [ i ] . addr ) ; else if ( priv -> pdata [ i ] . size == 4 ) val = * ( ( u32 * ) priv -> pdata [ i ] . addr ) ; if ( priv -> pdata [ i ] . flag & SHOW_INT ) p += sprintf ( p , " \n " , priv -> pdata [ i ] . name , val ) ; else if ( priv -> pdata [ i ] . flag & SHOW_HEX ) p += sprintf ( p , " \n " , priv -> pdata [ i ] . name , val ) ; else if ( priv -> pdata [ i ] . flag & SHOW_STRING ) { if ( ! strncmp ( priv -> pdata [ i ] . name , " " , strlen ( " " ) ) ) { sd_read_cmd52_val ( priv -> pbt ) ; form_cmd52_string ( priv -> pbt ) ; } p += sprintf ( p , " \n " , priv -> pdata [ i ] . name , ( char * ) priv -> pdata [ i ] . addr ) ; } } pdata -> rdlen = strlen ( pdata -> rdbuf ) ; LEAVE ( ) ; return BT_STATUS_SUCCESS ; }
@brief This function handle the generic file open
  @param inode   A pointer to inode structure
  @param file    A pointer to file structure
  @return     BT_STATUS_SUCCESS or other error no.
@brief This function handle the generic file open @param inode A pointer to inode structure @param file A pointer to file structure @return BT_STATUS_SUCCESS or other error no .