From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Joe Perches <joe@perches.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [possible PATCH] crypto: sahara - Use #ifdef DEBUG not IS_ENABLED(DEBUG)
Date: Fri, 22 Mar 2019 13:54:47 +0100 [thread overview]
Message-ID: <4ea24643-5832-981f-3d39-9a84692be6e7@c-s.fr> (raw)
In-Reply-To: <5ef0cab4dee128058a43f43c723c13924662e80d.camel@perches.com>
Le 08/03/2019 à 01:15, Joe Perches a écrit :
> Normal use of IS_ENABLED is with a CONFIG_<SYMBOL> and
> there is no -DDEBUG in the Makefile here.
>
> Replace the IS_ENABLED(DEBUG) with #ifdef DEBUG/#endif
> blocks.
By doing this you hide a big part of the code which cannot be verified
unless DEBUG is defined.
I suggest to add the following helper:
static bool is_debug_enabled(void)
{
#ifdef DEBUG
return true;
#else
return false;
#endif
}
then replace
if (IS_ENABLED(DEBUG))
by
if (is_debug_enabled())
Christophe
>
> Miscellanea:
>
> o Move the sahara_state array into the function that uses it.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/crypto/sahara.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
> index 8c32a3059b4a..d2b4bd483507 100644
> --- a/drivers/crypto/sahara.c
> +++ b/drivers/crypto/sahara.c
> @@ -348,14 +348,13 @@ static void sahara_decode_error(struct sahara_dev *dev, unsigned int error)
> dev_err(dev->device, "\n");
> }
>
> -static const 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;
> + static const char *sahara_state[4] = {
> + "Idle", "Busy", "Error", "HW Fault"
> + };
>
> state = SAHARA_STATUS_GET_STATE(status);
>
> @@ -400,15 +399,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) (%pad):\n",
> i, &dev->hw_phys_desc[i]);
> @@ -421,15 +419,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) (%pad):\n",
> i, &dev->hw_phys_link[i]);
> @@ -439,6 +436,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)
>
next prev parent reply other threads:[~2019-03-22 12:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 0:15 [possible PATCH] crypto: sahara - Use #ifdef DEBUG not IS_ENABLED(DEBUG) Joe Perches
2019-03-22 12:43 ` Herbert Xu
2019-03-22 14:29 ` Ard Biesheuvel
2019-03-22 15:07 ` Joe Perches
2019-03-22 16:21 ` Ard Biesheuvel
2019-03-22 16:29 ` Joe Perches
2019-03-22 12:54 ` Christophe Leroy [this message]
2019-03-22 14:13 ` Daniel Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ea24643-5832-981f-3d39-9a84692be6e7@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=joe@perches.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).