Re: [PATCH v6 5/8] usb: add usb port auto power off mechanism

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2013/1/23 1:18, Greg KH wrote:
On Wed, Jan 23, 2013 at 12:58:09AM +0800, Lan Tianyu wrote
The above line, as written is under 80 characters, so I don't understand
the issue.
If I do following, scripts/checkpatch.pl will complain over 80 characters.

@@ -3767,7 +3814,9 @@

                 if (!(portchange & USB_PORT_STAT_C_CONNECTION) &&
                      (portstatus & USB_PORT_STAT_CONNECTION) == connection) {
-                       stable_time += HUB_DEBOUNCE_STEP;
+                       if (!must_be_connected ||
+                                       (connection == USB_PORT_STAT_CONNECTION))
+                               stable_time += HUB_DEBOUNCE_STEP;
                         if (stable_time >= HUB_DEBOUNCE_STABLE)
                                 break;
                 } else {

WARNING: line over 80 characters
#203: FILE: drivers/usb/core/hub.c:3818:
+                                       (connection == USB_PORT_STAT_CONNECTION))

Of course, which is why I didn't say to do that :)

See above for where to line up the line with the previous one, showing
that it all can fit just fine within 80 characters.

Ok. I get it. learn one more trick. :)

Now I have two solutions. Which one do you think more readable?
@@ -3740,7 +3814,9 @@ static int hub_port_debounce(struct usb_hub *hub, int port1)

                if (!(portchange & USB_PORT_STAT_C_CONNECTION) &&
                     (portstatus & USB_PORT_STAT_CONNECTION) == connection) {
-                       stable_time += HUB_DEBOUNCE_STEP;
+                       if (!must_be_connected ||
+                                       (connection & USB_PORT_STAT_CONNECTION))
+                               stable_time += HUB_DEBOUNCE_STEP;
                        if (stable_time >= HUB_DEBOUNCE_STABLE)
                                break;


@@ -3740,7 +3814,9 @@ static int hub_port_debounce(struct usb_hub *hub, int port1)

                if (!(portchange & USB_PORT_STAT_C_CONNECTION) &&
                     (portstatus & USB_PORT_STAT_CONNECTION) == connection) {
-                       stable_time += HUB_DEBOUNCE_STEP;
+                       if (!must_be_connected ||
+                            (connection == USB_PORT_STAT_CONNECTION))
+                               stable_time += HUB_DEBOUNCE_STEP;
                        if (stable_time >= HUB_DEBOUNCE_STABLE)







If I use (connection & USB_PORT_STAT_CONNECTION)), that will be ok.
I am curious about that checkpatch.pl considers a space or tab as a character?

It understands the difference between tabs and spaces properly.

thanks,

greg k-h


--
Best Regards
Tianyu Lan
linux kernel enabling team
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux