Release 4.11 drivers/usb/class/cdc-acm.c
/*
* cdc-acm.c
*
* Copyright (c) 1999 Armin Fuerst <fuerst@in.tum.de>
* Copyright (c) 1999 Pavel Machek <pavel@ucw.cz>
* Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
* Copyright (c) 2004 Oliver Neukum <oliver@neukum.name>
* Copyright (c) 2005 David Kubicek <dave@awk.cz>
* Copyright (c) 2011 Johan Hovold <jhovold@gmail.com>
*
* USB Abstract Control Model driver for USB modems and ISDN adapters
*
* Sponsored by SuSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#undef DEBUG
#undef VERBOSE_DEBUG
#include <linux/kernel.h>
#include <linux/sched/signal.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include <linux/usb/cdc.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
#include <linux/idr.h>
#include <linux/list.h>
#include "cdc-acm.h"
#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek, Johan Hovold"
#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
static struct usb_driver acm_driver;
static struct tty_driver *acm_tty_driver;
static DEFINE_IDR(acm_minors);
static DEFINE_MUTEX(acm_minors_lock);
static void acm_tty_set_termios(struct tty_struct *tty,
struct ktermios *termios_old);
/*
* acm_minors accessors
*/
/*
* Look up an ACM structure by minor. If found and not disconnected, increment
* its refcount and return it with its mutex held.
*/
static struct acm *acm_get_by_minor(unsigned int minor)
{
struct acm *acm;
mutex_lock(&acm_minors_lock);
acm = idr_find(&acm_minors, minor);
if (acm) {
mutex_lock(&acm->mutex);
if (acm->disconnected) {
mutex_unlock(&acm->mutex);
acm = NULL;
} else {
tty_port_get(&acm->port);
mutex_unlock(&acm->mutex);
}
}
mutex_unlock(&acm_minors_lock);
return acm;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 78 | 82.11% | 1 | 25.00% |
Johan Hovold | 12 | 12.63% | 1 | 25.00% |
Alan Cox | 3 | 3.16% | 1 | 25.00% |
Linus Torvalds (pre-git) | 2 | 2.11% | 1 | 25.00% |
Total | 95 | 100.00% | 4 | 100.00% |
/*
* Try to find an available minor number and if found, associate it with 'acm'.
*/
static int acm_alloc_minor(struct acm *acm)
{
int minor;
mutex_lock(&acm_minors_lock);
minor = idr_alloc(&acm_minors, acm, 0, ACM_TTY_MINORS, GFP_KERNEL);
mutex_unlock(&acm_minors_lock);
return minor;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 29 | 64.44% | 1 | 33.33% |
Johan Hovold | 13 | 28.89% | 1 | 33.33% |
Alan Cox | 3 | 6.67% | 1 | 33.33% |
Total | 45 | 100.00% | 3 | 100.00% |
/* Release the minor number associated with 'acm'. */
static void acm_release_minor(struct acm *acm)
{
mutex_lock(&acm_minors_lock);
idr_remove(&acm_minors, acm->minor);
mutex_unlock(&acm_minors_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 25 | 75.76% | 1 | 50.00% |
Johan Hovold | 8 | 24.24% | 1 | 50.00% |
Total | 33 | 100.00% | 2 | 100.00% |
/*
* Functions for ACM control messages.
*/
static int acm_ctrl_msg(struct acm *acm, int request, int value,
void *buf, int len)
{
int retval;
retval = usb_autopm_get_interface(acm->control);
if (retval)
return retval;
retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0),
request, USB_RT_ACM, value,
acm->control->altsetting[0].desc.bInterfaceNumber,
buf, len, 5000);
dev_dbg(&acm->control->dev,
"%s - rq 0x%02x, val %#x, len %#x, result %d\n",
__func__, request, value, len, retval);
usb_autopm_put_interface(acm->control);
return retval < 0 ? retval : 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 81 | 65.32% | 8 | 61.54% |
Johan Hovold | 38 | 30.65% | 2 | 15.38% |
David Brownell | 4 | 3.23% | 2 | 15.38% |
Nishanth Aravamudan | 1 | 0.81% | 1 | 7.69% |
Total | 124 | 100.00% | 13 | 100.00% |
/* devices aren't required to support these requests.
* the cdc acm descriptor tells whether they do...
*/
static inline int acm_set_control(struct acm *acm, int control)
{
if (acm->quirks & QUIRK_CONTROL_LINE_STATE)
return -EOPNOTSUPP;
return acm_ctrl_msg(acm, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
control, NULL, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 35 | 85.37% | 1 | 50.00% |
Linus Torvalds (pre-git) | 6 | 14.63% | 1 | 50.00% |
Total | 41 | 100.00% | 2 | 100.00% |
#define acm_set_line(acm, line) \
acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0, line, sizeof *(line))
#define acm_send_break(acm, ms) \
acm_ctrl_msg(acm, USB_CDC_REQ_SEND_BREAK, ms, NULL, 0)
static void acm_kill_urbs(struct acm *acm)
{
int i;
usb_kill_urb(acm->ctrlurb);
for (i = 0; i < ACM_NW; i++)
usb_kill_urb(acm->wb[i].urb);
for (i = 0; i < acm->rx_buflimit; i++)
usb_kill_urb(acm->read_urbs[i]);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ladislav Michl | 71 | 100.00% | 1 | 100.00% |
Total | 71 | 100.00% | 1 | 100.00% |
/*
* Write buffer management.
* All of these assume proper locks taken by the caller.
*/
static int acm_wb_alloc(struct acm *acm)
{
int i, wbn;
struct acm_wb *wb;
wbn = 0;
i = 0;
for (;;) {
wb = &acm->wb[wbn];
if (!wb->use) {
wb->use = 1;
return wbn;
}
wbn = (wbn + 1) % ACM_NW;
if (++i >= ACM_NW)
return -1;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 84 | 98.82% | 2 | 66.67% |
David Engraf | 1 | 1.18% | 1 | 33.33% |
Total | 85 | 100.00% | 3 | 100.00% |
static int acm_wb_is_avail(struct acm *acm)
{
int i, n;
unsigned long flags;
n = ACM_NW;
spin_lock_irqsave(&acm->write_lock, flags);
for (i = 0; i < ACM_NW; i++)
n -= acm->wb[i].use;
spin_unlock_irqrestore(&acm->write_lock, flags);
return n;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 47 | 66.20% | 2 | 66.67% |
David Brownell | 24 | 33.80% | 1 | 33.33% |
Total | 71 | 100.00% | 3 | 100.00% |
/*
* Finish write. Caller must hold acm->write_lock
*/
static void acm_write_done(struct acm *acm, struct acm_wb *wb)
{
wb->use = 0;
acm->transmitting--;
usb_autopm_put_interface_async(acm->control);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 26 | 76.47% | 3 | 75.00% |
David Engraf | 8 | 23.53% | 1 | 25.00% |
Total | 34 | 100.00% | 4 | 100.00% |
/*
* Poke write.
*
* the caller is responsible for locking
*/
static int acm_start_wb(struct acm *acm, struct acm_wb *wb)
{
int rc;
acm->transmitting++;
wb->urb->transfer_buffer = wb->buf;
wb->urb->transfer_dma = wb->dmah;
wb->urb->transfer_buffer_length = wb->len;
wb->urb->dev = acm->dev;
rc = usb_submit_urb(wb->urb, GFP_ATOMIC);
if (rc < 0) {
dev_err(&acm->data->dev,
"%s - usb_submit_urb(write bulk) failed: %d\n",
__func__, rc);
acm_write_done(acm, wb);
}
return rc;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 94 | 86.24% | 1 | 33.33% |
Johan Hovold | 11 | 10.09% | 1 | 33.33% |
Alan Cox | 4 | 3.67% | 1 | 33.33% |
Total | 109 | 100.00% | 3 | 100.00% |
/*
* attributes exported through sysfs
*/
static ssize_t show_caps
(struct device *dev, struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
struct acm *acm = usb_get_intfdata(intf);
return sprintf(buf, "%d", acm->ctrl_caps);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 52 | 100.00% | 1 | 100.00% |
Total | 52 | 100.00% | 1 | 100.00% |
static DEVICE_ATTR(bmCapabilities, S_IRUGO, show_caps, NULL);
static ssize_t show_country_codes
(struct device *dev, struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
struct acm *acm = usb_get_intfdata(intf);
memcpy(buf, acm->country_codes, acm->country_code_size);
return acm->country_code_size;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 58 | 100.00% | 1 | 100.00% |
Total | 58 | 100.00% | 1 | 100.00% |
static DEVICE_ATTR(wCountryCodes, S_IRUGO, show_country_codes, NULL);
static ssize_t show_country_rel_date
(struct device *dev, struct device_attribute *attr, char *buf)
{
struct usb_interface *intf = to_usb_interface(dev);
struct acm *acm = usb_get_intfdata(intf);
return sprintf(buf, "%d", acm->country_rel_date);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 52 | 100.00% | 1 | 100.00% |
Total | 52 | 100.00% | 1 | 100.00% |
static DEVICE_ATTR(iCountryCodeRelDate, S_IRUGO, show_country_rel_date, NULL);
/*
* Interrupt handlers for various ACM device responses
*/
/* control interface reports status changes with "interrupt" transfers */
static void acm_ctrl_irq(struct urb *urb)
{
struct acm *acm = urb->context;
struct usb_cdc_notification *dr = urb->transfer_buffer;
unsigned char *data;
int newctrl;
int difference;
int retval;
int status = urb->status;
switch (status) {
case 0:
/* success */
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dev_dbg(&acm->control->dev,
"%s - urb shutting down with status: %d\n",
__func__, status);
return;
default:
dev_dbg(&acm->control->dev,
"%s - nonzero urb status received: %d\n",
__func__, status);
goto exit;
}
usb_mark_last_busy(acm->dev);
data = (unsigned char *)(dr + 1);
switch (dr->bNotificationType) {
case USB_CDC_NOTIFY_NETWORK_CONNECTION:
dev_dbg(&acm->control->dev,
"%s - network connection: %d\n", __func__, dr->wValue);
break;
case USB_CDC_NOTIFY_SERIAL_STATE:
newctrl = get_unaligned_le16(data);
if (!acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
dev_dbg(&acm->control->dev,
"%s - calling hangup\n", __func__);
tty_port_tty_hangup(&acm->port, false);
}
difference = acm->ctrlin ^ newctrl;
spin_lock(&acm->read_lock);
acm->ctrlin = newctrl;
acm->oldcount = acm->iocount;
if (difference & ACM_CTRL_DSR)
acm->iocount.dsr++;
if (difference & ACM_CTRL_BRK)
acm->iocount.brk++;
if (difference & ACM_CTRL_RI)
acm->iocount.rng++;
if (difference & ACM_CTRL_DCD)
acm->iocount.dcd++;
if (difference & ACM_CTRL_FRAMING)
acm->iocount.frame++;
if (difference & ACM_CTRL_PARITY)
acm->iocount.parity++;
if (difference & ACM_CTRL_OVERRUN)
acm->iocount.overrun++;
spin_unlock(&acm->read_lock);
if (difference)
wake_up_all(&acm->wioctl);
break;
default:
dev_dbg(&acm->control->dev,
"%s - unknown notification %d received: index %d "
"len %d data0 %d data1 %d\n",
__func__,
dr->bNotificationType, dr->wIndex,
dr->wLength, data[0], data[1]);
break;
}
exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval && retval != -EPERM)
dev_err(&acm->control->dev,
"%s - usb_submit_urb failed: %d\n", __func__, retval);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 125 | 28.94% | 3 | 12.00% |
Linus Torvalds (pre-git) | 124 | 28.70% | 8 | 32.00% |
Greg Kroah-Hartman | 70 | 16.20% | 3 | 12.00% |
Johan Hovold | 65 | 15.05% | 3 | 12.00% |
Linus Torvalds | 28 | 6.48% | 2 | 8.00% |
David Brownell | 8 | 1.85% | 2 | 8.00% |
Jiri Slaby | 7 | 1.62% | 1 | 4.00% |
Harvey Harrison | 4 | 0.93% | 2 | 8.00% |
Alan Cox | 1 | 0.23% | 1 | 4.00% |
Total | 432 | 100.00% | 25 | 100.00% |
static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags)
{
int res;
if (!test_and_clear_bit(index, &acm->read_urbs_free))
return 0;
res = usb_submit_urb(acm->read_urbs[index], mem_flags);
if (res) {
if (res != -EPERM) {
dev_err(&acm->data->dev,
"urb %d failed submission with %d\n",
index, res);
}
set_bit(index, &acm->read_urbs_free);
return res;
} else {
dev_vdbg(&acm->data->dev, "submitted urb %d\n", index);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 54 | 47.37% | 2 | 22.22% |
Oliver Neukum | 26 | 22.81% | 3 | 33.33% |
David Brownell | 19 | 16.67% | 1 | 11.11% |
David Kubicek | 12 | 10.53% | 1 | 11.11% |
Linus Torvalds (pre-git) | 3 | 2.63% | 2 | 22.22% |
Total | 114 | 100.00% | 9 | 100.00% |
static int acm_submit_read_urbs(struct acm *acm, gfp_t mem_flags)
{
int res;
int i;
for (i = 0; i < acm->rx_buflimit; ++i) {
res = acm_submit_read_urb(acm, i, mem_flags);
if (res)
return res;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 44 | 75.86% | 1 | 20.00% |
Oliver Neukum | 11 | 18.97% | 2 | 40.00% |
David Kubicek | 2 | 3.45% | 1 | 20.00% |
David Brownell | 1 | 1.72% | 1 | 20.00% |
Total | 58 | 100.00% | 5 | 100.00% |
static void acm_process_read_urb(struct acm *acm, struct urb *urb)
{
if (!urb->actual_length)
return;
tty_insert_flip_string(&acm->port, urb->transfer_buffer,
urb->actual_length);
tty_flip_buffer_push(&acm->port);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 12 | 25.00% | 1 | 10.00% |
Linus Torvalds (pre-git) | 11 | 22.92% | 3 | 30.00% |
David Brownell | 9 | 18.75% | 1 | 10.00% |
Jiri Slaby | 8 | 16.67% | 2 | 20.00% |
Oliver Neukum | 4 | 8.33% | 1 | 10.00% |
David Kubicek | 2 | 4.17% | 1 | 10.00% |
Alan Cox | 2 | 4.17% | 1 | 10.00% |
Total | 48 | 100.00% | 10 | 100.00% |
static void acm_read_bulk_callback(struct urb *urb)
{
struct acm_rb *rb = urb->context;
struct acm *acm = rb->instance;
unsigned long flags;
int status = urb->status;
dev_vdbg(&acm->data->dev, "got urb %d, len %d, status %d\n",
rb->index, urb->actual_length, status);
set_bit(rb->index, &acm->read_urbs_free);
if (!acm->dev) {
dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__);
return;
}
switch (status) {
case 0:
usb_mark_last_busy(acm->dev);
acm_process_read_urb(acm, urb);
break;
case -EPIPE:
set_bit(EVENT_RX_STALL, &acm->flags);
schedule_work(&acm->work);
return;
case -ENOENT:
case -ECONNRESET:
case -ESHUTDOWN:
dev_dbg(&acm->data->dev,
"%s - urb shutting down with status: %d\n",
__func__, status);
return;
default:
dev_dbg(&acm->data->dev,
"%s - nonzero urb status received: %d\n",
__func__, status);
break;
}
/*
* Unthrottle may run on another CPU which needs to see events
* in the same order. Submission has an implict barrier
*/
smp_mb__before_atomic();
/* throttle device if requested by tty */
spin_lock_irqsave(&acm->read_lock, flags);
acm->throttled = acm->throttle_req;
if (!acm->throttled) {
spin_unlock_irqrestore(&acm->read_lock, flags);
acm_submit_read_urb(acm, rb->index, GFP_ATOMIC);
} else {
spin_unlock_irqrestore(&acm->read_lock, flags);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 93 | 36.05% | 3 | 25.00% |
Ladislav Michl | 77 | 29.84% | 1 | 8.33% |
Oliver Neukum | 41 | 15.89% | 4 | 33.33% |
David Kubicek | 39 | 15.12% | 1 | 8.33% |
Arseniy Lartsev | 4 | 1.55% | 1 | 8.33% |
Jarek Poplawski | 3 | 1.16% | 1 | 8.33% |
Lu Baolu | 1 | 0.39% | 1 | 8.33% |
Total | 258 | 100.00% | 12 | 100.00% |
/* data interface wrote those outgoing bytes */
static void acm_write_bulk(struct urb *urb)
{
struct acm_wb *wb = urb->context;
struct acm *acm = wb->instance;
unsigned long flags;
int status = urb->status;
if (status || (urb->actual_length != urb->transfer_buffer_length))
dev_vdbg(&acm->data->dev, "wrote len %d/%d, status %d\n",
urb->actual_length,
urb->transfer_buffer_length,
status);
spin_lock_irqsave(&acm->write_lock, flags);
acm_write_done(acm, wb);
spin_unlock_irqrestore(&acm->write_lock, flags);
set_bit(EVENT_TTY_WAKEUP, &acm->flags);
schedule_work(&acm->work);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Brownell | 38 | 31.40% | 1 | 7.69% |
Oliver Neukum | 26 | 21.49% | 5 | 38.46% |
Brandon Philips | 24 | 19.83% | 1 | 7.69% |
Linus Torvalds (pre-git) | 16 | 13.22% | 3 | 23.08% |
Ladislav Michl | 10 | 8.26% | 1 | 7.69% |
David Engraf | 6 | 4.96% | 1 | 7.69% |
Johan Hovold | 1 | 0.83% | 1 | 7.69% |
Total | 121 | 100.00% | 13 | 100.00% |
static void acm_softint(struct work_struct *work)
{
int i;
struct acm *acm = container_of(work, struct acm, work);
if (test_bit(EVENT_RX_STALL, &acm->flags)) {
if (!(usb_autopm_get_interface(acm->data))) {
for (i = 0; i < acm->rx_buflimit; i++)
usb_kill_urb(acm->read_urbs[i]);
usb_clear_halt(acm->dev, acm->in);
acm_submit_read_urbs(acm, GFP_KERNEL);
usb_autopm_put_interface(acm->data);
}
clear_bit(EVENT_RX_STALL, &acm->flags);
}
if (test_bit(EVENT_TTY_WAKEUP, &acm->flags)) {
tty_port_tty_wakeup(&acm->port);
clear_bit(EVENT_TTY_WAKEUP, &acm->flags);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ladislav Michl | 115 | 77.18% | 1 | 20.00% |
Oliver Neukum | 25 | 16.78% | 1 | 20.00% |
Alan Cox | 4 | 2.68% | 1 | 20.00% |
Linus Torvalds (pre-git) | 4 | 2.68% | 1 | 20.00% |
Jiri Slaby | 1 | 0.67% | 1 | 20.00% |
Total | 149 | 100.00% | 5 | 100.00% |
/*
* TTY handlers
*/
static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
{
struct acm *acm;
int retval;
acm = acm_get_by_minor(tty->index);
if (!acm)
return -ENODEV;
retval = tty_standard_install(driver, tty);
if (retval)
goto error_init_termios;
tty->driver_data = acm;
return 0;
error_init_termios:
tty_port_put(&acm->port);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 35 | 43.75% | 1 | 9.09% |
Linus Torvalds (pre-git) | 22 | 27.50% | 3 | 27.27% |
Oliver Neukum | 11 | 13.75% | 2 | 18.18% |
David Engraf | 5 | 6.25% | 1 | 9.09% |
Johan Hovold | 3 | 3.75% | 2 | 18.18% |
Jiri Slaby | 3 | 3.75% | 1 | 9.09% |
Al Viro | 1 | 1.25% | 1 | 9.09% |
Total | 80 | 100.00% | 11 | 100.00% |
static int acm_tty_open(struct tty_struct *tty, struct file *filp)
{
struct acm *acm = tty->driver_data;
return tty_port_open(&acm->port, tty, filp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 27 | 71.05% | 1 | 25.00% |
Linus Torvalds (pre-git) | 6 | 15.79% | 2 | 50.00% |
Alan Cox | 5 | 13.16% | 1 | 25.00% |
Total | 38 | 100.00% | 4 | 100.00% |
static void acm_port_dtr_rts(struct tty_port *port, int raise)
{
struct acm *acm = container_of(port, struct acm, port);
int val;
int res;
if (raise)
val = ACM_CTRL_DTR | ACM_CTRL_RTS;
else
val = 0;
/* FIXME: add missing ctrlout locking throughout driver */
acm->ctrlout = val;
res = acm_set_control(acm, val);
if (res && (acm->ctrl_caps & USB_CDC_CAP_LINE))
dev_err(&acm->control->dev, "failed to set dtr/rts\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 90 | 100.00% | 1 | 100.00% |
Total | 90 | 100.00% | 1 | 100.00% |
static int acm_port_activate(struct tty_port *port, struct tty_struct *tty)
{
struct acm *acm = container_of(port, struct acm, port);
int retval = -ENODEV;
int i;
mutex_lock(&acm->mutex);
if (acm->disconnected)
goto disconnected;
retval = usb_autopm_get_interface(acm->control);
if (retval)
goto error_get_interface;
/*
* FIXME: Why do we need this? Allocating 64K of physically contiguous
* memory is really nasty...
*/
set_bit(TTY_NO_WRITE_SPLIT, &tty->flags);
acm->control->needs_remote_wakeup = 1;
acm->ctrlurb->dev = acm->dev;
retval = usb_submit_urb(acm->ctrlurb, GFP_KERNEL);
if (retval) {
dev_err(&acm->control->dev,
"%s - usb_submit_urb(ctrl irq) failed\n", __func__);
goto error_submit_urb;
}
acm_tty_set_termios(tty, NULL);
/*
* Unthrottle device in case the TTY was closed while throttled.
*/
spin_lock_irq(&acm->read_lock);
acm->throttled = 0;
acm->throttle_req = 0;
spin_unlock_irq(&acm->read_lock);
retval = acm_submit_read_urbs(acm, GFP_KERNEL);
if (retval)
goto error_submit_read_urbs;
usb_autopm_put_interface(acm->control);
mutex_unlock(&acm->mutex);
return 0;
error_submit_read_urbs:
for (i = 0; i < acm->rx_buflimit; i++)
usb_kill_urb(acm->read_urbs[i]);
usb_kill_urb(acm->ctrlurb);
error_submit_urb:
usb_autopm_put_interface(acm->control);
error_get_interface:
disconnected:
mutex_unlock(&acm->mutex);
return usb_translate_errors(retval);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 80 | 29.96% | 1 | 4.76% |
Johan Hovold | 76 | 28.46% | 5 | 23.81% |
Oliver Neukum | 45 | 16.85% | 6 | 28.57% |
Otto Meta | 29 | 10.86% | 1 | 4.76% |
Linus Torvalds (pre-git) | 23 | 8.61% | 4 | 19.05% |
Jim Paris | 7 | 2.62% | 1 | 4.76% |
Alan Cox | 4 | 1.50% | 1 | 4.76% |
Greg Kroah-Hartman | 3 | 1.12% | 2 | 9.52% |
Total | 267 | 100.00% | 21 | 100.00% |
static void acm_port_destruct(struct tty_port *port)
{
struct acm *acm = container_of(port, struct acm, port);
acm_release_minor(acm);
usb_put_intf(acm->control);
kfree(acm->country_codes);
kfree(acm);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Brian Murphy | 26 | 52.00% | 1 | 33.33% |
Håvard Skinnemoen | 17 | 34.00% | 1 | 33.33% |
Oliver Neukum | 7 | 14.00% | 1 | 33.33% |
Total | 50 | 100.00% | 3 | 100.00% |
static void acm_port_shutdown(struct tty_port *port)
{
struct acm *acm = container_of(port, struct acm, port);
struct urb *urb;
struct acm_wb *wb;
/*
* Need to grab write_lock to prevent race with resume, but no need to
* hold it due to the tty-port initialised flag.
*/
spin_lock_irq(&acm->write_lock);
spin_unlock_irq(&acm->write_lock);
usb_autopm_get_interface_no_resume(acm->control);
acm->control->needs_remote_wakeup = 0;
usb_autopm_put_interface(acm->control);
for (;;) {
urb = usb_get_from_anchor(&acm->delayed);
if (!urb)
break;
wb = urb->context;
wb->use = 0;
usb_autopm_put_interface_async(acm->control);
}
acm_kill_urbs(acm);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johan Hovold | 80 | 65.57% | 3 | 27.27% |
Linus Torvalds (pre-git) | 18 | 14.75% | 5 | 45.45% |
Håvard Skinnemoen | 18 | 14.75% | 1 | 9.09% |
Oliver Neukum | 5 | 4.10% | 1 | 9.09% |
Ladislav Michl | 1 | 0.82% | 1 | 9.09% |
Total | 122 | 100.00% | 11 | 100.00% |
static void acm_tty_cleanup(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
tty_port_put(&acm->port);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 18 | 64.29% | 1 | 20.00% |
Håvard Skinnemoen | 8 | 28.57% | 2 | 40.00% |
Linus Torvalds (pre-git) | 2 | 7.14% | 2 | 40.00% |
Total | 28 | 100.00% | 5 | 100.00% |
static void acm_tty_hangup(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
tty_port_hangup(&acm->port);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 25 | 89.29% | 1 | 33.33% |
Håvard Skinnemoen | 2 | 7.14% | 1 | 33.33% |
Francesco Lavra | 1 | 3.57% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
static void acm_tty_close(struct tty_struct *tty, struct file *filp)
{
struct acm *acm = tty->driver_data;
tty_port_close(&acm->port, tty, filp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Håvard Skinnemoen | 26 | 70.27% | 2 | 40.00% |
Francesco Lavra | 8 | 21.62% | 1 | 20.00% |
Oliver Neukum | 2 | 5.41% | 1 | 20.00% |
Linus Torvalds (pre-git) | 1 | 2.70% | 1 | 20.00% |
Total | 37 | 100.00% | 5 | 100.00% |
static int acm_tty_write(struct tty_struct *tty,
const unsigned char *buf, int count)
{
struct acm *acm = tty->driver_data;
int stat;
unsigned long flags;
int wbn;
struct acm_wb *wb;
if (!count)
return 0;
dev_vdbg(&acm->data->dev, "%d bytes from tty layer\n", count);
spin_lock_irqsave(&acm->write_lock, flags);
wbn = acm_wb_alloc(acm);
if (wbn < 0) {
spin_unlock_irqrestore(&acm->write_lock, flags);
return 0;
}
wb = &acm->wb[wbn];
if (!acm->dev) {
wb->use = 0;
spin_unlock_irqrestore(&acm->write_lock, flags);
return -ENODEV;
}
count = (count > acm->writesize) ? acm->writesize : count;
dev_vdbg(&acm->data->dev, "writing %d bytes\n", count);
memcpy(wb->buf, buf, count);
wb->len = count;
stat = usb_autopm_get_interface_async(acm->control);
if (stat) {
wb->use = 0;
spin_unlock_irqrestore(&acm->write_lock, flags);
return stat;
}
if (acm->susp_count) {
if (acm->putbuffer) {
/* now to preserve order */
usb_anchor_urb(acm->putbuffer->urb, &acm->delayed);
acm->putbuffer = NULL;
}
usb_anchor_urb(wb->urb, &acm->delayed);
spin_unlock_irqrestore(&acm->write_lock, flags);
return count;
} else {
if (acm->putbuffer) {
/* at this point there is no good way to handle errors */
acm_start_wb(acm, acm->putbuffer);
acm->putbuffer = NULL;
}
}
stat = acm_start_wb(acm, wb);
spin_unlock_irqrestore(&acm->write_lock, flags);
if (stat < 0)
return stat;
return count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 128 | 37.21% | 4 | 20.00% |
Linus Torvalds (pre-git) | 76 | 22.09% | 6 | 30.00% |
Greg Kroah-Hartman | 66 | 19.19% | 3 | 15.00% |
Johan Hovold | 55 | 15.99% | 4 | 20.00% |
David Brownell | 10 | 2.91% | 1 | 5.00% |
Alan Cox | 8 | 2.33% | 1 | 5.00% |
David Engraf | 1 | 0.29% | 1 | 5.00% |
Total | 344 | 100.00% | 20 | 100.00% |
static void acm_tty_flush_chars(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
struct acm_wb *cur = acm->putbuffer;
int err;
unsigned long flags;
if (!cur) /* nothing to do */
return;
acm->putbuffer = NULL;
err = usb_autopm_get_interface_async(acm->control);
spin_lock_irqsave(&acm->write_lock, flags);
if (err < 0) {
cur->use = 0;
acm->putbuffer = cur;
goto out;
}
if (acm->susp_count)
usb_anchor_urb(cur->urb, &acm->delayed);
else
acm_start_wb(acm, cur);
out:
spin_unlock_irqrestore(&acm->write_lock, flags);
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 130 | 100.00% | 2 | 100.00% |
Total | 130 | 100.00% | 2 | 100.00% |
static int acm_tty_put_char(struct tty_struct *tty, unsigned char ch)
{
struct acm *acm = tty->driver_data;
struct acm_wb *cur;
int wbn;
unsigned long flags;
overflow:
cur = acm->putbuffer;
if (!cur) {
spin_lock_irqsave(&acm->write_lock, flags);
wbn = acm_wb_alloc(acm);
if (wbn >= 0) {
cur = &acm->wb[wbn];
acm->putbuffer = cur;
}
spin_unlock_irqrestore(&acm->write_lock, flags);
if (!cur)
return 0;
}
if (cur->len == acm->writesize) {
acm_tty_flush_chars(tty);
goto overflow;
}
cur->buf[cur->len++] = ch;
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 145 | 100.00% | 1 | 100.00% |
Total | 145 | 100.00% | 1 | 100.00% |
static int acm_tty_write_room(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
/*
* Do not let the line discipline to know that we have a reserve,
* or it might get too enthusiastic.
*/
return acm_wb_is_avail(acm) ? acm->writesize : 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 26 | 78.79% | 4 | 80.00% |
Oliver Neukum | 7 | 21.21% | 1 | 20.00% |
Total | 33 | 100.00% | 5 | 100.00% |
static int acm_tty_chars_in_buffer(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
/*
* if the device was unplugged then any remaining characters fell out
* of the connector ;)
*/
if (acm->disconnected)
return 0;
/*
* This is inaccurate (overcounts), but it works.
*/
return (ACM_NW - acm_wb_is_avail(acm)) * acm->writesize;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 31 | 68.89% | 3 | 42.86% |
Oliver Neukum | 10 | 22.22% | 2 | 28.57% |
Håvard Skinnemoen | 3 | 6.67% | 1 | 14.29% |
Alan Cox | 1 | 2.22% | 1 | 14.29% |
Total | 45 | 100.00% | 7 | 100.00% |
static void acm_tty_throttle(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
spin_lock_irq(&acm->read_lock);
acm->throttle_req = 1;
spin_unlock_irq(&acm->read_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 25 | 59.52% | 6 | 75.00% |
Oliver Neukum | 12 | 28.57% | 1 | 12.50% |
Johan Hovold | 5 | 11.90% | 1 | 12.50% |
Total | 42 | 100.00% | 8 | 100.00% |
static void acm_tty_unthrottle(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
unsigned int was_throttled;
spin_lock_irq(&acm->read_lock);
was_throttled = acm->throttled;
acm->throttled = 0;
acm->throttle_req = 0;
spin_unlock_irq(&acm->read_lock);
if (was_throttled)
acm_submit_read_urbs(acm, GFP_KERNEL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 29 | 42.03% | 2 | 50.00% |
Johan Hovold | 28 | 40.58% | 1 | 25.00% |
Oliver Neukum | 12 | 17.39% | 1 | 25.00% |
Total | 69 | 100.00% | 4 | 100.00% |
static int acm_tty_break_ctl(struct tty_struct *tty, int state)
{
struct acm *acm = tty->driver_data;
int retval;
retval = acm_send_break(acm, state ? 0xffff : 0);
if (retval < 0)
dev_dbg(&acm->control->dev,
"%s - send break failed\n", __func__);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 36 | 58.06% | 3 | 60.00% |
Alan Cox | 15 | 24.19% | 1 | 20.00% |
Johan Hovold | 11 | 17.74% | 1 | 20.00% |
Total | 62 | 100.00% | 5 | 100.00% |
static int acm_tty_tiocmget(struct tty_struct *tty)
{
struct acm *acm = tty->driver_data;
return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
(acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
(acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
(acm->ctrlin & ACM_CTRL_RI ? TIOCM_RI : 0) |
(acm->ctrlin & ACM_CTRL_DCD ? TIOCM_CD : 0) |
TIOCM_CTS;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 81 | 97.59% | 1 | 50.00% |
Greg Kroah-Hartman | 2 | 2.41% | 1 | 50.00% |
Total | 83 | 100.00% | 2 | 100.00% |
static int acm_tty_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{
struct acm *acm = tty->driver_data;
unsigned int newctrl;
newctrl = acm->ctrlout;
set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
(set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) |
(clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
newctrl = (newctrl & ~clear) | set;
if (acm->ctrlout == newctrl)
return 0;
return acm_set_control(acm, acm->ctrlout = newctrl);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Greg Kroah-Hartman | 61 | 52.59% | 1 | 16.67% |
Linus Torvalds (pre-git) | 55 | 47.41% | 5 | 83.33% |
Total | 116 | 100.00% | 6 | 100.00% |
static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
{
struct serial_struct tmp;
memset(&tmp, 0, sizeof(tmp));
tmp.xmit_fifo_size = acm->writesize;
tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
tmp.close_delay = acm->port.close_delay / 10;
tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE :
acm->port.closing_wait / 10;
if (copy_to_user(info, &tmp, sizeof(tmp)))
return -EFAULT;
else
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 78 | 69.64% | 1 | 50.00% |
Dan J Williams | 34 | 30.36% | 1 | 50.00% |
Total | 112 | 100.00% | 2 | 100.00% |
static int set_serial_info(struct acm *acm,
struct serial_struct __user *newinfo)
{
struct serial_struct new_serial;
unsigned int closing_wait, close_delay;
int retval = 0;
if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
return -EFAULT;
close_delay = new_serial.close_delay * 10;
closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
mutex_lock(&acm->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
if ((close_delay != acm->port.close_delay) ||
(closing_wait != acm->port.closing_wait))
retval = -EPERM;
else
retval = -EOPNOTSUPP;
} else {
acm->port.close_delay = close_delay;
acm->port.closing_wait = closing_wait;
}
mutex_unlock(&acm->port.mutex);
return retval;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dan J Williams | 160 | 100.00% | 1 | 100.00% |
Total | 160 | 100.00% | 1 | 100.00% |
static int wait_serial_change(struct acm *acm, unsigned long arg)
{
int rv = 0;
DECLARE_WAITQUEUE(wait, current);
struct async_icount old, new;
do {
spin_lock_irq(&acm->read_lock);
old = acm->oldcount;
new = acm->iocount;
acm->oldcount = new;
spin_unlock_irq(&acm->read_lock);
if ((arg & TIOCM_DSR) &&
old.dsr != new.dsr)
break;
if ((arg & TIOCM_CD) &&
old.dcd != new.dcd)
break;
if ((arg & TIOCM_RI) &&
old.rng != new.rng)
break;
add_wait_queue(&acm->wioctl, &wait);
set_current_state(TASK_INTERRUPTIBLE);
schedule();
remove_wait_queue(&acm->wioctl, &wait);
if (acm->disconnected) {
if (arg & TIOCM_CD)
break;
else
rv = -ENODEV;
} else {
if (signal_pending(current))
rv = -ERESTARTSYS;
}
} while (!rv);
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 196 | 100.00% | 1 | 100.00% |
Total | 196 | 100.00% | 1 | 100.00% |
static int acm_tty_get_icount(struct tty_struct *tty,
struct serial_icounter_struct *icount)
{
struct acm *acm = tty->driver_data;
icount->dsr = acm->iocount.dsr;
icount->rng = acm->iocount.rng;
icount->dcd = acm->iocount.dcd;
icount->frame = acm->iocount.frame;
icount->overrun = acm->iocount.overrun;
icount->parity = acm->iocount.parity;
icount->brk = acm->iocount.brk;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 80 | 81.63% | 1 | 50.00% |
Johan Hovold | 18 | 18.37% | 1 | 50.00% |
Total | 98 | 100.00% | 2 | 100.00% |
static int acm_tty_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
struct acm *acm = tty->driver_data;
int rv = -ENOIOCTLCMD;
switch (cmd) {
case TIOCGSERIAL: /* gets serial port data */
rv = get_serial_info(acm, (struct serial_struct __user *) arg);
break;
case TIOCSSERIAL:
rv = set_serial_info(acm, (struct serial_struct __user *) arg);
break;
case TIOCMIWAIT:
rv = usb_autopm_get_interface(acm->control);
if (rv < 0) {
rv = -EIO;
break;
}
rv = wait_serial_change(acm, arg);
usb_autopm_put_interface(acm->control);
break;
}
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 84 | 67.20% | 3 | 42.86% |
Dan J Williams | 19 | 15.20% | 1 | 14.29% |
Greg Kroah-Hartman | 18 | 14.40% | 1 | 14.29% |
Linus Torvalds (pre-git) | 4 | 3.20% | 2 | 28.57% |
Total | 125 | 100.00% | 7 | 100.00% |
static void acm_tty_set_termios(struct tty_struct *tty,
struct ktermios *termios_old)
{
struct acm *acm = tty->driver_data;
struct ktermios *termios = &tty->termios;
struct usb_cdc_line_coding newline;
int newctrl = acm->ctrlout;
newline.dwDTERate = cpu_to_le32(tty_get_baud_rate(tty));
newline.bCharFormat = termios->c_cflag & CSTOPB ? 2 : 0;
newline.bParityType = termios->c_cflag & PARENB ?
(termios->c_cflag & PARODD ? 1 : 2) +
(termios->c_cflag & CMSPAR ? 2 : 0) : 0;
switch (termios->c_cflag & CSIZE) {
case CS5:
newline.bDataBits = 5;
break;
case CS6:
newline.bDataBits = 6;
break;
case CS7:
newline.bDataBits = 7;
break;
case CS8:
default:
newline.bDataBits = 8;
break;
}
/* FIXME: Needs to clear unsupported bits in the termios */
acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
if (C_BAUD(tty) == B0) {
newline.dwDTERate = acm->line.dwDTERate;
newctrl &= ~ACM_CTRL_DTR;
} else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) {
newctrl |= ACM_CTRL_DTR;
}
if (newctrl != acm->ctrlout)
acm_set_control(acm, acm->ctrlout = newctrl);
if (memcmp(&acm->line, &newline, sizeof newline)) {
memcpy(&acm->line, &newline, sizeof newline);
dev_dbg(&acm->control->dev, "%s - set line: %d %d %d %d\n",
__func__,
le32_to_cpu(newline.dwDTERate),
newline.bCharFormat, newline.bParityType,
newline.bDataBits);
acm_set_line(acm, &acm->line);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 208 | 65.62% | 7 | 43.75% |
Nicolas Boullis | 45 | 14.20% | 1 | 6.25% |
Johan Hovold | 34 | 10.73% | 2 | 12.50% |
David Brownell | 15 | 4.73% | 1 | 6.25% |
Alan Cox | 9 | 2.84% | 4 | 25.00% |
Linus Torvalds | 6 | 1.89% | 1 | 6.25% |
Total | 317 | 100.00% | 16 | 100.00% |
static const struct tty_port_operations acm_port_ops = {
.dtr_rts = acm_port_dtr_rts,
.shutdown = acm_port_shutdown,
.activate = acm_port_activate,
.destruct = acm_port_destruct,
};
/*
* USB probe and disconnect routines.
*/
/* Little helpers: write/read buffers free */
static void acm_write_buffers_free(struct acm *acm)
{
int i;
struct acm_wb *wb;
for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++)
usb_free_coherent(acm->dev, acm->writesize, wb->buf, wb->dmah);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 60 | 93.75% | 2 | 50.00% |
Ladislav Michl | 3 | 4.69% | 1 | 25.00% |
Daniel Mack | 1 | 1.56% | 1 | 25.00% |
Total | 64 | 100.00% | 4 | 100.00% |
static void acm_read_buffers_free(struct acm *acm)
{
int i;
for (i = 0; i < acm->rx_buflimit; i++)
usb_free_coherent(acm->dev, acm->readsize,
acm->read_buffers[i].base, acm->read_buffers[i].dma);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 49 | 84.48% | 1 | 20.00% |
Johan Hovold | 5 | 8.62% | 2 | 40.00% |
Ladislav Michl | 3 | 5.17% | 1 | 20.00% |
Daniel Mack | 1 | 1.72% | 1 | 20.00% |
Total | 58 | 100.00% | 5 | 100.00% |
/* Little helper: write buffers allocate */
static int acm_write_buffers_alloc(struct acm *acm)
{
int i;
struct acm_wb *wb;
for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++) {
wb->buf = usb_alloc_coherent(acm->dev, acm->writesize, GFP_KERNEL,
&wb->dmah);
if (!wb->buf) {
while (i != 0) {
--i;
--wb;
usb_free_coherent(acm->dev, acm->writesize,
wb->buf, wb->dmah);
}
return -ENOMEM;
}
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 116 | 98.31% | 2 | 66.67% |
Daniel Mack | 2 | 1.69% | 1 | 33.33% |
Total | 118 | 100.00% | 3 | 100.00% |
static int acm_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_cdc_union_desc *union_header = NULL;
struct usb_cdc_call_mgmt_descriptor *cmgmd = NULL;
unsigned char *buffer = intf->altsetting->extra;
int buflen = intf->altsetting->extralen;
struct usb_interface *control_interface;
struct usb_interface *data_interface;
struct usb_endpoint_descriptor *epctrl = NULL;
struct usb_endpoint_descriptor *epread = NULL;
struct usb_endpoint_descriptor *epwrite = NULL;
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct usb_cdc_parsed_header h;
struct acm *acm;
int minor;
int ctrlsize, readsize;
u8 *buf;
int call_intf_num = -1;
int data_intf_num = -1;
unsigned long quirks;
int num_rx_buf;
int i;
int combined_interfaces = 0;
struct device *tty_dev;
int rv = -ENOMEM;
/* normal quirks */
quirks = (unsigned long)id->driver_info;
if (quirks == IGNORE_DEVICE)
return -ENODEV;
memset(&h, 0x00, sizeof(struct usb_cdc_parsed_header));
num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR;
/* handle quirks deadly to normal probing*/
if (quirks == NO_UNION_NORMAL) {
data_interface = usb_ifnum_to_if(usb_dev, 1);
control_interface = usb_ifnum_to_if(usb_dev, 0);
/* we would crash */
if (!data_interface || !control_interface)
return -ENODEV;
goto skip_normal_probe;
}
/* normal probing*/
if (!buffer) {
dev_err(&intf->dev, "Weird descriptor references\n");
return -EINVAL;
}
if (!intf->cur_altsetting)
return -EINVAL;
if (!buflen) {
if (intf->cur_altsetting->endpoint &&
intf->cur_altsetting->endpoint->extralen &&
intf->cur_altsetting->endpoint->extra) {
dev_dbg(&intf->dev,
"Seeking extra descriptors on endpoint\n");
buflen = intf->cur_altsetting->endpoint->extralen;
buffer = intf->cur_altsetting->endpoint->extra;
} else {
dev_err(&intf->dev,
"Zero length descriptor references\n");
return -EINVAL;
}
}
cdc_parse_cdc_header(&h, intf, buffer, buflen);
union_header = h.usb_cdc_union_desc;
cmgmd = h.usb_cdc_call_mgmt_descriptor;
if (cmgmd)
call_intf_num = cmgmd->bDataInterface;
if (!union_header) {
if (call_intf_num > 0) {
dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n");
/* quirks for Droids MuIn LCD */
if (quirks & NO_DATA_INTERFACE) {
data_interface = usb_ifnum_to_if(usb_dev, 0);
} else {
data_intf_num = call_intf_num;
data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
}
control_interface = intf;
} else {
if (intf->cur_altsetting->desc.bNumEndpoints != 3) {
dev_dbg(&intf->dev,"No union descriptor, giving up\n");
return -ENODEV;
} else {
dev_warn(&intf->dev,"No union descriptor, testing for castrated device\n");
combined_interfaces = 1;
control_interface = data_interface = intf;
goto look_for_collapsed_interface;
}
}
} else {
data_intf_num = union_header->bSlaveInterface0;
control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
}
if (!control_interface || !data_interface) {
dev_dbg(&intf->dev, "no interfaces\n");
return -ENODEV;
}
if (!data_interface->cur_altsetting || !control_interface->cur_altsetting)
return -ENODEV;
if (data_intf_num != call_intf_num)
dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n");
if (control_interface == data_interface) {
/* some broken devices designed for windows work this way */
dev_warn(&intf->dev,"Control and data interfaces are not separated!\n");
combined_interfaces = 1;
/* a popular other OS doesn't use it */
quirks |= NO_CAP_LINE;
if (data_interface->cur_altsetting->desc.bNumEndpoints != 3) {
dev_err(&intf->dev, "This needs exactly 3 endpoints\n");
return -EINVAL;
}
look_for_collapsed_interface:
for (i = 0; i < 3; i++) {
struct usb_endpoint_descriptor *ep;
ep = &data_interface->cur_altsetting->endpoint[i].desc;
if (usb_endpoint_is_int_in(ep))
epctrl = ep;
else if (usb_endpoint_is_bulk_out(ep))
epwrite = ep;
else if (usb_endpoint_is_bulk_in(ep))
epread = ep;
else
return -EINVAL;
}
if (!epctrl || !epread || !epwrite)
return -ENODEV;
else
goto made_compressed_probe;
}
skip_normal_probe:
/*workaround for switched interfaces */
if (data_interface->cur_altsetting->desc.bInterfaceClass
!= CDC_DATA_INTERFACE_TYPE) {
if (control_interface->cur_altsetting->desc.bInterfaceClass
== CDC_DATA_INTERFACE_TYPE) {
dev_dbg(&intf->dev,
"Your device has switched interfaces.\n");
swap(control_interface, data_interface);
} else {
return -EINVAL;
}
}
/* Accept probe requests only for the control interface */
if (!combined_interfaces && intf != control_interface)
return -ENODEV;
if (!combined_interfaces && usb_interface_claimed(data_interface)) {
/* valid in this context */
dev_dbg(&intf->dev, "The data interface isn't available\n");
return -EBUSY;
}
if (data_interface->cur_altsetting->desc.bNumEndpoints < 2 ||
control_interface->cur_altsetting->desc.bNumEndpoints == 0)
return -EINVAL;
epctrl = &control_interface->cur_altsetting->endpoint[0].desc;
epread = &data_interface->cur_altsetting->endpoint[0].desc;
epwrite = &data_interface->cur_altsetting->endpoint[1].desc;
/* workaround for switched endpoints */
if (!usb_endpoint_dir_in(epread)) {
/* descriptors are swapped */
dev_dbg(&intf->dev,
"The data interface has switched endpoints\n");
swap(epread, epwrite);
}
made_compressed_probe:
dev_dbg(&intf->dev, "interfaces are valid\n");
acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
if (acm == NULL)
goto alloc_fail;
minor = acm_alloc_minor(acm);
if (minor < 0)
goto alloc_fail1;
ctrlsize = usb_endpoint_maxp(epctrl);
readsize = usb_endpoint_maxp(epread) *
(quirks == SINGLE_RX_URB ? 1 : 2);
acm->combined_interfaces = combined_interfaces;
acm->writesize = usb_endpoint_maxp(epwrite) * 20;
acm->control = control_interface;
acm->data = data_interface;
acm->minor = minor;
acm->dev = usb_dev;
if (h.usb_cdc_acm_descriptor)
acm->ctrl_caps = h.usb_cdc_acm_descriptor->bmCapabilities;
if (quirks & NO_CAP_LINE)
acm->ctrl_caps &= ~USB_CDC_CAP_LINE;
acm->ctrlsize = ctrlsize;
acm->readsize = readsize;
acm->rx_buflimit = num_rx_buf;
INIT_WORK(&acm->work, acm_softint);
init_waitqueue_head(&acm->wioctl);
spin_lock_init(&acm->write_lock);
spin_lock_init(&acm->read_lock);
mutex_init(&acm->mutex);
if (usb_endpoint_xfer_int(epread)) {
acm->bInterval = epread->bInterval;
acm->in = usb_rcvintpipe(usb_dev, epread->bEndpointAddress);
} else {
acm->in = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
}
if (usb_endpoint_xfer_int(epwrite))
acm->out = usb_sndintpipe(usb_dev, epwrite->bEndpointAddress);
else
acm->out = usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress);
tty_port_init(&acm->port);
acm->port.ops = &acm_port_ops;
init_usb_anchor(&acm->delayed);
acm->quirks = quirks;
buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
if (!buf)
goto alloc_fail2;
acm->ctrl_buffer = buf;
if (acm_write_buffers_alloc(acm) < 0)
goto alloc_fail4;
acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
if (!acm->ctrlurb)
goto alloc_fail5;
for (i = 0; i < num_rx_buf; i++) {
struct acm_rb *rb = &(acm->read_buffers[i]);
struct urb *urb;
rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
&rb->dma);
if (!rb->base)
goto alloc_fail6;
rb->index = i;
rb->instance = acm;
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
goto alloc_fail6;
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
urb->transfer_dma = rb->dma;
if (usb_endpoint_xfer_int(epread))
usb_fill_int_urb(urb, acm->dev, acm->in, rb->base,
acm->readsize,
acm_read_bulk_callback, rb,
acm->bInterval);
else
usb_fill_bulk_urb(urb, acm->dev, acm->in, rb->base,
acm->readsize,
acm_read_bulk_callback, rb);
acm->read_urbs[i] = urb;
__set_bit(i, &acm->read_urbs_free);
}
for (i = 0; i < ACM_NW; i++) {
struct acm_wb *snd = &(acm->wb[i]);
snd->urb = usb_alloc_urb(0, GFP_KERNEL);
if (snd->urb == NULL)
goto alloc_fail7;
if (usb_endpoint_xfer_int(epwrite))
usb_fill_int_urb(snd->urb, usb_dev, acm->out,
NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
else
usb_fill_bulk_urb(snd->urb, usb_dev, acm->out,
NULL, acm->writesize, acm_write_bulk, snd);
snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
if (quirks & SEND_ZERO_PACKET)
snd->urb->transfer_flags |= URB_ZERO_PACKET;
snd->instance = acm;
}
usb_set_intfdata(intf, acm);
i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
if (i < 0)
goto alloc_fail7;
if (h.usb_cdc_country_functional_desc) { /* export the country data */
struct usb_cdc_country_functional_desc * cfd =
h.usb_cdc_country_functional_desc;
acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
if (!acm->country_codes)
goto skip_countries;
acm->country_code_size = cfd->bLength - 4;
memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0,
cfd->bLength - 4);
acm->country_rel_date = cfd->iCountryCodeRelDate;
i = device_create_file(&intf->dev, &dev_attr_wCountryCodes);
if (i < 0) {
kfree(acm->country_codes);
acm->country_codes = NULL;
acm->country_code_size = 0;
goto skip_countries;
}
i = device_create_file(&intf->dev,
&dev_attr_iCountryCodeRelDate);
if (i < 0) {
device_remove_file(&intf->dev, &dev_attr_wCountryCodes);
kfree(acm->country_codes);
acm->country_codes = NULL;
acm->country_code_size = 0;
goto skip_countries;
}
}
skip_countries:
usb_fill_int_urb(acm->ctrlurb, usb_dev,
usb_rcvintpipe(usb_dev, epctrl->bEndpointAddress),
acm->ctrl_buffer, ctrlsize, acm_ctrl_irq, acm,
/* works around buggy devices */
epctrl->bInterval ? epctrl->bInterval : 16);
acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
acm->ctrlurb->transfer_dma = acm->ctrl_dma;
dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
acm->line.dwDTERate = cpu_to_le32(9600);
acm->line.bDataBits = 8;
acm_set_line(acm, &acm->line);
usb_driver_claim_interface(&acm_driver, data_interface, acm);
usb_set_intfdata(data_interface, acm);
usb_get_intf(control_interface);
tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
&control_interface->dev);
if (IS_ERR(tty_dev)) {
rv = PTR_ERR(tty_dev);
goto alloc_fail8;
}
if (quirks & CLEAR_HALT_CONDITIONS) {
usb_clear_halt(usb_dev, acm->in);
usb_clear_halt(usb_dev, acm->out);
}
return 0;
alloc_fail8:
if (acm->country_codes) {
device_remove_file(&acm->control->dev,
&dev_attr_wCountryCodes);
device_remove_file(&acm->control->dev,
&dev_attr_iCountryCodeRelDate);
kfree(acm->country_codes);
}
device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
alloc_fail7:
usb_set_intfdata(intf, NULL);
for (i = 0; i < ACM_NW; i++)
usb_free_urb(acm->wb[i].urb);
alloc_fail6:
for (i = 0; i < num_rx_buf; i++)
usb_free_urb(acm->read_urbs[i]);
acm_read_buffers_free(acm);
usb_free_urb(acm->ctrlurb);
alloc_fail5:
acm_write_buffers_free(acm);
alloc_fail4:
usb_free_coherent(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
alloc_fail2:
acm_release_minor(acm);
alloc_fail1:
kfree(acm);
alloc_fail:
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 1130 | 51.13% | 21 | 24.42% |
Johan Hovold | 168 | 7.60% | 6 | 6.98% |
Linus Torvalds (pre-git) | 147 | 6.65% | 13 | 15.12% |
Alexey Khoroshilov | 89 | 4.03% | 1 | 1.16% |
David Engraf | 87 | 3.94% | 1 | 1.16% |
Ladislav Michl | 83 | 3.76% | 2 | 2.33% |
David Kubicek | 70 | 3.17% | 1 | 1.16% |
Greg Kroah-Hartman | 62 | 2.81% | 7 | 8.14% |
Colin Leroy | 57 | 2.58% | 2 | 2.33% |
David Brownell | 47 | 2.13% | 6 | 6.98% |
Arseniy Lartsev | 33 | 1.49% | 1 | 1.16% |
Alan Cox | 32 | 1.45% | 2 | 2.33% |
Håvard Skinnemoen | 25 | 1.13% | 1 | 1.16% |
Julia Lawall | 23 | 1.04% | 1 | 1.16% |
Alexey Sokolov | 22 | 1.00% | 1 | 1.16% |
Erik Slagter | 20 | 0.90% | 1 | 1.16% |
Axel Lin | 14 | 0.63% | 1 | 1.16% |
Lu Baolu | 14 | 0.63% | 1 | 1.16% |
Alan Stern | 12 | 0.54% | 2 | 2.33% |
Dmitry Torokhov | 10 | 0.45% | 1 | 1.16% |
Sven Schnelle | 10 | 0.45% | 1 | 1.16% |
Joe Perches | 9 | 0.41% | 2 | 2.33% |
Fabian Frederick | 8 | 0.36% | 1 | 1.16% |
Ingo Molnar | 6 | 0.27% | 1 | 1.16% |
Jiri Slaby | 6 | 0.27% | 1 | 1.16% |
Toby Gray | 6 | 0.27% | 1 | 1.16% |
Brian Murphy | 6 | 0.27% | 1 | 1.16% |
Luiz Fernando N. Capitulino | 4 | 0.18% | 1 | 1.16% |
Kuninori Morimoto | 3 | 0.14% | 1 | 1.16% |
Quentin Casasnovas | 3 | 0.14% | 1 | 1.16% |
Daniel Mack | 2 | 0.09% | 1 | 1.16% |
Catalin(ux aka Dino) M. Boie | 1 | 0.05% | 1 | 1.16% |
Felipe Balbi | 1 | 0.05% | 1 | 1.16% |
Total | 2210 | 100.00% | 86 | 100.00% |
static void acm_disconnect(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
struct tty_struct *tty;
/* sibling interface is already cleaning up */
if (!acm)
return;
mutex_lock(&acm->mutex);
acm->disconnected = true;
if (acm->country_codes) {
device_remove_file(&acm->control->dev,
&dev_attr_wCountryCodes);
device_remove_file(&acm->control->dev,
&dev_attr_iCountryCodeRelDate);
}
wake_up_all(&acm->wioctl);
device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
usb_set_intfdata(acm->control, NULL);
usb_set_intfdata(acm->data, NULL);
mutex_unlock(&acm->mutex);
tty = tty_port_tty_get(&acm->port);
if (tty) {
tty_vhangup(tty);
tty_kref_put(tty);
}
acm_kill_urbs(acm);
cancel_work_sync(&acm->work);
tty_unregister_device(acm_tty_driver, acm->minor);
acm_write_buffers_free(acm);
usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
acm_read_buffers_free(acm);
if (!acm->combined_interfaces)
usb_driver_release_interface(&acm_driver, intf == acm->control ?
acm->data : acm->control);
tty_port_put(&acm->port);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 103 | 42.92% | 7 | 30.43% |
Håvard Skinnemoen | 54 | 22.50% | 1 | 4.35% |
Linus Torvalds (pre-git) | 33 | 13.75% | 5 | 21.74% |
Greg Kroah-Hartman | 12 | 5.00% | 2 | 8.70% |
Ladislav Michl | 11 | 4.58% | 2 | 8.70% |
Alan Cox | 10 | 4.17% | 1 | 4.35% |
Alan Stern | 9 | 3.75% | 1 | 4.35% |
David Brownell | 4 | 1.67% | 2 | 8.70% |
David Kubicek | 3 | 1.25% | 1 | 4.35% |
Daniel Mack | 1 | 0.42% | 1 | 4.35% |
Total | 240 | 100.00% | 23 | 100.00% |
#ifdef CONFIG_PM
static int acm_suspend(struct usb_interface *intf, pm_message_t message)
{
struct acm *acm = usb_get_intfdata(intf);
int cnt;
spin_lock_irq(&acm->write_lock);
if (PMSG_IS_AUTO(message)) {
if (acm->transmitting) {
spin_unlock_irq(&acm->write_lock);
return -EBUSY;
}
}
cnt = acm->susp_count++;
spin_unlock_irq(&acm->write_lock);
if (cnt)
return 0;
acm_kill_urbs(acm);
cancel_work_sync(&acm->work);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 71 | 69.61% | 2 | 33.33% |
Johan Hovold | 22 | 21.57% | 3 | 50.00% |
Ladislav Michl | 9 | 8.82% | 1 | 16.67% |
Total | 102 | 100.00% | 6 | 100.00% |
static int acm_resume(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
struct urb *urb;
int rv = 0;
spin_lock_irq(&acm->write_lock);
if (--acm->susp_count)
goto out;
if (tty_port_initialized(&acm->port)) {
rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC);
for (;;) {
urb = usb_get_from_anchor(&acm->delayed);
if (!urb)
break;
acm_start_wb(acm, urb->context);
}
/*
* delayed error checking because we must
* do the write path at all cost
*/
if (rv < 0)
goto out;
rv = acm_submit_read_urbs(acm, GFP_ATOMIC);
}
out:
spin_unlock_irq(&acm->write_lock);
return rv;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 85 | 62.50% | 3 | 30.00% |
Johan Hovold | 46 | 33.82% | 4 | 40.00% |
Håvard Skinnemoen | 3 | 2.21% | 1 | 10.00% |
Peter Hurley | 1 | 0.74% | 1 | 10.00% |
Alan Cox | 1 | 0.74% | 1 | 10.00% |
Total | 136 | 100.00% | 10 | 100.00% |
static int acm_reset_resume(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
if (tty_port_initialized(&acm->port))
tty_port_tty_hangup(&acm->port, false);
return acm_resume(intf);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Francesco Lavra | 40 | 85.11% | 1 | 25.00% |
Jiri Slaby | 3 | 6.38% | 1 | 25.00% |
Håvard Skinnemoen | 3 | 6.38% | 1 | 25.00% |
Peter Hurley | 1 | 2.13% | 1 | 25.00% |
Total | 47 | 100.00% | 4 | 100.00% |
#endif /* CONFIG_PM */
static int acm_pre_reset(struct usb_interface *intf)
{
struct acm *acm = usb_get_intfdata(intf);
clear_bit(EVENT_RX_STALL, &acm->flags);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ladislav Michl | 34 | 100.00% | 1 | 100.00% |
Total | 34 | 100.00% | 1 | 100.00% |
#define NOKIA_PCSUITE_ACM_INFO(x) \
USB_DEVICE_AND_INTERFACE_INFO(0x0421, x, \
USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
USB_CDC_ACM_PROTO_VENDOR)
#define SAMSUNG_PCSUITE_ACM_INFO(x) \
USB_DEVICE_AND_INTERFACE_INFO(0x04e7, x, \
USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, \
USB_CDC_ACM_PROTO_VENDOR)
/*
* USB driver structure.
*/
static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
{ USB_DEVICE(0x076d, 0x0006), /* Denso Cradle CU-321 */
.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0ace, 0x1602), /* ZyDAS 56K USB MODEM */
.driver_info = SINGLE_RX_URB,
},
{ USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
.driver_info = SINGLE_RX_URB, /* firmware bug */
},
{ USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */
.driver_info = SINGLE_RX_URB, /* firmware bug */
},
{ USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0572, 0x1321), /* Conexant USB MODEM CX93010 */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0572, 0x1324), /* Conexant USB MODEM RD02-D400 */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
{ USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */
.driver_info = QUIRK_CONTROL_LINE_STATE, },
{ USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */
{ USB_DEVICE(0x2184, 0x0036) }, /* GW Instek AFG-125 */
{ USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
},
/* Motorola H24 HSPA module: */
{ USB_DEVICE(0x22b8, 0x2d91) }, /* modem */
{ USB_DEVICE(0x22b8, 0x2d92), /* modem + diagnostics */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d93), /* modem + AT port */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d95), /* modem + AT port + diagnostics */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d96), /* modem + NMEA */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d97), /* modem + diagnostics + NMEA */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d99), /* modem + AT port + NMEA */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x22b8, 0x2d9a), /* modem + AT port + diagnostics + NMEA */
.driver_info = NO_UNION_NORMAL, /* handle only modem interface */
},
{ USB_DEVICE(0x0572, 0x1329), /* Hummingbird huc56s (Conexant) */
.driver_info = NO_UNION_NORMAL, /* union descriptor misplaced on
data interface instead of
communications interface.
Maybe we should define a new
quirk for this. */
},
{ USB_DEVICE(0x0572, 0x1340), /* Conexant CX93010-2x UCMxx */
.driver_info = NO_UNION_NORMAL,
},
{ USB_DEVICE(0x05f9, 0x4002), /* PSC Scanning, Magellan 800i */
.driver_info = NO_UNION_NORMAL,
},
{ USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */
.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
},
{ USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
.driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
},
{ USB_DEVICE(0x2912, 0x0001), /* ATOL FPrint */
.driver_info = CLEAR_HALT_CONDITIONS,
},
/* Nokia S60 phones expose two ACM channels. The first is
* a modem and is picked up by the standard AT-command
* information below. The second is 'vendor-specific' but
* is treated as a serial device at the S60 end, so we want
* to expose it on Linux too. */
{ NOKIA_PCSUITE_ACM_INFO(0x042D), }, /* Nokia 3250 */
{ NOKIA_PCSUITE_ACM_INFO(0x04D8), }, /* Nokia 5500 Sport */
{ NOKIA_PCSUITE_ACM_INFO(0x04C9), }, /* Nokia E50 */
{ NOKIA_PCSUITE_ACM_INFO(0x0419), }, /* Nokia E60 */
{ NOKIA_PCSUITE_ACM_INFO(0x044D), }, /* Nokia E61 */
{ NOKIA_PCSUITE_ACM_INFO(0x0001), }, /* Nokia E61i */
{ NOKIA_PCSUITE_ACM_INFO(0x0475), }, /* Nokia E62 */
{ NOKIA_PCSUITE_ACM_INFO(0x0508), }, /* Nokia E65 */
{ NOKIA_PCSUITE_ACM_INFO(0x0418), }, /* Nokia E70 */
{ NOKIA_PCSUITE_ACM_INFO(0x0425), }, /* Nokia N71 */
{ NOKIA_PCSUITE_ACM_INFO(0x0486), }, /* Nokia N73 */
{ NOKIA_PCSUITE_ACM_INFO(0x04DF), }, /* Nokia N75 */
{ NOKIA_PCSUITE_ACM_INFO(0x000e), }, /* Nokia N77 */
{ NOKIA_PCSUITE_ACM_INFO(0x0445), }, /* Nokia N80 */
{ NOKIA_PCSUITE_ACM_INFO(0x042F), }, /* Nokia N91 & N91 8GB */
{ NOKIA_PCSUITE_ACM_INFO(0x048E), }, /* Nokia N92 */
{ NOKIA_PCSUITE_ACM_INFO(0x0420), }, /* Nokia N93 */
{ NOKIA_PCSUITE_ACM_INFO(0x04E6), }, /* Nokia N93i */
{ NOKIA_PCSUITE_ACM_INFO(0x04B2), }, /* Nokia 5700 XpressMusic */
{ NOKIA_PCSUITE_ACM_INFO(0x0134), }, /* Nokia 6110 Navigator (China) */
{ NOKIA_PCSUITE_ACM_INFO(0x046E), }, /* Nokia 6110 Navigator */
{ NOKIA_PCSUITE_ACM_INFO(0x002f), }, /* Nokia 6120 classic & */
{ NOKIA_PCSUITE_ACM_INFO(0x0088), }, /* Nokia 6121 classic */
{ NOKIA_PCSUITE_ACM_INFO(0x00fc), }, /* Nokia 6124 classic */
{ NOKIA_PCSUITE_ACM_INFO(0x0042), }, /* Nokia E51 */
{ NOKIA_PCSUITE_ACM_INFO(0x00b0), }, /* Nokia E66 */
{ NOKIA_PCSUITE_ACM_INFO(0x00ab), }, /* Nokia E71 */
{ NOKIA_PCSUITE_ACM_INFO(0x0481), }, /* Nokia N76 */
{ NOKIA_PCSUITE_ACM_INFO(0x0007), }, /* Nokia N81 & N81 8GB */
{ NOKIA_PCSUITE_ACM_INFO(0x0071), }, /* Nokia N82 */
{ NOKIA_PCSUITE_ACM_INFO(0x04F0), }, /* Nokia N95 & N95-3 NAM */
{ NOKIA_PCSUITE_ACM_INFO(0x0070), }, /* Nokia N95 8GB */
{ NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */
{ NOKIA_PCSUITE_ACM_INFO(0x0099), }, /* Nokia 6210 Navigator, RM-367 */
{ NOKIA_PCSUITE_ACM_INFO(0x0128), }, /* Nokia 6210 Navigator, RM-419 */
{ NOKIA_PCSUITE_ACM_INFO(0x008f), }, /* Nokia 6220 Classic */
{ NOKIA_PCSUITE_ACM_INFO(0x00a0), }, /* Nokia 6650 */
{ NOKIA_PCSUITE_ACM_INFO(0x007b), }, /* Nokia N78 */
{ NOKIA_PCSUITE_ACM_INFO(0x0094), }, /* Nokia N85 */
{ NOKIA_PCSUITE_ACM_INFO(0x003a), }, /* Nokia N96 & N96-3 */
{ NOKIA_PCSUITE_ACM_INFO(0x00e9), }, /* Nokia 5320 XpressMusic */
{ NOKIA_PCSUITE_ACM_INFO(0x0108), }, /* Nokia 5320 XpressMusic 2G */
{ NOKIA_PCSUITE_ACM_INFO(0x01f5), }, /* Nokia N97, RM-505 */
{ NOKIA_PCSUITE_ACM_INFO(0x02e3), }, /* Nokia 5230, RM-588 */
{ NOKIA_PCSUITE_ACM_INFO(0x0178), }, /* Nokia E63 */
{ NOKIA_PCSUITE_ACM_INFO(0x010e), }, /* Nokia E75 */
{ NOKIA_PCSUITE_ACM_INFO(0x02d9), }, /* Nokia 6760 Slide */
{ NOKIA_PCSUITE_ACM_INFO(0x01d0), }, /* Nokia E52 */
{ NOKIA_PCSUITE_ACM_INFO(0x0223), }, /* Nokia E72 */
{ NOKIA_PCSUITE_ACM_INFO(0x0275), }, /* Nokia X6 */
{ NOKIA_PCSUITE_ACM_INFO(0x026c), }, /* Nokia N97 Mini */
{ NOKIA_PCSUITE_ACM_INFO(0x0154), }, /* Nokia 5800 XpressMusic */
{ NOKIA_PCSUITE_ACM_INFO(0x04ce), }, /* Nokia E90 */
{ NOKIA_PCSUITE_ACM_INFO(0x01d4), }, /* Nokia E55 */
{ NOKIA_PCSUITE_ACM_INFO(0x0302), }, /* Nokia N8 */
{ NOKIA_PCSUITE_ACM_INFO(0x0335), }, /* Nokia E7 */
{ NOKIA_PCSUITE_ACM_INFO(0x03cd), }, /* Nokia C7 */
{ SAMSUNG_PCSUITE_ACM_INFO(0x6651), }, /* Samsung GTi8510 (INNOV8) */
/* Support for Owen devices */
{ USB_DEVICE(0x03eb, 0x0030), }, /* Owen SI30 */
/* NOTE: non-Nokia COMM/ACM/0xff is likely MSFT RNDIS... NOT a modem! */
/* Support for Droids MuIn LCD */
{ USB_DEVICE(0x04d8, 0x000b),
.driver_info = NO_DATA_INTERFACE,
},
#if IS_ENABLED(CONFIG_INPUT_IMS_PCU)
{ USB_DEVICE(0x04d8, 0x0082), /* Application mode */
.driver_info = IGNORE_DEVICE,
},
{ USB_DEVICE(0x04d8, 0x0083), /* Bootloader mode */
.driver_info = IGNORE_DEVICE,
},
#endif
/*Samsung phone in firmware update mode */
{ USB_DEVICE(0x04e8, 0x685d),
.driver_info = IGNORE_DEVICE,
},
/* Exclude Infineon Flash Loader utility */
{ USB_DEVICE(0x058b, 0x0041),
.driver_info = IGNORE_DEVICE,
},
/* control interfaces without any protocol set */
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_PROTO_NONE) },
/* control interfaces with various AT-command sets */
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_V25TER) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_PCCA101) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_PCCA101_WAKE) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_GSM) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_3G) },
{ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
USB_CDC_ACM_PROTO_AT_CDMA) },
{ USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */
.driver_info = SEND_ZERO_PACKET,
},
{ }
};
MODULE_DEVICE_TABLE(usb, acm_ids);
static struct usb_driver acm_driver = {
.name = "cdc_acm",
.probe = acm_probe,
.disconnect = acm_disconnect,
#ifdef CONFIG_PM
.suspend = acm_suspend,
.resume = acm_resume,
.reset_resume = acm_reset_resume,
#endif
.pre_reset = acm_pre_reset,
.id_table = acm_ids,
#ifdef CONFIG_PM
.supports_autosuspend = 1,
#endif
.disable_hub_initiated_lpm = 1,
};
/*
* TTY driver structures.
*/
static const struct tty_operations acm_ops = {
.install = acm_tty_install,
.open = acm_tty_open,
.close = acm_tty_close,
.cleanup = acm_tty_cleanup,
.hangup = acm_tty_hangup,
.write = acm_tty_write,
.put_char = acm_tty_put_char,
.flush_chars = acm_tty_flush_chars,
.write_room = acm_tty_write_room,
.ioctl = acm_tty_ioctl,
.throttle = acm_tty_throttle,
.unthrottle = acm_tty_unthrottle,
.chars_in_buffer = acm_tty_chars_in_buffer,
.break_ctl = acm_tty_break_ctl,
.set_termios = acm_tty_set_termios,
.tiocmget = acm_tty_tiocmget,
.tiocmset = acm_tty_tiocmset,
.get_icount = acm_tty_get_icount,
};
/*
* Init / exit.
*/
static int __init acm_init(void)
{
int retval;
acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
if (!acm_tty_driver)
return -ENOMEM;
acm_tty_driver->driver_name = "acm",
acm_tty_driver->name = "ttyACM",
acm_tty_driver->major = ACM_TTY_MAJOR,
acm_tty_driver->minor_start = 0,
acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL,
acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
acm_tty_driver->init_termios = tty_std_termios;
acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD |
HUPCL | CLOCAL;
tty_set_operations(acm_tty_driver, &acm_ops);
retval = tty_register_driver(acm_tty_driver);
if (retval) {
put_tty_driver(acm_tty_driver);
return retval;
}
retval = usb_register(&acm_driver);
if (retval) {
tty_unregister_driver(acm_tty_driver);
put_tty_driver(acm_tty_driver);
return retval;
}
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 76 | 47.20% | 1 | 7.69% |
Linus Torvalds (pre-git) | 54 | 33.54% | 7 | 53.85% |
Daniele Bellucci | 17 | 10.56% | 1 | 7.69% |
Greg Kroah-Hartman | 12 | 7.45% | 3 | 23.08% |
Linus Torvalds | 2 | 1.24% | 1 | 7.69% |
Total | 161 | 100.00% | 13 | 100.00% |
static void __exit acm_exit(void)
{
usb_deregister(&acm_driver);
tty_unregister_driver(acm_tty_driver);
put_tty_driver(acm_tty_driver);
idr_destroy(&acm_minors);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 20 | 64.52% | 1 | 33.33% |
Johannes Thumshirn | 6 | 19.35% | 1 | 33.33% |
Al Viro | 5 | 16.13% | 1 | 33.33% |
Total | 31 | 100.00% | 3 | 100.00% |
module_init(acm_init);
module_exit(acm_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
MODULE_ALIAS_CHARDEV_MAJOR(ACM_TTY_MAJOR);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Oliver Neukum | 3417 | 35.24% | 45 | 19.15% |
Linus Torvalds (pre-git) | 1291 | 13.32% | 30 | 12.77% |
Johan Hovold | 1075 | 11.09% | 26 | 11.06% |
Håvard Skinnemoen | 468 | 4.83% | 2 | 0.85% |
Ladislav Michl | 422 | 4.35% | 5 | 2.13% |
Adrian Taylor | 354 | 3.65% | 1 | 0.43% |
Greg Kroah-Hartman | 317 | 3.27% | 16 | 6.81% |
David Brownell | 247 | 2.55% | 9 | 3.83% |
Dan J Williams | 213 | 2.20% | 1 | 0.43% |
Alan Cox | 183 | 1.89% | 10 | 4.26% |
David Kubicek | 132 | 1.36% | 1 | 0.43% |
Toby Gray | 118 | 1.22% | 3 | 1.28% |
David Engraf | 108 | 1.11% | 2 | 0.85% |
Alexey Khoroshilov | 89 | 0.92% | 1 | 0.43% |
Al Viro | 85 | 0.88% | 2 | 0.85% |
Krzysztof Hałasa | 74 | 0.76% | 1 | 0.43% |
Linus Torvalds | 59 | 0.61% | 6 | 2.55% |
Colin Leroy | 57 | 0.59% | 2 | 0.85% |
Michael Ulbricht | 56 | 0.58% | 1 | 0.43% |
Francesco Lavra | 54 | 0.56% | 2 | 0.85% |
Dmitry Torokhov | 48 | 0.50% | 1 | 0.43% |
Nicolas Boullis | 45 | 0.46% | 1 | 0.43% |
Arseniy Lartsev | 37 | 0.38% | 1 | 0.43% |
Alexey Sokolov | 37 | 0.38% | 1 | 0.43% |
Erik Slagter | 35 | 0.36% | 1 | 0.43% |
Brian Murphy | 32 | 0.33% | 1 | 0.43% |
Lu Baolu | 30 | 0.31% | 2 | 0.85% |
Otto Meta | 29 | 0.30% | 1 | 0.43% |
Jiri Slaby | 28 | 0.29% | 6 | 2.55% |
Rusty Russell | 28 | 0.29% | 1 | 0.43% |
Brandon Philips | 25 | 0.26% | 1 | 0.43% |
Julia Lawall | 23 | 0.24% | 1 | 0.43% |
Jim Paris | 22 | 0.23% | 1 | 0.43% |
Alan Stern | 21 | 0.22% | 2 | 0.85% |
Eric Sandeen | 17 | 0.18% | 1 | 0.43% |
Daniele Bellucci | 17 | 0.18% | 1 | 0.43% |
Masahito Omote | 17 | 0.18% | 1 | 0.43% |
Iain McFarlane | 17 | 0.18% | 1 | 0.43% |
Adam J. Richter | 17 | 0.18% | 1 | 0.43% |
Chris Malley | 17 | 0.18% | 1 | 0.43% |
Russ Nelson | 17 | 0.18% | 1 | 0.43% |
Andrey Arapov | 17 | 0.18% | 1 | 0.43% |
Xiao Kaijian | 17 | 0.18% | 1 | 0.43% |
Andrew Lunn | 17 | 0.18% | 1 | 0.43% |
Kir Kolyshkin | 17 | 0.18% | 1 | 0.43% |
David Cluytens | 16 | 0.17% | 1 | 0.43% |
Björn Gerhart | 16 | 0.17% | 1 | 0.43% |
Jean-Christian de Rivaz | 15 | 0.15% | 1 | 0.43% |
Denis N Ladin | 15 | 0.15% | 1 | 0.43% |
Jonas Jonsson | 15 | 0.15% | 1 | 0.43% |
Axel Lin | 14 | 0.14% | 1 | 0.43% |
Philippe Corbes | 12 | 0.12% | 1 | 0.43% |
Denis Pershin | 11 | 0.11% | 1 | 0.43% |
Dmitriy Taychenachev | 11 | 0.11% | 1 | 0.43% |
Nathaniel Quillin | 10 | 0.10% | 1 | 0.43% |
Sven Schnelle | 10 | 0.10% | 1 | 0.43% |
Ingo Molnar | 9 | 0.09% | 2 | 0.85% |
Joe Perches | 9 | 0.09% | 2 | 0.85% |
Arvid Ephraim Picciani | 8 | 0.08% | 1 | 0.43% |
Vojtech Pavlik | 8 | 0.08% | 1 | 0.43% |
Przemo Firszt | 8 | 0.08% | 1 | 0.43% |
Fabian Frederick | 8 | 0.08% | 1 | 0.43% |
Daniel Mack | 7 | 0.07% | 1 | 0.43% |
Johannes Thumshirn | 6 | 0.06% | 1 | 0.43% |
Sarah Sharp | 5 | 0.05% | 1 | 0.43% |
Scott James Remnant | 5 | 0.05% | 1 | 0.43% |
Luiz Fernando N. Capitulino | 4 | 0.04% | 1 | 0.43% |
Arjan van de Ven | 4 | 0.04% | 1 | 0.43% |
Harvey Harrison | 4 | 0.04% | 2 | 0.85% |
Kuninori Morimoto | 3 | 0.03% | 1 | 0.43% |
Dave Jones | 3 | 0.03% | 1 | 0.43% |
Quentin Casasnovas | 3 | 0.03% | 1 | 0.43% |
Jarek Poplawski | 3 | 0.03% | 1 | 0.43% |
Peter Hurley | 2 | 0.02% | 1 | 0.43% |
Catalin(ux aka Dino) M. Boie | 1 | 0.01% | 1 | 0.43% |
Nishanth Aravamudan | 1 | 0.01% | 1 | 0.43% |
Jeff Dike | 1 | 0.01% | 1 | 0.43% |
Felipe Balbi | 1 | 0.01% | 1 | 0.43% |
Márton Németh | 1 | 0.01% | 1 | 0.43% |
Total | 9695 | 100.00% | 235 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.