Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp707765ybl; Wed, 21 Aug 2019 04:29:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7I89eITtlRVEm1CoBNI1Dn0yKcyCwjNKbyXKY7WI/jdVXIWXv4eeea3ifchQPZDquTqiX X-Received: by 2002:a17:902:6843:: with SMTP id f3mr30842214pln.97.1566386974829; Wed, 21 Aug 2019 04:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566386974; cv=none; d=google.com; s=arc-20160816; b=OtmeweKUK13DTtEQuQ3TTFU7C1SpfX1LeaU+5r2bLHWQN7ODHkN33JEucZNXU654X+ iUI9UYAYz3gZ2zJ2zqy29wi2MEr+rJZk8vVk3+0aNlkT8Qx02doAgLQad7r/wDsdS8/C rYzbX9Z8QqwrncvMqPyK5maZb0mLH7Ei/eXMDLpa/YIN5D+ZIPVcEzNLamVXGu/nL608 LvzrtiBJdLarrIFPuV2YhYgm44l0rIVW8SWIdHDNMEriVpa6cdAYmReHZtRTpapbmEJX xWPZ0Mx/oyMhIk589ejgNNvUG9714pKU0DmBVjcD/P/gUgDmfOSnrL/I6RnD2UvvrvJT 9OzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=TuaZG7Omor+G/AkU6ujx9Ln8/VDzjqK3KDTH0UUDhuU=; b=XCMB7mXxmBxLAGQMfUbfkDtb0bYFR38ns2uBSmSXjz5M69RdgVq5FWyJnbddsjRJ6C EAlr6ejFQTCL1s8EZT8Bd8eR666mdCtDLscLOw33KnojMIHC1Z0WzF1RYyW4G1w+aaD0 nar4RGeseRKO1I3hy+JaqT7xiwd2eCBKzKFLH0N7qdw7tITBQ9ftz8451EwGpyyHzSFk 4gzHDMrkaDPBhqEwH64ovpWM6Y4JfN3HeUDVZpQgUFvTZoR7TZMYtjtShpMG4qrm2UDu asCp6bCvSgDWnmfOb4tDmL/KFUTiPkqVzn+fI3boFJetC3vm0YZp1J1L1XQbXuA6uAJs TZbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r62si14507714plb.363.2019.08.21.04.29.19; Wed, 21 Aug 2019 04:29:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726966AbfHUL23 (ORCPT + 99 others); Wed, 21 Aug 2019 07:28:29 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34807 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfHUL23 (ORCPT ); Wed, 21 Aug 2019 07:28:29 -0400 Received: by mail-ot1-f65.google.com with SMTP id c7so1718510otp.1; Wed, 21 Aug 2019 04:28:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TuaZG7Omor+G/AkU6ujx9Ln8/VDzjqK3KDTH0UUDhuU=; b=PinaZKHD4MuwCZgZ4BVknOphxjy2VBVHAwQZfD0PhJmnMkEmRfVl/TjzA0xTDT9aCH 6GGI2TEp9EFtbLlxMcCbQAkVlHVdEwtPztJZSSniTXbvqjbXWz8xWg5Hjpg7MHjz78ma VYZ5oXNXq8vRgpnlwDpJtHClnnuOuFtYBeASegTLX3ra86Fbv9LNUrlGlPNNIlwQsee8 FZ+AYOi/1flfvsTqdHWmhhfsVCcTuIPFQSFMjmIRVWstrEAMIeum8dmpHkqZ11UBKnyH oRUl5m+n0EeYNzkYbdEkvd2ydwYe4tA3Q9DeJv04XrdCDaCZQrniGgDAVMju9ymxEcD1 Ksbw== X-Gm-Message-State: APjAAAVbdjYAIFF6v6oVUB7XIamb/A9lhBSQ/cFnus7gAs1cHzd7lA4w 6z27WBxi0Kk5MqoWwXrx6Yrqu9Bapa5oh5alYlI= X-Received: by 2002:a9d:68c5:: with SMTP id i5mr3012150oto.250.1566386908109; Wed, 21 Aug 2019 04:28:28 -0700 (PDT) MIME-Version: 1.0 References: <20190805155515.22621-1-jacopo+renesas@jmondi.org> <20190805181244.663585ac@archlinux> In-Reply-To: <20190805181244.663585ac@archlinux> From: Geert Uytterhoeven Date: Wed, 21 Aug 2019 13:28:16 +0200 Message-ID: Subject: Re: [PATCH] iio: adc: max9611: Fix temperature reading in probe To: Jonathan Cameron , Jacopo Mondi Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Kuninori Morimoto , Stefan Agner , linux-iio@vger.kernel.org, Linux Kernel Mailing List , Linux-Renesas , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, Jacopo, On Mon, Aug 5, 2019 at 7:15 PM Jonathan Cameron wrote: > On Mon, 5 Aug 2019 17:55:15 +0200 > Jacopo Mondi wrote: > > > The max9611 driver reads the die temperature at probe time to validate > > the communication channel. Use the actual read value to perform the test > > instead of the read function return value, which was mistakenly used so > > far. > > > > The temperature reading test was only successful because the 0 return > > value is in the range of supported temperatures. > > > > Fixes: 69780a3bbc0b ("iio: adc: Add Maxim max9611 ADC driver") > > Signed-off-by: Jacopo Mondi > > Applied to the fixes-togreg branch of iio.git and marked for > stable. That'll be a bit fiddly given other changes around this > so we may need to do backports. This is now commit b9ddd5091160793e ("iio: adc: max9611: Fix temperature reading in probe") in v5.3-rc5, and has been backported to 4.14, 4.19, and 5.2. > > --- a/drivers/iio/adc/max9611.c > > +++ b/drivers/iio/adc/max9611.c > > @@ -480,7 +480,7 @@ static int max9611_init(struct max9611_dev *max9611) > > if (ret) > > return ret; > > > > - regval = ret & MAX9611_TEMP_MASK; > > + regval &= MAX9611_TEMP_MASK; > > > > if ((regval > MAX9611_TEMP_MAX_POS && > > regval < MAX9611_TEMP_MIN_NEG) || While this did fix a bug, it also introduced a regression: on Salvator-XS, which has two max9611 instances, I now see intermittent failures max9611 4-007c: Invalid value received from ADC 0x8000: aborting max9611: probe of 4-007c failed with error -5 and/or max9611 4-007f: Invalid value received from ADC 0x8000: aborting max9611: probe of 4-007f failed with error -5 during boot. Retrying on failure fixes the issue, e.g.: max9611_init:483: regval = 0x8000 max9611 4-007f: Invalid value received from ADC 0x8000: aborting max9611_init:483: regval = 0x2780 According to the datasheet, 0x8000 is the Power-On Reset value. Looks like it should be ignored, and retried? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds