Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: aspeed: 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.

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>
Link: https://patch.msgid.link/20250703183508.2074735-1-robh@kernel.org
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>

authored by

Rob Herring (Arm) and committed by
Andrew Jeffery
c5313eea 8f5ae30d

+6 -22
+3 -11
drivers/soc/aspeed/aspeed-lpc-ctrl.c
··· 10 10 #include <linux/mm.h> 11 11 #include <linux/module.h> 12 12 #include <linux/of_address.h> 13 + #include <linux/of_reserved_mem.h> 13 14 #include <linux/platform_device.h> 14 15 #include <linux/poll.h> 15 16 #include <linux/regmap.h> ··· 255 254 dev_set_drvdata(&pdev->dev, lpc_ctrl); 256 255 257 256 /* If memory-region is described in device tree then store */ 258 - node = of_parse_phandle(dev->of_node, "memory-region", 0); 259 - if (!node) { 260 - dev_dbg(dev, "Didn't find reserved memory\n"); 261 - } else { 262 - rc = of_address_to_resource(node, 0, &resm); 263 - of_node_put(node); 264 - if (rc) { 265 - dev_err(dev, "Couldn't address to resource for reserved memory\n"); 266 - return -ENXIO; 267 - } 268 - 257 + rc = of_reserved_mem_region_to_resource(dev->of_node, 0, &resm); 258 + if (!rc) { 269 259 lpc_ctrl->mem_size = resource_size(&resm); 270 260 lpc_ctrl->mem_base = resm.start; 271 261
+3 -11
drivers/soc/aspeed/aspeed-p2a-ctrl.c
··· 19 19 #include <linux/module.h> 20 20 #include <linux/mutex.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_address.h> 22 + #include <linux/of_reserved_mem.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/regmap.h> 25 25 #include <linux/slab.h> ··· 334 334 struct aspeed_p2a_ctrl *misc_ctrl; 335 335 struct device *dev; 336 336 struct resource resm; 337 - struct device_node *node; 338 337 int rc = 0; 339 338 340 339 dev = &pdev->dev; ··· 345 346 mutex_init(&misc_ctrl->tracking); 346 347 347 348 /* optional. */ 348 - node = of_parse_phandle(dev->of_node, "memory-region", 0); 349 - if (node) { 350 - rc = of_address_to_resource(node, 0, &resm); 351 - of_node_put(node); 352 - if (rc) { 353 - dev_err(dev, "Couldn't address to resource for reserved memory\n"); 354 - return -ENODEV; 355 - } 356 - 349 + rc = of_reserved_mem_region_to_resource(dev->of_node, 0, &resm); 350 + if (!rc) { 357 351 misc_ctrl->mem_size = resource_size(&resm); 358 352 misc_ctrl->mem_base = resm.start; 359 353 }