Thread (17 messages) 17 messages, 2 authors, 2017-02-07

Re: [PATCH 2/2] power: bq24190_charger: Use PM runtime autosuspend

From: Liam Breck <hidden>
Date: 2017-02-03 21:44:54
Also in: linux-omap

On Fri, Feb 3, 2017 at 1:17 PM, Tony Lindgren [off-list ref] wrote:
From: Tony Lindgren <tony@atomide.com>
Date: Mon, 30 Jan 2017 07:10:31 -0800
Subject: [PATCH] power: bq24190_charger: Use PM runtime autosuspend

We can get quite a few interrupts when the battery is trickle charging.
Let's enable PM runtime autosuspend to avoid constantly toggling device
driver PM runtime state.

Let's use a 600 ms timeout as that's how long the USB chager detection
might take.

Cc: Liam Breck <redacted>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Liam Breck <redacted>

quoted hunk ↗ jump to hunk
@@ -1480,10 +1531,20 @@ static int bq24190_pm_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
+       int error;
+
+       error = pm_runtime_get_sync(bdi->dev);
+       if (error < 0) {
+               dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
+               pm_runtime_put_noidle(bdi->dev);
+       }

-       pm_runtime_get_sync(bdi->dev);
        bq24190_register_reset(bdi);
-       pm_runtime_put_sync(bdi->dev);
+
+       if (!error) {
+               pm_runtime_mark_last_busy(bdi->dev);
+               pm_runtime_put_autosuspend(bdi->dev);
+       }

        return 0;
 }
@@ -1492,15 +1553,25 @@ static int bq24190_pm_resume(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
        struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
+       int error;

        bdi->f_reg = 0;
        bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */

-       pm_runtime_get_sync(bdi->dev);
+       error = pm_runtime_get_sync(bdi->dev);
+       if (error < 0) {
+               pm_runtime_put_noidle(bdi->dev);
+               dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
+       }
Last nitpick: call put_noidle after dev_warn, as in suspend :-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help