Commit 47b10cd1 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

rt2x00: Remove async vendor request calls from rt2x00usb

The async vendor requests are a ugly hack which is not working correctly.
The proper fix for the scheduling while atomic issue is finding out why
we can't use led classes for USB drivers and fix that.

Just replace all async calls with the regular ones and print an
error for the disallowed LED configuration attempts. That will
help in determining which led class is causing the problem.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 31562e80
...@@ -292,6 +292,12 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev, ...@@ -292,6 +292,12 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
unsigned int activity = unsigned int activity =
led->rt2x00dev->led_flags & LED_SUPPORT_ACTIVITY; led->rt2x00dev->led_flags & LED_SUPPORT_ACTIVITY;
if (in_atomic()) {
NOTICE(led->rt2x00dev,
"Ignoring LED brightness command for led %d", led->type);
return;
}
if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC) { if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC) {
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg, rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
MAC_CSR20_LINK, enabled); MAC_CSR20_LINK, enabled);
...@@ -299,8 +305,8 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev, ...@@ -299,8 +305,8 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
MAC_CSR20_ACTIVITY, enabled && activity); MAC_CSR20_ACTIVITY, enabled && activity);
} }
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_SINGLE_WRITE, rt2500usb_register_write(led->rt2x00dev, MAC_CSR20,
MAC_CSR20, led->rt2x00dev->led_mcu_reg); led->rt2x00dev->led_mcu_reg);
} }
#else #else
#define rt2500usb_led_brightness NULL #define rt2500usb_led_brightness NULL
......
...@@ -122,58 +122,6 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev, ...@@ -122,58 +122,6 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
} }
EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_buff); EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_buff);
static void rt2x00usb_vendor_request_async_complete(struct urb *urb)
{
/*
* We're done with it, descrease usage count and let the
* usb layer delete it as soon as it is done with it.
*/
usb_put_urb(urb);
}
int rt2x00usb_vendor_request_async(struct rt2x00_dev *rt2x00dev,
const u8 request, const u16 offset,
const u16 value)
{
struct usb_device *usb_dev = rt2x00dev_usb_dev(rt2x00dev);
struct usb_ctrlrequest *ctrl;
struct urb *urb;
int status;
urb = usb_alloc_urb(0, GFP_NOIO);
if (!urb)
return -ENOMEM;
ctrl = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
if (!ctrl) {
status = -ENOMEM;
goto exit;
}
ctrl->bRequestType= USB_VENDOR_REQUEST_OUT;
ctrl->bRequest = request;
ctrl->wValue = cpu_to_le16p(&value);
ctrl->wIndex = cpu_to_le16p(&offset);
ctrl->wLength = 0;
usb_fill_control_urb(urb, usb_dev, usb_sndctrlpipe(usb_dev, 0),
(unsigned char *)ctrl, NULL, 0,
rt2x00usb_vendor_request_async_complete, NULL);
status = usb_submit_urb(urb, GFP_ATOMIC);
if (!status)
goto exit;
return 0;
exit:
usb_put_urb(urb);
kfree(ctrl);
return status;
}
EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_async);
/* /*
* TX data handlers. * TX data handlers.
*/ */
......
...@@ -194,24 +194,6 @@ static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev, ...@@ -194,24 +194,6 @@ static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
eeprom, lenght, timeout); eeprom, lenght, timeout);
} }
/**
* rt2x00usb_vendor_request_async - Send register command to device (async)
* @rt2x00dev: Pointer to &struct rt2x00_dev
* @request: USB vendor command (See &enum rt2x00usb_vendor_request)
* @offset: Register offset to perform action on
* @value: Value to write to device
*
* Asynchroneous version of &rt2x00usb_vendor_request this is required
* for some routines where the driver cannot sleep because it is in
* irq context. Note that with this function the driver will not be
* notified on failure or timeout of the command. It will only be notified
* if the start of the command succeeded or not. This means it should not be
* used when the command must succeed.
*/
int rt2x00usb_vendor_request_async(struct rt2x00_dev *rt2x00dev,
const u8 request, const u16 offset,
const u16 value);
/* /*
* Radio handlers * Radio handlers
*/ */
......
...@@ -290,29 +290,38 @@ static void rt73usb_led_brightness(struct led_classdev *led_cdev, ...@@ -290,29 +290,38 @@ static void rt73usb_led_brightness(struct led_classdev *led_cdev,
unsigned int bg_mode = unsigned int bg_mode =
(enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ); (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
if (in_atomic()) {
NOTICE(led->rt2x00dev,
"Ignoring LED brightness command for led %d", led->type);
return;
}
if (led->type == LED_TYPE_RADIO) { if (led->type == LED_TYPE_RADIO) {
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg, rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
MCU_LEDCS_RADIO_STATUS, enabled); MCU_LEDCS_RADIO_STATUS, enabled);
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL, rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
0, led->rt2x00dev->led_mcu_reg); 0, led->rt2x00dev->led_mcu_reg,
REGISTER_TIMEOUT);
} else if (led->type == LED_TYPE_ASSOC) { } else if (led->type == LED_TYPE_ASSOC) {
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg, rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
MCU_LEDCS_LINK_BG_STATUS, bg_mode); MCU_LEDCS_LINK_BG_STATUS, bg_mode);
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg, rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
MCU_LEDCS_LINK_A_STATUS, a_mode); MCU_LEDCS_LINK_A_STATUS, a_mode);
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL, rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
0, led->rt2x00dev->led_mcu_reg); 0, led->rt2x00dev->led_mcu_reg,
REGISTER_TIMEOUT);
} else if (led->type == LED_TYPE_QUALITY) { } else if (led->type == LED_TYPE_QUALITY) {
/* /*
* The brightness is divided into 6 levels (0 - 5), * The brightness is divided into 6 levels (0 - 5),
* this means we need to convert the brightness * this means we need to convert the brightness
* argument into the matching level within that range. * argument into the matching level within that range.
*/ */
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL, rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
brightness / (LED_FULL / 6), brightness / (LED_FULL / 6),
led->rt2x00dev->led_mcu_reg); led->rt2x00dev->led_mcu_reg,
REGISTER_TIMEOUT);
} }
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment