All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Subject: [PATCH v2 08/10] hwmon: (max6650) Read non-volatile registers only once
Date: Fri,  7 Jun 2019 10:23:23 -0700	[thread overview]
Message-ID: <1559928205-14030-8-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1559928205-14030-1-git-send-email-linux@roeck-us.net>

Only tachometer and alarm status registers are modified by the chip.
All other registers only need to be read only once, and reading them
repeatedly does not add any value.

Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: No change

 drivers/hwmon/max6650.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index bcd50307d963..6f1a1a6eae46 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -162,17 +162,10 @@ static struct max6650_data *max6650_update_device(struct device *dev)
 	mutex_lock(&data->update_lock);
 
 	if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
-		data->speed = i2c_smbus_read_byte_data(client,
-						       MAX6650_REG_SPEED);
-		data->config = i2c_smbus_read_byte_data(client,
-							MAX6650_REG_CONFIG);
 		for (i = 0; i < data->nr_fans; i++) {
 			data->tach[i] = i2c_smbus_read_byte_data(client,
 								 tach_reg[i]);
 		}
-		data->count = i2c_smbus_read_byte_data(client,
-							MAX6650_REG_COUNT);
-		data->dac = i2c_smbus_read_byte_data(client, MAX6650_REG_DAC);
 
 		/*
 		 * Alarms are cleared on read in case the condition that
@@ -421,8 +414,22 @@ static int max6650_init_client(struct max6650_data *data,
 		dev_err(dev, "Config write error, aborting.\n");
 		return err;
 	}
-
 	data->config = reg;
+
+	reg = i2c_smbus_read_byte_data(client, MAX6650_REG_SPEED);
+	if (reg < 0) {
+		dev_err(dev, "Failed to read speed register, aborting.\n");
+		return reg;
+	}
+	data->speed = reg;
+
+	reg = i2c_smbus_read_byte_data(client, MAX6650_REG_DAC);
+	if (reg < 0) {
+		dev_err(dev, "Failed to read DAC register, aborting.\n");
+		return reg;
+	}
+	data->dac = reg;
+
 	reg = i2c_smbus_read_byte_data(client, MAX6650_REG_COUNT);
 	if (reg < 0) {
 		dev_err(dev, "Failed to read count register, aborting.\n");
-- 
2.7.4


  parent reply	other threads:[~2019-06-07 17:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 17:23 [PATCH v2 01/10] hwmon: (max6650) Use devm function to register thermal device Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 02/10] hwmon: (max6650) Introduce pwm_to_dac and dac_to_pwm Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 03/10] hwmon: (max6650) Improve error handling in max6650_init_client Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 04/10] hwmon: (max6650) Declare valid as boolean Guenter Roeck
2019-06-10 11:33   ` Jean-Francois Dagenais
2019-06-10 12:47     ` Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 05/10] hwmon: (max6650) Cache alarm_en register Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 06/10] hwmon: (max6650) Simplify alarm handling Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 07/10] hwmon: (max6650) Convert to use devm_hwmon_device_register_with_info Guenter Roeck
2019-06-07 17:23 ` Guenter Roeck [this message]
2019-06-07 17:23 ` [PATCH v2 09/10] hwmon: (max6650) Improve error handling in max6650_update_device Guenter Roeck
2019-06-07 17:23 ` [PATCH v2 10/10] hwmon: (max6650) Fix minor formatting issues 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=1559928205-14030-8-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=jeff.dagenais@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.