diff options
| author | Phil Reid <preid@electromag.com.au> | 2016-07-24 22:42:58 -0400 |
|---|---|---|
| committer | Sebastian Reichel <sre@kernel.org> | 2016-08-15 15:51:30 -0400 |
| commit | d2cec82c28802da31596b395ad292cb8f132fd63 (patch) | |
| tree | f4c9974089fd309e12d8922271acea6e999692d8 /drivers/power | |
| parent | 9239a86f0976b58d3da7a2261ed659ac9eba0f25 (diff) | |
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>
Diffstat (limited to 'drivers/power')
| -rw-r--r-- | drivers/power/supply/sbs-battery.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 20f3be6f5b9a..f9012ed29f47 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c | |||
| @@ -162,7 +162,6 @@ struct sbs_info { | |||
| 162 | bool is_present; | 162 | bool is_present; |
| 163 | bool gpio_detect; | 163 | bool gpio_detect; |
| 164 | bool enable_detection; | 164 | bool enable_detection; |
| 165 | int irq; | ||
| 166 | int last_state; | 165 | int last_state; |
| 167 | int poll_time; | 166 | int poll_time; |
| 168 | struct delayed_work work; | 167 | struct delayed_work work; |
| @@ -661,7 +660,8 @@ done: | |||
| 661 | 660 | ||
| 662 | static irqreturn_t sbs_irq(int irq, void *devid) | 661 | static irqreturn_t sbs_irq(int irq, void *devid) |
| 663 | { | 662 | { |
| 664 | struct power_supply *battery = devid; | 663 | struct sbs_info *chip = devid; |
| 664 | struct power_supply *battery = chip->power_supply; | ||
| 665 | 665 | ||
| 666 | power_supply_changed(battery); | 666 | power_supply_changed(battery); |
| 667 | 667 | ||
| @@ -869,9 +869,9 @@ static int sbs_probe(struct i2c_client *client, | |||
| 869 | goto skip_gpio; | 869 | goto skip_gpio; |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | rc = request_irq(irq, sbs_irq, | 872 | rc = devm_request_threaded_irq(&client->dev, irq, NULL, sbs_irq, |
| 873 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 873 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 874 | dev_name(&client->dev), chip->power_supply); | 874 | dev_name(&client->dev), chip); |
| 875 | if (rc) { | 875 | if (rc) { |
| 876 | dev_warn(&client->dev, "Failed to request irq: %d\n", rc); | 876 | dev_warn(&client->dev, "Failed to request irq: %d\n", rc); |
| 877 | gpio_free(pdata->battery_detect); | 877 | gpio_free(pdata->battery_detect); |
| @@ -879,8 +879,6 @@ static int sbs_probe(struct i2c_client *client, | |||
| 879 | goto skip_gpio; | 879 | goto skip_gpio; |
| 880 | } | 880 | } |
| 881 | 881 | ||
| 882 | chip->irq = irq; | ||
| 883 | |||
| 884 | skip_gpio: | 882 | skip_gpio: |
| 885 | /* | 883 | /* |
| 886 | * Before we register, we might need to make sure we can actually talk | 884 | * Before we register, we might need to make sure we can actually talk |
| @@ -915,8 +913,6 @@ skip_gpio: | |||
| 915 | return 0; | 913 | return 0; |
| 916 | 914 | ||
| 917 | exit_psupply: | 915 | exit_psupply: |
| 918 | if (chip->irq) | ||
| 919 | free_irq(chip->irq, chip->power_supply); | ||
| 920 | if (chip->gpio_detect) | 916 | if (chip->gpio_detect) |
| 921 | gpio_free(pdata->battery_detect); | 917 | gpio_free(pdata->battery_detect); |
| 922 | 918 | ||
| @@ -927,8 +923,6 @@ static int sbs_remove(struct i2c_client *client) | |||
| 927 | { | 923 | { |
| 928 | struct sbs_info *chip = i2c_get_clientdata(client); | 924 | struct sbs_info *chip = i2c_get_clientdata(client); |
| 929 | 925 | ||
| 930 | if (chip->irq) | ||
| 931 | free_irq(chip->irq, chip->power_supply); | ||
| 932 | if (chip->gpio_detect) | 926 | if (chip->gpio_detect) |
| 933 | gpio_free(chip->pdata->battery_detect); | 927 | gpio_free(chip->pdata->battery_detect); |
| 934 | 928 | ||
