]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fbdev: simplefb: Use of_reserved_mem_region_to_resource() for "memory-region"
authorRob Herring (Arm) <robh@kernel.org>
Thu, 3 Jul 2025 18:35:13 +0000 (13:35 -0500)
committerHelge Deller <deller@gmx.de>
Sun, 27 Jul 2025 17:56:51 +0000 (19:56 +0200)
Use the newly added of_reserved_mem_region_to_resource() function to
handle "memory-region" properties.

The error handling is a bit different. "memory-region" is optional, so
failed lookup is not an error. But then an error in
of_address_to_resource() is treated as an error. However, that
distinction is not really important. Either the region is available
and usable or it is not. So now, it is just
of_reserved_mem_region_to_resource() which is checked for an error.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/simplefb.c

index be95fcddce4c8ca794826b805cd7dad2985bd637..1893815dc67f4c1403eea42c0e10a7ead4d96ba9 100644 (file)
@@ -21,9 +21,9 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
 #include <linux/of_clk.h>
 #include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
 #include <linux/parser.h>
 #include <linux/pm_domain.h>
 #include <linux/regulator/consumer.h>
@@ -134,7 +134,7 @@ struct simplefb_params {
 static int simplefb_parse_dt(struct platform_device *pdev,
                           struct simplefb_params *params)
 {
-       struct device_node *np = pdev->dev.of_node, *mem;
+       struct device_node *np = pdev->dev.of_node;
        int ret;
        const char *format;
        int i;
@@ -174,19 +174,10 @@ static int simplefb_parse_dt(struct platform_device *pdev,
                return -EINVAL;
        }
 
-       mem = of_parse_phandle(np, "memory-region", 0);
-       if (mem) {
-               ret = of_address_to_resource(mem, 0, &params->memory);
-               if (ret < 0) {
-                       dev_err(&pdev->dev, "failed to parse memory-region\n");
-                       of_node_put(mem);
-                       return ret;
-               }
-
+       ret = of_reserved_mem_region_to_resource(np, 0, &params->memory);
+       if (!ret) {
                if (of_property_present(np, "reg"))
                        dev_warn(&pdev->dev, "preferring \"memory-region\" over \"reg\" property\n");
-
-               of_node_put(mem);
        } else {
                memset(&params->memory, 0, sizeof(params->memory));
        }