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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>


"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@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux