drivers/usb/isp1760/isp1760-udc.c:270:17: sparse: sparse: incorrect type in assignment (different base types)
From: kernel test robot
Date: Tue Oct 20 2020 - 20:40:08 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c4d6fe7311762f2e03b3c27ad38df7c40c80cc93
commit: 005b73d0dd83c9cb9420a196bea8070cde30ecac m68knommu: __force type casts for raw IO access
date: 3 months ago
config: m68k-randconfig-s031-20201021 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=005b73d0dd83c9cb9420a196bea8070cde30ecac
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 005b73d0dd83c9cb9420a196bea8070cde30ecac
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=m68k
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/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:212:24: sparse: sparse: cast to restricted __le32
drivers/usb/isp1760/isp1760-udc.c:214:31: sparse: sparse: cast to restricted __le16
drivers/usb/isp1760/isp1760-udc.c:214:31: sparse: sparse: cast to restricted __le16
drivers/usb/isp1760/isp1760-udc.c:214:31: sparse: sparse: cast to restricted __le16
drivers/usb/isp1760/isp1760-udc.c:214:31: sparse: sparse: cast to restricted __le16
drivers/usb/isp1760/isp1760-udc.c:268:53: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned int [usertype] val @@ got restricted __le32 [usertype] @@
drivers/usb/isp1760/isp1760-udc.c:268:53: sparse: expected unsigned int [usertype] val
drivers/usb/isp1760/isp1760-udc.c:268:53: sparse: got restricted __le32 [usertype]
>> drivers/usb/isp1760/isp1760-udc.c:270:17: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short volatile [usertype] @@ got restricted __le16 [usertype] @@
>> drivers/usb/isp1760/isp1760-udc.c:270:17: sparse: expected unsigned short volatile [usertype]
drivers/usb/isp1760/isp1760-udc.c:270:17: sparse: got restricted __le16 [usertype]
drivers/usb/isp1760/isp1760-udc.c:485:9: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short volatile [usertype] @@ got restricted __le16 [usertype] @@
drivers/usb/isp1760/isp1760-udc.c:485:9: sparse: expected unsigned short volatile [usertype]
drivers/usb/isp1760/isp1760-udc.c:485:9: sparse: got restricted __le16 [usertype]
vim +270 drivers/usb/isp1760/isp1760-udc.c
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 170
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 171 /* -----------------------------------------------------------------------------
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 172 * Data Endpoints
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 173 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 174
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 175 /* Called with the UDC spinlock held. */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 176 static bool isp1760_udc_receive(struct isp1760_ep *ep,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 177 struct isp1760_request *req)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 178 {
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 179 struct isp1760_udc *udc = ep->udc;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 180 unsigned int len;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 181 u32 *buf;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 182 int i;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 183
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 184 isp1760_udc_select_ep(ep);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 185 len = isp1760_udc_read(udc, DC_BUFLEN) & DC_DATACOUNT_MASK;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 186
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 187 dev_dbg(udc->isp->dev, "%s: received %u bytes (%u/%u done)\n",
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 188 __func__, len, req->req.actual, req->req.length);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 189
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 190 len = min(len, req->req.length - req->req.actual);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 191
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 192 if (!len) {
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 193 /*
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 194 * There's no data to be read from the FIFO, acknowledge the RX
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 195 * interrupt by clearing the buffer.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 196 *
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 197 * TODO: What if another packet arrives in the meantime ? The
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 198 * datasheet doesn't clearly document how this should be
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 199 * handled.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 200 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 201 isp1760_udc_write(udc, DC_CTRLFUNC, DC_CLBUF);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 202 return false;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 203 }
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 204
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 205 buf = req->req.buf + req->req.actual;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 206
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 207 /*
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 208 * Make sure not to read more than one extra byte, otherwise data from
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 209 * the next packet might be removed from the FIFO.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 210 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 211 for (i = len; i > 2; i -= 4, ++buf)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 @212 *buf = le32_to_cpu(isp1760_udc_read(udc, DC_DATAPORT));
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 213 if (i > 0)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 214 *(u16 *)buf = le16_to_cpu(readw(udc->regs + DC_DATAPORT));
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 215
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 216 req->req.actual += len;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 217
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 218 /*
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 219 * TODO: The short_not_ok flag isn't supported yet, but isn't used by
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 220 * any gadget driver either.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 221 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 222
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 223 dev_dbg(udc->isp->dev,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 224 "%s: req %p actual/length %u/%u maxpacket %u packet size %u\n",
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 225 __func__, req, req->req.actual, req->req.length, ep->maxpacket,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 226 len);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 227
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 228 ep->rx_pending = false;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 229
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 230 /*
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 231 * Complete the request if all data has been received or if a short
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 232 * packet has been received.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 233 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 234 if (req->req.actual == req->req.length || len < ep->maxpacket) {
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 235 list_del(&req->queue);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 236 return true;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 237 }
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 238
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 239 return false;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 240 }
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 241
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 242 static void isp1760_udc_transmit(struct isp1760_ep *ep,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 243 struct isp1760_request *req)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 244 {
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 245 struct isp1760_udc *udc = ep->udc;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 246 u32 *buf = req->req.buf + req->req.actual;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 247 int i;
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 248
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 249 req->packet_size = min(req->req.length - req->req.actual,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 250 ep->maxpacket);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 251
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 252 dev_dbg(udc->isp->dev, "%s: transferring %u bytes (%u/%u done)\n",
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 253 __func__, req->packet_size, req->req.actual,
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 254 req->req.length);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 255
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 256 __isp1760_udc_select_ep(ep, USB_DIR_IN);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 257
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 258 if (req->packet_size)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 259 isp1760_udc_write(udc, DC_BUFLEN, req->packet_size);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 260
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 261 /*
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 262 * Make sure not to write more than one extra byte, otherwise extra data
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 263 * will stay in the FIFO and will be transmitted during the next control
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 264 * request. The endpoint control CLBUF bit is supposed to allow flushing
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 265 * the FIFO for this kind of conditions, but doesn't seem to work.
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 266 */
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 267 for (i = req->packet_size; i > 2; i -= 4, ++buf)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 268 isp1760_udc_write(udc, DC_DATAPORT, cpu_to_le32(*buf));
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 269 if (i > 0)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 @270 writew(cpu_to_le16(*(u16 *)buf), udc->regs + DC_DATAPORT);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 271
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 272 if (ep->addr == 0)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 273 isp1760_udc_write(udc, DC_CTRLFUNC, DC_DSEN);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 274 if (!req->packet_size)
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 275 isp1760_udc_write(udc, DC_CTRLFUNC, DC_VENDP);
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 276 }
0316ca6319b98e4 drivers/usb/host/isp1760-udc.c Laurent Pinchart 2015-01-21 277
:::::: The code at line 270 was first introduced by commit
:::::: 0316ca6319b98e485325be98a47d08fed07ead43 usb: isp1760: Add device controller support
:::::: TO: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
:::::: CC: Felipe Balbi <balbi@xxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip