Skip to contentSkip to conversation

spi: imx: add lpspi bus driver

bug report Dan Carpenter 2 participants 2 messages Nov 23, 2016 – Nov 24, 2016 SPI

lore
Share & tools
lore
#0 lore raw

Hello Gao Pan,

The patch 5314987de5e5: "spi: imx: add lpspi bus driver" from Nov 22, 2016, leads to the following static checker warning:

	drivers/spi/spi-fsl-lpspi.c:220 fsl_lpspi_set_cmd()
	warn: potential shift truncation.  '0x11 << 30'

drivers/spi/spi-fsl-lpspi.c
213 static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi,
214 bool is_first_xfer)
215 {
216 u32 temp = 0;
217

   218          temp |= fsl_lpspi->config.bpw - 1;
   219          temp |= fsl_lpspi->config.prescale << 27;
   220          temp |= (fsl_lpspi->config.mode & 0x11) << 30;

Are you sure you didn't intend to write:

		temp |= (fsl_lpspi->config.mode & 0x3) << 30;

The current code doesn't make sense at any rate.

   221          temp |= (fsl_lpspi->config.chip_select & 0x3) << 24;
   222  
   223          /*
   224           * Set TCR_CONT will keep SS asserted after current transfer.
   225           * For the first transfer, clear TCR_CONTC to assert SS.
   226           * For subsequent transfer, set TCR_CONTC to keep SS asserted.
   227           */
   228          temp |= TCR_CONT;
   229          if (is_first_xfer)
   230                  temp &= ~TCR_CONTC;
   231          else
   232                  temp |= TCR_CONTC;
   233  
   234          writel(temp, fsl_lpspi->base + IMX7ULP_TCR);
   235  
   236          dev_dbg(fsl_lpspi->dev, "TCR=0x%x\n", temp);
   237  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

From: Dan Carpenter <mailto:[email protected]> Sent: Thursday, November 24, 2016 6:57 AM

Quoted 22 lines

To: Pandy Gao <[email protected]>
Cc: [email protected]
Subject: [bug report] spi: imx: add lpspi bus driver

Hello Gao Pan,

The patch 5314987de5e5: "spi: imx: add lpspi bus driver" from Nov 22, 2016, leads to the following static checker warning:

	drivers/spi/spi-fsl-lpspi.c:220 fsl_lpspi_set_cmd()
	warn: potential shift truncation.  '0x11 << 30'

drivers/spi/spi-fsl-lpspi.c
213 static void fsl_lpspi_set_cmd(struct fsl_lpspi_data *fsl_lpspi,
214 bool is_first_xfer)

   215  {
   216          u32 temp = 0;
   217
   218          temp |= fsl_lpspi->config.bpw - 1;
   219          temp |= fsl_lpspi->config.prescale << 27;
   220          temp |= (fsl_lpspi->config.mode & 0x11) << 30;
Quoted 5 lines

Are you sure you didn't intend to write:

		temp |= (fsl_lpspi->config.mode & 0x3) << 30;

The current code doesn't make sense at any rate.

Yes, you are right. Will submit a patch to fix this bug. Thanks!

Best Regards
Gao Pan

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html