crypto: sa2ul - Use of_device_get_match_data() helper
authorSuman Anna <s-anna@ti.com>
Fri, 14 May 2021 16:12:44 +0000 (11:12 -0500)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 23 May 2021 00:52:40 +0000 (08:52 +0800)
Simplify the probe function by using the of_device_get_match_data()
helper instead of open coding. The logic is also moved up to fix the
missing pm_runtime cleanup in case of a match failure.

Fixes: 0bc42311cdff ("crypto: sa2ul - Add support for AM64")
Signed-off-by: Suman Anna <s-anna@ti.com>
Reviewed-by: Tero Kristo <kristo@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/sa2ul.c

index a215daedf78af56e6abc12bd85a6bfa504d6e78f..9f077ec9dbb7fe0d1089a0260299e0a3ee09d136 100644 (file)
@@ -2388,7 +2388,6 @@ MODULE_DEVICE_TABLE(of, of_match);
 
 static int sa_ul_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *match;
        struct device *dev = &pdev->dev;
        struct device_node *node = dev->of_node;
        struct resource *res;
@@ -2400,6 +2399,10 @@ static int sa_ul_probe(struct platform_device *pdev)
        if (!dev_data)
                return -ENOMEM;
 
+       dev_data->match_data = of_device_get_match_data(dev);
+       if (!dev_data->match_data)
+               return -ENODEV;
+
        sa_k3_dev = dev;
        dev_data->dev = dev;
        dev_data->pdev = pdev;
@@ -2420,13 +2423,6 @@ static int sa_ul_probe(struct platform_device *pdev)
        if (ret)
                goto destroy_dma_pool;
 
-       match = of_match_node(of_match, dev->of_node);
-       if (!match) {
-               dev_err(dev, "No compatible match found\n");
-               return -ENODEV;
-       }
-       dev_data->match_data = match->data;
-
        spin_lock_init(&dev_data->scid_lock);
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        saul_base = devm_ioremap_resource(dev, res);