Release 4.7 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/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 | 
| haavard skinnemoen | haavard skinnemoen | 78 | 82.11% | 1 | 25.00% | 
| johan hovold | johan hovold | 12 | 12.63% | 1 | 25.00% | 
| alan cox | alan cox | 3 | 3.16% | 1 | 25.00% | 
| pre-git | 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 | 
| haavard skinnemoen | haavard skinnemoen | 29 | 64.44% | 1 | 33.33% | 
| johan hovold | johan hovold | 13 | 28.89% | 1 | 33.33% | 
| alan cox | 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 | 
| haavard skinnemoen | haavard skinnemoen | 25 | 75.76% | 1 | 50.00% | 
| johan hovold | 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 | 
| pre-git | pre-git | 81 | 65.32% | 8 | 61.54% | 
| johan hovold | johan hovold | 38 | 30.65% | 2 | 15.38% | 
| david brownell | david brownell | 4 | 3.23% | 2 | 15.38% | 
| nishanth aravamudan | 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 | johan hovold | 35 | 85.37% | 1 | 50.00% | 
| pre-git | 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)
/*
 * 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 | oliver neukum | 84 | 98.82% | 2 | 66.67% | 
| david engraf | 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 | oliver neukum | 47 | 66.20% | 2 | 66.67% | 
| david brownell | 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 | oliver neukum | 26 | 76.47% | 3 | 75.00% | 
| david engraf | 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 | oliver neukum | 94 | 86.24% | 1 | 33.33% | 
| johan hovold | johan hovold | 11 | 10.09% | 1 | 33.33% | 
| alan cox | 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 | 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 | 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 | 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 | oliver neukum | 125 | 28.94% | 3 | 12.00% | 
| pre-git | pre-git | 124 | 28.70% | 8 | 32.00% | 
| greg kroah-hartman | greg kroah-hartman | 70 | 16.20% | 3 | 12.00% | 
| johan hovold | johan hovold | 65 | 15.05% | 3 | 12.00% | 
| linus torvalds | linus torvalds | 28 | 6.48% | 2 | 8.00% | 
| david brownell | david brownell | 8 | 1.85% | 2 | 8.00% | 
| jiri slaby | jiri slaby | 7 | 1.62% | 1 | 4.00% | 
| harvey harrison | harvey harrison | 4 | 0.93% | 2 | 8.00% | 
| alan cox | 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;
	dev_vdbg(&acm->data->dev, "%s - urb %d\n", __func__, index);
	res = usb_submit_urb(acm->read_urbs[index], mem_flags);
	if (res) {
		if (res != -EPERM) {
			dev_err(&acm->data->dev,
					"%s - usb_submit_urb failed: %d\n",
					__func__, res);
		}
		set_bit(index, &acm->read_urbs_free);
		return res;
	}
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| johan hovold | johan hovold | 62 | 54.87% | 2 | 25.00% | 
| david brownell | david brownell | 19 | 16.81% | 1 | 12.50% | 
| oliver neukum | oliver neukum | 17 | 15.04% | 2 | 25.00% | 
| david kubicek | david kubicek | 12 | 10.62% | 1 | 12.50% | 
| pre-git | pre-git | 3 | 2.65% | 2 | 25.00% | 
 | Total | 113 | 100.00% | 8 | 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 | johan hovold | 44 | 75.86% | 1 | 20.00% | 
| oliver neukum | oliver neukum | 11 | 18.97% | 2 | 40.00% | 
| david kubicek | david kubicek | 2 | 3.45% | 1 | 20.00% | 
| david brownell | 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 | johan hovold | 12 | 25.00% | 1 | 10.00% | 
| pre-git | pre-git | 11 | 22.92% | 3 | 30.00% | 
| david brownell | david brownell | 9 | 18.75% | 1 | 10.00% | 
| jiri slaby | jiri slaby | 8 | 16.67% | 2 | 20.00% | 
| oliver neukum | oliver neukum | 4 | 8.33% | 1 | 10.00% | 
| david kubicek | david kubicek | 2 | 4.17% | 1 | 10.00% | 
| alan cox | 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, "%s - urb %d, len %d\n", __func__,
					rb->index, urb->actual_length);
	if (!acm->dev) {
		set_bit(rb->index, &acm->read_urbs_free);
		dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__);
		return;
	}
	if (status) {
		set_bit(rb->index, &acm->read_urbs_free);
		dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n",
							__func__, status);
		if ((status != -ENOENT) || (urb->actual_length == 0))
			return;
	}
	usb_mark_last_busy(acm->dev);
	acm_process_read_urb(acm, urb);
	/*
         * Unthrottle may run on another CPU which needs to see events
         * in the same order. Submission has an implict barrier
         */
	smp_mb__before_atomic();
	set_bit(rb->index, &acm->read_urbs_free);
	/* 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 | johan hovold | 108 | 44.63% | 3 | 30.00% | 
| oliver neukum | oliver neukum | 63 | 26.03% | 3 | 30.00% | 
| david kubicek | david kubicek | 46 | 19.01% | 1 | 10.00% | 
| lu baolu | lu baolu | 17 | 7.02% | 1 | 10.00% | 
| jarek poplawski | jarek poplawski | 4 | 1.65% | 1 | 10.00% | 
| arseniy lartsev | arseniy lartsev | 4 | 1.65% | 1 | 10.00% | 
 | Total | 242 | 100.00% | 10 | 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, "%s - len %d/%d, status %d\n",
			__func__,
			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);
	schedule_work(&acm->work);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| david brownell | david brownell | 38 | 33.63% | 1 | 8.33% | 
| oliver neukum | oliver neukum | 25 | 22.12% | 4 | 33.33% | 
| brandon philips | brandon philips | 24 | 21.24% | 1 | 8.33% | 
| pre-git | pre-git | 16 | 14.16% | 3 | 25.00% | 
| david engraf | david engraf | 6 | 5.31% | 1 | 8.33% | 
| johan hovold | johan hovold | 4 | 3.54% | 2 | 16.67% | 
 | Total | 113 | 100.00% | 12 | 100.00% | 
static void acm_softint(struct work_struct *work)
{
	struct acm *acm = container_of(work, struct acm, work);
	dev_vdbg(&acm->data->dev, "%s\n", __func__);
	tty_port_tty_wakeup(&acm->port);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 28 | 58.33% | 1 | 16.67% | 
| david brownell | david brownell | 8 | 16.67% | 1 | 16.67% | 
| alan cox | alan cox | 4 | 8.33% | 1 | 16.67% | 
| pre-git | pre-git | 4 | 8.33% | 1 | 16.67% | 
| johan hovold | johan hovold | 3 | 6.25% | 1 | 16.67% | 
| jiri slaby | jiri slaby | 1 | 2.08% | 1 | 16.67% | 
 | Total | 48 | 100.00% | 6 | 100.00% | 
/*
 * TTY handlers
 */
