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. Horia