linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] max17042_battery: add suspend/resume hooks
Date: Fri, 4 May 2012 20:38:09 -0700	[thread overview]
Message-ID: <20120505033809.GA3285@lizard> (raw)
In-Reply-To: <1332795220-8343-1-git-send-email-ramakrishna.pallala@intel.com>

On Tue, Mar 27, 2012 at 02:23:40AM +0530, Ramakrishna Pallala wrote:
> This patch adds suspend/resume methods to the driver.
> 
> In suspend method irq line is disabled to avoid i2c
> read/write errors from the interrupt handler as the
> i2c bus itself could be in suspend state.
> In resume function irq  line will be re-enabled.
> 
> Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
> ---

Applied, thank you!

[...]
> +#else
> +#define max17042_suspend NULL
> +#define max17042_resume NULL
> +#endif
> +
[...]
> +static const struct dev_pm_ops max17042_pm_ops = {
> +	.suspend		= max17042_suspend,
> +	.resume			= max17042_resume,
> +};
> +
>  static struct i2c_driver max17042_i2c_driver = {
>  	.driver	= {
>  		.name	= "max17042",
>  		.of_match_table = of_match_ptr(max17042_dt_match),
> +		.pm	= &max17042_pm_ops,

It's better to hide dev_pm_ops under CONFIG_PM, and pass NULL in case
of !PM.

FYI, I applied this on top:

diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 07dee97..738648d 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -727,7 +727,8 @@ static int max17042_suspend(struct device *dev)
 {
 	struct max17042_chip *chip = dev_get_drvdata(dev);
 
-	/* disable the irq and enable irq_wake
+	/*
+	 * disable the irq and enable irq_wake
 	 * capability to the interrupt line.
 	 */
 	if (chip->client->irq) {
@@ -751,9 +752,15 @@ static int max17042_resume(struct device *dev)
 
 	return 0;
 }
+
+static const struct dev_pm_ops max17042_pm_ops = {
+	.suspend	= max17042_suspend,
+	.resume		= max17042_resume,
+};
+
+#define MAX17042_PM_OPS (&max17042_pm_ops)
 #else
-#define max17042_suspend NULL
-#define max17042_resume NULL
+#define MAX17042_PM_OPS NULL
 #endif
 
 #ifdef CONFIG_OF
@@ -770,16 +777,11 @@ static const struct i2c_device_id max17042_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, max17042_id);
 
-static const struct dev_pm_ops max17042_pm_ops = {
-	.suspend		= max17042_suspend,
-	.resume			= max17042_resume,
-};
-
 static struct i2c_driver max17042_i2c_driver = {
 	.driver	= {
 		.name	= "max17042",
 		.of_match_table = of_match_ptr(max17042_dt_match),
-		.pm	= &max17042_pm_ops,
+		.pm	= MAX17042_PM_OPS,
 	},
 	.probe		= max17042_probe,
 	.remove		= __devexit_p(max17042_remove),

      reply	other threads:[~2012-05-05  3:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 20:53 [PATCH] max17042_battery: add suspend/resume hooks Ramakrishna Pallala
2012-05-05  3:38 ` Anton Vorontsov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120505033809.GA3285@lizard \
    --to=cbouatmailru@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ramakrishna.pallala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).