aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index e11dab2216c6..832006b5aab1 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -231,9 +231,12 @@ static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer)
231 */ 231 */
232static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev) 232static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev)
233{ 233{
234 __le32 reg; 234 __le32 *reg;
235 u32 fw_mode; 235 u32 fw_mode;
236 236
237 reg = kmalloc(sizeof(*reg), GFP_KERNEL);
238 if (reg == NULL)
239 return -ENOMEM;
237 /* cannot use rt2x00usb_register_read here as it uses different 240 /* cannot use rt2x00usb_register_read here as it uses different
238 * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the 241 * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the
239 * magic value USB_MODE_AUTORUN (0x11) to the device, thus the 242 * magic value USB_MODE_AUTORUN (0x11) to the device, thus the
@@ -241,8 +244,9 @@ static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev)
241 */ 244 */
242 rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE, 245 rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
243 USB_VENDOR_REQUEST_IN, 0, USB_MODE_AUTORUN, 246 USB_VENDOR_REQUEST_IN, 0, USB_MODE_AUTORUN,
244 &reg, sizeof(reg), REGISTER_TIMEOUT_FIRMWARE); 247 reg, sizeof(*reg), REGISTER_TIMEOUT_FIRMWARE);
245 fw_mode = le32_to_cpu(reg); 248 fw_mode = le32_to_cpu(*reg);
249 kfree(reg);
246 250
247 if ((fw_mode & 0x00000003) == 2) 251 if ((fw_mode & 0x00000003) == 2)
248 return 1; 252 return 1;
@@ -261,6 +265,7 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
261 int status; 265 int status;
262 u32 offset; 266 u32 offset;
263 u32 length; 267 u32 length;
268 int retval;
264 269
265 /* 270 /*
266 * Check which section of the firmware we need. 271 * Check which section of the firmware we need.
@@ -278,7 +283,10 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
278 /* 283 /*
279 * Write firmware to device. 284 * Write firmware to device.
280 */ 285 */
281 if (rt2800usb_autorun_detect(rt2x00dev)) { 286 retval = rt2800usb_autorun_detect(rt2x00dev);
287 if (retval < 0)
288 return retval;
289 if (retval) {
282 rt2x00_info(rt2x00dev, 290 rt2x00_info(rt2x00dev,
283 "Firmware loading not required - NIC in AutoRun mode\n"); 291 "Firmware loading not required - NIC in AutoRun mode\n");
284 } else { 292 } else {
@@ -763,7 +771,12 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
763 */ 771 */
764static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev) 772static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev)
765{ 773{
766 if (rt2800usb_autorun_detect(rt2x00dev)) 774 int retval;
775
776 retval = rt2800usb_autorun_detect(rt2x00dev);
777 if (retval < 0)
778 return retval;
779 if (retval)
767 return 1; 780 return 1;
768 return rt2800_efuse_detect(rt2x00dev); 781 return rt2800_efuse_detect(rt2x00dev);
769} 782}
@@ -772,7 +785,10 @@ static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev)
772{ 785{
773 int retval; 786 int retval;
774 787
775 if (rt2800usb_efuse_detect(rt2x00dev)) 788 retval = rt2800usb_efuse_detect(rt2x00dev);
789 if (retval < 0)
790 return retval;
791 if (retval)
776 retval = rt2800_read_eeprom_efuse(rt2x00dev); 792 retval = rt2800_read_eeprom_efuse(rt2x00dev);
777 else 793 else
778 retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, 794 retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,