static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
{
	struct acm *acm;
	int retval;
	dev_dbg(tty->dev, "%s\n", __func__);
	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 | 
| haavard skinnemoen | haavard skinnemoen | 43 | 47.25% | 1 | 9.09% | 
| pre-git | pre-git | 22 | 24.18% | 3 | 27.27% | 
| oliver neukum | oliver neukum | 14 | 15.38% | 2 | 18.18% | 
| david engraf | david engraf | 5 | 5.49% | 1 | 9.09% | 
| johan hovold | johan hovold | 3 | 3.30% | 2 | 18.18% | 
| jiri slaby | jiri slaby | 3 | 3.30% | 1 | 9.09% | 
| al viro | al viro | 1 | 1.10% | 1 | 9.09% | 
 | Total | 91 | 100.00% | 11 | 100.00% | 
static int acm_tty_open(struct tty_struct *tty, struct file *filp)
{
	struct acm *acm = tty->driver_data;
	dev_dbg(tty->dev, "%s\n", __func__);
	return tty_port_open(&acm->port, tty, filp);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| haavard skinnemoen | haavard skinnemoen | 37 | 75.51% | 1 | 25.00% | 
| pre-git | pre-git | 7 | 14.29% | 2 | 50.00% | 
| alan cox | alan cox | 5 | 10.20% | 1 | 25.00% | 
 | Total | 49 | 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 | 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;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	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 | 
| haavard skinnemoen | haavard skinnemoen | 89 | 31.67% | 1 | 4.55% | 
| johan hovold | johan hovold | 76 | 27.05% | 5 | 22.73% | 
| oliver neukum | oliver neukum | 50 | 17.79% | 7 | 31.82% | 
| otto meta | otto meta | 29 | 10.32% | 1 | 4.55% | 
| pre-git | pre-git | 23 | 8.19% | 4 | 18.18% | 
| jim paris | jim paris | 7 | 2.49% | 1 | 4.55% | 
| alan cox | alan cox | 4 | 1.42% | 1 | 4.55% | 
| greg kroah-hartman | greg kroah-hartman | 3 | 1.07% | 2 | 9.09% | 
 | Total | 281 | 100.00% | 22 | 100.00% | 
static void acm_port_destruct(struct tty_port *port)
{
	struct acm *acm = container_of(port, struct acm, port);
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	acm_release_minor(acm);
	usb_put_intf(acm->control);
	kfree(acm->country_codes);
	kfree(acm);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| brian murphy | brian murphy | 32 | 50.00% | 1 | 33.33% | 
| haavard skinnemoen | haavard skinnemoen | 25 | 39.06% | 1 | 33.33% | 
| oliver neukum | oliver neukum | 7 | 10.94% | 1 | 33.33% | 
 | Total | 64 | 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;
	int i;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	/*
         * 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);
	}
	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 | 
| johan hovold | johan hovold | 84 | 43.98% | 5 | 31.25% | 
| haavard skinnemoen | haavard skinnemoen | 32 | 16.75% | 1 | 6.25% | 
| pre-git | pre-git | 30 | 15.71% | 5 | 31.25% | 
| david engraf | david engraf | 19 | 9.95% | 1 | 6.25% | 
| david kubicek | david kubicek | 17 | 8.90% | 1 | 6.25% | 
| oliver neukum | oliver neukum | 5 | 2.62% | 1 | 6.25% | 
| borislav petkov | borislav petkov | 3 | 1.57% | 1 | 6.25% | 
| alan cox | alan cox | 1 | 0.52% | 1 | 6.25% | 
 | Total | 191 | 100.00% | 16 | 100.00% | 
static void acm_tty_cleanup(struct tty_struct *tty)
{
	struct acm *acm = tty->driver_data;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	tty_port_put(&acm->port);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| alan cox | alan cox | 24 | 57.14% | 1 | 20.00% | 
| haavard skinnemoen | haavard skinnemoen | 16 | 38.10% | 2 | 40.00% | 
| pre-git | pre-git | 2 | 4.76% | 2 | 40.00% | 
 | Total | 42 | 100.00% | 5 | 100.00% | 
static void acm_tty_hangup(struct tty_struct *tty)
{
	struct acm *acm = tty->driver_data;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	tty_port_hangup(&acm->port);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| alan cox | alan cox | 32 | 76.19% | 1 | 33.33% | 
| haavard skinnemoen | haavard skinnemoen | 6 | 14.29% | 1 | 33.33% | 
| francesco lavra | francesco lavra | 4 | 9.52% | 1 | 33.33% | 
 | Total | 42 | 100.00% | 3 | 100.00% | 
static void acm_tty_close(struct tty_struct *tty, struct file *filp)
{
	struct acm *acm = tty->driver_data;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	tty_port_close(&acm->port, tty, filp);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| haavard skinnemoen | haavard skinnemoen | 33 | 64.71% | 2 | 33.33% | 
| francesco lavra | francesco lavra | 11 | 21.57% | 1 | 16.67% | 
| alan cox | alan cox | 4 | 7.84% | 1 | 16.67% | 
| oliver neukum | oliver neukum | 2 | 3.92% | 1 | 16.67% | 
| pre-git | pre-git | 1 | 1.96% | 1 | 16.67% | 
 | Total | 51 | 100.00% | 6 | 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, "%s - count %d\n", __func__, 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, "%s - write %d\n", __func__, 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 | oliver neukum | 126 | 36.21% | 3 | 15.79% | 
| pre-git | pre-git | 76 | 21.84% | 6 | 31.58% | 
| greg kroah-hartman | greg kroah-hartman | 66 | 18.97% | 3 | 15.79% | 
| johan hovold | johan hovold | 61 | 17.53% | 4 | 21.05% | 
| david brownell | david brownell | 10 | 2.87% | 1 | 5.26% | 
| alan cox | alan cox | 8 | 2.30% | 1 | 5.26% | 
| david engraf | david engraf | 1 | 0.29% | 1 | 5.26% | 
 | Total | 348 | 100.00% | 19 | 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 | 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 | 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 | 
| pre-git | pre-git | 26 | 78.79% | 4 | 80.00% | 
| oliver neukum | 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 | 
| pre-git | pre-git | 31 | 68.89% | 3 | 42.86% | 
| oliver neukum | oliver neukum | 10 | 22.22% | 2 | 28.57% | 
| haavard skinnemoen | haavard skinnemoen | 3 | 6.67% | 1 | 14.29% | 
| alan cox | 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 | 
| pre-git | pre-git | 25 | 59.52% | 6 | 75.00% | 
| oliver neukum | oliver neukum | 12 | 28.57% | 1 | 12.50% | 
| johan hovold | 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 | 
| pre-git | pre-git | 29 | 42.03% | 2 | 50.00% | 
| johan hovold | johan hovold | 28 | 40.58% | 1 | 25.00% | 
| oliver neukum | 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 | 
| pre-git | pre-git | 36 | 58.06% | 3 | 60.00% | 
| alan cox | alan cox | 15 | 24.19% | 1 | 20.00% | 
| johan hovold | 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 | 
| pre-git | pre-git | 81 | 97.59% | 1 | 50.00% | 
| greg kroah-hartman | 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 | greg kroah-hartman | 61 | 52.59% | 1 | 16.67% | 
| pre-git | 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;
	if (!info)
		return -EINVAL;
	memset(&tmp, 0, sizeof(tmp));
	tmp.flags = ASYNC_LOW_LATENCY;
	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 | oliver neukum | 93 | 73.23% | 1 | 50.00% | 
| dan williams | dan williams | 34 | 26.77% | 1 | 50.00% | 
 | Total | 127 | 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 williams | dan 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;
	if (arg & (TIOCM_DSR | TIOCM_RI | TIOCM_CD ))
		return -EINVAL;
	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 | oliver neukum | 212 | 100.00% | 1 | 100.00% | 
 | Total | 212 | 100.00% | 1 | 100.00% | 
static int get_serial_usage(struct acm *acm,
			    struct serial_icounter_struct __user *count)
{
	struct serial_icounter_struct icount;
	int rv = 0;
	memset(&icount, 0, sizeof(icount));
	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;
	if (copy_to_user(count, &icount, sizeof(icount)) > 0)
		rv = -EFAULT;
	return rv;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 134 | 100.00% | 1 | 100.00% | 
 | Total | 134 | 100.00% | 1 | 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;
	case TIOCGICOUNT:
		rv = get_serial_usage(acm, (struct serial_icounter_struct __user *) arg);
		break;
	}
	return rv;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 103 | 71.53% | 4 | 50.00% | 
| dan williams | dan williams | 19 | 13.19% | 1 | 12.50% | 
| greg kroah-hartman | greg kroah-hartman | 18 | 12.50% | 1 | 12.50% | 
| pre-git | pre-git | 4 | 2.78% | 2 | 25.00% | 
 | Total | 144 | 100.00% | 8 | 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 | 
| pre-git | pre-git | 208 | 65.62% | 7 | 43.75% | 
| nicolas boullis | nicolas boullis | 45 | 14.20% | 1 | 6.25% | 
| johan hovold | johan hovold | 34 | 10.73% | 2 | 12.50% | 
| david brownell | david brownell | 15 | 4.73% | 1 | 6.25% | 
| alan cox | alan cox | 9 | 2.84% | 4 | 25.00% | 
| linus torvalds | 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;
	struct usb_device *usb_dev = interface_to_usbdev(acm->control);
	for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++)
		usb_free_coherent(usb_dev, acm->writesize, wb->buf, wb->dmah);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 73 | 98.65% | 3 | 75.00% | 
| daniel mack | daniel mack | 1 | 1.35% | 1 | 25.00% | 
 | Total | 74 | 100.00% | 4 | 100.00% | 
static void acm_read_buffers_free(struct acm *acm)
{
	struct usb_device *usb_dev = interface_to_usbdev(acm->control);
	int i;
	for (i = 0; i < acm->rx_buflimit; i++)
		usb_free_coherent(usb_dev, acm->readsize,
			  acm->read_buffers[i].base, acm->read_buffers[i].dma);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 62 | 91.18% | 1 | 25.00% | 
| johan hovold | johan hovold | 5 | 7.35% | 2 | 50.00% | 
| daniel mack | daniel mack | 1 | 1.47% | 1 | 25.00% | 
 | Total | 68 | 100.00% | 4 | 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 | oliver neukum | 116 | 98.31% | 2 | 66.67% | 
| daniel mack | 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_country_functional_desc *cfd = 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 acm *acm;
	int minor;
	int ctrlsize, readsize;
	u8 *buf;
	u8 ac_management_function = 0;
	u8 call_management_function = 0;
	int call_interface_num = -1;
	int data_interface_num = -1;
	unsigned long quirks;
	int num_rx_buf;
	int i;
	unsigned int elength = 0;
	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;
	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 (!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;
		}
	}
	while (buflen > 0) {
		elength = buffer[0];
		if (!elength) {
			dev_err(&intf->dev, "skipping garbage byte\n");
			elength = 1;
			goto next_desc;
		}
		if (buffer[1] != USB_DT_CS_INTERFACE) {
			dev_err(&intf->dev, "skipping garbage\n");
			goto next_desc;
		}
		switch (buffer[2]) {
		case USB_CDC_UNION_TYPE: /* we've found it */
			if (elength < sizeof(struct usb_cdc_union_desc))
				goto next_desc;
			if (union_header) {
				dev_err(&intf->dev, "More than one "
					"union descriptor, skipping ...\n");
				goto next_desc;
			}
			union_header = (struct usb_cdc_union_desc *)buffer;
			break;
		case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
			if (elength < sizeof(struct usb_cdc_country_functional_desc))
				goto next_desc;
			cfd = (struct usb_cdc_country_functional_desc *)buffer;
			break;
		case USB_CDC_HEADER_TYPE: /* maybe check version */
			break; /* for now we ignore it */
		case USB_CDC_ACM_TYPE:
			if (elength < 4)
				goto next_desc;
			ac_management_function = buffer[3];
			break;
		case USB_CDC_CALL_MANAGEMENT_TYPE:
			if (elength < 5)
				goto next_desc;
			call_management_function = buffer[3];
			call_interface_num = buffer[4];
			break;
		default:
			/*
                         * there are LOTS more CDC descriptors that
                         * could legitimately be found here.
                         */
			dev_dbg(&intf->dev, "Ignoring descriptor: "
					"type %02x, length %ud\n",
					buffer[2], elength);
			break;
		}
next_desc:
		buflen -= elength;
		buffer += elength;
	}
	if (!union_header) {
		if (call_interface_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_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_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 {
		control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
		data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0));
	}
	if (!control_interface || !data_interface) {
		dev_dbg(&intf->dev, "no interfaces\n");
		return -ENODEV;
	}
	if (data_interface_num != call_interface_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) {
		dev_err(&intf->dev, "no more free acm devices\n");
		kfree(acm);
		return -ENODEV;
	}
	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;
	acm->ctrl_caps = ac_management_function;
	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);
	acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
	acm->is_int_ep = usb_endpoint_xfer_int(epread);
	if (acm->is_int_ep)
		acm->bInterval = epread->bInterval;
	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 (acm->is_int_ep) {
			usb_fill_int_urb(urb, acm->dev,
					 acm->rx_endpoint,
					 rb->base,
					 acm->readsize,
					 acm_read_bulk_callback, rb,
					 acm->bInterval);
		} else {
			usb_fill_bulk_urb(urb, acm->dev,
					  acm->rx_endpoint,
					  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,
				usb_sndintpipe(usb_dev, epwrite->bEndpointAddress),
				NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
		else
			usb_fill_bulk_urb(snd->urb, usb_dev,
				usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
				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 (cfd) { /* export the country data */
		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, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress));
		usb_clear_halt(usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress));
	}
	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);
	kfree(acm);
alloc_fail:
	return rv;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 1217 | 51.85% | 17 | 20.24% | 
| johan hovold | johan hovold | 180 | 7.67% | 7 | 8.33% | 
| pre-git | pre-git | 152 | 6.48% | 14 | 16.67% | 
| david engraf | david engraf | 94 | 4.01% | 1 | 1.19% | 
| alexey khoroshilov | alexey khoroshilov | 89 | 3.79% | 1 | 1.19% | 
| david kubicek | david kubicek | 81 | 3.45% | 1 | 1.19% | 
| greg kroah-hartman | greg kroah-hartman | 72 | 3.07% | 7 | 8.33% | 
| colin leroy | colin leroy | 63 | 2.68% | 2 | 2.38% | 
| david brownell | david brownell | 58 | 2.47% | 6 | 7.14% | 
| arseniy lartsev | arseniy lartsev | 39 | 1.66% | 1 | 1.19% | 
| alexey sokolov | alexey sokolov | 36 | 1.53% | 1 | 1.19% | 
| haavard skinnemoen | haavard skinnemoen | 35 | 1.49% | 1 | 1.19% | 
| alan cox | alan cox | 33 | 1.41% | 2 | 2.38% | 
| quentin casasnovas | quentin casasnovas | 31 | 1.32% | 1 | 1.19% | 
| julia lawall | julia lawall | 23 | 0.98% | 1 | 1.19% | 
| erik slagter | erik slagter | 20 | 0.85% | 1 | 1.19% | 
| lu baolu | lu baolu | 14 | 0.60% | 1 | 1.19% | 
| axel lin | axel lin | 14 | 0.60% | 1 | 1.19% | 
| alan stern | alan stern | 12 | 0.51% | 2 | 2.38% | 
| alex kanavin | alex kanavin | 11 | 0.47% | 1 | 1.19% | 
| dmitry torokhov | dmitry torokhov | 10 | 0.43% | 1 | 1.19% | 
| sven schnelle | sven schnelle | 10 | 0.43% | 1 | 1.19% | 
| joe perches | joe perches | 9 | 0.38% | 2 | 2.38% | 
| fabian frederick | fabian frederick | 8 | 0.34% | 1 | 1.19% | 
| brian murphy | brian murphy | 6 | 0.26% | 1 | 1.19% | 
| toby gray | toby gray | 6 | 0.26% | 1 | 1.19% | 
| ingo molnar | ingo molnar | 6 | 0.26% | 1 | 1.19% | 
| jiri slaby | jiri slaby | 6 | 0.26% | 1 | 1.19% | 
| luiz fernando capitulino | luiz fernando capitulino | 4 | 0.17% | 1 | 1.19% | 
| kuninori morimoto | kuninori morimoto | 3 | 0.13% | 1 | 1.19% | 
| daniel mack | daniel mack | 2 | 0.09% | 1 | 1.19% | 
| catalin boie | catalin boie | 1 | 0.04% | 1 | 1.19% | 
| ming lei | ming lei | 1 | 0.04% | 1 | 1.19% | 
| felipe balbi | felipe balbi | 1 | 0.04% | 1 | 1.19% | 
 | Total | 2347 | 100.00% | 84 | 100.00% | 
