software/drivers/sd8887/src/wlan/mlinux/moal_ioctl.c
/**
 *  @brief TDLS configuration ioctl handler
 *
 *  @param dev      A pointer to net_device structure
 *  @param req      A pointer to ifreq structure
 *  @return         0 --success, otherwise fail
 */
@brief TDLS configuration ioctl handler
@param dev      A pointer to net_device structure
@param req      A pointer to ifreq structure
@return         0 --success, otherwise fail
@brief TDLS configuration ioctl handler @param dev A pointer to net_device structure @param req A pointer to ifreq structure @return 0 -- success otherwise fail
int
woal_tdls_config_ioctl(struct net_device *dev, struct ifreq *req)
{
	moal_private *priv = (moal_private *)netdev_priv(dev);
	mlan_ioctl_req *ioctl_req = NULL;
	mlan_ds_misc_cfg *misc = NULL;
	mlan_ds_misc_tdls_config *tdls_data = NULL;
	int ret = 0;
	mlan_status status = MLAN_STATUS_SUCCESS;
	gfp_t flag;
	ENTER();
	if (req->ifr_data == NULL) {
		PRINTM(MERROR, "woal_tdls_config_ioctl() corrupt data\n");
		ret = -EFAULT;
		goto done;
	}
	flag = (in_atomic() || irqs_disabled())? GFP_ATOMIC : GFP_KERNEL;
	tdls_data = kzalloc(sizeof(mlan_ds_misc_tdls_config), flag);
	if (!tdls_data) {
		ret = -ENOMEM;
		goto done;
	}
	if (copy_from_user
	    (tdls_data, req->ifr_data, sizeof(mlan_ds_misc_tdls_config))) {
		PRINTM(MERROR, "Copy from user failed\n");
		ret = -EFAULT;
		goto done;
	}
	ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
	if (ioctl_req == NULL) {
		ret = -ENOMEM;
		goto done;
	}
	misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
	misc->sub_command = MLAN_OID_MISC_TDLS_CONFIG;
	ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
	if (tdls_data->tdls_action == WLAN_TDLS_DISCOVERY_REQ
	    || tdls_data->tdls_action == WLAN_TDLS_LINK_STATUS)
		ioctl_req->action = MLAN_ACT_GET;
	else
		ioctl_req->action = MLAN_ACT_SET;
	memcpy(&misc->param.tdls_config, tdls_data,
	       sizeof(mlan_ds_misc_tdls_config));
	status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	if (tdls_data->tdls_action == WLAN_TDLS_DISCOVERY_REQ
	    || tdls_data->tdls_action == WLAN_TDLS_LINK_STATUS) {
		if (copy_to_user(req->ifr_data, &misc->param.tdls_config,
				 sizeof(mlan_ds_misc_tdls_config))) {
			PRINTM(MERROR, "Copy to user failed!\n");
			ret = -EFAULT;
			goto done;
		}
	}
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(ioctl_req);
	kfree(tdls_data);
	LEAVE();
	return ret;
}
int woal_tdls_config_ioctl ( struct net_device * dev , struct ifreq * req ) { moal_private * priv = ( moal_private * ) netdev_priv ( dev ) ; mlan_ioctl_req * ioctl_req = NULL ; mlan_ds_misc_cfg * misc = NULL ; mlan_ds_misc_tdls_config * tdls_data = NULL ; int ret = 0 ; mlan_status status = MLAN_STATUS_SUCCESS ; gfp_t flag ; ENTER ( ) ; if ( req -> ifr_data == NULL ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } flag = ( in_atomic ( ) || irqs_disabled ( ) ) ? GFP_ATOMIC : GFP_KERNEL ; tdls_data = kzalloc ( sizeof ( mlan_ds_misc_tdls_config ) , flag ) ; if ( ! tdls_data ) { ret = - ENOMEM ; goto done ; } if ( copy_from_user ( tdls_data , req -> ifr_data , sizeof ( mlan_ds_misc_tdls_config ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } ioctl_req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_misc_cfg ) ) ; if ( ioctl_req == NULL ) { ret = - ENOMEM ; goto done ; } misc = ( mlan_ds_misc_cfg * ) ioctl_req -> pbuf ; misc -> sub_command = MLAN_OID_MISC_TDLS_CONFIG ; ioctl_req -> req_id = MLAN_IOCTL_MISC_CFG ; if ( tdls_data -> tdls_action == WLAN_TDLS_DISCOVERY_REQ || tdls_data -> tdls_action == WLAN_TDLS_LINK_STATUS ) ioctl_req -> action = MLAN_ACT_GET ; else ioctl_req -> action = MLAN_ACT_SET ; memcpy ( & misc -> param . tdls_config , tdls_data , sizeof ( mlan_ds_misc_tdls_config ) ) ; status = woal_request_ioctl ( priv , ioctl_req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( tdls_data -> tdls_action == WLAN_TDLS_DISCOVERY_REQ || tdls_data -> tdls_action == WLAN_TDLS_LINK_STATUS ) { if ( copy_to_user ( req -> ifr_data , & misc -> param . tdls_config , sizeof ( mlan_ds_misc_tdls_config ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } } done : if ( status != MLAN_STATUS_PENDING ) kfree ( ioctl_req ) ; kfree ( tdls_data ) ; LEAVE ( ) ; return ret ; }
@brief TDLS configuration ioctl handler
  @param dev      A pointer to net_device structure
  @param req      A pointer to ifreq structure
  @return         0 --success, otherwise fail
@brief TDLS configuration ioctl handler @param dev A pointer to net_device structure @param req A pointer to ifreq structure @return 0 -- success otherwise fail
/* Sanity check */