]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
input: twl4030-pwrbutton: avoid merge conflicts
authorFelipe Balbi <felipe.balbi@nokia.com>
Thu, 5 Mar 2009 19:27:11 +0000 (19:27 +0000)
committerTony Lindgren <tony@atomide.com>
Thu, 5 Mar 2009 23:52:34 +0000 (15:52 -0800)
sync up with the version going upstream.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/input/misc/Kconfig
drivers/input/misc/twl4030-pwrbutton.c

index 9667b500cdca355faf32ca48189099c34a3af178..6fa9e3847c3679a041a08ea6bb94e2cb14a0a7db 100644 (file)
@@ -196,6 +196,12 @@ config INPUT_CM109
 config INPUT_TWL4030_PWRBUTTON
        tristate "TWL4030 Power button Driver"
        depends on TWL4030_CORE
+       help
+         Say Y here if you want to enable power key reporting via the
+         TWL4030 family of chips.
+
+         To compile this driver as a module, choose M here. The module will
+         be called twl4030_pwrbutton.
 
 config INPUT_UINPUT
        tristate "User level driver support"
index b0a9c9fda742446400dc427982155854d0fcba7f..71508306684fdfd677931839f7fe055a166d8c58 100644 (file)
@@ -1,11 +1,10 @@
 /**
- * drivers/i2c/chips/twl4030-pwrbutton.c
+ * twl4030-pwrbutton.c - TWL4030 Power Button Input Driver
  *
- * Driver for sending triton2 power button event to input-layer
- *
- * Copyright (C) 2008 Nokia Corporation
+ * Copyright (C) 2008-2009 Nokia Corporation
  *
  * Written by Peter De Schrijver <peter.de-schrijver@nokia.com>
+ * Several fixes by Felipe Balbi <felipe.balbi@nokia.com>
  *
  * This file is subject to the terms and conditions of the GNU General
  * Public License. See the file "COPYING" in the main directory of this
 
 #define STS_HW_CONDITIONS 0xf
 
-static struct input_dev *powerbutton_dev;
-static struct device *dbg_dev;
-
-static irqreturn_t powerbutton_irq(int irq, void *dev_id)
+static irqreturn_t powerbutton_irq(int irq, void *_pwr)
 {
+       struct input_dev *pwr = _pwr;
        int err;
        u8 value;
 
 #ifdef CONFIG_LOCKDEP
        /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
-        * we don't want and can't tolerate.  Although it might be
-        * friendlier not to borrow this thread context...
+        * we don't want and can't tolerate since this is a threaded
+        * IRQ and can sleep due to the i2c reads it has to issue.
+        * Although it might be friendlier not to borrow this thread
+        * context...
         */
        local_irq_enable();
 #endif
@@ -53,11 +52,11 @@ static irqreturn_t powerbutton_irq(int irq, void *dev_id)
        err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value,
                                  STS_HW_CONDITIONS);
        if (!err)  {
-               input_report_key(powerbutton_dev, KEY_POWER,
-                                value & PWR_PWRON_IRQ);
+               input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ);
+               input_sync(pwr);
        } else {
-               dev_err(dbg_dev, "twl4030: i2c error %d while reading TWL4030"
-                       " PM_MASTER STS_HW_CONDITIONS register\n", err);
+               dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading"
+                       " TWL4030 PM_MASTER STS_HW_CONDITIONS register\n", err);
        }
 
        return IRQ_HANDLED;
@@ -65,66 +64,64 @@ static irqreturn_t powerbutton_irq(int irq, void *dev_id)
 
 static int __devinit twl4030_pwrbutton_probe(struct platform_device *pdev)
 {
-       int err = 0;
+       struct input_dev *pwr;
        int irq = platform_get_irq(pdev, 0);
+       int err;
 
-       dbg_dev = &pdev->dev;
+       pwr = input_allocate_device();
+       if (!pwr) {
+               dev_dbg(&pdev->dev, "Can't allocate power button\n");
+               err = -ENOMEM;
+               goto out;
+       }
 
-       /* PWRBTN == PWRON */
        err = request_irq(irq, powerbutton_irq,
                        IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
-                       "twl4030-pwrbutton", NULL);
+                       "twl4030_pwrbutton", pwr);
        if (err < 0) {
-               dev_dbg(&pdev->dev, "Can't get IRQ for power button: %d\n", err);
-               goto out;
-       }
-
-       powerbutton_dev = input_allocate_device();
-       if (!powerbutton_dev) {
-               dev_dbg(&pdev->dev, "Can't allocate power button\n");
-               err = -ENOMEM;
-               goto free_irq_and_out;
+               dev_dbg(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err);
+               goto free_input_dev;
        }
 
-       powerbutton_dev->evbit[0] = BIT_MASK(EV_KEY);
-       powerbutton_dev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
-       powerbutton_dev->name = "triton2-pwrbutton";
+       pwr->evbit[0] = BIT_MASK(EV_KEY);
+       pwr->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
+       pwr->name = "twl4030_pwrbutton";
+       pwr->phys = "twl4030_pwrbutton/input0";
+       pwr->dev.parent = &pdev->dev;
+       platform_set_drvdata(pdev, pwr);
 
-       err = input_register_device(powerbutton_dev);
+       err = input_register_device(pwr);
        if (err) {
                dev_dbg(&pdev->dev, "Can't register power button: %d\n", err);
-               goto free_input_dev;
+               goto free_irq_and_out;
        }
 
-       dev_info(&pdev->dev, "triton2 power button driver initialized\n");
-
        return 0;
 
-
-free_input_dev:
-       input_free_device(powerbutton_dev);
 free_irq_and_out:
-       free_irq(TWL4030_PWRIRQ_PWRBTN, NULL);
+       free_irq(irq, NULL);
+free_input_dev:
+       input_free_device(pwr);
 out:
        return err;
 }
 
 static int __devexit twl4030_pwrbutton_remove(struct platform_device *pdev)
 {
+       struct input_dev *pwr = platform_get_drvdata(pdev);
        int irq = platform_get_irq(pdev, 0);
 
-       free_irq(irq, NULL);
-       input_unregister_device(powerbutton_dev);
-       input_free_device(powerbutton_dev);
+       free_irq(irq, pwr);
+       input_unregister_device(pwr);
 
        return 0;
 }
 
 struct platform_driver twl4030_pwrbutton_driver = {
        .probe          = twl4030_pwrbutton_probe,
-       .remove         = twl4030_pwrbutton_remove,
+       .remove         = __devexit_p(twl4030_pwrbutton_remove),
        .driver         = {
-               .name   = "twl4030-pwrbutton",
+               .name   = "twl4030_pwrbutton",
                .owner  = THIS_MODULE,
        },
 };
@@ -141,7 +138,9 @@ static void __exit twl4030_pwrbutton_exit(void)
 }
 module_exit(twl4030_pwrbutton_exit);
 
+MODULE_ALIAS("platform:twl4030_pwrbutton");
 MODULE_DESCRIPTION("Triton2 Power Button");
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Peter De Schrijver");
+MODULE_AUTHOR("Peter De Schrijver <peter.de-schrijver@nokia.com>");
+MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");