software/drivers/sd8887/src/wlan/mlinux/moal_ioctl.c
/**
 *  @brief Get extended driver version
 *
 *  @param priv         A pointer to moal_private structure
 *  @param ireq         A pointer to ifreq structure
 *
 *  @return             0 --success, otherwise fail
 */
@brief Get extended driver version
@param priv         A pointer to moal_private structure
@param ireq         A pointer to ifreq structure

@return             0 --success, otherwise fail
@brief Get extended driver version @param priv A pointer to moal_private structure @param ireq A pointer to ifreq structure @return 0 -- success otherwise fail
int
woal_get_driver_verext(moal_private *priv, struct ifreq *ireq)
{
	struct iwreq *wrq = (struct iwreq *)ireq;
	mlan_ds_get_info *info = NULL;
	mlan_ioctl_req *req = NULL;
	int ret = 0;
	mlan_status status = MLAN_STATUS_SUCCESS;
	ENTER();
	req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_get_info));
	if (req == NULL) {
		LEAVE();
		return -ENOMEM;
	}
	info = (mlan_ds_get_info *)req->pbuf;
	info->sub_command = MLAN_OID_GET_VER_EXT;
	req->req_id = MLAN_IOCTL_GET_INFO;
	req->action = MLAN_ACT_GET;
	if (!wrq->u.data.flags) {
		info->param.ver_ext.version_str_sel =
			*((int *)(wrq->u.name + SUBCMD_OFFSET));
	} else {
		if (copy_from_user
		    (&info->param.ver_ext.version_str_sel, wrq->u.data.pointer,
		     sizeof(info->param.ver_ext.version_str_sel))) {
			PRINTM(MERROR, "Copy from user failed\n");
			ret = -EFAULT;
			goto done;
		} else {
			if (((t_s32)(info->param.ver_ext.version_str_sel)) < 0) {
				PRINTM(MERROR, "Invalid arguments!\n");
				ret = -EINVAL;
				goto done;
			}
		}
	}
	status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
	if (status != MLAN_STATUS_SUCCESS) {
		ret = -EFAULT;
		goto done;
	}
	if (wrq->u.data.pointer) {
		if (copy_to_user
		    (wrq->u.data.pointer, info->param.ver_ext.version_str,
		     strlen(info->param.ver_ext.version_str))) {
			PRINTM(MERROR, "Copy to user failed\n");
			ret = -EFAULT;
			goto done;
		}
		wrq->u.data.length = strlen(info->param.ver_ext.version_str);
	}
	PRINTM(MINFO, "MOAL EXTENDED VERSION: %s\n",
	       info->param.ver_ext.version_str);
done:
	if (status != MLAN_STATUS_PENDING)
		kfree(req);
	LEAVE();
	return ret;
}
int woal_get_driver_verext ( moal_private * priv , struct ifreq * ireq ) { struct iwreq * wrq = ( struct iwreq * ) ireq ; mlan_ds_get_info * info = NULL ; mlan_ioctl_req * req = NULL ; int ret = 0 ; mlan_status status = MLAN_STATUS_SUCCESS ; ENTER ( ) ; req = woal_alloc_mlan_ioctl_req ( sizeof ( mlan_ds_get_info ) ) ; if ( req == NULL ) { LEAVE ( ) ; return - ENOMEM ; } info = ( mlan_ds_get_info * ) req -> pbuf ; info -> sub_command = MLAN_OID_GET_VER_EXT ; req -> req_id = MLAN_IOCTL_GET_INFO ; req -> action = MLAN_ACT_GET ; if ( ! wrq -> u . data . flags ) { info -> param . ver_ext . version_str_sel = * ( ( int * ) ( wrq -> u . name + SUBCMD_OFFSET ) ) ; } else { if ( copy_from_user ( & info -> param . ver_ext . version_str_sel , wrq -> u . data . pointer , sizeof ( info -> param . ver_ext . version_str_sel ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } else { if ( ( ( t_s32 ) ( info -> param . ver_ext . version_str_sel ) ) < 0 ) { PRINTM ( MERROR , " \n " ) ; ret = - EINVAL ; goto done ; } } } status = woal_request_ioctl ( priv , req , MOAL_IOCTL_WAIT ) ; if ( status != MLAN_STATUS_SUCCESS ) { ret = - EFAULT ; goto done ; } if ( wrq -> u . data . pointer ) { if ( copy_to_user ( wrq -> u . data . pointer , info -> param . ver_ext . version_str , strlen ( info -> param . ver_ext . version_str ) ) ) { PRINTM ( MERROR , " \n " ) ; ret = - EFAULT ; goto done ; } wrq -> u . data . length = strlen ( info -> param . ver_ext . version_str ) ; } PRINTM ( MINFO , " \n " , info -> param . ver_ext . version_str ) ; done : if ( status != MLAN_STATUS_PENDING ) kfree ( req ) ; LEAVE ( ) ; return ret ; }
@brief Get extended driver version
  @param priv         A pointer to moal_private structure
  @param ireq         A pointer to ifreq structure
@brief Get extended driver version @param priv A pointer to moal_private structure @param ireq A pointer to ifreq structure