From: Peter Geis <pgwipeout@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Ezequiel Garcia <ezequiel@collabora.com>,
linux-kernel@vger.kernel.org, Peter Geis <pgwipeout@gmail.com>
Subject: [PATCH 2/3] regulator: fan53555: only bind tcs4525 to correct chip id
Date: Tue, 11 May 2021 17:13:34 -0400 [thread overview]
Message-ID: <20210511211335.2935163-3-pgwipeout@gmail.com> (raw)
In-Reply-To: <20210511211335.2935163-1-pgwipeout@gmail.com>
The tcs4525 regulator has a chip id of <12>.
Only allow the driver to bind to the correct chip id for safety, in
accordance with the other supported devices.
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
drivers/regulator/fan53555.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 26f06f685b1b..16f28f9df6a1 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -89,6 +89,10 @@ enum {
FAN53555_CHIP_ID_08 = 8,
};
+enum {
+ TCS4525_CHIP_ID_12 = 12,
+};
+
/* IC mask revision */
enum {
FAN53555_CHIP_REV_00 = 0x3,
@@ -368,14 +372,21 @@ static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di)
static int fan53555_voltages_setup_tcs(struct fan53555_device_info *di)
{
- di->slew_reg = TCS4525_TIME;
- di->slew_mask = TCS_SLEW_MASK;
- di->slew_shift = TCS_SLEW_MASK;
+ switch (di->chip_id) {
+ case TCS4525_CHIP_ID_12:
+ di->slew_reg = TCS4525_TIME;
+ di->slew_mask = TCS_SLEW_MASK;
+ di->slew_shift = TCS_SLEW_MASK;
- /* Init voltage range and step */
- di->vsel_min = 600000;
- di->vsel_step = 6250;
- di->vsel_count = FAN53526_NVOLTAGES;
+ /* Init voltage range and step */
+ di->vsel_min = 600000;
+ di->vsel_step = 6250;
+ di->vsel_count = FAN53526_NVOLTAGES;
+ break;
+ default:
+ dev_err(di->dev, "Chip ID %d not supported!\n", di->chip_id);
+ return -EINVAL;
+ }
return 0;
}
--
2.25.1
next prev parent reply other threads:[~2021-05-11 21:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 21:13 [PATCH 0/3] regulator: fan53555: tcs4525 fix and cleanup Peter Geis
2021-05-11 21:13 ` [PATCH 1/3] regulator: fan53555: fix TCS4525 voltage calulation Peter Geis
2021-05-11 21:13 ` Peter Geis [this message]
2021-05-11 21:13 ` [PATCH 3/3] regulator: fan53555: fix tcs4525 function names Peter Geis
2021-05-12 17:04 ` [PATCH 0/3] regulator: fan53555: tcs4525 fix and cleanup Mark Brown
2021-05-13 17:23 ` Ezequiel Garcia
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=20210511211335.2935163-3-pgwipeout@gmail.com \
--to=pgwipeout@gmail.com \
--cc=broonie@kernel.org \
--cc=ezequiel@collabora.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).