From patchwork Fri Oct 5 21:45:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jae Hyun Yoo X-Patchwork-Id: 979791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42RjyJ1KjZz9s4V for ; Sat, 6 Oct 2018 07:46:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42RjyH6jFvzF3ct for ; Sat, 6 Oct 2018 07:46:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Original-To: openbmc@lists.ozlabs.org Delivered-To: openbmc@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.intel.com (client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jae.hyun.yoo@linux.intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42Rjwg5mrlzF3cs; Sat, 6 Oct 2018 07:45:23 +1000 (AEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2018 14:45:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,346,1534834800"; d="scan'208";a="75773038" Received: from maru.jf.intel.com ([10.54.51.77]) by fmsmga007.fm.intel.com with ESMTP; 05 Oct 2018 14:45:11 -0700 From: Jae Hyun Yoo To: Brendan Higgins , Wolfram Sang , Benjamin Herrenschmidt , Joel Stanley , Rob Herring , Mark Rutland , Andrew Jeffery , linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH i2c-next v7 2/5] i2c: core: Add support reading of 'bus-timeout-ms' and '#retries' properties Date: Fri, 5 Oct 2018 14:45:04 -0700 Message-Id: <20181005214507.26315-3-jae.hyun.yoo@linux.intel.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> References: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> MIME-Version: 1.0 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vernon Mauery , Jae Hyun Yoo , Jarkko Nikula , James Feist Errors-To: openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "openbmc" This commit adds support for 'bus-timeout-ms' and '#retries' properties to set 'timeout' and 'retries' values in 'struct i2c_adapter' in case an adapter node has the properties. Still the values can be set by I2C_TIMEOUT and I2C_RETRIES ioctls on cdev at runtime too. These properties may not be supported by all drivers. However, if a driver wants to support one of them, it should adapt the bindings in the dt-bindings document. Signed-off-by: Jae Hyun Yoo --- drivers/i2c/i2c-core-base.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 799776c6d421..aa2a365d374a 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1214,6 +1214,7 @@ EXPORT_SYMBOL_GPL(i2c_handle_smbus_host_notify); static int i2c_register_adapter(struct i2c_adapter *adap) { int res = -EINVAL; + u32 bus_timeout_ms = 0; /* Can't register until after driver model init */ if (WARN_ON(!is_registered)) { @@ -1239,8 +1240,15 @@ static int i2c_register_adapter(struct i2c_adapter *adap) INIT_LIST_HEAD(&adap->userspace_clients); /* Set default timeout to 1 second if not already set */ - if (adap->timeout == 0) - adap->timeout = HZ; + if (adap->timeout == 0) { + device_property_read_u32(&adap->dev, "bus-timeout-ms", + &bus_timeout_ms); + adap->timeout = bus_timeout_ms ? + msecs_to_jiffies(bus_timeout_ms) : HZ; + } + + /* Set retries count if it has the property setting */ + device_property_read_u32(&adap->dev, "#retries", &adap->retries); /* register soft irqs for Host Notify */ res = i2c_setup_host_notify_irq_domain(adap);