On Fri, Feb 3, 2017 at 10:54 AM, Tony Lindgren <tony@xxxxxxxxxxx> wrote: > ... > From: Tony Lindgren <tony@xxxxxxxxxxx> > 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 <kernel@xxxxxxxxxxxxxxxxx> > Acked-by: Mark Greer <mgreer@xxxxxxxxxxxxxxx> > Signed-off-by: Tony Lindgren <tony@xxxxxxxxxxx> > --- > drivers/power/supply/bq24190_charger.c | 156 ++++++++++++++++++++++++--------- > 1 file changed, 114 insertions(+), 42 deletions(-) > > diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c > --- a/drivers/power/supply/bq24190_charger.c > +++ b/drivers/power/supply/bq24190_charger.c > > @@ -1234,11 +1267,18 @@ static void bq24190_check_status(struct bq24190_dev_info *bdi) > static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) > { > struct bq24190_dev_info *bdi = data; > + int ret; > > bdi->irq_event = true; > - pm_runtime_get_sync(bdi->dev); > + ret = pm_runtime_get_sync(bdi->dev); > + if (ret < 0) { > + dev_err(bdi->dev, "Runtime PM failed in %s: %i\n", > + __func__, ret); > + return IRQ_NONE; > + } Now this is a nitpick... Error msg should be consistent with suspend/resume: > @@ -1480,10 +1532,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); > + } Like here. > @@ -1492,15 +1554,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); > + } And here. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html