int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
{
	int retval;

	if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
		return 0;

	/*
	 * If this is the first interface which is added,
	 * we should load the firmware now.
	 */
	retval = rt2x00lib_load_firmware(rt2x00dev);
	if (retval)
		return retval;

	/*
	 * Initialize the device.
	 */
	retval = rt2x00lib_initialize(rt2x00dev);
	if (retval)
		return retval;

	rt2x00dev->intf_ap_count = 0;
	rt2x00dev->intf_sta_count = 0;
	rt2x00dev->intf_associated = 0;

	/* Enable the radio */
	retval = rt2x00lib_enable_radio(rt2x00dev);
	if (retval)
		return retval;

	set_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags);

	return 0;
}
Example #2
0
int rt2x00mac_start(struct ieee80211_hw *hw)
{
	struct rt2x00_dev *rt2x00dev = hw->priv;
	int status;

	if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) ||
	    test_bit(DEVICE_STARTED, &rt2x00dev->flags))
		return 0;

	/*
	 * If this is the first interface which is added,
	 * we should load the firmware now.
	 */
	if (test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags)) {
		status = rt2x00lib_load_firmware(rt2x00dev);
		if (status)
			return status;
	}

	/*
	 * Initialize the device.
	 */
	status = rt2x00lib_initialize(rt2x00dev);
	if (status)
		return status;

	/*
	 * Enable radio.
	 */
	status = rt2x00lib_enable_radio(rt2x00dev);
	if (status) {
		rt2x00lib_uninitialize(rt2x00dev);
		return status;
	}

	__set_bit(DEVICE_STARTED, &rt2x00dev->flags);

	return 0;
}