Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3628225pxa; Sun, 9 Aug 2020 06:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxef71T1KSrx51KK2HMJY2YgVwdDfF7xNbWhhFdZd9XmuqGngQ2R1LBdXpReXSYy6LM4AqC X-Received: by 2002:a17:906:d102:: with SMTP id b2mr16737333ejz.465.1596980000181; Sun, 09 Aug 2020 06:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596980000; cv=none; d=google.com; s=arc-20160816; b=uB2vVMzvgauYXMvZ24mi/dP1BMdNXdyPy14Y1q/HX7US0xQLZMNGsSyrjwQ7DpfbKl D2fU0VH5+Jz0JeiORJtWEgSGdrU+V9f/qthjPGxZVn7VWyQhTrIlaDLqQqCvCvvqfiBa y39f1JFlsPKXjikNfob+ZIQ4BphqaIQPOBOvsPCfFt5kCh/WHLb4iRfzD+J20R7J265Y 2bAShuM8fjWY3+LEUk0WR6MDV/sVWO3S7oQ5Ou507w48j+gu5qrpkE1wk+LaLHMRBQE3 3WVAQxssk2EImyWJM1qlgKRpKFjEzNStI+jh20w4y97svXXWchJ+qjEdbduFPMWW0VTE mELQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=4qxfWYQkmQGZq+4+JacIJwMHKU1xgadopxO7iEG8FFg=; b=W0pw++tt7gp+whj9oAind13+xoPYwEbe405R4AgJyMzwbOJnjOHpjxUGpD0H7+9+JJ FVx0kSDZxG2taOWBE4gasoQ/xtqwLe67NhZJ+tHs/SxSuGoVTbUA5ZUwavschV5DJGDt UM+8/vHeO7KvqvWyq76gBni1+28rIfQh5/lk1UNt4PDWewEKrP3L5k7fS0jpNNKXQxTO F2EfAlsBiApfU4fXMfGALKhqbaootJGAXNvODSiLgoFIlolXD+KBFCHrcXB4IaTCaVKs LvXpByuebDsex9+o4sjES8oj/mA3XpiVlD4tfCXYOwedBLOwjvpDR8dt6VIKFVuiv3uk A1Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cdU7jvqs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y26si8690299edr.390.2020.08.09.06.32.56; Sun, 09 Aug 2020 06:33:20 -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=pass header.i=@kernel.org header.s=default header.b=cdU7jvqs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgHINc1 (ORCPT + 99 others); Sun, 9 Aug 2020 09:32:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgHINc0 (ORCPT ); Sun, 9 Aug 2020 09:32:26 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4F98206B6; Sun, 9 Aug 2020 13:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596979945; bh=x6hX5hmHtgNXUpMMJKzfq2gMV3FBFrP/xYq9lyBrJcs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cdU7jvqsvRA99y1tAOZjJre7pKdrkjgJGNC1NJRQStZ5+VBClhBupnCfrwhR7ZzcI h2FTdhTCSM5lC/pYXU76djpASYaCUEBvFVY3mMKl15iQHwU4N97qFmhQYMY9KnH8g4 eXfoW2EWAD6HUzECMNTluDfaat1XoE0MAf5Z2+0M= Date: Sun, 9 Aug 2020 14:32:22 +0100 From: Jonathan Cameron To: Crt Mori Cc: Andy Shevchenko , linux-iio , Linux Kernel Mailing List Subject: Re: [PATCH v4 2/4] iio:temperature:mlx90632: Adding extended calibration option Message-ID: <20200809143222.4e19ea38@archlinux> In-Reply-To: References: <20200808121026.1300375-1-cmo@melexis.com> <20200808121026.1300375-3-cmo@melexis.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 8 Aug 2020 23:57:59 +0200 Crt Mori wrote: > Hi, > I am very sorry you missed them, I thought you saw it (reply on v3 of > the patch). Maybe something happened to that mail, as it contained > link to datasheet, so I will omit it now. > > Except for the order, only the remarks below are still open (did you > get the polling trail I did?) > > On Sat, 8 Aug 2020 at 22:04, Andy Shevchenko wrote: > > > > On Sat, Aug 8, 2020 at 3:11 PM Crt Mori wrote: > > > > > > For some time the market wants medical grade accuracy in medical range, > > > while still retaining the declared accuracy outside of the medical range > > > within the same sensor. That is why we created extended calibration > > > which is automatically switched to when object temperature is too high. > > > > > > This patch also introduces the object_ambient_temperature variable which > > > is needed for more accurate calculation of the object infra-red > > > footprint as sensor's ambient temperature might be totally different > > > than what the ambient temperature is at object and that is why we can > > > have some more errors which can be eliminated. Currently this temperature > > > is fixed at 25, but the interface to adjust it by user (with external > > > sensor or just IR measurement of the other object which acts as ambient), > > > will be introduced in another commit. > > > > The kernel doc patch should go before this patch. > > > > ... > > > > > + *ambient_new_raw = (s16)read_tmp; > > > > > + *ambient_old_raw = (s16)read_tmp; > > > > Sorry, did I miss your answer about these castings all over the patch? > > > > These castings are in fact needed. You read unsigned integer, but the > return value is signed integer. Without the cast it did not extend the > signed bit, but just wrote the value to signed. Also I find it more > obvious with casts, that I did not "accidentally" convert to signed. Should we perhaps be making this explicit for the cases where we are sign extending? That doesn't include these two as the lvalue is s16, but does include some of the others. sign_extend32(read_tmp, 15) > > > ... > > > > > + ret = regmap_read(regmap, MLX90632_RAM_1(17), &read_tmp); > > > + ret = regmap_read(regmap, MLX90632_RAM_2(17), &read_tmp); > > > + ret = regmap_read(regmap, MLX90632_RAM_1(18), &read_tmp); > > > + ret = regmap_read(regmap, MLX90632_RAM_2(18), &read_tmp); > > > + ret = regmap_read(regmap, MLX90632_RAM_1(19), &read_tmp); > > > + ret = regmap_read(regmap, MLX90632_RAM_2(19), &read_tmp); > > > > What so special about these magic 17, 18, 19? Can you provide definitions? > > > When we started 0 to 19 were all open for access, from userspace, then > only 1 and 2 were used with calculations, and now we use 17, 18 and > 19. Matter of fact is, I can't provide a descriptive name as it > depends on DSP version and as you can see now within the same DSP > version, also on the ID part. While RAM3 vs RAM1 and RAM2 could be > named RAM_OBJECT1, RAM_OBJECT2, RAM_AMBIENT, knowing our development > that might not be true in the next configuration, so I rather keep the > naming as in the datasheet. Normal solution for that is to version the defines as well. MLX90632_FW3_RAM_1_AMBIENT etc When a new version changes this, then you introduced new defines to support that firmware. > > > ... > > > > > + int tries = 4; > > > > > + while (tries-- > 0) { > > > + ret = mlx90632_perform_measurement(data); > > > + if (ret < 0) > > > + goto read_unlock; > > > + > > > + if (ret == 19) > > > + break; > > > + } > > > + if (tries < 0) { > > > + ret = -ETIMEDOUT; > > > + goto read_unlock; > > > + } > > > > Please avoid ping-pong type of changes in the same series (similar way > > as for kernel doc), which means don't introduce something you are > > going to change later on. Patch to move to do {} while () should go > > before this one. > > OK, will fix that ordering in v5, but will wait till we solve also > above discussions to avoid adding new versions. > > > > > -- > > With Best Regards, > > Andy Shevchenko > > And about that voodoo stuff with numbers: > > Honestly, the equation is in the datasheet[1] and this is just making > floating point to fixed point with proper intermediate scaling > (initially I had defines of TENTOX, but that was not desired). There > is no better explanation of this voodoo. We all love fixed point arithmetic :) Jonathan