From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 1/4] hwmon: (tmp401) Simplify temperature register arrays
Date: Tue, 9 Nov 2021 15:48:11 -0800 [thread overview]
Message-ID: <20211109234814.3724798-2-linux@roeck-us.net> (raw)
In-Reply-To: <20211109234814.3724798-1-linux@roeck-us.net>
The difference between TMP431 and other chips of this series is that the
TMP431 has an additional sensor. The register addresses for other sensors
are the same for all chips. It is therefore unnecessary to maintain two
different arrays for TMP431 and the other chips. Just use the same array
for all chips and add the TMP431 register addresses as third column.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/tmp401.c | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index b31f4964f852..29c857a76c9e 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -49,36 +49,22 @@ enum chips { tmp401, tmp411, tmp431, tmp432, tmp435 };
#define TMP401_MANUFACTURER_ID_REG 0xFE
#define TMP401_DEVICE_ID_REG 0xFF
-static const u8 TMP401_TEMP_MSB_READ[7][2] = {
- { 0x00, 0x01 }, /* temp */
- { 0x06, 0x08 }, /* low limit */
- { 0x05, 0x07 }, /* high limit */
- { 0x20, 0x19 }, /* therm (crit) limit */
- { 0x30, 0x34 }, /* lowest */
- { 0x32, 0x36 }, /* highest */
-};
-
-static const u8 TMP401_TEMP_MSB_WRITE[7][2] = {
- { 0, 0 }, /* temp (unused) */
- { 0x0C, 0x0E }, /* low limit */
- { 0x0B, 0x0D }, /* high limit */
- { 0x20, 0x19 }, /* therm (crit) limit */
- { 0x30, 0x34 }, /* lowest */
- { 0x32, 0x36 }, /* highest */
-};
-
-static const u8 TMP432_TEMP_MSB_READ[4][3] = {
+static const u8 TMP401_TEMP_MSB_READ[7][3] = {
{ 0x00, 0x01, 0x23 }, /* temp */
{ 0x06, 0x08, 0x16 }, /* low limit */
{ 0x05, 0x07, 0x15 }, /* high limit */
- { 0x20, 0x19, 0x1A }, /* therm (crit) limit */
+ { 0x20, 0x19, 0x1a }, /* therm (crit) limit */
+ { 0x30, 0x34, 0x00 }, /* lowest */
+ { 0x32, 0x36, 0x00 }, /* highest */
};
-static const u8 TMP432_TEMP_MSB_WRITE[4][3] = {
- { 0, 0, 0 }, /* temp - unused */
+static const u8 TMP401_TEMP_MSB_WRITE[7][3] = {
+ { 0x00, 0x00, 0x00 }, /* temp (unused) */
{ 0x0C, 0x0E, 0x16 }, /* low limit */
{ 0x0B, 0x0D, 0x15 }, /* high limit */
- { 0x20, 0x19, 0x1A }, /* therm (crit) limit */
+ { 0x20, 0x19, 0x1a }, /* therm (crit) limit */
+ { 0x30, 0x34, 0x00 }, /* lowest */
+ { 0x32, 0x36, 0x00 }, /* highest */
};
/* [0] = fault, [1] = low, [2] = high, [3] = therm/crit */
@@ -182,9 +168,7 @@ static int tmp401_update_device_reg16(struct i2c_client *client,
for (j = 0; j < num_regs; j++) { /* temp / low / ... */
u8 regaddr;
- regaddr = data->kind == tmp432 ?
- TMP432_TEMP_MSB_READ[j][i] :
- TMP401_TEMP_MSB_READ[j][i];
+ regaddr = TMP401_TEMP_MSB_READ[j][i];
if (j == 3) { /* crit is msb only */
val = i2c_smbus_read_byte_data(client, regaddr);
} else {
@@ -336,8 +320,7 @@ static ssize_t temp_store(struct device *dev,
mutex_lock(&data->update_lock);
- regaddr = data->kind == tmp432 ? TMP432_TEMP_MSB_WRITE[nr][index]
- : TMP401_TEMP_MSB_WRITE[nr][index];
+ regaddr = TMP401_TEMP_MSB_WRITE[nr][index];
if (nr == 3) { /* crit is msb only */
i2c_smbus_write_byte_data(client, regaddr, reg >> 8);
} else {
--
2.33.0
next prev parent reply other threads:[~2021-11-09 23:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 23:48 [PATCH 0/4] hwmon: (tmp401) Various improvements Guenter Roeck
2021-11-09 23:48 ` Guenter Roeck [this message]
2021-11-09 23:48 ` [PATCH 2/4] hwmon: (tmp401) Convert to _info API Guenter Roeck
2021-11-09 23:48 ` [PATCH 3/4] hwmon: (tmp401) Use regmap Guenter Roeck
2021-11-09 23:48 ` [PATCH 4/4] hwmon: (tmp401) Hide register write address differences in regmap code Guenter Roeck
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=20211109234814.3724798-2-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@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