Web lists-archives.com

Re: [linux-usb-devel] Question about struct usb_hub




On Tue, 3 Jul 2007, jidong xiao wrote:

> What's the difference between event_bits and change_bits?
> I just cannot understand why we need two variables.
> 
> 
>     188 struct usb_hub {
>     ...
>     205         unsigned long           event_bits[1];  /* status
> change bitmask */
>     206         unsigned long           change_bits[1]; /* ports with
> logical connect
>     207                                                         status change */
> 
> Take following section for example,inside hub_events() sampled from
> drivers/usb/core/hub.c:
> 
>    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;
> 
> Why do we need to test changes_bits and then test event_bits?

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@xxxxxxxxxxxxxxxxxxxxx
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel