On Fri, Aug 23, 2013 at 11:15:06AM +0300, Xenia Ragiadakou wrote: > This patch refactors the code in TRB_RESET_DEV switch case in > handle_cmd_completion() into a fuction named xhci_handle_cmd_reset_dev(). > > Here, in the original code, the slot id is retrieved by the command TRB. > Since this slot id matches the one in Slot ID field of the command completion > event, which is available, there is no need to determine it again.
So, this does more that just refactor the code, which is what your subject implies. Potentially, the host controller could put the wrong slot ID in the command completion event, one that doesn't match the slot ID in the command. That could cause a change in xHCI driver behavior, which is not what refactoring patches are supposed to do. Could you break this up into two patches? The first should convert the current code to using slot_id instead of digging it out of the command. The second should refactor the code. That way, if someone is looking for a patch that could have caused a problem with a reset device command, they won't immediately discard a "simple" refactoring patch. Sarah Sharp > Signed-off-by: Xenia Ragiadakou <burzalod...@gmail.com> > --- > drivers/usb/host/xhci-ring.c | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c > index f00d9ef..0f9863e 100644 > --- a/drivers/usb/host/xhci-ring.c > +++ b/drivers/usb/host/xhci-ring.c > @@ -1400,6 +1400,20 @@ static void xhci_handle_cmd_addr_dev(struct xhci_hcd > *xhci, int slot_id, > complete(&xhci->addr_dev); > } > > +static void xhci_handle_cmd_reset_dev(struct xhci_hcd *xhci, int slot_id, > + struct xhci_event_cmd *event) > +{ > + struct xhci_virt_device *virt_dev; > + > + xhci_dbg(xhci, "Completed reset device command.\n"); > + virt_dev = xhci->devs[slot_id]; > + if (virt_dev) > + handle_cmd_in_cmd_wait_list(xhci, virt_dev, event); > + else > + xhci_warn(xhci, "Reset device command completion " > + "for disabled slot %u\n", slot_id); > +} > + > static void handle_cmd_completion(struct xhci_hcd *xhci, > struct xhci_event_cmd *event) > { > @@ -1527,15 +1541,7 @@ bandwidth_change: > xhci_handle_cmd_reset_ep(xhci, event, xhci->cmd_ring->dequeue); > break; > case TRB_TYPE(TRB_RESET_DEV): > - xhci_dbg(xhci, "Completed reset device command.\n"); > - slot_id = TRB_TO_SLOT_ID( > - le32_to_cpu(xhci->cmd_ring->dequeue->generic.field[3])); > - virt_dev = xhci->devs[slot_id]; > - if (virt_dev) > - handle_cmd_in_cmd_wait_list(xhci, virt_dev, event); > - else > - xhci_warn(xhci, "Reset device command completion " > - "for disabled slot %u\n", slot_id); > + xhci_handle_cmd_reset_dev(xhci, slot_id, event); > break; > case TRB_TYPE(TRB_NEC_GET_FW): > if (!(xhci->quirks & XHCI_NEC_HOST)) { > -- > 1.8.3.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html