All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Tony Lindgren <tony@atomide.com>, Paul Walmsley <paul@pwsan.com>,
	Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: omap_hwmod: Fix up resource names when booted with devicetree
Date: Thu, 23 Aug 2012 16:54:09 +0300	[thread overview]
Message-ID: <1345730049-12675-1-git-send-email-peter.ujfalusi@ti.com> (raw)

When booted with some resource will have their name set to NULL. This can
cause later kernel crash since this is not expected by the platform code.

When we boot without DT the devices are created with platform_device_add()
which itself fixes up the missing resource names:
if (r->name == NULL)
	r->name = dev_name(&pdev->dev);

The of core also fixes up the resource names when taking the information
from DT data - in __of_address_to_resource():
r->name = name ? name : dev->full_name;

When we boot OMAP with devicetree: of will create the devices based on the
DT data so the resource names are guarantied to be not NULL. Since we have
the 'ti,hwmod' tag, we remove the of created resources from the device and
re-create them based on hwmod data. If the hwmod data does not specify a
name for a resource it will be NULL.
This can cause kernel crash if the driver uses
platform_get_resource_byname() to get any resource.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/plat-omap/omap_device.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index c490240..ff57b5a 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -370,6 +370,14 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
 		goto odbfd_exit1;
 	}
 
+	/* Fix up missing resource names */
+	for (i = 0; i < pdev->num_resources; i++) {
+		struct resource *r = &pdev->resource[i];
+
+		if (r->name == NULL)
+			r->name = dev_name(&pdev->dev);
+	}
+
 	if (of_get_property(node, "ti,no_idle_on_suspend", NULL))
 		omap_device_disable_idle_on_suspend(pdev);
 
-- 
1.7.8.6


WARNING: multiple messages have this Message-ID (diff)
From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: omap_hwmod: Fix up resource names when booted with devicetree
Date: Thu, 23 Aug 2012 16:54:09 +0300	[thread overview]
Message-ID: <1345730049-12675-1-git-send-email-peter.ujfalusi@ti.com> (raw)

When booted with some resource will have their name set to NULL. This can
cause later kernel crash since this is not expected by the platform code.

When we boot without DT the devices are created with platform_device_add()
which itself fixes up the missing resource names:
if (r->name == NULL)
	r->name = dev_name(&pdev->dev);

The of core also fixes up the resource names when taking the information
from DT data - in __of_address_to_resource():
r->name = name ? name : dev->full_name;

When we boot OMAP with devicetree: of will create the devices based on the
DT data so the resource names are guarantied to be not NULL. Since we have
the 'ti,hwmod' tag, we remove the of created resources from the device and
re-create them based on hwmod data. If the hwmod data does not specify a
name for a resource it will be NULL.
This can cause kernel crash if the driver uses
platform_get_resource_byname() to get any resource.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/plat-omap/omap_device.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index c490240..ff57b5a 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -370,6 +370,14 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
 		goto odbfd_exit1;
 	}
 
+	/* Fix up missing resource names */
+	for (i = 0; i < pdev->num_resources; i++) {
+		struct resource *r = &pdev->resource[i];
+
+		if (r->name == NULL)
+			r->name = dev_name(&pdev->dev);
+	}
+
 	if (of_get_property(node, "ti,no_idle_on_suspend", NULL))
 		omap_device_disable_idle_on_suspend(pdev);
 
-- 
1.7.8.6

             reply	other threads:[~2012-08-23 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 13:54 Peter Ujfalusi [this message]
2012-08-23 13:54 ` [PATCH] ARM: omap_hwmod: Fix up resource names when booted with devicetree Peter Ujfalusi
2012-08-24 15:38 ` Paul Walmsley
2012-08-24 15:38   ` Paul Walmsley
2012-08-24 16:20   ` Peter Ujfalusi
2012-08-24 16:20     ` Peter Ujfalusi
2012-09-05 14:27     ` Benoit Cousson
2012-09-05 14:27       ` Benoit Cousson
2012-09-05 14:46       ` Benoit Cousson
2012-09-05 14:46         ` Benoit Cousson
2012-09-05 14:46       ` Benoit Cousson
2012-09-05 14:46         ` Benoit Cousson
2012-09-05 20:05       ` Vaibhav Hiremath
2012-09-05 20:05         ` Vaibhav Hiremath
2012-09-06  7:37         ` Benoit Cousson
2012-09-06  7:37           ` Benoit Cousson
2012-09-06  8:28           ` Hiremath, Vaibhav
2012-09-06  8:28             ` Hiremath, Vaibhav

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=1345730049-12675-1-git-send-email-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=b-cousson@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    --cc=tony@atomide.com \
    /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.