Re: [PATCH v1 1/9] power: supply: max17042_battery: Put LSB units into defines
From: Dan Carpenter
Date: Sat Jun 06 2026 - 12:13:48 EST
On Mon, Apr 06, 2026 at 04:57:49PM -0400, Vincent Cloutier wrote:
> From: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@xxxxxxx>
>
> Signed-off-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@xxxxxxx>
> ---
> drivers/power/supply/max17042_battery.c | 36 ++++++++++++++-----------
> 1 file changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index acea176101fa..a6798b9a1c82 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -52,6 +52,13 @@
>
> #define MAX17042_VMAX_TOLERANCE 50 /* 50 mV */
>
> +#define MAX17042_CURRENT_LSB 1562500ll /* 1.5625µV/Rsense */
> +#define MAX17042_CAPACITY_LSB 5000000ll /* 5.0µVH/Rsense */
> +#define MAX17042_TIME_LSB 5625 / 1000 /* s */
> +#define MAX17042_VOLTAGE_LSB 625 / 8 /* µV */
> +#define MAX17042_RESISTANCE_LSB 1 / 4096 /* Ω */
> +#define MAX17042_TEMPERATURE_LSB 1 / 256 /* °C */
Checkpatch complains about this:
ERROR: Macros with complex values should be enclosed in parentheses
But the macros rely on the fact that the parentheses are missing. You're
going to get one patch per year until the end of time which tries to add
the parentheses and eventually you will come to hate this bit of
cleverness.
regards,
dan carpenter