Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: sahara - Fix misuse of IS_ENABLED
@ 2015-08-10  7:18 Axel Lin
  2015-08-10  7:32 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2015-08-10  7:18 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller; +Cc: Javier Martin, Steffen Trumtrar, linux-crypto

IS_ENABLED should only be used for CONFIG_* symbols.
So use #ifdef DEBUG instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/crypto/sahara.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index 397a500b..b2661a5 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -384,11 +384,9 @@ static char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
 
 static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
 {
+#ifdef DEBUG
 	u8 state;
 
-	if (!IS_ENABLED(DEBUG))
-		return;
-
 	state = SAHARA_STATUS_GET_STATE(status);
 
 	dev_dbg(dev->device, "%s: Status Register = 0x%08x\n",
@@ -432,15 +430,14 @@ static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
 		sahara_read(dev, SAHARA_REG_CDAR));
 	dev_dbg(dev->device, "Initial DAR: 0x%08x\n\n",
 		sahara_read(dev, SAHARA_REG_IDAR));
+#endif
 }
 
 static void sahara_dump_descriptors(struct sahara_dev *dev)
 {
+#ifdef DEBUG
 	int i;
 
-	if (!IS_ENABLED(DEBUG))
-		return;
-
 	for (i = 0; i < SAHARA_MAX_HW_DESC; i++) {
 		dev_dbg(dev->device, "Descriptor (%d) (0x%08x):\n",
 			i, dev->hw_phys_desc[i]);
@@ -453,15 +450,14 @@ static void sahara_dump_descriptors(struct sahara_dev *dev)
 			dev->hw_desc[i]->next);
 	}
 	dev_dbg(dev->device, "\n");
+#endif
 }
 
 static void sahara_dump_links(struct sahara_dev *dev)
 {
+#ifdef DEBUG
 	int i;
 
-	if (!IS_ENABLED(DEBUG))
-		return;
-
 	for (i = 0; i < SAHARA_MAX_HW_LINK; i++) {
 		dev_dbg(dev->device, "Link (%d) (0x%08x):\n",
 			i, dev->hw_phys_link[i]);
@@ -471,6 +467,7 @@ static void sahara_dump_links(struct sahara_dev *dev)
 			dev->hw_link[i]->next);
 	}
 	dev_dbg(dev->device, "\n");
+#endif
 }
 
 static int sahara_hw_descriptor_create(struct sahara_dev *dev)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: sahara - Fix misuse of IS_ENABLED
  2015-08-10  7:18 [PATCH] crypto: sahara - Fix misuse of IS_ENABLED Axel Lin
@ 2015-08-10  7:32 ` Herbert Xu
  2015-08-11  0:33   ` Axel Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2015-08-10  7:32 UTC (permalink / raw)
  To: Axel Lin; +Cc: David S. Miller, Javier Martin, Steffen Trumtrar, linux-crypto

On Mon, Aug 10, 2015 at 03:18:36PM +0800, Axel Lin wrote:
> IS_ENABLED should only be used for CONFIG_* symbols.
> So use #ifdef DEBUG instead.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Nack.  While the abuse is certainly wrong you're removing compiler
coverage over code which is worse.

PLease find a way to remove the IS_ENABLED abuse without causing
the code in question to lose compiler coverage.

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] 3+ messages in thread

* Re: [PATCH] crypto: sahara - Fix misuse of IS_ENABLED
  2015-08-10  7:32 ` Herbert Xu
@ 2015-08-11  0:33   ` Axel Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Axel Lin @ 2015-08-11  0:33 UTC (permalink / raw)
  To: Herbert Xu; +Cc: David S. Miller, Javier Martin, Steffen Trumtrar, linux-crypto

2015-08-10 15:32 GMT+08:00 Herbert Xu <herbert@gondor.apana.org.au>:
> On Mon, Aug 10, 2015 at 03:18:36PM +0800, Axel Lin wrote:
>> IS_ENABLED should only be used for CONFIG_* symbols.
>> So use #ifdef DEBUG instead.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>
> Nack.  While the abuse is certainly wrong you're removing compiler
> coverage over code which is worse.
>
> PLease find a way to remove the IS_ENABLED abuse without causing
> the code in question to lose compiler coverage.

I don't get it.

sahara_decode_status/sahara_dump_descriptors/sahara_dump_links functions
are mainly debug code. In original code, if IS_ENABLED(DEBUG) is false,
these functions return immediately.
DEBUG is defined or not is compile time determinated, so I don't understand
that "removing compiler coverage over code which is worse".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-11  0:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-10  7:18 [PATCH] crypto: sahara - Fix misuse of IS_ENABLED Axel Lin
2015-08-10  7:32 ` Herbert Xu
2015-08-11  0:33   ` Axel Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox