From: Andre Przywara <andre.przywara@arm.com>
To: Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev,
linux-kernel@vger.kernel.org,
Martin Botka <martin.botka@somainline.org>,
Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH v2 2/5] mfd: axp20x: ensure relationship between IDs and model names
Date: Mon, 7 Oct 2024 01:14:05 +0100 [thread overview]
Message-ID: <20241007001408.27249-3-andre.przywara@arm.com> (raw)
In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com>
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>
---
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 4051551757f2d..5ceea359289f4 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 a8e91d9d028b8..3ba76dbd0fb9e 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 f4dfc1871a95b..79ecaaaa20703 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.46.2
next prev parent reply other threads:[~2024-10-07 0:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 0:14 [PATCH v2 0/5] regulator: add X-Powers AXP323 support Andre Przywara
2024-10-07 0:14 ` [PATCH v2 1/5] dt-bindings: mfd: x-powers,axp152: Document AXP323 Andre Przywara
2024-10-07 0:14 ` Andre Przywara [this message]
2024-10-07 0:14 ` [PATCH v2 3/5] mfd: axp20x: Allow multiple regulators Andre Przywara
2024-12-07 17:45 ` Chris Morgan
2024-12-27 22:34 ` Vasily Khoruzhick
2025-01-06 19:50 ` Andrey Skvortsov
2024-10-07 0:14 ` [PATCH v2 4/5] mfd: axp20x: Add support for AXP323 Andre Przywara
2024-10-07 0:14 ` [PATCH v2 5/5] regulator: axp20x: add support for the AXP323 Andre Przywara
2024-10-15 10:23 ` Lee Jones
2024-10-18 19:18 ` Mark Brown
2024-10-31 15:51 ` [PATCH v2 0/5] regulator: add X-Powers AXP323 support Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241007001408.27249-3-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=macromorgan@hotmail.com \
--cc=martin.botka@somainline.org \
--cc=robh@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox