Skip to contentSkip to conversation

usb: host: xhci: check DYING state earlier

PATCH New Felipe Balbi 1 participant 1 message Apr 17, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 2/20 usb: host: xhci: check DYING state earlier

Hi,

Quoted 9 lines · Mathias Nyman
Quoted 3 lines · Felipe Balbi

Instead of allocating urb priv and, maybe, bail out due to xhci being in DYING state, we can move the check earlier and avoid the memory allocation altogether.

This also moves checking for DYING outside the lock.

Most cases set DYING with lock held, so if we first get the lock before checking DYING we have a better chance of not being in the process of dying.

pretty sure that's atomic, though.

Quoted 1 line

Small thing, but so is this cleanup, so not sure its worth the change

Look at the result. With this change we don't need to take a lock, allocate memory, search for endpoint index, search for endpoint state. All of those are needed for proper operation of the function, but if the controller has already died, there's no point in going any further.