Hi Nathael,
Am Mittwoch, den 24.01.2007, 13:01 +0100 schrieb Nathael Pajani:
> Hi!
>
> I found a bug in the USB core (present in linux-2.6.20-rc5-git2 with your
> patch
> >from http://kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/:
> gregkh-03-usb-2.6.20-rc5-git2.patch )
>
> in the core/driver.c file, function store_new_id()
> the problem comes from the call to list_add_tail() which is done as
> list_add_tail(head, new) instead of list_add_tail(new, head)
>
> This is OK for the first inclusion, but not for the second, and any following
> ones, because previously added entries are no more referenced.
> This also creates a memory leak (we loose the reference to the alocated
> memory).
> See attached patch.
Ouch, didn't see this one.
(Note: i re-posted the original patches from gregkh, so this is probably
my mistake. I didn't test it with more than one id per driver :-( )
> I'm actually working on dynamic ids for a serial driver (using the generic
> part
> for all but the new features, which are dynamic ids and static allocation of
> ttyUSB numbers depending on geographic position on USB bus.)
>
> I saw the modifications you made for dynamic ids in usb-serial, but why not
> exporting usb_match_dynamic_id() from core/driver.c instead of rewriting it
> in
> serial/usb-serial.c
>
> I know usb_match_dynamic_id() needs a usb_driver and not a usb_serial_driver,
> but the usb_serial_driver struct now contain a pointer to a usb_driver.
> Using this would enable the new serial driver to create it's usb_driver
> struct
> with ".no_dynamic_id = 0," and update this pointer (I did not check what it
> is
> used for yet, but I think this is the goal).
> This creates the sysfs new_id file automatically, and ids added with this
> file
> are then seen by the usb-serial.
>
> Another way should be to call the probe function registered in the
> usb_serial_driver struct, and let the device do the matching.
The problem by adding the new_id to the usb_driver is, that more than
one usb_serial_driver can point to the same usb_driver. For example,
when you look at the edgeport device tables, in io_tables.h, there are
different devices for different port counts, but the usb_driver is the
same.
To let the usb serial driver select the correct usb_serial_driver when
a new device is added it isn't enough to now the usb_driver but also to
now the usb_serial_driver.
To solve this the new_id is added under the serial driver directory at:
/sys/bus/usb-serial/drivers/<driver>/new_id
When a new id is added to this file, it is automatically added to the
corresponding usb_driver, thats why the pointer form usb_serial_driver
is added to the usb_driver.
Another possible solution is to dump the usb_serial _bus_ entirely and
use normal tty Devices and for each usb_serial_driver exactly one
usb_driver. But this is a very big change.
Yours sincerely,
Johannes Hölzl
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel