From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <lars@metafoo.de>,
<Michael.Hennerich@analog.com>, <dlechner@baylibre.com>,
<nuno.sa@analog.com>, <andy@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<jonath4nns@gmail.com>
Subject: Re: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros
Date: Sat, 27 Dec 2025 15:55:25 +0000 [thread overview]
Message-ID: <20251227155525.6d712f42@jic23-huawei> (raw)
In-Reply-To: <43504217d5b3c32da946bed0ce4d81e216f7c7c7.1765900411.git.Jonathan.Santos@analog.com>
On Wed, 17 Dec 2025 02:52:45 -0300
Jonathan Santos <Jonathan.Santos@analog.com> wrote:
> Add macros for percentage related units, with basis points defined as
> 1/100th of a percent. Basis points are commonly used in finance and
> engineering to express small percentage changes with precision.
>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
> ---
> v5 Changes:
> * Included PERCENT macro along with BASIS_POINTS.
> * Adjusted commit description and comment in the code to add more context and
> examples.
>
> v4 Changes:
> * New patch.
> ---
> include/linux/units.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/linux/units.h b/include/linux/units.h
> index 00e15de33eca..9c2fbcf04c81 100644
> --- a/include/linux/units.h
> +++ b/include/linux/units.h
> @@ -21,6 +21,20 @@
> #define PICO 1000000000000ULL
> #define FEMTO 1000000000000000ULL
>
> +/*
> + * Percentage and basis point units
> + *
> + * Basis points are 1/100th of a percent (1/100), commonly used in finance,
> + * engineering or other applications that require precise percentage
> + * calculations.
> + *
> + * Examples:
> + * 100% = 10000 basis points = BASIS_POINTS
> + * 1% = 100 basis points = PERCENT
I don't understand the final equality in these examples.
The top line is as it says 10000 basis points but you have it equal
to BASIS_POINTS?
> + */
> +#define PERCENT 100UL
> +#define BASIS_POINTS 10000UL
> +
> #define NANOHZ_PER_HZ 1000000000UL
> #define MICROHZ_PER_HZ 1000000UL
> #define MILLIHZ_PER_HZ 1000UL
next prev parent reply other threads:[~2025-12-27 15:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 5:52 [PATCH v5 0/5] Add support for ADAQ776x-1 ADC Family Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 1/5] dt-bindings: iio: adc: ad7768-1: add new supported parts Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 2/5] iio: adc: ad7768-1: introduce chip info for future multidevice support Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros Jonathan Santos
2025-12-27 15:55 ` Jonathan Cameron [this message]
2025-12-27 16:48 ` Andy Shevchenko
2025-12-27 16:52 ` Andy Shevchenko
2025-12-27 16:53 ` Andy Shevchenko
2026-01-11 2:11 ` Jonathan Santos
2026-01-13 6:49 ` Andy Shevchenko
2025-12-17 5:52 ` [PATCH v5 4/5] iio: adc: ad7768-1: refactor ad7768_write_raw() Jonathan Santos
2025-12-17 5:53 ` [PATCH v5 5/5] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family Jonathan Santos
2025-12-27 16:11 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251227155525.6d712f42@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Santos@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jonath4nns@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox