MODULE_DEVICE_TABLE(of, bq24296_battery_of_match);
#endif
+static int bq24296_battery_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ cancel_delayed_work_sync(&bq24296_di->usb_detect_work);
+ return 0;
+}
+
+static int bq24296_battery_resume(struct i2c_client *client)
+{
+ schedule_delayed_work(&bq24296_di->usb_detect_work, msecs_to_jiffies(50));
+ return 0;
+}
+
static int bq24296_battery_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
struct bq24296_device_info *di;
u8 retval = 0;
struct bq24296_board *pdev;
struct device_node *bq24296_node;
- int ret=0,irq=0;
+ int ret = -EINVAL;
DBG("%s,line=%d\n", __func__,__LINE__);
di = devm_kzalloc(&client->dev,sizeof(*di), GFP_KERNEL);
if (!di) {
dev_err(&client->dev, "failed to allocate device info data\n");
- retval = -ENOMEM;
+ ret = -ENOMEM;
goto batt_failed_2;
}
i2c_set_clientdata(client, di);
if (gpio_is_valid(pdev->chg_irq_pin)){
- irq = gpio_to_irq(pdev->chg_irq_pin);
- ret = request_threaded_irq(irq, NULL,chg_irq_func, IRQF_TRIGGER_FALLING| IRQF_ONESHOT, "bq24296_chg_irq", di);
+ pdev->chg_irq = gpio_to_irq(pdev->chg_irq_pin);
+ ret = request_threaded_irq(pdev->chg_irq, NULL, chg_irq_func, IRQF_TRIGGER_FALLING| IRQF_ONESHOT, "bq24296_chg_irq", di);
if (ret) {
ret = -EINVAL;
printk("failed to request bq24296_chg_irq\n");
err_chgirq_failed:
free_irq(gpio_to_irq(pdev->chg_irq_pin), NULL);
batt_failed_2:
- return retval;
+ return ret;
}
static void bq24296_battery_shutdown(struct i2c_client *client)
{
+ struct bq24296_device_info *di = i2c_get_clientdata(client);
- if (gpio_is_valid(bq24296_pdata->chg_irq_pin)){
- free_irq(gpio_to_irq(bq24296_pdata->chg_irq_pin), NULL);
- }
-
+ if (bq24296_pdata->chg_irq)
+ free_irq(bq24296_pdata->chg_irq, di);
}
+
static int bq24296_battery_remove(struct i2c_client *client)
{
- struct bq24296_device_info *di = i2c_get_clientdata(client);
- kfree(di);
+
return 0;
}
.probe = bq24296_battery_probe,
.remove = bq24296_battery_remove,
.shutdown = bq24296_battery_shutdown,
+ .suspend = bq24296_battery_suspend,
+ .resume = bq24296_battery_resume,
.id_table = bq24296_id,
};