From patchwork Tue Feb 9 09:26:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8259091 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78852BEEE5 for ; Tue, 9 Feb 2016 09:27:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7E0D2022A for ; Tue, 9 Feb 2016 09:27:30 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6264220265 for ; Tue, 9 Feb 2016 09:27:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aT4a0-0004cH-4Q; Tue, 09 Feb 2016 09:27:28 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aT4Zy-0004bp-KG for tpmdd-devel@lists.sourceforge.net; Tue, 09 Feb 2016 09:27:26 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.67 as permitted sender) client-ip=74.125.82.67; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f67.google.com; Received: from mail-wm0-f67.google.com ([74.125.82.67]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aT4Zx-0007HS-Va for tpmdd-devel@lists.sourceforge.net; Tue, 09 Feb 2016 09:27:26 +0000 Received: by mail-wm0-f67.google.com with SMTP id c200so2246064wme.0 for ; Tue, 09 Feb 2016 01:27:25 -0800 (PST) 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=CSCgXxpvw4RTsNaQdeu1ZI4w26nPqMRu9ZqfAVFsGcc=; b=GCKrgE15IC4j1la/OFR08dX3mg3zyWE5CDhhTFs3xhmdH9YiSawAhhLY/hmslrj69Z v8Zbz298ivisgn5X5sXPypaPxlJA2MLx0uZ20UR3fSPL5Ff9SCES52SvP2lwAvjpXH8g IWl9yer5yAljYUgAsSodOQKFwk/YyJCeWFpnu4CEmL4Jq+vMIFW6Sm9Au7SyQyJALlbw LpRiqCFPKoVPF7DMExizkqLtiKvHkOcmHwK7cXpbpDAnG8ZeVGoISZaXeUXw9mh461z8 ExAdRY8s/wchH2c9BWj3izmmqt3VSe5Qf9DElGCezAPQJuVfAHtZv9sdnrvJz9caXlAU 5MiQ== X-Gm-Message-State: AG10YORbuwuLZZYXQQtRumzfvqXbFB4JMOepdofUIq8kKuTVXjqNtL6u7PuBKnHtzywbBA== X-Received: by 10.28.14.4 with SMTP id 4mr3819026wmo.100.1455010040027; Tue, 09 Feb 2016 01:27:20 -0800 (PST) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id az10sm33793007wjc.28.2016.02.09.01.27.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Feb 2016 01:27:19 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com, peterhuewe@gmx.de Date: Tue, 9 Feb 2016 10:26:56 +0100 Message-Id: <1455010021-21927-8-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455010021-21927-1-git-send-email-christophe-h.ricard@st.com> References: <1455010021-21927-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1aT4Zx-0007HS-Va Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, christophe.ricard@gmail.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH 07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip is present or in a bad state. Signed-off-by: Christophe Ricard Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/st33zp24/spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index 0af836a..7cabf1d 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c @@ -213,6 +213,11 @@ static int st33zp24_spi_evaluate_latency(void *phy_id) &data, 1); latency++; } + if (status < 0) + return status; + if (latency == MAX_SPI_LATENCY) + return -ENODEV; + return latency - 1; } /* evaluate_latency() */