lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MfpwuMh-MH1UEHKky09iAs4g9=iGFPptARXzoZrVS8hdQ@mail.gmail.com>
Date: Wed, 11 Dec 2024 14:51:32 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Song Chen <chensong_2000@....cn>
Cc: krzk@...nel.org, lgirdwood@...il.com, broonie@...nel.org, lee@...nel.org, 
	linus.walleij@...aro.org, linux-kernel@...r.kernel.org, 
	linux-gpio@...r.kernel.org, linux-samsung-soc@...r.kernel.org
Subject: Re: [PATCH v2] regulator:s5m8767: Fully convert to GPIO descriptors

On Wed, Dec 11, 2024 at 6:10 AM Song Chen <chensong_2000@....cn> wrote:
>
> This converts s5m8767 regulator driver to use GPIO descriptors.
>
> ---
> v1 - v2:
> 1, reedit commit message.
> 2, remove development code.
> 3, print error msg in dev_err_probe.
> 4, doesn't set gpiod directions until successfully requesting
>    all gpiods. It's pretty much equivalent with original code.
>
> Signed-off-by: Song Chen <chensong_2000@....cn>
> ---
>  drivers/regulator/s5m8767.c      | 106 ++++++++++++++-----------------
>  include/linux/mfd/samsung/core.h |   4 +-
>  2 files changed, 48 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
> index d25cd81e3f36..b23df037336b 100644
> --- a/drivers/regulator/s5m8767.c
> +++ b/drivers/regulator/s5m8767.c
> @@ -5,7 +5,7 @@
>
>  #include <linux/cleanup.h>
>  #include <linux/err.h>
> -#include <linux/of_gpio.h>
> +#include <linux/of.h>
>  #include <linux/gpio/consumer.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> @@ -35,8 +35,8 @@ struct s5m8767_info {
>         u8 buck2_vol[8];
>         u8 buck3_vol[8];
>         u8 buck4_vol[8];
> -       int buck_gpios[3];
> -       int buck_ds[3];
> +       struct gpio_desc *buck_gpios[3];
> +       struct gpio_desc *buck_ds[3];
>         int buck_gpioindex;
>  };
>
> @@ -272,9 +272,9 @@ static inline int s5m8767_set_high(struct s5m8767_info *s5m8767)
>  {
>         int temp_index = s5m8767->buck_gpioindex;
>
> -       gpio_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1);
> -       gpio_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1);
> -       gpio_set_value(s5m8767->buck_gpios[2], temp_index & 0x1);
> +       gpiod_set_value(s5m8767->buck_gpios[0], (temp_index >> 2) & 0x1);
> +       gpiod_set_value(s5m8767->buck_gpios[1], (temp_index >> 1) & 0x1);
> +       gpiod_set_value(s5m8767->buck_gpios[2], temp_index & 0x1);
>

It seems to me that these GPIOs are always manipulated at once. Maybe
consider adding fwnode_gpiod_get_index_array() to GPIO core and using
it here to shrink the code a bit more?

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