2017-06-28 09:37:31

by karthik

[permalink] [raw]
Subject: [PATCH 0/2] staging: ccree: Fix coding style and remove warnings

From: Karthik Tummala <[email protected]>

This patch series fixes coding style and removes the following
checkpatch.pl warnings:

Prefer using '"%s...", __func__' to using the function's name,
in a string.

Braces {} are not necessary for single statement blocks.

Rebased on top of next-20170627.
Patches were tested and built on next-20170627

Karthik Tummala (2):
staging: ccree: Use __func__ instead of function name
staging: ccree: Remove braces {} for single statement blocks

drivers/staging/ccree/ssi_aead.c | 48 ++++++++++++++++------------------------
1 file changed, 19 insertions(+), 29 deletions(-)

--
1.9.1


2017-06-28 09:37:33

by karthik

[permalink] [raw]
Subject: [PATCH 1/2] staging: ccree: Use __func__ instead of function name

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
WARNING: Prefer using '"%s...", __func__' to using
the function's name, in a string

It is prefered to use '%s & __func__' instead of function
name for logging.

Signed-off-by: Karthik Tummala <[email protected]>
---
drivers/staging/ccree/ssi_aead.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index c70e450..4004d69 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -1899,7 +1899,7 @@ static int config_gcm_context(struct aead_request *req)
(req->cryptlen - ctx->authsize);
__be32 counter = cpu_to_be32(2);

- SSI_LOG_DEBUG("config_gcm_context() cryptlen = %d, req->assoclen = %d ctx->authsize = %d \n", cryptlen, req->assoclen, ctx->authsize);
+ SSI_LOG_DEBUG("%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d \n", __func__, cryptlen, req->assoclen, ctx->authsize);

memset(req_ctx->hkey, 0, AES_BLOCK_SIZE);

@@ -2220,7 +2220,7 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
int rc = 0;

- SSI_LOG_DEBUG("ssi_rfc4106_gcm_setkey() keylen %d, key %p \n", keylen, key);
+ SSI_LOG_DEBUG("%s() keylen %d, key %p \n", __func__, keylen, key);

if (keylen < 4)
return -EINVAL;
@@ -2238,7 +2238,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
int rc = 0;

- SSI_LOG_DEBUG("ssi_rfc4543_gcm_setkey() keylen %d, key %p \n", keylen, key);
+ SSI_LOG_DEBUG("%s() keylen %d, key %p \n", __func__, keylen, key);

if (keylen < 4)
return -EINVAL;
@@ -2273,7 +2273,7 @@ static int ssi_gcm_setauthsize(struct crypto_aead *authenc,
static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc,
unsigned int authsize)
{
- SSI_LOG_DEBUG("ssi_rfc4106_gcm_setauthsize() authsize %d \n", authsize);
+ SSI_LOG_DEBUG("%s() authsize %d \n", __func__, authsize);

switch (authsize) {
case 8:
@@ -2290,7 +2290,7 @@ static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc,
static int ssi_rfc4543_gcm_setauthsize(struct crypto_aead *authenc,
unsigned int authsize)
{
- SSI_LOG_DEBUG("ssi_rfc4543_gcm_setauthsize() authsize %d \n", authsize);
+ SSI_LOG_DEBUG("%s() authsize %d \n", __func__, authsize);

if (authsize != 16)
return -EINVAL;
--
1.9.1

2017-06-28 09:37:51

by karthik

[permalink] [raw]
Subject: [PATCH 2/2] staging: ccree: Remove braces {} for single statement blocks

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
WARNING: braces {} are not necessary for single
statement blocks.

Signed-off-by: Karthik Tummala <[email protected]>
---
drivers/staging/ccree/ssi_aead.c | 38 ++++++++++++++------------------------
1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 4004d69..1a4664f 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -243,11 +243,10 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c

/* If an IV was generated, copy it back to the user provided buffer. */
if (areq_ctx->backup_giv != NULL) {
- if (ctx->cipher_mode == DRV_CIPHER_CTR) {
+ if (ctx->cipher_mode == DRV_CIPHER_CTR)
memcpy(areq_ctx->backup_giv, areq_ctx->ctr_iv + CTR_RFC3686_NONCE_SIZE, CTR_RFC3686_IV_SIZE);
- } else if (ctx->cipher_mode == DRV_CIPHER_CCM) {
+ else if (ctx->cipher_mode == DRV_CIPHER_CCM)
memcpy(areq_ctx->backup_giv, areq_ctx->ctr_iv + CCM_BLOCK_IV_OFFSET, CCM_BLOCK_IV_SIZE);
- }
}
}

@@ -521,9 +520,8 @@ static int validate_keys_sizes(struct ssi_aead_ctx *ctx)
if (unlikely(rc != 0))
SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc);

- if (likely(key_dma_addr != 0)) {
+ if (likely(key_dma_addr != 0))
dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE);
- }

