From patchwork Mon Dec 10 21:02:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 10722493 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 522C714E2 for ; Mon, 10 Dec 2018 21:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F1052A7E3 for ; Mon, 10 Dec 2018 21:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30B772A9FD; Mon, 10 Dec 2018 21:04:08 +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 CE7ED2A7E3 for ; Mon, 10 Dec 2018 21:04:07 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=S4MeuTBNCktjVrpmsGMY6B7Wjd2bLE7dcCr4HfjkzF8=; b=f/uQBkKIS/OHFpwUuH/ONaP8aa iuczYTlQBtAwMbuOlY2Xz2O8B6DHdkEKrUZT0FY47mC0TG0dU+94D2sadXCliFn2WhRvmi5iWVMEW azpCY5Z5JzoJEk40sA073LB3OUuP5LNbu/+yVL/bDRhW/AlkPS0xHn0Tg/J2HTfINPUm01uHpNXGT V7zRQoDlCrD6YCne1i0VqdtwMSZZxNsoBYsKnuuBXS9CsYnljTOgE/BuBW4ewRsAba96o8VGHlPWH u3HZwh2KVwrgVm7GMG+K0qXAf12bgxnhR0aj3E4Uu/jWNNit1jKPARJJOeMaZe7NbF/zLnQkRmCa0 Cs32M3Bw==; 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 1gWSia-0007pQ-Ff; Mon, 10 Dec 2018 21:03:56 +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 1gWSi9-00076j-9o for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 21:03:31 +0000 Received: from localhost (p54B335CF.dip0.t-ipconnect.de [84.179.53.207]) by pokefinder.org (Postfix) with ESMTPSA id BC9124C2010; Mon, 10 Dec 2018 22:03:13 +0100 (CET) From: Wolfram Sang To: linux-i2c@vger.kernel.org Subject: [RFC/RFT 01/10] i2c: add 'is_suspended' flag for i2c adapters Date: Mon, 10 Dec 2018 22:02:59 +0100 Message-Id: <20181210210310.12677-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181210210310.12677-1-wsa+renesas@sang-engineering.com> References: <20181210210310.12677-1-wsa+renesas@sang-engineering.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_130329_482262_0AFC8DAF X-CRM114-Status: GOOD ( 11.99 ) 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 , linux-pm@vger.kernel.org, Wolfram Sang , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Hans de Goede , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 Some drivers open code handling of suspended adapters. It should be handled by the core, though, to ensure generic handling. This patch adds the flag and an accessor function. Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core-base.c | 1 + include/linux/i2c.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 28460f6a60cc..9f89e258c8ff 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1232,6 +1232,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap) if (!adap->lock_ops) adap->lock_ops = &i2c_adapter_lock_ops; + adap->is_suspended = false; rt_mutex_init(&adap->bus_lock); rt_mutex_init(&adap->mux_lock); mutex_init(&adap->userspace_clients_lock); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 65b4eaed1d96..9852038ee3a7 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -680,6 +680,7 @@ struct i2c_adapter { int timeout; /* in jiffies */ int retries; struct device dev; /* the adapter device */ + unsigned int is_suspended:1; /* owned by the I2C core */ int nr; char name[48]; @@ -762,6 +763,14 @@ i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags) adapter->lock_ops->unlock_bus(adapter, flags); } +static inline void i2c_mark_adapter_suspended(struct i2c_adapter *adap, + bool suspended) +{ + i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER); + adap->is_suspended = suspended; + i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER); +} + /*flags for the client struct: */ #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */