crypto: talitos: replace in_be32/out_be32 with ioread32be/iowrite32be
PATCH 1/1 crypto: talitos: replace in_be32/out_be32 with ioread32be/iowrite32be
Convert ppc4xx-specific in_be32/out_be32 and the setbits32/clrbits32 macros to the portable ioread32be/iowrite32be helpers.
Add HAS_IOMEM dependency as these accessors need it.
Add COMPILE_TEST for extra compile coverage.
--- drivers/crypto/Kconfig | 3 +- drivers/crypto/talitos.c | 379 ++++++++++++++++++++------------------- 2 files changed, 192 insertions(+), 190 deletions(-)
drivers/crypto/Kconfig +2 -1
@@ -262,7 +262,8 @@ config CRYPTO_DEV_TALITOS select CRYPTO_HASH select CRYPTO_LIB_DES select HW_RANDOM - depends on FSL_SOC + depends on FSL_SOC || COMPILE_TEST + depends on HAS_IOMEM help Say 'Y' here to use the Freescale Security Engine (SEC) to offload cryptographic algorithm computation.
drivers/crypto/talitos.c +190 -189
527 lines not on this page · raw message
Signature · 1 line
2.54.0
Hi,
Quoted 2 lines · Rosen Penev
Convert ppc4xx-specific in_be32/out_be32 and the setbits32/clrbits32 macros to the portable ioread32be/iowrite32be helpers.
It doesn't do that. The setbits32/clrbits32 macros are unchanged.
If they had been adapted, there would have been no need to inline the macro definition before substituting the IO accessors.
This inlining makes the code harder to read, because it consists of nested function calls (which have very specific and annoying indentation requirements that you're not following), and also duplicates the address calculation.
Quoted 3 lines
Add
COMPILE_TESTfor extra compile coverage.Assisted-by opencode:big-pickle
I suspect these two lines are related in a horrible way, and this code has only been compile-tested on the wrong architecture as part of the feedback loop. COMPILE_TEST is not necessary for compile-testing with a cross compiler and an appropriate defconfig for the target platform.
drivers/crypto/talitos.c static int reset_channel(struct device *dev, int ch) · line 148
Quoted 5 lines
drivers/crypto/talitos.c +3
-2-setbits32 (priv->chan[ch].reg +TALITOS_CCCR_LO , -TALITOS1_CCCR_LO_RESET ); +iowrite32be (ioread32be (priv->chan[ch].reg +TALITOS_CCCR_LO ) | + (TALITOS1_CCCR_LO_RESET ), + priv->chan[ch].reg +TALITOS_CCCR_LO );
Wrong formatting, and either the parentheses around TALITOS1_CCCR_LO_RESET are unnecessary here, or
drivers/crypto/talitos.c static int reset_channel(struct device *dev, int ch) · line 152
Quoted 5 lines
drivers/crypto/talitos.c +3
-2-while ((in_be32 (priv->chan[ch].reg +TALITOS_CCCR_LO ) & -TALITOS1_CCCR_LO_RESET ) && --timeout) +while ((ioread32be (priv->chan[ch].reg +TALITOS_CCCR_LO ) & +TALITOS1_CCCR_LO_RESET ) && + --timeout)
also needs them. The former is correct (macro definitions need to include parentheses if using them inside a calculation would give you unexpected operator precedence.
drivers/crypto/talitos.c static int reset_channel(struct device *dev, int ch) · line 171
Quoted 6 lines
/* set 36-bit addressing, done writeback enable and done IRQ enable */
drivers/crypto/talitos.c +3
-2-setbits32 (priv->chan[ch].reg +TALITOS_CCCR_LO ,TALITOS_CCCR_LO_EAE | -TALITOS_CCCR_LO_CDWE |TALITOS_CCCR_LO_CDIE ); +iowrite32be (ioread32be (priv->chan[ch].reg +TALITOS_CCCR_LO ) | + (TALITOS_CCCR_LO_EAE |TALITOS_CCCR_LO_CDWE |TALITOS_CCCR_LO_CDIE ), + priv->chan[ch].reg +TALITOS_CCCR_LO );
These parentheses are likewise unnecessary. It's a big OR, no need to group them.
\> +#define DEF_TALITOS1_DONE(name, ch_done_mask)
\
drivers/crypto/talitos.c static void flush_channel(struct device *dev, int ch, int error, int reset_ch) · line 474
Quoted 1 line
drivers/crypto/talitos.c +1
-0+ static void talitos1_done_##name(unsigned long data) \
Inconsistent backslashes, and does not improve the horribleness that was there before, only makes it longer and harder to read.
drivers/crypto/talitos.c static void report_eu_error(struct device *dev, int ch, __be32 desc_hdr) · line 598
Quoted 3 lines
if (!desc_hdr)
drivers/crypto/talitos.c +1
-1- desc_hdr =cpu_to_be32 (in_be32 (priv->chan[ch].reg +TALITOS_DESCBUF )); + desc_hdr =cpu_to_be32 (ioread32be (priv->chan[ch].reg +TALITOS_DESCBUF ));
Likewise, this is bad and unreadable in the current state, and this patch does nothing to improve that.
drivers/crypto/talitos.c static void report_eu_error(struct device *dev, int ch, __be32 desc_hdr) · line 603
Quoted 5 lines
drivers/crypto/talitos.c +2
-3-dev_err (dev,"AFEUISR 0x%08x_%08x\n" , -in_be32 (priv->reg_afeu +TALITOS_EUISR ), -in_be32 (priv->reg_afeu +TALITOS_EUISR_LO )); +dev_err (dev,"AFEUISR 0x%08x_%08x\n" ,ioread32be (priv->reg_afeu +TALITOS_EUISR ), +ioread32be (priv->reg_afeu +TALITOS_EUISR_LO ));
You can probably see how the formatting is worse than before.
I'm not going to bother checking if this introduces any bugs, as I have the strong suspicion that I would be the first person reading this code.
Simon