diff mbox series

[RESEND,v4,08/11] usb: gadget: bdc: use the BIT macro to define bit filed

Message ID 1610505748-30616-8-git-send-email-chunfeng.yun@mediatek.com (mailing list archive)
State Accepted
Commit cb387becbf16ebac6dc50799f72974ba0ced5b4c
Headers show
Series [RESEND,v4,01/11] usb: gadget: bdc: fix improper SPDX comment style for header file | expand

Commit Message

Chunfeng Yun (云春峰) Jan. 13, 2021, 2:42 a.m. UTC
Prefer using the BIT macro to define bit fileds

Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
---
v4 resend: base on kernel 5.11-rc1
v4: no changes, but rebase on kernel 5.10-rc1
v3: add acked-by Florian
v2: add Cc Florian
---
 drivers/usb/gadget/udc/bdc/bdc.h | 84 ++++++++++++++++----------------
 1 file changed, 42 insertions(+), 42 deletions(-)

Comments

kernel test robot Jan. 13, 2021, 5:30 a.m. UTC | #1
Hi Chunfeng,

I love your patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/testing/next]
[also build test WARNING on v5.11-rc3 next-20210112]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chunfeng-Yun/usb-gadget-bdc-fix-improper-SPDX-comment-style-for-header-file/20210113-105252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git testing/next
config: x86_64-randconfig-s022-20210113 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-208-g46a52ca4-dirty
        # https://github.com/0day-ci/linux/commit/b9301494d83b247a1c4c1ecc892a9f806dde0aaf
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Chunfeng-Yun/usb-gadget-bdc-fix-improper-SPDX-comment-style-for-header-file/20210113-105252
        git checkout b9301494d83b247a1c4c1ecc892a9f806dde0aaf
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


"sparse warnings: (new ones prefixed by >>)"
>> drivers/usb/gadget/udc/bdc/bdc_ep.c:498:26: sparse: sparse: cast truncates bits from constant value (ffffffff7fffffff becomes 7fffffff)

vim +498 drivers/usb/gadget/udc/bdc/bdc_ep.c

