diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2017-07-06 16:59:13 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2017-07-18 11:50:59 +0200 |
commit | 970e8303cb8d6d8e77402345abbdd83862e800ac (patch) | |
tree | 2bec04857f2902b78ff4f56095f220d22f8a11fe /drivers/crypto/ccp/ccp-platform.c | |
parent | MAINTAINERS: add a maintainer for Microchip / Atmel ECC driver (diff) | |
download | linux-970e8303cb8d6d8e77402345abbdd83862e800ac.tar.xz linux-970e8303cb8d6d8e77402345abbdd83862e800ac.zip |
crypto: ccp - Use devres interface to allocate PCI/iomap and cleanup
Update pci and platform files to use devres interface to allocate the PCI
and iomap resources. Also add helper functions to consolicate module init,
exit and power mangagement code duplication.
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/ccp-platform.c')
-rw-r--r-- | drivers/crypto/ccp/ccp-platform.c | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c index 6020c4ae72fc..613188c5a624 100644 --- a/drivers/crypto/ccp/ccp-platform.c +++ b/drivers/crypto/ccp/ccp-platform.c @@ -104,19 +104,6 @@ static void ccp_free_irqs(struct ccp_device *ccp) free_irq(ccp->irq, dev); } -static struct resource *ccp_find_mmio_area(struct ccp_device *ccp) -{ - struct device *dev = ccp->dev; - struct platform_device *pdev = to_platform_device(dev); - struct resource *ior; - - ior = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (ior && (resource_size(ior) >= 0x800)) - return ior; - - return NULL; -} - static int ccp_platform_probe(struct platform_device *pdev) { struct ccp_device *ccp; @@ -146,7 +133,7 @@ static int ccp_platform_probe(struct platform_device *pdev) ccp->get_irq = ccp_get_irqs; ccp->free_irq = ccp_free_irqs; - ior = ccp_find_mmio_area(ccp); + ior = platform_get_resource(pdev, IORESOURCE_MEM, 0); ccp->io_map = devm_ioremap_resource(dev, ior); if (IS_ERR(ccp->io_map)) { ret = PTR_ERR(ccp->io_map); @@ -174,7 +161,7 @@ static int ccp_platform_probe(struct platform_device *pdev) dev_set_drvdata(dev, ccp); - ret = ccp->vdata->perform->init(ccp); + ret = ccp_dev_init(ccp); if (ret) goto e_err; @@ -192,7 +179,7 @@ static int ccp_platform_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct ccp_device *ccp = dev_get_drvdata(dev); - ccp->vdata->perform->destroy(ccp); + ccp_dev_destroy(ccp); dev_notice(dev, "disabled\n"); @@ -205,47 +192,16 @@ static int ccp_platform_suspend(struct platform_device *pdev, { struct device *dev = &pdev->dev; struct ccp_device *ccp = dev_get_drvdata(dev); - unsigned long flags; - unsigned int i; - - spin_lock_irqsave(&ccp->cmd_lock, flags); - ccp->suspending = 1; - - /* Wake all the queue kthreads to prepare for suspend */ - for (i = 0; i < ccp->cmd_q_count; i++) - wake_up_process(ccp->cmd_q[i].kthread); - - spin_unlock_irqrestore(&ccp->cmd_lock, flags); - - /* Wait for all queue kthreads to say they're done */ - while (!ccp_queues_suspended(ccp)) - wait_event_interruptible(ccp->suspend_queue, - ccp_queues_suspended(ccp)); - - return 0; + return ccp_dev_suspend(ccp, state); } static int ccp_platform_resume(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ccp_device *ccp = dev_get_drvdata(dev); - unsigned long flags; - unsigned int i; - - spin_lock_irqsave(&ccp->cmd_lock, flags); - ccp->suspending = 0; - - /* Wake up all the kthreads */ - for (i = 0; i < ccp->cmd_q_count; i++) { - ccp->cmd_q[i].suspended = 0; - wake_up_process(ccp->cmd_q[i].kthread); - } - - spin_unlock_irqrestore(&ccp->cmd_lock, flags); - - return 0; + return ccp_dev_resume(ccp); } #endif @@ -260,7 +216,7 @@ MODULE_DEVICE_TABLE(acpi, ccp_acpi_match); #ifdef CONFIG_OF static const struct of_device_id ccp_of_match[] = { { .compatible = "amd,ccp-seattle-v1a", - .data = (const void *)&ccpv3 }, + .data = (const void *)&ccpv3_platform }, { }, }; MODULE_DEVICE_TABLE(of, ccp_of_match); |