spi: stm32: Fix warnings when compiling with W=1
authorPatrick Delaunay <patrick.delaunay@st.com>
Fri, 21 Jun 2019 13:26:58 +0000 (15:26 +0200)
committerPatrick Delaunay <patrick.delaunay@st.com>
Fri, 12 Jul 2019 09:50:57 +0000 (11:50 +0200)
This patch solves the following warnings:

drivers/spi/stm32_spi.c: In function 'stm32_spi_write_txfifo':
drivers/spi/stm32_spi.c:116:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (priv->tx_len >= sizeof(u32) &&
                    ^~
drivers/spi/stm32_spi.c:122:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   } else if (priv->tx_len >= sizeof(u16) &&
                           ^~
drivers/spi/stm32_spi.c: In function 'stm32_spi_read_rxfifo':
drivers/spi/stm32_spi.c:150:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       (priv->rx_len >= sizeof(u32) || (sr & SPI_SR_RXWNE))) {
                     ^~
drivers/spi/stm32_spi.c:156:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       (priv->rx_len >= sizeof(u16) ||
                     ^~
drivers/core/simple-bus.c:15:12: warning: no previous prototype for 'simple_bus_translate' [-Wmissing-prototypes]
 fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr)
            ^~~~~~~~~~~~~~~~~~~~
drivers/spi/stm32_spi.c: In function 'stm32_spi_set_speed':
drivers/spi/stm32_spi.c:335:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      div > STM32_MBR_DIV_MAX)
          ^
drivers/spi/stm32_spi.c:344:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  if ((mbrdiv - 1) < 0)
                   ^
drivers/spi/stm32_spi.c: In function 'stm32_spi_probe':
drivers/spi/stm32_spi.c:531:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < ARRAY_SIZE(priv->cs_gpios); i++) {
                ^
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
drivers/spi/stm32_spi.c

index 34b2175..75b6006 100644 (file)
@@ -99,8 +99,8 @@ struct stm32_spi_priv {
        unsigned int cur_bpw;
        unsigned int cur_hz;
        unsigned int cur_xferlen; /* current transfer length in bytes */
-       int tx_len;               /* number of data to be written in bytes */
-       int rx_len;               /* number of data to be read in bytes */
+       unsigned int tx_len;      /* number of data to be written in bytes */
+       unsigned int rx_len;      /* number of data to be read in bytes */
        const void *tx_buf;       /* data to be written, or NULL */
        void *rx_buf;             /* data to be read, or NULL */
        u32 cur_mode;
@@ -322,7 +322,8 @@ static int stm32_spi_set_fthlv(struct udevice *dev, u32 xfer_len)
 static int stm32_spi_set_speed(struct udevice *bus, uint hz)
 {
        struct stm32_spi_priv *priv = dev_get_priv(bus);
-       u32 div, mbrdiv;
+       u32 mbrdiv;
+       long div;
 
        debug("%s: hz=%d\n", __func__, hz);
 
@@ -341,7 +342,7 @@ static int stm32_spi_set_speed(struct udevice *bus, uint hz)
        else
                mbrdiv = fls(div) - 1;
 
-       if ((mbrdiv - 1) < 0)
+       if (!mbrdiv)
                return -EINVAL;
 
        clrsetbits_le32(priv->base + STM32_SPI_CFG1, SPI_CFG1_MBR,
@@ -481,7 +482,7 @@ static int stm32_spi_probe(struct udevice *dev)
        struct stm32_spi_priv *priv = dev_get_priv(dev);
        unsigned long clk_rate;
        int ret;
-       int i;
+       unsigned int i;
 
        priv->base = dev_remap_addr(dev);
        if (!priv->base)