power: sbs-battery: Request threaded irq and fix dev callback cookie
Currently the battery detect gpio can not be used with a chained interrupt controller that requires threaded irq handlers. Use threaded irq instead. In addition this was not going to be working at present because chip->power_supply is assigned after the request irq call. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
9239a86f09
commit
d2cec82c28
|
@ -162,7 +162,6 @@ struct sbs_info {
|
||||||
bool is_present;
|
bool is_present;
|
||||||
bool gpio_detect;
|
bool gpio_detect;
|
||||||
bool enable_detection;
|
bool enable_detection;
|
||||||
int irq;
|
|
||||||
int last_state;
|
int last_state;
|
||||||
int poll_time;
|
int poll_time;
|
||||||
struct delayed_work work;
|
struct delayed_work work;
|
||||||
|
@ -661,7 +660,8 @@ static int sbs_get_property(struct power_supply *psy,
|
||||||
|
|
||||||
static irqreturn_t sbs_irq(int irq, void *devid)
|
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);
|
power_supply_changed(battery);
|
||||||
|
|
||||||
|
@ -869,9 +869,9 @@ static int sbs_probe(struct i2c_client *client,
|
||||||
goto skip_gpio;
|
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,
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||||
dev_name(&client->dev), chip->power_supply);
|
dev_name(&client->dev), chip);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_warn(&client->dev, "Failed to request irq: %d\n", rc);
|
dev_warn(&client->dev, "Failed to request irq: %d\n", rc);
|
||||||
gpio_free(pdata->battery_detect);
|
gpio_free(pdata->battery_detect);
|
||||||
|
@ -879,8 +879,6 @@ static int sbs_probe(struct i2c_client *client,
|
||||||
goto skip_gpio;
|
goto skip_gpio;
|
||||||
}
|
}
|
||||||
|
|
||||||
chip->irq = irq;
|
|
||||||
|
|
||||||
skip_gpio:
|
skip_gpio:
|
||||||
/*
|
/*
|
||||||
* Before we register, we might need to make sure we can actually talk
|
* Before we register, we might need to make sure we can actually talk
|
||||||
|
@ -915,8 +913,6 @@ static int sbs_probe(struct i2c_client *client,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_psupply:
|
exit_psupply:
|
||||||
if (chip->irq)
|
|
||||||
free_irq(chip->irq, chip->power_supply);
|
|
||||||
if (chip->gpio_detect)
|
if (chip->gpio_detect)
|
||||||
gpio_free(pdata->battery_detect);
|
gpio_free(pdata->battery_detect);
|
||||||
|
|
||||||
|
@ -927,8 +923,6 @@ static int sbs_remove(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct sbs_info *chip = i2c_get_clientdata(client);
|
struct sbs_info *chip = i2c_get_clientdata(client);
|
||||||
|
|
||||||
if (chip->irq)
|
|
||||||
free_irq(chip->irq, chip->power_supply);
|
|
||||||
if (chip->gpio_detect)
|
if (chip->gpio_detect)
|
||||||
gpio_free(chip->pdata->battery_detect);
|
gpio_free(chip->pdata->battery_detect);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue