summaryrefslogtreecommitdiffstats
path: root/drivers/power/lp8727_charger.c
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-08-31 11:23:25 +0200
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-09-21 02:57:12 +0200
commit60fd57e06ed7ea13bc0bdf4cb5324d47039105ab (patch)
tree784c8828925917ab2d692c2641dd2cdb78d15b24 /drivers/power/lp8727_charger.c
parentlp8727_charger: Fix buggy code of NULL pdata (diff)
downloadlinux-60fd57e06ed7ea13bc0bdf4cb5324d47039105ab.tar.xz
linux-60fd57e06ed7ea13bc0bdf4cb5324d47039105ab.zip
lp8727_charger: Add configurable debouce timer
Debounce time is configurable in the platform side. If it is not defined, the default value is 270ms. Platform data is msec unit, and this time is converted to jiffies internally. The workqueue uses this jiffies time in the interrupt handling. So debounce_jiffies is added in the private data. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/lp8727_charger.c')
-rw-r--r--drivers/power/lp8727_charger.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 7c19c0927f3a..1907b1f7953d 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -17,7 +17,7 @@
#include <linux/power_supply.h>
#include <linux/platform_data/lp8727.h>
-#define DEBOUNCE_MSEC 270
+#define DEFAULT_DEBOUNCE_MSEC 270
/* Registers */
#define CTRL1 0x1
@@ -90,6 +90,7 @@ struct lp8727_chg {
struct lp8727_psy *psy;
struct lp8727_chg_param *chg_parm;
enum lp8727_dev_id devid;
+ unsigned long debounce_jiffies;
};
static int lp8727_read_bytes(struct lp8727_chg *pchg, u8 reg, u8 *data, u8 len)
@@ -236,15 +237,18 @@ static void lp8727_delayed_func(struct work_struct *_work)
static irqreturn_t lp8727_isr_func(int irq, void *ptr)
{
struct lp8727_chg *pchg = ptr;
- unsigned long delay = msecs_to_jiffies(DEBOUNCE_MSEC);
- queue_delayed_work(pchg->irqthread, &pchg->work, delay);
+ queue_delayed_work(pchg->irqthread, &pchg->work,
+ pchg->debounce_jiffies);
return IRQ_HANDLED;
}
static int lp8727_intr_config(struct lp8727_chg *pchg)
{
+ unsigned delay_msec = pchg->pdata ? pchg->pdata->debounce_msec :
+ DEFAULT_DEBOUNCE_MSEC;
+
INIT_DELAYED_WORK(&pchg->work, lp8727_delayed_func);
pchg->irqthread = create_singlethread_workqueue("lp8727-irqthd");
@@ -253,6 +257,8 @@ static int lp8727_intr_config(struct lp8727_chg *pchg)
return -ENOMEM;
}
+ pchg->debounce_jiffies = msecs_to_jiffies(delay_msec);
+
return request_threaded_irq(pchg->client->irq,
NULL,
lp8727_isr_func,