Commit 6da23358 authored by Pali Rohár's avatar Pali Rohár Committed by Paul Walmsley

ARM: OMAP2+: Return correct error values from device and hwmod

Without this patch function pm_runtime_get_sync() returns 0 even when
some omap subfunction fails. This patch properly propagate error codes
from omap functions back to caller.

This patch fix problem, when loading omap-aes driver in qemu cause
kernel oops.
Signed-off-by: default avatarPali Rohár <pali.rohar@gmail.com>
[paul@pwsan.com: fix a checkpatch warning]
Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
parent fabbe6df
...@@ -224,13 +224,13 @@ static int _omap_device_notifier_call(struct notifier_block *nb, ...@@ -224,13 +224,13 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
*/ */
static int _omap_device_enable_hwmods(struct omap_device *od) static int _omap_device_enable_hwmods(struct omap_device *od)
{ {
int ret = 0;
int i; int i;
for (i = 0; i < od->hwmods_cnt; i++) for (i = 0; i < od->hwmods_cnt; i++)
omap_hwmod_enable(od->hwmods[i]); ret |= omap_hwmod_enable(od->hwmods[i]);
/* XXX pass along return value here? */ return ret;
return 0;
} }
/** /**
...@@ -241,13 +241,13 @@ static int _omap_device_enable_hwmods(struct omap_device *od) ...@@ -241,13 +241,13 @@ static int _omap_device_enable_hwmods(struct omap_device *od)
*/ */
static int _omap_device_idle_hwmods(struct omap_device *od) static int _omap_device_idle_hwmods(struct omap_device *od)
{ {
int ret = 0;
int i; int i;
for (i = 0; i < od->hwmods_cnt; i++) for (i = 0; i < od->hwmods_cnt; i++)
omap_hwmod_idle(od->hwmods[i]); ret |= omap_hwmod_idle(od->hwmods[i]);
/* XXX pass along return value here? */ return ret;
return 0;
} }
/* Public functions for use by core code */ /* Public functions for use by core code */
...@@ -595,18 +595,20 @@ static int _od_runtime_suspend(struct device *dev) ...@@ -595,18 +595,20 @@ static int _od_runtime_suspend(struct device *dev)
int ret; int ret;
ret = pm_generic_runtime_suspend(dev); ret = pm_generic_runtime_suspend(dev);
if (ret)
return ret;
if (!ret) return omap_device_idle(pdev);
omap_device_idle(pdev);
return ret;
} }
static int _od_runtime_resume(struct device *dev) static int _od_runtime_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
int ret;
omap_device_enable(pdev); ret = omap_device_enable(pdev);
if (ret)
return ret;
return pm_generic_runtime_resume(dev); return pm_generic_runtime_resume(dev);
} }
...@@ -743,7 +745,8 @@ int omap_device_enable(struct platform_device *pdev) ...@@ -743,7 +745,8 @@ int omap_device_enable(struct platform_device *pdev)
ret = _omap_device_enable_hwmods(od); ret = _omap_device_enable_hwmods(od);
od->_state = OMAP_DEVICE_STATE_ENABLED; if (ret == 0)
od->_state = OMAP_DEVICE_STATE_ENABLED;
return ret; return ret;
} }
...@@ -773,7 +776,8 @@ int omap_device_idle(struct platform_device *pdev) ...@@ -773,7 +776,8 @@ int omap_device_idle(struct platform_device *pdev)
ret = _omap_device_idle_hwmods(od); ret = _omap_device_idle_hwmods(od);
od->_state = OMAP_DEVICE_STATE_IDLE; if (ret == 0)
od->_state = OMAP_DEVICE_STATE_IDLE;
return ret; return ret;
} }
......
...@@ -3318,16 +3318,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh) ...@@ -3318,16 +3318,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
*/ */
int omap_hwmod_idle(struct omap_hwmod *oh) int omap_hwmod_idle(struct omap_hwmod *oh)
{ {
int r;
unsigned long flags; unsigned long flags;
if (!oh) if (!oh)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&oh->_lock, flags); spin_lock_irqsave(&oh->_lock, flags);
_idle(oh); r = _idle(oh);
spin_unlock_irqrestore(&oh->_lock, flags); spin_unlock_irqrestore(&oh->_lock, flags);
return 0; return r;
} }
/** /**
...@@ -3340,16 +3341,17 @@ int omap_hwmod_idle(struct omap_hwmod *oh) ...@@ -3340,16 +3341,17 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
*/ */
int omap_hwmod_shutdown(struct omap_hwmod *oh) int omap_hwmod_shutdown(struct omap_hwmod *oh)
{ {
int r;
unsigned long flags; unsigned long flags;
if (!oh) if (!oh)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&oh->_lock, flags); spin_lock_irqsave(&oh->_lock, flags);
_shutdown(oh); r = _shutdown(oh);
spin_unlock_irqrestore(&oh->_lock, flags); spin_unlock_irqrestore(&oh->_lock, flags);
return 0; return r;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment