1.
插入华为e261
[root@root]# usb 1-1.3: usbfs: process 919 (3g-modem) did not claim interface 0 before use
usb 1-1.3: USB disconnect, address 3
usb 1-1.3: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.3: New USB device found, idVendor=12d1, idProduct=140c
usb 1-1.3: New USB device strings: Mfr=3, Product=2, SerialNumber=0
usb 1-1.3: Product: HUAWEI Mobile
usb 1-1.3: Manufacturer: HUAWEI Technology
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.0: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/option.c,option_instat_callback,1174:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.1: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.2: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.3: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB3
scsi6 : usb-storage 1-1.3:1.4
scsi7 : usb-storage 1-1.3:1.5
drivers/usb/serial/option.c,option_instat_callback,1174:
drivers/usb/serial/option.c,option_instat_callback,1174:
scsi 6:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
scsi 7:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
scsi 6:0:0:0: Attached scsi generic sg0 type 5
sd 7:0:0:0: Attached scsi generic sg1 type 0
sd 7:0:0:0: [sda] Attached SCSI removable disk
usb_driver的probe函数是usb-serial.c的usb_serial_probe,每一次调用这个函数都会生成一个ttyUSBx。而每次在usb设备插入时,usb core每枚举到一个interface,就会调用一次这个probe。所以usb modem的配置描述符里面有几个interface决定了生成几个ttyUSBx。
而由usb modem的interface生成的各个ttyUSBx的功能也不一样,由厂家自定义。
int usb_serial_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(interface);
struct usb_serial *serial = NULL;
struct usb_serial_port *port;
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
struct usb_endpoint_descriptor *interrupt_in_endpoint[MAX_NUM_PORTS];
struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS];
struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
struct usb_serial_driver *type = NULL;
int retval;
unsigned int minor;
int buffer_size;
int i;
int num_interrupt_in = 0;
int num_interrupt_out = 0;
int num_bulk_in = 0;
int num_bulk_out = 0;
int num_ports = 0;
int max_endpoints;
lock_kernel(); /* guard against unloading a serial driver module */
type = search_serial_device(interface);
if (!type) {
unlock_kernel();
dbg("none matched");
return -ENODEV;
}
serial = create_serial(dev, interface, type);
if (!serial) {
unlock_kernel();
dev_err(&interface->dev, "%s - out of memory\n", __func__);
return -ENOMEM;
}
/* if this device type has a probe function, call it */
if (type->probe) {
const struct usb_device_id *id;
if (!try_module_get(type->driver.owner)) {
unlock_kernel();
dev_err(&interface->dev,
"module get failed, exiting\n");
kfree(serial);
return -EIO;
}
id = get_iface_id(type, interface);
retval = type->probe(serial, id);
module_put(type->driver.owner);
if (retval) {
unlock_kernel();
dbg("sub driver rejected device");
kfree(serial);
return retval;
}
}
/* descriptor matches, let's find the endpoints needed */
/* check out the endpoints */
iface_desc = interface->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_bulk_in(endpoint)) {
/* we found a bulk in endpoint */
dbg("found bulk in on endpoint %d", i);
bulk_in_endpoint[num_bulk_in] = endpoint;
++num_bulk_in;
}
if (usb_endpoint_is_bulk_out(endpoint)) {
/* we found a bulk out endpoint */
dbg("found bulk out on endpoint %d", i);
bulk_out_endpoint[num_bulk_out] = endpoint;
++num_bulk_out;
}
if (usb_endpoint_is_int_in(endpoint)) {
/* we found a interrupt in endpoint */
dbg("found interrupt in on endpoint %d", i);
interrupt_in_endpoint[num_interrupt_in] = endpoint;
++num_interrupt_in;
}
if (usb_endpoint_is_int_out(endpoint)) {
/* we found an interrupt out endpoint */
dbg("found interrupt out on endpoint %d", i);
interrupt_out_endpoint[num_interrupt_out] = endpoint;
++num_interrupt_out;
}
}
#if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
/* BEGIN HORRIBLE HACK FOR PL2303 */
/* this is needed due to the looney way its endpoints are set up */
if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) &&
(le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) &&
(le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) ||
((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) &&
(le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) ||
((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) &&
(le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) {
if (interface != dev->actconfig->interface[0]) {
/* check out the endpoints of the other interface*/
iface_desc = dev->actconfig->interface[0]->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_int_in(endpoint)) {
/* we found a interrupt in endpoint */
dbg("found interrupt in for Prolific device on separate interface");
interrupt_in_endpoint[num_interrupt_in] = endpoint;
++num_interrupt_in;
}
}
}
/* Now make sure the PL-2303 is configured correctly.
* If not, give up now and hope this hack will work
* properly during a later invocation of usb_serial_probe
*/
if (num_bulk_in == 0 || num_bulk_out == 0) {
unlock_kernel();
dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n");
kfree(serial);
return -ENODEV;
}
}
/* END HORRIBLE HACK FOR PL2303 */
#endif
#ifdef CONFIG_USB_SERIAL_GENERIC
if (type == &usb_serial_generic_device) {
num_ports = num_bulk_out;
if (num_ports == 0) {
unlock_kernel();
dev_err(&interface->dev,
"Generic device with no bulk out, not allowed.\n");
kfree(serial);
return -EIO;
}
}
#endif
if (!num_ports) {
/* if this device type has a calc_num_ports function, call it */
if (type->calc_num_ports) {
if (!try_module_get(type->driver.owner)) {
unlock_kernel();
dev_err(&interface->dev,
"module get failed, exiting\n");
kfree(serial);
return -EIO;
}
num_ports = type->calc_num_ports(serial);
module_put(type->driver.owner);
}
if (!num_ports)
num_ports = type->num_ports;
}
serial->num_ports = num_ports;
serial->num_bulk_in = num_bulk_in;
serial->num_bulk_out = num_bulk_out;
serial->num_interrupt_in = num_interrupt_in;
serial->num_interrupt_out = num_interrupt_out;
/* found all that we need */
dev_info(&interface->dev, "%s converter detected\n",
type->description);
/* create our ports, we need as many as the max endpoints */
/* we don't use num_ports here because some devices have more
endpoint pairs than ports */
max_endpoints = max(num_bulk_in, num_bulk_out);
max_endpoints = max(max_endpoints, num_interrupt_in);
max_endpoints = max(max_endpoints, num_interrupt_out);
max_endpoints = max(max_endpoints, (int)serial->num_ports);
serial->num_port_pointers = max_endpoints;
unlock_kernel();
dbg("%s - setting up %d port structures for this device",
__func__, max_endpoints);
for (i = 0; i < max_endpoints; ++i) {
port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
if (!port)
goto probe_error;
tty_port_init(&port->port);
port->port.ops = &serial_port_ops;
port->serial = serial;
spin_lock_init(&port->lock);
/* Keep this for private driver use for the moment but
should probably go away */
INIT_WORK(&port->work, usb_serial_port_work);
serial->port[i] = port;
port->dev.parent = &interface->dev;
port->dev.driver = NULL;
port->dev.bus = &usb_serial_bus_type;
port->dev.release = &port_release;
device_initialize(&port->dev);
}
/* set up the endpoint information */
for (i = 0; i < num_bulk_in; ++i) {
endpoint = bulk_in_endpoint[i];
port = serial->port[i];
port->read_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->read_urb) {
dev_err(&interface->dev, "No free urbs available\n");
goto probe_error;
}
buffer_size = serial->type->bulk_in_size;
if (!buffer_size)
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
port->bulk_in_size = buffer_size;
port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!port->bulk_in_buffer) {
dev_err(&interface->dev,
"Couldn't allocate bulk_in_buffer\n");
goto probe_error;
}
usb_fill_bulk_urb(port->read_urb, dev,
usb_rcvbulkpipe(dev,
endpoint->bEndpointAddress),
port->bulk_in_buffer, buffer_size,
serial->type->read_bulk_callback, port);
}
for (i = 0; i < num_bulk_out; ++i) {
int j;
endpoint = bulk_out_endpoint[i];
port = serial->port[i];
port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->write_urb) {
dev_err(&interface->dev, "No free urbs available\n");
goto probe_error;
}
if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
goto probe_error;
buffer_size = serial->type->bulk_out_size;
if (!buffer_size)
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
port->bulk_out_size = buffer_size;
port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!port->bulk_out_buffer) {
dev_err(&interface->dev,
"Couldn't allocate bulk_out_buffer\n");
goto probe_error;
}
usb_fill_bulk_urb(port->write_urb, dev,
usb_sndbulkpipe(dev,
endpoint->bEndpointAddress),
port->bulk_out_buffer, buffer_size,
serial->type->write_bulk_callback, port);
for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) {
set_bit(j, &port->write_urbs_free);
port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL);
if (!port->write_urbs[j]) {
dev_err(&interface->dev,
"No free urbs available\n");
goto probe_error;
}
port->bulk_out_buffers[j] = kmalloc(buffer_size,
GFP_KERNEL);
if (!port->bulk_out_buffers[j]) {
dev_err(&interface->dev,
"Couldn't allocate bulk_out_buffer\n");
goto probe_error;
}
usb_fill_bulk_urb(port->write_urbs[j], dev,
usb_sndbulkpipe(dev,
endpoint->bEndpointAddress),
port->bulk_out_buffers[j], buffer_size,
serial->type->write_bulk_callback,
port);
}
}
if (serial->type->read_int_callback) {
for (i = 0; i < num_interrupt_in; ++i) {
endpoint = interrupt_in_endpoint[i];
port = serial->port[i];
port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->interrupt_in_urb) {
dev_err(&interface->dev,
"No free urbs available\n");
goto probe_error;
}
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
port->interrupt_in_endpointAddress =
endpoint->bEndpointAddress;
port->interrupt_in_buffer = kmalloc(buffer_size,
GFP_KERNEL);
if (!port->interrupt_in_buffer) {
dev_err(&interface->dev,
"Couldn't allocate interrupt_in_buffer\n");
goto probe_error;
}
usb_fill_int_urb(port->interrupt_in_urb, dev,
usb_rcvintpipe(dev,
endpoint->bEndpointAddress),
port->interrupt_in_buffer, buffer_size,
serial->type->read_int_callback, port,
endpoint->bInterval);
}
} else if (num_interrupt_in) {
dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined");
}
if (serial->type->write_int_callback) {
for (i = 0; i < num_interrupt_out; ++i) {
endpoint = interrupt_out_endpoint[i];
port = serial->port[i];
port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!port->interrupt_out_urb) {
dev_err(&interface->dev,
"No free urbs available\n");
goto probe_error;
}
buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
port->interrupt_out_size = buffer_size;
port->interrupt_out_endpointAddress =
endpoint->bEndpointAddress;
port->interrupt_out_buffer = kmalloc(buffer_size,
GFP_KERNEL);
if (!port->interrupt_out_buffer) {
dev_err(&interface->dev,
"Couldn't allocate interrupt_out_buffer\n");
goto probe_error;
}
usb_fill_int_urb(port->interrupt_out_urb, dev,
usb_sndintpipe(dev,
endpoint->bEndpointAddress),
port->interrupt_out_buffer, buffer_size,
serial->type->write_int_callback, port,
endpoint->bInterval);
}
} else if (num_interrupt_out) {
dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
}
/* if this device type has an attach function, call it */
if (type->attach) {
if (!try_module_get(type->driver.owner)) {
dev_err(&interface->dev,
"module get failed, exiting\n");
goto probe_error;
}
retval = type->attach(serial);
module_put(type->driver.owner);
if (retval < 0)
goto probe_error;
serial->attached = 1;
if (retval > 0) {
/* quietly accept this device, but don't bind to a
serial port as it's about to disappear */
serial->num_ports = 0;
goto exit;
}
} else {
serial->attached = 1;
}
if (get_free_serial(serial, num_ports, &minor) == NULL) {
dev_err(&interface->dev, "No more free serial devices\n");
goto probe_error;
}
serial->minor = minor;
/* register all of the individual ports with the driver core */
for (i = 0; i < num_ports; ++i) {
port = serial->port[i];
dev_set_name(&port->dev, "ttyUSB%d", port->number);
dbg ("%s - registering %s", __func__, dev_name(&port->dev));
port->dev_state = PORT_REGISTERING;
retval = device_add(&port->dev);
if (retval) {
dev_err(&port->dev, "Error registering port device, "
"continuing\n");
port->dev_state = PORT_UNREGISTERED;
} else {
port->dev_state = PORT_REGISTERED;
}
}
usb_serial_console_init(debug, minor);
exit:
/* success */
usb_set_intfdata(interface, serial);
return 0;
probe_error:
usb_serial_put(serial);
return -EIO;
}
上层操作ttyUSBx的接口,usb-serial.c
static const struct tty_operations serial_ops = {
.open = serial_open,
.close = serial_close,
.write = serial_write,
.hangup = serial_hangup,
.write_room = serial_write_room,
.ioctl = serial_ioctl,
.set_termios = serial_set_termios,
.throttle = serial_throttle,
.unthrottle = serial_unthrottle,
.break_ctl = serial_break,
.chars_in_buffer = serial_chars_in_buffer,
.tiocmget = serial_tiocmget,
.tiocmset = serial_tiocmset,
.cleanup = serial_cleanup,
.install = serial_install,
.proc_fops = &serial_proc_fops,
};
写入时调用函数如下
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
看来是最终调用到
usb_wwan.c里面的usb_wwan_write(负责提交urb :usb_submit_urb)
在usb_serial_probe里面会初始化urb,比如初始化批量urb是usb_fill_bulk_urb(),其会指定回调函数,usb有数据到来的时候会激发这个函数。
具体就是usb_wwan.c的usb_wwan_outdat_callback和usb_wwan_indat_callback。usb core将从外界搞到的urb传递给call back函数。callbak再传递给对应的串口。
log
[root@root]# cd drivers/usb/serial/
[root@root]# insmod usbserial.ko
drivers/usb/serial/usb-serial.c,usb_serial_init,1261:
usbcore: registered new interface driver usbserial
drivers/usb/serial/generic.c,usb_serial_generic_register,92:
usbserial: USB Serial Driver core
[root@root]# insmod usb_wwan.ko
[root@root]#
[root@root]#
[root@root]# insmod option.ko
drivers/usb/serial/option.c,option_init,1084:
drivers/usb/serial/usb-serial.c,usb_serial_register,1383:
drivers/usb/serial/usb-serial.c,fixup_generic,1367:
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
[root@root]# pwd
/mnt/FriendlyArm/linux/linux-2.6.38/drivers/usb/serial
[root@root]#
[root@root]#
[root@root]# ls
3g_devices.c io_ti.h oti6858.h
ChangeLog.history io_ti.o oti6858.o
Kconfig io_usbvend.h pl2303.c
Makefile ipaq.c pl2303.h
Makefile-keyspan_pda_fw ipaq.o pl2303.o
aircable.c ipw.c qcaux.c
aircable.o ipw.o qcaux.o
ark3116.c ir-usb.c qcserial.c
ark3116.o ir-usb.o qcserial.o
belkin_sa.c iuu_phoenix.c safe_serial.c
belkin_sa.h iuu_phoenix.h safe_serial.o
belkin_sa.o iuu_phoenix.o sam-ba.c
built-in.o keyspan.c sam-ba.o
bus.c keyspan.h siemens_mpi.c
bus.o keyspan.o siemens_mpi.o
ch341.c keyspan_pda.c sierra.c
ch341.o keyspan_pda.o sierra.o
console.c keyspan_usa26msg.h spcp8x5.c
cp210x.c keyspan_usa28msg.h spcp8x5.o
cp210x.o keyspan_usa49msg.h ssu100.c
cyberjack.c keyspan_usa67msg.h ssu100.o
cyberjack.o keyspan_usa90msg.h symbolserial.c
cypress_m8.c kl5kusb105.c symbolserial.o
cypress_m8.h kl5kusb105.h ti_usb_3410_5052.c
cypress_m8.o kl5kusb105.o ti_usb_3410_5052.h
digi_acceleport.c kobil_sct.c ti_usb_3410_5052.o
digi_acceleport.o kobil_sct.h usb-serial.c
empeg.c kobil_sct.o usb-serial.o
empeg.o mct_u232.c usb-wwan.h
ezusb.c mct_u232.h usb_debug.c
ezusb.o mct_u232.o usb_debug.o
ezusb_convert.pl modules.builtin usb_wwan.c
ftdi_sio.c modules.order usb_wwan.ko
ftdi_sio.h mos7720.c usb_wwan.mod.c
ftdi_sio.o mos7720.o usb_wwan.mod.o
ftdi_sio_ids.h mos7840.c usb_wwan.o
funsoft.c mos7840.o usbserial.ko
funsoft.o moto_modem.c usbserial.mod.c
garmin_gps.c moto_modem.o usbserial.mod.o
garmin_gps.o navman.c usbserial.o
generic.c navman.o visor.c
generic.o omninet.c visor.h
hp4x.c omninet.o visor.o
hp4x.o opticon.c vivopay-serial.c
io_16654.h opticon.o vivopay-serial.o
io_edgeport.c option.c whiteheat.c
io_edgeport.h option.ko whiteheat.h
io_edgeport.o option.mod.c whiteheat.o
io_ionsp.h option.mod.o zio.c
io_tables.h option.o zio.o
io_ti.c oti6858.c
[root@root]#
[root@root]# usb 1-1.3: usbfs: process 919 (3g-modem) did not claim interface 0 before use
usb 1-1.3: USB disconnect, address 3
usb 1-1.3: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.3: New USB device found, idVendor=12d1, idProduct=140c
usb 1-1.3: New USB device strings: Mfr=3, Product=2, SerialNumber=0
usb 1-1.3: Product: HUAWEI Mobile
usb 1-1.3: Manufacturer: HUAWEI Technology
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.0: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/option.c,option_instat_callback,1174:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.1: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.2: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB2
drivers/usb/serial/usb-serial.c,usb_serial_probe,749:
drivers/usb/serial/usb-serial.c,search_serial_device,705:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/usb-serial.c,create_serial,648:
drivers/usb/serial/usb-serial.c,get_iface_id,686:
drivers/usb/serial/option.c,option_probe,1117:
option 1-1.3:1.3: GSM modem (1-port) converter detected
drivers/usb/serial/usb_wwan.c,usb_wwan_startup,549:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urbs,507:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb_wwan.c,usb_wwan_setup_urb,484:
drivers/usb/serial/usb-serial.c,get_free_serial,100:
usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB3
scsi6 : usb-storage 1-1.3:1.4
scsi7 : usb-storage 1-1.3:1.5
drivers/usb/serial/option.c,option_instat_callback,1174:
drivers/usb/serial/option.c,option_instat_callback,1174:
scsi 6:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
scsi 7:0:0:0: Direct-Access HUAWEI SD Storage 2.31 PQ: 0 ANSI: 2
scsi 6:0:0:0: Attached scsi generic sg0 type 5
sd 7:0:0:0: Attached scsi generic sg1 type 0
sd 7:0:0:0: [sda] Attached SCSI removable disk
[root@root]#
[root@root]# ls /dev/ttyUSB*
/dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3
[root@root]# echo at >/dev/ttyUSB0
drivers/usb/serial/usb-serial.c,serial_install,206:
drivers/usb/serial/usb-serial.c,usb_serial_get_by_index,78:
drivers/usb/serial/usb-serial.c,serial_open,276:
drivers/usb/serial/usb-serial.c,serial_activate,259:
drivers/usb/serial/usb_wwan.c,usb_wwan_open,413:
drivers/usb/serial/option.c,option_send_setup,1236:
drivers/usb/serial/option.c,is_blacklisted,1157:
drivers/usb/serial/usb-serial.c,serial_dtr_rts,732:
drivers/usb/serial/usb_wwan.c,usb_wwan_dtr_rts,45:
drivers/usb/serial/option.c,option_send_setup,1236:
drivers/usb/serial/option.c,is_blacklisted,1157:
drivers/usb/serial/usb-serial.c,serial_carrier_raised,721:
drivers/usb/serial/usb-serial.c,serial_open,276:
drivers/usb/serial/usb-serial.c,serial_dtr_rts,732:
drivers/usb/serial/usb_wwan.c,usb_wwan_dtr_rts,45:
drivers/usb/serial/option.c,option_send_setup,1236:
drivers/usb/serial/option.c,is_blacklisted,1157:
drivers/usb/serial/usb-serial.c,serial_carrier_raised,721:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb-serial.c,usb_serial_port_work,574:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_close,318:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_indat_callback,291:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368:
drivers/usb/serial/usb-serial.c,serial_write,366:
drivers/usb/serial/usb_wwan.c,usb_wwan_write,217:
drivers/usb/serial/usb-serial.c,serial_write_room,384:
drivers/usb/serial/usb_wwan.c,usb_wwan_outdat_callback,339:
drivers/usb/serial/usb-serial.c,usb_serial_port_softint,567:
drivers/usb/serial/usb_wwan.c,usb_wwan_write_room,368: