software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Set/Get system clock
 *
 *  @param priv         A pointer to moal_private structure
 *  @param wrq          A pointer to iwreq structure
 *
 *  @return             0 --success, otherwise fail
 */
@brief Set/Get system clock
@param priv         A pointer to moal_private structure
@param wrq          A pointer to iwreq structure

@return             0 --success, otherwise fail
@brief Set / Get system clock @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_ecl_sys_clock(moal_private *priv, struct iwreq *wrq)
{
	int data[64], copy_len;
	int ret = 0;
	mlan_ioctl_req *req = NULL;
	mlan_ds_misc_cfg *cfg = NULL;
	int data_length = wrq->u.data.length;
	int i = 0;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	memset(data, 0, sizeof(data));
	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;
	}
	cfg = (mlan_ds_misc_cfg *)req->pbuf;
	cfg->sub_command = MLAN_OID_MISC_SYS_CLOCK;
	req->req_id = MLAN_IOCTL_MISC_CFG;
	if (!data_length)
		req->action = MLAN_ACT_GET;
	else if (data_length <= MLAN_MAX_CLK_NUM) {
		req->action = MLAN_ACT_SET;
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
	} else {
		PRINTM(MERROR, "Invalid arguments\n");
		ret = -EINVAL;
		goto done;
	}
	if (req->action == MLAN_ACT_GET) {
		cfg->param.sys_clock.sys_clk_type = MLAN_CLK_CONFIGURABLE;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto done;
		}
		data[0] = (int)cfg->param.sys_clock.cur_sys_clk;
		wrq->u.data.length = 1;
		data_length =
			MIN(cfg->param.sys_clock.sys_clk_num, MLAN_MAX_CLK_NUM);
		for (i = 0; i < data_length; i++) {
			data[i + wrq->u.data.length] =
				(int)cfg->param.sys_clock.sys_clk[i];
		}
		wrq->u.data.length += data_length;
		cfg->param.sys_clock.sys_clk_type = MLAN_CLK_SUPPORTED;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto done;
		}
		data_length =
			MIN(cfg->param.sys_clock.sys_clk_num, MLAN_MAX_CLK_NUM);
		for (i = 0; i < data_length; i++) {
			data[i + wrq->u.data.length] =
				(int)cfg->param.sys_clock.sys_clk[i];
		}
		wrq->u.data.length += data_length;
		if (copy_to_user
		    (wrq->u.data.pointer, data,
		     sizeof(int) * wrq->u.data.length)) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto done;
		}
	} else {
		cfg->param.sys_clock.sys_clk_type = MLAN_CLK_CONFIGURABLE;
		cfg->param.sys_clock.sys_clk_num =
			MIN(MLAN_MAX_CLK_NUM, data_length);
		for (i = 0; i < cfg->param.sys_clock.sys_clk_num; i++)
			cfg->param.sys_clock.sys_clk[i] = (t_u16)data[i];
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto done;
		}
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_ecl_sys_clock ( moal_private * priv , struct iwreq * wrq ) { int data [ 64 ] , copy_len ; int ret = 0 ; mlan_ioctl_req * req = NULL ; mlan_ds_misc_cfg * cfg = NULL ; int data_length = wrq -> u . data . length ; int i = 0 ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; memset ( data , 0 , sizeof ( data ) ) ; 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 ; } cfg = ( mlan_ds_misc_cfg * ) req -> pbuf ; cfg -> sub_command = MLAN_OID_MISC_SYS_CLOCK ; req -> req_id = MLAN_IOCTL_MISC_CFG ; if ( ! data_length ) req -> action = MLAN_ACT_GET ; else if ( data_length <= MLAN_MAX_CLK_NUM ) { req -> action = MLAN_ACT_SET ; if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } } else { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } if ( req -> action == MLAN_ACT_GET ) { cfg -> param . sys_clock . sys_clk_type = MLAN_CLK_CONFIGURABLE ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } data [ 0 ] = ( int ) cfg -> param . sys_clock . cur_sys_clk ; wrq -> u . data . length = 1 ; data_length = MIN ( cfg -> param . sys_clock . sys_clk_num , MLAN_MAX_CLK_NUM ) ; for ( i = 0 ; i < data_length ; i ++ ) { data [ i + wrq -> u . data . length ] = ( int ) cfg -> param . sys_clock . sys_clk [ i ] ; } wrq -> u . data . length += data_length ; cfg -> param . sys_clock . sys_clk_type = MLAN_CLK_SUPPORTED ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } data_length = MIN ( cfg -> param . sys_clock . sys_clk_num , MLAN_MAX_CLK_NUM ) ; for ( i = 0 ; i < data_length ; i ++ ) { data [ i + wrq -> u . data . length ] = ( int ) cfg -> param . sys_clock . sys_clk [ i ] ; } wrq -> u . data . length += data_length ; if ( copy_to_user ( wrq -> u . data . pointer , data , sizeof ( int ) * wrq -> u . data . length ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } } else { cfg -> param . sys_clock . sys_clk_type = MLAN_CLK_CONFIGURABLE ; cfg -> param . sys_clock . sys_clk_num = MIN ( MLAN_MAX_CLK_NUM , data_length ) ; for ( i = 0 ; i < cfg -> param . sys_clock . sys_clk_num ; i ++ ) cfg -> param . sys_clock . sys_clk [ i ] = ( t_u16 ) data [ i ] ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get system clock
  @param priv         A pointer to moal_private structure
  @param wrq          A pointer to iwreq structure
@brief Set / Get system clock @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure
/* Get configurable clocks */ /* Current system clock */ /* Configurable clocks */ /* Get supported clocks */ /* Supported clocks */ /* Set configurable clocks */