From patchwork Sat Dec 27 22:35:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 5545231 Return-Path: X-Original-To: patchwork-linux-arm@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 EF5489F1BF for ; Sat, 27 Dec 2014 22:39:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F29F52010F for ; Sat, 27 Dec 2014 22:39:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 273772010C for ; Sat, 27 Dec 2014 22:39:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y4zxX-00045W-E1; Sat, 27 Dec 2014 22:35:43 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y4zxS-00042D-Ek for linux-arm-kernel@lists.infradead.org; Sat, 27 Dec 2014 22:35:40 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id D164D81D5E; Sat, 27 Dec 2014 23:35:16 +0100 (CET) Date: Sat, 27 Dec 2014 23:35:16 +0100 From: Pavel Machek To: Sebastian Reichel Subject: Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor Message-ID: <20141227223516.GA18455@amd> References: <20141226102933.GA28778@amd> <1419597294-21487-1-git-send-email-sre@kernel.org> <1419597294-21487-3-git-send-email-sre@kernel.org> <20141227195825.GF10007@amd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141227195825.GF10007@amd> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141227_143538_692839_3AE7E3F7 X-CRM114-Status: GOOD ( 20.77 ) X-Spam-Score: -2.3 (--) Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Tony Lindgren , Kumar Gala , linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org, Rob Herring , Jean Delvare , =?iso-8859-1?Q?Beno=EEt?= Cousson , Pali Rohar , Mark Rutland , linux-omap@vger.kernel.org, Guenter Roeck X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_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 On Sat 2014-12-27 20:58:25, Pavel Machek wrote: > On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote: > > OMAP34xx and OMAP36xx processors contain a register in the syscon area, > > which can be used to determine the SoCs temperature. This patch provides > > a DT based driver for the temperature sensor based on an older driver > > written by Peter De Schrijver for the Nokia N900 and N9. > > > > Signed-off-by: Sebastian Reichel > > --- > > drivers/hwmon/Kconfig | 8 ++ > > drivers/hwmon/Makefile | 1 + > > drivers/hwmon/omap3-temp.c | 307 +++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 316 insertions(+) > > create mode 100644 drivers/hwmon/omap3-temp.c > > When it hangs, it loops here: > > do { > regmap_read(data->syscon, SYSCON_TEMP_REG,&temp_sensor_reg); > if ((temp_sensor_reg & eocz_mask) == level) > return true; > printk("="); > } > while (ktime_us_delta(expire, ktime_get()) > 0); And this fixes the hang, and makes level handling more readable. Fix the timeout code, now it actually works. Driver still fails after a while. Signed-off-by: Pavel Machek diff --git a/drivers/hwmon/omap3-temp.c b/drivers/hwmon/omap3-temp.c index 8a69604..1b8c768 100644 --- a/drivers/hwmon/omap3-temp.c +++ b/drivers/hwmon/omap3-temp.c @@ -130,9 +130,7 @@ static inline bool wait_for_eocz(struct omap3_temp_data *data, ktime_t timeout, expire; u32 temp_sensor_reg, eocz_mask; eocz_mask = BIT(data->hwdata->eocz_bit); - level &= 1; - level *= eocz_mask; expire = ktime_add_ns(ktime_get(), max_delay); timeout = ktime_set(0, min_delay); @@ -140,9 +141,9 @@ static inline bool wait_for_eocz(struct omap3_temp_data *data, schedule_hrtimeout(&timeout, HRTIMER_MODE_REL); do { regmap_read(data->syscon, SYSCON_TEMP_REG, &temp_sensor_reg); - if ((temp_sensor_reg & eocz_mask) == level) + if (!!(temp_sensor_reg & eocz_mask) == level) return true; - } while (ktime_us_delta(expire, ktime_get()) > 0); + } while (ktime_after(expire, ktime_get())); return false; }