[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250318111242.00007457@huawei.com>
Date: Tue, 18 Mar 2025 11:12:42 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: "Rob Herring (Arm)" <robh@...nel.org>
CC: Saravana Kannan <saravanak@...gle.com>, Bjorn Andersson
<andersson@...nel.org>, Mathieu Poirier <mathieu.poirier@...aro.org>, "Shawn
Guo" <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>, Fabio Estevam
<festevam@...il.com>, Patrice Chotard <patrice.chotard@...s.st.com>, "Maxime
Coquelin" <mcoquelin.stm32@...il.com>, Alexandre Torgue
<alexandre.torgue@...s.st.com>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-remoteproc@...r.kernel.org>,
<imx@...ts.linux.dev>, <linux-arm-kernel@...ts.infradead.org>,
<linux-arm-msm@...r.kernel.org>, <linux-stm32@...md-mailman.stormreply.com>
Subject: Re: [PATCH 1/3] of: reserved_mem: Add functions to parse
"memory-region"
On Mon, 17 Mar 2025 18:24:21 -0500
"Rob Herring (Arm)" <robh@...nel.org> wrote:
> Drivers with "memory-region" properties currently have to do their own
> parsing of "memory-region" properties. The result is all the drivers
> have similar patterns of a call to parse "memory-region" and then get
> the region's address and size. As this is a standard property, it should
> have common functions for drivers to use. Add new functions to count the
> number of regions and retrieve the region's address as a resource.
>
> Signed-off-by: Rob Herring (Arm) <robh@...nel.org>
> ---
> drivers/of/of_reserved_mem.c | 77 +++++++++++++++++++++++++++++++++
> include/linux/of_reserved_mem.h | 26 +++++++++++
> 2 files changed, 103 insertions(+)
>
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 75e819f66a56..fd50038dff76 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -12,6 +12,7 @@
> #define pr_fmt(fmt) "OF: reserved mem: " fmt
>
> #include <linux/err.h>
> +#include <linux/ioport.h>
> #include <linux/libfdt.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> @@ -740,3 +741,79 @@ struct reserved_mem *of_reserved_mem_lookup(struct device_node *np)
> return NULL;
> }
> EXPORT_SYMBOL_GPL(of_reserved_mem_lookup);
> +
> +/**
> + * of_reserved_mem_region_to_resource() - Get a reserved memory region as a resource
> + * @np: node containing 'memory-region' property
> + * @idx: index of 'memory-region' property to lookup
> + * @res: Pointer to a struct resource to fill in with reserved region
> + *
> + * This function allows drivers to lookup a node's 'memory-region' property
> + * entries by index and return a struct resource for the entry.
> + *
> + * Returns 0 on success with @res filled in. Returns -ENODEV if 'memory-region'
> + * is missing or unavailable, -EINVAL for any other error.
> + */
> +int of_reserved_mem_region_to_resource(const struct device_node *np, unsigned int idx, struct resource *res)
Maybe wrap?
> +{
Powered by blists - more mailing lists