]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: xhci: convert to TRB_LEN() and TRB_INTR_TARGET()
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Tue, 8 Sep 2020 17:00:00 +0000 (19:00 +0200)
committerMarek Vasut <marex@denx.de>
Thu, 1 Oct 2020 17:43:05 +0000 (19:43 +0200)
For normal TRB fields:
use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK);
and use TRB_INTR_TARGET(x) instead of
(((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/usb/host/xhci-ring.c
include/usb/xhci.h

index 13c98fb09a7d513a126371e2f9c723e4b46d5392..9ef72efe9598001910d55bc77847c0755546828a 100644 (file)
@@ -688,10 +688,9 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe,
                                              length, maxpacketsize,
                                              more_trbs_coming);
 
-               length_field = ((trb_buff_len & TRB_LEN_MASK) |
+               length_field = (TRB_LEN(trb_buff_len) |
                                TRB_TD_SIZE(remainder) |
-                               ((0 & TRB_INTR_TARGET_MASK) <<
-                               TRB_INTR_TARGET_SHIFT));
+                               TRB_INTR_TARGET(0));
 
                trb_fields[0] = lower_32_bits(addr);
                trb_fields[1] = upper_32_bits(addr);
@@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
        trb_fields[1] = le16_to_cpu(req->index) |
                        le16_to_cpu(req->length) << 16;
        /* TRB_LEN | (TRB_INTR_TARGET) */
-       trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) <<
-                       TRB_INTR_TARGET_SHIFT));
+       trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0));
        /* Immediate data in pointer */
        trb_fields[3] = field;
        queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -866,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 
        remainder = xhci_td_remainder(ctrl, 0, length, length,
                                      usb_maxpacket(udev, pipe), true);
-       length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
-                       ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+       length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) |
+                      TRB_INTR_TARGET(0);
        debug("length_field = %d, length = %d,"
                "xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
-               length_field, (length & TRB_LEN_MASK),
+               length_field, TRB_LEN(length),
                TRB_TD_SIZE(remainder), 0);
 
        if (length > 0) {
@@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 
        trb_fields[0] = 0;
        trb_fields[1] = 0;
-       trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+       trb_fields[2] = TRB_INTR_TARGET(0);
                /* Event on completion */
        trb_fields[3] = field | TRB_IOC |
                        TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
index bdba51df599f8fcf589f8966b397984fd8ea741d..35c66042baa166411124a6187ca7e67e6f4d6fa1 100644 (file)
@@ -847,12 +847,9 @@ struct xhci_event_cmd {
 /* Normal TRB fields */
 /* transfer_len bitmasks - bits 0:16 */
 #define        TRB_LEN(p)                      ((p) & 0x1ffff)
-#define        TRB_LEN_MASK                    (0x1ffff)
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)          (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-#define        TRB_INTR_TARGET_SHIFT           (22)
-#define        TRB_INTR_TARGET_MASK            (0x3ff)
 #define TRB_INTR_TARGET(p)             (((p) & 0x3ff) << 22)
 #define GET_INTR_TARGET(p)             (((p) >> 22) & 0x3ff)
 #define TRB_TBC(p)                     (((p) & 0x3) << 7)