--- zzzz-none-000/linux-3.10.107/drivers/net/wireless/orinoco/orinoco_usb.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/net/wireless/orinoco/orinoco_usb.c 2021-02-04 17:41:59.000000000 +0000 @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -101,25 +100,11 @@ .code = NULL, }; -#ifdef CONFIG_USB_DEBUG -static int debug = 1; -#else -static int debug; -#endif - /* Debugging macros */ -#undef dbg -#define dbg(format, arg...) \ - do { if (debug) printk(KERN_DEBUG PFX "%s: " format "\n", \ - __func__ , ## arg); } while (0) #undef err #define err(format, arg...) \ do { printk(KERN_ERR PFX format "\n", ## arg); } while (0) -/* Module paramaters */ -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Debug enabled or not"); - MODULE_FIRMWARE("orinoco_ezusb_fw"); /* @@ -342,7 +327,7 @@ ctx->state = EZUSB_CTX_REQ_TIMEOUT; } else { ctx->state = EZUSB_CTX_RESP_TIMEOUT; - dbg("couldn't unlink"); + dev_dbg(&ctx->outurb->dev->dev, "couldn't unlink\n"); atomic_inc(&ctx->refcount); ctx->killed = 1; ezusb_ctx_complete(ctx); @@ -379,9 +364,7 @@ atomic_set(&ctx->refcount, 1); init_completion(&ctx->done); - init_timer(&ctx->timer); - ctx->timer.function = ezusb_request_timerfn; - ctx->timer.data = (u_long) ctx; + setup_timer(&ctx->timer, ezusb_request_timerfn, (u_long)ctx); return ctx; } @@ -549,7 +532,7 @@ if (ctx->killed) { spin_unlock_irqrestore(&upriv->req_lock, flags); - pr_warning("interrupt called with dead ctx"); + pr_warn("interrupt called with dead ctx\n"); goto out; } @@ -635,9 +618,9 @@ ctx = c; break; } - dbg("Skipped (0x%x/0x%x) (%d/%d)", - le16_to_cpu(ans->hermes_rid), - c->in_rid, ans->ans_reply_count, reply_count); + netdev_dbg(upriv->dev, "Skipped (0x%x/0x%x) (%d/%d)\n", + le16_to_cpu(ans->hermes_rid), c->in_rid, + ans->ans_reply_count, reply_count); } } @@ -686,8 +669,8 @@ default: spin_unlock_irqrestore(&upriv->req_lock, flags); - pr_warning("Matched IN URB, unexpected context state(0x%x)", - state); + pr_warn("Matched IN URB, unexpected context state(0x%x)\n", + state); /* Throw this CTX away and try submitting another */ del_timer(&ctx->timer); ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK; @@ -769,7 +752,7 @@ void *cur_buf = upriv->read_urb->transfer_buffer; if (upriv->read_urb->status == -EINPROGRESS) { - dbg("urb busy, not resubmiting"); + netdev_dbg(upriv->dev, "urb busy, not resubmiting\n"); retval = -EBUSY; goto exit; } @@ -839,8 +822,9 @@ memcpy(fw_buffer, &fw->code[addr], FW_BUF_SIZE); if (variant_offset >= addr && variant_offset < addr + FW_BUF_SIZE) { - dbg("Patching card_variant byte at 0x%04X", - variant_offset); + netdev_dbg(upriv->dev, + "Patching card_variant byte at 0x%04X\n", + variant_offset); fw_buffer[variant_offset - addr] = FW_VAR_VALUE; } retval = usb_control_msg(upriv->udev, @@ -880,8 +864,8 @@ BUG_ON(in_irq()); if (!upriv->udev) { - dbg("Device disconnected"); - return -ENODEV; + retval = -ENODEV; + goto exit; } if (upriv->read_urb->status != -EINPROGRESS) @@ -935,7 +919,6 @@ retval = -EFAULT; } goto exit; - break; } if (ctx->in_rid) { struct ezusb_packet *ans = ctx->buf; @@ -1023,8 +1006,9 @@ cpu_to_le16(parm1), cpu_to_le16(parm2), }; - dbg("0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X", - cmd, parm0, parm1, parm2); + netdev_dbg(upriv->dev, + "0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X\n", cmd, + parm0, parm1, parm2); ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK); if (!ctx) return -ENOMEM; @@ -1045,7 +1029,7 @@ 0, 0, }; - dbg("0x%04X, parm0 0x%04X", cmd, parm0); + netdev_dbg(upriv->dev, "0x%04X, parm0 0x%04X\n", cmd, parm0); ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK); if (!ctx) return -ENOMEM; @@ -1332,7 +1316,7 @@ return retval; } - dbg("sending control message"); + netdev_dbg(upriv->dev, "sending control message\n"); retval = usb_control_msg(upriv->udev, usb_sndctrlpipe(upriv->udev, 0), EZUSB_REQUEST_TRIGER, @@ -1401,32 +1385,31 @@ u16 crc; u16 hermes_rid; - if (upriv->udev == NULL) { - dbg("disconnected"); + if (upriv->udev == NULL) return; - } if (urb->status == -ETIMEDOUT) { /* When a device gets unplugged we get this every time * we resubmit, flooding the logs. Since we don't use * USB timeouts, it shouldn't happen any other time*/ - pr_warning("%s: urb timed out, not resubmiting", __func__); + pr_warn("%s: urb timed out, not resubmitting\n", __func__); return; } if (urb->status == -ECONNABORTED) { - pr_warning("%s: connection abort, resubmiting urb", - __func__); + pr_warn("%s: connection abort, resubmitting urb\n", + __func__); goto resubmit; } if ((urb->status == -EILSEQ) || (urb->status == -ENOENT) || (urb->status == -ECONNRESET)) { - dbg("status %d, not resubmiting", urb->status); + netdev_dbg(upriv->dev, "status %d, not resubmiting\n", + urb->status); return; } if (urb->status) - dbg("status: %d length: %d", - urb->status, urb->actual_length); + netdev_dbg(upriv->dev, "status: %d length: %d\n", + urb->status, urb->actual_length); if (urb->actual_length < sizeof(*ans)) { err("%s: short read, ignoring", __func__); goto resubmit; @@ -1519,6 +1502,7 @@ if (upriv->dev) { struct orinoco_private *priv = ndev_priv(upriv->dev); orinoco_if_del(priv); + wiphy_unregister(priv_to_wiphy(upriv)); free_orinocodev(priv); } } @@ -1592,6 +1576,7 @@ ezusb_hard_reset, NULL); if (!priv) { err("Couldn't allocate orinocodev"); + retval = -ENOMEM; goto exit; } @@ -1620,13 +1605,10 @@ for (i = 0; i < iface_desc->bNumEndpoints; ++i) { ep = &interface->altsetting[0].endpoint[i].desc; - if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) - == USB_DIR_IN) && - ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) - == USB_ENDPOINT_XFER_BULK)) { + if (usb_endpoint_is_bulk_in(ep)) { /* we found a bulk in endpoint */ if (upriv->read_urb != NULL) { - pr_warning("Found a second bulk in ep, ignored"); + pr_warn("Found a second bulk in ep, ignored\n"); continue; } @@ -1636,10 +1618,10 @@ goto error; } if (le16_to_cpu(ep->wMaxPacketSize) != 64) - pr_warning("bulk in: wMaxPacketSize!= 64"); + pr_warn("bulk in: wMaxPacketSize!= 64\n"); if (ep->bEndpointAddress != (2 | USB_DIR_IN)) - pr_warning("bulk in: bEndpointAddress: %d", - ep->bEndpointAddress); + pr_warn("bulk in: bEndpointAddress: %d\n", + ep->bEndpointAddress); upriv->read_pipe = usb_rcvbulkpipe(udev, ep-> bEndpointAddress); @@ -1651,21 +1633,18 @@ } } - if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) - == USB_DIR_OUT) && - ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) - == USB_ENDPOINT_XFER_BULK)) { + if (usb_endpoint_is_bulk_out(ep)) { /* we found a bulk out endpoint */ if (upriv->bap_buf != NULL) { - pr_warning("Found a second bulk out ep, ignored"); + pr_warn("Found a second bulk out ep, ignored\n"); continue; } if (le16_to_cpu(ep->wMaxPacketSize) != 64) - pr_warning("bulk out: wMaxPacketSize != 64"); + pr_warn("bulk out: wMaxPacketSize != 64\n"); if (ep->bEndpointAddress != 2) - pr_warning("bulk out: bEndpointAddress: %d", - ep->bEndpointAddress); + pr_warn("bulk out: bEndpointAddress: %d\n", + ep->bEndpointAddress); upriv->write_pipe = usb_sndbulkpipe(udev, ep-> bEndpointAddress); @@ -1687,7 +1666,7 @@ firmware.code = fw_entry->data; } if (firmware.size && firmware.code) { - if (ezusb_firmware_download(upriv, &firmware)) + if (ezusb_firmware_download(upriv, &firmware) < 0) goto error; } else { err("No firmware to download"); @@ -1718,6 +1697,7 @@ if (orinoco_if_add(priv, 0, 0, &ezusb_netdev_ops) != 0) { upriv->dev = NULL; err("%s: orinoco_if_add() failed", __func__); + wiphy_unregister(priv_to_wiphy(priv)); goto error; } upriv->dev = priv->ndev;