Re: [PATCH v8] iio: adc: pac1921: Add ACPI support to Microchip pac1921

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 8, 2024 at 10:52 AM <victor.duicu@xxxxxxxxxxxxx> wrote:
>
> From: Victor Duicu <victor.duicu@xxxxxxxxxxxxx>
>
> 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





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux