mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 17:23:25 -05:00
power: bq27xxx_battery: Add interrupt handling support
Some devices have a pin that can generate an interrupt when the battery's status changes. Add an interrupt handler to read the new battery status. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
74aab849f3
commit
8807feb91b
1 changed files with 23 additions and 0 deletions
|
@ -48,6 +48,7 @@
|
||||||
#include <linux/idr.h>
|
#include <linux/idr.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/interrupt.h>
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
|
||||||
#include <linux/power/bq27xxx_battery.h>
|
#include <linux/power/bq27xxx_battery.h>
|
||||||
|
@ -761,6 +762,15 @@ static void bq27xxx_battery_update(struct bq27xxx_device_info *di)
|
||||||
di->last_update = jiffies;
|
di->last_update = jiffies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
|
||||||
|
{
|
||||||
|
struct bq27xxx_device_info *di = data;
|
||||||
|
|
||||||
|
bq27xxx_battery_update(di);
|
||||||
|
|
||||||
|
return IRQ_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
static void bq27xxx_battery_poll(struct work_struct *work)
|
static void bq27xxx_battery_poll(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct bq27xxx_device_info *di =
|
struct bq27xxx_device_info *di =
|
||||||
|
@ -1128,6 +1138,19 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
|
||||||
|
|
||||||
i2c_set_clientdata(client, di);
|
i2c_set_clientdata(client, di);
|
||||||
|
|
||||||
|
if (client->irq) {
|
||||||
|
retval = devm_request_threaded_irq(&client->dev, client->irq,
|
||||||
|
NULL, bq27xxx_battery_irq_handler_thread,
|
||||||
|
IRQF_ONESHOT,
|
||||||
|
name, di);
|
||||||
|
if (retval) {
|
||||||
|
dev_err(&client->dev,
|
||||||
|
"Unable to register IRQ %d error %d\n",
|
||||||
|
client->irq, retval);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
batt_failed:
|
batt_failed:
|
||||||
|
|
Loading…
Add table
Reference in a new issue