public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] The fix prevents kernel crash caused by twl4030 power button malfunction.
@ 2008-06-17 13:48 Roman Tereshonkov
  2008-06-23 10:43 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Roman Tereshonkov @ 2008-06-17 13:48 UTC (permalink / raw)
  To: linux-omap; +Cc: Roman Tereshonkov

If i2c connection is broken the twl4030 power button driver is unregistered.
The function input_free_device has to be called only when
input_register_device failed. Otherwise input_unregister_device is used.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 drivers/i2c/chips/twl4030-pwrbutton.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/chips/twl4030-pwrbutton.c b/drivers/i2c/chips/twl4030-pwrbutton.c
index cbc31aa..a8258df 100644
--- a/drivers/i2c/chips/twl4030-pwrbutton.c
+++ b/drivers/i2c/chips/twl4030-pwrbutton.c
@@ -95,8 +95,10 @@ static int __init twl4030_pwrbutton_init(void)
 	powerbutton_dev->name = "triton2-pwrbutton";
 
 	err = input_register_device(powerbutton_dev);
-	if (err)
-		goto free_input_dev;
+	if (err) {
+		input_free_device(powerbutton_dev);
+		goto free_irq_and_out;
+	}
 
 	err = twl4030_i2c_read_u8(TWL4030_MODULE_INT, &value, PWR_IMR1);
 	if (err) {
@@ -122,7 +124,7 @@ static int __init twl4030_pwrbutton_init(void)
 	}
 
 	err = twl4030_i2c_write_u8(TWL4030_MODULE_INT,
-				   value | PWR_PWRON_BOTH , PWR_EDR1);
+				   value | PWR_PWRON_BOTH, PWR_EDR1);
 
 	if (err) {
 		printk(KERN_WARNING "I2C error %d while writing TWL4030"
@@ -136,7 +138,7 @@ static int __init twl4030_pwrbutton_init(void)
 
 
 free_input_dev:
-	input_free_device(powerbutton_dev);
+	input_unregister_device(powerbutton_dev);
 free_irq_and_out:
 	free_irq(TWL4030_PWRIRQ_PWRBTN, NULL);
 out:
-- 
1.5.5.1


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

* Re: [PATCH] The fix prevents kernel crash caused by twl4030 power button malfunction.
  2008-06-17 13:48 [PATCH] The fix prevents kernel crash caused by twl4030 power button malfunction Roman Tereshonkov
@ 2008-06-23 10:43 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2008-06-23 10:43 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: linux-omap

* Roman Tereshonkov <roman.tereshonkov@nokia.com> [080617 16:49]:
> If i2c connection is broken the twl4030 power button driver is unregistered.
> The function input_free_device has to be called only when
> input_register_device failed. Otherwise input_unregister_device is used.

Pushing today.

Tony

> 
> Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
> ---
>  drivers/i2c/chips/twl4030-pwrbutton.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/chips/twl4030-pwrbutton.c b/drivers/i2c/chips/twl4030-pwrbutton.c
> index cbc31aa..a8258df 100644
> --- a/drivers/i2c/chips/twl4030-pwrbutton.c
> +++ b/drivers/i2c/chips/twl4030-pwrbutton.c
> @@ -95,8 +95,10 @@ static int __init twl4030_pwrbutton_init(void)
>  	powerbutton_dev->name = "triton2-pwrbutton";
>  
>  	err = input_register_device(powerbutton_dev);
> -	if (err)
> -		goto free_input_dev;
> +	if (err) {
> +		input_free_device(powerbutton_dev);
> +		goto free_irq_and_out;
> +	}
>  
>  	err = twl4030_i2c_read_u8(TWL4030_MODULE_INT, &value, PWR_IMR1);
>  	if (err) {
> @@ -122,7 +124,7 @@ static int __init twl4030_pwrbutton_init(void)
>  	}
>  
>  	err = twl4030_i2c_write_u8(TWL4030_MODULE_INT,
> -				   value | PWR_PWRON_BOTH , PWR_EDR1);
> +				   value | PWR_PWRON_BOTH, PWR_EDR1);
>  
>  	if (err) {
>  		printk(KERN_WARNING "I2C error %d while writing TWL4030"
> @@ -136,7 +138,7 @@ static int __init twl4030_pwrbutton_init(void)
>  
>  
>  free_input_dev:
> -	input_free_device(powerbutton_dev);
> +	input_unregister_device(powerbutton_dev);
>  free_irq_and_out:
>  	free_irq(TWL4030_PWRIRQ_PWRBTN, NULL);
>  out:
> -- 
> 1.5.5.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2008-06-23 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-17 13:48 [PATCH] The fix prevents kernel crash caused by twl4030 power button malfunction Roman Tereshonkov
2008-06-23 10:43 ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox