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

@return         0 --success, otherwise fail
@brief Set / Get sleep period @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_sleep_pd(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0;
	mlan_ds_pm_cfg *pm_cfg = NULL;
	mlan_ioctl_req *req = NULL;
	int data = 0;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_pm_cfg));
	if (req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	pm_cfg = (mlan_ds_pm_cfg *)req->pbuf;
	pm_cfg->sub_command = MLAN_OID_PM_CFG_SLEEP_PD;
	req->req_id = MLAN_IOCTL_PM_CFG;
	if (wrq->u.data.length) {
		if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		if ((data <= MAX_SLEEP_PERIOD && data >= MIN_SLEEP_PERIOD) ||
		    (data == 0)
		    || (data == SLEEP_PERIOD_RESERVED_FF)
			) {
			req->action = MLAN_ACT_SET;
			pm_cfg->param.sleep_period = data;
		} else {
			ret = -EINVAL;
			goto done;
		}
	} else
		req->action = MLAN_ACT_GET;
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	if (!wrq->u.data.length) {
		data = pm_cfg->param.sleep_period;
		if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) {
			ret = -EFAULT;
			goto done;
		}
		wrq->u.data.length = 1;
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_sleep_pd ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 ; mlan_ds_pm_cfg * pm_cfg = NULL ; mlan_ioctl_req * req = NULL ; int data = 0 ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_pm_cfg ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto done ; } pm_cfg = ( mlan_ds_pm_cfg * ) req -> pbuf ; pm_cfg -> sub_command = MLAN_OID_PM_CFG_SLEEP_PD ; req -> req_id = MLAN_IOCTL_PM_CFG ; if ( wrq -> u . data . length ) { if ( copy_from_user ( & data , wrq -> u . data . pointer , sizeof ( int ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } if ( ( data <= MAX_SLEEP_PERIOD && data >= MIN_SLEEP_PERIOD ) || ( data == 0 ) || ( data == SLEEP_PERIOD_RESERVED_FF ) ) { req -> action = MLAN_ACT_SET ; pm_cfg -> param . sleep_period = data ; } else { ret = - EINVAL ; goto done ; } } else req -> action = MLAN_ACT_GET ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( ! wrq -> u . data . length ) { data = pm_cfg -> param . sleep_period ; if ( copy_to_user ( wrq -> u . data . pointer , & data , sizeof ( int ) ) ) { ret = - EFAULT ; goto done ; } wrq -> u . data . length = 1 ; } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get sleep period
 @param priv     A pointer to moal_private structure
 @param wrq      A pointer to iwreq structure
@brief Set / Get sleep period @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure