* [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation
@ 2016-01-07 15:58 Andre Przywara
2016-01-07 15:58 ` [PATCH 1/2] crypto: sunxi-ss-cipher: promote variables to match types in min3() calls Andre Przywara
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andre Przywara @ 2016-01-07 15:58 UTC (permalink / raw)
To: Corentin Labbe, maxime.ripard, Chen-Yu Tsai, arnd
Cc: Herbert Xu, David S . Miller, linux-sunxi, linux-arm-kernel,
linux-kernel
Hi,
these two patches provide a different approach to an issue I tried
to fix lately [1].
Instead of casting everything I now promote local types to size_t, so
that the min3() arguments naturally match in type.
As size_t is defined as "unsigned int" on 32-bit architectures
anyway, that actually does not change anything there, but instead
provides a clean approach to get it compiled for arm64.
I split this up because 1/2 seems much cleaner to me than 2/2, so we
can have a separate discussion/merge process on this.
Cheers,
Andre.
[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-December/395689.html
Andre Przywara (2):
crypto: sunxi-ss-cipher: promote variables to match types in min3()
calls
crypto: sunxi-ss-hash: promote variables to match types in min3()
calls
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 20 ++++++++++----------
drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 12 ++++++------
drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
--
2.6.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] crypto: sunxi-ss-cipher: promote variables to match types in min3() calls
2016-01-07 15:58 [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Andre Przywara
@ 2016-01-07 15:58 ` Andre Przywara
2016-01-07 15:58 ` [PATCH 2/2] crypto: sunxi-ss-hash: " Andre Przywara
2016-01-08 9:59 ` [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Herbert Xu
2 siblings, 0 replies; 5+ messages in thread
From: Andre Przywara @ 2016-01-07 15:58 UTC (permalink / raw)
To: Corentin Labbe, maxime.ripard, Chen-Yu Tsai, arnd
Cc: Herbert Xu, David S . Miller, linux-sunxi, linux-arm-kernel,
linux-kernel
The min3() macro expects all arguments to be of the same type (or
size at least).
Change the type of some local variables in sun4i-ss-cipher.c to
size_t to match the type used in some generic structures we
compare against.
That shouldn't change anything for 32-bit (as size_t is unsigned int
there anyway), but allows compilation for 64-bit architectures.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
index a19ee12..707f30f 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
@@ -25,13 +25,13 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
struct sun4i_cipher_req_ctx *ctx = ablkcipher_request_ctx(areq);
u32 mode = ctx->mode;
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
- u32 rx_cnt = SS_RX_DEFAULT;
- u32 tx_cnt = 0;
+ size_t rx_cnt = SS_RX_DEFAULT;
+ size_t tx_cnt = 0;
u32 spaces;
u32 v;
int i, err = 0;
- unsigned int ileft = areq->nbytes;
- unsigned int oleft = areq->nbytes;
+ size_t ileft = areq->nbytes;
+ size_t oleft = areq->nbytes;
unsigned int todo;
struct sg_mapping_iter mi, mo;
unsigned int oi, oo; /* offset for in and out */
@@ -134,13 +134,13 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
struct sun4i_cipher_req_ctx *ctx = ablkcipher_request_ctx(areq);
u32 mode = ctx->mode;
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
- u32 rx_cnt = SS_RX_DEFAULT;
- u32 tx_cnt = 0;
+ size_t rx_cnt = SS_RX_DEFAULT;
+ size_t tx_cnt = 0;
u32 v;
u32 spaces;
int i, err = 0;
- unsigned int ileft = areq->nbytes;
- unsigned int oleft = areq->nbytes;
+ size_t ileft = areq->nbytes;
+ size_t oleft = areq->nbytes;
unsigned int todo;
struct sg_mapping_iter mi, mo;
unsigned int oi, oo; /* offset for in and out */
@@ -148,7 +148,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
char bufo[4 * SS_TX_MAX]; /* buffer for linearize SG dst */
unsigned int ob = 0; /* offset in buf */
unsigned int obo = 0; /* offset in bufo*/
- unsigned int obl = 0; /* length of data in bufo */
+ size_t obl = 0; /* length of data in bufo */
if (areq->nbytes == 0)
return 0;
@@ -251,7 +251,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
spaces = readl(ss->base + SS_FCSR);
rx_cnt = SS_RXFIFO_SPACES(spaces);
tx_cnt = SS_TXFIFO_SPACES(spaces);
- dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u %u\n",
+ dev_dbg(ss->dev, "%x %u/%zu %zu/%u cnt=%zu %u/%zu %zu/%u cnt=%zu %u %u\n",
mode,
oi, mi.length, ileft, areq->nbytes, rx_cnt,
oo, mo.length, oleft, areq->nbytes, tx_cnt,
--
2.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] crypto: sunxi-ss-hash: promote variables to match types in min3() calls
2016-01-07 15:58 [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Andre Przywara
2016-01-07 15:58 ` [PATCH 1/2] crypto: sunxi-ss-cipher: promote variables to match types in min3() calls Andre Przywara
@ 2016-01-07 15:58 ` Andre Przywara
2016-01-08 9:59 ` [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Herbert Xu
2 siblings, 0 replies; 5+ messages in thread
From: Andre Przywara @ 2016-01-07 15:58 UTC (permalink / raw)
To: Corentin Labbe, maxime.ripard, Chen-Yu Tsai, arnd
Cc: Herbert Xu, David S . Miller, linux-sunxi, linux-arm-kernel,
linux-kernel
The min3() macro expects all arguments to be of the same type (or
size at least).
Change the type of some local variables in sun4i-ss-hash.c to
size_t to match the type used in some generic structures we
compare against.
That shouldn't change anything for 32-bit (as size_t is unsigned int
there anyway), but allows compilation for 64-bit architectures.
There are two casts still necessary, because we can't change the type
in a generic structure.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 12 ++++++------
drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
index ff80314..c0384f1 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
@@ -170,7 +170,7 @@ int sun4i_hash_update(struct ahash_request *areq)
struct sun4i_ss_ctx *ss = op->ss;
struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq);
unsigned int in_i = 0; /* advancement in the current SG */
- unsigned int end;
+ size_t end;
/*
* end is the position when we need to stop writing to the device,
* to be compared to i
@@ -181,7 +181,7 @@ int sun4i_hash_update(struct ahash_request *areq)
size_t copied = 0;
struct sg_mapping_iter mi;
- dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x",
+ dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%zu h0=%0x",
__func__, crypto_tfm_alg_name(areq->base.tfm),
op->byte_count, areq->nbytes, op->mode,
op->len, op->hash[0]);
@@ -206,7 +206,7 @@ int sun4i_hash_update(struct ahash_request *areq)
end = ((areq->nbytes + op->len) / 64) * 64 - op->len;
if (end > areq->nbytes || areq->nbytes - end > 63) {
- dev_err(ss->dev, "ERROR: Bound error %u %u\n",
+ dev_err(ss->dev, "ERROR: Bound error %zu %u\n",
end, areq->nbytes);
return -EINVAL;
}
@@ -266,7 +266,7 @@ int sun4i_hash_update(struct ahash_request *areq)
}
if (mi.length - in_i > 3 && i < end) {
/* how many bytes we can read from current SG */
- in_r = min3(mi.length - in_i, areq->nbytes - i,
+ in_r = min3(mi.length - in_i, (size_t)areq->nbytes - i,
((mi.length - in_i) / 4) * 4);
/* how many bytes we can write in the device*/
todo = min3((u32)(end - i) / 4, rx_cnt, (u32)in_r / 4);
@@ -289,7 +289,7 @@ int sun4i_hash_update(struct ahash_request *areq)
if ((areq->nbytes - i) < 64) {
while (i < areq->nbytes && in_i < mi.length && op->len < 64) {
/* how many bytes we can read from current SG */
- in_r = min3(mi.length - in_i, areq->nbytes - i,
+ in_r = min3(mi.length - in_i, (size_t)areq->nbytes - i,
64 - op->len);
memcpy(op->buf + op->len, mi.addr + in_i, in_r);
op->len += in_r;
@@ -352,7 +352,7 @@ int sun4i_hash_final(struct ahash_request *areq)
u32 wb = 0;
unsigned int nwait, nbw = 0;
- dev_dbg(ss->dev, "%s: byte=%llu len=%u mode=%x wl=%u h=%x",
+ dev_dbg(ss->dev, "%s: byte=%llu len=%u mode=%x wl=%zu h=%x",
__func__, op->byte_count, areq->nbytes, op->mode,
op->len, op->hash[0]);
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h
index 8e9c05f..c15fa21 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss.h
+++ b/drivers/crypto/sunxi-ss/sun4i-ss.h
@@ -162,7 +162,7 @@ struct sun4i_req_ctx {
u64 byte_count; /* number of bytes "uploaded" to the device */
u32 hash[5]; /* for storing SS_IVx register */
char buf[64];
- unsigned int len;
+ size_t len;
struct sun4i_ss_ctx *ss;
};
--
2.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation
2016-01-07 15:58 [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Andre Przywara
2016-01-07 15:58 ` [PATCH 1/2] crypto: sunxi-ss-cipher: promote variables to match types in min3() calls Andre Przywara
2016-01-07 15:58 ` [PATCH 2/2] crypto: sunxi-ss-hash: " Andre Przywara
@ 2016-01-08 9:59 ` Herbert Xu
2016-01-08 11:15 ` Andre Przywara
2 siblings, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2016-01-08 9:59 UTC (permalink / raw)
To: Andre Przywara
Cc: Corentin Labbe, maxime.ripard, Chen-Yu Tsai, arnd,
David S . Miller, linux-sunxi, linux-arm-kernel, linux-kernel
On Thu, Jan 07, 2016 at 03:58:16PM +0000, Andre Przywara wrote:
> Hi,
>
> these two patches provide a different approach to an issue I tried
> to fix lately [1].
> Instead of casting everything I now promote local types to size_t, so
> that the min3() arguments naturally match in type.
> As size_t is defined as "unsigned int" on 32-bit architectures
> anyway, that actually does not change anything there, but instead
> provides a clean approach to get it compiled for arm64.
>
> I split this up because 1/2 seems much cleaner to me than 2/2, so we
> can have a separate discussion/merge process on this.
If this is meant for the crypto tree it needs to go to the linux-crypto
list.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation
2016-01-08 9:59 ` [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Herbert Xu
@ 2016-01-08 11:15 ` Andre Przywara
0 siblings, 0 replies; 5+ messages in thread
From: Andre Przywara @ 2016-01-08 11:15 UTC (permalink / raw)
To: Herbert Xu
Cc: Corentin Labbe, maxime.ripard, Chen-Yu Tsai, arnd,
David S . Miller, linux-sunxi, linux-arm-kernel, linux-kernel,
linux-crypto
Hi Herbert,
On 08/01/16 09:59, Herbert Xu wrote:
> On Thu, Jan 07, 2016 at 03:58:16PM +0000, Andre Przywara wrote:
>> Hi,
>>
>> these two patches provide a different approach to an issue I tried
>> to fix lately [1].
>> Instead of casting everything I now promote local types to size_t, so
>> that the min3() arguments naturally match in type.
>> As size_t is defined as "unsigned int" on 32-bit architectures
>> anyway, that actually does not change anything there, but instead
>> provides a clean approach to get it compiled for arm64.
>>
>> I split this up because 1/2 seems much cleaner to me than 2/2, so we
>> can have a separate discussion/merge process on this.
>
> If this is meant for the crypto tree it needs to go to the linux-crypto
> list.
Oh dear, I planned on adding the list, but eventually forgot it. Sorry
for that, I will resend it to linux-crypto.
Thanks for pointing this out!
Cheers,
Andre.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-08 11:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07 15:58 [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Andre Przywara
2016-01-07 15:58 ` [PATCH 1/2] crypto: sunxi-ss-cipher: promote variables to match types in min3() calls Andre Przywara
2016-01-07 15:58 ` [PATCH 2/2] crypto: sunxi-ss-hash: " Andre Przywara
2016-01-08 9:59 ` [PATCH 0/2] crypto: sunxi-ss: fix 64-bit compilation Herbert Xu
2016-01-08 11:15 ` Andre Przywara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).