Esempio n. 1
0
static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
				      enum dev_state state)
{
	int retval = 0;

	switch (state) {
	case STATE_RADIO_ON:
		/*
		 * Before the radio can be enabled, the device first has
		 * to be woken up. After that it needs a bit of time
		 * to be fully awake and then the radio can be enabled.
		 */
		rt2800pci_set_state(rt2x00dev, STATE_AWAKE);
		msleep(1);
		retval = rt2800pci_enable_radio(rt2x00dev);
		break;
	case STATE_RADIO_OFF:
		/*
		 * After the radio has been disabled, the device should
		 * be put to sleep for powersaving.
		 */
		rt2800pci_disable_radio(rt2x00dev);
		rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
		break;
	case STATE_RADIO_RX_ON:
	case STATE_RADIO_RX_ON_LINK:
	case STATE_RADIO_RX_OFF:
	case STATE_RADIO_RX_OFF_LINK:
		rt2800pci_toggle_rx(rt2x00dev, state);
		break;
	case STATE_RADIO_IRQ_ON:
	case STATE_RADIO_IRQ_OFF:
		rt2800pci_toggle_irq(rt2x00dev, state);
		break;
	case STATE_DEEP_SLEEP:
	case STATE_SLEEP:
	case STATE_STANDBY:
	case STATE_AWAKE:
		retval = rt2800pci_set_state(rt2x00dev, state);
		break;
	default:
		retval = -ENOTSUPP;
		break;
	}

	if (unlikely(retval))
		ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
		      state, retval);

	return retval;
}
static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev,
                                      enum dev_state state)
{
    int retval = 0;

    switch (state) {
    case STATE_RADIO_ON:
        retval = rt2800pci_enable_radio(rt2x00dev);
        break;
    case STATE_RADIO_OFF:
        /*
         * After the radio has been disabled, the device should
         * be put to sleep for powersaving.
         */
        rt2800pci_disable_radio(rt2x00dev);
        rt2800pci_set_state(rt2x00dev, STATE_SLEEP);
        break;
    case STATE_RADIO_IRQ_ON:
    case STATE_RADIO_IRQ_OFF:
        rt2800pci_toggle_irq(rt2x00dev, state);
        break;
    case STATE_DEEP_SLEEP:
    case STATE_SLEEP:
    case STATE_STANDBY:
    case STATE_AWAKE:
        retval = rt2800pci_set_state(rt2x00dev, state);
        break;
    default:
        retval = -ENOTSUPP;
        break;
    }

    if (unlikely(retval))
        ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
              state, retval);

    return retval;
}