From patchwork Thu Feb 14 17:17:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 2142211 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3BDFDDF283 for ; Thu, 14 Feb 2013 16:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934696Ab3BNQSd (ORCPT ); Thu, 14 Feb 2013 11:18:33 -0500 Received: from mail-vc0-f176.google.com ([209.85.220.176]:43294 "EHLO mail-vc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934673Ab3BNQSd (ORCPT ); Thu, 14 Feb 2013 11:18:33 -0500 Received: by mail-vc0-f176.google.com with SMTP id fk10so1575296vcb.21 for ; Thu, 14 Feb 2013 08:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=TbF8YCjmovNKSZ5gwZnqq9pUVAZzltmkJl+vSEdObLE=; b=wA8A0Zcfl0st/t/oCOqdiwROj/3vaJL3BFM5j4KUlOKKczqXxCfUzWvOtwsZlyuYwm /4mN10jrvobTReprDLMp5kd3674gKX1Fa5MqtCgHa9APRDPVfy1iFHtIvA7UQjAUPfIZ NJxZFezm0eA4ROvD3H3lApmSZ2z83j/5LtsPbCwCOEUX6KyJOIrKAdE2WV3YMyMNa1UQ lvjoZFhEChXkAcroEZ9rXCRWIT3C8XgiFVxqhivA4FMbAJEg7HF/3OQN/NLtiPRWpb6+ P5656N546EaUivuwL9LkSgrelckjBj/eFnvSTTPpAcnSNEFxDDkuEk1CTiLvcpUHfE0c NDQA== X-Received: by 10.52.38.163 with SMTP id h3mr31122983vdk.35.1360858712049; Thu, 14 Feb 2013 08:18:32 -0800 (PST) Received: from bender.routerdd3bcc.com (rrcs-50-74-208-202.nyc.biz.rr.com. [50.74.208.202]) by mx.google.com with ESMTPS id cl9sm76424534vdb.3.2013.02.14.08.18.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Feb 2013 08:18:31 -0800 (PST) From: Bastian Hecht To: linux-sh@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Magnus Damm , Bastian Hecht Subject: [PATCH] i2c: sh_mobile: Don't start transfers when suspending Date: Thu, 14 Feb 2013 11:17:37 -0600 Message-Id: <1360862257-10807-1-git-send-email-hechtb+renesas@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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 --- 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[] = {