static void pl2303_release(struct usb_serial *serial) { struct pl2303_serial_private *spriv; spriv = usb_get_serial_data(serial); kfree(spriv); }
static int opticon_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; struct opticon_private *priv = usb_get_serial_data(port->serial); unsigned long flags; bool rts; bool changed = false; if (!usb_get_intfdata(port->serial->interface)) return -ENODEV; /* We only support RTS so we only handle that */ spin_lock_irqsave(&priv->lock, flags); rts = priv->rts; if (set & TIOCM_RTS) priv->rts = true; if (clear & TIOCM_RTS) priv->rts = false; changed = rts ^ priv->rts; spin_unlock_irqrestore(&priv->lock, flags); if (!changed) return 0; /* Send the new RTS state to the connected device */ return send_control_msg(port, CONTROL_RTS, !rts); }
static void ipw_release(struct usb_serial *serial) { struct usb_wwan_intf_private *data = usb_get_serial_data(serial); usb_set_serial_data(serial, NULL); kfree(data); }
static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) { struct opticon_private *priv = usb_get_serial_data(port->serial); unsigned long flags; int result = 0; dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->throttled = false; priv->actually_throttled = false; priv->port = port; spin_unlock_irqrestore(&priv->lock, flags); /* Start reading from the device */ usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev, usb_rcvbulkpipe(priv->udev, priv->bulk_address), priv->bulk_in_buffer, priv->buffer_size, opticon_bulk_callback, priv); result = usb_submit_urb(priv->bulk_read_urb, GFP_KERNEL); if (result) dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); return result; }
static int qt2_setup_urbs(struct usb_serial *serial) { struct usb_serial_port *port0; struct qt2_serial_private *serial_priv; int status; port0 = serial->port[0]; serial_priv = usb_get_serial_data(serial); serial_priv->read_urb = usb_alloc_urb(0, GFP_KERNEL); if (!serial_priv->read_urb) return -ENOMEM; usb_fill_bulk_urb(serial_priv->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, port0->bulk_in_endpointAddress), serial_priv->read_buffer, QT2_READ_BUFFER_SIZE, qt2_read_bulk_callback, serial); status = usb_submit_urb(serial_priv->read_urb, GFP_KERNEL); if (status != 0) { dev_err(&serial->dev->dev, "%s - submit read urb failed %i\n", __func__, status); usb_free_urb(serial_priv->read_urb); return status; } return 0; }
static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct pl2303_serial_private *spriv = usb_get_serial_data(serial); int result; if (spriv->type != HX) { usb_clear_halt(serial->dev, port->write_urb->pipe); usb_clear_halt(serial->dev, port->read_urb->pipe); } else { /* reset upstream data pipes */ pl2303_vendor_write(8, 0, serial); pl2303_vendor_write(9, 0, serial); } /* Setup termios */ if (tty) pl2303_set_termios(tty, port, NULL); result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); if (result) { dev_err(&port->dev, "%s - failed submitting interrupt urb," " error %d\n", __func__, result); return result; } result = usb_serial_generic_open(tty, port); if (result) { usb_kill_urb(port->interrupt_in_urb); return result; } return 0; }
static void qc_release(struct usb_serial *serial) { struct usb_wwan_intf_private *priv = usb_get_serial_data(serial); usb_set_serial_data(serial, NULL); kfree(priv); }
static void qt2_close(struct usb_serial_port *port) { struct usb_serial *serial; struct qt2_serial_private *serial_priv; struct qt2_port_private *port_priv; unsigned long flags; int i; serial = port->serial; serial_priv = usb_get_serial_data(serial); port_priv = usb_get_serial_port_data(port); port_priv->is_open = false; spin_lock_irqsave(&port_priv->urb_lock, flags); if (port_priv->write_urb->status == -EINPROGRESS) usb_kill_urb(port_priv->write_urb); port_priv->urb_in_use = false; spin_unlock_irqrestore(&port_priv->urb_lock, flags); mutex_lock(&port->serial->disc_mutex); if (port->serial->disconnected) { mutex_unlock(&port->serial->disc_mutex); return; } /* flush the port transmit buffer */ i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), QT2_FLUSH_DEVICE, 0x40, 1, port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); if (i < 0) dev_err(&port->dev, "%s - transmit buffer flush failed: %i\n", __func__, i); /* flush the port receive buffer */ i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), QT2_FLUSH_DEVICE, 0x40, 0, port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); if (i < 0) dev_err(&port->dev, "%s - receive buffer flush failed: %i\n", __func__, i); /* close the port */ i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), QT_OPEN_CLOSE_CHANNEL, 0x40, 0, port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); if (i < 0) dev_err(&port->dev, "%s - close port failed %i\n", __func__, i); mutex_unlock(&port->serial->disc_mutex); }
static int qt2_setup_urbs(struct usb_serial *serial) { struct usb_serial_port *port; struct usb_serial_port *port0; struct qt2_serial_private *serial_priv; struct qt2_port_private *port_priv; int pcount, status; port0 = serial->port[0]; serial_priv = usb_get_serial_data(serial); serial_priv->read_urb = usb_alloc_urb(0, GFP_KERNEL); if (!serial_priv->read_urb) { dev_err(&serial->dev->dev, "No free urbs available\n"); return -ENOMEM; } usb_fill_bulk_urb(serial_priv->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, port0->bulk_in_endpointAddress), serial_priv->read_buffer, sizeof(serial_priv->read_buffer), qt2_read_bulk_callback, serial); /* setup write_urb for each port */ for (pcount = 0; pcount < serial->num_ports; pcount++) { port = serial->port[pcount]; port_priv = usb_get_serial_port_data(port); port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL); if (!port_priv->write_urb) { dev_err(&serial->dev->dev, "failed to alloc write_urb for port %i\n", pcount); return -ENOMEM; } usb_fill_bulk_urb(port_priv->write_urb, serial->dev, usb_sndbulkpipe(serial->dev, port0-> bulk_out_endpointAddress), port_priv->write_buffer, sizeof(port_priv->write_buffer), qt2_write_bulk_callback, port); } status = usb_submit_urb(serial_priv->read_urb, GFP_KERNEL); if (status != 0) { dev_err(&serial->dev->dev, "%s - submit read urb failed %i\n", __func__, status); usb_free_urb(serial_priv->read_urb); return status; } return 0; }
static int opticon_suspend(struct usb_interface *intf, pm_message_t message) { struct usb_serial *serial = usb_get_intfdata(intf); struct opticon_private *priv = usb_get_serial_data(serial); usb_kill_urb(priv->bulk_read_urb); return 0; }
static void qc_release(struct usb_serial *serial) { struct usb_wwan_intf_private *priv = usb_get_serial_data(serial); /* Free the private data allocated in qcprobe */ usb_set_serial_data(serial, NULL); kfree(priv); }
static void symbol_release(struct usb_serial *serial) { struct symbol_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); kfree(priv->int_buffer); kfree(priv); }
static void symbol_disconnect(struct usb_serial *serial) { struct symbol_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); usb_kill_urb(priv->int_urb); usb_free_urb(priv->int_urb); }
static void opticon_close(struct usb_serial_port *port) { struct opticon_private *priv = usb_get_serial_data(port->serial); dbg("%s - port %d", __func__, port->number); usb_kill_urb(priv->bulk_read_urb); }
static void qt2_release(struct usb_serial *serial) { struct qt2_serial_private *serial_priv; serial_priv = usb_get_serial_data(serial); usb_free_urb(serial_priv->read_urb); kfree(serial_priv); }
static void qt2_release(struct usb_serial *serial) { int i; kfree(usb_get_serial_data(serial)); for (i = 0; i < serial->num_ports; i++) kfree(usb_get_serial_port_data(serial->port[i])); }
static void opticon_disconnect(struct usb_serial *serial) { struct opticon_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); usb_kill_urb(priv->bulk_read_urb); usb_free_urb(priv->bulk_read_urb); }
static void symbol_close(struct usb_serial_port *port) { struct symbol_private *priv = usb_get_serial_data(port->serial); dbg("%s - port %d", __func__, port->number); usb_kill_urb(priv->int_urb); }
static void opticon_release(struct usb_serial *serial) { struct opticon_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); kfree(priv->bulk_in_buffer); kfree(priv); }
static int modem_tiocmget(struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; struct modem_port *modem_port_ptr = usb_get_serial_data(port->serial); if (modem_port_ptr == NULL) return 0; return (int)modem_port_ptr->modem_status; }
static void opticon_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) { struct opticon_private *priv = usb_get_serial_data(port->serial); dbg("%s - port %d", __func__, port->number); /* shutdown our urbs */ usb_kill_urb(priv->bulk_read_urb); }
static void symbol_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct symbol_private *priv = usb_get_serial_data(port->serial); dbg("%s - port %d", __func__, port->number); spin_lock_irq(&priv->lock); priv->throttled = true; spin_unlock_irq(&priv->lock); }
static void qc_release(struct usb_serial *serial) { struct usb_wwan_intf_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); /* Call usb_wwan release & free the private data allocated in qcprobe */ usb_wwan_release(serial); usb_set_serial_data(serial, NULL); kfree(priv); }
static void opticon_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct opticon_private *priv = usb_get_serial_data(port->serial); unsigned long flags; dbg("%s - port %d", __func__, port->number); spin_lock_irqsave(&priv->lock, flags); priv->throttled = true; spin_unlock_irqrestore(&priv->lock, flags); }
static void opticon_shutdown(struct usb_serial *serial) { struct opticon_private *priv = usb_get_serial_data(serial); dbg("%s", __func__); usb_kill_urb(priv->bulk_read_urb); usb_free_urb(priv->bulk_read_urb); kfree(priv->bulk_in_buffer); kfree(priv); usb_set_serial_data(serial, NULL); }
static void modem_usb_disable_wakeup_irq(struct usb_interface *intf) { struct usb_serial *serial = usb_get_intfdata(intf); struct modem_port *modem_port_ptr = usb_get_serial_data(serial); if (modem_port_ptr == NULL) return; if (modem_wake_irq) { disable_irq_wake(modem_wake_irq); disable_irq(modem_wake_irq); } }
static void hsictty_write_callback(struct urb *urb) { struct usb_serial_port *port; struct hsictty_port_private *portdata; struct hsictty_intf_private *intfdata; int i; port = urb->context; intfdata = usb_get_serial_data(port->serial); portdata = usb_get_serial_port_data(port); if (urb->actual_length <= 0) { hsictty_error ("%s: write failed, write length: %d in channel:%d, endpoint:%d\n", __func__, urb->actual_length, portdata->channel, usb_pipeendpoint(urb->pipe)); } else { hsictty_dbg("%s: write length: %d in channel:%d, endpoint:%d\n", __func__, urb->actual_length, portdata->channel, usb_pipeendpoint(urb->pipe)); } #ifdef BACKUP_DATA_DUMP if (!dumped) backup_log(portdata->channel, 1, urb->transfer_buffer, urb->transfer_buffer_length); #endif usb_serial_port_softint(port); usb_autopm_put_interface_async(port->serial->interface); portdata = usb_get_serial_port_data(port); spin_lock(&intfdata->susp_lock); intfdata->in_flight--; spin_unlock(&intfdata->susp_lock); for (i = 0; i < N_OUT_URB; ++i) { if (portdata->out_urbs[i] == urb) { smp_mb__before_clear_bit(); hsictty_dbg ("%s: urb(%d) freed on channel:%d, endpoint:%d, in_flight:%d, pm use cnt:%d\n", __func__, i, portdata->channel, usb_pipeendpoint(urb->pipe), intfdata->in_flight, atomic_read(&port->serial->interface->dev.power. usage_count)); clear_bit(i, &portdata->out_busy); complete_all(&portdata->tx_notifier); break; } } }
static int opticon_resume(struct usb_interface *intf) { struct usb_serial *serial = usb_get_intfdata(intf); struct opticon_private *priv = usb_get_serial_data(serial); struct usb_serial_port *port = serial->port[0]; int result; mutex_lock(&port->mutex); if (port->port.count) result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO); else result = 0; mutex_unlock(&port->mutex); return result; }
static int sierra_calc_num_ports(struct usb_serial *serial) { int result; int *num_ports = usb_get_serial_data(serial); dev_dbg(&serial->dev->dev, "%s", __func__); result = *num_ports; if (result) { kfree(num_ports); usb_set_serial_data(serial, NULL); } return result; }
static int mxu1_port_probe(struct usb_serial_port *port) { struct mxu1_port *mxport; struct mxu1_device *mxdev; struct urb *urb; mxport = kzalloc(sizeof(struct mxu1_port), GFP_KERNEL); if (!mxport) return -ENOMEM; spin_lock_init(&mxport->mxp_lock); mutex_init(&mxport->mxp_mutex); mxport->mxp_port = port; mxdev = usb_get_serial_data(port->serial); urb = port->interrupt_in_urb; if (!urb) { dev_err(&port->dev, "%s - no interrupt urb\n", __func__); return -EINVAL; } switch (mxdev->mxd_model) { case MXU1_1110_PRODUCT_ID: mxport->mxp_uart_types = MXU1_TYPE_RS232; mxport->mxp_uart_mode = MXU1_UART_232; break; case MXU1_1130_PRODUCT_ID: case MXU1_1131_PRODUCT_ID: mxport->mxp_uart_types = MXU1_TYPE_RS422 | MXU1_TYPE_RS485; mxport->mxp_uart_mode = MXU1_UART_485_RECEIVER_DISABLED; break; case MXU1_1150_PRODUCT_ID: case MXU1_1151_PRODUCT_ID: mxport->mxp_uart_types = MXU1_TYPE_RS232 | MXU1_TYPE_RS422 | MXU1_TYPE_RS485; mxport->mxp_uart_mode = MXU1_UART_232; break; } usb_set_serial_port_data(port, mxport); port->port.closing_wait = msecs_to_jiffies(MXU1_DEFAULT_CLOSING_WAIT * 10); port->port.drain_delay = 1; return 0; }