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: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Родитель
31562e802a
Коммит
47b10cd137
|
@ -292,6 +292,12 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
|
|||
unsigned int 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) {
|
||||
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
|
||||
MAC_CSR20_LINK, enabled);
|
||||
|
@ -299,8 +305,8 @@ static void rt2500usb_led_brightness(struct led_classdev *led_cdev,
|
|||
MAC_CSR20_ACTIVITY, enabled && activity);
|
||||
}
|
||||
|
||||
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_SINGLE_WRITE,
|
||||
MAC_CSR20, led->rt2x00dev->led_mcu_reg);
|
||||
rt2500usb_register_write(led->rt2x00dev, MAC_CSR20,
|
||||
led->rt2x00dev->led_mcu_reg);
|
||||
}
|
||||
#else
|
||||
#define rt2500usb_led_brightness NULL
|
||||
|
|
|
@ -122,58 +122,6 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
|
|||
}
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -194,24 +194,6 @@ static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -290,29 +290,38 @@ static void rt73usb_led_brightness(struct led_classdev *led_cdev,
|
|||
unsigned int bg_mode =
|
||||
(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) {
|
||||
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
|
||||
MCU_LEDCS_RADIO_STATUS, enabled);
|
||||
|
||||
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL,
|
||||
0, led->rt2x00dev->led_mcu_reg);
|
||||
rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
|
||||
0, led->rt2x00dev->led_mcu_reg,
|
||||
REGISTER_TIMEOUT);
|
||||
} else if (led->type == LED_TYPE_ASSOC) {
|
||||
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
|
||||
MCU_LEDCS_LINK_BG_STATUS, bg_mode);
|
||||
rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
|
||||
MCU_LEDCS_LINK_A_STATUS, a_mode);
|
||||
|
||||
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL,
|
||||
0, led->rt2x00dev->led_mcu_reg);
|
||||
rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
|
||||
0, led->rt2x00dev->led_mcu_reg,
|
||||
REGISTER_TIMEOUT);
|
||||
} else if (led->type == LED_TYPE_QUALITY) {
|
||||
/*
|
||||
* The brightness is divided into 6 levels (0 - 5),
|
||||
* this means we need to convert the brightness
|
||||
* argument into the matching level within that range.
|
||||
*/
|
||||
rt2x00usb_vendor_request_async(led->rt2x00dev, USB_LED_CONTROL,
|
||||
brightness / (LED_FULL / 6),
|
||||
led->rt2x00dev->led_mcu_reg);
|
||||
rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
|
||||
brightness / (LED_FULL / 6),
|
||||
led->rt2x00dev->led_mcu_reg,
|
||||
REGISTER_TIMEOUT);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
Загрузка…
Ссылка в новой задаче