From patchwork Tue Apr 22 16:45:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4033721 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 80E829F319 for ; Tue, 22 Apr 2014 16:47:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0449620170 for ; Tue, 22 Apr 2014 16:47:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55BC82022D for ; Tue, 22 Apr 2014 16:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932737AbaDVQq1 (ORCPT ); Tue, 22 Apr 2014 12:46:27 -0400 Received: from mail-ie0-f202.google.com ([209.85.223.202]:36453 "EHLO mail-ie0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932892AbaDVQqV (ORCPT ); Tue, 22 Apr 2014 12:46:21 -0400 Received: by mail-ie0-f202.google.com with SMTP id lx4so1214828iec.3 for ; Tue, 22 Apr 2014 09:46:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gVukRlmLh6xJmj/Ny/ZAcBnkgJLwCEqBJmH33qF3PPs=; b=cwdM3w2UGneDUnN/aJYcmTX3lAPl6Agqr2uU2cTYwpZDIg8bjqEG+8z42hYBwfqroh 4+54DA85dOXUkD4ui2uy/FTwDTyDgEvP9PlrNCPNjvJR6vAvhEjSx+z4Bsq9F62DsKm2 yrmv69qWR3F4xoVUwxBYzxmVPE0C2VFDPctpsl/pwjo2e6jPDMX0bHHCUdktaGSVkykU LWq4ETOQuStpnQVYCkobZ5me5xyRl01H6OnvEPXr0H2iYi3jledZT0jJhFfqQUImXSXD Tn5bAbeiPf8KOU1ogJb5WkiA0S5xYhEmfxhwi9iY5A7ejIDsCCAMDhnHnw6CaUAWYLZS 2zpA== X-Gm-Message-State: ALoCoQkDtccNsJqygylqdAMVJRDCq/N7mTUQ2ipD/H14TzJXayqBcQj4/Pv+BRt9Ja724ZktmBCoFnUfobgc0qX2ugQlH9ZvpAT0Gsnwff1R2Z6fs/sqx2Pc3p5nTZoD2116Ewy5Ke3OsOjpIuNF918KXnbFCn4ng/p1Y2dfHeRjQ2kKwrPVzt+siPRZWldLYfZQn4X86nO/iG5oxQBIzRkCuh3r0OtKQA== X-Received: by 10.42.62.11 with SMTP id w11mr18535283ich.29.1398185180729; Tue, 22 Apr 2014 09:46:20 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id s65si5666430yhc.2.2014.04.22.09.46.20 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Apr 2014 09:46:20 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.72.141]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 889F55A4298; Tue, 22 Apr 2014 09:46:20 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 2AEB280535; Tue, 22 Apr 2014 09:46:20 -0700 (PDT) From: Doug Anderson To: lee.jones@linaro.org, swarren@nvidia.com, wsa@the-dreams.de Cc: abrestic@chromium.org, dgreid@chromium.org, olof@lixom.net, sjg@chromium.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, David Hendricks , Doug Anderson , sameo@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] mfd: cros_ec: spi: calculate delay between transfers correctly Date: Tue, 22 Apr 2014 09:45:48 -0700 Message-Id: <1398185154-19404-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1398185154-19404-1-git-send-email-dianders@chromium.org> References: <1398185154-19404-1-git-send-email-dianders@chromium.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Hendricks To avoid spamming the EC we calculate the time between the previous transfer and the current transfer and force a delay if the time delta is too small. However, a small miscalculation causes the delay period to be far too short. Most noticably this impacts commands with a long turnaround time such as EC firmware reads and writes. Signed-off-by: David Hendricks Signed-off-by: Doug Anderson Reviewed-by: Simon Glass Tested-by: Andrew Bresticker Tested-by: Stephen Warren --- Changes in v2: None drivers/mfd/cros_ec_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 84af8d7..c185eb6 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c @@ -219,7 +219,7 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, ktime_get_ts(&ts); delay = timespec_to_ns(&ts) - ec_spi->last_transfer_ns; if (delay < EC_SPI_RECOVERY_TIME_NS) - ndelay(delay); + ndelay(EC_SPI_RECOVERY_TIME_NS - delay); } /* Transmit phase - send our message */