diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 12:28:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-03 12:28:16 -0400 |
commit | 59ecc26004e77e100c700b1d0da7502b0fdadb46 (patch) | |
tree | 1faec47bda8439cc2cbe3bd9bf15756e67808e63 /drivers/char | |
parent | bea803183e12a1c78a12ec70907174d13d958333 (diff) | |
parent | 8ceee72808d1ae3fb191284afc2257a2be964725 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu:
"Here is the crypto update for 3.15:
- Added 3DES driver for OMAP4/AM43xx
- Added AVX2 acceleration for SHA
- Added hash-only AEAD algorithms in caam
- Removed tegra driver as it is not functioning and the hardware is
too slow
- Allow blkcipher walks over AEAD (needed for ARM)
- Fixed unprotected FPU/SSE access in ghash-clmulni-intel
- Fixed highmem crash in omap-sham
- Add (zero entropy) randomness when initialising hardware RNGs
- Fixed unaligned ahash comletion functions
- Added soft module depedency for crc32c for initrds that use crc32c"
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (60 commits)
crypto: ghash-clmulni-intel - use C implementation for setkey()
crypto: x86/sha1 - reduce size of the AVX2 asm implementation
crypto: x86/sha1 - fix stack alignment of AVX2 variant
crypto: x86/sha1 - re-enable the AVX variant
crypto: sha - SHA1 transform x86_64 AVX2
crypto: crypto_wq - Fix late crypto work queue initialization
crypto: caam - add missing key_dma unmap
crypto: caam - add support for aead null encryption
crypto: testmgr - add aead null encryption test vectors
crypto: export NULL algorithms defines
crypto: caam - remove error propagation handling
crypto: hash - Simplify the ahash_finup implementation
crypto: hash - Pull out the functions to save/restore request
crypto: hash - Fix the pointer voodoo in unaligned ahash
crypto: caam - Fix first parameter to caam_init_rng
crypto: omap-sham - Map SG pages if they are HIGHMEM before accessing
crypto: caam - Dynamic memory allocation for caam_rng_ctx object
crypto: allow blkcipher walks over AEAD data
crypto: remove direct blkcipher_walk dependency on transform
hwrng: add randomness to system from rng sources
...
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/atmel-rng.c | 23 | ||||
-rw-r--r-- | drivers/char/hw_random/core.c | 17 | ||||
-rw-r--r-- | drivers/char/hw_random/nomadik-rng.c | 13 | ||||
-rw-r--r-- | drivers/char/hw_random/omap3-rom-rng.c | 3 | ||||
-rw-r--r-- | drivers/char/hw_random/picoxcell-rng.c | 27 | ||||
-rw-r--r-- | drivers/char/hw_random/timeriomem-rng.c | 40 |
6 files changed, 36 insertions, 87 deletions
diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c index bf9fc6b79328..851bc7e20ad2 100644 --- a/drivers/char/hw_random/atmel-rng.c +++ b/drivers/char/hw_random/atmel-rng.c | |||
@@ -54,29 +54,22 @@ static int atmel_trng_probe(struct platform_device *pdev) | |||
54 | struct resource *res; | 54 | struct resource *res; |
55 | int ret; | 55 | int ret; |
56 | 56 | ||
57 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
58 | if (!res) | ||
59 | return -EINVAL; | ||
60 | |||
61 | trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); | 57 | trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); |
62 | if (!trng) | 58 | if (!trng) |
63 | return -ENOMEM; | 59 | return -ENOMEM; |
64 | 60 | ||
65 | if (!devm_request_mem_region(&pdev->dev, res->start, | 61 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
66 | resource_size(res), pdev->name)) | 62 | trng->base = devm_ioremap_resource(&pdev->dev, res); |
67 | return -EBUSY; | 63 | if (IS_ERR(trng->base)) |
68 | 64 | return PTR_ERR(trng->base); | |
69 | trng->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); | ||
70 | if (!trng->base) | ||
71 | return -EBUSY; | ||
72 | 65 | ||
73 | trng->clk = clk_get(&pdev->dev, NULL); | 66 | trng->clk = devm_clk_get(&pdev->dev, NULL); |
74 | if (IS_ERR(trng->clk)) | 67 | if (IS_ERR(trng->clk)) |
75 | return PTR_ERR(trng->clk); | 68 | return PTR_ERR(trng->clk); |
76 | 69 | ||
77 | ret = clk_enable(trng->clk); | 70 | ret = clk_enable(trng->clk); |
78 | if (ret) | 71 | if (ret) |
79 | goto err_enable; | 72 | return ret; |
80 | 73 | ||
81 | writel(TRNG_KEY | 1, trng->base + TRNG_CR); | 74 | writel(TRNG_KEY | 1, trng->base + TRNG_CR); |
82 | trng->rng.name = pdev->name; | 75 | trng->rng.name = pdev->name; |
@@ -92,9 +85,6 @@ static int atmel_trng_probe(struct platform_device *pdev) | |||
92 | 85 | ||
93 | err_register: | 86 | err_register: |
94 | clk_disable(trng->clk); | 87 | clk_disable(trng->clk); |
95 | err_enable: | ||
96 | clk_put(trng->clk); | ||
97 | |||
98 | return ret; | 88 | return ret; |
99 | } | 89 | } |
100 | 90 | ||
@@ -106,7 +96,6 @@ static int atmel_trng_remove(struct platform_device *pdev) | |||
106 | 96 | ||
107 | writel(TRNG_KEY, trng->base + TRNG_CR); | 97 | writel(TRNG_KEY, trng->base + TRNG_CR); |
108 | clk_disable(trng->clk); | 98 | clk_disable(trng->clk); |
109 | clk_put(trng->clk); | ||
110 | 99 | ||
111 | return 0; | 100 | return 0; |
112 | } | 101 | } |
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index b9495a8c05c6..334601cc81cf 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/miscdevice.h> | 40 | #include <linux/miscdevice.h> |
41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/random.h> | ||
43 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
44 | 45 | ||
45 | 46 | ||
@@ -301,9 +302,10 @@ err_misc_dereg: | |||
301 | 302 | ||
302 | int hwrng_register(struct hwrng *rng) | 303 | int hwrng_register(struct hwrng *rng) |
303 | { | 304 | { |
304 | int must_register_misc; | ||
305 | int err = -EINVAL; | 305 | int err = -EINVAL; |
306 | struct hwrng *old_rng, *tmp; | 306 | struct hwrng *old_rng, *tmp; |
307 | unsigned char bytes[16]; | ||
308 | int bytes_read; | ||
307 | 309 | ||
308 | if (rng->name == NULL || | 310 | if (rng->name == NULL || |
309 | (rng->data_read == NULL && rng->read == NULL)) | 311 | (rng->data_read == NULL && rng->read == NULL)) |
@@ -326,7 +328,6 @@ int hwrng_register(struct hwrng *rng) | |||
326 | goto out_unlock; | 328 | goto out_unlock; |
327 | } | 329 | } |
328 | 330 | ||
329 | must_register_misc = (current_rng == NULL); | ||
330 | old_rng = current_rng; | 331 | old_rng = current_rng; |
331 | if (!old_rng) { | 332 | if (!old_rng) { |
332 | err = hwrng_init(rng); | 333 | err = hwrng_init(rng); |
@@ -335,18 +336,20 @@ int hwrng_register(struct hwrng *rng) | |||
335 | current_rng = rng; | 336 | current_rng = rng; |
336 | } | 337 | } |
337 | err = 0; | 338 | err = 0; |
338 | if (must_register_misc) { | 339 | if (!old_rng) { |
339 | err = register_miscdev(); | 340 | err = register_miscdev(); |
340 | if (err) { | 341 | if (err) { |
341 | if (!old_rng) { | 342 | hwrng_cleanup(rng); |
342 | hwrng_cleanup(rng); | 343 | current_rng = NULL; |
343 | current_rng = NULL; | ||
344 | } | ||
345 | goto out_unlock; | 344 | goto out_unlock; |
346 | } | 345 | } |
347 | } | 346 | } |
348 | INIT_LIST_HEAD(&rng->list); | 347 | INIT_LIST_HEAD(&rng->list); |
349 | list_add_tail(&rng->list, &rng_list); | 348 | list_add_tail(&rng->list, &rng_list); |
349 | |||
350 | bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); | ||
351 | if (bytes_read > 0) | ||
352 | add_device_randomness(bytes, bytes_read); | ||
350 | out_unlock: | 353 | out_unlock: |
351 | mutex_unlock(&rng_mutex); | 354 | mutex_unlock(&rng_mutex); |
352 | out: | 355 | out: |
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c index 00e9d2d46634..9c8581577246 100644 --- a/drivers/char/hw_random/nomadik-rng.c +++ b/drivers/char/hw_random/nomadik-rng.c | |||
@@ -43,7 +43,7 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) | |||
43 | void __iomem *base; | 43 | void __iomem *base; |
44 | int ret; | 44 | int ret; |
45 | 45 | ||
46 | rng_clk = clk_get(&dev->dev, NULL); | 46 | rng_clk = devm_clk_get(&dev->dev, NULL); |
47 | if (IS_ERR(rng_clk)) { | 47 | if (IS_ERR(rng_clk)) { |
48 | dev_err(&dev->dev, "could not get rng clock\n"); | 48 | dev_err(&dev->dev, "could not get rng clock\n"); |
49 | ret = PTR_ERR(rng_clk); | 49 | ret = PTR_ERR(rng_clk); |
@@ -56,33 +56,28 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) | |||
56 | if (ret) | 56 | if (ret) |
57 | goto out_clk; | 57 | goto out_clk; |
58 | ret = -ENOMEM; | 58 | ret = -ENOMEM; |
59 | base = ioremap(dev->res.start, resource_size(&dev->res)); | 59 | base = devm_ioremap(&dev->dev, dev->res.start, |
60 | resource_size(&dev->res)); | ||
60 | if (!base) | 61 | if (!base) |
61 | goto out_release; | 62 | goto out_release; |
62 | nmk_rng.priv = (unsigned long)base; | 63 | nmk_rng.priv = (unsigned long)base; |
63 | ret = hwrng_register(&nmk_rng); | 64 | ret = hwrng_register(&nmk_rng); |
64 | if (ret) | 65 | if (ret) |
65 | goto out_unmap; | 66 | goto out_release; |
66 | return 0; | 67 | return 0; |
67 | 68 | ||
68 | out_unmap: | ||
69 | iounmap(base); | ||
70 | out_release: | 69 | out_release: |
71 | amba_release_regions(dev); | 70 | amba_release_regions(dev); |
72 | out_clk: | 71 | out_clk: |
73 | clk_disable(rng_clk); | 72 | clk_disable(rng_clk); |
74 | clk_put(rng_clk); | ||
75 | return ret; | 73 | return ret; |
76 | } | 74 | } |
77 | 75 | ||
78 | static int nmk_rng_remove(struct amba_device *dev) | 76 | static int nmk_rng_remove(struct amba_device *dev) |
79 | { | 77 | { |
80 | void __iomem *base = (void __iomem *)nmk_rng.priv; | ||
81 | hwrng_unregister(&nmk_rng); | 78 | hwrng_unregister(&nmk_rng); |
82 | iounmap(base); | ||
83 | amba_release_regions(dev); | 79 | amba_release_regions(dev); |
84 | clk_disable(rng_clk); | 80 | clk_disable(rng_clk); |
85 | clk_put(rng_clk); | ||
86 | return 0; | 81 | return 0; |
87 | } | 82 | } |
88 | 83 | ||
diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c index c853e9e68573..6f2eaffed623 100644 --- a/drivers/char/hw_random/omap3-rom-rng.c +++ b/drivers/char/hw_random/omap3-rom-rng.c | |||
@@ -103,7 +103,7 @@ static int omap3_rom_rng_probe(struct platform_device *pdev) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | setup_timer(&idle_timer, omap3_rom_rng_idle, 0); | 105 | setup_timer(&idle_timer, omap3_rom_rng_idle, 0); |
106 | rng_clk = clk_get(&pdev->dev, "ick"); | 106 | rng_clk = devm_clk_get(&pdev->dev, "ick"); |
107 | if (IS_ERR(rng_clk)) { | 107 | if (IS_ERR(rng_clk)) { |
108 | pr_err("unable to get RNG clock\n"); | 108 | pr_err("unable to get RNG clock\n"); |
109 | return PTR_ERR(rng_clk); | 109 | return PTR_ERR(rng_clk); |
@@ -120,7 +120,6 @@ static int omap3_rom_rng_remove(struct platform_device *pdev) | |||
120 | { | 120 | { |
121 | hwrng_unregister(&omap3_rom_rng_ops); | 121 | hwrng_unregister(&omap3_rom_rng_ops); |
122 | clk_disable_unprepare(rng_clk); | 122 | clk_disable_unprepare(rng_clk); |
123 | clk_put(rng_clk); | ||
124 | return 0; | 123 | return 0; |
125 | } | 124 | } |
126 | 125 | ||
diff --git a/drivers/char/hw_random/picoxcell-rng.c b/drivers/char/hw_random/picoxcell-rng.c index 3d4c2293c6f5..eab5448ad56f 100644 --- a/drivers/char/hw_random/picoxcell-rng.c +++ b/drivers/char/hw_random/picoxcell-rng.c | |||
@@ -104,24 +104,11 @@ static int picoxcell_trng_probe(struct platform_device *pdev) | |||
104 | int ret; | 104 | int ret; |
105 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 105 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
106 | 106 | ||
107 | if (!mem) { | 107 | rng_base = devm_ioremap_resource(&pdev->dev, mem); |
108 | dev_warn(&pdev->dev, "no memory resource\n"); | 108 | if (IS_ERR(rng_base)) |
109 | return -ENOMEM; | 109 | return PTR_ERR(rng_base); |
110 | } | ||
111 | |||
112 | if (!devm_request_mem_region(&pdev->dev, mem->start, resource_size(mem), | ||
113 | "picoxcell_trng")) { | ||
114 | dev_warn(&pdev->dev, "unable to request io mem\n"); | ||
115 | return -EBUSY; | ||
116 | } | ||
117 | 110 | ||
118 | rng_base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); | 111 | rng_clk = devm_clk_get(&pdev->dev, NULL); |
119 | if (!rng_base) { | ||
120 | dev_warn(&pdev->dev, "unable to remap io mem\n"); | ||
121 | return -ENOMEM; | ||
122 | } | ||
123 | |||
124 | rng_clk = clk_get(&pdev->dev, NULL); | ||
125 | if (IS_ERR(rng_clk)) { | 112 | if (IS_ERR(rng_clk)) { |
126 | dev_warn(&pdev->dev, "no clk\n"); | 113 | dev_warn(&pdev->dev, "no clk\n"); |
127 | return PTR_ERR(rng_clk); | 114 | return PTR_ERR(rng_clk); |
@@ -130,7 +117,7 @@ static int picoxcell_trng_probe(struct platform_device *pdev) | |||
130 | ret = clk_enable(rng_clk); | 117 | ret = clk_enable(rng_clk); |
131 | if (ret) { | 118 | if (ret) { |
132 | dev_warn(&pdev->dev, "unable to enable clk\n"); | 119 | dev_warn(&pdev->dev, "unable to enable clk\n"); |
133 | goto err_enable; | 120 | return ret; |
134 | } | 121 | } |
135 | 122 | ||
136 | picoxcell_trng_start(); | 123 | picoxcell_trng_start(); |
@@ -145,9 +132,6 @@ static int picoxcell_trng_probe(struct platform_device *pdev) | |||
145 | 132 | ||
146 | err_register: | 133 | err_register: |
147 | clk_disable(rng_clk); | 134 | clk_disable(rng_clk); |
148 | err_enable: | ||
149 | clk_put(rng_clk); | ||
150 | |||
151 | return ret; | 135 | return ret; |
152 | } | 136 | } |
153 | 137 | ||
@@ -155,7 +139,6 @@ static int picoxcell_trng_remove(struct platform_device *pdev) | |||
155 | { | 139 | { |
156 | hwrng_unregister(&picoxcell_trng); | 140 | hwrng_unregister(&picoxcell_trng); |
157 | clk_disable(rng_clk); | 141 | clk_disable(rng_clk); |
158 | clk_put(rng_clk); | ||
159 | 142 | ||
160 | return 0; | 143 | return 0; |
161 | } | 144 | } |
diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c index 73ce739f8e19..439ff8b28c43 100644 --- a/drivers/char/hw_random/timeriomem-rng.c +++ b/drivers/char/hw_random/timeriomem-rng.c | |||
@@ -118,7 +118,8 @@ static int timeriomem_rng_probe(struct platform_device *pdev) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | /* Allocate memory for the device structure (and zero it) */ | 120 | /* Allocate memory for the device structure (and zero it) */ |
121 | priv = kzalloc(sizeof(struct timeriomem_rng_private_data), GFP_KERNEL); | 121 | priv = devm_kzalloc(&pdev->dev, |
122 | sizeof(struct timeriomem_rng_private_data), GFP_KERNEL); | ||
122 | if (!priv) { | 123 | if (!priv) { |
123 | dev_err(&pdev->dev, "failed to allocate device structure.\n"); | 124 | dev_err(&pdev->dev, "failed to allocate device structure.\n"); |
124 | return -ENOMEM; | 125 | return -ENOMEM; |
@@ -134,17 +135,16 @@ static int timeriomem_rng_probe(struct platform_device *pdev) | |||
134 | period = i; | 135 | period = i; |
135 | else { | 136 | else { |
136 | dev_err(&pdev->dev, "missing period\n"); | 137 | dev_err(&pdev->dev, "missing period\n"); |
137 | err = -EINVAL; | 138 | return -EINVAL; |
138 | goto out_free; | ||
139 | } | 139 | } |
140 | } else | 140 | } else { |
141 | period = pdata->period; | 141 | period = pdata->period; |
142 | } | ||
142 | 143 | ||
143 | priv->period = usecs_to_jiffies(period); | 144 | priv->period = usecs_to_jiffies(period); |
144 | if (priv->period < 1) { | 145 | if (priv->period < 1) { |
145 | dev_err(&pdev->dev, "period is less than one jiffy\n"); | 146 | dev_err(&pdev->dev, "period is less than one jiffy\n"); |
146 | err = -EINVAL; | 147 | return -EINVAL; |
147 | goto out_free; | ||
148 | } | 148 | } |
149 | 149 | ||
150 | priv->expires = jiffies; | 150 | priv->expires = jiffies; |
@@ -160,24 +160,16 @@ static int timeriomem_rng_probe(struct platform_device *pdev) | |||
160 | priv->timeriomem_rng_ops.data_read = timeriomem_rng_data_read; | 160 | priv->timeriomem_rng_ops.data_read = timeriomem_rng_data_read; |
161 | priv->timeriomem_rng_ops.priv = (unsigned long)priv; | 161 | priv->timeriomem_rng_ops.priv = (unsigned long)priv; |
162 | 162 | ||
163 | if (!request_mem_region(res->start, resource_size(res), | 163 | priv->io_base = devm_ioremap_resource(&pdev->dev, res); |
164 | dev_name(&pdev->dev))) { | 164 | if (IS_ERR(priv->io_base)) { |
165 | dev_err(&pdev->dev, "request_mem_region failed\n"); | 165 | err = PTR_ERR(priv->io_base); |
166 | err = -EBUSY; | ||
167 | goto out_timer; | 166 | goto out_timer; |
168 | } | 167 | } |
169 | 168 | ||
170 | priv->io_base = ioremap(res->start, resource_size(res)); | ||
171 | if (priv->io_base == NULL) { | ||
172 | dev_err(&pdev->dev, "ioremap failed\n"); | ||
173 | err = -EIO; | ||
174 | goto out_release_io; | ||
175 | } | ||
176 | |||
177 | err = hwrng_register(&priv->timeriomem_rng_ops); | 169 | err = hwrng_register(&priv->timeriomem_rng_ops); |
178 | if (err) { | 170 | if (err) { |
179 | dev_err(&pdev->dev, "problem registering\n"); | 171 | dev_err(&pdev->dev, "problem registering\n"); |
180 | goto out; | 172 | goto out_timer; |
181 | } | 173 | } |
182 | 174 | ||
183 | dev_info(&pdev->dev, "32bits from 0x%p @ %dus\n", | 175 | dev_info(&pdev->dev, "32bits from 0x%p @ %dus\n", |
@@ -185,30 +177,18 @@ static int timeriomem_rng_probe(struct platform_device *pdev) | |||
185 | 177 | ||
186 | return 0; | 178 | return 0; |
187 | 179 | ||
188 | out: | ||
189 | iounmap(priv->io_base); | ||
190 | out_release_io: | ||
191 | release_mem_region(res->start, resource_size(res)); | ||
192 | out_timer: | 180 | out_timer: |
193 | del_timer_sync(&priv->timer); | 181 | del_timer_sync(&priv->timer); |
194 | out_free: | ||
195 | kfree(priv); | ||
196 | return err; | 182 | return err; |
197 | } | 183 | } |
198 | 184 | ||
199 | static int timeriomem_rng_remove(struct platform_device *pdev) | 185 | static int timeriomem_rng_remove(struct platform_device *pdev) |
200 | { | 186 | { |
201 | struct timeriomem_rng_private_data *priv = platform_get_drvdata(pdev); | 187 | struct timeriomem_rng_private_data *priv = platform_get_drvdata(pdev); |
202 | struct resource *res; | ||
203 | |||
204 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
205 | 188 | ||
206 | hwrng_unregister(&priv->timeriomem_rng_ops); | 189 | hwrng_unregister(&priv->timeriomem_rng_ops); |
207 | 190 | ||
208 | del_timer_sync(&priv->timer); | 191 | del_timer_sync(&priv->timer); |
209 | iounmap(priv->io_base); | ||
210 | release_mem_region(res->start, resource_size(res)); | ||
211 | kfree(priv); | ||
212 | 192 | ||
213 | return 0; | 193 | return 0; |
214 | } | 194 | } |