diff options
author | Nitesh Lal <NiteshNarayanLal@freescale.com> | 2014-03-07 05:36:08 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-03-10 08:17:12 -0400 |
commit | 6e4e603a9a99c6e27a74c1a813a7c751d85a721d (patch) | |
tree | 2ff725ece6047f8a46f230b2d5b79f3707454777 /drivers/crypto/caam/caamrng.c | |
parent | 4f7f1d7cff8f2c170ce0319eb4c01a82c328d34f (diff) |
crypto: caam - Dynamic memory allocation for caam_rng_ctx object
This patch allocates memory from DMAable region to the caam_rng_ctx object,
earlier it had been statically allocated which resulted in errorneous
behaviour on inserting the caamrng module at the runtime.
Signed-off-by: Nitesh Lal <NiteshNarayanLal@freescale.com>
Acked-by: Ruchika Gupta <ruchika.gupta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam/caamrng.c')
-rw-r--r-- | drivers/crypto/caam/caamrng.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 28486b19fc36..403d8d599b5f 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c | |||
@@ -76,7 +76,7 @@ struct caam_rng_ctx { | |||
76 | struct buf_data bufs[2]; | 76 | struct buf_data bufs[2]; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static struct caam_rng_ctx rng_ctx; | 79 | static struct caam_rng_ctx *rng_ctx; |
80 | 80 | ||
81 | static inline void rng_unmap_buf(struct device *jrdev, struct buf_data *bd) | 81 | static inline void rng_unmap_buf(struct device *jrdev, struct buf_data *bd) |
82 | { | 82 | { |
@@ -137,7 +137,7 @@ static inline int submit_job(struct caam_rng_ctx *ctx, int to_current) | |||
137 | 137 | ||
138 | static int caam_read(struct hwrng *rng, void *data, size_t max, bool wait) | 138 | static int caam_read(struct hwrng *rng, void *data, size_t max, bool wait) |
139 | { | 139 | { |
140 | struct caam_rng_ctx *ctx = &rng_ctx; | 140 | struct caam_rng_ctx *ctx = rng_ctx; |
141 | struct buf_data *bd = &ctx->bufs[ctx->current_buf]; | 141 | struct buf_data *bd = &ctx->bufs[ctx->current_buf]; |
142 | int next_buf_idx, copied_idx; | 142 | int next_buf_idx, copied_idx; |
143 | int err; | 143 | int err; |
@@ -237,12 +237,12 @@ static void caam_cleanup(struct hwrng *rng) | |||
237 | struct buf_data *bd; | 237 | struct buf_data *bd; |
238 | 238 | ||
239 | for (i = 0; i < 2; i++) { | 239 | for (i = 0; i < 2; i++) { |
240 | bd = &rng_ctx.bufs[i]; | 240 | bd = &rng_ctx->bufs[i]; |
241 | if (atomic_read(&bd->empty) == BUF_PENDING) | 241 | if (atomic_read(&bd->empty) == BUF_PENDING) |
242 | wait_for_completion(&bd->filled); | 242 | wait_for_completion(&bd->filled); |
243 | } | 243 | } |
244 | 244 | ||
245 | rng_unmap_ctx(&rng_ctx); | 245 | rng_unmap_ctx(rng_ctx); |
246 | } | 246 | } |
247 | 247 | ||
248 | static void caam_init_buf(struct caam_rng_ctx *ctx, int buf_id) | 248 | static void caam_init_buf(struct caam_rng_ctx *ctx, int buf_id) |
@@ -273,8 +273,9 @@ static struct hwrng caam_rng = { | |||
273 | 273 | ||
274 | static void __exit caam_rng_exit(void) | 274 | static void __exit caam_rng_exit(void) |
275 | { | 275 | { |
276 | caam_jr_free(rng_ctx.jrdev); | 276 | caam_jr_free(rng_ctx->jrdev); |
277 | hwrng_unregister(&caam_rng); | 277 | hwrng_unregister(&caam_rng); |
278 | kfree(rng_ctx); | ||
278 | } | 279 | } |
279 | 280 | ||
280 | static int __init caam_rng_init(void) | 281 | static int __init caam_rng_init(void) |
@@ -286,7 +287,9 @@ static int __init caam_rng_init(void) | |||
286 | pr_err("Job Ring Device allocation for transform failed\n"); | 287 | pr_err("Job Ring Device allocation for transform failed\n"); |
287 | return PTR_ERR(dev); | 288 | return PTR_ERR(dev); |
288 | } | 289 | } |
289 | 290 | rng_ctx = kmalloc(sizeof(struct caam_rng_ctx), GFP_DMA); | |
291 | if (!rng_ctx) | ||
292 | return -ENOMEM; | ||
290 | caam_init_rng(&rng_ctx, dev); | 293 | caam_init_rng(&rng_ctx, dev); |
291 | 294 | ||
292 | dev_info(dev, "registering rng-caam\n"); | 295 | dev_info(dev, "registering rng-caam\n"); |