Unverified Commit 16e36101 authored by Pawel Laszczak's avatar Pawel Laszczak Committed by Peter Chen
Browse files

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: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarPawel Laszczak <pawell@cadence.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
parent fba8701b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -414,7 +414,7 @@ static inline const char *cdnsp_decode_slot_context(u32 info, u32 info2,
		s = "UNKNOWN speed";
	}

	ret = sprintf(str, "%s Ctx Entries %ld",
	ret = sprintf(str, "%s Ctx Entries %d",
		      s, (info & LAST_CTX_MASK) >> 27);

	ret += sprintf(str + ret, " [Intr %ld] Addr %ld State %s",
+6 −7
Original line number Diff line number Diff line
@@ -137,10 +137,8 @@ int cdnsp_status_stage(struct cdnsp_device *pdev)
	return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
}

static int cdnsp_w_index_to_ep_index(__le32  wIndex)
static int cdnsp_w_index_to_ep_index(u16 wIndex)
{
	wIndex = le32_to_cpu(wIndex);

	if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
		return 0;

@@ -176,7 +174,8 @@ static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,
		 */
		return cdnsp_ep0_delegate_req(pdev, ctrl);
	case USB_RECIP_ENDPOINT:
		pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
		ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
		pep = &pdev->eps[ep_sts];
		ep_sts = GET_EP_CTX_STATE(pep->out_ctx);

		/* check if endpoint is stalled */
@@ -305,10 +304,10 @@ static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
					     int set)
{
	struct cdnsp_ep *pep;
	u32 wValue;
	u16 wValue;

	wValue = le16_to_cpu(ctrl->wValue);
	pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
	pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];

	switch (wValue) {
	case USB_ENDPOINT_HALT:
@@ -435,7 +434,7 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
{
	struct usb_ctrlrequest *ctrl = &pdev->setup;
	int ret = 0;
	__le16 len;
	u16 len;

	trace_cdnsp_ctrl_req(ctrl);

+9 −15
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ static void cdnsp_invalidate_ep_events(struct cdnsp_device *pdev,
	struct cdnsp_segment *segment;
	union cdnsp_trb *event;
	u32 cycle_state;
	__le32  data;
	u32  data;

	event = pdev->event_ring->dequeue;
	segment = pdev->event_ring->deq_seg;
@@ -527,9 +527,9 @@ int cdnsp_wait_for_cmd_compl(struct cdnsp_device *pdev)
	dma_addr_t cmd_deq_dma;
	union cdnsp_trb *event;
	u32 cycle_state;
	__le32  flags;
	int ret, val;
	u64 cmd_dma;
	u32  flags;

	cmd_trb = pdev->cmd.command_trb;
	pdev->cmd.status = 0;
@@ -1568,7 +1568,7 @@ static void cdnsp_get_ep_buffering(struct cdnsp_device *pdev,
		return;
	}

	endpoints = HCS_ENDPOINTS(readl(&pdev->hcs_params1)) / 2;
	endpoints = HCS_ENDPOINTS(pdev->hcs_params1) / 2;

	/* Set to XBUF_TX_TAG_MASK_0 register. */
	reg += XBUF_TX_CMD_OFFSET + (endpoints * 2 + 2) * sizeof(u32);
@@ -1754,22 +1754,16 @@ void cdnsp_irq_reset(struct cdnsp_device *pdev)
static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
{
	void __iomem *reg = &pdev->cap_regs->hc_capbase;
	struct cdnsp_rev_cap *rev_cap;

	reg += cdnsp_find_next_ext_cap(reg, 0, RTL_REV_CAP);
	rev_cap = reg;

	pdev->rev_cap.ctrl_revision = readl(&rev_cap->ctrl_revision);
	pdev->rev_cap.rtl_revision = readl(&rev_cap->rtl_revision);
	pdev->rev_cap.ep_supported = readl(&rev_cap->ep_supported);
	pdev->rev_cap.ext_cap = readl(&rev_cap->ext_cap);
	pdev->rev_cap.rx_buff_size = readl(&rev_cap->rx_buff_size);
	pdev->rev_cap.tx_buff_size = readl(&rev_cap->tx_buff_size);
	pdev->rev_cap  = reg;

	dev_info(pdev->dev, "Rev: %08x/%08x, eps: %08x, buff: %08x/%08x\n",
		 pdev->rev_cap.ctrl_revision, pdev->rev_cap.rtl_revision,
		 pdev->rev_cap.ep_supported, pdev->rev_cap.rx_buff_size,
		 pdev->rev_cap.tx_buff_size);
		 readl(&pdev->rev_cap->ctrl_revision),
		 readl(&pdev->rev_cap->rtl_revision),
		 readl(&pdev->rev_cap->ep_supported),
		 readl(&pdev->rev_cap->rx_buff_size),
		 readl(&pdev->rev_cap->tx_buff_size));
}

static int cdnsp_gen_setup(struct cdnsp_device *pdev)
+7 −6
Original line number Diff line number Diff line
@@ -493,7 +493,8 @@ struct cdnsp_3xport_cap {
#define CDNSP_VER_1 0x00000000
#define CDNSP_VER_2 0x10000000

#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) ((pdev)->rev_cap.ep_supported & \
#define CDNSP_IF_EP_EXIST(pdev, ep_num, dir) \
			 (readl(&(pdev)->rev_cap->ep_supported) & \
			 (BIT(ep_num) << ((dir) ? 0 : 16)))

/**
@@ -594,7 +595,7 @@ struct cdnsp_slot_ctx {
#define DEV_SPEED		GENMASK(23, 20)
#define GET_DEV_SPEED(n)	(((n) & DEV_SPEED) >> 20)
/* Index of the last valid endpoint context in this device context - 27:31. */
#define LAST_CTX_MASK		GENMASK(31, 27)
#define LAST_CTX_MASK		((unsigned int)GENMASK(31, 27))
#define LAST_CTX(p)		((p) << 27)
#define LAST_CTX_TO_EP_NUM(p)	(((p) >> 27) - 1)
#define SLOT_FLAG		BIT(0)
@@ -1351,9 +1352,9 @@ struct cdnsp_port {
 * @ir_set: Current interrupter register set.
 * @port20_regs: Port 2.0 Peripheral Configuration Registers.
 * @port3x_regs: USB3.x Port Peripheral Configuration Registers.
 * @rev_cap: Controller Capabilities Registers.
 * @hcs_params1: Cached register copies of read-only HCSPARAMS1
 * @hcc_params: Cached register copies of read-only HCCPARAMS1
 * @rev_cap: Controller capability.
 * @setup: Temporary buffer for setup packet.
 * @ep0_preq: Internal allocated request used during enumeration.
 * @ep0_stage: ep0 stage during enumeration process.
@@ -1402,12 +1403,12 @@ struct cdnsp_device {
	struct	cdnsp_intr_reg __iomem *ir_set;
	struct cdnsp_20port_cap __iomem *port20_regs;
	struct cdnsp_3xport_cap __iomem *port3x_regs;
	struct cdnsp_rev_cap __iomem *rev_cap;

	/* Cached register copies of read-only CDNSP data */
	__u32 hcs_params1;
	__u32 hcs_params3;
	__u32 hcc_params;
	struct cdnsp_rev_cap rev_cap;
	/* Lock used in interrupt thread context. */
	spinlock_t lock;
	struct usb_ctrlrequest setup;
+6 −5
Original line number Diff line number Diff line
@@ -759,8 +759,9 @@ int cdnsp_setup_addressable_priv_dev(struct cdnsp_device *pdev)

	port = DEV_PORT(pdev->active_port->port_num);
	slot_ctx->dev_port |= cpu_to_le32(port);
	slot_ctx->dev_state = (pdev->device_address & DEV_ADDR_MASK);
	ep0_ctx->tx_info = EP_AVG_TRB_LENGTH(0x8);
	slot_ctx->dev_state = cpu_to_le32((pdev->device_address &
					   DEV_ADDR_MASK));
	ep0_ctx->tx_info = cpu_to_le32(EP_AVG_TRB_LENGTH(0x8));
	ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
	ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3) |
					 max_packets);
@@ -925,7 +926,7 @@ static u32 cdnsp_get_max_esit_payload(struct usb_gadget *g,
	/* SuperSpeedPlus Isoc ep sending over 48k per EIST. */
	if (g->speed >= USB_SPEED_SUPER_PLUS &&
	    USB_SS_SSP_ISOC_COMP(pep->endpoint.desc->bmAttributes))
		return le32_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
		return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
	/* SuperSpeed or SuperSpeedPlus Isoc ep with less than 48k per esit */
	else if (g->speed >= USB_SPEED_SUPER)
		return le16_to_cpu(pep->endpoint.comp_desc->wBytesPerInterval);
@@ -1184,11 +1185,11 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)

	trace_cdnsp_init("Found USB 2.0 ports and  USB 3.0 ports.");

	pdev->usb2_port.regs = (struct cdnsp_port_regs *)
	pdev->usb2_port.regs = (struct cdnsp_port_regs __iomem *)
			       (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
				(pdev->usb2_port.port_num - 1));

	pdev->usb3_port.regs = (struct cdnsp_port_regs *)
	pdev->usb3_port.regs = (struct cdnsp_port_regs __iomem *)
			       (&pdev->op_regs->port_reg_base + NUM_PORT_REGS *
				(pdev->usb3_port.port_num - 1));

Loading