Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4097997imu; Mon, 10 Dec 2018 13:06:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VJbEqR4oLo/EQVMBo4caHdLEuGcC/Kyr5/pSQlSb7PIrLMiWxyLJnj+Q1xpJwpO7wPmn1E X-Received: by 2002:a62:37c3:: with SMTP id e186mr14134633pfa.251.1544475990988; Mon, 10 Dec 2018 13:06:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544475990; cv=none; d=google.com; s=arc-20160816; b=Ye9+1vnsJoe4Omiti0j6hh+aqt/gCB1JrzZ0gPY7dGYTUvtsnJ7+5NBIbd1meQ9nAk rT2XL7KkarhZ6ku37XsVlV5qX/ZsY9UwsRQoEqqYI0ldiRW2pqjyw2ajDxasKUJ/UY9B ydXcv5SpXfZHsKKSylXE5PWWFaUDszYejhSLmTJ5LA8qyPQoXrHrPZNZPR4qPbxDUGC0 NZkkG4skBucXS24sm2nBIY/sN3gdgyPqmZsPc7xRWu5f4UoJiqq5ldnfvMOKIcvndEcW A9Ct52CUvFewHj9BoJvUcLbh+A3/621+n5MDgzjyf0zjVx+e48hn2nPGdquc6JD1o8aF 19Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7ydMYNTEP1n+QOeNluqK6l3wYNkcW0lFhXgo44krI24=; b=Ww/pKwUXIkoZaNAWKb15hd669WLSE2TeGq86qTAYsqLlnYxoHHOgbPFZcaFK43efY1 jHwbk06j+/eX+6ocDdXWoDxmh4uzTUFpWjEg8DKXt8H6szP+1Y25FsOWTMwbgLlTaU4H vKchTXrUY9fZRMGKAMt25DwRTw9RROKzYPitgq2UtgME9WoN7NlM+PtytzTBxILmXfJM eBw+ZsgiuquaF1e8VYgCqw9VmcwOZPG1V71VRe/13QTYMn1b9ElDjRzB3QDxFdto12fi vXOQesVJqtcj9Swbd7HzUOUiEyXrVg3L6+B8iP/Kvn42YowaXhKrlRX41ktlqa+FLiLE 7tcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si10104270pgl.303.2018.12.10.13.06.14; Mon, 10 Dec 2018 13:06:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729922AbeLJVDR (ORCPT + 99 others); Mon, 10 Dec 2018 16:03:17 -0500 Received: from sauhun.de ([88.99.104.3]:36676 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727967AbeLJVDP (ORCPT ); Mon, 10 Dec 2018 16:03:15 -0500 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 Cc: linux-renesas-soc@vger.kernel.org, Hans de Goede , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Wolfram Sang , Wolfram Sang , linux-kernel@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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.11.0