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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGb2v65jcxCYC7mess=4H9dz0gXk434tTyP_ATDvbrpdj_=aOQ@mail.gmail.com>
Date: Thu, 3 Oct 2024 23:12:46 +0800
From: Chen-Yu Tsai <wens@...e.org>
To: Andre Przywara <andre.przywara@....com>
Cc: Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>, devicetree@...r.kernel.org, 
	linux-sunxi@...ts.linux.dev, linux-kernel@...r.kernel.org, 
	Martin Botka <martin.botka@...ainline.org>, Chris Morgan <macromorgan@...mail.com>
Subject: Re: [PATCH 2/5] mfd: axp20x: ensure relationship between IDs and
 model names

On Thu, Oct 3, 2024 at 7:15 PM Andre Przywara <andre.przywara@....com> wrote:
>
> At the moment there is an implicit relationship between the AXP model
> IDs and the order of the strings in the axp20x_model_names[] array.
> This is fragile, and makes adding IDs in the middle error prone.
>
> Make this relationship official by changing the ID type to the actual
> enum used, and using indexed initialisers for the string list.
>
> Signed-off-by: Andre Przywara <andre.przywara@....com>

Reviewed-by: Chen-Yu Tsai <wens@...e.org>

> ---
>  drivers/mfd/axp20x.c                 | 30 ++++++++++++++--------------
>  drivers/regulator/axp20x-regulator.c |  2 +-
>  include/linux/mfd/axp20x.h           |  2 +-
>  3 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
> index 4051551757f2..5ceea359289f 100644
> --- a/drivers/mfd/axp20x.c
> +++ b/drivers/mfd/axp20x.c
> @@ -34,20 +34,20 @@
>  #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE    BIT(4)
>
>  static const char * const axp20x_model_names[] = {
> -       "AXP152",
> -       "AXP192",
> -       "AXP202",
> -       "AXP209",
> -       "AXP221",
> -       "AXP223",
> -       "AXP288",
> -       "AXP313a",
> -       "AXP717",
> -       "AXP803",
> -       "AXP806",
> -       "AXP809",
> -       "AXP813",
> -       "AXP15060",
> +       [AXP152_ID] = "AXP152",
> +       [AXP192_ID] = "AXP192",
> +       [AXP202_ID] = "AXP202",
> +       [AXP209_ID] = "AXP209",
> +       [AXP221_ID] = "AXP221",
> +       [AXP223_ID] = "AXP223",
> +       [AXP288_ID] = "AXP288",
> +       [AXP313A_ID] = "AXP313a",
> +       [AXP717_ID] = "AXP717",
> +       [AXP803_ID] = "AXP803",
> +       [AXP806_ID] = "AXP806",
> +       [AXP809_ID] = "AXP809",
> +       [AXP813_ID] = "AXP813",
> +       [AXP15060_ID] = "AXP15060",
>  };
>
>  static const struct regmap_range axp152_writeable_ranges[] = {
> @@ -1345,7 +1345,7 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
>                 axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip;
>                 break;
>         default:
> -               dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant);
> +               dev_err(dev, "unsupported AXP20X ID %u\n", axp20x->variant);
>                 return -EINVAL;
>         }
>
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index a8e91d9d028b..3ba76dbd0fb9 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -1597,7 +1597,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
>                 nregulators = AXP15060_REG_ID_MAX;
>                 break;
>         default:
> -               dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
> +               dev_err(&pdev->dev, "Unsupported AXP variant: %d\n",
>                         axp20x->variant);
>                 return -EINVAL;
>         }
> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
> index f4dfc1871a95..79ecaaaa2070 100644
> --- a/include/linux/mfd/axp20x.h
> +++ b/include/linux/mfd/axp20x.h
> @@ -959,7 +959,7 @@ struct axp20x_dev {
>         unsigned long                   irq_flags;
>         struct regmap                   *regmap;
>         struct regmap_irq_chip_data     *regmap_irqc;
> -       long                            variant;
> +       enum axp20x_variants            variant;
>         int                             nr_cells;
>         const struct mfd_cell           *cells;
>         const struct regmap_config      *regmap_cfg;
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