Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mfd: axp20x: Ensure relationship between IDs and model names

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>

authored by

Andre Przywara and committed by
Lee Jones
697a4001 bd91530a

+17 -17
+15 -15
drivers/mfd/axp20x.c
··· 34 34 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) 35 35 36 36 static const char * const axp20x_model_names[] = { 37 - "AXP152", 38 - "AXP192", 39 - "AXP202", 40 - "AXP209", 41 - "AXP221", 42 - "AXP223", 43 - "AXP288", 44 - "AXP313a", 45 - "AXP717", 46 - "AXP803", 47 - "AXP806", 48 - "AXP809", 49 - "AXP813", 50 - "AXP15060", 37 + [AXP152_ID] = "AXP152", 38 + [AXP192_ID] = "AXP192", 39 + [AXP202_ID] = "AXP202", 40 + [AXP209_ID] = "AXP209", 41 + [AXP221_ID] = "AXP221", 42 + [AXP223_ID] = "AXP223", 43 + [AXP288_ID] = "AXP288", 44 + [AXP313A_ID] = "AXP313a", 45 + [AXP717_ID] = "AXP717", 46 + [AXP803_ID] = "AXP803", 47 + [AXP806_ID] = "AXP806", 48 + [AXP809_ID] = "AXP809", 49 + [AXP813_ID] = "AXP813", 50 + [AXP15060_ID] = "AXP15060", 51 51 }; 52 52 53 53 static const struct regmap_range axp152_writeable_ranges[] = { ··· 1345 1345 axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip; 1346 1346 break; 1347 1347 default: 1348 - dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); 1348 + dev_err(dev, "unsupported AXP20X ID %u\n", axp20x->variant); 1349 1349 return -EINVAL; 1350 1350 } 1351 1351
+1 -1
drivers/regulator/axp20x-regulator.c
··· 1597 1597 nregulators = AXP15060_REG_ID_MAX; 1598 1598 break; 1599 1599 default: 1600 - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", 1600 + dev_err(&pdev->dev, "Unsupported AXP variant: %d\n", 1601 1601 axp20x->variant); 1602 1602 return -EINVAL; 1603 1603 }
+1 -1
include/linux/mfd/axp20x.h
··· 959 959 unsigned long irq_flags; 960 960 struct regmap *regmap; 961 961 struct regmap_irq_chip_data *regmap_irqc; 962 - long variant; 962 + enum axp20x_variants variant; 963 963 int nr_cells; 964 964 const struct mfd_cell *cells; 965 965 const struct regmap_config *regmap_cfg;