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

@return         0 --success, otherwise fail
@brief Set / Get module configuration @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_fw_wakeup_method(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0, data[2];
	mlan_ds_pm_cfg *pm_cfg = NULL;
	mlan_ioctl_req *req = NULL;
	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;
	if (wrq->u.data.length > 2) {
		ret = -EINVAL;
		goto done;
	}
	if (!wrq->u.data.length) {
		req->action = MLAN_ACT_GET;
	} else {
		req->action = MLAN_ACT_SET;
		if (copy_from_user
		    (data, wrq->u.data.pointer,
		     sizeof(int) * wrq->u.data.length)) {
			PRINTM(MINFO, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		}
		if (data[0] != FW_WAKEUP_METHOD_INTERFACE &&
		    data[0] != FW_WAKEUP_METHOD_GPIO) {
			PRINTM(MERROR, "Invalid FW wake up method:%d\n",
			       data[0]);
			ret = -EINVAL;
			goto done;
		}
		if (data[0] == FW_WAKEUP_METHOD_GPIO) {
			if (wrq->u.data.length == 1) {
				PRINTM(MERROR,
				       "Please provide gpio pin number for FW_WAKEUP_METHOD gpio\n");
				ret = -EINVAL;
				goto done;
			}
			pm_cfg->param.fw_wakeup_params.gpio_pin = data[1];
		}
		pm_cfg->param.fw_wakeup_params.method = data[0];
	}
	pm_cfg->sub_command = MLAN_OID_PM_CFG_FW_WAKEUP_METHOD;
	req->req_id = MLAN_IOCTL_PM_CFG;
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	data[0] = ((mlan_ds_pm_cfg *)req->pbuf)->param.fw_wakeup_params.method;
	data[1] =
		((mlan_ds_pm_cfg *)req->pbuf)->param.fw_wakeup_params.gpio_pin;
	if (data[0] == FW_WAKEUP_METHOD_INTERFACE)
		wrq->u.data.length = 1;
	else
		wrq->u.data.length = 2;
	if (copy_to_user
	    (wrq->u.data.pointer, data, sizeof(int) * wrq->u.data.length)) {
		ret = -EFAULT;
		goto done;
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_fw_wakeup_method ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 , data [ 2 ] ; mlan_ds_pm_cfg * pm_cfg = NULL ; mlan_ioctl_req * req = NULL ; 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 ; if ( wrq -> u . data . length > 2 ) { ret = - EINVAL ; goto done ; } if ( ! wrq -> u . data . length ) { req -> action = MLAN_ACT_GET ; } else { req -> action = MLAN_ACT_SET ; if ( copy_from_user ( data , wrq -> u . data . pointer , sizeof ( int ) * wrq -> u . data . length ) ) { PRINTM ( MINFO , " \n " ) ; ret = - EFAULT ; goto done ; } if ( data [ 0 ] != FW_WAKEUP_METHOD_INTERFACE && data [ 0 ] != FW_WAKEUP_METHOD_GPIO ) { PRINTM ( MERROR , " \n " , data [ 0 ] ) ; ret = - EINVAL ; goto done ; } if ( data [ 0 ] == FW_WAKEUP_METHOD_GPIO ) { if ( wrq -> u . data . length == 1 ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } pm_cfg -> param . fw_wakeup_params . gpio_pin = data [ 1 ] ; } pm_cfg -> param . fw_wakeup_params . method = data [ 0 ] ; } pm_cfg -> sub_command = MLAN_OID_PM_CFG_FW_WAKEUP_METHOD ; req -> req_id = MLAN_IOCTL_PM_CFG ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } data [ 0 ] = ( ( mlan_ds_pm_cfg * ) req -> pbuf ) -> param . fw_wakeup_params . method ; data [ 1 ] = ( ( mlan_ds_pm_cfg * ) req -> pbuf ) -> param . fw_wakeup_params . gpio_pin ; if ( data [ 0 ] == FW_WAKEUP_METHOD_INTERFACE ) wrq -> u . data . length = 1 ; else wrq -> u . data . length = 2 ; if ( copy_to_user ( wrq -> u . data . pointer , data , sizeof ( int ) * wrq -> u . data . length ) ) { ret = - EFAULT ; goto done ; } done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get module configuration
 @param priv     A pointer to moal_private structure
 @param wrq      A pointer to iwreq structure
@brief Set / Get module configuration @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure