These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / crypto / ccp / ccp-platform.c
index b1c20b2..01b50cb 100644 (file)
@@ -29,7 +29,6 @@
 #include "ccp-dev.h"
 
 struct ccp_platform {
-       int use_acpi;
        int coherent;
 };
 
@@ -90,64 +89,12 @@ static struct resource *ccp_find_mmio_area(struct ccp_device *ccp)
        return NULL;
 }
 
-#ifdef CONFIG_ACPI
-static int ccp_acpi_support(struct ccp_device *ccp)
-{
-       struct ccp_platform *ccp_platform = ccp->dev_specific;
-       struct acpi_device *adev = ACPI_COMPANION(ccp->dev);
-       acpi_handle handle;
-       acpi_status status;
-       unsigned long long data;
-       int cca;
-
-       /* Retrieve the device cache coherency value */
-       handle = adev->handle;
-       do {
-               status = acpi_evaluate_integer(handle, "_CCA", NULL, &data);
-               if (!ACPI_FAILURE(status)) {
-                       cca = data;
-                       break;
-               }
-       } while (!ACPI_FAILURE(status));
-
-       if (ACPI_FAILURE(status)) {
-               dev_err(ccp->dev, "error obtaining acpi coherency value\n");
-               return -EINVAL;
-       }
-
-       ccp_platform->coherent = !!cca;
-
-       return 0;
-}
-#else  /* CONFIG_ACPI */
-static int ccp_acpi_support(struct ccp_device *ccp)
-{
-       return -EINVAL;
-}
-#endif
-
-#ifdef CONFIG_OF
-static int ccp_of_support(struct ccp_device *ccp)
-{
-       struct ccp_platform *ccp_platform = ccp->dev_specific;
-
-       ccp_platform->coherent = of_dma_is_coherent(ccp->dev->of_node);
-
-       return 0;
-}
-#else
-static int ccp_of_support(struct ccp_device *ccp)
-{
-       return -EINVAL;
-}
-#endif
-
 static int ccp_platform_probe(struct platform_device *pdev)
 {
        struct ccp_device *ccp;
        struct ccp_platform *ccp_platform;
        struct device *dev = &pdev->dev;
-       struct acpi_device *adev = ACPI_COMPANION(dev);
+       enum dev_dma_attr attr;
        struct resource *ior;
        int ret;
 
@@ -164,8 +111,6 @@ static int ccp_platform_probe(struct platform_device *pdev)
        ccp->get_irq = ccp_get_irqs;
        ccp->free_irq = ccp_free_irqs;
 
-       ccp_platform->use_acpi = (!adev || acpi_disabled) ? 0 : 1;
-
        ior = ccp_find_mmio_area(ccp);
        ccp->io_map = devm_ioremap_resource(dev, ior);
        if (IS_ERR(ccp->io_map)) {
@@ -174,26 +119,24 @@ static int ccp_platform_probe(struct platform_device *pdev)
        }
        ccp->io_regs = ccp->io_map;
 
-       if (!dev->dma_mask)
-               dev->dma_mask = &dev->coherent_dma_mask;
-       ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
-       if (ret) {
-               dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
+       attr = device_get_dma_attr(dev);
+       if (attr == DEV_DMA_NOT_SUPPORTED) {
+               dev_err(dev, "DMA is not supported");
                goto e_err;
        }
 
-       if (ccp_platform->use_acpi)
-               ret = ccp_acpi_support(ccp);
-       else
-               ret = ccp_of_support(ccp);
-       if (ret)
-               goto e_err;
-
+       ccp_platform->coherent = (attr == DEV_DMA_COHERENT);
        if (ccp_platform->coherent)
                ccp->axcache = CACHE_WB_NO_ALLOC;
        else
                ccp->axcache = CACHE_NONE;
 
+       ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+       if (ret) {
+               dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
+               goto e_err;
+       }
+
        dev_set_drvdata(dev, ccp);
 
        ret = ccp_init(ccp);
@@ -276,6 +219,7 @@ static const struct acpi_device_id ccp_acpi_match[] = {
        { "AMDI0C00", 0 },
        { },
 };
+MODULE_DEVICE_TABLE(acpi, ccp_acpi_match);
 #endif
 
 #ifdef CONFIG_OF
@@ -283,11 +227,12 @@ static const struct of_device_id ccp_of_match[] = {
        { .compatible = "amd,ccp-seattle-v1a" },
        { },
 };
+MODULE_DEVICE_TABLE(of, ccp_of_match);
 #endif
 
 static struct platform_driver ccp_platform_driver = {
        .driver = {
-               .name = "AMD Cryptographic Coprocessor",
+               .name = "ccp",
 #ifdef CONFIG_ACPI
                .acpi_match_table = ccp_acpi_match,
 #endif