From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796022071; b=PiTaRDSY73zPMCK/EBKoKy+wPBf/996xqdmWowBUkzkFe9jip9adcrnX2pLYLFFTksjC J6+8q6n1Q0x3pEpPNy784PEpBxQy92fK/DUl7kuWDpmqyEP8voEKu5kd6/b324RtWi/OM LOpGtIfUBMxT89/Lw+8KraxW2HrDnx5Hq1T0Ur0b2Ckr2v6Y0LnL+zCSitRHOj9mPdn8w XCrIE2W2nDlt7RVJxr8AHhYXrsiDd6M8Gp8RlVvXtRWZH3k5o5EHw6+4VqfnXURzGsTgH H1JcTbpSFAFkg19aC3zblRqnx2JemNZIDlRMG5gWQ4doYGCPJ/gUzojTTF1DhCur3pw== 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=HYezDRLTyYKCUsD8kNdNjwG9MjAYNDMRnfjT2/6l4vpmnqKSt+Met84UrgcIJU7cHe8y ZkI1Ha6ICkZ6AzPFSnzKLUMEdeFF6i5XNNLNaVZ6ZKt9dQ5XGrcPBb/nI51GdDtWogEwf S7VCv9zPQlCdWhRlKj+8R9ryGPPMhQIZ3Jm0fpMOhkD+hKGgmGuDH8CXfaCLRgbwsdTYb mXXF702txLiAyfKB4g2TbsVj9vBuVSi1XnMB1SplirXZmDweZairx1qGTr4V5+WK7lTwV Hvpd/cWDShxgLb34tFGBIM2GUvPuDGHPYgs11BBfzQsPbHvx7FnGtOTaofL98NJR8aA== 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.49 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 71553606A320 for ; Mon, 30 Nov 2026 07:01:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 71553606A320 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-f49.google.com with SMTP id 2adb3069b0e04-5c14470729eso9020205e87.2 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=T+uyVuvCRUETosC861Dr8OMGoFsqU6GjGnr+UA/ZTYERbgT6kxIg51vLZI+alSt4Lc zlKCC9YmQ2w3ci2ZVI1H2+Vu935jLgUXKVLo192dkNKJFn/T2y2WAjaESZZhoy14YRNc tXfy9gVcLS+EWieb+iEKRgjNJe+4VMfs3AVAcwyVFWeVyX7tkrDHnDFjNgQdHqPU7xCn MBlr7fOff96qjD+Kj0wGy9bXQHHuqTUuWojZrYCruLSlCo5yrSnMWSzrho1RzS9Uo/pf yfwyUx6uSDRlVrb6ADmmdOEKHv2ZPO5GDKBuKs3NVWBoTgrvkrHeZZ8iudgnOO7pkG7y Le8A== X-Forwarded-Encrypted: i=1; AL+hErGh2bWrhpTt0KSOMROSpyWQT7ur9h5Oz796w/UHT8/+wYBhi2COaavzxO/sO/lemERHI89rcO4qWaI=@vger.kernel.org X-Gm-Message-State: APuU4Z95N2quaIlWywxc6bCEP61nqIoQcCcwzMQH5iz3oGsPz2vY9YEE ct+7zB0BUPiYp6rZYcVIkuWCNMDs/Tcz7EHQfEOo5FER0ZTgg0AOhIrv X-Gm-Gg: AZFdTZfnUN3HLBAsUc/6n3Opvvcwe9fXvrs5ezmzE7agbKDP366PdgPuEDO/6JKfPCQ yVE0ge1i2lwBU9hz7wpPH2cefc/muS+I7T5ziNBbRfq94VPVCB0jzNKx134U9qCkbn7nZI0IxDY usTo+CPghnWEQrvkUWvWLndPpRkmG8cAdHAfpgz4TvfrYDZJv28SFJz1xTqhEj/MfCyGtvhk36f T+fFZIPnPRnmFXfSEwWNi8WgGk2r1u5Gp6zizyEU1Rm6K9fiRoQFOK54Qi1DarFnxBrsOj/zwqa mnO3TUa2vM4pW9twp+Tp8NvYzvCGHdgU7vxLpB2QE55M15PuUCfgA/GfOC5EGausxZPs25TdkBb IoQKxn6HTb7XXH5OKKJh7XnYLTgJ9eZ9Q33ZF4WOLIJfLoIAaL6jKmOtMEeN3q3kL6qHPrprc3z ERwccCVYSBStf/7NM4XRhUp+2EvYmBq0g481WPGcrF+6ZIP2FOo2/vmAauaIB0VZFy+np51W9TC k1UHL0ryYe4UqIXz+lL6u8EC+Rj57Zec/5a0SPWuPRApSnBvqyK5bcmoMIUqYus7ZnZCYIW09oK NsNraRlhpqAfGAk5lk1kWRMwpqkGxtoS1rn1dSGtNoNuPE6XxG2DIoYbeznDb9q8+2/0ZLKHta9 1xqFZJniQqA== 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-iio@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! ~~