efed421a94e62a7d Ashwini Pahuja 2014-11-13  423  
efed421a94e62a7d Ashwini Pahuja 2014-11-13  424  /* Setup the bd dma descriptor for a given request */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  425  static int setup_bd_list_xfr(struct bdc *bdc, struct bdc_req *req, int num_bds)
efed421a94e62a7d Ashwini Pahuja 2014-11-13  426  {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  427  	dma_addr_t buf_add = req->usb_req.dma;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  428  	u32 maxp, tfs, dword2, dword3;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  429  	struct bd_transfer *bd_xfr;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  430  	struct bd_list *bd_list;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  431  	struct bdc_ep *ep;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  432  	struct bdc_bd *bd;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  433  	int ret, bdnum;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  434  	u32 req_len;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  435  
efed421a94e62a7d Ashwini Pahuja 2014-11-13  436  	ep = req->ep;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  437  	bd_list = &ep->bd_list;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  438  	bd_xfr = &req->bd_xfr;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  439  	bd_xfr->req = req;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  440  	bd_xfr->start_bdi = bd_list->eqp_bdi;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  441  	bd = bdi_to_bd(ep, bd_list->eqp_bdi);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  442  	req_len = req->usb_req.length;
cc2e895c604c480b Felipe Balbi   2016-09-28  443  	maxp = usb_endpoint_maxp(ep->desc);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  444  	tfs = roundup(req->usb_req.length, maxp);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  445  	tfs = tfs/maxp;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  446  	dev_vdbg(bdc->dev, "%s ep:%s num_bds:%d tfs:%d r_len:%d bd:%p\n",
efed421a94e62a7d Ashwini Pahuja 2014-11-13  447  				__func__, ep->name, num_bds, tfs, req_len, bd);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  448  
efed421a94e62a7d Ashwini Pahuja 2014-11-13  449  	for (bdnum = 0; bdnum < num_bds; bdnum++) {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  450  		dword2 = dword3 = 0;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  451  		/* First bd */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  452  		if (!bdnum) {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  453  			dword3 |= BD_SOT|BD_SBF|(tfs<<BD_TFS_SHIFT);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  454  			dword2 |= BD_LTF;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  455  			/* format of first bd for ep0 is different than other */
016040268ccafaa7 Dan Carpenter  2014-11-29  456  			if (ep->ep_num == 1) {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  457  				ret = setup_first_bd_ep0(bdc, req, &dword3);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  458  				if (ret)
efed421a94e62a7d Ashwini Pahuja 2014-11-13  459  					return ret;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  460  			}
016040268ccafaa7 Dan Carpenter  2014-11-29  461  		}
efed421a94e62a7d Ashwini Pahuja 2014-11-13  462  		if (!req->ep->dir)
efed421a94e62a7d Ashwini Pahuja 2014-11-13  463  			dword3 |= BD_ISP;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  464  
efed421a94e62a7d Ashwini Pahuja 2014-11-13  465  		if (req_len > BD_MAX_BUFF_SIZE) {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  466  			dword2 |= BD_MAX_BUFF_SIZE;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  467  			req_len -= BD_MAX_BUFF_SIZE;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  468  		} else {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  469  			/* this should be the last bd */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  470  			dword2 |= req_len;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  471  			dword3 |= BD_IOC;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  472  			dword3 |= BD_EOT;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  473  		}
efed421a94e62a7d Ashwini Pahuja 2014-11-13  474  		/* Currently only 1 INT target is supported */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  475  		dword2 |= BD_INTR_TARGET(0);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  476  		bd = bdi_to_bd(ep, ep->bd_list.eqp_bdi);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  477  		if (unlikely(!bd)) {
efed421a94e62a7d Ashwini Pahuja 2014-11-13  478  			dev_err(bdc->dev, "Err bd pointing to wrong addr\n");
efed421a94e62a7d Ashwini Pahuja 2014-11-13  479  			return -EINVAL;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  480  		}
efed421a94e62a7d Ashwini Pahuja 2014-11-13  481  		/* write bd */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  482  		bd->offset[0] = cpu_to_le32(lower_32_bits(buf_add));
efed421a94e62a7d Ashwini Pahuja 2014-11-13  483  		bd->offset[1] = cpu_to_le32(upper_32_bits(buf_add));
efed421a94e62a7d Ashwini Pahuja 2014-11-13  484  		bd->offset[2] = cpu_to_le32(dword2);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  485  		bd->offset[3] = cpu_to_le32(dword3);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  486  		/* advance eqp pointer */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  487  		ep_bdlist_eqp_adv(ep);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  488  		/* advance the buff pointer */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  489  		buf_add += BD_MAX_BUFF_SIZE;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  490  		dev_vdbg(bdc->dev, "buf_add:%08llx req_len:%d bd:%p eqp:%d\n",
efed421a94e62a7d Ashwini Pahuja 2014-11-13  491  				(unsigned long long)buf_add, req_len, bd,
efed421a94e62a7d Ashwini Pahuja 2014-11-13  492  							ep->bd_list.eqp_bdi);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  493  		bd = bdi_to_bd(ep, ep->bd_list.eqp_bdi);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  494  		bd->offset[3] = cpu_to_le32(BD_SBF);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  495  	}
efed421a94e62a7d Ashwini Pahuja 2014-11-13  496  	/* clear the STOP BD fetch bit from the first bd of this xfr */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  497  	bd = bdi_to_bd(ep, bd_xfr->start_bdi);
efed421a94e62a7d Ashwini Pahuja 2014-11-13 @498  	bd->offset[3] &= cpu_to_le32(~BD_SBF);
efed421a94e62a7d Ashwini Pahuja 2014-11-13  499  	/* the new eqp will be next hw dqp */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  500  	bd_xfr->num_bds  = num_bds;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  501  	bd_xfr->next_hwd_bdi = ep->bd_list.eqp_bdi;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  502  	/* everything is written correctly before notifying the HW */
efed421a94e62a7d Ashwini Pahuja 2014-11-13  503  	wmb();
efed421a94e62a7d Ashwini Pahuja 2014-11-13  504  
efed421a94e62a7d Ashwini Pahuja 2014-11-13  505  	return 0;
efed421a94e62a7d Ashwini Pahuja 2014-11-13  506  }
efed421a94e62a7d Ashwini Pahuja 2014-11-13  507  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Felipe Balbi Jan. 13, 2021, 8:44 a.m. UTC | #2
Chunfeng Yun <chunfeng.yun@mediatek.com> writes:

> Prefer using the BIT macro to define bit fileds
>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Acked-by: Felipe Balbi <balbi@kernel.org>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index f8d595804258..8d00b1239f21 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -102,7 +102,7 @@ 
 #define BDC_SPB(p)	((p) & 0x7)
 
 /* BDC Capability1 */
-#define BDC_P64		(1 << 0)
+#define BDC_P64		BIT(0)
 
 /* BDC Command register */
 #define BDC_CMD_FH	0xe
@@ -111,7 +111,7 @@ 
 #define BDC_CMD_BLA	0x3
 #define BDC_CMD_EPC	0x2
 #define BDC_CMD_DVC	0x1
-#define BDC_CMD_CWS		(0x1 << 5)
+#define BDC_CMD_CWS		BIT(5)
 #define BDC_CMD_CST(p)		(((p) & (0xf << 6))>>6)
 #define BDC_CMD_EPN(p)		(((p) & 0x1f) << 10)
 #define BDC_SUB_CMD_ADD		(0x1 << 17)
@@ -124,7 +124,7 @@ 
 #define BDC_SUB_CMD_EP_STP	(0x2 << 17)
 #define BDC_SUB_CMD_EP_STL	(0x4 << 17)
 #define BDC_SUB_CMD_EP_RST	(0x1 << 17)
-#define BDC_CMD_SRD		(1 << 27)
+#define BDC_CMD_SRD		BIT(27)
 
 /* CMD completion status */
 #define BDC_CMDS_SUCC	0x1
@@ -141,19 +141,19 @@ 
 #define EPM_SHIFT	4
 
 /* BDC USPSC */
-#define BDC_VBC		(1 << 31)
-#define BDC_PRC		(1 << 30)
-#define BDC_PCE		(1 << 29)
-#define BDC_CFC		(1 << 28)
-#define BDC_PCC		(1 << 27)
-#define BDC_PSC		(1 << 26)
-#define BDC_VBS		(1 << 25)
-#define BDC_PRS		(1 << 24)
-#define BDC_PCS		(1 << 23)
+#define BDC_VBC		BIT(31)
+#define BDC_PRC		BIT(30)
+#define BDC_PCE		BIT(29)
+#define BDC_CFC		BIT(28)
+#define BDC_PCC		BIT(27)
+#define BDC_PSC		BIT(26)
+#define BDC_VBS		BIT(25)
+#define BDC_PRS		BIT(24)
+#define BDC_PCS		BIT(23)
 #define BDC_PSP(p)	(((p) & (0x7 << 20))>>20)
-#define BDC_SCN		(1 << 8)
-#define BDC_SDC		(1 << 7)
-#define BDC_SWS		(1 << 4)
+#define BDC_SCN		BIT(8)
+#define BDC_SDC		BIT(7)
+#define BDC_SWS		BIT(4)
 
 #define BDC_USPSC_RW	(BDC_SCN|BDC_SDC|BDC_SWS|0xf)
 #define BDC_PSP(p)	(((p) & (0x7 << 20))>>20)
@@ -167,17 +167,17 @@ 
 #define BDC_PST_MASK	0xf
 
 /* USPPMS */
-#define BDC_U2E		(0x1 << 31)
-#define BDC_U1E		(0x1 << 30)
-#define BDC_U2A		(0x1 << 29)
-#define BDC_PORT_W1S	(0x1 << 17)
+#define BDC_U2E		BIT(31)
+#define BDC_U1E		BIT(30)
+#define BDC_U2A		BIT(29)
+#define BDC_PORT_W1S	BIT(17)
 #define BDC_U1T(p)	((p) & 0xff)
 #define BDC_U2T(p)	(((p) & 0xff) << 8)
 #define BDC_U1T_MASK	0xff
 
 /* USBPM2 */
 /* Hardware LPM Enable */
-#define BDC_HLE		(1 << 16)
+#define BDC_HLE		BIT(16)
 
 /* BDC Status and Control */
 #define BDC_COP_RST	(1 << 29)
@@ -186,11 +186,11 @@ 
 
 #define BDC_COP_MASK (BDC_COP_RST|BDC_COP_RUN|BDC_COP_STP)
 
-#define BDC_COS		(1 << 28)
+#define BDC_COS		BIT(28)
 #define BDC_CSTS(p)	(((p) & (0x7 << 20)) >> 20)
-#define BDC_MASK_MCW	(1 << 7)
-#define BDC_GIE		(1 << 1)
-#define BDC_GIP		(1 << 0)
+#define BDC_MASK_MCW	BIT(7)
+#define BDC_GIE		BIT(1)
+#define BDC_GIP		BIT(0)
 
 #define BDC_HLT	1
 #define BDC_NOR	2
@@ -201,19 +201,19 @@ 
 #define BD_CHAIN	0xf
 
 #define BD_TFS_SHIFT	4
-#define BD_SOT		(1 << 26)
-#define BD_EOT		(1 << 27)
-#define BD_ISP		(1 << 29)
-#define BD_IOC		(1 << 30)
-#define BD_SBF		(1 << 31)
+#define BD_SOT		BIT(26)
+#define BD_EOT		BIT(27)
+#define BD_ISP		BIT(29)
+#define BD_IOC		BIT(30)
+#define BD_SBF		BIT(31)
 
 #define BD_INTR_TARGET(p)	(((p) & 0x1f) << 27)
 
-#define BDC_SRR_RWS		(1 << 4)
-#define BDC_SRR_RST		(1 << 3)
-#define BDC_SRR_ISR		(1 << 2)
-#define BDC_SRR_IE		(1 << 1)
-#define BDC_SRR_IP		(1 << 0)
+#define BDC_SRR_RWS		BIT(4)
+#define BDC_SRR_RST		BIT(3)
+#define BDC_SRR_ISR		BIT(2)
+#define BDC_SRR_IE		BIT(1)
+#define BDC_SRR_IP		BIT(0)
 #define BDC_SRR_EPI(p)	(((p) & (0xff << 24)) >> 24)
 #define BDC_SRR_DPI(p) (((p) & (0xff << 16)) >> 16)
 #define BDC_SRR_DPI_MASK	0x00ff0000
@@ -221,7 +221,7 @@ 
 #define MARK_CHAIN_BD	(BD_CHAIN|BD_EOT|BD_SOT)
 
 /* Control transfer BD specific fields */
-#define BD_DIR_IN		(1 << 25)
+#define BD_DIR_IN		BIT(25)
 
 #define BDC_PTC_MASK	0xf0000000
 
@@ -241,13 +241,13 @@ 
 
 /* Transfer BD fields */
 #define BD_LEN(p) ((p) & 0x1ffff)
-#define BD_LTF		(1 << 25)
+#define BD_LTF		BIT(25)
 #define BD_TYPE_DS	0x1
 #define BD_TYPE_SS	0x2
 
-#define BDC_EP_ENABLED     (1 << 0)
-#define BDC_EP_STALL       (1 << 1)
-#define BDC_EP_STOP        (1 << 2)
+#define BDC_EP_ENABLED     BIT(0)
+#define BDC_EP_STALL       BIT(1)
+#define BDC_EP_STOP        BIT(2)
 
 /* One BD can transfer max 65536 bytes */
 #define BD_MAX_BUFF_SIZE	(1 << 16)
@@ -266,9 +266,9 @@ 
 /* FUNCTION WAKE DEV NOTIFICATION interval, USB3 spec table 8.13 */
 #define BDC_TNOTIFY 2500 /*in ms*/
 /* Devstatus bitfields */
-#define REMOTE_WAKEUP_ISSUED	(1 << 16)
-#define DEVICE_SUSPENDED	(1 << 17)
-#define FUNC_WAKE_ISSUED	(1 << 18)
+#define REMOTE_WAKEUP_ISSUED	BIT(16)
+#define DEVICE_SUSPENDED	BIT(17)
+#define FUNC_WAKE_ISSUED	BIT(18)
 #define REMOTE_WAKE_ENABLE	(1 << USB_DEVICE_REMOTE_WAKEUP)
 
 /* On disconnect, preserve these bits and clear rest */