software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Set/Get CFP table codes
 *
 *  @param priv     Pointer to the moal_private driver data struct
 *  @param wrq      A pointer to iwreq structure
 *
 *  @return         0 --success, otherwise fail
 */
@brief Set/Get CFP table codes
@param priv     Pointer to the moal_private driver data struct
@param wrq      A pointer to iwreq structure

@return         0 --success, otherwise fail
@brief Set / Get CFP table codes @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_cfp_code(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0;
	int data[2], copy_len;
	int data_length = wrq->u.data.length;
	mlan_ioctl_req *req = NULL;
	mlan_ds_misc_cfg *misc_cfg = NULL;
	mlan_ds_misc_cfp_code *cfp_code = NULL;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	if (data_length > 2) {
		PRINTM(MERROR, "Invalid number of argument!\n");
		ret = -EINVAL;
		goto done;
	}
	copy_len = MIN(sizeof(data), sizeof(int) * data_length);
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
	if (req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	misc_cfg = (mlan_ds_misc_cfg *)req->pbuf;
	cfp_code = &misc_cfg->param.cfp_code;
	misc_cfg->sub_command = MLAN_OID_MISC_CFP_CODE;
	req->req_id = MLAN_IOCTL_MISC_CFG;
	if (!data_length) {
		req->action = MLAN_ACT_GET;
	} else {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		cfp_code->cfp_code_bg = data[0];
		if (data_length == 2)
			cfp_code->cfp_code_a = data[1];
		req->action = MLAN_ACT_SET;
	}
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	if (!data_length) {
		data[0] = cfp_code->cfp_code_bg;
		data[1] = cfp_code->cfp_code_a;
		data_length = 2;
		if (copy_to_user
		    (wrq->u.data.pointer, &data, sizeof(int) * data_length)) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto done;
		}
		wrq->u.data.length = data_length;
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_cfp_code ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 ; int data [ 2 ] , copy_len ; int data_length = wrq -> u . data . length ; mlan_ioctl_req * req = NULL ; mlan_ds_misc_cfg * misc_cfg = NULL ; mlan_ds_misc_cfp_code * cfp_code = NULL ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; if ( data_length > 2 ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * data_length ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_misc_cfg ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto done ; } misc_cfg = ( mlan_ds_misc_cfg * ) req -> pbuf ; cfp_code = & misc_cfg -> param . cfp_code ; misc_cfg -> sub_command = MLAN_OID_MISC_CFP_CODE ; req -> req_id = MLAN_IOCTL_MISC_CFG ; if ( ! data_length ) { req -> action = MLAN_ACT_GET ; } else { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } cfp_code -> cfp_code_bg = data [ 0 ] ; if ( data_length == 2 ) cfp_code -> cfp_code_a = data [ 1 ] ; req -> action = MLAN_ACT_SET ; } status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( ! data_length ) { data [ 0 ] = cfp_code -> cfp_code_bg ; data [ 1 ] = cfp_code -> cfp_code_a ; data_length = 2 ; if ( copy_to_user ( wrq -> u . data . pointer , & data , sizeof ( int ) * data_length ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } wrq -> u . data . length = data_length ; } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get CFP table codes
  @param priv     Pointer to the moal_private driver data struct
  @param wrq      A pointer to iwreq structure
@brief Set / Get CFP table codes @param priv Pointer to the moal_private driver data struct @param wrq A pointer to iwreq structure
/* Allocate an IOCTL request buffer */ /* Fill request buffer */ /* Send IOCTL request to MLAN */