From patchwork Tue Oct 30 21:09:13 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: 10661585 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 927261734 for ; Tue, 30 Oct 2018 21:09:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FF612A5C2 for ; Tue, 30 Oct 2018 21:09:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72C632A5C9; Tue, 30 Oct 2018 21:09:38 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 2A2072A5C2 for ; Tue, 30 Oct 2018 21:09:38 +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=IEVcg/eXfT01K22XQ+jNasVhuwGzbmZHfl5kLf2pIBs=; b=hyf2j9ffWy9+Dm xzEgKJ3xbvuWlfiB6F7zvnGGrd4QMiMAyoxuaNTgkvLnOpXrt3vqVIrGBuqW3xL1sivuPDzu5Le/O qIjKcHNiOP3UahD1rg9zIu13pIbehRuo1EhBUDRhbeOIeTwT1gAeIY/ZuYYSLEQEt2Y4oY9jONxTe RODDQ1sbYgziQduJY3xRArdBuWpxzKBsmEa/C9DWvSRByqV9buFS6PW4dMzbkQwp3CLnF+Govy+1h g4UsYXuqDlRwAAVfBqcPErxyJAgdITjP9xepIyDJ8x+lca6mBdzEowlrEwBOAMipD1ETDLvzrKHOW 5A5aNjUu7XqwGr5E+gxA==; 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 1gHbGY-0002fA-Um; Tue, 30 Oct 2018 21:09:34 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHbGV-0002bn-G5 for linux-arm-kernel@lists.infradead.org; Tue, 30 Oct 2018 21:09:32 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 14:09:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,446,1534834800"; d="scan'208";a="100110058" Received: from maru.jf.intel.com ([10.54.51.77]) by fmsmga002.fm.intel.com with ESMTP; 30 Oct 2018 14:09:23 -0700 From: Jae Hyun Yoo To: Wolfram Sang , Brendan Higgins , Rob Herring , Joel Stanley , Benjamin Herrenschmidt , 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 v9 2/5] i2c: core: Add support reading of 'bus-timeout-ms' and '#retries' properties Date: Tue, 30 Oct 2018 14:09:13 -0700 Message-Id: <20181030210917.32711-3-jae.hyun.yoo@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181030210917.32711-1-jae.hyun.yoo@linux.intel.com> References: <20181030210917.32711-1-jae.hyun.yoo@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181030_140931_551598_B85F692A X-CRM114-Status: GOOD ( 18.22 ) 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: Vernon Mauery , Jae Hyun Yoo , Jarkko Nikula , James Feist 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 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 dc78aa7369de..abf8e78bdb82 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);