From mboxrd@z Thu Jan 1 00:00:00 1970 From: Liam Breck Subject: Re: [PATCH 2/2] power: bq24190_charger: Use PM runtime autosuspend Date: Fri, 3 Feb 2017 13:44:52 -0800 Message-ID: References: <20170131000210.5442-1-tony@atomide.com> <20170131000210.5442-3-tony@atomide.com> <20170131003632.GB7403@atomide.com> <20170203185408.GB3721@atomide.com> <20170203211707.GC3721@atomide.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from mail-it0-f65.google.com ([209.85.214.65]:35784 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbdBCVoy (ORCPT ); Fri, 3 Feb 2017 16:44:54 -0500 In-Reply-To: <20170203211707.GC3721@atomide.com> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Tony Lindgren Cc: Sebastian Reichel , Liam Breck , "Mark A . Greer" , linux-pm@vger.kernel.org, linux-omap@vger.kernel.org On Fri, Feb 3, 2017 at 1:17 PM, Tony Lindgren wrote: > From: Tony Lindgren > 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 > Acked-by: Mark Greer > Signed-off-by: Tony Lindgren Acked-by: Liam Breck > @@ -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 :-)