From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049260; b=CJUUIHce2wweDx1e4EhMYH/APMEiFFg30jfGaww3a2PIXaPk/sWNgq0mR73QK7L7/vZc UDJjFntPXxq1/7KTLp8D1gC+Am9v3SI5EP67YHaXJDNrjf71J6HBkNOEIAFk/T+0gHpkK XD9bijaX/goXef/tQgn+zYQcRAR2v9ZaZg+hOfTqmygIMX5EU16f1WJMIlbnoZ4LQAYo9 u+Ww8MDXmSkuVSf98/hyz66crwMXpbPrb3ah3j8jnv9Q7LMg89Vi3bF4uOQ5ZFSw9Xfmo jH/5ivgFiv7Fi51B1LsZFGW+/KwFXwRLEkaSzUY803duutn2OhI1zGN2F1Orh1fC1QA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049260; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=fblHtQlJ64grYP5t6aqSG7Q5/bVtbiIrgEogkU8ONRQ=; b=SEiJk9ohLwIhwUW2HBnflruZuAa/ijJxn57titu+rfr2AoANbD9sGbjef7kiMKKUYEXm cBjMRKL7LxHCy7WdycVZcrxiCRdgizZbFscPCa3vC3gmQWY5raGzCR1v/hqYjzOAvMGoL U7wjssAnuTj+YG2l3lftikdVEbkX3J3QKB4SwMpY6zT9bA1yvdYUOW69nv/e2ehAI+Zh1 HeCuIaK24EiU/zlZlsyVz7W9Zu3hQhCXLxwlAscC2G8v83ybLjhtx95IZvbMlYq9KxomN CDtR67gYFldtgjA8KKMU9MOB6W/GUDK8szG+belzGyh1zaKSpjtSwljE/FXKJbvuMIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WCWopw8c; arc=none smtp.remote-ip=198.175.65.18 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E609606A338; Mon, 30 Nov 2026 14:34:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7E609606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WCWopw8c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796049259; x=1827585259; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=fblHtQlJ64grYP5t6aqSG7Q5/bVtbiIrgEogkU8ONRQ=; b=WCWopw8cXUTyDn/cCOAvW4R+06LUK0l9NL90se+8rsI27pCtvnN3cVPw QQ4GDmGZKJpEMSTjCQ9+oLLIbpjxzgOtmWv2KUuuhwKXpxV84QlfLuDcc mq8uDhEPv2qwckD5nAt1cqHaQ86SLIYMTdw8XtxIkHpFm6/zgtkOW9pDF z3FmvQtJr02x9eGf8N1Aw9N0NAO2HmofihWQlSSImA3MVx5cMddHloQlm 9Ylz4ohBOfUBFquZKDCg+Fvmc/C3UJ0sTD04sG+IIC/1OI1ouP55ncuIv K3hnhVNmpT5WFRgQV0W4yWYIPxwmYidFOtVR07qPGXrdqsXEI5e79zkw/ w==; X-CSE-ConnectionGUID: vWIyiFCgR6WeWubk6hu+ZQ== X-CSE-MsgGUID: tHJmNVcnQzCR5OrWXDBwGg== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4886716" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4886716" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:34:19 -0800 X-CSE-ConnectionGUID: FvuQOOw2Q7GNIlMexWZpDA== X-CSE-MsgGUID: qEmI02I+QRmDxmTt02HTYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="13253305" Received: from abityuts-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.117]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:34:17 -0800 Date: Mon, 30 Nov 2026 16:34:14 +0200 From: Andy Shevchenko To: Matti Vaittinen Cc: Joshua Crofts , Jonathan Cameron , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages Message-ID: 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> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Mon, Nov 30, 2026 at 09:01:07AM +0200, Matti Vaittinen wrote: > 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. Then we will end up with different SI units when we apply different style to them. > > > > 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. Vcc can be in Volts, millivolts, microvolts, and so on. We add unit suffices for readability to understand the order of the values and give more meaning to the expressions like vref_mV = 5; Then we have different suffices based on SI + registered multipliers and how they are represented in the physical world. Yes, it's not that much a problem as we take it standalone (for isolated driver and isolated case), but in general it's a deviation in style. > 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. I understand the frustration, but I'm for the common style, like a standard at least in the borders of a single subsystem. What you are saying about individual approach based on the SI in use I disagree with, because it would lead to potential misinterpretations. > > 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. It requires an additional cognitive work to get the order of the value kept in 'ret'. With (MICRO / MILLI) it's easier to understand (as it's read as 'we got value in microSOMETHING and we convert it to milliSOMETHING). ... > > > > > 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. Everybody understands what are they. The same argument as you used about 'mv' versus 'mV' above. > 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. Yes, this is the main point of our disagreement. So, I think we can go thru applying the multiplier in the units.h as MICROVOLT_PER_MILLIVOLT and then it will follow the pattern that is used *a lot* in the kernel for other things. > 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 :) ... With all arguments being said, I do not think we can productively and effectively continue this discussion. Let's just not waist our time on this anymore and do something more useful. Do you agree? Especially taking into account that Jonathan is okay with your style and AFAICS he applied this already. -- With Best Regards, Andy Shevchenko