Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 16:28:16 +0000 (09:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 16:28:16 +0000 (09:28 -0700)
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
  ...

1  2 
drivers/char/hw_random/core.c
drivers/char/hw_random/nomadik-rng.c

index b9495a8c05c6d7e9b192c8a2b403b7fb2ac90fdc,7ac96fbc06edf4374d5bfc085a60ed5c0c1b9b54..334601cc81cf57ce92e83664ec192a01a5e353c4
  #include <linux/kernel.h>
  #include <linux/fs.h>
  #include <linux/sched.h>
 -#include <linux/init.h>
  #include <linux/miscdevice.h>
  #include <linux/delay.h>
  #include <linux/slab.h>
+ #include <linux/random.h>
  #include <asm/uaccess.h>
  
  
@@@ -301,9 -303,10 +302,10 @@@ err_misc_dereg
  
  int hwrng_register(struct hwrng *rng)
  {
-       int must_register_misc;
        int err = -EINVAL;
        struct hwrng *old_rng, *tmp;
+       unsigned char bytes[16];
+       int bytes_read;
  
        if (rng->name == NULL ||
            (rng->data_read == NULL && rng->read == NULL))
                        goto out_unlock;
        }
  
-       must_register_misc = (current_rng == NULL);
        old_rng = current_rng;
        if (!old_rng) {
                err = hwrng_init(rng);
                current_rng = rng;
        }
        err = 0;
-       if (must_register_misc) {
+       if (!old_rng) {
                err = register_miscdev();
                if (err) {
-                       if (!old_rng) {
-                               hwrng_cleanup(rng);
-                               current_rng = NULL;
-                       }
+                       hwrng_cleanup(rng);
+                       current_rng = NULL;
                        goto out_unlock;
                }
        }
        INIT_LIST_HEAD(&rng->list);
        list_add_tail(&rng->list, &rng_list);
+       bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1);
+       if (bytes_read > 0)
+               add_device_randomness(bytes, bytes_read);
  out_unlock:
        mutex_unlock(&rng_mutex);
  out:
index 00e9d2d466343784a46abae1bbdbb5623d6d5037,bc904bb3f8a2c0484bbed975f5b9f4a7f5d3077e..9c85815772464d526afb22208e55a9d9b3ab141a
@@@ -10,6 -10,7 +10,6 @@@
  
  #include <linux/kernel.h>
  #include <linux/module.h>
 -#include <linux/init.h>
  #include <linux/device.h>
  #include <linux/amba/bus.h>
  #include <linux/hw_random.h>
@@@ -43,7 -44,7 +43,7 @@@ static int nmk_rng_probe(struct amba_de
        void __iomem *base;
        int ret;
  
-       rng_clk = clk_get(&dev->dev, NULL);
+       rng_clk = devm_clk_get(&dev->dev, NULL);
        if (IS_ERR(rng_clk)) {
                dev_err(&dev->dev, "could not get rng clock\n");
                ret = PTR_ERR(rng_clk);
        if (ret)
                goto out_clk;
        ret = -ENOMEM;
-       base = ioremap(dev->res.start, resource_size(&dev->res));
+       base = devm_ioremap(&dev->dev, dev->res.start,
+                           resource_size(&dev->res));
        if (!base)
                goto out_release;
        nmk_rng.priv = (unsigned long)base;
        ret = hwrng_register(&nmk_rng);
        if (ret)
-               goto out_unmap;
+               goto out_release;
        return 0;
  
- out_unmap:
-       iounmap(base);
  out_release:
        amba_release_regions(dev);
  out_clk:
        clk_disable(rng_clk);
-       clk_put(rng_clk);
        return ret;
  }
  
  static int nmk_rng_remove(struct amba_device *dev)
  {
-       void __iomem *base = (void __iomem *)nmk_rng.priv;
        hwrng_unregister(&nmk_rng);
-       iounmap(base);
        amba_release_regions(dev);
        clk_disable(rng_clk);
-       clk_put(rng_clk);
        return 0;
  }