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

@return             0 --success, otherwise fail
@brief Get / Set inactivity timeout extend @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_inactivity_timeout_ext(moal_private *priv, struct iwreq *wrq)
{
	int data[4], copy_len;
	int ret = 0;
	mlan_ioctl_req *req = NULL;
	mlan_ds_pm_cfg *pmcfg = NULL;
	pmlan_ds_inactivity_to inac_to = NULL;
	int data_length = wrq->u.data.length;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	copy_len = MIN(sizeof(data), sizeof(int) * data_length);
	memset(data, 0, sizeof(data));
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
	if (req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	pmcfg = (mlan_ds_pm_cfg *)req->pbuf;
	inac_to = &pmcfg->param.inactivity_to;
	pmcfg->sub_command = MLAN_OID_PM_CFG_INACTIVITY_TO;
	req->req_id = MLAN_IOCTL_PM_CFG;
	if ((data_length != 0 && data_length != 3 && data_length != 4) ||
	    sizeof(int) * data_length > sizeof(data)) {
		PRINTM(MERROR, "Invalid number of parameters\n");
		ret = -EINVAL;
		goto done;
	}
	req->action = MLAN_ACT_GET;
	if (data_length) {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		req->action = MLAN_ACT_SET;
		inac_to->timeout_unit = data[0];
		inac_to->unicast_timeout = data[1];
		inac_to->mcast_timeout = data[2];
		inac_to->ps_entry_timeout = data[3];
	}
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	data[0] = inac_to->timeout_unit;
	data[1] = inac_to->unicast_timeout;
	data[2] = inac_to->mcast_timeout;
	data[3] = inac_to->ps_entry_timeout;
	if (req->action == MLAN_ACT_GET) {
		wrq->u.data.length = 4;
		if (copy_to_user
		    (wrq->u.data.pointer, data,
		     wrq->u.data.length * sizeof(int))) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto done;
		}
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_inactivity_timeout_ext ( moal_private * priv , struct iwreq * wrq ) { int data [ 4 ] , copy_len ; int ret = 0 ; mlan_ioctl_req * req = NULL ; mlan_ds_pm_cfg * pmcfg = NULL ; pmlan_ds_inactivity_to inac_to = NULL ; int data_length = wrq -> u . data . length ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * data_length ) ; memset ( data , 0 , sizeof ( data ) ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_pm_cfg ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto done ; } pmcfg = ( mlan_ds_pm_cfg * ) req -> pbuf ; inac_to = & pmcfg -> param . inactivity_to ; pmcfg -> sub_command = MLAN_OID_PM_CFG_INACTIVITY_TO ; req -> req_id = MLAN_IOCTL_PM_CFG ; if ( ( data_length != 0 && data_length != 3 && data_length != 4 ) || sizeof ( int ) * data_length > sizeof ( data ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } req -> action = MLAN_ACT_GET ; if ( data_length ) { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } req -> action = MLAN_ACT_SET ; inac_to -> timeout_unit = data [ 0 ] ; inac_to -> unicast_timeout = data [ 1 ] ; inac_to -> mcast_timeout = data [ 2 ] ; inac_to -> ps_entry_timeout = data [ 3 ] ; } status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } data [ 0 ] = inac_to -> timeout_unit ; data [ 1 ] = inac_to -> unicast_timeout ; data [ 2 ] = inac_to -> mcast_timeout ; data [ 3 ] = inac_to -> ps_entry_timeout ; if ( req -> action == MLAN_ACT_GET ) { wrq -> u . data . length = 4 ; if ( copy_to_user ( wrq -> u . data . pointer , data , wrq -> u . data . length * sizeof ( int ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Get/Set inactivity timeout extend
  @param priv         A pointer to moal_private structure
  @param wrq          A pointer to iwreq structure
@brief Get / Set inactivity timeout extend @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure
/* Copy back current values regardless of GET/SET */