return rc;
}
@@ -928,11 +926,10 @@ static inline void ssi_aead_setup_cipher_desc(
set_flow_mode(&desc[idx], ctx->flow_mode);
set_din_type(&desc[idx], DMA_DLLI, req_ctx->gen_ctx.iv_dma_addr,
hw_iv_size, NS_BIT);
- if (ctx->cipher_mode == DRV_CIPHER_CTR) {
+ if (ctx->cipher_mode == DRV_CIPHER_CTR)
set_setup_mode(&desc[idx], SETUP_LOAD_STATE1);
- } else {
+ else
set_setup_mode(&desc[idx], SETUP_LOAD_STATE0);
- }
set_cipher_mode(&desc[idx], ctx->cipher_mode);
idx++;

@@ -1375,9 +1372,9 @@ static int validate_data_size(struct ssi_aead_ctx *ctx,
static unsigned int format_ccm_a0(u8 *pA0Buff, u32 headerSize)
{
unsigned int len = 0;
- if (headerSize == 0) {
+ if (headerSize == 0)
return 0;
- }
+
if (headerSize < ((1UL << 16) - (1UL << 8))) {
len = 2;

@@ -1498,9 +1495,8 @@ static inline int ssi_aead_ccm(
}

/* process the cipher */
- if (req_ctx->cryptlen != 0) {
+ if (req_ctx->cryptlen != 0)
ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, &idx);
- }

/* Read temporal MAC */
hw_desc_init(&desc[idx]);
@@ -1579,9 +1575,8 @@ static int config_ccm_adata(struct aead_request *req)
*b0 |= 64; /* Enable bit 6 if Adata exists. */

rc = set_msg_len(b0 + 16 - l, cryptlen, l); /* Write L'. */
- if (rc != 0) {
+ if (rc != 0)
return rc;
- }
/* END of "taken from crypto/ccm.c" */

/* l(a) - size of associated data. */
@@ -1861,9 +1856,8 @@ static inline void ssi_aead_dump_gcm(
SSI_LOG_DEBUG("cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d \n", \
ctx->cipher_mode, ctx->authsize, ctx->enc_keylen, req->assoclen, req_ctx->cryptlen);

- if (ctx->enckey != NULL) {
+ if (ctx->enckey != NULL)
dump_byte_array("mac key", ctx->enckey, 16);
- }

dump_byte_array("req->iv", req->iv, AES_BLOCK_SIZE);

@@ -1877,13 +1871,11 @@ static inline void ssi_aead_dump_gcm(

dump_byte_array("gcm_len_block", req_ctx->gcm_len_block.lenA, AES_BLOCK_SIZE);

- if (req->src != NULL && req->cryptlen) {
+ if (req->src != NULL && req->cryptlen)
dump_byte_array("req->src", sg_virt(req->src), req->cryptlen+req->assoclen);
- }

- if (req->dst != NULL) {
+ if (req->dst != NULL)
dump_byte_array("req->dst", sg_virt(req->dst), req->cryptlen+ctx->authsize+req->assoclen);
- }
}
#endif

@@ -2084,14 +2076,12 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction
#if (SSI_CC_HAS_AES_CCM || SSI_CC_HAS_AES_GCM)
case DRV_HASH_NULL:
#if SSI_CC_HAS_AES_CCM
- if (ctx->cipher_mode == DRV_CIPHER_CCM) {
+ if (ctx->cipher_mode == DRV_CIPHER_CCM)
ssi_aead_ccm(req, desc, &seq_len);
- }
#endif /*SSI_CC_HAS_AES_CCM*/
#if SSI_CC_HAS_AES_GCM
- if (ctx->cipher_mode == DRV_CIPHER_GCTR) {
+ if (ctx->cipher_mode == DRV_CIPHER_GCTR)
ssi_aead_gcm(req, desc, &seq_len);
- }
#endif /*SSI_CC_HAS_AES_GCM*/
break;
#endif
--
1.9.1

2017-06-28 09:45:28

by Gilad Ben-Yossef

[permalink] [raw]
Subject: Re: [PATCH 0/2] staging: ccree: Fix coding style and remove warnings

Thank you Karthik,

On Wed, Jun 28, 2017 at 12:37 PM, <[email protected]> wrote:
> From: Karthik Tummala <[email protected]>
>
> This patch series fixes coding style and removes the following
> checkpatch.pl warnings:
>
> Prefer using '"%s...", __func__' to using the function's name,
> in a string.

This one is good.
>
> Braces {} are not necessary for single statement blocks.

I have already sent a patch addressing this and some other things
yesterday/

>
> Rebased on top of next-20170627.
> Patches were tested and built on next-20170627

Can you please check patch 1 still applies after yesterdays patch series?

>
> Karthik Tummala (2):
> staging: ccree: Use __func__ instead of function name
> staging: ccree: Remove braces {} for single statement blocks
>
> drivers/staging/ccree/ssi_aead.c | 48 ++++++++++++++++------------------------
> 1 file changed, 19 insertions(+), 29 deletions(-)
>
> --
> 1.9.1
>

Thanks,
Gilad

--
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
-- Jean-Baptiste Queru

2017-06-29 10:43:45

by karthik

[permalink] [raw]
Subject: Re: [PATCH 0/2] staging: ccree: Fix coding style and remove warnings

On Wednesday 28 June 2017 03:15 PM, Gilad Ben-Yossef wrote:
> Thank you Karthik,
>
> On Wed, Jun 28, 2017 at 12:37 PM, <[email protected]> wrote:
>> From: Karthik Tummala <[email protected]>
>>
>> This patch series fixes coding style and removes the following
>> checkpatch.pl warnings:
>>
>> Prefer using '"%s...", __func__' to using the function's name,
>> in a string.
>
> This one is good.
>>
>> Braces {} are not necessary for single statement blocks.
>
> I have already sent a patch addressing this and some other things
> yesterday/
>
>>
>> Rebased on top of next-20170627.
>> Patches were tested and built on next-20170627
>
> Can you please check patch 1 still applies after yesterdays patch series?
Hi, I have applied your patch series and then tried to apply patch 1 and
it failed. Should I wait until the patch series gets accepted and then
continue my work on the new linux-next release ? or is there any other
option ?
>
>>
>> Karthik Tummala (2):
>> staging: ccree: Use __func__ instead of function name
>> staging: ccree: Remove braces {} for single statement blocks
>>
>> drivers/staging/ccree/ssi_aead.c | 48 ++++++++++++++++------------------------
>> 1 file changed, 19 insertions(+), 29 deletions(-)
>>
>> --
>> 1.9.1
>>
>
> Thanks,
> Gilad
>
Thanks
karthik

2017-06-29 14:18:56

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 0/2] staging: ccree: Fix coding style and remove warnings

On Thu, Jun 29, 2017 at 04:13:38PM +0530, karthik wrote:
> On Wednesday 28 June 2017 03:15 PM, Gilad Ben-Yossef wrote:
> > Thank you Karthik,
> >
> > On Wed, Jun 28, 2017 at 12:37 PM, <[email protected]> wrote:
> > > From: Karthik Tummala <[email protected]>
> > >
> > > This patch series fixes coding style and removes the following
> > > checkpatch.pl warnings:
> > >
> > > Prefer using '"%s...", __func__' to using the function's name,
> > > in a string.
> >
> > This one is good.
> > >
> > > Braces {} are not necessary for single statement blocks.
> >
> > I have already sent a patch addressing this and some other things
> > yesterday/
> >
> > >
> > > Rebased on top of next-20170627.
> > > Patches were tested and built on next-20170627
> >
> > Can you please check patch 1 still applies after yesterdays patch series?
> Hi, I have applied your patch series and then tried to apply patch 1 and it
> failed. Should I wait until the patch series gets accepted and then continue
> my work on the new linux-next release ? or is there any other option ?

You need to rebased on top of these changes. All of them are now in
staging-testing, soon to move to staging-next in a day or so. Rebase on
there and resend.

thanks,

greg k-h

2017-06-29 17:09:42

by karthik

[permalink] [raw]
Subject: [PATCH v2] staging: ccree: Use __func__ instead of function name

From: Karthik Tummala <[email protected]>

Fixed following checkpatch.pl warning:
WARNING: Prefer using '"%s...", __func__' to using
the function's name, in a string

It is prefered to use '%s & __func__' instead of function
name for logging.

Signed-off-by: Karthik Tummala <[email protected]>
---
Changes for v2:
v1 was a patch series, which consisted of two patches in which
second one was already submitted by Gilad Ben-Yossef, so dropped
that one.

Patch generated on staging-testing as suggested by Greg-K H.
---
drivers/staging/ccree/ssi_aead.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 1fc0b05..1168161 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -1886,7 +1886,7 @@ static int config_gcm_context(struct aead_request *req)
(req->cryptlen - ctx->authsize);
__be32 counter = cpu_to_be32(2);

- SSI_LOG_DEBUG("config_gcm_context() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", cryptlen, req->assoclen, ctx->authsize);
+ SSI_LOG_DEBUG("%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", __func__, cryptlen, req->assoclen, ctx->authsize);

memset(req_ctx->hkey, 0, AES_BLOCK_SIZE);

@@ -2198,7 +2198,7 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
int rc = 0;

- SSI_LOG_DEBUG("ssi_rfc4106_gcm_setkey() keylen %d, key %p\n", keylen, key);
+ SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key);

if (keylen < 4)
return -EINVAL;
@@ -2216,7 +2216,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
int rc = 0;

- SSI_LOG_DEBUG("ssi_rfc4543_gcm_setkey() keylen %d, key %p\n", keylen, key);
+ SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key);

if (keylen < 4)
return -EINVAL;
--
1.9.1

2017-07-11 13:40:06

by Gilad Ben-Yossef

[permalink] [raw]
Subject: Re: [PATCH v2] staging: ccree: Use __func__ instead of function name

Hello Karthik ,

Thank you for the patch.

On Thu, Jun 29, 2017 at 8:08 PM, <[email protected]> wrote:
> From: Karthik Tummala <[email protected]>
>
> Fixed following checkpatch.pl warning:
> WARNING: Prefer using '"%s...", __func__' to using
> the function's name, in a string
>
> It is prefered to use '%s & __func__' instead of function
> name for logging.
>
> Signed-off-by: Karthik Tummala <[email protected]>
> ---
> Changes for v2:
> v1 was a patch series, which consisted of two patches in which
> second one was already submitted by Gilad Ben-Yossef, so dropped
> that one.
>
> Patch generated on staging-testing as suggested by Greg-K H.
> ---
> drivers/staging/ccree/ssi_aead.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
> index 1fc0b05..1168161 100644
> --- a/drivers/staging/ccree/ssi_aead.c
> +++ b/drivers/staging/ccree/ssi_aead.c
> @@ -1886,7 +1886,7 @@ static int config_gcm_context(struct aead_request *req)
> (req->cryptlen - ctx->authsize);
> __be32 counter = cpu_to_be32(2);
>
> - SSI_LOG_DEBUG("config_gcm_context() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", cryptlen, req->assoclen, ctx->authsize);
> + SSI_LOG_DEBUG("%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", __func__, cryptlen, req->assoclen, ctx->authsize);
>
> memset(req_ctx->hkey, 0, AES_BLOCK_SIZE);
>
> @@ -2198,7 +2198,7 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
> struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> int rc = 0;
>
> - SSI_LOG_DEBUG("ssi_rfc4106_gcm_setkey() keylen %d, key %p\n", keylen, key);
> + SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key);
>
> if (keylen < 4)
> return -EINVAL;
> @@ -2216,7 +2216,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign
> struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm);
> int rc = 0;
>
> - SSI_LOG_DEBUG("ssi_rfc4543_gcm_setkey() keylen %d, key %p\n", keylen, key);
> + SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key);
>
> if (keylen < 4)
> return -EINVAL;
> --
> 1.9.1
>

Acked-by: Gilad Ben-Yossef <[email protected]>

Gilad

--
Gilad Ben-Yossef
Chief Coffee Drinker

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
-- Jean-Baptiste Queru