From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Paul Louvel <paul.louvel@bootlin.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Herve Codina <herve.codina@bootlin.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/29] crypto: talitos/hwrng - Move into separate file
Date: Fri, 29 May 2026 13:26:55 +0200 [thread overview]
Message-ID: <d6f4f508-65ce-4753-b326-a2de54e1bc2d@kernel.org> (raw)
In-Reply-To: <20260528-7-1-rc1_talitos_cleanup-v1-4-cb1ad6cdea49@bootlin.com>
Le 28/05/2026 à 11:08, Paul Louvel a écrit :
> Move the hardware random number generator implementation from
> talitos.c into a dedicated talitos-rng.c file.
>
> Signed-off-by: Paul Louvel <paul.louvel@bootlin.com>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> ---
> drivers/crypto/talitos/Makefile | 2 +
> drivers/crypto/talitos/talitos-rng.c | 93 ++++++++++++++++++++++++++++++++++++
> drivers/crypto/talitos/talitos.c | 83 --------------------------------
> drivers/crypto/talitos/talitos.h | 5 ++
> 4 files changed, 100 insertions(+), 83 deletions(-)
>
> diff --git a/drivers/crypto/talitos/Makefile b/drivers/crypto/talitos/Makefile
> index fcc5db5e63c2..901ec681f010 100644
> --- a/drivers/crypto/talitos/Makefile
> +++ b/drivers/crypto/talitos/Makefile
> @@ -1 +1,3 @@
> obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
> +
> +talitos-y := talitos.o talitos-rng.o
> diff --git a/drivers/crypto/talitos/talitos-rng.c b/drivers/crypto/talitos/talitos-rng.c
> new file mode 100644
> index 000000000000..3aa00de33b25
> --- /dev/null
> +++ b/drivers/crypto/talitos/talitos-rng.c
> @@ -0,0 +1,93 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +/*
> + * Freescale SEC (talitos) device hardware random number generator implementation
> + *
> + * Copyright (c) 2006-2011 Freescale Semiconductor, Inc.
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +
> +#include "talitos.h"
> +
> +static int talitos_rng_data_present(struct hwrng *rng, int wait)
> +{
> + struct device *dev = (struct device *)rng->priv;
> + struct talitos_private *priv = dev_get_drvdata(dev);
> + u32 ofl;
> + int i;
> +
> + for (i = 0; i < 20; i++) {
> + ofl = in_be32(priv->reg_rngu + TALITOS_EUSR_LO) &
> + TALITOS_RNGUSR_LO_OFL;
> + if (ofl || !wait)
> + break;
> + udelay(10);
> + }
> +
> + return !!ofl;
> +}
> +
> +static int talitos_rng_data_read(struct hwrng *rng, u32 *data)
> +{
> + struct device *dev = (struct device *)rng->priv;
> + struct talitos_private *priv = dev_get_drvdata(dev);
> +
> + /* rng fifo requires 64-bit accesses */
> + *data = in_be32(priv->reg_rngu + TALITOS_EU_FIFO);
> + *data = in_be32(priv->reg_rngu + TALITOS_EU_FIFO_LO);
> +
> + return sizeof(u32);
> +}
> +
> +static int talitos_rng_init(struct hwrng *rng)
> +{
> + struct device *dev = (struct device *)rng->priv;
> + struct talitos_private *priv = dev_get_drvdata(dev);
> + unsigned int timeout = TALITOS_TIMEOUT;
> +
> + setbits32(priv->reg_rngu + TALITOS_EURCR_LO, TALITOS_RNGURCR_LO_SR);
> + while (!(in_be32(priv->reg_rngu + TALITOS_EUSR_LO)
> + & TALITOS_RNGUSR_LO_RD)
> + && --timeout)
> + cpu_relax();
> + if (timeout == 0) {
> + dev_err(dev, "failed to reset rng hw\n");
> + return -ENODEV;
> + }
> +
> + /* start generating */
> + setbits32(priv->reg_rngu + TALITOS_EUDSR_LO, 0);
> +
> + return 0;
> +}
> +
> +int talitos_register_rng(struct device *dev)
> +{
> + struct talitos_private *priv = dev_get_drvdata(dev);
> + int err;
> +
> + priv->rng.name = dev_driver_string(dev);
> + priv->rng.init = talitos_rng_init;
> + priv->rng.data_present = talitos_rng_data_present;
> + priv->rng.data_read = talitos_rng_data_read;
> + priv->rng.priv = (unsigned long)dev;
> +
> + err = hwrng_register(&priv->rng);
> + if (!err)
> + priv->rng_registered = true;
> +
> + return err;
> +}
> +
> +void talitos_unregister_rng(struct device *dev)
> +{
> + struct talitos_private *priv = dev_get_drvdata(dev);
> +
> + if (!priv->rng_registered)
> + return;
> +
> + hwrng_unregister(&priv->rng);
> + priv->rng_registered = false;
> +}
> diff --git a/drivers/crypto/talitos/talitos.c b/drivers/crypto/talitos/talitos.c
> index 8ca587b98d92..f5feff8f7d3d 100644
> --- a/drivers/crypto/talitos/talitos.c
> +++ b/drivers/crypto/talitos/talitos.c
> @@ -820,89 +820,6 @@ DEF_TALITOS2_INTERRUPT(ch0_2, TALITOS2_ISR_CH_0_2_DONE, TALITOS2_ISR_CH_0_2_ERR,
> DEF_TALITOS2_INTERRUPT(ch1_3, TALITOS2_ISR_CH_1_3_DONE, TALITOS2_ISR_CH_1_3_ERR,
> 1)
>
> -/*
> - * hwrng
> - */
> -static int talitos_rng_data_present(struct hwrng *rng, int wait)
> -{
> - struct device *dev = (struct device *)rng->priv;
> - struct talitos_private *priv = dev_get_drvdata(dev);
> - u32 ofl;
> - int i;
> -
> - for (i = 0; i < 20; i++) {
> - ofl = in_be32(priv->reg_rngu + TALITOS_EUSR_LO) &
> - TALITOS_RNGUSR_LO_OFL;
> - if (ofl || !wait)
> - break;
> - udelay(10);
> - }
> -
> - return !!ofl;
> -}
> -
> -static int talitos_rng_data_read(struct hwrng *rng, u32 *data)
> -{
> - struct device *dev = (struct device *)rng->priv;
> - struct talitos_private *priv = dev_get_drvdata(dev);
> -
> - /* rng fifo requires 64-bit accesses */
> - *data = in_be32(priv->reg_rngu + TALITOS_EU_FIFO);
> - *data = in_be32(priv->reg_rngu + TALITOS_EU_FIFO_LO);
> -
> - return sizeof(u32);
> -}
> -
> -static int talitos_rng_init(struct hwrng *rng)
> -{
> - struct device *dev = (struct device *)rng->priv;
> - struct talitos_private *priv = dev_get_drvdata(dev);
> - unsigned int timeout = TALITOS_TIMEOUT;
> -
> - setbits32(priv->reg_rngu + TALITOS_EURCR_LO, TALITOS_RNGURCR_LO_SR);
> - while (!(in_be32(priv->reg_rngu + TALITOS_EUSR_LO)
> - & TALITOS_RNGUSR_LO_RD)
> - && --timeout)
> - cpu_relax();
> - if (timeout == 0) {
> - dev_err(dev, "failed to reset rng hw\n");
> - return -ENODEV;
> - }
> -
> - /* start generating */
> - setbits32(priv->reg_rngu + TALITOS_EUDSR_LO, 0);
> -
> - return 0;
> -}
> -
> -static int talitos_register_rng(struct device *dev)
> -{
> - struct talitos_private *priv = dev_get_drvdata(dev);
> - int err;
> -
> - priv->rng.name = dev_driver_string(dev);
> - priv->rng.init = talitos_rng_init;
> - priv->rng.data_present = talitos_rng_data_present;
> - priv->rng.data_read = talitos_rng_data_read;
> - priv->rng.priv = (unsigned long)dev;
> -
> - err = hwrng_register(&priv->rng);
> - if (!err)
> - priv->rng_registered = true;
> -
> - return err;
> -}
> -
> -static void talitos_unregister_rng(struct device *dev)
> -{
> - struct talitos_private *priv = dev_get_drvdata(dev);
> -
> - if (!priv->rng_registered)
> - return;
> -
> - hwrng_unregister(&priv->rng);
> - priv->rng_registered = false;
> -}
>
> /*
> * crypto alg
> diff --git a/drivers/crypto/talitos/talitos.h b/drivers/crypto/talitos/talitos.h
> index 56e36a65ddcc..fa8c71b1f90f 100644
> --- a/drivers/crypto/talitos/talitos.h
> +++ b/drivers/crypto/talitos/talitos.h
> @@ -431,3 +431,8 @@ static inline bool has_ftr_sec1(struct talitos_private *priv)
> #define DESC_PTR_LNKTBL_JUMP 0x80
> #define DESC_PTR_LNKTBL_RET 0x02
> #define DESC_PTR_LNKTBL_NEXT 0x01
> +
> +/* Hardware RNG */
> +
> +int talitos_register_rng(struct device *dev);
> +void talitos_unregister_rng(struct device *dev);
>
next prev parent reply other threads:[~2026-05-29 11:27 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 9:08 [PATCH 00/29] crypto: talitos - Driver cleanup Paul Louvel
2026-05-28 9:08 ` [PATCH 01/29] crypto: talitos/hash - Use CRYPTO_AHASH_BLOCK_ONLY API Paul Louvel
2026-05-29 11:25 ` Christophe Leroy (CS GROUP)
2026-06-01 5:40 ` Christophe Leroy (CS GROUP)
2026-06-01 8:06 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 02/29] crypto: talitos - Move driver into dedicated directory Paul Louvel
2026-05-29 11:25 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 03/29] crypto: talitos - Add missing includes to driver header file Paul Louvel
2026-05-29 11:26 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 04/29] crypto: talitos/hwrng - Move into separate file Paul Louvel
2026-05-29 11:26 ` Christophe Leroy (CS GROUP) [this message]
2026-05-28 9:08 ` [PATCH 05/29] crypto: talitos - Prepare crypto implementation file splitting Paul Louvel
2026-05-29 13:21 ` Christophe Leroy (CS GROUP)
2026-05-29 16:24 ` David Laight
2026-06-01 8:49 ` Paul Louvel
2026-06-01 10:16 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 06/29] crypto: talitos - Introduce registration helper Paul Louvel
2026-06-01 5:45 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 07/29] crypto: talitos/hash - Move into separate file Paul Louvel
2026-06-01 11:47 ` Christophe Leroy (CS GROUP)
2026-06-04 12:31 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 08/29] crypto: talitos/skcipher " Paul Louvel
2026-06-01 11:47 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 09/29] crypto: talitos/aead " Paul Louvel
2026-06-01 11:48 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 10/29] crypto: talitos - Remove alg settings in talitos_register_common() Paul Louvel
2026-06-01 11:53 ` Christophe Leroy (CS GROUP)
2026-06-04 12:38 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 11/29] crypto: talitos - Remove unused priority field in struct talitos_alg_template Paul Louvel
2026-06-01 11:54 ` Christophe Leroy (CS GROUP)
2026-06-04 12:39 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 12/29] crypto: talitos/hash - Convert to init_tfm/exit_tfm type-specific API Paul Louvel
2026-06-01 11:57 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 13/29] crypto: talitos/skcipher - Convert to init/exit " Paul Louvel
2026-06-01 11:58 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 14/29] crypto: talitos/aead " Paul Louvel
2026-06-01 11:59 ` Christophe Leroy (CS GROUP)
2026-06-04 12:44 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 15/29] crypto: talitos/hash - Use macro for algorithm definitions Paul Louvel
2026-06-01 12:02 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 16/29] crypto: talitos/skcipher " Paul Louvel
2026-06-01 12:02 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 17/29] crypto: talitos/aead " Paul Louvel
2026-06-01 12:12 ` Christophe Leroy (CS GROUP)
2026-06-10 14:41 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 18/29] crypto: talitos - Split SEC1/SEC2 code into separate function variants Paul Louvel
2026-06-01 5:51 ` Christophe Leroy (CS GROUP)
2026-06-01 12:32 ` Christophe Leroy (CS GROUP)
2026-06-04 12:46 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 19/29] crypto: talitos - Introduce struct talitos_ops Paul Louvel
2026-05-28 9:08 ` [PATCH 20/29] crypto: talitos - Replace SEC1/SEC2 conditionals with ops dispatch Paul Louvel
2026-06-04 9:37 ` Christophe Leroy (CS GROUP)
2026-06-04 13:05 ` Paul Louvel
2026-06-04 15:26 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 21/29] crypto: talitos - Export common channel and error handling routines Paul Louvel
2026-05-28 9:08 ` [PATCH 22/29] crypto: talitos - Move SEC1 ops into talitos-sec1.c Paul Louvel
2026-05-28 9:08 ` [PATCH 23/29] crypto: talitos - Move SEC2 ops into talitos-sec2.c Paul Louvel
2026-05-28 9:08 ` [PATCH 24/29] crypto: talitos - Introduce per-SEC-version pointer helper ops Paul Louvel
2026-06-04 9:48 ` Christophe Leroy (CS GROUP)
2026-05-28 9:08 ` [PATCH 25/29] crypto: talitos - Dispatch pointer helpers through ptr_ops Paul Louvel
2026-05-28 9:08 ` [PATCH 26/29] crypto: talitos - Remove now-unused global pointer helpers Paul Louvel
2026-05-28 9:08 ` [PATCH 27/29] crypto: talitos - Introduce per-SEC-version descriptor structures and ops Paul Louvel
2026-06-04 9:57 ` Christophe Leroy (CS GROUP)
2026-06-04 13:01 ` Paul Louvel
2026-05-28 9:08 ` [PATCH 28/29] crypto: talitos - Clean up includes in core driver file Paul Louvel
2026-05-28 9:08 ` [PATCH 29/29] crypto: talitos - Remove TALITOS_DESC_SIZE macro Paul Louvel
2026-06-04 9:59 ` Christophe Leroy (CS GROUP)
2026-06-04 13:01 ` Paul Louvel
2026-06-01 6:15 ` [PATCH 00/29] crypto: talitos - Driver cleanup Christophe Leroy (CS GROUP)
2026-06-01 9:17 ` Paul Louvel
2026-06-01 10:27 ` Christophe Leroy (CS GROUP)
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=d6f4f508-65ce-4753-b326-a2de54e1bc2d@kernel.org \
--to=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=herve.codina@bootlin.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.louvel@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
/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
Powered by JetHome