Skip to content

Commit 9ba5502

Browse files
robherringSuzuki K Poulose
authored andcommitted
hwtracing: coresight: Use of_reserved_mem_region_to_resource() for "memory-region"
Use the newly added of_reserved_mem_region_to_resource() function to handle "memory-region" properties. Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20250703183534.2075569-1-robh@kernel.org
1 parent 12d9a9d commit 9ba5502

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

drivers/hwtracing/coresight/coresight-tmc-core.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/pm_runtime.h>
2525
#include <linux/of.h>
2626
#include <linux/of_address.h>
27+
#include <linux/of_reserved_mem.h>
2728
#include <linux/coresight.h>
2829
#include <linux/amba/bus.h>
2930
#include <linux/platform_device.h>
@@ -634,25 +635,14 @@ static int of_tmc_get_reserved_resource_by_name(struct device *dev,
634635
const char *name,
635636
struct resource *res)
636637
{
637-
int index, rc = -ENODEV;
638-
struct device_node *node;
638+
int rc = -ENODEV;
639639

640-
if (!is_of_node(dev->fwnode))
641-
return -ENODEV;
642-
643-
index = of_property_match_string(dev->of_node, "memory-region-names",
644-
name);
645-
if (index < 0)
646-
return rc;
647-
648-
node = of_parse_phandle(dev->of_node, "memory-region", index);
649-
if (!node)
640+
rc = of_reserved_mem_region_to_resource_byname(dev->of_node, name, res);
641+
if (rc < 0)
650642
return rc;
651643

652-
if (!of_address_to_resource(node, 0, res) &&
653-
res->start != 0 && resource_size(res) != 0)
654-
rc = 0;
655-
of_node_put(node);
644+
if (res->start == 0 || resource_size(res) == 0)
645+
rc = -ENODEV;
656646

657647
return rc;
658648
}

0 commit comments

Comments
 (0)