Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3851289pxa; Sun, 9 Aug 2020 14:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3yGtqNdhcitzWSRI/5YNNEzn7IQdrIjcCJwC0lXlMBLvxkAtsgl2fJRWZfFQqjhNldw0V X-Received: by 2002:aa7:dc02:: with SMTP id b2mr17973429edu.260.1597007244695; Sun, 09 Aug 2020 14:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597007244; cv=none; d=google.com; s=arc-20160816; b=H7Z9L1PrcbjKl3jiyweNYQHiST2UgwD46JasXtm7qyKcbV0Rtp7WZDSuqARKCbZaLX ZnFDYs9ennOdjROVNEHb88Wum6oyBmCUU0whtzsttytoRiU97JedVcEgFplWHXIBCTSK byd/GCEGPAziAF/Ivs68ZaaEWVRhx4MHUHy/n9X4+XoQqrAUjk4hqPNfSwD8o7Wq0+9f 5VjjKlci/bxQfzdLOZJ0pJcNFHlnSMCQdczrldh3R2SA+MydxVCbJuGpyhIhq65br32D q3cecWYdb1V2HrXIwL05dfs3S9k++ZdoAGRhEImiWSjr0wwedgsd7rSJpEEFn/xFf+vM vHiA== 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:dkim-signature; bh=o8F23zcscVB1QKocpaxhAuhbpCbH7PudCZvz9GajNE0=; b=iAVBpYTIwCphHAqYMVWIx9LtpOD1drBk/o25HuNe97FkdqZb825mZgemGSKJoLwsbk Mnp7ec18w1lELps20C4fuOaF+pwdMp8o7WX/XTo9Nq4wIr5IiNUr/kWSfG+Y4lKfJZRH +4g5inHNVsl+H/WdgZAxjP9HDUASIpFOpjYQQcDOLbYcZdg5K13JVQwYdwVjm2c0h8MM Us1YKzFVHLMbq/tUgkEG3T7nKRoYKhyAZhoM402niiMErM4ChUUrDAdQe4gTGORbKMkf XxrCP7vE/q7Zw2nnWCI+KOLjGwDqf2BneP2C5z+HJrmT5J0TW0dDg71TVOqVi5epX9iD qWug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@melexis.com header.s=google header.b=WvIXphsu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gj25si9834758ejb.26.2020.08.09.14.07.01; Sun, 09 Aug 2020 14:07:24 -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=@melexis.com header.s=google header.b=WvIXphsu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726350AbgHIVG1 (ORCPT + 99 others); Sun, 9 Aug 2020 17:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgHIVGZ (ORCPT ); Sun, 9 Aug 2020 17:06:25 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A834C061756 for ; Sun, 9 Aug 2020 14:06:25 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id a5so6941988ioa.13 for ; Sun, 09 Aug 2020 14:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=melexis.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o8F23zcscVB1QKocpaxhAuhbpCbH7PudCZvz9GajNE0=; b=WvIXphsumD/84UBawdSSvREujkdf++uBtSv4umWl22VRHIoN6yBCv+q8wgI0qJhYZW 38ImT5eSAcP/1G0QePaN1/zphOkBibq+FUKPcNazwOfXnmSmibjBXj4tsTWIaKkpn+to lFajnQlHUicGE20GwnMnRqrt5x/qWM84NXHINpctJAfso2iO++Hf+ShA/3e/oD7KrZm9 /LNeHMLVUOsHNN6dem0t5od2nE5My68LU1yspryaRGcRrD54a7W8x8hWyFfF2oW7WMjO jjPYZrp++yYF4QZ6exBV3JPyDDiJfJsAEcUnCzCfymhxc/gxkwxy2D+B02SHftrX7tGU cHHQ== 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=o8F23zcscVB1QKocpaxhAuhbpCbH7PudCZvz9GajNE0=; b=gbIJIe017mgo/135w5/6q+ITsPPMgYazdi/l2yEU1NozPWHBemL+/quErBL14ymiL1 H4Vf1C52fUr/EloyieVDtqvJrHgdLr6P6xbRH027NYWFDkKgXHafjUw57+vu7qCAB4PO sn7yOTdm3acbUq6JCqoSrNXHtDY89ZfWerHyTiyygd1TGH6XQXkouY+ShQEpBcHkmAb8 554Qij4gkS9DuNsWyBemv7BbdD+7rYcokIeBnHbLtp0cEOkMvqTwIC7B385UQYk5hFUF b06uHRRo148G53Hq/WgowwRWy2FxSVha6rIcso46H8mVIGAYNmE9VFp/Eio8zuFp22nz tu3g== X-Gm-Message-State: AOAM530+BIwS1jZgLFAapzKbMH6xQf+/8SpIymDtUI/O0HmjexURgPPd lxpJ0144Apt3HXgIeohkK/YaBujrBZ3q9Hzz5UHp1+OM99jMrA== X-Received: by 2002:a5e:dd4c:: with SMTP id u12mr14004089iop.93.1597007184650; Sun, 09 Aug 2020 14:06:24 -0700 (PDT) MIME-Version: 1.0 References: <20200808121026.1300375-1-cmo@melexis.com> <20200808121026.1300375-3-cmo@melexis.com> <20200809143222.4e19ea38@archlinux> In-Reply-To: <20200809143222.4e19ea38@archlinux> From: Crt Mori Date: Sun, 9 Aug 2020 23:05:48 +0200 Message-ID: Subject: Re: [PATCH v4 2/4] iio:temperature:mlx90632: Adding extended calibration option To: Jonathan Cameron Cc: Andy Shevchenko , linux-iio , Linux Kernel Mailing List 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 On Sun, 9 Aug 2020 at 15:32, Jonathan Cameron wrote: > > 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) > So for you lines like s32 read; read = (read + (s16)read_tmp) / 2; would actually be better as: read = (read + sign_extend32(read_tmp, 15)) / 2; Hm, strange. I would read that more align the read_tmp to 32 bit than the value you have in read_tmp is actually a signed 16 bit integer... > > > > > ... > > > > > > > + 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. > OK will add those, but it is ending up as: MLX90632_RAM_DSP5_AMBIENT MLX90632_RAM_DSP5_EXTENDED_AMBIENT MLX90632_RAM_DSP5_OBJECT_1 MLX90632_RAM_DSP5_EXTENDED_OBJECT_1 MLX90632_RAM_DSP5_OBJECT_2 MLX90632_RAM_DSP5_EXTENDED_OBJECT_2 ok? > > > > > ... > > > > > > > + 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