Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 10/11] hwmon: (ina2xx) Move ina2xx_get_value()
Date: Tue, 27 Aug 2024 08:34:54 -0700	[thread overview]
Message-ID: <20240827153455.1344529-11-linux@roeck-us.net> (raw)
In-Reply-To: <20240827153455.1344529-1-linux@roeck-us.net>

ina2xx_get_value() will be needed earlier in the next patch, so move it.
No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/ina2xx.c | 72 +++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index d1bd998645b6..14136c96533f 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -209,6 +209,42 @@ static u16 ina226_interval_to_reg(unsigned long interval)
 	return FIELD_PREP(INA226_AVG_RD_MASK, avg_bits);
 }
 
+static int ina2xx_get_value(struct ina2xx_data *data, u8 reg,
+			    unsigned int regval)
+{
+	int val;
+
+	switch (reg) {
+	case INA2XX_SHUNT_VOLTAGE:
+		/* signed register */
+		val = DIV_ROUND_CLOSEST((s16)regval, data->config->shunt_div);
+		break;
+	case INA2XX_BUS_VOLTAGE:
+		val = (regval >> data->config->bus_voltage_shift) *
+		  data->config->bus_voltage_lsb;
+		val = DIV_ROUND_CLOSEST(val, 1000);
+		break;
+	case INA2XX_POWER:
+		val = regval * data->power_lsb_uW;
+		break;
+	case INA2XX_CURRENT:
+		/* signed register, result in mA */
+		val = (s16)regval * data->current_lsb_uA;
+		val = DIV_ROUND_CLOSEST(val, 1000);
+		break;
+	case INA2XX_CALIBRATION:
+		val = regval;
+		break;
+	default:
+		/* programmer goofed */
+		WARN_ON_ONCE(1);
+		val = 0;
+		break;
+	}
+
+	return val;
+}
+
 static int ina2xx_read_reg(struct device *dev, int reg, unsigned int *regval)
 {
 	struct ina2xx_data *data = dev_get_drvdata(dev);
@@ -262,42 +298,6 @@ static int ina2xx_read_reg(struct device *dev, int reg, unsigned int *regval)
 	return -ENODEV;
 }
 
-static int ina2xx_get_value(struct ina2xx_data *data, u8 reg,
-			    unsigned int regval)
-{
-	int val;
-
-	switch (reg) {
-	case INA2XX_SHUNT_VOLTAGE:
-		/* signed register */
-		val = DIV_ROUND_CLOSEST((s16)regval, data->config->shunt_div);
-		break;
-	case INA2XX_BUS_VOLTAGE:
-		val = (regval >> data->config->bus_voltage_shift) *
-		  data->config->bus_voltage_lsb;
-		val = DIV_ROUND_CLOSEST(val, 1000);
-		break;
-	case INA2XX_POWER:
-		val = regval * data->power_lsb_uW;
-		break;
-	case INA2XX_CURRENT:
-		/* signed register, result in mA */
-		val = (s16)regval * data->current_lsb_uA;
-		val = DIV_ROUND_CLOSEST(val, 1000);
-		break;
-	case INA2XX_CALIBRATION:
-		val = regval;
-		break;
-	default:
-		/* programmer goofed */
-		WARN_ON_ONCE(1);
-		val = 0;
-		break;
-	}
-
-	return val;
-}
-
 static ssize_t ina2xx_value_show(struct device *dev,
 				 struct device_attribute *da, char *buf)
 {
-- 
2.45.2


  parent reply	other threads:[~2024-08-27 15:35 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27 15:34 [PATCH 00/11] hwmon: (ina2xx) Cleanup and convert to use with_info API Guenter Roeck
2024-08-27 15:34 ` [PATCH 01/11] hwmon: (ina2xx) Reorder include files to alphabetic order Guenter Roeck
2024-08-29 14:53   ` Tzung-Bi Shih
2024-08-27 15:34 ` [PATCH 02/11] hwmon: (ina2xx) Replace platform data with device properties Guenter Roeck
2024-08-29 14:53   ` Tzung-Bi Shih
2024-08-27 15:34 ` [PATCH 03/11] hwmon: (ina2xx) Use bit operations Guenter Roeck
2024-08-29 14:53   ` Tzung-Bi Shih
2024-08-27 15:34 ` [PATCH 04/11] hwmon: (ina2xx) Mark regmap_config as const Guenter Roeck
2024-08-29 14:54   ` Tzung-Bi Shih
2024-08-29 16:44     ` Guenter Roeck
2024-08-27 15:34 ` [PATCH 05/11] hwmon: (ina2xx) Use local regmap pointer if used more than once Guenter Roeck
2024-08-29 14:54   ` Tzung-Bi Shih
2024-08-27 15:34 ` [PATCH 06/11] hwmon: (ina2xx) Re-initialize chip using regmap functions Guenter Roeck
2024-08-29 14:54   ` Tzung-Bi Shih
2024-08-29 16:45     ` Guenter Roeck
2024-08-27 15:34 ` [PATCH 07/11] hwmon: (ina2xx) Set alert latch when enabling alerts Guenter Roeck
2024-08-29 14:54   ` Tzung-Bi Shih
2024-08-29 17:28     ` Guenter Roeck
2024-08-27 15:34 ` [PATCH 08/11] hwmon: (ina2xx) Fix various overflow issues Guenter Roeck
2024-08-29 14:55   ` Tzung-Bi Shih
2024-08-29 16:56     ` Guenter Roeck
2024-08-27 15:34 ` [PATCH 09/11] hwmon: (ina2xx) Consolidate chip initialization code Guenter Roeck
2024-08-29 14:55   ` Tzung-Bi Shih
2024-08-29 16:57     ` Guenter Roeck
2024-08-27 15:34 ` Guenter Roeck [this message]
2024-08-29 14:55   ` [PATCH 10/11] hwmon: (ina2xx) Move ina2xx_get_value() Tzung-Bi Shih
2024-08-27 15:34 ` [PATCH 11/11] hwmon: (ina2xx) Convert to use with_info hwmon API Guenter Roeck
2024-08-29 14:55   ` Tzung-Bi Shih
2024-08-29 16:53     ` 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=20240827153455.1344529-11-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