From patchwork Thu Jul 9 04:06:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 6752991 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D9B49F38C for ; Thu, 9 Jul 2015 04:07:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7812920691 for ; Thu, 9 Jul 2015 04:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E098120676 for ; Thu, 9 Jul 2015 04:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751291AbbGIEHG (ORCPT ); Thu, 9 Jul 2015 00:07:06 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:47132 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbbGIEG4 (ORCPT ); Thu, 9 Jul 2015 00:06:56 -0400 Received: from 85-23-164-218.bb.dnainternet.fi ([85.23.164.218] helo=localhost.localdomain.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ZD36s-0002AB-TY; Thu, 09 Jul 2015 07:06:54 +0300 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari Subject: [PATCH 09/12] tda10071: use jiffies when poll firmware status Date: Thu, 9 Jul 2015 07:06:29 +0300 Message-Id: <1436414792-9716-9-git-send-email-crope@iki.fi> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1436414792-9716-1-git-send-email-crope@iki.fi> References: <1436414792-9716-1-git-send-email-crope@iki.fi> X-SA-Exim-Connect-IP: 85.23.164.218 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, 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 Use jiffies to set timeout for firmware command status polling. It is more elegant solution than poll X times with sleep. Shorten timeout to 30ms as all commands seems to be executed under 10ms. Signed-off-by: Antti Palosaari --- drivers/media/dvb-frontends/tda10071.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c index 6226b57..c1507cc 100644 --- a/drivers/media/dvb-frontends/tda10071.c +++ b/drivers/media/dvb-frontends/tda10071.c @@ -53,8 +53,9 @@ static int tda10071_cmd_execute(struct tda10071_dev *dev, struct tda10071_cmd *cmd) { struct i2c_client *client = dev->client; - int ret, i; + int ret; unsigned int uitmp; + unsigned long timeout; if (!dev->warm) { ret = -EFAULT; @@ -72,17 +73,19 @@ static int tda10071_cmd_execute(struct tda10071_dev *dev, goto error; /* wait cmd execution terminate */ - for (i = 1000, uitmp = 1; i && uitmp; i--) { + #define CMD_EXECUTE_TIMEOUT 30 + timeout = jiffies + msecs_to_jiffies(CMD_EXECUTE_TIMEOUT); + for (uitmp = 1; !time_after(jiffies, timeout) && uitmp;) { ret = regmap_read(dev->regmap, 0x1f, &uitmp); if (ret) goto error; - - usleep_range(200, 5000); } - dev_dbg(&client->dev, "loop=%d\n", i); + dev_dbg(&client->dev, "cmd execution took %u ms\n", + jiffies_to_msecs(jiffies) - + (jiffies_to_msecs(timeout) - CMD_EXECUTE_TIMEOUT)); - if (i == 0) { + if (uitmp) { ret = -ETIMEDOUT; goto error; }