linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastian Hecht <hechtb@gmail.com>
To: linux-sh@vger.kernel.org, linux-i2c@vger.kernel.org
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Bastian Hecht <hechtb+renesas@gmail.com>
Subject: [PATCH] i2c: sh_mobile: Don't start transfers when suspending
Date: Thu, 14 Feb 2013 16:18:35 +0000	[thread overview]
Message-ID: <1360862257-10807-1-git-send-email-hechtb+renesas@gmail.com> (raw)

Currently we provoke i2c timeouts by allowing transfers when
suspending. This patch adds awareness to suspending and fixes these
issues.
The patch follows the style used in i2c-tegra.c - thanks.

Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index b6e7a83..da28164 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -132,6 +132,7 @@ struct sh_mobile_i2c_data {
 	struct i2c_msg *msg;
 	int pos;
 	int sr;
+	bool is_suspended;
 };
 
 #define IIC_FLAG_HAS_ICIC67	(1 << 0)
@@ -511,6 +512,9 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
 	u_int8_t val;
 	int i, k, retry_count;
 
+	if (pd->is_suspended)
+		return -EBUSY;
+
 	activate_ch(pd);
 
 	/* Process all messages */
@@ -753,9 +757,33 @@ static int sh_mobile_i2c_runtime_nop(struct device *dev)
 	return 0;
 }
 
+static int sh_mobile_i2c_suspend(struct device *dev)
+{
+	struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
+
+	i2c_lock_adapter(&pd->adap);
+	pd->is_suspended = true;
+	i2c_unlock_adapter(&pd->adap);
+
+	return 0;
+}
+
+static int sh_mobile_i2c_resume(struct device *dev)
+{
+	struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
+
+	i2c_lock_adapter(&pd->adap);
+	pd->is_suspended = false;
+	i2c_unlock_adapter(&pd->adap);
+
+	return 0;
+}
+
 static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
 	.runtime_suspend = sh_mobile_i2c_runtime_nop,
 	.runtime_resume = sh_mobile_i2c_runtime_nop,
+	.suspend = sh_mobile_i2c_suspend,
+	.resume = sh_mobile_i2c_resume,
 };
 
 static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
-- 
1.7.9.5


             reply	other threads:[~2013-02-14 16:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 16:18 Bastian Hecht [this message]
     [not found] ` <1360862257-10807-1-git-send-email-hechtb+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-16  2:26   ` [PATCH] i2c: sh_mobile: Don't start transfers when suspending Simon Horman
2013-02-16  3:54 ` Magnus Damm
2013-02-18 16:03   ` Bastian Hecht
     [not found]     ` <CABYn4szejurs2gBVOx_+geOxw13r9KvoShfRiM7OOF5wVvDPLA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-21  9:14       ` Wolfram Sang
2013-02-21 14:54         ` Bastian Hecht
     [not found]           ` <CABYn4swuDgTvvyigjnabcg46rcze-DnGhv2Rh7WEFdwkXcHR4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-21 14:59             ` Wolfram Sang
2014-05-21 11:00           ` Wolfram Sang
2014-06-24  8:14             ` Bastian Hecht

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=1360862257-10807-1-git-send-email-hechtb+renesas@gmail.com \
    --to=hechtb@gmail.com \
    --cc=hechtb+renesas@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.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).