diff mbox

[2/2] spi: core: Use cast inside 'min' macro

Message ID 1455722424-15490-2-git-send-email-fabio.estevam@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabio Estevam Feb. 17, 2016, 3:20 p.m. UTC
Use cast inside 'min' macro in order to avoid the following 
build warning on ARM64:

include/linux/kernel.h:754:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_min1 == &_min2);  \
                 ^
drivers/spi/spi.c:2304:17: note: in expansion of macro 'min'
  xfers[0].len = min(maxsize, xfer[0].len);

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/spi/spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Geert Uytterhoeven Feb. 17, 2016, 5:34 p.m. UTC | #1
On Wed, Feb 17, 2016 at 4:20 PM, Fabio Estevam <fabio.estevam@nxp.com> wrote:
> Use cast inside 'min' macro in order to avoid the following
> build warning on ARM64:
>
> include/linux/kernel.h:754:17: warning: comparison of distinct pointer types lacks a cast
>   (void) (&_min1 == &_min2);  \
>                  ^
> drivers/spi/spi.c:2304:17: note: in expansion of macro 'min'
>   xfers[0].len = min(maxsize, xfer[0].len);
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/spi/spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 0725ffa..4498f40 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -2301,7 +2301,7 @@ static int __spi_split_transfer_maxsize(struct spi_master *master,
>         /* the first transfer just needs the length modified, so we
>          * run it outside the loop
>          */
> -       xfers[0].len = min(maxsize, xfer[0].len);
> +       xfers[0].len = min(maxsize, (size_t)xfer[0].len);

Please use "min_t(size_t, ..., ...)" instead of explicit casting.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0725ffa..4498f40 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2301,7 +2301,7 @@  static int __spi_split_transfer_maxsize(struct spi_master *master,
 	/* the first transfer just needs the length modified, so we
 	 * run it outside the loop
 	 */
-	xfers[0].len = min(maxsize, xfer[0].len);
+	xfers[0].len = min(maxsize, (size_t)xfer[0].len);
 
 	/* all the others need rx_buf/tx_buf also set */
 	for (i = 1, offset = maxsize; i < count; offset += maxsize, i++) {