From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C693C65BBF for ; Fri, 5 Oct 2018 21:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AD5621473 for ; Fri, 5 Oct 2018 21:45:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AD5621473 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729279AbeJFEqS (ORCPT ); Sat, 6 Oct 2018 00:46:18 -0400 Received: from mga03.intel.com ([134.134.136.65]:29594 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbeJFEp5 (ORCPT ); Sat, 6 Oct 2018 00:45:57 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.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 Cc: Jarkko Nikula , James Feist , Vernon Mauery , Jae Hyun Yoo 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.19.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jae Hyun Yoo 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> References: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org 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 Cc: Vernon Mauery , Jae Hyun Yoo , Jarkko Nikula , James Feist List-Id: devicetree@vger.kernel.org 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); -- 2.19.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: jae.hyun.yoo@linux.intel.com (Jae Hyun Yoo) Date: Fri, 5 Oct 2018 14:45:04 -0700 Subject: [PATCH i2c-next v7 2/5] i2c: core: Add support reading of 'bus-timeout-ms' and '#retries' properties In-Reply-To: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> References: <20181005214507.26315-1-jae.hyun.yoo@linux.intel.com> Message-ID: <20181005214507.26315-3-jae.hyun.yoo@linux.intel.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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); -- 2.19.0