From e87760183df0d7e07533e3361041620617389429 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 3 Jul 2020 11:29:25 +0100 Subject: [PATCH] [usb] Avoid unnecessary calls to usb_hub_set_drvdata() The driver-private data for root hubs is already set immediately after allocating the USB bus. There seems to be no reason to set it again when opening the root hub. Signed-off-by: Michael Brown --- src/drivers/usb/ehci.c | 9 +-------- src/drivers/usb/uhci.c | 13 ++++--------- src/drivers/usb/xhci.c | 11 +++-------- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index cd3967070..29c32b356 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -1552,8 +1552,7 @@ static void ehci_hub_close ( struct usb_hub *hub __unused ) { * @ret rc Return status code */ static int ehci_root_open ( struct usb_hub *hub ) { - struct usb_bus *bus = hub->bus; - struct ehci_device *ehci = usb_bus_get_hostdata ( bus ); + struct ehci_device *ehci = usb_hub_get_drvdata ( hub ); uint32_t portsc; unsigned int i; @@ -1571,9 +1570,6 @@ static int ehci_root_open ( struct usb_hub *hub ) { /* Wait 20ms after potentially enabling power to a port */ mdelay ( EHCI_PORT_POWER_DELAY_MS ); - /* Record hub driver private data */ - usb_hub_set_drvdata ( hub, ehci ); - return 0; } @@ -1587,9 +1583,6 @@ static void ehci_root_close ( struct usb_hub *hub ) { /* Route all ports back to companion controllers */ writel ( 0, ehci->op + EHCI_OP_CONFIGFLAG ); - - /* Clear hub driver private data */ - usb_hub_set_drvdata ( hub, NULL ); } /** diff --git a/src/drivers/usb/uhci.c b/src/drivers/usb/uhci.c index 528c1be1d..ce2962d36 100644 --- a/src/drivers/usb/uhci.c +++ b/src/drivers/usb/uhci.c @@ -1124,13 +1124,9 @@ static void uhci_hub_close ( struct usb_hub *hub __unused ) { * @v hub USB hub * @ret rc Return status code */ -static int uhci_root_open ( struct usb_hub *hub ) { - struct usb_bus *bus = hub->bus; - struct uhci_device *uhci = usb_bus_get_hostdata ( bus ); - - /* Record hub driver private data */ - usb_hub_set_drvdata ( hub, uhci ); +static int uhci_root_open ( struct usb_hub *hub __unused) { + /* Nothing to do */ return 0; } @@ -1139,10 +1135,9 @@ static int uhci_root_open ( struct usb_hub *hub ) { * * @v hub USB hub */ -static void uhci_root_close ( struct usb_hub *hub ) { +static void uhci_root_close ( struct usb_hub *hub __unused ) { - /* Clear hub driver private data */ - usb_hub_set_drvdata ( hub, NULL ); + /* Nothing to do */ } /** diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index 21c3e0001..aa6ca73c4 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -2944,8 +2944,7 @@ static void xhci_hub_close ( struct usb_hub *hub __unused ) { * @ret rc Return status code */ static int xhci_root_open ( struct usb_hub *hub ) { - struct usb_bus *bus = hub->bus; - struct xhci_device *xhci = usb_bus_get_hostdata ( bus ); + struct xhci_device *xhci = usb_hub_get_drvdata ( hub ); struct usb_port *port; uint32_t portsc; unsigned int i; @@ -2982,9 +2981,6 @@ static int xhci_root_open ( struct usb_hub *hub ) { */ mdelay ( XHCI_LINK_STATE_DELAY_MS ); - /* Record hub driver private data */ - usb_hub_set_drvdata ( hub, xhci ); - return 0; } @@ -2993,10 +2989,9 @@ static int xhci_root_open ( struct usb_hub *hub ) { * * @v hub USB hub */ -static void xhci_root_close ( struct usb_hub *hub ) { +static void xhci_root_close ( struct usb_hub *hub __unused ) { - /* Clear hub driver private data */ - usb_hub_set_drvdata ( hub, NULL ); + /* Nothing to do */ } /** -- 2.47.2