Pull USB fixes from Greg Kroah-Hartman: "Here are a number of USB fixes that resolve issues that have been reported against 3.9-rc3." * tag 'usb-3.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (37 commits) USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT USB: ssu100: fix use-after-free in TIOCMIWAIT USB: spcp8x5: fix use-after-free in TIOCMIWAIT USB: quatech2: fix use-after-free in TIOCMIWAIT USB: pl2303: fix use-after-free in TIOCMIWAIT USB: oti6858: fix use-after-free in TIOCMIWAIT USB: mos7840: fix use-after-free in TIOCMIWAIT USB: mos7840: fix broken TIOCMIWAIT USB: mct_u232: fix use-after-free in TIOCMIWAIT USB: io_ti: fix use-after-free in TIOCMIWAIT USB: io_edgeport: fix use-after-free in TIOCMIWAIT USB: ftdi_sio: fix use-after-free in TIOCMIWAIT USB: f81232: fix use-after-free in TIOCMIWAIT USB: cypress_m8: fix use-after-free in TIOCMIWAIT USB: ch341: fix use-after-free in TIOCMIWAIT USB: ark3116: fix use-after-free in TIOCMIWAIT USB: serial: add modem-status-change wait queue USB: serial: fix interface refcounting USB: io_ti: fix get_icount for two port adapters USB: garmin_gps: fix memory leak on disconnect ...
Unified · Split
| @@ -593,7 +593,6 @@ static void acm_port_destruct(struct tty_port *port) · 592 unmodified lines | ||
| 593 | 593 | |
| 594 | 594 | dev_dbg(&acm->control->dev, "%s\n", __func__); |
| 595 | 595 | |
| 596 | − tty_unregister_device(acm_tty_driver, acm->minor); | |
| 597 | 596 | acm_release_minor(acm); |
| 598 | 597 | usb_put_intf(acm->control); |
| 599 | 598 | kfree(acm->country_codes); |
| @@ -977,6 +976,8 @@ static int acm_probe(struct usb_interface *intf, · 377 unmodified lines | ||
| 977 | 976 | int num_rx_buf; |
| 978 | 977 | int i; |
| 979 | 978 | int combined_interfaces = 0; |
| 979 | + struct device *tty_dev; | |
| 980 | + int rv = -ENOMEM; | |
| 980 | 981 | |
| 981 | 982 | /* normal quirks */ |
| 982 | 983 | quirks = (unsigned long)id->driver_info; |
| @@ -1339,11 +1340,24 @@ skip_countries: · 356 unmodified lines | ||
| 1339 | 1340 | usb_set_intfdata(data_interface, acm); |
| 1340 | 1341 | |
| 1341 | 1342 | usb_get_intf(control_interface); |
| 1342 | − tty_port_register_device(&acm->port, acm_tty_driver, minor, | |
| 1343 | + tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor, | |
| 1343 | 1344 | &control_interface->dev); |
| 1345 | + if (IS_ERR(tty_dev)) { | |
| 1346 | + rv = PTR_ERR(tty_dev); | |
| 1347 | + goto alloc_fail8; | |
| 1348 | + } | |
| 1344 | 1349 | |
| 1345 | 1350 | return 0; |
| 1351 | +alloc_fail8: | |
| 1352 | + if (acm->country_codes) { | |
| 1353 | + device_remove_file(&acm->control->dev, | |
| 1354 | + &dev_attr_wCountryCodes); | |
| 1355 | + device_remove_file(&acm->control->dev, | |
| 1356 | + &dev_attr_iCountryCodeRelDate); | |
| 1357 | + } | |
| 1358 | + device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); | |
| 1346 | 1359 | alloc_fail7: |
| 1360 | + usb_set_intfdata(intf, NULL); | |
| 1347 | 1361 | for (i = 0; i < ACM_NW; i++) |
| 1348 | 1362 | usb_free_urb(acm->wb[i].urb); |
| 1349 | 1363 | alloc_fail6: |
| @@ -1359,7 +1373,7 @@ alloc_fail2: · 9 unmodified lines | ||
| 1359 | 1373 | acm_release_minor(acm); |
| 1360 | 1374 | kfree(acm); |
| 1361 | 1375 | alloc_fail: |
| 1362 | − return -ENOMEM; | |
| 1376 | + return rv; | |
| 1363 | 1377 | } |
| 1364 | 1378 | |
| 1365 | 1379 | static void stop_data_traffic(struct acm *acm) |
| @@ -1411,6 +1425,8 @@ static void acm_disconnect(struct usb_interface *intf) · 45 unmodified lines | ||
| 1411 | 1425 | |
| 1412 | 1426 | stop_data_traffic(acm); |
| 1413 | 1427 | |
| 1428 | + tty_unregister_device(acm_tty_driver, acm->minor); | |
| 1429 | + | |
| 1414 | 1430 | usb_free_urb(acm->ctrlurb); |
| 1415 | 1431 | for (i = 0; i < ACM_NW; i++) |
| 1416 | 1432 | usb_free_urb(acm->wb[i].urb); |
| @@ -173,6 +173,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · 172 unmodified lines | ||
| 173 | 173 | struct hc_driver *driver; |
| 174 | 174 | struct usb_hcd *hcd; |
| 175 | 175 | int retval; |
| 176 | + int hcd_irq = 0; | |
| 176 | 177 | |
| 177 | 178 | if (usb_disabled()) |
| 178 | 179 | return -ENODEV; |
| @@ -187,15 +188,19 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · 8 unmodified lines | ||
| 187 | 188 | return -ENODEV; |
| 188 | 189 | dev->current_state = PCI_D0; |
| 189 | 190 | |
| 190 | − /* The xHCI driver supports MSI and MSI-X, | |
| 191 | − * so don't fail if the BIOS doesn't provide a legacy IRQ. | |
| 191 | + /* | |
| 192 | + * The xHCI driver has its own irq management | |
| 193 | + * make sure irq setup is not touched for xhci in generic hcd code | |
| 192 | 194 | */ |
| 193 | − if (!dev->irq && (driver->flags & HCD_MASK) != HCD_USB3) { | |
| 194 | − dev_err(&dev->dev, | |
| 195 | − "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", | |
| 196 | − pci_name(dev)); | |
| 197 | − retval = -ENODEV; | |
| 198 | − goto disable_pci; | |
| 195 | + if ((driver->flags & HCD_MASK) != HCD_USB3) { | |
| 196 | + if (!dev->irq) { | |
| 197 | + dev_err(&dev->dev, | |
| 198 | + "Found HC with no IRQ. Check BIOS/PCI %s setup!\n", | |
| 199 | + pci_name(dev)); | |
| 200 | + retval = -ENODEV; | |
| 201 | + goto disable_pci; | |
| 202 | + } | |
| 203 | + hcd_irq = dev->irq; | |
| 199 | 204 | } |
| 200 | 205 | |
| 201 | 206 | hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev)); |
| @@ -245,7 +250,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) · 43 unmodified lines | ||
| 245 | 250 | |
| 246 | 251 | pci_set_master(dev); |
| 247 | 252 | |
| 248 | − retval = usb_add_hcd(hcd, dev->irq, IRQF_SHARED); | |
| 253 | + retval = usb_add_hcd(hcd, hcd_irq, IRQF_SHARED); | |
| 249 | 254 | if (retval != 0) |
| 250 | 255 | goto unmap_registers; |
| 251 | 256 | set_hs_companion(dev, hcd); |
| @@ -447,14 +447,13 @@ static void rndis_response_complete(struct usb_ep *ep, struct usb_request *req) · 446 unmodified lines | ||
| 447 | 447 | static void rndis_command_complete(struct usb_ep *ep, struct usb_request *req) |
| 448 | 448 | { |
| 449 | 449 | struct f_rndis *rndis = req->context; |
| 450 | − struct usb_composite_dev *cdev = rndis->port.func.config->cdev; | |
| 451 | 450 | int status; |
| 452 | 451 | |
| 453 | 452 | /* received RNDIS command from USB_CDC_SEND_ENCAPSULATED_COMMAND */ |
| 454 | 453 | // spin_lock(&dev->lock); |
| 455 | 454 | status = rndis_msg_parser(rndis->config, (u8 *) req->buf); |
| 456 | 455 | if (status < 0) |
| 457 | − ERROR(cdev, "RNDIS command error %d, %d/%d\n", | |
| 456 | + pr_err("RNDIS command error %d, %d/%d\n", | |
| 458 | 457 | status, req->actual, req->length); |
| 459 | 458 | // spin_unlock(&dev->lock); |
| 460 | 459 | } |
| @@ -357,7 +357,7 @@ static int gfs_bind(struct usb_composite_dev *cdev) · 356 unmodified lines | ||
| 357 | 357 | goto error; |
| 358 | 358 | gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; |
| 359 | 359 | |
| 360 | − for (i = func_num; --i; ) { | |
| 360 | + for (i = func_num; i--; ) { | |
| 361 | 361 | ret = functionfs_bind(ffs_tab[i].ffs_data, cdev); |
| 362 | 362 | if (unlikely(ret < 0)) { |
| 363 | 363 | while (++i < func_num) |
| @@ -413,7 +413,7 @@ static int gfs_unbind(struct usb_composite_dev *cdev) · 49 unmodified lines | ||
| 413 | 413 | gether_cleanup(); |
| 414 | 414 | gfs_ether_setup = false; |
| 415 | 415 | |
| 416 | − for (i = func_num; --i; ) | |
| 416 | + for (i = func_num; i--; ) | |
| 417 | 417 | if (ffs_tab[i].ffs_data) |
| 418 | 418 | functionfs_unbind(ffs_tab[i].ffs_data); |
| 419 | 419 | |
| @@ -59,7 +59,7 @@ static const char * const ep_name[] = { · 58 unmodified lines | ||
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) |
| 62 | −#ifdef CONFIG_USB_GADGET_NET2272_DMA | |
| 62 | +#ifdef CONFIG_USB_NET2272_DMA | |
| 63 | 63 | /* |
| 64 | 64 | * use_dma: the NET2272 can use an external DMA controller. |
| 65 | 65 | * Note that since there is no generic DMA api, some functions, |
| @@ -1495,6 +1495,13 @@ stop_activity(struct net2272 *dev, struct usb_gadget_driver *driver) · 1429 unmodified lines | ||
| 1495 | 1495 | for (i = 0; i < 4; ++i) |
| 1496 | 1496 | net2272_dequeue_all(&dev->ep[i]); |
| 1497 | 1497 | |
| 1498 | + /* report disconnect; the driver is already quiesced */ | |
| 1499 | + if (driver) { | |
| 1500 | + spin_unlock(&dev->lock); | |
| 1501 | + driver->disconnect(&dev->gadget); | |
| 1502 | + spin_lock(&dev->lock); | |
| 1503 | + } | |
| 1504 | + | |
| 1498 | 1505 | net2272_usb_reinit(dev); |
| 1499 | 1506 | } |
| 1500 | 1507 | |
| @@ -1924,7 +1924,6 @@ static int net2280_start(struct usb_gadget *_gadget, · 1923 unmodified lines | ||
| 1924 | 1924 | err_func: |
| 1925 | 1925 | device_remove_file (&dev->pdev->dev, &dev_attr_function); |
| 1926 | 1926 | err_unbind: |
| 1927 | − driver->unbind (&dev->gadget); | |
| 1928 | 1927 | dev->gadget.dev.driver = NULL; |
| 1929 | 1928 | dev->driver = NULL; |
| 1930 | 1929 | return retval; |
| @@ -1946,6 +1945,13 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver) · 15 unmodified lines | ||
| 1946 | 1945 | for (i = 0; i < 7; i++) |
| 1947 | 1946 | nuke (&dev->ep [i]); |
| 1948 | 1947 | |
| 1948 | + /* report disconnect; the driver is already quiesced */ | |
| 1949 | + if (driver) { | |
| 1950 | + spin_unlock(&dev->lock); | |
| 1951 | + driver->disconnect(&dev->gadget); | |
| 1952 | + spin_lock(&dev->lock); | |
| 1953 | + } | |
| 1954 | + | |
| 1949 | 1955 | usb_reinit (dev); |
| 1950 | 1956 | } |
| 1951 | 1957 | |
| @@ -136,7 +136,7 @@ static struct portmaster { · 135 unmodified lines | ||
| 136 | 136 | pr_debug(fmt, ##arg) |
| 137 | 137 | #endif /* pr_vdebug */ |
| 138 | 138 | #else |
| 139 | −#ifndef pr_vdebig | |
| 139 | +#ifndef pr_vdebug | |
| 140 | 140 | #define pr_vdebug(fmt, arg...) \ |
| 141 | 141 | ({ if (0) pr_debug(fmt, ##arg); }) |
| 142 | 142 | #endif /* pr_vdebug */ |
| @@ -216,7 +216,7 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) · 215 unmodified lines | ||
| 216 | 216 | usb_gadget_disconnect(udc->gadget); |
| 217 | 217 | udc->driver->disconnect(udc->gadget); |
| 218 | 218 | udc->driver->unbind(udc->gadget); |
| 219 | − usb_gadget_udc_stop(udc->gadget, udc->driver); | |
| 219 | + usb_gadget_udc_stop(udc->gadget, NULL); | |
| 220 | 220 | |
| 221 | 221 | udc->driver = NULL; |
| 222 | 222 | udc->dev.driver = NULL; |
| @@ -302,6 +302,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci) · 301 unmodified lines | ||
| 302 | 302 | |
| 303 | 303 | static void end_unlink_async(struct ehci_hcd *ehci); |
| 304 | 304 | static void unlink_empty_async(struct ehci_hcd *ehci); |
| 305 | +static void unlink_empty_async_suspended(struct ehci_hcd *ehci); | |
| 305 | 306 | static void ehci_work(struct ehci_hcd *ehci); |
| 306 | 307 | static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); |
| 307 | 308 | static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); |
| @@ -328,7 +328,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) · 327 unmodified lines | ||
| 328 | 328 | ehci->rh_state = EHCI_RH_SUSPENDED; |
| 329 | 329 | |
| 330 | 330 | end_unlink_async(ehci); |
| 331 | − unlink_empty_async(ehci); | |
| 331 | + unlink_empty_async_suspended(ehci); | |
| 332 | 332 | ehci_handle_intr_unlinks(ehci); |
| 333 | 333 | end_free_itds(ehci); |
| 334 | 334 | |
| @@ -1316,6 +1316,19 @@ static void unlink_empty_async(struct ehci_hcd *ehci) · 1315 unmodified lines | ||
| 1316 | 1316 | } |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | +/* The root hub is suspended; unlink all the async QHs */ | |
| 1320 | +static void unlink_empty_async_suspended(struct ehci_hcd *ehci) | |
| 1321 | +{ | |
| 1322 | + struct ehci_qh *qh; | |
| 1323 | + | |
| 1324 | + while (ehci->async->qh_next.qh) { | |
| 1325 | + qh = ehci->async->qh_next.qh; | |
| 1326 | + WARN_ON(!list_empty(&qh->qtd_list)); | |
| 1327 | + single_unlink_async(ehci, qh); | |
| 1328 | + } | |
| 1329 | + start_iaa_cycle(ehci, false); | |
| 1330 | +} | |
| 1331 | + | |
| 1319 | 1332 | /* makes sure the async qh will become idle */ |
| 1320 | 1333 | /* caller must own ehci->lock */ |
| 1321 | 1334 | |
| @@ -304,7 +304,7 @@ static void ehci_iaa_watchdog(struct ehci_hcd *ehci) · 303 unmodified lines | ||
| 304 | 304 | * (a) SMP races against real IAA firing and retriggering, and |
| 305 | 305 | * (b) clean HC shutdown, when IAA watchdog was pending. |
| 306 | 306 | */ |
| 307 | − if (ehci->async_iaa) { | |
| 307 | + if (1) { | |
| 308 | 308 | u32 cmd, status; |
| 309 | 309 | |
| 310 | 310 | /* If we get here, IAA is *REALLY* late. It's barely |
| @@ -350,7 +350,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) · 349 unmodified lines | ||
| 350 | 350 | * generate interrupts. Don't even try to enable MSI. |
| 351 | 351 | */ |
| 352 | 352 | if (xhci->quirks & XHCI_BROKEN_MSI) |
| 353 | − return 0; | |
| 353 | + goto legacy_irq; | |
| 354 | 354 | |
| 355 | 355 | /* unregister the legacy interrupt */ |
| 356 | 356 | if (hcd->irq) |
| @@ -371,6 +371,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) · 14 unmodified lines | ||
| 371 | 371 | return -EINVAL; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | + legacy_irq: | |
| 374 | 375 | /* fall back to legacy interrupt*/ |
| 375 | 376 | ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, |
| 376 | 377 | hcd->irq_descr, hcd); |
| @@ -206,8 +206,8 @@ struct xhci_op_regs { · 205 unmodified lines | ||
| 206 | 206 | /* bits 12:31 are reserved (and should be preserved on writes). */ |
| 207 | 207 | |
| 208 | 208 | /* IMAN - Interrupt Management Register */ |
| 209 | −#define IMAN_IP (1 << 1) | |
| 210 | −#define IMAN_IE (1 << 0) | |
| 209 | +#define IMAN_IE (1 << 1) | |
| 210 | +#define IMAN_IP (1 << 0) | |
| 211 | 211 | |
| 212 | 212 | /* USBSTS - USB status - status bitmasks */ |
| 213 | 213 | /* HC not running - set to 1 when run/stop bit is cleared. */ |
| @@ -327,7 +327,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) · 326 unmodified lines | ||
| 327 | 327 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); |
| 328 | 328 | int err; |
| 329 | 329 | |
| 330 | − err = musb->int_usb & USB_INTR_VBUSERROR; | |
| 330 | + err = musb->int_usb & MUSB_INTR_VBUSERROR; | |
| 331 | 331 | if (err) { |
| 332 | 332 | /* |
| 333 | 333 | * The Mentor core doesn't debounce VBUS as needed |
| @@ -141,7 +141,9 @@ static inline void map_dma_buffer(struct musb_request *request, · 140 unmodified lines | ||
| 141 | 141 | static inline void unmap_dma_buffer(struct musb_request *request, |
| 142 | 142 | struct musb *musb) |
| 143 | 143 | { |
| 144 | − if (!is_buffer_mapped(request)) | |
| 144 | + struct musb_ep *musb_ep = request->ep; | |
| 145 | + | |
| 146 | + if (!is_buffer_mapped(request) || !musb_ep->dma) | |
| 145 | 147 | return; |
| 146 | 148 | |
| 147 | 149 | if (request->request.dma == DMA_ADDR_INVALID) { |
| @@ -195,7 +197,10 @@ __acquires(ep->musb->lock) · 47 unmodified lines | ||
| 195 | 197 | |
| 196 | 198 | ep->busy = 1; |
| 197 | 199 | spin_unlock(&musb->lock); |
| 198 | − unmap_dma_buffer(req, musb); | |
| 200 | + | |
| 201 | + if (!dma_mapping_error(&musb->g.dev, request->dma)) | |
| 202 | + unmap_dma_buffer(req, musb); | |
| 203 | + | |
| 199 | 204 | if (request->status == 0) |
| 200 | 205 | dev_dbg(musb->controller, "%s done request %p, %d/%d\n", |
| 201 | 206 | ep->end_point.name, request, |
| @@ -62,7 +62,6 @@ static int is_irda(struct usb_serial *serial) · 61 unmodified lines | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | struct ark3116_private { |
| 65 | − wait_queue_head_t delta_msr_wait; | |
| 66 | 65 | struct async_icount icount; |
| 67 | 66 | int irda; /* 1 for irda device */ |
| 68 | 67 | |
| @@ -146,7 +145,6 @@ static int ark3116_port_probe(struct usb_serial_port *port) · 77 unmodified lines | ||
| 146 | 145 | if (!priv) |
| 147 | 146 | return -ENOMEM; |
| 148 | 147 | |
| 149 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 150 | 148 | mutex_init(&priv->hw_lock); |
| 151 | 149 | spin_lock_init(&priv->status_lock); |
| 152 | 150 | |
| @@ -456,10 +454,14 @@ static int ark3116_ioctl(struct tty_struct *tty, · 303 unmodified lines | ||
| 456 | 454 | case TIOCMIWAIT: |
| 457 | 455 | for (;;) { |
| 458 | 456 | struct async_icount prev = priv->icount; |
| 459 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 457 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 460 | 458 | /* see if a signal did it */ |
| 461 | 459 | if (signal_pending(current)) |
| 462 | 460 | return -ERESTARTSYS; |
| 461 | + | |
| 462 | + if (port->serial->disconnected) | |
| 463 | + return -EIO; | |
| 464 | + | |
| 463 | 465 | if ((prev.rng == priv->icount.rng) && |
| 464 | 466 | (prev.dsr == priv->icount.dsr) && |
| 465 | 467 | (prev.dcd == priv->icount.dcd) && |
| @@ -580,7 +582,7 @@ static void ark3116_update_msr(struct usb_serial_port *port, __u8 msr) · 114 unmodified lines | ||
| 580 | 582 | priv->icount.dcd++; |
| 581 | 583 | if (msr & UART_MSR_TERI) |
| 582 | 584 | priv->icount.rng++; |
| 583 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 585 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 584 | 586 | } |
| 585 | 587 | } |
| 586 | 588 | |
| @@ -80,7 +80,6 @@ MODULE_DEVICE_TABLE(usb, id_table); · 79 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | struct ch341_private { |
| 82 | 82 | spinlock_t lock; /* access lock */ |
| 83 | − wait_queue_head_t delta_msr_wait; /* wait queue for modem status */ | |
| 84 | 83 | unsigned baud_rate; /* set baud rate */ |
| 85 | 84 | u8 line_control; /* set line control value RTS/DTR */ |
| 86 | 85 | u8 line_status; /* active status of modem control inputs */ |
| @@ -252,7 +251,6 @@ static int ch341_port_probe(struct usb_serial_port *port) · 165 unmodified lines | ||
| 252 | 251 | return -ENOMEM; |
| 253 | 252 | |
| 254 | 253 | spin_lock_init(&priv->lock); |
| 255 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 256 | 254 | priv->baud_rate = DEFAULT_BAUD_RATE; |
| 257 | 255 | priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; |
| 258 | 256 | |
| @@ -298,7 +296,7 @@ static void ch341_dtr_rts(struct usb_serial_port *port, int on) · 39 unmodified lines | ||
| 298 | 296 | priv->line_control &= ~(CH341_BIT_RTS | CH341_BIT_DTR); |
| 299 | 297 | spin_unlock_irqrestore(&priv->lock, flags); |
| 300 | 298 | ch341_set_handshake(port->serial->dev, priv->line_control); |
| 301 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 299 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 302 | 300 | } |
| 303 | 301 | |
| 304 | 302 | static void ch341_close(struct usb_serial_port *port) |
| @@ -491,7 +489,7 @@ static void ch341_read_int_callback(struct urb *urb) · 186 unmodified lines | ||
| 491 | 489 | tty_kref_put(tty); |
| 492 | 490 | } |
| 493 | 491 | |
| 494 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 492 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 495 | 493 | } |
| 496 | 494 | |
| 497 | 495 | exit: |
| @@ -517,11 +515,14 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 19 unmodified lines | ||
| 517 | 515 | spin_unlock_irqrestore(&priv->lock, flags); |
| 518 | 516 | |
| 519 | 517 | while (!multi_change) { |
| 520 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 518 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 521 | 519 | /* see if a signal did it */ |
| 522 | 520 | if (signal_pending(current)) |
| 523 | 521 | return -ERESTARTSYS; |
| 524 | 522 | |
| 523 | + if (port->serial->disconnected) | |
| 524 | + return -EIO; | |
| 525 | + | |
| 525 | 526 | spin_lock_irqsave(&priv->lock, flags); |
| 526 | 527 | status = priv->line_status; |
| 527 | 528 | multi_change = priv->multi_status_change; |
| @@ -111,7 +111,6 @@ struct cypress_private { · 110 unmodified lines | ||
| 111 | 111 | int baud_rate; /* stores current baud rate in |
| 112 | 112 | integer form */ |
| 113 | 113 | int isthrottled; /* if throttled, discard reads */ |
| 114 | − wait_queue_head_t delta_msr_wait; /* used for TIOCMIWAIT */ | |
| 115 | 114 | char prev_status, diff_status; /* used for TIOCMIWAIT */ |
| 116 | 115 | /* we pass a pointer to this as the argument sent to |
| 117 | 116 | cypress_set_termios old_termios */ |
| @@ -449,7 +448,6 @@ static int cypress_generic_port_probe(struct usb_serial_port *port) · 331 unmodified lines | ||
| 449 | 448 | kfree(priv); |
| 450 | 449 | return -ENOMEM; |
| 451 | 450 | } |
| 452 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 453 | 451 | |
| 454 | 452 | usb_reset_configuration(serial->dev); |
| 455 | 453 | |
| @@ -868,12 +866,16 @@ static int cypress_ioctl(struct tty_struct *tty, · 412 unmodified lines | ||
| 868 | 866 | switch (cmd) { |
| 869 | 867 | /* This code comes from drivers/char/serial.c and ftdi_sio.c */ |
| 870 | 868 | case TIOCMIWAIT: |
| 871 | − while (priv != NULL) { | |
| 872 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 869 | + for (;;) { | |
| 870 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 873 | 871 | /* see if a signal did it */ |
| 874 | 872 | if (signal_pending(current)) |
| 875 | 873 | return -ERESTARTSYS; |
| 876 | − else { | |
| 874 | + | |
| 875 | + if (port->serial->disconnected) | |
| 876 | + return -EIO; | |
| 877 | + | |
| 878 | + { | |
| 877 | 879 | char diff = priv->diff_status; |
| 878 | 880 | if (diff == 0) |
| 879 | 881 | return -EIO; /* no change => error */ |
| @@ -1187,7 +1189,7 @@ static void cypress_read_int_callback(struct urb *urb) · 307 unmodified lines | ||
| 1187 | 1189 | if (priv->current_status != priv->prev_status) { |
| 1188 | 1190 | priv->diff_status |= priv->current_status ^ |
| 1189 | 1191 | priv->prev_status; |
| 1190 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 1192 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 1191 | 1193 | priv->prev_status = priv->current_status; |
| 1192 | 1194 | } |
| 1193 | 1195 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -47,7 +47,6 @@ MODULE_DEVICE_TABLE(usb, id_table); · 46 unmodified lines | ||
| 47 | 47 | |
| 48 | 48 | struct f81232_private { |
| 49 | 49 | spinlock_t lock; |
| 50 | − wait_queue_head_t delta_msr_wait; | |
| 51 | 50 | u8 line_control; |
| 52 | 51 | u8 line_status; |
| 53 | 52 | }; |
| @@ -111,7 +110,7 @@ static void f81232_process_read_urb(struct urb *urb) · 57 unmodified lines | ||
| 111 | 110 | line_status = priv->line_status; |
| 112 | 111 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; |
| 113 | 112 | spin_unlock_irqrestore(&priv->lock, flags); |
| 114 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 113 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 115 | 114 | |
| 116 | 115 | if (!urb->actual_length) |
| 117 | 116 | return; |
| @@ -256,11 +255,14 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 138 unmodified lines | ||
| 256 | 255 | spin_unlock_irqrestore(&priv->lock, flags); |
| 257 | 256 | |
| 258 | 257 | while (1) { |
| 259 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 258 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 260 | 259 | /* see if a signal did it */ |
| 261 | 260 | if (signal_pending(current)) |
| 262 | 261 | return -ERESTARTSYS; |
| 263 | 262 | |
| 263 | + if (port->serial->disconnected) | |
| 264 | + return -EIO; | |
| 265 | + | |
| 264 | 266 | spin_lock_irqsave(&priv->lock, flags); |
| 265 | 267 | status = priv->line_status; |
| 266 | 268 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -322,7 +324,6 @@ static int f81232_port_probe(struct usb_serial_port *port) · 55 unmodified lines | ||
| 322 | 324 | return -ENOMEM; |
| 323 | 325 | |
| 324 | 326 | spin_lock_init(&priv->lock); |
| 325 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 326 | 327 | |
| 327 | 328 | usb_set_serial_port_data(port, priv); |
| 328 | 329 | |
| @@ -69,9 +69,7 @@ struct ftdi_private { · 68 unmodified lines | ||
| 69 | 69 | int flags; /* some ASYNC_xxxx flags are supported */ |
| 70 | 70 | unsigned long last_dtr_rts; /* saved modem control outputs */ |
| 71 | 71 | struct async_icount icount; |
| 72 | − wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ | |
| 73 | 72 | char prev_status; /* Used for TIOCMIWAIT */ |
| 74 | − bool dev_gone; /* Used to abort TIOCMIWAIT */ | |
| 75 | 73 | char transmit_empty; /* If transmitter is empty or not */ |
| 76 | 74 | __u16 interface; /* FT2232C, FT2232H or FT4232H port interface |
| 77 | 75 | (0 for FT232/245) */ |
| @@ -1691,10 +1689,8 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) · 1613 unmodified lines | ||
| 1691 | 1689 | |
| 1692 | 1690 | kref_init(&priv->kref); |
| 1693 | 1691 | mutex_init(&priv->cfg_lock); |
| 1694 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 1695 | 1692 | |
| 1696 | 1693 | priv->flags = ASYNC_LOW_LATENCY; |
| 1697 | − priv->dev_gone = false; | |
| 1698 | 1694 | |
| 1699 | 1695 | if (quirk && quirk->port_probe) |
| 1700 | 1696 | quirk->port_probe(priv); |
| @@ -1840,8 +1836,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) · 139 unmodified lines | ||
| 1840 | 1836 | { |
| 1841 | 1837 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
| 1842 | 1838 | |
| 1843 | − priv->dev_gone = true; | |
| 1844 | − wake_up_interruptible_all(&priv->delta_msr_wait); | |
| 1839 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 1845 | 1840 | |
| 1846 | 1841 | remove_sysfs_attrs(port); |
| 1847 | 1842 | |
| @@ -1989,7 +1984,7 @@ static int ftdi_process_packet(struct usb_serial_port *port, · 141 unmodified lines | ||
| 1989 | 1984 | if (diff_status & FTDI_RS0_RLSD) |
| 1990 | 1985 | priv->icount.dcd++; |
| 1991 | 1986 | |
| 1992 | − wake_up_interruptible_all(&priv->delta_msr_wait); | |
| 1987 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 1993 | 1988 | priv->prev_status = status; |
| 1994 | 1989 | } |
| 1995 | 1990 | |
| @@ -2440,11 +2435,15 @@ static int ftdi_ioctl(struct tty_struct *tty, · 444 unmodified lines | ||
| 2440 | 2435 | */ |
| 2441 | 2436 | case TIOCMIWAIT: |
| 2442 | 2437 | cprev = priv->icount; |
| 2443 | − while (!priv->dev_gone) { | |
| 2444 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 2438 | + for (;;) { | |
| 2439 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 2445 | 2440 | /* see if a signal did it */ |
| 2446 | 2441 | if (signal_pending(current)) |
| 2447 | 2442 | return -ERESTARTSYS; |
| 2443 | + | |
| 2444 | + if (port->serial->disconnected) | |
| 2445 | + return -EIO; | |
| 2446 | + | |
| 2448 | 2447 | cnow = priv->icount; |
| 2449 | 2448 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
| 2450 | 2449 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
| @@ -2454,8 +2453,6 @@ static int ftdi_ioctl(struct tty_struct *tty, · 3 unmodified lines | ||
| 2454 | 2453 | } |
| 2455 | 2454 | cprev = cnow; |
| 2456 | 2455 | } |
| 2457 | − return -EIO; | |
| 2458 | − break; | |
| 2459 | 2456 | case TIOCSERGETLSR: |
| 2460 | 2457 | return get_lsr_info(port, (struct serial_struct __user *)arg); |
| 2461 | 2458 | break; |
| @@ -956,10 +956,7 @@ static void garmin_close(struct usb_serial_port *port) · 955 unmodified lines | ||
| 956 | 956 | if (!serial) |
| 957 | 957 | return; |
| 958 | 958 | |
| 959 | − mutex_lock(&port->serial->disc_mutex); | |
| 960 | − | |
| 961 | − if (!port->serial->disconnected) | |
| 962 | − garmin_clear(garmin_data_p); | |
| 959 | + garmin_clear(garmin_data_p); | |
| 963 | 960 | |
| 964 | 961 | /* shutdown our urbs */ |
| 965 | 962 | usb_kill_urb(port->read_urb); |
| @@ -968,8 +965,6 @@ static void garmin_close(struct usb_serial_port *port) · 2 unmodified lines | ||
| 968 | 965 | /* keep reset state so we know that we must start a new session */ |
| 969 | 966 | if (garmin_data_p->state != STATE_RESET) |
| 970 | 967 | garmin_data_p->state = STATE_DISCONNECTED; |
| 971 | − | |
| 972 | − mutex_unlock(&port->serial->disc_mutex); | |
| 973 | 968 | } |
| 974 | 969 | |
| 975 | 970 | |
| @@ -110,7 +110,6 @@ struct edgeport_port { · 109 unmodified lines | ||
| 110 | 110 | wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ |
| 111 | 111 | wait_queue_head_t wait_open; /* for handling sleeping while waiting for open to finish */ |
| 112 | 112 | wait_queue_head_t wait_command; /* for handling sleeping while waiting for command to finish */ |
| 113 | − wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ | |
| 114 | 113 | |
| 115 | 114 | struct async_icount icount; |
| 116 | 115 | struct usb_serial_port *port; /* loop back to the owner of this object */ |
| @@ -884,7 +883,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) · 767 unmodified lines | ||
| 884 | 883 | /* initialize our wait queues */ |
| 885 | 884 | init_waitqueue_head(&edge_port->wait_open); |
| 886 | 885 | init_waitqueue_head(&edge_port->wait_chase); |
| 887 | − init_waitqueue_head(&edge_port->delta_msr_wait); | |
| 888 | 886 | init_waitqueue_head(&edge_port->wait_command); |
| 889 | 887 | |
| 890 | 888 | /* initialize our icount structure */ |
| @@ -1669,13 +1667,17 @@ static int edge_ioctl(struct tty_struct *tty, · 778 unmodified lines | ||
| 1669 | 1667 | dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number); |
| 1670 | 1668 | cprev = edge_port->icount; |
| 1671 | 1669 | while (1) { |
| 1672 | − prepare_to_wait(&edge_port->delta_msr_wait, | |
| 1670 | + prepare_to_wait(&port->delta_msr_wait, | |
| 1673 | 1671 | &wait, TASK_INTERRUPTIBLE); |
| 1674 | 1672 | schedule(); |
| 1675 | − finish_wait(&edge_port->delta_msr_wait, &wait); | |
| 1673 | + finish_wait(&port->delta_msr_wait, &wait); | |
| 1676 | 1674 | /* see if a signal did it */ |
| 1677 | 1675 | if (signal_pending(current)) |
| 1678 | 1676 | return -ERESTARTSYS; |
| 1677 | + | |
| 1678 | + if (port->serial->disconnected) | |
| 1679 | + return -EIO; | |
| 1680 | + | |
| 1679 | 1681 | cnow = edge_port->icount; |
| 1680 | 1682 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
| 1681 | 1683 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) |
| @@ -2051,7 +2053,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr) · 369 unmodified lines | ||
| 2051 | 2053 | icount->dcd++; |
| 2052 | 2054 | if (newMsr & EDGEPORT_MSR_DELTA_RI) |
| 2053 | 2055 | icount->rng++; |
| 2054 | − wake_up_interruptible(&edge_port->delta_msr_wait); | |
| 2056 | + wake_up_interruptible(&edge_port->port->delta_msr_wait); | |
| 2055 | 2057 | } |
| 2056 | 2058 | |
| 2057 | 2059 | /* Save the new modem status */ |
| @@ -87,9 +87,6 @@ struct edgeport_port { · 86 unmodified lines | ||
| 87 | 87 | int close_pending; |
| 88 | 88 | int lsr_event; |
| 89 | 89 | struct async_icount icount; |
| 90 | − wait_queue_head_t delta_msr_wait; /* for handling sleeping while | |
| 91 | − waiting for msr change to | |
| 92 | − happen */ | |
| 93 | 90 | struct edgeport_serial *edge_serial; |
| 94 | 91 | struct usb_serial_port *port; |
| 95 | 92 | __u8 bUartMode; /* Port type, 0: RS232, etc. */ |
| @@ -1459,7 +1456,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr) · 1363 unmodified lines | ||
| 1459 | 1456 | icount->dcd++; |
| 1460 | 1457 | if (msr & EDGEPORT_MSR_DELTA_RI) |
| 1461 | 1458 | icount->rng++; |
| 1462 | − wake_up_interruptible(&edge_port->delta_msr_wait); | |
| 1459 | + wake_up_interruptible(&edge_port->port->delta_msr_wait); | |
| 1463 | 1460 | } |
| 1464 | 1461 | |
| 1465 | 1462 | /* Save the new modem status */ |
| @@ -1754,7 +1751,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) · 288 unmodified lines | ||
| 1754 | 1751 | dev = port->serial->dev; |
| 1755 | 1752 | |
| 1756 | 1753 | memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount)); |
| 1757 | − init_waitqueue_head(&edge_port->delta_msr_wait); | |
| 1758 | 1754 | |
| 1759 | 1755 | /* turn off loopback */ |
| 1760 | 1756 | status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0); |
| @@ -2434,10 +2430,14 @@ static int edge_ioctl(struct tty_struct *tty, · 673 unmodified lines | ||
| 2434 | 2430 | dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); |
| 2435 | 2431 | cprev = edge_port->icount; |
| 2436 | 2432 | while (1) { |
| 2437 | − interruptible_sleep_on(&edge_port->delta_msr_wait); | |
| 2433 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 2438 | 2434 | /* see if a signal did it */ |
| 2439 | 2435 | if (signal_pending(current)) |
| 2440 | 2436 | return -ERESTARTSYS; |
| 2437 | + | |
| 2438 | + if (port->serial->disconnected) | |
| 2439 | + return -EIO; | |
| 2440 | + | |
| 2441 | 2441 | cnow = edge_port->icount; |
| 2442 | 2442 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
| 2443 | 2443 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) |
| @@ -2649,6 +2649,7 @@ static struct usb_serial_driver edgeport_2port_device = { · 205 unmodified lines | ||
| 2649 | 2649 | .set_termios = edge_set_termios, |
| 2650 | 2650 | .tiocmget = edge_tiocmget, |
| 2651 | 2651 | .tiocmset = edge_tiocmset, |
| 2652 | + .get_icount = edge_get_icount, | |
| 2652 | 2653 | .write = edge_write, |
| 2653 | 2654 | .write_room = edge_write_room, |
| 2654 | 2655 | .chars_in_buffer = edge_chars_in_buffer, |
| @@ -114,8 +114,6 @@ struct mct_u232_private { · 113 unmodified lines | ||
| 114 | 114 | unsigned char last_msr; /* Modem Status Register */ |
| 115 | 115 | unsigned int rx_flags; /* Throttling flags */ |
| 116 | 116 | struct async_icount icount; |
| 117 | − wait_queue_head_t msr_wait; /* for handling sleeping while waiting | |
| 118 | − for msr change to happen */ | |
| 119 | 117 | }; |
| 120 | 118 | |
| 121 | 119 | #define THROTTLED 0x01 |
| @@ -409,7 +407,6 @@ static int mct_u232_port_probe(struct usb_serial_port *port) · 287 unmodified lines | ||
| 409 | 407 | return -ENOMEM; |
| 410 | 408 | |
| 411 | 409 | spin_lock_init(&priv->lock); |
| 412 | − init_waitqueue_head(&priv->msr_wait); | |
| 413 | 410 | |
| 414 | 411 | usb_set_serial_port_data(port, priv); |
| 415 | 412 | |
| @@ -601,7 +598,7 @@ static void mct_u232_read_int_callback(struct urb *urb) · 185 unmodified lines | ||
| 601 | 598 | tty_kref_put(tty); |
| 602 | 599 | } |
| 603 | 600 | #endif |
| 604 | − wake_up_interruptible(&priv->msr_wait); | |
| 601 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 605 | 602 | spin_unlock_irqrestore(&priv->lock, flags); |
| 606 | 603 | exit: |
| 607 | 604 | retval = usb_submit_urb(urb, GFP_ATOMIC); |
| @@ -810,13 +807,17 @@ static int mct_u232_ioctl(struct tty_struct *tty, · 202 unmodified lines | ||
| 810 | 807 | cprev = mct_u232_port->icount; |
| 811 | 808 | spin_unlock_irqrestore(&mct_u232_port->lock, flags); |
| 812 | 809 | for ( ; ; ) { |
| 813 | − prepare_to_wait(&mct_u232_port->msr_wait, | |
| 810 | + prepare_to_wait(&port->delta_msr_wait, | |
| 814 | 811 | &wait, TASK_INTERRUPTIBLE); |
| 815 | 812 | schedule(); |
| 816 | − finish_wait(&mct_u232_port->msr_wait, &wait); | |
| 813 | + finish_wait(&port->delta_msr_wait, &wait); | |
| 817 | 814 | /* see if a signal did it */ |
| 818 | 815 | if (signal_pending(current)) |
| 819 | 816 | return -ERESTARTSYS; |
| 817 | + | |
| 818 | + if (port->serial->disconnected) | |
| 819 | + return -EIO; | |
| 820 | + | |
| 820 | 821 | spin_lock_irqsave(&mct_u232_port->lock, flags); |
| 821 | 822 | cnow = mct_u232_port->icount; |
| 822 | 823 | spin_unlock_irqrestore(&mct_u232_port->lock, flags); |
| @@ -219,7 +219,6 @@ struct moschip_port { · 218 unmodified lines | ||
| 219 | 219 | char open; |
| 220 | 220 | char open_ports; |
| 221 | 221 | wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ |
| 222 | − wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ | |
| 223 | 222 | int delta_msr_cond; |
| 224 | 223 | struct async_icount icount; |
| 225 | 224 | struct usb_serial_port *port; /* loop back to the owner of this object */ |
| @@ -423,6 +422,9 @@ static void mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr) · 197 unmodified lines | ||
| 423 | 422 | icount->rng++; |
| 424 | 423 | smp_wmb(); |
| 425 | 424 | } |
| 425 | + | |
| 426 | + mos7840_port->delta_msr_cond = 1; | |
| 427 | + wake_up_interruptible(&port->port->delta_msr_wait); | |
| 426 | 428 | } |
| 427 | 429 | } |
| 428 | 430 | |
| @@ -1127,7 +1129,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) · 698 unmodified lines | ||
| 1127 | 1129 | |
| 1128 | 1130 | /* initialize our wait queues */ |
| 1129 | 1131 | init_waitqueue_head(&mos7840_port->wait_chase); |
| 1130 | − init_waitqueue_head(&mos7840_port->delta_msr_wait); | |
| 1131 | 1132 | |
| 1132 | 1133 | /* initialize our icount structure */ |
| 1133 | 1134 | memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount)); |
| @@ -2017,8 +2018,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty, · 883 unmodified lines | ||
| 2017 | 2018 | mos7840_port->read_urb_busy = false; |
| 2018 | 2019 | } |
| 2019 | 2020 | } |
| 2020 | − wake_up(&mos7840_port->delta_msr_wait); | |
| 2021 | − mos7840_port->delta_msr_cond = 1; | |
| 2022 | 2021 | dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is End %x\n", __func__, |
| 2023 | 2022 | mos7840_port->shadowLCR); |
| 2024 | 2023 | } |
| @@ -2219,13 +2218,18 @@ static int mos7840_ioctl(struct tty_struct *tty, · 194 unmodified lines | ||
| 2219 | 2218 | while (1) { |
| 2220 | 2219 | /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ |
| 2221 | 2220 | mos7840_port->delta_msr_cond = 0; |
| 2222 | − wait_event_interruptible(mos7840_port->delta_msr_wait, | |
| 2223 | − (mos7840_port-> | |
| 2221 | + wait_event_interruptible(port->delta_msr_wait, | |
| 2222 | + (port->serial->disconnected || | |
| 2223 | + mos7840_port-> | |
| 2224 | 2224 | delta_msr_cond == 1)); |
| 2225 | 2225 | |
| 2226 | 2226 | /* see if a signal did it */ |
| 2227 | 2227 | if (signal_pending(current)) |
| 2228 | 2228 | return -ERESTARTSYS; |
| 2229 | + | |
| 2230 | + if (port->serial->disconnected) | |
| 2231 | + return -EIO; | |
| 2232 | + | |
| 2229 | 2233 | cnow = mos7840_port->icount; |
| 2230 | 2234 | smp_rmb(); |
| 2231 | 2235 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
| @@ -188,7 +188,6 @@ struct oti6858_private { · 187 unmodified lines | ||
| 188 | 188 | u8 setup_done; |
| 189 | 189 | struct delayed_work delayed_setup_work; |
| 190 | 190 | |
| 191 | − wait_queue_head_t intr_wait; | |
| 192 | 191 | struct usb_serial_port *port; /* USB port with which associated */ |
| 193 | 192 | }; |
| 194 | 193 | |
| @@ -339,7 +338,6 @@ static int oti6858_port_probe(struct usb_serial_port *port) · 144 unmodified lines | ||
| 339 | 338 | return -ENOMEM; |
| 340 | 339 | |
| 341 | 340 | spin_lock_init(&priv->lock); |
| 342 | − init_waitqueue_head(&priv->intr_wait); | |
| 343 | 341 | priv->port = port; |
| 344 | 342 | INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); |
| 345 | 343 | INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); |
| @@ -664,11 +662,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 318 unmodified lines | ||
| 664 | 662 | spin_unlock_irqrestore(&priv->lock, flags); |
| 665 | 663 | |
| 666 | 664 | while (1) { |
| 667 | − wait_event_interruptible(priv->intr_wait, | |
| 665 | + wait_event_interruptible(port->delta_msr_wait, | |
| 666 | + port->serial->disconnected || | |
| 668 | 667 | priv->status.pin_state != prev); |
| 669 | 668 | if (signal_pending(current)) |
| 670 | 669 | return -ERESTARTSYS; |
| 671 | 670 | |
| 671 | + if (port->serial->disconnected) | |
| 672 | + return -EIO; | |
| 673 | + | |
| 672 | 674 | spin_lock_irqsave(&priv->lock, flags); |
| 673 | 675 | status = priv->status.pin_state & PIN_MASK; |
| 674 | 676 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -763,7 +765,7 @@ static void oti6858_read_int_callback(struct urb *urb) · 88 unmodified lines | ||
| 763 | 765 | |
| 764 | 766 | if (!priv->transient) { |
| 765 | 767 | if (xs->pin_state != priv->status.pin_state) |
| 766 | − wake_up_interruptible(&priv->intr_wait); | |
| 768 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 767 | 769 | memcpy(&priv->status, xs, OTI6858_CTRL_PKT_SIZE); |
| 768 | 770 | } |
| 769 | 771 | |
| @@ -139,7 +139,6 @@ struct pl2303_serial_private { · 138 unmodified lines | ||
| 139 | 139 | |
| 140 | 140 | struct pl2303_private { |
| 141 | 141 | spinlock_t lock; |
| 142 | − wait_queue_head_t delta_msr_wait; | |
| 143 | 142 | u8 line_control; |
| 144 | 143 | u8 line_status; |
| 145 | 144 | }; |
| @@ -233,7 +232,6 @@ static int pl2303_port_probe(struct usb_serial_port *port) · 87 unmodified lines | ||
| 233 | 232 | return -ENOMEM; |
| 234 | 233 | |
| 235 | 234 | spin_lock_init(&priv->lock); |
| 236 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 237 | 235 | |
| 238 | 236 | usb_set_serial_port_data(port, priv); |
| 239 | 237 | |
| @@ -607,11 +605,14 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 367 unmodified lines | ||
| 607 | 605 | spin_unlock_irqrestore(&priv->lock, flags); |
| 608 | 606 | |
| 609 | 607 | while (1) { |
| 610 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 608 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 611 | 609 | /* see if a signal did it */ |
| 612 | 610 | if (signal_pending(current)) |
| 613 | 611 | return -ERESTARTSYS; |
| 614 | 612 | |
| 613 | + if (port->serial->disconnected) | |
| 614 | + return -EIO; | |
| 615 | + | |
| 615 | 616 | spin_lock_irqsave(&priv->lock, flags); |
| 616 | 617 | status = priv->line_status; |
| 617 | 618 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -719,7 +720,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port, · 101 unmodified lines | ||
| 719 | 720 | spin_unlock_irqrestore(&priv->lock, flags); |
| 720 | 721 | if (priv->line_status & UART_BREAK_ERROR) |
| 721 | 722 | usb_serial_handle_break(port); |
| 722 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 723 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 723 | 724 | |
| 724 | 725 | tty = tty_port_tty_get(&port->port); |
| 725 | 726 | if (!tty) |
| @@ -783,7 +784,7 @@ static void pl2303_process_read_urb(struct urb *urb) · 57 unmodified lines | ||
| 783 | 784 | line_status = priv->line_status; |
| 784 | 785 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; |
| 785 | 786 | spin_unlock_irqrestore(&priv->lock, flags); |
| 786 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 787 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 787 | 788 | |
| 788 | 789 | if (!urb->actual_length) |
| 789 | 790 | return; |
| @@ -128,7 +128,6 @@ struct qt2_port_private { · 127 unmodified lines | ||
| 128 | 128 | u8 shadowLSR; |
| 129 | 129 | u8 shadowMSR; |
| 130 | 130 | |
| 131 | − wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ | |
| 132 | 131 | struct async_icount icount; |
| 133 | 132 | |
| 134 | 133 | struct usb_serial_port *port; |
| @@ -506,8 +505,9 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 371 unmodified lines | ||
| 506 | 505 | spin_unlock_irqrestore(&priv->lock, flags); |
| 507 | 506 | |
| 508 | 507 | while (1) { |
| 509 | − wait_event_interruptible(priv->delta_msr_wait, | |
| 510 | − ((priv->icount.rng != prev.rng) || | |
| 508 | + wait_event_interruptible(port->delta_msr_wait, | |
| 509 | + (port->serial->disconnected || | |
| 510 | + (priv->icount.rng != prev.rng) || | |
| 511 | 511 | (priv->icount.dsr != prev.dsr) || |
| 512 | 512 | (priv->icount.dcd != prev.dcd) || |
| 513 | 513 | (priv->icount.cts != prev.cts))); |
| @@ -515,6 +515,9 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 1 unmodified line | ||
| 515 | 515 | if (signal_pending(current)) |
| 516 | 516 | return -ERESTARTSYS; |
| 517 | 517 | |
| 518 | + if (port->serial->disconnected) | |
| 519 | + return -EIO; | |
| 520 | + | |
| 518 | 521 | spin_lock_irqsave(&priv->lock, flags); |
| 519 | 522 | cur = priv->icount; |
| 520 | 523 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -827,7 +830,6 @@ static int qt2_port_probe(struct usb_serial_port *port) · 306 unmodified lines | ||
| 827 | 830 | |
| 828 | 831 | spin_lock_init(&port_priv->lock); |
| 829 | 832 | spin_lock_init(&port_priv->urb_lock); |
| 830 | − init_waitqueue_head(&port_priv->delta_msr_wait); | |
| 831 | 833 | port_priv->port = port; |
| 832 | 834 | |
| 833 | 835 | port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL); |
| @@ -970,7 +972,7 @@ static void qt2_update_msr(struct usb_serial_port *port, unsigned char *ch) · 136 unmodified lines | ||
| 970 | 972 | if (newMSR & UART_MSR_TERI) |
| 971 | 973 | port_priv->icount.rng++; |
| 972 | 974 | |
| 973 | − wake_up_interruptible(&port_priv->delta_msr_wait); | |
| 975 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 974 | 976 | } |
| 975 | 977 | } |
| 976 | 978 | |
| @@ -149,7 +149,6 @@ enum spcp8x5_type { · 148 unmodified lines | ||
| 149 | 149 | struct spcp8x5_private { |
| 150 | 150 | spinlock_t lock; |
| 151 | 151 | enum spcp8x5_type type; |
| 152 | − wait_queue_head_t delta_msr_wait; | |
| 153 | 152 | u8 line_control; |
| 154 | 153 | u8 line_status; |
| 155 | 154 | }; |
| @@ -179,7 +178,6 @@ static int spcp8x5_port_probe(struct usb_serial_port *port) · 23 unmodified lines | ||
| 179 | 178 | return -ENOMEM; |
| 180 | 179 | |
| 181 | 180 | spin_lock_init(&priv->lock); |
| 182 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 183 | 181 | priv->type = type; |
| 184 | 182 | |
| 185 | 183 | usb_set_serial_port_data(port , priv); |
| @@ -475,7 +473,7 @@ static void spcp8x5_process_read_urb(struct urb *urb) · 289 unmodified lines | ||
| 475 | 473 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; |
| 476 | 474 | spin_unlock_irqrestore(&priv->lock, flags); |
| 477 | 475 | /* wake up the wait for termios */ |
| 478 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 476 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 479 | 477 | |
| 480 | 478 | if (!urb->actual_length) |
| 481 | 479 | return; |
| @@ -526,12 +524,15 @@ static int spcp8x5_wait_modem_info(struct usb_serial_port *port, · 44 unmodified lines | ||
| 526 | 524 | |
| 527 | 525 | while (1) { |
| 528 | 526 | /* wake up in bulk read */ |
| 529 | − interruptible_sleep_on(&priv->delta_msr_wait); | |
| 527 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 530 | 528 | |
| 531 | 529 | /* see if a signal did it */ |
| 532 | 530 | if (signal_pending(current)) |
| 533 | 531 | return -ERESTARTSYS; |
| 534 | 532 | |
| 533 | + if (port->serial->disconnected) | |
| 534 | + return -EIO; | |
| 535 | + | |
| 535 | 536 | spin_lock_irqsave(&priv->lock, flags); |
| 536 | 537 | status = priv->line_status; |
| 537 | 538 | spin_unlock_irqrestore(&priv->lock, flags); |
| @@ -61,7 +61,6 @@ struct ssu100_port_private { · 60 unmodified lines | ||
| 61 | 61 | spinlock_t status_lock; |
| 62 | 62 | u8 shadowLSR; |
| 63 | 63 | u8 shadowMSR; |
| 64 | − wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ | |
| 65 | 64 | struct async_icount icount; |
| 66 | 65 | }; |
| 67 | 66 | |
| @@ -355,8 +354,9 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 287 unmodified lines | ||
| 355 | 354 | spin_unlock_irqrestore(&priv->status_lock, flags); |
| 356 | 355 | |
| 357 | 356 | while (1) { |
| 358 | − wait_event_interruptible(priv->delta_msr_wait, | |
| 359 | − ((priv->icount.rng != prev.rng) || | |
| 357 | + wait_event_interruptible(port->delta_msr_wait, | |
| 358 | + (port->serial->disconnected || | |
| 359 | + (priv->icount.rng != prev.rng) || | |
| 360 | 360 | (priv->icount.dsr != prev.dsr) || |
| 361 | 361 | (priv->icount.dcd != prev.dcd) || |
| 362 | 362 | (priv->icount.cts != prev.cts))); |
| @@ -364,6 +364,9 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) · 1 unmodified line | ||
| 364 | 364 | if (signal_pending(current)) |
| 365 | 365 | return -ERESTARTSYS; |
| 366 | 366 | |
| 367 | + if (port->serial->disconnected) | |
| 368 | + return -EIO; | |
| 369 | + | |
| 367 | 370 | spin_lock_irqsave(&priv->status_lock, flags); |
| 368 | 371 | cur = priv->icount; |
| 369 | 372 | spin_unlock_irqrestore(&priv->status_lock, flags); |
| @@ -445,7 +448,6 @@ static int ssu100_port_probe(struct usb_serial_port *port) · 75 unmodified lines | ||
| 445 | 448 | return -ENOMEM; |
| 446 | 449 | |
| 447 | 450 | spin_lock_init(&priv->status_lock); |
| 448 | − init_waitqueue_head(&priv->delta_msr_wait); | |
| 449 | 451 | |
| 450 | 452 | usb_set_serial_port_data(port, priv); |
| 451 | 453 | |
| @@ -537,7 +539,7 @@ static void ssu100_update_msr(struct usb_serial_port *port, u8 msr) · 85 unmodified lines | ||
| 537 | 539 | priv->icount.dcd++; |
| 538 | 540 | if (msr & UART_MSR_TERI) |
| 539 | 541 | priv->icount.rng++; |
| 540 | − wake_up_interruptible(&priv->delta_msr_wait); | |
| 542 | + wake_up_interruptible(&port->delta_msr_wait); | |
| 541 | 543 | } |
| 542 | 544 | } |
| 543 | 545 | |
| @@ -74,7 +74,6 @@ struct ti_port { · 73 unmodified lines | ||
| 74 | 74 | int tp_flags; |
| 75 | 75 | int tp_closing_wait;/* in .01 secs */ |
| 76 | 76 | struct async_icount tp_icount; |
| 77 | − wait_queue_head_t tp_msr_wait; /* wait for msr change */ | |
| 78 | 77 | wait_queue_head_t tp_write_wait; |
| 79 | 78 | struct ti_device *tp_tdev; |
| 80 | 79 | struct usb_serial_port *tp_port; |
| @@ -432,7 +431,6 @@ static int ti_port_probe(struct usb_serial_port *port) · 351 unmodified lines | ||
| 432 | 431 | else |
| 433 | 432 | tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; |
| 434 | 433 | tport->tp_closing_wait = closing_wait; |
| 435 | − init_waitqueue_head(&tport->tp_msr_wait); | |
| 436 | 434 | init_waitqueue_head(&tport->tp_write_wait); |
| 437 | 435 | if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) { |
| 438 | 436 | kfree(tport); |
| @@ -784,9 +782,13 @@ static int ti_ioctl(struct tty_struct *tty, · 345 unmodified lines | ||
| 784 | 782 | dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__); |
| 785 | 783 | cprev = tport->tp_icount; |
| 786 | 784 | while (1) { |
| 787 | − interruptible_sleep_on(&tport->tp_msr_wait); | |
| 785 | + interruptible_sleep_on(&port->delta_msr_wait); | |
| 788 | 786 | if (signal_pending(current)) |
| 789 | 787 | return -ERESTARTSYS; |
| 788 | + | |
| 789 | + if (port->serial->disconnected) | |
| 790 | + return -EIO; | |
| 791 | + | |
| 790 | 792 | cnow = tport->tp_icount; |
| 791 | 793 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
| 792 | 794 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) |
| @@ -1392,7 +1394,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr) · 599 unmodified lines | ||
| 1392 | 1394 | icount->dcd++; |
| 1393 | 1395 | if (msr & TI_MSR_DELTA_RI) |
| 1394 | 1396 | icount->rng++; |
| 1395 | − wake_up_interruptible(&tport->tp_msr_wait); | |
| 1397 | + wake_up_interruptible(&tport->tp_port->delta_msr_wait); | |
| 1396 | 1398 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
| 1397 | 1399 | } |
| 1398 | 1400 | |
| @@ -151,6 +151,7 @@ static void destroy_serial(struct kref *kref) · 150 unmodified lines | ||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | + usb_put_intf(serial->interface); | |
| 154 | 155 | usb_put_dev(serial->dev); |
| 155 | 156 | kfree(serial); |
| 156 | 157 | } |
| @@ -620,7 +621,7 @@ static struct usb_serial *create_serial(struct usb_device *dev, · 463 unmodified lines | ||
| 620 | 621 | } |
| 621 | 622 | serial->dev = usb_get_dev(dev); |
| 622 | 623 | serial->type = driver; |
| 623 | − serial->interface = interface; | |
| 624 | + serial->interface = usb_get_intf(interface); | |
| 624 | 625 | kref_init(&serial->kref); |
| 625 | 626 | mutex_init(&serial->disc_mutex); |
| 626 | 627 | serial->minor = SERIAL_TTY_NO_MINOR; |
| @@ -496,6 +496,13 @@ UNUSUAL_DEV( 0x04e8, 0x5122, 0x0000, 0x9999, · 495 unmodified lines | ||
| 496 | 496 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
| 497 | 497 | US_FL_MAX_SECTORS_64 | US_FL_BULK_IGNORE_TAG), |
| 498 | 498 | |
| 499 | +/* Added by Dmitry Artamonow <mad_soft@inbox.ru> */ | |
| 500 | +UNUSUAL_DEV( 0x04e8, 0x5136, 0x0000, 0x9999, | |
| 501 | + "Samsung", | |
| 502 | + "YP-Z3", | |
| 503 | + USB_SC_DEVICE, USB_PR_DEVICE, NULL, | |
| 504 | + US_FL_MAX_SECTORS_64), | |
| 505 | + | |
| 499 | 506 | /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. |
| 500 | 507 | * Device uses standards-violating 32-byte Bulk Command Block Wrappers and |
| 501 | 508 | * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. |
| @@ -66,6 +66,7 @@ · 65 unmodified lines | ||
| 66 | 66 | * port. |
| 67 | 67 | * @flags: usb serial port flags |
| 68 | 68 | * @write_wait: a wait_queue_head_t used by the port. |
| 69 | + * @delta_msr_wait: modem-status-change wait queue | |
| 69 | 70 | * @work: work queue entry for the line discipline waking up. |
| 70 | 71 | * @throttled: nonzero if the read urb is inactive to throttle the device |
| 71 | 72 | * @throttle_req: nonzero if the tty wants to throttle us |
| @@ -112,6 +113,7 @@ struct usb_serial_port { · 40 unmodified lines | ||
| 112 | 113 | |
| 113 | 114 | unsigned long flags; |
| 114 | 115 | wait_queue_head_t write_wait; |
| 116 | + wait_queue_head_t delta_msr_wait; | |
| 115 | 117 | struct work_struct work; |
| 116 | 118 | char throttled; |
| 117 | 119 | char throttle_req; |
| @@ -181,8 +181,16 @@ · 180 unmodified lines | ||
| 181 | 181 | |
| 182 | 182 | /*-------------------------------------------------------------------------*/ |
| 183 | 183 | |
| 184 | +#if IS_ENABLED(CONFIG_USB_ULPI) | |
| 184 | 185 | struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, |
| 185 | 186 | unsigned int flags); |
| 187 | +#else | |
| 188 | +static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, | |
| 189 | + unsigned int flags) | |
| 190 | +{ | |
| 191 | + return NULL; | |
| 192 | +} | |
| 193 | +#endif | |
| 186 | 194 | |
| 187 | 195 | #ifdef CONFIG_USB_ULPI_VIEWPORT |
| 188 | 196 | /* access ops for controllers with a viewport register */ |