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

@return             0 --success, otherwise fail
@brief Set / Get Band and Adhoc - band setting @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_band_cfg(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0;
	unsigned int i;
	int data[3];
	int user_data_len = wrq->u.data.length, copy_len;
	t_u32 infra_band = 0;
	t_u32 adhoc_band = 0;
	t_u32 adhoc_channel = 0;
	mlan_ioctl_req *req = NULL;
	mlan_ds_radio_cfg *radio_cfg = NULL;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	if (sizeof(int) * user_data_len > sizeof(data)) {
		PRINTM(MERROR, "Too many arguments\n");
		LEAVE();
		return -EINVAL;
	}
	if (user_data_len > 0) {
		if (priv->media_connected == MTRUE) {
			LEAVE();
			return -EOPNOTSUPP;
		}
	}
	copy_len = MIN(sizeof(data), sizeof(int) * user_data_len);
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
	if (req == NULL) {
		ret = -ENOMEM;
		goto error;
	}
	radio_cfg = (mlan_ds_radio_cfg *)req->pbuf;
	radio_cfg->sub_command = MLAN_OID_BAND_CFG;
	req->req_id = MLAN_IOCTL_RADIO_CFG;
	if (wrq->u.data.length == 0) {
		req->action = MLAN_ACT_GET;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto error;
		}
		data[0] = radio_cfg->param.band_cfg.config_bands;
		data[1] = radio_cfg->param.band_cfg.adhoc_start_band;
		data[2] = radio_cfg->param.band_cfg.adhoc_channel;
		wrq->u.data.length = 3;
		if (copy_to_user
		    (wrq->u.data.pointer, data,
		     sizeof(int) * wrq->u.data.length)) {
			ret = -EFAULT;
			goto error;
		}
	} else {
		if (copy_from_user(data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto error;
		}
		infra_band = data[0];
		for (i = 0; i < sizeof(SupportedInfraBand); i++)
			if (infra_band == SupportedInfraBand[i])
				break;
		if (i == sizeof(SupportedInfraBand)) {
			ret = -EINVAL;
			goto error;
		}
		if (user_data_len >= 2) {
			adhoc_band = data[1];
			for (i = 0; i < sizeof(SupportedAdhocBand); i++)
				if (adhoc_band == SupportedAdhocBand[i])
					break;
			if (i == sizeof(SupportedAdhocBand)) {
				ret = -EINVAL;
				goto error;
			}
		}
		if (user_data_len >= 3) {
			adhoc_channel = data[2];
			if (adhoc_channel == 0) {
				ret = -EINVAL;
				goto error;
			}
		}
		req->action = MLAN_ACT_SET;
		radio_cfg->param.band_cfg.config_bands = infra_band;
		radio_cfg->param.band_cfg.adhoc_start_band = adhoc_band;
		radio_cfg->param.band_cfg.adhoc_channel = adhoc_channel;
		status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
		if (status != MLAN_STATUS_SUCCESS) {
			ret = -EFAULT;
			goto error;
		}
	}
error:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
static int woal_band_cfg ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 ; unsigned int i ; int data [ 3 ] ; int user_data_len = wrq -> u . data . length , copy_len ; t_u32 infra_band = 0 ; t_u32 adhoc_band = 0 ; t_u32 adhoc_channel = 0 ; mlan_ioctl_req * req = NULL ; mlan_ds_radio_cfg * radio_cfg = NULL ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; if ( sizeof ( int ) * user_data_len > sizeof ( data ) ) { PRINTM ( MERROR , " \n " ) ; LEAVE ( ) ; return - EINVAL ; } if ( user_data_len > 0 ) { if ( priv -> media_connected == MTRUE ) { LEAVE ( ) ; return - EOPNOTSUPP ; } } copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * user_data_len ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_radio_cfg ) ) ; if ( req == NULL ) { ret = - ENOMEM ; goto error ; } radio_cfg = ( mlan_ds_radio_cfg * ) req -> pbuf ; radio_cfg -> sub_command = MLAN_OID_BAND_CFG ; req -> req_id = MLAN_IOCTL_RADIO_CFG ; if ( wrq -> u . data . length == 0 ) { req -> action = MLAN_ACT_GET ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto error ; } data [ 0 ] = radio_cfg -> param . band_cfg . config_bands ; data [ 1 ] = radio_cfg -> param . band_cfg . adhoc_start_band ; data [ 2 ] = radio_cfg -> param . band_cfg . adhoc_channel ; wrq -> u . data . length = 3 ; if ( copy_to_user ( wrq -> u . data . pointer , data , sizeof ( int ) * wrq -> u . data . length ) ) { ret = - EFAULT ; goto error ; } } else { if ( copy_from_user ( data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto error ; } infra_band = data [ 0 ] ; for ( i = 0 ; i < sizeof ( SupportedInfraBand ) ; i ++ ) if ( infra_band == SupportedInfraBand [ i ] ) break ; if ( i == sizeof ( SupportedInfraBand ) ) { ret = - EINVAL ; goto error ; } if ( user_data_len >= 2 ) { adhoc_band = data [ 1 ] ; for ( i = 0 ; i < sizeof ( SupportedAdhocBand ) ; i ++ ) if ( adhoc_band == SupportedAdhocBand [ i ] ) break ; if ( i == sizeof ( SupportedAdhocBand ) ) { ret = - EINVAL ; goto error ; } } if ( user_data_len >= 3 ) { adhoc_channel = data [ 2 ] ; if ( adhoc_channel == 0 ) { ret = - EINVAL ; goto error ; } } req -> action = MLAN_ACT_SET ; radio_cfg -> param . band_cfg . config_bands = infra_band ; radio_cfg -> param . band_cfg . adhoc_start_band = adhoc_band ; radio_cfg -> param . band_cfg . adhoc_channel = adhoc_channel ; status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto error ; } } error : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Set/Get Band and Adhoc-band setting
  @param priv         A pointer to moal_private structure
  @param wrq          A pointer to iwreq structure
@brief Set / Get Band and Adhoc - band setting @param priv A pointer to moal_private structure @param wrq A pointer to iwreq structure
/* Get config_bands, adhoc_start_band and adhoc_channel values from MLAN */ /* Infra Band */ /* Adhoc Band */ /* Adhoc Channel */ /* To support only <b/bg/bgn/n> */ /* Set Adhoc band */ /* Set Adhoc channel */ /* Check if specified adhoc channel is non-zero */ /* Set config_bands and adhoc_start_band values to MLAN */