Re: [PATCH v7 4/9] crypto: caam - drop global context pointer and init_done

From: Andrey Smirnov
Date: Mon Feb 24 2020 - 11:41:07 EST


On Tue, Feb 11, 2020 at 12:57 PM Horia Geanta <horia.geanta@xxxxxxx> wrote:
>
> On 1/27/2020 6:57 PM, Andrey Smirnov wrote:
> > @@ -70,6 +70,7 @@ struct buf_data {
> >
> > /* rng per-device context */
> > struct caam_rng_ctx {
> > + struct hwrng rng;
> > struct device *jrdev;
> > dma_addr_t sh_desc_dma;
> > u32 sh_desc[DESC_RNG_LEN];
> > @@ -78,13 +79,10 @@ struct caam_rng_ctx {
> > struct buf_data bufs[2];
> > };
> >
> > -static struct caam_rng_ctx *rng_ctx;
> > -
> > -/*
> > - * Variable used to avoid double free of resources in case
> > - * algorithm registration was unsuccessful
> > - */
> > -static bool init_done;
> > +static struct caam_rng_ctx *to_caam_rng_ctx(struct hwrng *r)
> > +{
> > + return container_of(r, struct caam_rng_ctx, rng);
> > +}
> [...]
> > -static struct hwrng caam_rng = {
> > - .name = "rng-caam",
> > - .init = caam_init,
> > - .cleanup = caam_cleanup,
> > - .read = caam_read,
> > -};
> [...]> + ctx->rng.name = "rng-caam";
> > + ctx->rng.init = caam_init;
> > + ctx->rng.cleanup = caam_cleanup;
> > + ctx->rng.read = caam_read;
> An alternative (probably better) for storing caamrng context
> is to use what is already available in struct hwrng:
> * @priv: Private data, for use by the RNG driver.
>

OK, will do in v8.

Thanks,
Andrey Smirnov