Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1146118pxk; Fri, 4 Sep 2020 01:36:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJUSrb3Ubao3MdtztMLxSQCqAIr3nqMKT79sF8RvMnAOrrEGjPf+nNkUOw2J7AXY8UhXv0 X-Received: by 2002:a50:bb65:: with SMTP id y92mr7289893ede.53.1599208605463; Fri, 04 Sep 2020 01:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599208605; cv=none; d=google.com; s=arc-20160816; b=z4NgcFWmoPIkZjhsyUUie/xEyE0V0g65bMEerQ1NqSEeL/yLBlvyPNfKQnJYBT/uxW PTdmGhZb3Bg3++ZE8pfBiHL9ndezyo6z/pSfz5ad4OvSlo2b0OmkFNAYBBudI7r9F5YY 5e1YpVIrdY+WhdOQYRvj/1BnB3u9N7eNw3rts9I7t/3UvrcXrChF0H7wRjp0GksUTLHD 3JjxKU6SSbnNaNor4y3CtiL13xEoJVq0+kZaTpZcDPYlwA8iZcnTz8G7/T1+2kK7JjOa rqMktcoxzFh4CT/oDV1pCLTlqW3SmE/fZ3a1EMceL4I82g0CubPOusrWgKR1l3mnI744 TBxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:references:ironport-sdr:dkim-signature; bh=kNwMM6HYUV8/hmRQrZp2flgA/kd+qCncmjZbwyB4Q+w=; b=bYIjkTERnBbrDHuLnbpg+Ij1G78xwONp2547DNArBOZYplbBjpvVxl/t9UP28nTT4/ ydpFIBVHJFvGFmrKEQ4PUQuhUjzqZ0qyv7FAUr8dQcV+8YOWS5SoiRVOllKF5AhNT4ks PU4PYH3OfhJJLbpNcgbrQgETCzBSM2Byly99xHZmdHYkLMmGgd+FPnFCjwsKFy7tmfUa J/Fy0+2/y9N8quc8gyguy+py9xBjwF/Ep+rq3LvpiMocp3SsA59hypzhdS1wbyGVvtRO jAYifWp1rLCbXWyjm7nI9dAD9XVqOMCEpUiTJy6j8FW7dzEeFGMaXKFTPGlm4sStgoBe U8gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=GcPJjKvd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si3548309ejc.311.2020.09.04.01.36.21; Fri, 04 Sep 2020 01:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=GcPJjKvd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbgIDId3 (ORCPT + 99 others); Fri, 4 Sep 2020 04:33:29 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:32671 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbgIDIdZ (ORCPT ); Fri, 4 Sep 2020 04:33:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1599208406; x=1630744406; h=references:from:to:cc:subject:in-reply-to:date: message-id:mime-version; bh=q7FxclsURvMFLB4KzgyOyXIzenqxhAB++84k34J/Njo=; b=GcPJjKvdLfiOh008m+5DyvCNKQ5Te4JMLwkquIbSmjYV7wfosvuH4OBs QBSpZ4hROguGziNPmC+OeeGwpJMg1Oz8NJNHlrybyzLciNa8Ux9p59vU1 ferBNuJoygiB/HBWvTGg+ScEO4JirTMSeOak+ysZdp4g8PlhIjjXiCvmt qSr0QU5xJnwX4ZRjSNtpLSMhD0LnF1K58dbZFwKxZcrp6fWYaR8W8oOhy kp3LoBeMTUnhLhcRMwJh2mS5o3lAZ4vIMJgtmczqUBIT5xxy7llEEfMuM 5EK/uSFXafb4wmDyRgyjHKXOjbxXdv3/7qlWxwf0dsoIERdrHPxxIkb3H Q==; IronPort-SDR: jBtz3COpuZ437EHW3+7MUlyGi+NWPaovslUEAsagCbvg/mLBURmJpyg+dbwcAe5KQ4MRlIpd/V F3f4YSULETNBQGYmyiCF0IZBiPu7qQTc1P1WJibgBf30aUwr2mi3BPjIHZr6tWu1n/xs2RzpB7 bLLTRb+n73doHDJxyT+Yz6tjwUTXZgv6++7uVO4zAtRQYkqZnqmmDRnOqEmwKH19OOxNhRUj8W 4zMYKfs81bTQQ5rVezkOCwPcTR/wM3MAu7mnOVUM1WJTJ3kNigNaWUroohVM4K/g7WYiOd19Va gaM= X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="89822923" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Sep 2020 01:33:25 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 4 Sep 2020 01:33:13 -0700 Received: from soft-dev15.microsemi.net.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3 via Frontend Transport; Fri, 4 Sep 2020 01:33:11 -0700 References: <20200903134704.8949-1-lars.povlsen@microchip.com> <8ca270c9-5561-3176-61cf-7a9fbee10d1f@roeck-us.net> From: Lars Povlsen To: Guenter Roeck CC: Lars Povlsen , Jean Delvare , Microchip Linux Driver Support , , , , "Zhang Rui" , Daniel Lezcano , "Amit Kucheria" Subject: Re: [PATCH] hwmon: sparx5: Fix initial reading of temperature In-Reply-To: <8ca270c9-5561-3176-61cf-7a9fbee10d1f@roeck-us.net> Date: Fri, 4 Sep 2020 10:33:11 +0200 Message-ID: <87v9guvt4o.fsf@soft-dev15.microsemi.net> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Guenter Roeck writes: > On 9/3/20 6:47 AM, Lars Povlsen wrote: >> If the temperature is read before the internal calibration is >> completed, the driver returns -EIO. Instead it should return -EAGAIN >> to encourage repeating the operation. >> >> Signed-off-by: Lars Povlsen >> --- >> drivers/hwmon/sparx5-temp.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/hwmon/sparx5-temp.c b/drivers/hwmon/sparx5-temp.c >> index 1a2b1026b026..98be48e3a22a 100644 >> --- a/drivers/hwmon/sparx5-temp.c >> +++ b/drivers/hwmon/sparx5-temp.c >> @@ -56,7 +56,7 @@ static int s5_read(struct device *dev, enum hwmon_sensor_types type, >> case hwmon_temp_input: >> stat = readl_relaxed(hwmon->base + TEMP_STAT); >> if (!(stat & TEMP_STAT_VALID)) >> - return -EIO; >> + return -EAGAIN; > > The problem is that this may result in a hard loop and effectively hang the system, > or at least the calling process. It may be better to return -ENODATA in this situation. > Guenther, Thank you for your response. The motivation for the patch was as I tried to use thermal support to control a fan, and I noticed an initial quip from thermal_core.c:update_temperature() - it will throw a dev_warn() for anything else than an "EAGAIN". The EAGAIN also seems to be used by several other hwmon drivers in similar situations. The bottom line is that I would like to get rid of the warning message. Changing the error code to ENODATA does not fix what I am trying to accomplish. Do you have any suggestions on how to achieve the objective? Sincerely, ---Lars > Guenter > >> value = stat & TEMP_STAT_TEMP; >> /* >> * From register documentation: >> -- >> 2.27.0 >> -- Lars Povlsen, Microchip