software/drivers/sd8887/src/wlan/mlinux/moal_priv.c
/**
 *  @brief Get/Set DeepSleep mode
 *
 *  @param priv     Pointer to the moal_private driver data struct
 *  @param wreq	    A pointer to iwreq structure
 *
 *  @return          0 --success, otherwise fail
 */
@brief Get/Set DeepSleep mode
@param priv     Pointer to the moal_private driver data struct
@param wreq     A pointer to iwreq structure

@return          0 --success, otherwise fail
@brief Get / Set DeepSleep mode @param priv Pointer to the moal_private driver data struct @param wreq A pointer to iwreq structure @return 0 -- success otherwise fail
static int
woal_deep_sleep_ioctl(moal_private *priv, struct iwreq *wrq)
{
	int ret = 0;
	int user_data_len;
	t_u32 deep_sleep = DEEP_SLEEP_OFF;
	t_u32 data[2];
	int copy_len;
	t_u16 idletime = DEEP_SLEEP_IDLE_TIME;
	ENTER();
	user_data_len = wrq->u.data.length;
	copy_len = MIN(sizeof(data), sizeof(int) * user_data_len);
	if (user_data_len == 1 || user_data_len == 2) {
		if (copy_from_user(&data, wrq->u.data.pointer, copy_len)) {
			PRINTM(MERROR, "Copy from user failed\n");
			LEAVE();
			return -EFAULT;
		}
		deep_sleep = data[0];
		if (deep_sleep == DEEP_SLEEP_OFF) {
			PRINTM(MINFO, "Exit Deep Sleep Mode\n");
			ret = woal_set_deep_sleep(priv, MOAL_IOCTL_WAIT, MFALSE,
						  0);
			if (ret != MLAN_STATUS_SUCCESS) {
				LEAVE();
				return -EINVAL;
			}
		} else if (deep_sleep == DEEP_SLEEP_ON) {
			PRINTM(MINFO, "Enter Deep Sleep Mode\n");
			if (user_data_len == 2)
				idletime = data[1];
			else
				idletime = 0;
			ret = woal_set_deep_sleep(priv, MOAL_IOCTL_WAIT, MTRUE,
						  idletime);
			if (ret != MLAN_STATUS_SUCCESS) {
				LEAVE();
				return -EINVAL;
			}
		} else {
			PRINTM(MERROR, "Unknown option = %u\n", deep_sleep);
			LEAVE();
			return -EINVAL;
		}
	} else if (user_data_len > 2) {
		PRINTM(MERROR, "Invalid number of arguments %d\n",
		       user_data_len);
		LEAVE();
		return -EINVAL;
	} else {		
		PRINTM(MINFO, "Get Deep Sleep Mode\n");
		if (MLAN_STATUS_SUCCESS != woal_get_deep_sleep(priv, data)) {
			LEAVE();
			return -EFAULT;
		}
		if (data[0] == 0)
			wrq->u.data.length = 1;
		else
			wrq->u.data.length = 2;
	}
	if (copy_to_user
	    (wrq->u.data.pointer, data, wrq->u.data.length * sizeof(int))) {
		PRINTM(MERROR, "Copy to user failed\n");
		LEAVE();
		return -EINVAL;
	}
	LEAVE();
	return 0;
}
static int woal_deep_sleep_ioctl ( moal_private * priv , struct iwreq * wrq ) { int ret = 0 ; int user_data_len ; t_u32 deep_sleep = DEEP_SLEEP_OFF ; t_u32 data [ 2 ] ; int copy_len ; t_u16 idletime = DEEP_SLEEP_IDLE_TIME ; ENTER ( ) ; user_data_len = wrq -> u . data . length ; copy_len = MIN ( sizeof ( data ) , sizeof ( int ) * user_data_len ) ; if ( user_data_len == 1 || user_data_len == 2 ) { if ( copy_from_user ( & data , wrq -> u . data . pointer , copy_len ) ) { PRINTM ( MERROR , " \n " ) ; LEAVE ( ) ; return - EFAULT ; } deep_sleep = data [ 0 ] ; if ( deep_sleep == DEEP_SLEEP_OFF ) { PRINTM ( MINFO , " \n " ) ; ret = woal_set_deep_sleep ( priv , MOAL_IOCTL_WAIT , MFALSE , 0 ) ; if ( ret != MLAN_STATUS_SUCCESS ) { LEAVE ( ) ; return - EINVAL ; } } else if ( deep_sleep == DEEP_SLEEP_ON ) { PRINTM ( MINFO , " \n " ) ; if ( user_data_len == 2 ) idletime = data [ 1 ] ; else idletime = 0 ; ret = woal_set_deep_sleep ( priv , MOAL_IOCTL_WAIT , MTRUE , idletime ) ; if ( ret != MLAN_STATUS_SUCCESS ) { LEAVE ( ) ; return - EINVAL ; } } else { PRINTM ( MERROR , " \n " , deep_sleep ) ; LEAVE ( ) ; return - EINVAL ; } } else if ( user_data_len > 2 ) { PRINTM ( MERROR , " \n " , user_data_len ) ; LEAVE ( ) ; return - EINVAL ; } else { PRINTM ( MINFO , " \n " ) ; if ( MLAN_STATUS_SUCCESS != woal_get_deep_sleep ( priv , data ) ) { LEAVE ( ) ; return - EFAULT ; } if ( data [ 0 ] == 0 ) wrq -> u . data . length = 1 ; else wrq -> u . data . length = 2 ; } if ( copy_to_user ( wrq -> u . data . pointer , data , wrq -> u . data . length * sizeof ( int ) ) ) { PRINTM ( MERROR , " \n " ) ; LEAVE ( ) ; return - EINVAL ; } LEAVE ( ) ; return 0 ; }
@brief Get/Set DeepSleep mode
  @param priv     Pointer to the moal_private driver data struct
  @param wreq     A pointer to iwreq structure
@brief Get / Set DeepSleep mode @param priv Pointer to the moal_private driver data struct @param wreq A pointer to iwreq structure
/* Display Deep Sleep settings */ /* Copy the Deep Sleep setting to user */