lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFRkauDdx00VmqhmzohdCyWbPkctCU2D03JqkpSw2x7n-bDzHA@mail.gmail.com>
Date:   Sat, 23 Feb 2019 20:54:54 +0800
From:   Axel Lin <axel.lin@...ics.com>
To:     Olliver Schinagl <oliver@...inagl.nl>
Cc:     Mark Brown <broonie@...nel.org>, Chen-Yu Tsai <wens@...e.org>,
        Priit Laes <plaes@...es.org>,
        Liam Girdwood <lgirdwood@...il.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] regulator: axp20x: Get rid of AXP20X_xxx_START/END/STEPS defines

> I will not disagree that it may be extra work to look up the define
> (especially if there is no tool tip or split view in the editor) but
> reading the whole lot of code, with only the magic values, you still
> have to look up the meaning of each magic value, have to guess which one
> has the same meaning etc.
>
> Further more, I do believe far more people reading will find an define
> to be more descriptive to read. Whoever needs to actually go in and
> fix/change things.

I disagree.
The reason I sent this patch is because these defines reduce readability.
I do care about readability, but in this case these defines make
readability worsen.

At the context of REGULATOR_LINEAR_RANGE, each fields has well known meaning.
When I look at the table with values (I don't care if it's hex or decimal),
it tells everything I need to know.
I can easily check if any linear ranger cover other ranges.
I can easily check if any gap between linar ranges, (probably due to
reserved bits).
I can easily count the number of entries in each range.
I can easily calculate the min/max voltage of each range and double
check with datasheet.
i.e. If there are something wrong, it's eash to detect it.

When you change the values to DEFINES, I have to check the value of
each define *one-by-one*.
There is no benefit in this case.

I don't mean adding DEFINES is wrong. Just in this case it does not
help and actually has downside.
I only remove AXP20X_xxx_START/END/STEPS defines, not all defines.

BTW, just show you an example (from drivers/regulator/88pm8607.c)
I don't think change all below values to DEFINES help in readability.
static const unsigned int BUCK1_table[] = {
         725000,  750000,  775000,  800000,  825000,  850000,  875000,  900000,
         925000,  950000,  975000, 1000000, 1025000, 1050000, 1075000, 1100000,
        1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
        1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,
              0,   25000,   50000,   75000,  100000,  125000,  150000,  175000,
         200000,  225000,  250000,  275000,  300000,  325000,  350000,  375000,
         400000,  425000,  450000,  475000,  500000,  525000,  550000,  575000,
         600000,  625000,  650000,  675000,  700000,  725000,  750000,  775000,
};


Regards,
Axel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