Hi Johann,
thanks for your reply. Surelly I understand what the codes > > return !!*buf; literally mean. What I would like to know is, what does it suppose to do in context of USB layer. If one follows the USB codes, then one will see that this "uhci_hub_status_data" will be called by rh_report_status() in usb/core/hcd.c as shown below: /* timer callback */ static void rh_report_status (unsigned long ptr) { ... if (HCD_IS_RUNNING (hcd->state)) { length = hcd->driver->hub_status_data (hcd, urb->transfer_buffer); spin_unlock_irqrestore (&urb->lock, flags); if (length > 0) { urb->actual_length = length; urb->status = 0; urb->complete (urb); } spin_lock_irqsave (&hcd_data_lock, flags); urb->status = -EINPROGRESS; ... } As far as I can understand from UHCI Specs, this following line will query the enabled/disabled status of UHCI ports: > > *buf |= ((inw(io_addr + USBPORTSC1 + i * 2) & 0xa) > 0 ? (1 << (i >+ 1)) : 0); thus it is not an indication of the real "urb->actual_length". Maybe it is supposed to force "urb->complete(urb)" to be called on the ports' status changing. These kind of "not obvious" purposes seem sadly to be common in kernel sources. Little notes in code will be really helpful. Best regards, sE On Wed, 24 Jul 2002 10:47:12 +0200 "Johann Deneux" <[EMAIL PROTECTED]> wrote: > Soewono Effendi wrote: > > Hi all, > > > > > > I'm just curious if there is any particular reason to use the following code > > > > return !!*buf; > > > > instead of the simple > > > > return (int) *buf; > > > > This would be a trick to return 0 or 1. > Take for example *buf equal to 3. > !*buf -> !3 -> !(true) -> false -> 0 > !!*buf -> !0 -> 1 > > return !!*buf returns 1, while return (int) *buf returns 3; > > > in function "uhci_hub_status_data", file: usb/host/uhci-hub.c > > > > static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf) > > { > > struct uhci_hcd *uhci = hcd_to_uhci(hcd); > > unsigned int io_addr = uhci->io_addr; > > int i, len = 1; > > > > *buf = 0; > > for (i = 0; i < uhci->rh_numports; i++) { > > *buf |= ((inw(io_addr + USBPORTSC1 + i * 2) & 0xa) > 0 ? (1 << (i >+ 1)) : 0); > > len = (i + 1) / 8 + 1; > > } > > > > return !!*buf; > > } > > > > > > Little notes in code will be helpful. > > > > Best regards, > > sE > > > > > > -- > Johann Deneux ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel