Commit 20ecae79 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Herbert Xu

crypto: atmel - fix 64-bit warnings

The atmel AES driver assumes that 'int' and 'size_t' are the same
type in multiple locations, which the compiler warns about when
building it for 64-bit systems:

In file included from ../drivers/crypto/atmel-aes.c:17:0:
drivers/crypto/atmel-aes.c: In function 'atmel_aes_sg_copy':
include/linux/kernel.h:724:17: warning: comparison of distinct pointer types lacks a cast
drivers/crypto/atmel-aes.c:448:11: note: in expansion of macro 'min'

drivers/crypto/atmel-aes.c: In function 'atmel_aes_crypt_dma_stop':
include/linux/kern_levels.h:4:18: warning: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned int}' [-Wformat=]

This changes the format strings to use the %z modifier when printing
a size_t, and makes sure that we use the correct size_t type where
needed. In case of sg_dma_len(), the type of the result depends
on CONFIG_NEED_SG_DMA_LENGTH, so we have to use min_t to get it to
work in all configurations.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarCyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 08346170
...@@ -184,7 +184,7 @@ static int atmel_aes_sg_length(struct ablkcipher_request *req, ...@@ -184,7 +184,7 @@ static int atmel_aes_sg_length(struct ablkcipher_request *req,
static int atmel_aes_sg_copy(struct scatterlist **sg, size_t *offset, static int atmel_aes_sg_copy(struct scatterlist **sg, size_t *offset,
void *buf, size_t buflen, size_t total, int out) void *buf, size_t buflen, size_t total, int out)
{ {
unsigned int count, off = 0; size_t count, off = 0;
while (buflen && total) { while (buflen && total) {
count = min((*sg)->length - *offset, total); count = min((*sg)->length - *offset, total);
...@@ -444,8 +444,8 @@ static int atmel_aes_crypt_dma_start(struct atmel_aes_dev *dd) ...@@ -444,8 +444,8 @@ static int atmel_aes_crypt_dma_start(struct atmel_aes_dev *dd)
if (fast) { if (fast) {
count = min(dd->total, sg_dma_len(dd->in_sg)); count = min_t(size_t, dd->total, sg_dma_len(dd->in_sg));
count = min(count, sg_dma_len(dd->out_sg)); count = min_t(size_t, count, sg_dma_len(dd->out_sg));
err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE); err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE);
if (!err) { if (!err) {
...@@ -639,7 +639,7 @@ static int atmel_aes_crypt_dma_stop(struct atmel_aes_dev *dd) ...@@ -639,7 +639,7 @@ static int atmel_aes_crypt_dma_stop(struct atmel_aes_dev *dd)
dd->buf_out, dd->buflen, dd->dma_size, 1); dd->buf_out, dd->buflen, dd->dma_size, 1);
if (count != dd->dma_size) { if (count != dd->dma_size) {
err = -EINVAL; err = -EINVAL;
pr_err("not all data converted: %u\n", count); pr_err("not all data converted: %zu\n", count);
} }
} }
} }
...@@ -666,7 +666,7 @@ static int atmel_aes_buff_init(struct atmel_aes_dev *dd) ...@@ -666,7 +666,7 @@ static int atmel_aes_buff_init(struct atmel_aes_dev *dd)
dd->dma_addr_in = dma_map_single(dd->dev, dd->buf_in, dd->dma_addr_in = dma_map_single(dd->dev, dd->buf_in,
dd->buflen, DMA_TO_DEVICE); dd->buflen, DMA_TO_DEVICE);
if (dma_mapping_error(dd->dev, dd->dma_addr_in)) { if (dma_mapping_error(dd->dev, dd->dma_addr_in)) {
dev_err(dd->dev, "dma %d bytes error\n", dd->buflen); dev_err(dd->dev, "dma %zd bytes error\n", dd->buflen);
err = -EINVAL; err = -EINVAL;
goto err_map_in; goto err_map_in;
} }
...@@ -674,7 +674,7 @@ static int atmel_aes_buff_init(struct atmel_aes_dev *dd) ...@@ -674,7 +674,7 @@ static int atmel_aes_buff_init(struct atmel_aes_dev *dd)
dd->dma_addr_out = dma_map_single(dd->dev, dd->buf_out, dd->dma_addr_out = dma_map_single(dd->dev, dd->buf_out,
dd->buflen, DMA_FROM_DEVICE); dd->buflen, DMA_FROM_DEVICE);
if (dma_mapping_error(dd->dev, dd->dma_addr_out)) { if (dma_mapping_error(dd->dev, dd->dma_addr_out)) {
dev_err(dd->dev, "dma %d bytes error\n", dd->buflen); dev_err(dd->dev, "dma %zd bytes error\n", dd->buflen);
err = -EINVAL; err = -EINVAL;
goto err_map_out; goto err_map_out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment