From patchwork Sat Dec 22 20:26:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10741461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CFE713B5 for ; Sat, 22 Dec 2018 20:27:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F08C728A4F for ; Sat, 22 Dec 2018 20:27:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E455828A52; Sat, 22 Dec 2018 20:27:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 932D928A4F for ; Sat, 22 Dec 2018 20:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+LQ12Y1aeF2+Q9kXutYdyhpZPDmp1bSjOkRNZNNcRZY=; b=QAk8P8gdTnJO1+ 4uBqcnQ9ysetMmsIQxffKAd74oDYlMM4b5cfHdJWONMdGnZ/BBUskft9+OuJmVUO9uGjcHoTuFHzK 1/IgS9WCfMbgm7Jd2aMvBNim5bmbO+UkoHOW/zywwtuBTLckDk7jtbKuZPzD53Di1AQgYWdk1LFNs Puct8kA2sU8WjM+WhFLy8Xx/TnXxevLPejFs9hTGaeBQdN6M4t68ddMgfF2MsCV6p3ak1D+pyUQ45 enDp/NbXr82bMAtV3Q+b4LVH0pLKiZM5a9w6GL44BnhgNhbZet6dj7ZoT1dSw0SdXrmnLJejto0OP jmTSm0hF7fSBdhiWh/Jg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ganrT-0008Pk-SI; Sat, 22 Dec 2018 20:27:03 +0000 Received: from sauhun.de ([88.99.104.3] helo=pokefinder.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ganrC-000885-5L for linux-arm-kernel@lists.infradead.org; Sat, 22 Dec 2018 20:26:48 +0000 Received: from localhost (p54B67A8B.dip0.t-ipconnect.de [84.182.122.139]) by pokefinder.org (Postfix) with ESMTPSA id 1B15A2E35C9; Sat, 22 Dec 2018 21:26:33 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [PATCH v2 2/9] i2c: reject new transfers when adapters are suspended Date: Sat, 22 Dec 2018 21:26:16 +0100 Message-Id: <20181222202623.4521-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181222202623.4521-1-wsa+renesas@sang-engineering.com> References: <20181222202623.4521-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181222_122646_402849_24BCC3E6 X-CRM114-Status: UNSURE ( 8.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wolfram Sang , Wolfram Sang , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Hans de Goede , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Using the 'is_suspended' flag from the PM core, we now reject new transfers if the parent of the adapter is already marked suspended. Signed-off-by: Wolfram Sang Signed-off-by: Hans de Goede --- Documentation/i2c/fault-codes | 4 ++++ drivers/i2c/i2c-core-base.c | 3 +++ drivers/i2c/i2c-core-smbus.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/Documentation/i2c/fault-codes b/Documentation/i2c/fault-codes index 47c25abb7d52..0cee0fc545b4 100644 --- a/Documentation/i2c/fault-codes +++ b/Documentation/i2c/fault-codes @@ -112,6 +112,10 @@ EPROTO case is when the length of an SMBus block data response (from the SMBus slave) is outside the range 1-32 bytes. +ESHUTDOWN + Returned when a transfer was requested using an adapter + which is already suspended. + ETIMEDOUT This is returned by drivers when an operation took too much time, and was aborted before it completed. diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 28460f6a60cc..3ce238b782f3 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1865,6 +1865,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (WARN_ON(!msgs || num < 1)) return -EINVAL; + if (WARN(device_is_suspended(adap->dev.parent), + "Accessing already suspended I2C/SMBus adapter")) + return -ESHUTDOWN; if (adap->quirks && i2c_check_for_quirks(adap, msgs, num)) return -EOPNOTSUPP; diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index 9cd66cabb84f..e0f7f22feabd 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c @@ -547,6 +547,10 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, int try; s32 res; + if (WARN(device_is_suspended(adapter->dev.parent), + "Accessing already suspended I2C/SMBus adapter")) + return -ESHUTDOWN; + /* If enabled, the following two tracepoints are conditional on * read_write and protocol. */