From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796022071; b=bwK/GZJiQy1fAZbRg2jz6P4XZA1u08k060LJuu9/WfOgshHvBmbTVTCieBMeXnRhxipv 74cO1FQKn/i51v4p409DtAaU/fgPvqq/ep2m4AnY+5fV/pcRM2YS/KlxxK0GSvY8Lj1Nr ThDiSkKNax9RqwftPdRB8zHU7GcHNRSKq2kJW5SegX/65TLs+Bg2lZsan0ZNs5b1nP1YW YfbOi0vsDmt34UsWJPKemYe3hCVgipXG9tTINfUBlB3qvzHOLGBysdQrFnX9xq059cExN 4C0NuVN5Wj/OHhHnQTFg1AmnNeUdM/5/fRtuNSSfuNvDm3dQjig7cyxStn0VwegJ7IQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796022071; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=teKRb9U1JQXYl35YntRr9laucD/h2Ph7KLVdmsCzk9g=; b=I6vSn0HdAsW60LjBtAzkMCd7c2IvLsVeAridz2VsdieAz0qUAHsEmZzdZBRaLdiNNb8w rBJvOD2oz8m0rbQ09UJZ+1Cub9NDC2FeN4WcdBxBvgaUOigN5ksz2DJ7XkI11f1rEldRI SkFaHNOrkRtXwDRn6b8Pv0/C5DsQPsGGAvaRexWzuqkBdL3Wdm1P4Jtv3PtKU1WVN/Qpd 1B8yyNfbbZOqIoOBOC4v9hijlxn8YwcYu3pTwrNmFA7SUIQ+URmIfDkqnAr1Aa6HcnqNb XVTxHVup0TBpqq0nMvk4fHwi4d8T5mutUVsy5GNmzYp5wo93333kb5ftBAxw0qMIbLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yx2iz99S; arc=none smtp.remote-ip=209.85.167.48 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CB50606A31C for ; Mon, 30 Nov 2026 07:01:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5CB50606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yx2iz99S Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5be53e5fce1so9640199e87.1 for ; Sun, 29 Nov 2026 23:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796022069; x=1796626869; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=teKRb9U1JQXYl35YntRr9laucD/h2Ph7KLVdmsCzk9g=; b=yx2iz99SU7GlQ+bbVGet8U8yThjMeu56E9Gd9X0dqUEkJtH7P4UC+eVyKMHfW7g/gK Uek50fu7cD01FrDH0m3QC8ReTPR8WmO83w2rI+UKlnTPEz03SACrWT7dZJ6Ej1oxHMaF 5W9cmcX33siWVNElZkMTsVkpKULzp4/tlwsgJ++MVAM6XsOPpMeMiFsy1D/W17PNjBRE xAh8mmHpgCbYr0Dr64K/ej/jyFc85dFUzWPvveTmaqeat9TXvr2akXSvL/zJInwH5ct8 4FVXf2rl3ZEXAueGn6b96rbEZTUmGk4tAz6nYQfzWDPaofFdZ05Dp0miFNL4UFNmIalU 6K0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796022069; x=1796626869; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=teKRb9U1JQXYl35YntRr9laucD/h2Ph7KLVdmsCzk9g=; b=KialMxmAJ5ZwkdHoOUErqjNfiBO0qVz6w5DOY8s8z8RJwgjMhFoEDUUW/vU5U/YARx R2sx0xD1U41V0QTSxbtqYtHrco1bgU8gQqbKZbjILwLYFUXTwPtaUzLZaDr3YyQMZ0aH ZtTYjRJL8tVKKBFXNg0hsJJU6JFkinduhqDdnseEXLDQi68XqgriuSfDp/qWvKV+NzAC ooxWQUpVa1iC7h8xGZqzMzuSBnj0/sUBC7xz+9+w7UpFyJ78B2laqz55B/JNkGyC+6dk 10ptFt4IgDqFjTuZKlftTk6uC5Li08TcwEA78aRRUQ6p3SRAC2gOBlcAUJeRAi6NXE+A n60g== X-Forwarded-Encrypted: i=1; AL+hErEjXdXZtamtgh1xh61ycFoP99O9zps/hDKcOqcpoW8MrYVzMmsh/OxiZiwUui3lu4f/v92+yZgWawoVki0=@vger.kernel.org X-Gm-Message-State: APuU4Z95huBP8ssB7FamLyeVjPUfJmB2rKaM+FXbZGjDMIZSJyT/zi3i RFhN9qxM1N3S8oJzECkrTmvp+sRx9UCkH+K2qRXMLEFdO6KcnEdW0RJFrstrK21d X-Gm-Gg: AZFdTZf5ewbs9CWukiZKCLMFQEM4z0P97PfyEjBL44teY+Gk9f+qEIFfwU+4BV9OipM fOSqC2uzfOy6VQbB9eivq9fiTLqoEZEUHaEv8ecIzJq6/Jn+seqYpn4yh+4bBSPfuBcdWjHvCwN WM5d8b/PnkHQii09aNAO94dWOWqA1CnR25PDkoYZ1oz+YBePgi2uiVM8burCw3skUKKzg7Ed/1H 7dD1f+1SW+GFoXwnHo6lkWSwb8G8nZwclcR4oa78mcqObH+Ml6jKsGXX+wIB38IIoj12yHCBjSz cHkZtQn4eWpR9QouVWUAP+m0C+ogwqb3uflOHQS//btJb/s7ivrYcc1nXzn1whalTWDV0iY81nF QUb3B/bchEPhskY/JoDrV9RdoIgIR9PgTuZxYiNpCKUDVFpUNZ5fTJNR4l7BWm3pXhMLP5NXNJr JW2+U60Sg+maE5kjjjWWd1SE+/3HtJyrsyB3U77InFF4lGPiUidLXJUf0Ks/AwMr1vFA4wxPqZg MB5nKNvd+RxwBEvdH6Hp3+OVg0ee1ufLx3i0bRzEPvNBv19pdkmDRYJQf/3ZBNC09l7wFaR1gBe 4ac+Whm2SYht+zFEBfhgLrd92N5M9dXaOkqvcCIXAc+Kvp4Z3dBrfxQpI9DekM8GYhJD8gXALvV G2oTEeduj1g== X-Received: by 2002:a05:6512:2314:b0:5c0:160:6dae with SMTP id 2adb3069b0e04-5c1bc7fb288mr9241806e87.24.1796022068951; Sun, 29 Nov 2026 23:01:08 -0800 (PST) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1bd04fdafsm7979302e87.61.2026.11.29.23.01.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 23:01:08 -0800 (PST) Message-ID: Date: Mon, 30 Nov 2026 09:01:07 +0200 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages To: Andy Shevchenko Cc: Joshua Crofts , Jonathan Cameron , David Lechner , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <0723d51fa973f0204e1c436c08a784b7b1cca795.1795699121.git.mazziesaccount@gmail.com> <3ec029d6-d53d-4cd9-8582-a15cfd3eb4d1@kernel.org> <036d044a-67ef-4716-aa0a-cdf3108c12e4@gmail.com> <9291049f-987e-4402-b32c-12c33c7aaa33@gmail.com> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 27/11/2026 14:08, Andy Shevchenko wrote: > On Fri, Nov 27, 2026 at 01:46:12PM +0200, Matti Vaittinen wrote: >> On 27/11/2026 13:03, Andy Shevchenko wrote: >>> On Fri, Nov 27, 2026 at 08:34:22AM +0200, Matti Vaittinen wrote: >>>> On 26/11/2026 15:31, Joshua Crofts wrote: >>>>> On 26-Nov-26 14:23, Matti Vaittinen wrote: > > ... > >>>>>> + int vcc_mv; >>>>> >>>>> _mV is the preferred style to denote SI unit variables. >>>> >>>> I have discussed this before, and I disagree. Regular variables have been >>>> lower case since forever. Capitals have been used to scream "Note me, here >>>> is something unusal you need to pay attention for" (like macros). In my, >>>> admittably not always humble enough, opinion, the whole "denote SI units" is >>>> stupid. I haven't yet seen an engineer who wouldn't understand the meaning >>>> of vcc_mv in this context. And, to be very blunt, if I saw such an engineer, >>>> I would rather him stay away from the driver code. On the other hand, I have >>>> seen engineers who have spent long time with kernel code, stop reading to >>>> wonder "Hey, we have capitals here, what's special with this >>>> variable/member". So for me a change from vcc_mv to vcc_mV makes this worse. >>> >>> And I disagree with your argumentation because the scope of discussion here is >>> more than just millivolts. We have (in practice!) already a problem with mHz >>> versus MHz. Yes, in real life. >> >> I see no mHz or MHz here. > > That's why I pointed that the issue is broader than just millivolts _here_. > FWIW, mHz is in drivers/iio/imu/st_lsm6dsx/. If the problem is with the mHz vs MHz - why adding weird variables elsewhere? In my opinion, we should avoid blindly following general "rules of thumb". And we definitely shouldn't invent such out of very specific cases. >>> So, that's why it's better to follow SI for all >>> SI registered units and stop messing with the multipliers. >> >> No. There is zero reason to use capitals in variable/member names when >> intent is clear. It only hurts reading with zero real benefits. > > It's clear for *you* or somebody else who is not the first day in IIO > development, always put yourself into the position of unprepared reader. If you consider someone coming outside of IIO (but someone who has spent time in-kernel) - it is likely seeing upper-case variable makes them rise their eyebrows. And no, VCC is not used only in IIO. VCC is pretty much used with a wide variety of electronics. Besides, I don't buy your claim that "vcc_mV" would make the meaning of variable any more known for someone who does not come from IIO than vcc_mv does. To me this claim sounds just plain silly. If you know vcc is a voltage, then mv -suffix is really obvious. If you don't know it is voltage, then mV - suffix won't help. I really have a feeling this is very made-up solution to a made-up problem. To me, (I don't claim this is how things are, this is how it seems to me) comments like this are a symptom of: "I want to show I am a Very Capable Experienced Kernel Developer and I want to feel important" attitude, rather than "I genuinely believe this is an important improvement to the contribution, and I want to help the author to improve". Please note, this does not mean I didn't appreciate your reviews. I do value many of your findings, you tend to add also some very valuable comments. > SI is known for much longer than computer even exist. > >>>>>> + int vfs_mv; > > ... > >>>>>> + data->vcc_mv = ret / 1000; >>>>> >>>>> Better to do ret / (MICRO / MILLI). >>>> >>>> This is another thing I've discussed also in the past. If you genuinely stop >>>> to think this, why would MICRO / MILLI be better than 1000? Which one brings >>>> smaller cognitional load, huh? And assigning the result to variable vcc_mv >>>> makes units explicit in any case. And speaking of SI units and scientific >>>> accuracy, what actually is MICRO? What is MILLI? >>> >>> Then what prevents you from adding a new multiplier to units.h? > > No answer? I think I've said it also earlier. In my opinion, we should not obfuscate 1000 with a define. To me, 1000 is as clear as it gets. If we have a define, then there is always a chance it means something else - unless we go and see the define. Like in case of MILLI and KILO, MICRO and MEGA. > ... > >>>> Micro is 10^-6! Milli is 10^-3. So, this becomes "ret / (10^-6 / 10^-3)", >>>> which is plain incorrect. So, instead of making things better, this >>>> obfuscates stuff even further. So please, let's not spread this madness any >>>> further. >>> >>> Because kernel does not work in float, it works in integer space. >> >> This does not mean Milli is same as Kilo. You were the one who ask for >> accuracy above (even though it really just breaks the known convention), and >> here you demand obfuscation. > > Yeah, it would be nice to have the stricter rules about this, but I see the > problems it may lead to. For the given case we transform the value in MICRO > volts to a MILLI volts using a ratio MICRO / MILLI. I consider that much easier > to read in the code and _understand_ what's going on. I understand the intention of explaining the transformation from micro to milli, but I genuinely think this is a very failed attempt. We are reading code, not documentation, and if code says: ret / (MICRO / MILLI); it says we are dividing ret by a value, which is MICRO / MILLI. In order to understand what resulting ret is going to be, one must dig out what the MICRO and MILLI are. This is extra step for anyone who does not know what they are, and also an unnecessary (although simple) computation for anyone who know what they are. It really is not a documentation but obfuscation. For unit conversion, one would logically expect to see _multiplication_ by the ratio (which, of course, would not work here as MICRO and MILLI aren't what they are supposed to be). This is just obfuscation to ... Somebody else, who is the first day in IIO development. Please, always put yourself into the position of unprepared reader. In my opinion, if the transformation really requires documentation, use real values and add a comment. vcc_mv = ret / 1000; /* uV to mV */ Do NOT add some strange inverse unit division with bad defines. Now, when one considers if a comment would be needed in above code, seeing the 'ret' value comes from regulator API and goes into vcc_mv ... In my opinion, this really is not something that would need a comment. >>> We don't have fractions without keeping a multiplier in mind. I do not >>> consider this a madness. >> >> swapping 1000 to (MICRO / MILLI) - where micro and milli arent what they are >> supposed to be - is madeness to me. > > And opposite to me as we may admit. I admit :) Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductor Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~