Still consider following piece of code, I see there is a change in
this part of code,here showed the same part of code but came from
different kernel version,one is sampled from kernel 2.6.10,while
another is sampled from kernel 2.6.21.

inside hub_events() sampled from drivers/usb/core/hub.c, 2.6.10:

    2594                 /* deal with port status changes */
    2595                 for (i = 0; i < hub->descriptor->bNbrPorts; i++) {
    2596                         connect_change = test_bit(i, hub->change_bits);
    2597                         if (!test_and_clear_bit(i+1,
hub->event_bits) &&
    2598                                         !connect_change)
    2599                                 continue;

This is the same part of code but just picked up from 2.6.21.
   2682                 /* deal with port status changes */
   2683                 for (i = 1; i <= hub->descriptor->bNbrPorts; i++) {
   2684                         if (test_bit(i, hub->busy_bits))
   2685                                 continue;
   2686                         connect_change = test_bit(i, hub->change_bits);
   2687                         if (!test_and_clear_bit(i, hub->event_bits) &&
   2688                                         !connect_change &&
!hub->activating)
   2689                                 continue;

an interesting thing is, in the former one,we call
test_and_clear_bit(i+1, **), while in the latter one, we call
test_and_clear_bit(i, **),this change is somehow strange,is one of
them wrong?

additionally,I am wondering the reason, for the change_bits map, we
just test, for the event_bits,besides test,we also need to clear the
bit, why?

Thanks
Jason


>
> event_bits records which ports have their bits set in the hub's
> interrupt URB.  change_bits records the ports for which we want to
> force a disable and re-enumeration.
>
> Sometimes the core needs to act as though a device has disconnected
> even when it really hasn't.  That's what change_bits is for.
> event_bits, on the other hand, tells us about real connect and
> disconnect events.  So the driver has to check both bit-vectors.
>
> Alan Stern
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to