]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
The fix prevents kernel crash caused by twl4030 power button malfunction.
authorRoman Tereshonkov <roman.tereshonkov@nokia.com>
Tue, 17 Jun 2008 13:48:06 +0000 (16:48 +0300)
committerTony Lindgren <tony@atomide.com>
Mon, 23 Jun 2008 10:43:27 +0000 (13:43 +0300)
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>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/i2c/chips/twl4030-pwrbutton.c

index cbc31aa33781cee02048e3273f7c8a847d484a0e..a8258df22fc3ec7d70e340488532103f9102e2ad 100644 (file)
@@ -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: