[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vd924pNBKkoWNse5Bjazrp9+HuqBJ5nj2tdk6vngaOiJg@mail.gmail.com>
Date: Fri, 8 Nov 2024 11:23:18 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: victor.duicu@...rochip.com
Cc: matteomartelli3@...il.com, jic23@...nel.org, lars@...afoo.de,
marius.cristea@...rochip.com, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8] iio: adc: pac1921: Add ACPI support to Microchip pac1921
On Fri, Nov 8, 2024 at 10:52 AM <victor.duicu@...rochip.com> wrote:
>
> From: Victor Duicu <victor.duicu@...rochip.com>
>
> This patch implements ACPI support to Microchip pac1921.
> The driver can read shunt resistor value and label from ACPI table.
read the shunt
from the ACPI
...
> #include <linux/iio/triggered_buffer.h>
> #include <linux/regmap.h>
> #include <linux/units.h>
> +#include <linux/limits.h>
Please, keep them sorted.
...
> +#define PAC1921_DSM_UUID "f7bb9932-86ee-4516-a236-7a7a742e55cb"
Besides the need to include uuid.h and call guid_parse(), just put
this to the comment and use
GUID_INIT() instead. It will save a few CPU cycles each time we want
to read that information from the ACPI.
...
> +static inline bool pac1921_shunt_is_valid(u32 shunt_val)
> +{
> + return shunt_val > 0 && shunt_val <= INT_MAX;
> +}
This basically is the (shunt_val - 1) & BIT(31) which can be used
inline in the caller. Hence, drop this function and use the check
inline. See also below.
...
> + /* This check is to ensure rshunt_uohm is non-zero positive */
Please, describe better the range of the values, because currently
it's quite confusing, taking into account the unsigned type of the
variable.
> + if (!pac1921_shunt_is_valid(rshunt_uohm))
> return -EINVAL;
...
> + guid_parse(PAC1921_DSM_UUID, &guid);
No need after use of GUID_INIT().
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists