Re: Question about struct usb_hub

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Wed, 4 Jul 2007, jidong xiao wrote:

> 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?

Look again.  In the first snippet i ranges from 0 to bNbrPorts-1, and
in the second snippet i ranges from 1 to bNbrPorts.  So the
test_and_clear_bit calls do the same thing.

> 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?

Both bits get cleared.  Look in hub_port_connect_change() to see where 
change_bits is reset.

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/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.