linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP2+: Return correct error values from device and hwmod
@ 2015-02-19 23:41 Pali Rohár
  2015-02-20  8:22 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Pali Rohár @ 2015-02-19 23:41 UTC (permalink / raw)
  To: linux-arm-kernel

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: Pali Roh?r <pali.rohar@gmail.com>
---
 arch/arm/mach-omap2/omap_device.c |   30 +++++++++++++++++-------------
 arch/arm/mach-omap2/omap_hwmod.c  |   20 ++++++++++++--------
 2 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index be9541e..9fd47a9 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -224,13 +224,13 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
  */
 static int _omap_device_enable_hwmods(struct omap_device *od)
 {
+	int ret = 0;
 	int 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 0;
+	return ret;
 }
 
 /**
@@ -241,13 +241,13 @@ static int _omap_device_enable_hwmods(struct omap_device *od)
  */
 static int _omap_device_idle_hwmods(struct omap_device *od)
 {
+	int ret = 0;
 	int 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 0;
+	return ret;
 }
 
 /* Public functions for use by core code */
@@ -595,18 +595,20 @@ static int _od_runtime_suspend(struct device *dev)
 	int ret;
 
 	ret = pm_generic_runtime_suspend(dev);
+	if (ret)
+		return ret;
 
-	if (!ret)
-		omap_device_idle(pdev);
-
-	return ret;
+	return omap_device_idle(pdev);
 }
 
 static int _od_runtime_resume(struct 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);
 }
@@ -740,7 +742,8 @@ int omap_device_enable(struct platform_device *pdev)
 
 	ret = _omap_device_enable_hwmods(od);
 
-	od->_state = OMAP_DEVICE_STATE_ENABLED;
+	if (ret == 0)
+		od->_state = OMAP_DEVICE_STATE_ENABLED;
 
 	return ret;
 }
@@ -770,7 +773,8 @@ int omap_device_idle(struct platform_device *pdev)
 
 	ret = _omap_device_idle_hwmods(od);
 
-	od->_state = OMAP_DEVICE_STATE_IDLE;
+	if (ret == 0)
+		od->_state = OMAP_DEVICE_STATE_IDLE;
 
 	return ret;
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index cbb908d..2ce4f39 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -3350,16 +3350,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
  */
 int omap_hwmod_idle(struct omap_hwmod *oh)
 {
+	int r;
 	unsigned long flags;
 
 	if (!oh)
 		return -EINVAL;
 
 	spin_lock_irqsave(&oh->_lock, flags);
-	_idle(oh);
+	r = _idle(oh);
 	spin_unlock_irqrestore(&oh->_lock, flags);
 
-	return 0;
+	return r;
 }
 
 /**
@@ -3372,16 +3373,17 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
  */
 int omap_hwmod_shutdown(struct omap_hwmod *oh)
 {
+	int r;
 	unsigned long flags;
 
 	if (!oh)
 		return -EINVAL;
 
 	spin_lock_irqsave(&oh->_lock, flags);
-	_shutdown(oh);
+	r = _shutdown(oh);
 	spin_unlock_irqrestore(&oh->_lock, flags);
 
-	return 0;
+	return r;
 }
 
 /**
@@ -3392,13 +3394,14 @@ int omap_hwmod_shutdown(struct omap_hwmod *oh)
  */
 int omap_hwmod_enable_clocks(struct omap_hwmod *oh)
 {
+	int r;
 	unsigned long flags;
 
 	spin_lock_irqsave(&oh->_lock, flags);
-	_enable_clocks(oh);
+	r = _enable_clocks(oh);
 	spin_unlock_irqrestore(&oh->_lock, flags);
 
-	return 0;
+	return r;
 }
 
 /**
@@ -3409,13 +3412,14 @@ int omap_hwmod_enable_clocks(struct omap_hwmod *oh)
  */
 int omap_hwmod_disable_clocks(struct omap_hwmod *oh)
 {
+	int r;
 	unsigned long flags;
 
 	spin_lock_irqsave(&oh->_lock, flags);
-	_disable_clocks(oh);
+	r = _disable_clocks(oh);
 	spin_unlock_irqrestore(&oh->_lock, flags);
 
-	return 0;
+	return r;
 }
 
 /**
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] ARM: OMAP2+: Return correct error values from device and hwmod
  2015-02-19 23:41 [PATCH] ARM: OMAP2+: Return correct error values from device and hwmod Pali Rohár
@ 2015-02-20  8:22 ` Pavel Machek
  2015-02-20  9:50   ` Pali Rohár
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2015-02-20  8:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri 2015-02-20 00:41:41, Pali Roh?r wrote:
> 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.

"fixes"

> Signed-off-by: Pali Roh?r <pali.rohar@gmail.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

> @@ -3350,16 +3350,17 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
>   */
>  int omap_hwmod_idle(struct omap_hwmod *oh)
>  {
> +	int r;
>  	unsigned long flags;
>  
>  	if (!oh)
>  		return -EINVAL;
>  
>  	spin_lock_irqsave(&oh->_lock, flags);
> -	_idle(oh);
> +	r = _idle(oh);
>  	spin_unlock_irqrestore(&oh->_lock, flags);
>  
> -	return 0;
> +	return r;
>  }

Normally, such variable is called ret or res...

									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ARM: OMAP2+: Return correct error values from device and hwmod
  2015-02-20  8:22 ` Pavel Machek
@ 2015-02-20  9:50   ` Pali Rohár
  0 siblings, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2015-02-20  9:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Friday 20 February 2015 09:22:26 Pavel Machek wrote:
> On Fri 2015-02-20 00:41:41, Pali Roh?r wrote:
> > 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.
> 
> "fixes"
> 
> > Signed-off-by: Pali Roh?r <pali.rohar@gmail.com>
> 
> Acked-by: Pavel Machek <pavel@ucw.cz>
> 
> > @@ -3350,16 +3350,17 @@ int omap_hwmod_enable(struct
> > omap_hwmod *oh)
> > 
> >   */
> >  
> >  int omap_hwmod_idle(struct omap_hwmod *oh)
> >  {
> > 
> > +	int r;
> > 
> >  	unsigned long flags;
> >  	
> >  	if (!oh)
> >  	
> >  		return -EINVAL;
> >  	
> >  	spin_lock_irqsave(&oh->_lock, flags);
> > 
> > -	_idle(oh);
> > +	r = _idle(oh);
> > 
> >  	spin_unlock_irqrestore(&oh->_lock, flags);
> > 
> > -	return 0;
> > +	return r;
> > 
> >  }
> 
> Normally, such variable is called ret or res...
> 
> 									Pavel

In other parts of this code is used name "r" not "ret".

-- 
Pali Roh?r
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150220/66029e73/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-20  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-19 23:41 [PATCH] ARM: OMAP2+: Return correct error values from device and hwmod Pali Rohár
2015-02-20  8:22 ` Pavel Machek
2015-02-20  9:50   ` Pali Rohár

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).