Release 4.7 drivers/usb/serial/bus.c
/*
* USB Serial Converter Bus specific functions
*
* Copyright (C) 2002 Greg Kroah-Hartman (greg@kroah.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
static int usb_serial_device_match(struct device *dev,
struct device_driver *drv)
{
struct usb_serial_driver *driver;
const struct usb_serial_port *port;
/*
* drivers are already assigned to ports in serial_probe so it's
* a simple check here.
*/
port = to_usb_serial_port(dev);
if (!port)
return 0;
driver = to_usb_serial_driver(drv);
if (driver == port->serial->type)
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 66 | 100.00% | 2 | 100.00% |
| Total | 66 | 100.00% | 2 | 100.00% |
static int usb_serial_device_probe(struct device *dev)
{
struct usb_serial_driver *driver;
struct usb_serial_port *port;
struct device *tty_dev;
int retval = 0;
int minor;
port = to_usb_serial_port(dev);
if (!port)
return -ENODEV;
/* make sure suspend/resume doesn't race against port_probe */
retval = usb_autopm_get_interface(port->serial->interface);
if (retval)
return retval;
driver = port->serial->type;
if (driver->port_probe) {
retval = driver->port_probe(port);
if (retval)
goto err_autopm_put;
}
minor = port->minor;
tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev);
if (IS_ERR(tty_dev)) {
retval = PTR_ERR(tty_dev);
goto err_port_remove;
}
usb_autopm_put_interface(port->serial->interface);
dev_info(&port->serial->dev->dev,
"%s converter now attached to ttyUSB%d\n",
driver->description, minor);
return 0;
err_port_remove:
if (driver->port_remove)
driver->port_remove(port);
err_autopm_put:
usb_autopm_put_interface(port->serial->interface);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 112 | 56.57% | 10 | 76.92% |
johan hovold | johan hovold | 60 | 30.30% | 2 | 15.38% |
bjorn mork | bjorn mork | 26 | 13.13% | 1 | 7.69% |
| Total | 198 | 100.00% | 13 | 100.00% |
static int usb_serial_device_remove(struct device *dev)
{
struct usb_serial_driver *driver;
struct usb_serial_port *port;
int retval = 0;
int minor;
int autopm_err;
port = to_usb_serial_port(dev);
if (!port)
return -ENODEV;
/*
* Make sure suspend/resume doesn't race against port_remove.
*
* Note that no further runtime PM callbacks will be made if
* autopm_get fails.
*/
autopm_err = usb_autopm_get_interface(port->serial->interface);
minor = port->minor;
tty_unregister_device(usb_serial_tty_driver, minor);
driver = port->serial->type;
if (driver->port_remove)
retval = driver->port_remove(port);
dev_info(dev, "%s converter now disconnected from ttyUSB%d\n",
driver->description, minor);
if (!autopm_err)
usb_autopm_put_interface(port->serial->interface);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 85 | 67.46% | 5 | 62.50% |
johan hovold | johan hovold | 23 | 18.25% | 2 | 25.00% |
bjorn mork | bjorn mork | 18 | 14.29% | 1 | 12.50% |
| Total | 126 | 100.00% | 8 | 100.00% |
static ssize_t new_id_store(struct device_driver *driver,
const char *buf, size_t count)
{
struct usb_serial_driver *usb_drv = to_usb_serial_driver(driver);
ssize_t retval = usb_store_new_id(&usb_drv->dynids, usb_drv->id_table,
driver, buf, count);
if (retval >= 0 && usb_drv->usb_driver != NULL)
retval = usb_store_new_id(&usb_drv->usb_driver->dynids,
usb_drv->usb_driver->id_table,
&usb_drv->usb_driver->drvwrap.driver,
buf, count);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 86 | 89.58% | 2 | 66.67% |
wolfram sang | wolfram sang | 10 | 10.42% | 1 | 33.33% |
| Total | 96 | 100.00% | 3 | 100.00% |
static ssize_t new_id_show(struct device_driver *driver, char *buf)
{
struct usb_serial_driver *usb_drv = to_usb_serial_driver(driver);
return usb_show_dynids(&usb_drv->dynids, buf);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
bjorn mork | bjorn mork | 35 | 97.22% | 1 | 50.00% |
greg kroah-hartman | greg kroah-hartman | 1 | 2.78% | 1 | 50.00% |
| Total | 36 | 100.00% | 2 | 100.00% |
static DRIVER_ATTR_RW(new_id);
static struct attribute *usb_serial_drv_attrs[] = {
&driver_attr_new_id.attr,
NULL,
};
ATTRIBUTE_GROUPS(usb_serial_drv);
static void free_dynids(struct usb_serial_driver *drv)
{
struct usb_dynid *dynid, *n;
spin_lock(&drv->dynids.lock);
list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
list_del(&dynid->node);
kfree(dynid);
}
spin_unlock(&drv->dynids.lock);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 64 | 100.00% | 1 | 100.00% |
| Total | 64 | 100.00% | 1 | 100.00% |
struct bus_type usb_serial_bus_type = {
.name = "usb-serial",
.match = usb_serial_device_match,
.probe = usb_serial_device_probe,
.remove = usb_serial_device_remove,
.drv_groups = usb_serial_drv_groups,
};
int usb_serial_bus_register(struct usb_serial_driver *driver)
{
int retval;
driver->driver.bus = &usb_serial_bus_type;
spin_lock_init(&driver->dynids.lock);
INIT_LIST_HEAD(&driver->dynids.list);
retval = driver_register(&driver->driver);
return retval;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 55 | 100.00% | 3 | 100.00% |
| Total | 55 | 100.00% | 3 | 100.00% |
void usb_serial_bus_deregister(struct usb_serial_driver *driver)
{
free_dynids(driver);
driver_unregister(&driver->driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 23 | 100.00% | 3 | 100.00% |
| Total | 23 | 100.00% | 3 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
greg kroah-hartman | greg kroah-hartman | 543 | 72.98% | 13 | 59.09% |
johan hovold | johan hovold | 83 | 11.16% | 4 | 18.18% |
bjorn mork | bjorn mork | 79 | 10.62% | 2 | 9.09% |
russell king | russell king | 26 | 3.49% | 1 | 4.55% |
wolfram sang | wolfram sang | 10 | 1.34% | 1 | 4.55% |
tejun heo | tejun heo | 3 | 0.40% | 1 | 4.55% |
| Total | 744 | 100.00% | 22 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.