]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: axp20x: Ensure relationship between IDs and model names
authorAndre Przywara <andre.przywara@arm.com>
Mon, 7 Oct 2024 00:14:05 +0000 (01:14 +0100)
committerLee Jones <lee@kernel.org>
Thu, 31 Oct 2024 15:51:20 +0000 (15:51 +0000)
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@arm.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20241007001408.27249-3-andre.przywara@arm.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/axp20x.c
drivers/regulator/axp20x-regulator.c
include/linux/mfd/axp20x.h

index 4051551757f2dca0f72525e0e12758c5ec01c093..5ceea359289f42fab0ebe6e22a8f4998cc32ae1e 100644 (file)
 #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;
        }
 
index a8e91d9d028b894edd8462faed0f1be20cf3f536..3ba76dbd0fb9ed4372b6fcce61d8f2b7778b2936 100644 (file)
@@ -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;
        }
index f4dfc1871a95ba3ffc10028ab27e7af16e172fd1..79ecaaaa20703e265359739157f59f9cd5d9901d 100644 (file)
@@ -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;