linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 2/2] USB hub_probe: put initialization before usage
@ 2016-11-07 18:55 Eugene Korenevsky
  2016-11-08  6:52 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Eugene Korenevsky @ 2016-11-07 18:55 UTC (permalink / raw)
  To: linux-kernel, linux-usb
  Cc: Greg Kroah-Hartman, Luiz Capitulino, Linus Torvalds,
	Chase Metzger, Alan Stern, Mathias Nyman, Lu Baolu,
	Oliver Neukum, Hans Yang

Minor optimization: move initialization immediately before usage.
This gives a chance for more accurate register allocation by the compiler.

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7a20980..c7f6b5f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1742,7 +1742,6 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_device *hdev;
 	struct usb_hub *hub;
 
-	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
 
 	/*
@@ -1813,6 +1812,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	}
 #endif
 
+	desc = intf->cur_altsetting;
 	if (!hub_check_descriptor_sanity(desc)) {
 		dev_err(&intf->dev, "bad descriptor, ignoring hub\n");
 		return -EIO;
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 2/2] USB hub_probe: put initialization before usage
  2016-11-07 18:55 [PATCH v3 2/2] USB hub_probe: put initialization before usage Eugene Korenevsky
@ 2016-11-08  6:52 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2016-11-08  6:52 UTC (permalink / raw)
  To: Eugene Korenevsky
  Cc: linux-kernel, linux-usb, Luiz Capitulino, Linus Torvalds,
	Chase Metzger, Alan Stern, Mathias Nyman, Lu Baolu,
	Oliver Neukum, Hans Yang

On Mon, Nov 07, 2016 at 09:55:09PM +0300, Eugene Korenevsky wrote:
> Minor optimization: move initialization immediately before usage.
> This gives a chance for more accurate register allocation by the compiler.

This is a probe function, a very slow path.  Don't do micro
optimizations where they are not needed, or can not be actually
measured.

Also please just cc: the needed mailing list and maintainer for the
patch, don't go overboard for such tiny stuff.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-08  6:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07 18:55 [PATCH v3 2/2] USB hub_probe: put initialization before usage Eugene Korenevsky
2016-11-08  6:52 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).