Skip to content

Commit

Permalink
spidev compiler warning gone
Browse files Browse the repository at this point in the history
Get rid of annoying GCC warning on 32-bit platforms.

drivers/spi/spidev.c: In function 'spidev_message':
drivers/spi/spidev.c:184: warning: cast to pointer from integer of different size
drivers/spi/spidev.c:216: warning: cast to pointer from integer of different size

The trick is to add an extra cast using "ptrdiff_t" to convert the u64 to
the correct size integer, and only then casting it into a "void *" pointer.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Brownell authored and Linus Torvalds committed Jul 17, 2007
1 parent ad24152 commit 4917d92
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/spi/spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ static int spidev_message(struct spidev_data *spidev,
}
if (u_tmp->tx_buf) {
k_tmp->tx_buf = buf;
if (copy_from_user(buf, (const u8 __user *)u_tmp->tx_buf,
if (copy_from_user(buf, (const u8 __user *)
(ptrdiff_t) u_tmp->tx_buf,
u_tmp->len))
goto done;
}
Expand Down Expand Up @@ -213,7 +214,8 @@ static int spidev_message(struct spidev_data *spidev,
buf = spidev->buffer;
for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
if (u_tmp->rx_buf) {
if (__copy_to_user((u8 __user *)u_tmp->rx_buf, buf,
if (__copy_to_user((u8 __user *)
(ptrdiff_t) u_tmp->rx_buf, buf,
u_tmp->len)) {
status = -EFAULT;
goto done;
Expand Down

0 comments on commit 4917d92

Please sign in to comment.