Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: cdnsp: Fixes for sparse warnings

Patch fixes all sparse warnings in cdsnp driver.

It fixes the following warnings:
cdnsp-ring.c:1441: warning: incorrect type in assignment
cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
cdnsp-ring.c:2200: warning: dubious: x | !y
cdnsp-gadget.c:501: warning: incorrect type in assignment
cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:509: warning: invalid assignment: |=
cdnsp-gadget.c:510: warning: cast from restricted __le32
cdnsp-gadget.c:558: warning: incorrect type in assignment
cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:1571: warning: incorrect type in argument 1
cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:1760: warning: incorrect type in assignment
cdnsp-gadget.c:1762: warning: incorrect type in assignment
cdnsp-gadget.c:1763: warning: incorrect type in assignment
cdnsp-gadget.c:1764: warning: incorrect type in assignment
cdnsp-gadget.c:1765: warning: incorrect type in assignment
cdnsp-gadget.c:1766: warning: incorrect type in assignment
cdnsp-gadget.c:1767: warning: incorrect type in assignment
cdnsp-gadget.c:458: warning: cast truncates bits from constant value
(ffffffff07ffffff becomes 7ffffff)
cdnsp-gadget.c:666: warning: cast truncates bits from constant value
(ffffffff07ffffff becomes 7ffffff)
cdnsp-mem.c:762: warning: incorrect type in assignment
cdnsp-mem.c:763: warning: incorrect type in assignment
cdnsp-mem.c:928: warning: cast from restricted __le16
cdnsp-mem.c:1187: warning: incorrect type in assignment
cdnsp-mem.c:1191: warning: incorrect type in assignment
cdnsp-ep0.c:142: warning: incorrect type in assignment
cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:179: warning: incorrect type in argument 1
cdnsp-ep0.c:311: warning: incorrect type in argument 1
cdnsp-ep0.c:469: warning: incorrect type in assignment
cdnsp-trace.h:611:1: warning: cast from restricted __le32

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>

authored by

Pawel Laszczak and committed by
Peter Chen
16e36101 fba8701b

+32 -37
+1 -1
drivers/usb/cdns3/cdnsp-debug.h
··· 414 414 s = "UNKNOWN speed"; 415 415 } 416 416 417 - ret = sprintf(str, "%s Ctx Entries %ld", 417 + ret = sprintf(str, "%s Ctx Entries %d", 418 418 s, (info & LAST_CTX_MASK) >> 27); 419 419 420 420 ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
+6 -7
drivers/usb/cdns3/cdnsp-ep0.c
··· 137 137 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq); 138 138 } 139 139 140 - static int cdnsp_w_index_to_ep_index(__le32 wIndex) 140 + static int cdnsp_w_index_to_ep_index(u16 wIndex) 141 141 { 142 - wIndex = le32_to_cpu(wIndex); 143 - 144 142 if (!(wIndex & USB_ENDPOINT_NUMBER_MASK)) 145 143 return 0; 146 144 ··· 174 176 */ 175 177 return cdnsp_ep0_delegate_req(pdev, ctrl); 176 178 case USB_RECIP_ENDPOINT: 177 - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)]; 179 + ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex)); 180 + pep = &pdev->eps[ep_sts]; 178 181 ep_sts = GET_EP_CTX_STATE(pep->out_ctx); 179 182 180 183 /* check if endpoint is stalled */ ··· 304 305 int set) 305 306 { 306 307 struct cdnsp_ep *pep; 307 - u32 wValue; 308 + u16 wValue; 308 309 309 310 wValue = le16_to_cpu(ctrl->wValue); 310 - pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)]; 311 + pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))]; 311 312 312 313 switch (wValue) { 313 314 case USB_ENDPOINT_HALT: ··· 434 435 { 435 436 struct usb_ctrlrequest *ctrl = &pdev->setup; 436 437 int ret = 0; 437 - __le16 len; 438 + u16 len; 438 439 439 440 trace_cdnsp_ctrl_req(ctrl); 440 441
+9 -15
drivers/usb/cdns3/cdnsp-gadget.c
··· 491 491 struct cdnsp_segment *segment; 492 492 union cdnsp_trb *event; 493 493 u32 cycle_state; 494 - __le32 data; 494 + u32 data; 495 495 496 496 event = pdev->event_ring->dequeue; 497 497 segment = pdev->event_ring->deq_seg; ··· 527 527 dma_addr_t cmd_deq_dma; 528 528 union cdnsp_trb *event; 529 529 u32 cycle_state; 530 - __le32 flags; 531 530 int ret, val; 532 531 u64 cmd_dma; 532 + u32 flags; 533 533 534 534 cmd_trb = pdev->cmd.command_trb; 535 535 pdev->cmd.status = 0; ··· 1568 1568 return; 1569 1569 } 1570 1570 1571 - endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2; 1571 + endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2; 1572 1572 1573 1573 /* Set to XBUF_TX_TAG_MASK_0 register. */ 1574 1574 reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32); ··· 1754 1754 static void cdnsp_get_rev_cap(struct cdnsp_device *pdev) 1755 1755 { 1756 1756 void __iomem *reg = &pdev->cap_regs->hc_capbase; 1757 - struct cdnsp_rev_cap *rev_cap; 1758 1757 1759 1758 reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP); 1760 - rev_cap = reg; 1761 - 1762 - pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision); 1763 - pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision); 1764 - pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported); 1765 - pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap); 1766 - pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size); 1767 - pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size); 1759 + pdev->rev_cap = reg; 1768 1760 1769 1761 dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n", 1770 - pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision, 1771 - pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size, 1772 - pdev->rev_cap.tx_buff_size); 1762 + readl(&pdev->rev_cap->ctrl_revision), 1763 + readl(&pdev->rev_cap->rtl_revision), 1764 + readl(&pdev->rev_cap->ep_supported), 1765 + readl(&pdev->rev_cap->rx_buff_size), 1766 + readl(&pdev->rev_cap->tx_buff_size)); 1773 1767 } 1774 1768 1775 1769 static int cdnsp_gen_setup(struct cdnsp_device *pdev)
+7 -6
drivers/usb/cdns3/cdnsp-gadget.h
··· 493 493 #define CDNSP_VER_1 0x00000000 494 494 #define CDNSP_VER_2 0x10000000 495 495 496 - #define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \ 497 - (BIT(ep_num) << ((dir) ? 0 : 16))) 496 + #define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \ 497 + (readl(&(pdev)->rev_cap->ep_supported) & \ 498 + (BIT(ep_num) << ((dir) ? 0 : 16))) 498 499 499 500 /** 500 - * struct cdnsp_rev_cap - controller capabilities . 501 + * struct cdnsp_rev_cap - controller capabilities. 501 502 * @ext_cap: Header for RTL Revision Extended Capability. 502 503 * @rtl_revision: RTL revision. 503 504 * @rx_buff_size: Rx buffer sizes. ··· 595 594 #define DEV_SPEED GENMASK(23, 20) 596 595 #define GET_DEV_SPEED(n) (((n) & DEV_SPEED) >> 20) 597 596 /* Index of the last valid endpoint context in this device context - 27:31. */ 598 - #define LAST_CTX_MASK GENMASK(31, 27) 597 + #define LAST_CTX_MASK ((unsigned int)GENMASK(31, 27)) 599 598 #define LAST_CTX(p) ((p) << 27) 600 599 #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1) 601 600 #define SLOT_FLAG BIT(0) ··· 1352 1351 * @ir_set: Current interrupter register set. 1353 1352 * @port20_regs: Port 2.0 Peripheral Configuration Registers. 1354 1353 * @port3x_regs: USB3.x Port Peripheral Configuration Registers. 1354 + * @rev_cap: Controller Capabilities Registers. 1355 1355 * @hcs_params1: Cached register copies of read-only HCSPARAMS1 1356 1356 * @hcc_params: Cached register copies of read-only HCCPARAMS1 1357 - * @rev_cap: Controller capability. 1358 1357 * @setup: Temporary buffer for setup packet. 1359 1358 * @ep0_preq: Internal allocated request used during enumeration. 1360 1359 * @ep0_stage: ep0 stage during enumeration process. ··· 1403 1402 struct cdnsp_intr_reg __iomem *ir_set; 1404 1403 struct cdnsp_20port_cap __iomem *port20_regs; 1405 1404 struct cdnsp_3xport_cap __iomem *port3x_regs; 1405 + struct cdnsp_rev_cap __iomem *rev_cap; 1406 1406 1407 1407 /* Cached register copies of read-only CDNSP data */ 1408 1408 __u32 hcs_params1; 1409 1409 __u32 hcs_params3; 1410 1410 __u32 hcc_params; 1411 - struct cdnsp_rev_cap rev_cap; 1412 1411 /* Lock used in interrupt thread context. */ 1413 1412 spinlock_t lock; 1414 1413 struct usb_ctrlrequest setup;
+6 -5
drivers/usb/cdns3/cdnsp-mem.c
··· 759 759 760 760 port = DEV_PORT(pdev->active_port->port_num); 761 761 slot_ctx->dev_port |= cpu_to_le32(port); 762 - slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK); 763 - ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8); 762 + slot_ctx->dev_state = cpu_to_le32((pdev->device_address & 763 + DEV_ADDR_MASK)); 764 + ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8)); 764 765 ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP)); 765 766 ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) | 766 767 max_packets); ··· 926 925 /* SuperSpeedPlus Isoc ep sending over 48k per EIST. */ 927 926 if (g->speed >= USB_SPEED_SUPER_PLUS && 928 927 USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes)) 929 - return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval); 928 + return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval); 930 929 /* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */ 931 930 else if (g->speed >= USB_SPEED_SUPER) 932 931 return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval); ··· 1185 1184 1186 1185 trace_cdnsp_init("Found USB 2.0 ports and USB 3.0 ports."); 1187 1186 1188 - pdev->usb2_port.regs = (struct cdnsp_port_regs *) 1187 + pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *) 1189 1188 (&pdev->op_regs->port_reg_base + NUM_PORT_REGS * 1190 1189 (pdev->usb2_port.port_num - 1)); 1191 1190 1192 - pdev->usb3_port.regs = (struct cdnsp_port_regs *) 1191 + pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *) 1193 1192 (&pdev->op_regs->port_reg_base + NUM_PORT_REGS * 1194 1193 (pdev->usb3_port.port_num - 1)); 1195 1194
+2 -2
drivers/usb/cdns3/cdnsp-ring.c
··· 1432 1432 unsigned int comp_code; 1433 1433 union cdnsp_trb *event; 1434 1434 bool update_ptrs = true; 1435 - __le32 cycle_bit; 1435 + u32 cycle_bit; 1436 1436 int ret = 0; 1437 1437 u32 flags; 1438 1438 ··· 2198 2198 * inverted in the first TDs isoc TRB. 2199 2199 */ 2200 2200 field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) | 2201 - !start_cycle | TRB_SIA | TRB_TBC(burst_count); 2201 + start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count); 2202 2202 2203 2203 /* Fill the rest of the TRB fields, and remaining normal TRBs. */ 2204 2204 for (i = 0; i < trbs_per_td; i++) {
+1 -1
drivers/usb/cdns3/cdnsp-trace.h
··· 620 620 TP_fast_assign( 621 621 __entry->info = le32_to_cpu(ctx->dev_info); 622 622 __entry->info2 = le32_to_cpu(ctx->dev_port); 623 - __entry->int_target = le64_to_cpu(ctx->int_target); 623 + __entry->int_target = le32_to_cpu(ctx->int_target); 624 624 __entry->state = le32_to_cpu(ctx->dev_state); 625 625 ), 626 626 TP_printk("%s", cdnsp_decode_slot_context(__entry->info,