static void stop_data_traffic(struct acm *acm)
{
	int i;
	dev_dbg(&acm->control->dev, "%s\n", __func__);
	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]);
	cancel_work_sync(&acm->work);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 62 | 66.67% | 2 | 40.00% | 
| david engraf | david engraf | 19 | 20.43% | 1 | 20.00% | 
| johan hovold | johan hovold | 12 | 12.90% | 2 | 40.00% | 
 | Total | 93 | 100.00% | 5 | 100.00% | 
static void acm_disconnect(struct usb_interface *intf)
{
	struct acm *acm = usb_get_intfdata(intf);
	struct usb_device *usb_dev = interface_to_usbdev(intf);
	struct tty_struct *tty;
	int i;
	dev_dbg(&intf->dev, "%s\n", __func__);
	/* 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);
	}
	stop_data_traffic(acm);
	tty_unregister_device(acm_tty_driver, acm->minor);
	usb_free_urb(acm->ctrlurb);
	for (i = 0; i < ACM_NW; i++)
		usb_free_urb(acm->wb[i].urb);
	for (i = 0; i < acm->rx_buflimit; i++)
		usb_free_urb(acm->read_urbs[i]);
	acm_write_buffers_free(acm);
	usb_free_coherent(usb_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 | 
| haavard skinnemoen | haavard skinnemoen | 116 | 37.18% | 1 | 4.35% | 
| oliver neukum | oliver neukum | 114 | 36.54% | 8 | 34.78% | 
| pre-git | pre-git | 33 | 10.58% | 5 | 21.74% | 
| greg kroah-hartman | greg kroah-hartman | 12 | 3.85% | 2 | 8.70% | 
| alan cox | alan cox | 11 | 3.53% | 1 | 4.35% | 
| johan hovold | johan hovold | 9 | 2.88% | 1 | 4.35% | 
| alan stern | alan stern | 9 | 2.88% | 1 | 4.35% | 
| david brownell | david brownell | 4 | 1.28% | 2 | 8.70% | 
| david kubicek | david kubicek | 3 | 0.96% | 1 | 4.35% | 
| daniel mack | daniel mack | 1 | 0.32% | 1 | 4.35% | 
 | Total | 312 | 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;
	stop_data_traffic(acm);
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| oliver neukum | oliver neukum | 72 | 76.60% | 2 | 40.00% | 
| johan hovold | johan hovold | 22 | 23.40% | 3 | 60.00% | 
 | Total | 94 | 100.00% | 5 | 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 | oliver neukum | 85 | 62.50% | 3 | 30.00% | 
| johan hovold | johan hovold | 46 | 33.82% | 4 | 40.00% | 
| haavard skinnemoen | haavard skinnemoen | 3 | 2.21% | 1 | 10.00% | 
| peter hurley | peter hurley | 1 | 0.74% | 1 | 10.00% | 
| alan cox | 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 | francesco lavra | 40 | 85.11% | 1 | 25.00% | 
| jiri slaby | jiri slaby | 3 | 6.38% | 1 | 25.00% | 
| haavard skinnemoen | haavard skinnemoen | 3 | 6.38% | 1 | 25.00% | 
| peter hurley | peter hurley | 1 | 2.13% | 1 | 25.00% | 
 | Total | 47 | 100.00% | 4 | 100.00% | 
#endif /* CONFIG_PM */
#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(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
	.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,
};
/*
 * 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 | al viro | 76 | 47.20% | 1 | 7.69% | 
| pre-git | pre-git | 54 | 33.54% | 7 | 53.85% | 
| daniele bellucci | daniele bellucci | 17 | 10.56% | 1 | 7.69% | 
| greg kroah-hartman | greg kroah-hartman | 12 | 7.45% | 3 | 23.08% | 
| linus torvalds | 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 | 
| pre-git | pre-git | 20 | 64.52% | 1 | 33.33% | 
| johannes thumshirn | johannes thumshirn | 6 | 19.35% | 1 | 33.33% | 
| al viro | 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 | oliver neukum | 3729 | 37.27% | 40 | 17.54% | 
| pre-git | pre-git | 1309 | 13.08% | 31 | 13.60% | 
| johan hovold | johan hovold | 1124 | 11.23% | 27 | 11.84% | 
| haavard skinnemoen | haavard skinnemoen | 608 | 6.08% | 2 | 0.88% | 
| adrian taylor | adrian taylor | 354 | 3.54% | 1 | 0.44% | 
| greg kroah-hartman | greg kroah-hartman | 327 | 3.27% | 16 | 7.02% | 
| david brownell | david brownell | 266 | 2.66% | 9 | 3.95% | 
| dan williams | dan williams | 213 | 2.13% | 1 | 0.44% | 
| alan cox | alan cox | 203 | 2.03% | 10 | 4.39% | 
| david kubicek | david kubicek | 167 | 1.67% | 1 | 0.44% | 
| david engraf | david engraf | 153 | 1.53% | 2 | 0.88% | 
| toby gray | toby gray | 118 | 1.18% | 3 | 1.32% | 
| alexey khoroshilov | alexey khoroshilov | 89 | 0.89% | 1 | 0.44% | 
| al viro | al viro | 85 | 0.85% | 2 | 0.88% | 
| krzysztof halasa | krzysztof halasa | 74 | 0.74% | 1 | 0.44% | 
| colin leroy | colin leroy | 63 | 0.63% | 2 | 0.88% | 
| francesco lavra | francesco lavra | 60 | 0.60% | 2 | 0.88% | 
| linus torvalds | linus torvalds | 59 | 0.59% | 6 | 2.63% | 
| michael ulbricht | michael ulbricht | 56 | 0.56% | 1 | 0.44% | 
| alexey sokolov | alexey sokolov | 51 | 0.51% | 1 | 0.44% | 
| dmitry torokhov | dmitry torokhov | 48 | 0.48% | 1 | 0.44% | 
| lu baolu | lu baolu | 46 | 0.46% | 2 | 0.88% | 
| nicolas boullis | nicolas boullis | 45 | 0.45% | 1 | 0.44% | 
| arseniy lartsev | arseniy lartsev | 43 | 0.43% | 1 | 0.44% | 
| brian murphy | brian murphy | 38 | 0.38% | 1 | 0.44% | 
| erik slagter | erik slagter | 35 | 0.35% | 1 | 0.44% | 
| quentin casasnovas | quentin casasnovas | 31 | 0.31% | 1 | 0.44% | 
| otto meta | otto meta | 29 | 0.29% | 1 | 0.44% | 
| jiri slaby | jiri slaby | 28 | 0.28% | 6 | 2.63% | 
| rusty russell | rusty russell | 28 | 0.28% | 1 | 0.44% | 
| brandon philips | brandon philips | 25 | 0.25% | 1 | 0.44% | 
| julia lawall | julia lawall | 23 | 0.23% | 1 | 0.44% | 
| jim paris | jim paris | 22 | 0.22% | 1 | 0.44% | 
| alan stern | alan stern | 21 | 0.21% | 2 | 0.88% | 
| daniele bellucci | daniele bellucci | 17 | 0.17% | 1 | 0.44% | 
| masahito omote | masahito omote | 17 | 0.17% | 1 | 0.44% | 
| andrew lunn | andrew lunn | 17 | 0.17% | 1 | 0.44% | 
| andrey arapov | andrey arapov | 17 | 0.17% | 1 | 0.44% | 
| adam richter | adam richter | 17 | 0.17% | 1 | 0.44% | 
| iain mcfarlane | iain mcfarlane | 17 | 0.17% | 1 | 0.44% | 
| kir kolyshkin | kir kolyshkin | 17 | 0.17% | 1 | 0.44% | 
| russ nelson | russ nelson | 17 | 0.17% | 1 | 0.44% | 
| chris malley | chris malley | 17 | 0.17% | 1 | 0.44% | 
| xiao kaijian | xiao kaijian | 17 | 0.17% | 1 | 0.44% | 
| eric sandeen | eric sandeen | 17 | 0.17% | 1 | 0.44% | 
| bjorn gerhart | bjorn gerhart | 16 | 0.16% | 1 | 0.44% | 
| david cluytens | david cluytens | 16 | 0.16% | 1 | 0.44% | 
| jean-christian de rivaz | jean-christian de rivaz | 15 | 0.15% | 1 | 0.44% | 
| jonas jonsson | jonas jonsson | 15 | 0.15% | 1 | 0.44% | 
| denis n ladin | denis n ladin | 15 | 0.15% | 1 | 0.44% | 
| axel lin | axel lin | 14 | 0.14% | 1 | 0.44% | 
| philippe corbes | philippe corbes | 12 | 0.12% | 1 | 0.44% | 
| denis pershin | denis pershin | 11 | 0.11% | 1 | 0.44% | 
| dmitriy taychenachev | dmitriy taychenachev | 11 | 0.11% | 1 | 0.44% | 
| alex kanavin | alex kanavin | 11 | 0.11% | 1 | 0.44% | 
| sven schnelle | sven schnelle | 10 | 0.10% | 1 | 0.44% | 
| joe perches | joe perches | 9 | 0.09% | 2 | 0.88% | 
| przemo firszt | przemo firszt | 8 | 0.08% | 1 | 0.44% | 
| fabian frederick | fabian frederick | 8 | 0.08% | 1 | 0.44% | 
| arvid ephraim picciani | arvid ephraim picciani | 8 | 0.08% | 1 | 0.44% | 
| vojtech pavlik | vojtech pavlik | 8 | 0.08% | 1 | 0.44% | 
| daniel mack | daniel mack | 7 | 0.07% | 1 | 0.44% | 
| ingo molnar | ingo molnar | 6 | 0.06% | 1 | 0.44% | 
| johannes thumshirn | johannes thumshirn | 6 | 0.06% | 1 | 0.44% | 
| sarah sharp | sarah sharp | 5 | 0.05% | 1 | 0.44% | 
| scott james remnant | scott james remnant | 5 | 0.05% | 1 | 0.44% | 
| luiz fernando capitulino | luiz fernando capitulino | 4 | 0.04% | 1 | 0.44% | 
| arjan van de ven | arjan van de ven | 4 | 0.04% | 1 | 0.44% | 
| harvey harrison | harvey harrison | 4 | 0.04% | 2 | 0.88% | 
| jarek poplawski | jarek poplawski | 4 | 0.04% | 1 | 0.44% | 
| borislav petkov | borislav petkov | 3 | 0.03% | 1 | 0.44% | 
| kuninori morimoto | kuninori morimoto | 3 | 0.03% | 1 | 0.44% | 
| dave jones | dave jones | 3 | 0.03% | 1 | 0.44% | 
| peter hurley | peter hurley | 2 | 0.02% | 1 | 0.44% | 
| nishanth aravamudan | nishanth aravamudan | 1 | 0.01% | 1 | 0.44% | 
| ming lei | ming lei | 1 | 0.01% | 1 | 0.44% | 
| felipe balbi | felipe balbi | 1 | 0.01% | 1 | 0.44% | 
| catalin boie | catalin boie | 1 | 0.01% | 1 | 0.44% | 
| marton nemeth | marton nemeth | 1 | 0.01% | 1 | 0.44% | 
| jeff dike | jeff dike | 1 | 0.01% | 1 | 0.44% | 
 | Total | 10006 | 100.00% | 228 | 100.00% | 
  
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.