bool is_present;
bool gpio_detect;
bool enable_detection;
- int irq;
int last_state;
int poll_time;
struct delayed_work work;
static irqreturn_t sbs_irq(int irq, void *devid)
{
- struct power_supply *battery = devid;
+ struct sbs_info *chip = devid;
+ struct power_supply *battery = chip->power_supply;
power_supply_changed(battery);
goto skip_gpio;
}
- rc = request_irq(irq, sbs_irq,
+ rc = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- dev_name(&client->dev), chip->power_supply);
+ dev_name(&client->dev), chip);
if (rc) {
dev_warn(&client->dev, "Failed to request irq: %d\n", rc);
gpio_free(pdata->battery_detect);
goto skip_gpio;
}
- chip->irq = irq;
-
skip_gpio:
/*
* Before we register, we might need to make sure we can actually talk
return 0;
exit_psupply:
- if (chip->irq)
- free_irq(chip->irq, chip->power_supply);
if (chip->gpio_detect)
gpio_free(pdata->battery_detect);
{
struct sbs_info *chip = i2c_get_clientdata(client);
- if (chip->irq)
- free_irq(chip->irq, chip->power_supply);
if (chip->gpio_detect)
gpio_free(chip->pdata->battery_detect);