Newer
Older
*/
retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev);
if (retval) {
ERROR(rt2x00dev, "Failed to allocate device.\n");
goto exit;
}
/*
* Initialize configuration work.
*/
INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled);
INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner);
/*
retval = rt2x00queue_allocate(rt2x00dev);
if (retval)
goto exit;
/*
* Initialize ieee80211 structure.
*/
retval = rt2x00lib_probe_hw(rt2x00dev);
if (retval) {
ERROR(rt2x00dev, "Failed to initialize hw.\n");
goto exit;
}
* Register extra components.
*/
rt2x00leds_register(rt2x00dev);
rt2x00rfkill_allocate(rt2x00dev);
rt2x00debug_register(rt2x00dev);
__set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
return 0;
exit:
rt2x00lib_remove_dev(rt2x00dev);
return retval;
}
EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev);
void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
{
__clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);
/*
* Disable radio.
*/
rt2x00lib_disable_radio(rt2x00dev);
/*
* Uninitialize device.
*/
rt2x00lib_uninitialize(rt2x00dev);
/*
* Free extra components
*/
rt2x00debug_deregister(rt2x00dev);
rt2x00rfkill_free(rt2x00dev);
rt2x00leds_unregister(rt2x00dev);
/*
* Free ieee80211_hw memory.
*/
rt2x00lib_remove_hw(rt2x00dev);
/*
* Free firmware image.
*/
rt2x00lib_free_firmware(rt2x00dev);
/*
}
EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev);
/*
* Device state handlers
*/
#ifdef CONFIG_PM
int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
{
int retval;
NOTICE(rt2x00dev, "Going to sleep.\n");
__clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);
/*
* Only continue if mac80211 has open interfaces.
*/
if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
goto exit;
__set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags);
rt2x00lib_stop(rt2x00dev);
rt2x00lib_uninitialize(rt2x00dev);
/*
* Suspend/disable extra components.
*/
rt2x00leds_suspend(rt2x00dev);
rt2x00rfkill_suspend(rt2x00dev);
rt2x00debug_deregister(rt2x00dev);
* Set device mode to sleep for power management,
* on some hardware this call seems to consistently fail.
* From the specifications it is hard to tell why it fails,
* and if this is a "bad thing".
* Overall it is safe to just ignore the failure and
* continue suspending. The only downside is that the
* device will not be in optimal power save mode, but with
* the radio and the other components already disabled the
* device is as good as disabled.
*/
retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP);
if (retval)
WARNING(rt2x00dev, "Device failed to enter sleep state, "
"continue suspending.\n");
return 0;
}
EXPORT_SYMBOL_GPL(rt2x00lib_suspend);
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
static void rt2x00lib_resume_intf(void *data, u8 *mac,
struct ieee80211_vif *vif)
{
struct rt2x00_dev *rt2x00dev = data;
struct rt2x00_intf *intf = vif_to_intf(vif);
spin_lock(&intf->lock);
rt2x00lib_config_intf(rt2x00dev, intf,
vif->type, intf->mac, intf->bssid);
/*
* Master or Ad-hoc mode require a new beacon update.
*/
if (vif->type == IEEE80211_IF_TYPE_AP ||
vif->type == IEEE80211_IF_TYPE_IBSS)
intf->delayed_flags |= DELAYED_UPDATE_BEACON;
spin_unlock(&intf->lock);
}
int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
{
int retval;
NOTICE(rt2x00dev, "Waking up.\n");
/*
* Restore/enable extra components.
*/
rt2x00debug_register(rt2x00dev);
rt2x00rfkill_resume(rt2x00dev);
rt2x00leds_resume(rt2x00dev);
* Only continue if mac80211 had open interfaces.
if (!__test_and_clear_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags))
/*
* Reinitialize device and all active interfaces.
*/
retval = rt2x00lib_start(rt2x00dev);
if (retval)
goto exit;
/*
* Reconfigure device.
*/
rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, 1);
if (!rt2x00dev->hw->conf.radio_enabled)
rt2x00lib_disable_radio(rt2x00dev);
/*
* Iterator over each active interface to
* reconfigure the hardware.
*/
ieee80211_iterate_active_interfaces(rt2x00dev->hw,
rt2x00lib_resume_intf, rt2x00dev);
/*
* We are ready again to receive requests from mac80211.
*/
__set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
/*
* It is possible that during that mac80211 has attempted
* to send frames while we were suspending or resuming.
* In that case we have disabled the TX queue and should
* now enable it again
*/
ieee80211_wake_queues(rt2x00dev->hw);
* During interface iteration we might have changed the
* delayed_flags, time to handles the event by calling
* the work handler directly.
rt2x00lib_intf_scheduled(&rt2x00dev->intf_work);
return 0;
exit:
rt2x00lib_disable_radio(rt2x00dev);
rt2x00lib_uninitialize(rt2x00dev);
rt2x00debug_deregister(rt2x00dev);
return retval;
}
EXPORT_SYMBOL_GPL(rt2x00lib_resume);
#endif /* CONFIG_PM */
/*
* rt2x00lib module information.
*/
MODULE_AUTHOR(DRV_PROJECT);
MODULE_VERSION(DRV_VERSION);
MODULE_DESCRIPTION("rt2x00 library");
MODULE_LICENSE("GPL");