Skip to contentSkip to conversation

USB hub_probe: put initialization before usage

PATCH Superseded Eugene Korenevsky 2 participants 2 messages Nov 7, 2016 – Nov 8, 2016 USB

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 USB hub_probe: put initialization before usage

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

---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/hub.c +1 -1
index 7a20980..c7f6b5f 100644
@@ -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;
Signature · 1 line
2.10.2
#1 lore raw
Quoted 2 lines · Eugene Korenevsky

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