From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: "Rob Herring (Arm)" <robh@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
"Shawn Guo" <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-remoteproc@vger.kernel.org>, <imx@lists.linux.dev>,
<linux-arm-kernel@lists.infradead.org>,
<linux-arm-msm@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 1/3] of: reserved_mem: Add functions to parse "memory-region"
Date: Tue, 18 Mar 2025 11:12:42 +0000 [thread overview]
Message-ID: <20250318111242.00007457@huawei.com> (raw)
In-Reply-To: <20250317232426.952188-2-robh@kernel.org>
On Mon, 17 Mar 2025 18:24:21 -0500
"Rob Herring (Arm)" <robh@kernel.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@kernel.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?
> +{
next prev parent reply other threads:[~2025-03-18 11:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 23:24 [PATCH 0/3] of: Common "memory-region" parsing Rob Herring (Arm)
2025-03-17 23:24 ` [PATCH 1/3] of: reserved_mem: Add functions to parse "memory-region" Rob Herring (Arm)
2025-03-18 8:54 ` Daniel Baluta
2025-03-18 11:12 ` Jonathan Cameron [this message]
2025-03-17 23:24 ` [PATCH 2/3] of: Simplify of_dma_set_restricted_buffer() to use of_for_each_phandle() Rob Herring (Arm)
2025-03-26 6:44 ` Chen-Yu Tsai
2025-03-26 18:52 ` Rob Herring
2025-03-27 4:32 ` Chen-Yu Tsai
2025-03-17 23:24 ` [PATCH 3/3] remoteproc: Use of_reserved_mem_region_* functions for "memory-region" Rob Herring (Arm)
2025-03-18 8:57 ` Daniel Baluta
2025-03-18 10:48 ` neil.armstrong
2025-03-19 15:23 ` [Linux-stm32] " Arnaud POULIQUEN
2025-03-19 23:04 ` Rob Herring
2025-03-20 9:21 ` Arnaud POULIQUEN
2025-03-20 9:37 ` Arnaud POULIQUEN
2025-03-20 18:02 ` Rob Herring
2025-03-21 8:22 ` Arnaud POULIQUEN
2025-03-21 13:14 ` Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250318111242.00007457@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mathieu.poirier@linaro.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=patrice.chotard@foss.st.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=saravanak@google.com \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).