/* Change the last TRB in the prev segment to be a Link TRB which points to the DMA address of the next segment. The caller needs to set any Link TRB related flags, such as End TRB, Toggle Cycle, and no snoop.  */
static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, struct xhci_segment *next, bool link_trbs)
/* Change the last TRB in the prev segment to be a Link TRB which points to the DMA address of the next segment. The caller needs to set any Link TRB related flags, such as End TRB, Toggle Cycle, and no snoop.  */
static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, struct xhci_segment *next, bool link_trbs)
{
	u32 val;
	if (!prev || !next)
		return;
	prev->next = next;
	if (link_trbs) {
		prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = next->dma;
		val = prev->trbs[TRBS_PER_SEGMENT-1].link.control;
		val &= ~TRB_TYPE_BITMASK;
		val |= TRB_TYPE(TRB_LINK);
		if (xhci_link_trb_quirk(xhci))
			val |= TRB_CHAIN;
		prev->trbs[TRBS_PER_SEGMENT-1].link.control = val;
	}
	xhci_dbg(xhci, "Linking segment 0x%llx to segment 0x%llx (DMA)\n",
			(unsigned long long)prev->dma,
			(unsigned long long)next->dma);
}