[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vdfc=V8uBBF4m3pDtpjsrhqq06q=5fEBPCOiUmYQdSkGA@mail.gmail.com>
Date: Sun, 19 Jun 2022 12:51:26 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Aidan MacDonald <aidanmacdonald.0x0@...il.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Chen-Yu Tsai <wens@...e.org>,
Jonathan Cameron <jic23@...nel.org>,
Lee Jones <lee.jones@...aro.org>,
Sebastian Reichel <sre@...nel.org>,
Mark Brown <broonie@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Liam Girdwood <lgirdwood@...il.com>,
Lars-Peter Clausen <lars@...afoo.de>,
"Rafael J. Wysocki" <rafael@...nel.org>, quic_gurus@...cinc.com,
Sebastian Reichel <sebastian.reichel@...labora.com>,
Michael Walle <michael@...le.cc>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
devicetree <devicetree@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
Linux PM <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v3 10/16] iio: adc: axp20x_adc: Minor code cleanups
On Sat, Jun 18, 2022 at 11:40 PM Aidan MacDonald
<aidanmacdonald.0x0@...il.com> wrote:
>
> The code may be clearer if parameters are not re-purposed to hold
> temporary results like register values, so introduce local variables
> as necessary to avoid that. Also, use the common FIELD_PREP macro
FIELD_PREP()
> instead of a hand-rolled version.
...
> #include <linux/property.h>
> #include <linux/regmap.h>
> #include <linux/thermal.h>
> +#include <linux/bitfield.h>
Keep it sorted?
...
> - val = val ? 1 : 0;
> + regval = val ? 1 : 0;
>
I think you may drop these two lines (including blank line) and...
> switch (chan->channel) {
> case AXP20X_GPIO0_V:
> - reg = AXP20X_GPIO10_IN_RANGE_GPIO0;
> - regval = AXP20X_GPIO10_IN_RANGE_GPIO0_VAL(val);
> + regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
> + regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, regval);
...use !!val as an argument here...
> break;
>
> case AXP20X_GPIO1_V:
> - reg = AXP20X_GPIO10_IN_RANGE_GPIO1;
> - regval = AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(val);
> + regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
> + regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, regval);
...and here.
> break;
>
> default:
> return -EINVAL;
> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists