Re: [PATCH] iio: dac: rohm-bd79703: Fix full-scale voltages

From: Andy Shevchenko

Date: Fri Nov 27 2026 - 06:03:11 EST


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. So, that's why it's better to follow SI for all
SI registered units and stop messing with the multipliers.

> > > + 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?

...

> 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. We don't
have fractions without keeping a multiplier in mind. I do not consider this
a madness.

> (So actually, this should be 1_PER_MICRO / 1_PER_MILLI - and that'd
> be even more cognitive load. When did our goal changed from making
> easy-to-understand -code back to making fancy-looking code, which is harder
> to understand, while claiming it to be an improvement? That's what these
> discussions really look to me.)
>
> I agree on using MEGA for 1000000 and even 10 * KILO. This makes sense as
> when the amount of zeroes increases, counting them becomes harder -
> especially with old eyes like mine. But using (MICRO / MILLI) instead of
> 1000, that's, in my opinion, just plain stupid. Intentional obfuscation of a
> perfectly clear thing.
>
> I am ready to discuss these points when I submit new features, and I've done
> this quite a lot in the past with Andy ;) But with a fix for a pretty severe
> bug potentially causing unexpected voltages being driven out of a device -
> which may cause a havoc to hardware. I'd rather get this fixed ASAP. Maybe
> you can send an improvement patch with suggested styling "fixes" if you feel
> really strongly about them, and we can continue discussion there? I am sure
> Andy will also join us ;)

Yep, with my full disagreement with you :-)

--
With Best Regards,
Andy Shevchenko