Re: some questions about usb_serial_probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi:

2012/7/18 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> On Wed, 18 Jul 2012, loody wrote:
>
>> hi all:
>>
>> 2012/7/18 loody <miloody@xxxxxxxxx>:
>> > hi:
>> >
>> > 2012/7/18 Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>:
>> >> On Wed, Jul 18, 2012 at 11:22:49AM +0800, loody wrote:
>> >>> Dear all:
>> >>> in usb_serial_probe, we create tty_port based on max_endpoints.
>> >>
>> >> Or based on the number that the driver said to create.
>> >>
>> >>> My questions are:
>> >>> 1. some callback functions, such serial_hangup, serial_carrier_raised,
>> >>> etc. will called by tty layer with different tty_ports.
>> >>> how tty layer know these tty_ports?
>> >>
>> >> They were registered with the tty layer.
>> >>
>> >>> I only found tty_port_init to initial these tty_ports, but where we
>> >>> register these tty_ports to tty layer?
>> >>
>> >> When we register the tty device.
>> > Would you mind to tell me which function it is?
>> after tracing source code, usb_serial_device_probe seems where we
>> register tty device.
>> But we only let tty know, tty_driver, index and struct device.
>> it seems we don't let tty know how many tty_ports we created.
>> Thanks for your help in advance,
>
> You didn't look at usb_serial_probe.  At the end of that function there
I found what you mentioned.
	for (i = 0; i < num_ports; ++i) {
................
		retval = device_add(&port->dev);
...................
> is a loop which runs over all the ports and registers them one at a
> time with the device layer.  When it is registered, the port is passed
> to usb_serial_device_probe, which then registers the port with the tty
> layer.
The port we pass to usb_serial_device_probe are usb_serial_port
instead of tty_port, we get it through "to_usb_serial_port(dev);"

in usb_serial_device_probe, it do following things.
1. try to call port_probe, which seems do some control for usb_port
instead of tty port.
2. calling device_create_file(dev, &dev_attr_port_number);
    dev in above function is embedded in usb_port not in tty_port.
3. tty_register_device(usb_serial_tty_driver, minor, dev); this is
most likely where we register tty port.
but all three parameters have no relations to tty port.

if above flow is correct, how tty layer know how many tty_ports this
usb device have?

appreciate your help,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux