Thread (12 messages) 12 messages, 5 authors, 2010-08-04
DORMANTno replies
Revisions (6)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v2 [diff vs current]
  4. v2 [diff vs current]
  5. v2 [diff vs current]
  6. v2 current

[PATCH v2 1/3] OMAP: PM: initial runtime PM core support

From: Grant Likely <hidden>
Date: 2010-08-04 22:55:27
Also in: linux-omap

On Thu, Jun 24, 2010 at 5:43 PM, Kevin Hilman
[off-list ref] wrote:
Implement the new runtime PM framework as a thin layer on top of the
omap_device API. ?Since we don't have an OMAP-specific bus, override
the runtime PM hooks for the platform_bus for the OMAP specific
implementation.
[...]
+int platform_pm_runtime_suspend(struct device *dev)
+{
+ ? ? ? struct platform_device *pdev = to_platform_device(dev);
+ ? ? ? struct omap_device *odev = to_omap_device(pdev);
+ ? ? ? int r, ret = 0;
+
+ ? ? ? dev_dbg(dev, "%s\n", __func__);
+
+ ? ? ? if (dev->driver->pm && dev->driver->pm->runtime_suspend)
+ ? ? ? ? ? ? ? ret = dev->driver->pm->runtime_suspend(dev);
+ ? ? ? if (!ret && omap_device_is_valid(odev)) {
+ ? ? ? ? ? ? ? r = omap_device_idle(pdev);
+ ? ? ? ? ? ? ? WARN_ON(r);
For the record, I should note here that this is *really* dangerous.
When handed a random platform_device pointer, it is not safe to use
to_omap_device() and dereference it with omap_device_is_valid().
There are no guarantees that the dereference is actually valid,
particularly so when the platform_device has been dynamically
allocated.

It is only okay to use to_omap_device() when the code is already
absolutely sure that the platform_device is in fact contained by a
struct omap_device.  There needs to be a different method to test if
it is contained by an omap_device before doing the dereference.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help