drm/tilcdc: request and mapp iomem with devres
authorPhilipp Stanner <pstanner@redhat.com>
Fri, 22 Dec 2023 11:52:17 +0000 (12:52 +0100)
committerJyri Sarha <jyri.sarha@iki.fi>
Thu, 28 Dec 2023 17:29:04 +0000 (19:29 +0200)
tilcdc currently just ioremaps its iomem, without doing the (a bit more
robust) request on the memory first. The devm_ functions provide a handy
way to both request and ioremap the memory with automatic cleanup.

Replace the manual ioremap with the devm_ version.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi>
Tested-by: Jyri Sarha <jyri.sarha@iki.fi>
Signed-off-by: Jyri Sarha <jyri.sarha@iki.fi>
Link: https://patchwork.freedesktop.org/patch/msgid/20231222115216.19218-2-pstanner@redhat.com
drivers/gpu/drm/tilcdc/tilcdc_drv.c

index 23bf16f596f617631985c5a039b5c203b67747ca..cd5eefa06060df44343e926ec0035f6a28b85675 100644 (file)
@@ -182,9 +182,6 @@ static void tilcdc_fini(struct drm_device *dev)
        if (priv->clk)
                clk_put(priv->clk);
 
-       if (priv->mmio)
-               iounmap(priv->mmio);
-
        if (priv->wq)
                destroy_workqueue(priv->wq);
 
@@ -201,7 +198,6 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
        struct platform_device *pdev = to_platform_device(dev);
        struct device_node *node = dev->of_node;
        struct tilcdc_drm_private *priv;
-       struct resource *res;
        u32 bpp = 0;
        int ret;
 
@@ -226,17 +222,10 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
                goto init_failed;
        }
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(dev, "failed to get memory resource\n");
-               ret = -EINVAL;
-               goto init_failed;
-       }
-
-       priv->mmio = ioremap(res->start, resource_size(res));
-       if (!priv->mmio) {
-               dev_err(dev, "failed to ioremap\n");
-               ret = -ENOMEM;
+       priv->mmio = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(priv->mmio)) {
+               dev_err(dev, "failed to request / ioremap\n");
+               ret = PTR_ERR(priv->mmio);
                goto init_failed;
        }