From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: at91: pm: fix SRAM allocation
Date: Tue, 3 Mar 2015 19:21:21 +0100 [thread overview]
Message-ID: <54F5FBA1.7000005@atmel.com> (raw)
In-Reply-To: <1425368287-4971-1-git-send-email-alexandre.belloni@free-electrons.com>
Le 03/03/2015 08:38, Alexandre Belloni a ?crit :
> On some platforms, there are multiple SRAM nodes defined in the device tree but
> some of them are disabled, leading to allocation failure. Try to find the first
> enabled SRAM node and allocate from it.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Tested-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
and added to at91-4.0-fixes. Thanks.
> ---
> Changes in v2:
> - initialize pdev to NULL
>
> arch/arm/mach-at91/pm.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 5e34fb143309..aa4116e9452f 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -270,37 +270,35 @@ static void __init at91_pm_sram_init(void)
> phys_addr_t sram_pbase;
> unsigned long sram_base;
> struct device_node *node;
> - struct platform_device *pdev;
> + struct platform_device *pdev = NULL;
>
> - node = of_find_compatible_node(NULL, NULL, "mmio-sram");
> - if (!node) {
> - pr_warn("%s: failed to find sram node!\n", __func__);
> - return;
> + for_each_compatible_node(node, NULL, "mmio-sram") {
> + pdev = of_find_device_by_node(node);
> + if (pdev) {
> + of_node_put(node);
> + break;
> + }
> }
>
> - pdev = of_find_device_by_node(node);
> if (!pdev) {
> pr_warn("%s: failed to find sram device!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_pool = dev_get_gen_pool(&pdev->dev);
> if (!sram_pool) {
> pr_warn("%s: sram pool unavailable!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
> if (!sram_base) {
> pr_warn("%s: unable to alloc ocram!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
> -
> -put_node:
> - of_node_put(node);
> }
> #endif
>
>
--
Nicolas Ferre
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Wenyou Yang <Wenyou.Yang@atmel.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] ARM: at91: pm: fix SRAM allocation
Date: Tue, 3 Mar 2015 19:21:21 +0100 [thread overview]
Message-ID: <54F5FBA1.7000005@atmel.com> (raw)
In-Reply-To: <1425368287-4971-1-git-send-email-alexandre.belloni@free-electrons.com>
Le 03/03/2015 08:38, Alexandre Belloni a écrit :
> On some platforms, there are multiple SRAM nodes defined in the device tree but
> some of them are disabled, leading to allocation failure. Try to find the first
> enabled SRAM node and allocate from it.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Tested-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
and added to at91-4.0-fixes. Thanks.
> ---
> Changes in v2:
> - initialize pdev to NULL
>
> arch/arm/mach-at91/pm.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 5e34fb143309..aa4116e9452f 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -270,37 +270,35 @@ static void __init at91_pm_sram_init(void)
> phys_addr_t sram_pbase;
> unsigned long sram_base;
> struct device_node *node;
> - struct platform_device *pdev;
> + struct platform_device *pdev = NULL;
>
> - node = of_find_compatible_node(NULL, NULL, "mmio-sram");
> - if (!node) {
> - pr_warn("%s: failed to find sram node!\n", __func__);
> - return;
> + for_each_compatible_node(node, NULL, "mmio-sram") {
> + pdev = of_find_device_by_node(node);
> + if (pdev) {
> + of_node_put(node);
> + break;
> + }
> }
>
> - pdev = of_find_device_by_node(node);
> if (!pdev) {
> pr_warn("%s: failed to find sram device!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_pool = dev_get_gen_pool(&pdev->dev);
> if (!sram_pool) {
> pr_warn("%s: sram pool unavailable!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
> if (!sram_base) {
> pr_warn("%s: unable to alloc ocram!\n", __func__);
> - goto put_node;
> + return;
> }
>
> sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
> -
> -put_node:
> - of_node_put(node);
> }
> #endif
>
>
--
Nicolas Ferre
next prev parent reply other threads:[~2015-03-03 18:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 7:38 [PATCH v2] ARM: at91: pm: fix SRAM allocation Alexandre Belloni
2015-03-03 7:38 ` Alexandre Belloni
2015-03-03 18:21 ` Nicolas Ferre [this message]
2015-03-03 18:21 ` Nicolas Ferre
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=54F5FBA1.7000005@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.