Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4437038pxb; Mon, 21 Feb 2022 21:35:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIRzbPOiUOgDnkXMMX2yO5OjZrknHI1kB5uDL7kJ6UBcqYDOUBAbIfGasn8J4Dbl4ecIzz X-Received: by 2002:a17:90a:c386:b0:1bc:274a:c202 with SMTP id h6-20020a17090ac38600b001bc274ac202mr2413203pjt.185.1645508115963; Mon, 21 Feb 2022 21:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645508115; cv=none; d=google.com; s=arc-20160816; b=SsNa3/+rWmfMMJvjwJvkWsKO/pkRnNH6Vnb9ThjxoEDtIskSYQ7ygnQTYjuFj7Y3Qh SIu96HRgWn9B8cCQ+aFnXFHrconhLEJU+9BRJm9O3vHR6XWBwFBq56HJ5tjJDpp5HoPb L1wSPlashtuRw5rsh3GpfN714FnObVaIDi9xtoYse0PRiiZtA3WnZoMxBsTrYOO/Pd8F QgwYWPbEQiLBv6JvjcG1Kv2Rfys2Yu3kM9b89TwMH9Qxxuke63m7FDi7EAb/UvDVdIfP 5AoSG+DDsxsSd8Dg1ZO7J2TbQzpDnLXudcxsaUQOUUM94bu5AmvGqHT7YS96tXKPOG4i noVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=CuC7f4KIwhRURQqrkG1raV3vJWZvnVGFpmPUwwQMuuE=; b=X/O/yt/e6HvXp/HR2+m9khS5kyW9thyxX+3ODKoTR1DfVrORosOutabB5dD/v43Ejo 04pPySn9oG3yzQmU7klNetaTvtkyMqkP6wodlMGX0QRYPip1v+xPJiu97tRcyWi/6BvH sercxsmdZh9tT04XeKhARNsYW7zcknj84Srbaju7Z5UPsfXeQbIgk73zZxH+PIVrSxip f50DVoj4hzl7xW068TvraVw6zdaEyOF2SLFAB+Tt7wEwq2R8C/jgCbgG6If6n/7lTVpw +VvEVgMZZJPjN3mHW8KNieWF4vF6uhidx/+xakTT501+bvabuQmEWnQaOAi3FgygAqhI Ezxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EPQjAelj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y4si2989642plk.99.2022.02.21.21.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:35:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EPQjAelj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1544A122F7F; Mon, 21 Feb 2022 21:02:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235254AbiBUWLr (ORCPT + 99 others); Mon, 21 Feb 2022 17:11:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232574AbiBUWLr (ORCPT ); Mon, 21 Feb 2022 17:11:47 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9216C22BF0; Mon, 21 Feb 2022 14:11:21 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id f10so14456589qkg.9; Mon, 21 Feb 2022 14:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=CuC7f4KIwhRURQqrkG1raV3vJWZvnVGFpmPUwwQMuuE=; b=EPQjAeljfZI07y1KWMA5ii6YRXBezMDpX4SEnWzSYInuqPIBI6PSuD3mEq88PACcIF BXnbcHmvKplH7koEBdQbpua/DvYHU3K+ylBLgw8Hdhyni9QEC1jQKkUf8S17NEd0tSpV EKaaOFLNJucljmw1c7lE+1ho7tBIsOy1M9+o/g0OJPNHPIRCAbLgLrwhbbahY31PdSlO /Kwh8R0pgEamuORLmC+fgNYuip5EAGQ7ZuQbZdu9B1u3h9KkjGSvyXq3JAE5W07GrK5A nqaltX6dD1VUnahlWp+CM7/hysZK5A9VP0DrHT08Um20TanzRODtDvbAnnkaIDu+Oyi4 jbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=CuC7f4KIwhRURQqrkG1raV3vJWZvnVGFpmPUwwQMuuE=; b=WBBhdAVHRhdJ1iIrm7coY1miuk0ctcAIrbCk1Yrcb+1elX2btCxmcKh5KrpaX2Zbud SiUbdvX72xdAlg9i4kY4zO+BoY7tCYVH6RRQ7sgoZKdMmnQp2B3M1xvKThVj4L0f9Wni tpwF9Kmwm13sE5cQyTnjeFT5O+/QKZGVNdiMcUW0wpx1FkaS6hrkuYIubXkOuD28/yVX piYO/ielQJ4xl2BTUyGf9F7LoR3XYkvS76bfaqe/RKqmKoBcRIm6zDH/qyhlZgd5tqt0 6SPITQxTG56JIKwLfDNSho9OgUL/USEDDkvIT35H4NH4LvEDCwJthm88xlniP2ZxBj+Z a6MA== X-Gm-Message-State: AOAM53065/enzU9VRbjxS8g2p/cCwNlGM7ElDi9lLZQVqJ2waADRwr72 6gq6OF45gTy1NF6K+yfNQwk0fD4ziYpnaw== X-Received: by 2002:ae9:dfc7:0:b0:648:e065:84be with SMTP id t190-20020ae9dfc7000000b00648e06584bemr4538507qkf.129.1645481480727; Mon, 21 Feb 2022 14:11:20 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h1sm28345769qkn.71.2022.02.21.14.11.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 14:11:19 -0800 (PST) Sender: Guenter Roeck Message-ID: <238e6fb0-cd77-4772-3e92-23941dc74403@roeck-us.net> Date: Mon, 21 Feb 2022 14:11:17 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v5 1/2] dt-bindings: hwmon: add tmp464.yaml Content-Language: en-US To: Krzysztof Adamski Cc: linux-hwmon@vger.kernel.org, Agathe Porte , Jean Delvare , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220218150908.1947772-1-linux@roeck-us.net> <66e6b131-274f-454b-44f6-17df879d71a9@roeck-us.net> From: Guenter Roeck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/21/22 13:24, Krzysztof Adamski wrote: > Dnia Mon, Feb 21, 2022 at 08:16:15AM -0800, Guenter Roeck napisał(a): >>> I still thing we should have the same format here and in tmp421, for >>> consistency. If use the same property name, "ti,n-factor" but on tmp421 >>> you have use 32bit value while here you have to use 8bit (which is weird >>> in DT, BTW), it might be confusing. >>> Back when we did this for TMP421, there was some discussion and we >>> settled on this approach, why do it differently now? >>> >> >> I seem to recall from that discussion that there was supposedly no way to >> express negative numbers in devicetree. Obviously that is incorrect. > > Well, I would still argue it *is* correct. DT only support unsigned > numbers and, really, only 32 or 64 bit. See the chapter 2.2.4 Properties > in: > https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf > > Devicetree also supports array of bytes, and this is how we get the > /bits/ magic but this is just a syntactic suggar. The same is true about > negative values. Just decompile your compiled DTB and you will see. > To put it in other words - DTS does support negative values, DTB don't.j > >> In addition to that, I strongly suspect that the tmp421 code as written >> does not work. Its value range is specified as 0..255, but it is read with >>     err = of_property_read_s32(child, "ti,n-factor", &val); >> and range checked with >>     if (val > 127 || val < -128) { >>                dev_err(dev, "n-factor for channel %d invalid (%d)\n", >>                       i, val); >>                return -EINVAL; >>        } >> >> That just looks wrong. Either the value range is 0..255 and checked >> as 0 .. 255, or it is -128 .. 127 and must be both checked and specified >> accordingly. This made me look into the code and I found how negative >> numbers are supposed to be handled. > > It worked for me when I tested that. I could redo the test, if you are > unsure. The code also looks good to me. I wasn't convinced for this > format in yaml but after the whole discussion we had, we settled on > that, with Robs blessing :) > It is hard for me to believe that you can enter, say, 255 into the dts file and of_property_read_s32() reads it as -1. If so, of_property_read_s32() could never support values of 128 and above, which seems unlikely. Now, I can imagine that one can enter 0xffffffff and of_property_read_s32() returns -1, but that isn't what is documented for tmp421. Guenter > Here's the actual discussion where all this was considered: > https://patchwork.kernel.org/project/linux-hwmon/patch/3ff7b4cc57dab2073fa091072366c1e524631729.1632984254.git.krzysztof.adamski@nokia.com/ > > I'm not saying the way we do this for tmp421 is better or even right, > all I say is that it would make sense to be consistent and not redo this > discussion every time we have this problem. > > Krzysztof