From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 6/6] hwmon: (amc6821) Use multi-byte regmap operations
Date: Tue, 16 Jul 2024 16:00:50 -0700 [thread overview]
Message-ID: <20240716230050.2049534-7-linux@roeck-us.net> (raw)
In-Reply-To: <20240716230050.2049534-1-linux@roeck-us.net>
Use multi-byte regmap operations where possible to reduce code size.
No functional changes.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/amc6821.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index ec94392fcb65..ac64b407ed0e 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -136,29 +136,25 @@ struct amc6821_data {
*/
static int amc6821_get_auto_point_temps(struct regmap *regmap, int channel, u8 *temps)
{
- u32 pwm, regval;
+ u32 regs[] = {
+ AMC6821_REG_DCY_LOW_TEMP,
+ AMC6821_REG_PSV_TEMP,
+ channel ? AMC6821_REG_RTEMP_FAN_CTRL : AMC6821_REG_LTEMP_FAN_CTRL
+ };
+ u8 regvals[3];
+ int slope;
int err;
- err = regmap_read(regmap, AMC6821_REG_DCY_LOW_TEMP, &pwm);
+ err = regmap_multi_reg_read(regmap, regs, regvals, 3);
if (err)
return err;
-
- err = regmap_read(regmap, AMC6821_REG_PSV_TEMP, ®val);
- if (err)
- return err;
- temps[0] = regval;
-
- err = regmap_read(regmap,
- channel ? AMC6821_REG_RTEMP_FAN_CTRL : AMC6821_REG_LTEMP_FAN_CTRL,
- ®val);
- if (err)
- return err;
- temps[1] = FIELD_GET(AMC6821_TEMP_LIMIT_MASK, regval) * 4;
+ temps[0] = regvals[1];
+ temps[1] = FIELD_GET(AMC6821_TEMP_LIMIT_MASK, regvals[2]) * 4;
/* slope is 32 >> <slope bits> in °C */
- regval = 32 >> FIELD_GET(AMC6821_TEMP_SLOPE_MASK, regval);
- if (regval)
- temps[2] = temps[1] + DIV_ROUND_CLOSEST(255 - pwm, regval);
+ slope = 32 >> FIELD_GET(AMC6821_TEMP_SLOPE_MASK, regvals[2]);
+ if (slope)
+ temps[2] = temps[1] + DIV_ROUND_CLOSEST(255 - regvals[0], slope);
else
temps[2] = 255;
--
2.39.2
next prev parent reply other threads:[~2024-07-16 23:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 23:00 [PATCH 0/6] hwmon: Use multi-byte regmap operations Guenter Roeck
2024-07-16 23:00 ` [PATCH 1/6] hwmon: (lm95245) " Guenter Roeck
2024-07-17 13:33 ` Tzung-Bi Shih
2024-07-16 23:00 ` [PATCH 2/6] hwmon: (nct7802) " Guenter Roeck
2024-07-17 13:35 ` Tzung-Bi Shih
2024-07-16 23:00 ` [PATCH 3/6] hwmon: (adt7x10) " Guenter Roeck
2024-07-17 13:35 ` Tzung-Bi Shih
2024-07-16 23:00 ` [PATCH 4/6] hwmon: (tmp464) " Guenter Roeck
2024-07-17 13:35 ` Tzung-Bi Shih
2024-07-17 14:37 ` Guenter Roeck
2024-07-18 1:29 ` Tzung-Bi Shih
2024-07-16 23:00 ` [PATCH 5/6] hwmon: (max6639) " Guenter Roeck
2024-07-17 13:36 ` Tzung-Bi Shih
2024-07-17 17:14 ` Guenter Roeck
2024-07-18 1:28 ` Tzung-Bi Shih
2024-07-18 2:27 ` Guenter Roeck
2024-07-16 23:00 ` Guenter Roeck [this message]
2024-07-17 13:36 ` [PATCH 6/6] hwmon: (amc6821) " Tzung-Bi Shih
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=20240716230050.2049534-7-linux@roeck-us.net \
--to=linux@roeck-us.net \
--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