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] [day] [month] [year] [list]
Message-ID: <CAMRc=Mf3-yY+Vg7WwfbcWfA=y0avJ=Q8joWUfXcdYm+a6KSZsQ@mail.gmail.com>
Date: Thu, 2 Jan 2025 14:09:16 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Shree Ramamoorthy <s-ramamoorthy@...com>
Cc: aaro.koskinen@....fi, andreas@...nade.info, khilman@...libre.com, 
	rogerq@...nel.org, tony@...mide.com, linus.walleij@...aro.org, 
	linux-omap@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-gpio@...r.kernel.org, m-leonard@...com, praneeth@...com
Subject: Re: [PATCH v1 3/3] gpio tps65215: Add support for varying gpio/offset values

On Thu, Dec 26, 2024 at 10:59 PM Shree Ramamoorthy <s-ramamoorthy@...com> wrote:
>
> Add device-specific structs to select the different PMIC .npgio and .offset
> values. With the chip_data struct values selected based on the match data,
> having a separate GPIO0_OFFSET macro is no longer needed.
>
> Signed-off-by: Shree Ramamoorthy <s-ramamoorthy@...com>
> ---
>  drivers/gpio/gpio-tps65219.c | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
> index 7adc1274d80e..18055c2dd35c 100644
> --- a/drivers/gpio/gpio-tps65219.c
> +++ b/drivers/gpio/gpio-tps65219.c
> @@ -13,7 +13,6 @@
>  #include <linux/regmap.h>
>
>  #define TPS65219_GPIO0_DIR_MASK                BIT(3)
> -#define TPS65219_GPIO0_OFFSET          2
>  #define TPS6521X_GPIO0_IDX                     0
>
>  struct tps65219_gpio {
> @@ -21,6 +20,11 @@ struct tps65219_gpio {
>         struct tps65219 *tps;
>  };
>
> +struct chip_data {

Please use the driver prefix here.

Bart

> +       int ngpio;
> +       int offset;
> +};
> +
>  static int tps65219_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  {
>         struct tps65219_gpio *gpio = gpiochip_get_data(gc);
> @@ -71,7 +75,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int val
>         struct device *dev = gpio->tps->dev;
>         int v, mask, bit;
>
> -       bit = (offset == TPS6521X_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offset - 1;
> +       bit = (offset == TPS6521X_GPIO0_IDX) ? (gpio->gpio_chip.ngpio - 1) : offset - 1;
>
>         mask = BIT(bit);
>         v = value ? mask : 0;
> @@ -148,14 +152,29 @@ static const struct gpio_chip tps65219_template_chip = {
>         .get                    = tps65219_gpio_get,
>         .set                    = tps65219_gpio_set,
>         .base                   = -1,
> -       .ngpio                  = 3,
>         .can_sleep              = true,
>  };
>
> +static const struct chip_data chip_info_table[] = {
> +       [TPS65219] = {
> +               .ngpio = 3,
> +               .offset = 2,
> +       },
> +       [TPS65215] = {
> +               .ngpio = 2,
> +               .offset = 1,
> +       },
> +};
> +
>  static int tps65219_gpio_probe(struct platform_device *pdev)
>  {
>         struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent);
>         struct tps65219_gpio *gpio;
> +       const struct chip_data *pmic;
> +
> +       enum pmic_id chip = platform_get_device_id(pdev)->driver_data;
> +
> +       pmic = &chip_info_table[chip];
>
>         gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
>         if (!gpio)
> @@ -164,6 +183,8 @@ static int tps65219_gpio_probe(struct platform_device *pdev)
>         gpio->tps = tps;
>         gpio->gpio_chip = tps65219_template_chip;
>         gpio->gpio_chip.label = dev_name(&pdev->dev);
> +       gpio->gpio_chip.ngpio =  pmic->ngpio;
> +       gpio->gpio_chip.offset = pmic->offset;
>         gpio->gpio_chip.parent = tps->dev;
>
>         return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio);
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