Loading Documentation/devicetree/bindings/rng/omap_rng.txt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -12,7 +12,8 @@ Required properties: - reg : Offset and length of the register set for the module - reg : Offset and length of the register set for the module - interrupts : the interrupt number for the RNG module. - interrupts : the interrupt number for the RNG module. Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" - clocks: the trng clock source - clocks: the trng clock source. Only mandatory for the "inside-secure,safexcel-eip76" compatible. Example: Example: /* AM335x */ /* AM335x */ Loading crypto/lrw.c +5 −2 Original line number Original line Diff line number Diff line Loading @@ -286,8 +286,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) subreq->cryptlen = LRW_BUFFER_SIZE; subreq->cryptlen = LRW_BUFFER_SIZE; if (req->cryptlen > LRW_BUFFER_SIZE) { if (req->cryptlen > LRW_BUFFER_SIZE) { subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); rctx->ext = kmalloc(subreq->cryptlen, gfp); rctx->ext = kmalloc(n, gfp); if (rctx->ext) subreq->cryptlen = n; } } rctx->src = req->src; rctx->src = req->src; Loading crypto/xts.c +5 −2 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) subreq->cryptlen = XTS_BUFFER_SIZE; subreq->cryptlen = XTS_BUFFER_SIZE; if (req->cryptlen > XTS_BUFFER_SIZE) { if (req->cryptlen > XTS_BUFFER_SIZE) { subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); rctx->ext = kmalloc(subreq->cryptlen, gfp); rctx->ext = kmalloc(n, gfp); if (rctx->ext) subreq->cryptlen = n; } } rctx->src = req->src; rctx->src = req->src; Loading drivers/char/hw_random/amd-rng.c +34 −8 Original line number Original line Diff line number Diff line Loading @@ -55,6 +55,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl); struct amd768_priv { struct amd768_priv { void __iomem *iobase; void __iomem *iobase; struct pci_dev *pcidev; struct pci_dev *pcidev; u32 pmbase; }; }; static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) Loading Loading @@ -148,33 +149,58 @@ static int __init mod_init(void) if (pmbase == 0) if (pmbase == 0) return -EIO; return -EIO; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) if (!priv) return -ENOMEM; return -ENOMEM; if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET, if (!request_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE, DRV_NAME)) { PMBASE_SIZE, DRV_NAME)) { dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n", dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n", pmbase + 0xF0); pmbase + 0xF0); return -EBUSY; err = -EBUSY; goto out; } } priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET, priv->iobase = ioport_map(pmbase + PMBASE_OFFSET, PMBASE_SIZE); PMBASE_SIZE); if (!priv->iobase) { if (!priv->iobase) { pr_err(DRV_NAME "Cannot map ioport\n"); pr_err(DRV_NAME "Cannot map ioport\n"); return -ENOMEM; err = -EINVAL; goto err_iomap; } } amd_rng.priv = (unsigned long)priv; amd_rng.priv = (unsigned long)priv; priv->pmbase = pmbase; priv->pcidev = pdev; priv->pcidev = pdev; pr_info(DRV_NAME " detected\n"); pr_info(DRV_NAME " detected\n"); return devm_hwrng_register(&pdev->dev, &amd_rng); err = hwrng_register(&amd_rng); if (err) { pr_err(DRV_NAME " registering failed (%d)\n", err); goto err_hwrng; } return 0; err_hwrng: ioport_unmap(priv->iobase); err_iomap: release_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE); out: kfree(priv); return err; } } static void __exit mod_exit(void) static void __exit mod_exit(void) { { struct amd768_priv *priv; priv = (struct amd768_priv *)amd_rng.priv; hwrng_unregister(&amd_rng); ioport_unmap(priv->iobase); release_region(priv->pmbase + PMBASE_OFFSET, PMBASE_SIZE); kfree(priv); } } module_init(mod_init); module_init(mod_init); Loading drivers/char/hw_random/geode-rng.c +35 −15 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,9 @@ #include <linux/module.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/pci.h> #define PFX KBUILD_MODNAME ": " #define GEODE_RNG_DATA_REG 0x50 #define GEODE_RNG_DATA_REG 0x50 #define GEODE_RNG_STATUS_REG 0x54 #define GEODE_RNG_STATUS_REG 0x54 Loading Loading @@ -82,6 +85,7 @@ static struct hwrng geode_rng = { static int __init mod_init(void) static int __init mod_init(void) { { int err = -ENODEV; struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL; const struct pci_device_id *ent; const struct pci_device_id *ent; void __iomem *mem; void __iomem *mem; Loading @@ -89,27 +93,43 @@ static int __init mod_init(void) for_each_pci_dev(pdev) { for_each_pci_dev(pdev) { ent = pci_match_id(pci_tbl, pdev); ent = pci_match_id(pci_tbl, pdev); if (ent) { if (ent) goto found; } /* Device not found. */ goto out; found: rng_base = pci_resource_start(pdev, 0); rng_base = pci_resource_start(pdev, 0); if (rng_base == 0) if (rng_base == 0) return -ENODEV; goto out; err = -ENOMEM; mem = devm_ioremap(&pdev->dev, rng_base, 0x58); mem = ioremap(rng_base, 0x58); if (!mem) if (!mem) return -ENOMEM; goto out; geode_rng.priv = (unsigned long)mem; geode_rng.priv = (unsigned long)mem; pr_info("AMD Geode RNG detected\n"); pr_info("AMD Geode RNG detected\n"); return devm_hwrng_register(&pdev->dev, &geode_rng); err = hwrng_register(&geode_rng); } if (err) { pr_err(PFX "RNG registering failed (%d)\n", err); goto err_unmap; } } out: return err; /* Device not found. */ err_unmap: return -ENODEV; iounmap(mem); goto out; } } static void __exit mod_exit(void) static void __exit mod_exit(void) { { void __iomem *mem = (void __iomem *)geode_rng.priv; hwrng_unregister(&geode_rng); iounmap(mem); } } module_init(mod_init); module_init(mod_init); Loading Loading
Documentation/devicetree/bindings/rng/omap_rng.txt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -12,7 +12,8 @@ Required properties: - reg : Offset and length of the register set for the module - reg : Offset and length of the register set for the module - interrupts : the interrupt number for the RNG module. - interrupts : the interrupt number for the RNG module. Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" - clocks: the trng clock source - clocks: the trng clock source. Only mandatory for the "inside-secure,safexcel-eip76" compatible. Example: Example: /* AM335x */ /* AM335x */ Loading
crypto/lrw.c +5 −2 Original line number Original line Diff line number Diff line Loading @@ -286,8 +286,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) subreq->cryptlen = LRW_BUFFER_SIZE; subreq->cryptlen = LRW_BUFFER_SIZE; if (req->cryptlen > LRW_BUFFER_SIZE) { if (req->cryptlen > LRW_BUFFER_SIZE) { subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); rctx->ext = kmalloc(subreq->cryptlen, gfp); rctx->ext = kmalloc(n, gfp); if (rctx->ext) subreq->cryptlen = n; } } rctx->src = req->src; rctx->src = req->src; Loading
crypto/xts.c +5 −2 Original line number Original line Diff line number Diff line Loading @@ -230,8 +230,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) subreq->cryptlen = XTS_BUFFER_SIZE; subreq->cryptlen = XTS_BUFFER_SIZE; if (req->cryptlen > XTS_BUFFER_SIZE) { if (req->cryptlen > XTS_BUFFER_SIZE) { subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); rctx->ext = kmalloc(subreq->cryptlen, gfp); rctx->ext = kmalloc(n, gfp); if (rctx->ext) subreq->cryptlen = n; } } rctx->src = req->src; rctx->src = req->src; Loading
drivers/char/hw_random/amd-rng.c +34 −8 Original line number Original line Diff line number Diff line Loading @@ -55,6 +55,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl); struct amd768_priv { struct amd768_priv { void __iomem *iobase; void __iomem *iobase; struct pci_dev *pcidev; struct pci_dev *pcidev; u32 pmbase; }; }; static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) Loading Loading @@ -148,33 +149,58 @@ static int __init mod_init(void) if (pmbase == 0) if (pmbase == 0) return -EIO; return -EIO; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) if (!priv) return -ENOMEM; return -ENOMEM; if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET, if (!request_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE, DRV_NAME)) { PMBASE_SIZE, DRV_NAME)) { dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n", dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n", pmbase + 0xF0); pmbase + 0xF0); return -EBUSY; err = -EBUSY; goto out; } } priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET, priv->iobase = ioport_map(pmbase + PMBASE_OFFSET, PMBASE_SIZE); PMBASE_SIZE); if (!priv->iobase) { if (!priv->iobase) { pr_err(DRV_NAME "Cannot map ioport\n"); pr_err(DRV_NAME "Cannot map ioport\n"); return -ENOMEM; err = -EINVAL; goto err_iomap; } } amd_rng.priv = (unsigned long)priv; amd_rng.priv = (unsigned long)priv; priv->pmbase = pmbase; priv->pcidev = pdev; priv->pcidev = pdev; pr_info(DRV_NAME " detected\n"); pr_info(DRV_NAME " detected\n"); return devm_hwrng_register(&pdev->dev, &amd_rng); err = hwrng_register(&amd_rng); if (err) { pr_err(DRV_NAME " registering failed (%d)\n", err); goto err_hwrng; } return 0; err_hwrng: ioport_unmap(priv->iobase); err_iomap: release_region(pmbase + PMBASE_OFFSET, PMBASE_SIZE); out: kfree(priv); return err; } } static void __exit mod_exit(void) static void __exit mod_exit(void) { { struct amd768_priv *priv; priv = (struct amd768_priv *)amd_rng.priv; hwrng_unregister(&amd_rng); ioport_unmap(priv->iobase); release_region(priv->pmbase + PMBASE_OFFSET, PMBASE_SIZE); kfree(priv); } } module_init(mod_init); module_init(mod_init); Loading
drivers/char/hw_random/geode-rng.c +35 −15 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,9 @@ #include <linux/module.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/pci.h> #define PFX KBUILD_MODNAME ": " #define GEODE_RNG_DATA_REG 0x50 #define GEODE_RNG_DATA_REG 0x50 #define GEODE_RNG_STATUS_REG 0x54 #define GEODE_RNG_STATUS_REG 0x54 Loading Loading @@ -82,6 +85,7 @@ static struct hwrng geode_rng = { static int __init mod_init(void) static int __init mod_init(void) { { int err = -ENODEV; struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL; const struct pci_device_id *ent; const struct pci_device_id *ent; void __iomem *mem; void __iomem *mem; Loading @@ -89,27 +93,43 @@ static int __init mod_init(void) for_each_pci_dev(pdev) { for_each_pci_dev(pdev) { ent = pci_match_id(pci_tbl, pdev); ent = pci_match_id(pci_tbl, pdev); if (ent) { if (ent) goto found; } /* Device not found. */ goto out; found: rng_base = pci_resource_start(pdev, 0); rng_base = pci_resource_start(pdev, 0); if (rng_base == 0) if (rng_base == 0) return -ENODEV; goto out; err = -ENOMEM; mem = devm_ioremap(&pdev->dev, rng_base, 0x58); mem = ioremap(rng_base, 0x58); if (!mem) if (!mem) return -ENOMEM; goto out; geode_rng.priv = (unsigned long)mem; geode_rng.priv = (unsigned long)mem; pr_info("AMD Geode RNG detected\n"); pr_info("AMD Geode RNG detected\n"); return devm_hwrng_register(&pdev->dev, &geode_rng); err = hwrng_register(&geode_rng); } if (err) { pr_err(PFX "RNG registering failed (%d)\n", err); goto err_unmap; } } out: return err; /* Device not found. */ err_unmap: return -ENODEV; iounmap(mem); goto out; } } static void __exit mod_exit(void) static void __exit mod_exit(void) { { void __iomem *mem = (void __iomem *)geode_rng.priv; hwrng_unregister(&geode_rng); iounmap(mem); } } module_init(mod_init); module_init(mod_init); Loading