Commit be762d8b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hwmon-for-v7.0-rc6' of...

Merge tag 'hwmon-for-v7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

 - PMBus driver fixes:
     - Add mutex protection for regulator operations
     - Fix reading from "write-only" attributes
     - Mark lowest/average/highest/rated attributes as read-only
     - isl68137: Add mutex protection for AVS enable sysfs attributes
     - ina233:  Fix error handling and sign extension when reading shunt voltage

 - adm1177: Fix sysfs ABI violation and current unit conversion

 - peci: Fix off-by-one in cputemp_is_visible(), and crit_hyst returning
   delta instead of absolute temperature

* tag 'hwmon-for-v7.0-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (pmbus/core) Protect regulator operations with mutex
  hwmon: (pmbus) Introduce the concept of "write-only" attributes
  hwmon: (pmbus) Mark lowest/average/highest/rated attributes as read-only
  hwmon: (adm1177) fix sysfs ABI violation and current unit conversion
  hwmon: (peci/cputemp) Fix off-by-one in cputemp_is_visible()
  hwmon: (peci/cputemp) Fix crit_hyst returning delta instead of absolute temperature
  hwmon: (pmbus/isl68137) Add mutex protection for AVS enable sysfs attributes
  hwmon: (pmbus/ina233) Fix error handling and sign extension in shunt voltage read
parents afb54c14 754bd2b4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -27,10 +27,10 @@ for details.
Sysfs entries
-------------

The following attributes are supported. Current maxim attribute
The following attributes are supported. Current maximum attribute
is read-write, all other attributes are read-only.

in0_input		Measured voltage in microvolts.
in0_input		Measured voltage in millivolts.

curr1_input		Measured current in microamperes.
curr1_max_alarm		Overcurrent alarm in microamperes.
curr1_input		Measured current in milliamperes.
curr1_max		Overcurrent shutdown threshold in milliamperes.
+6 −4
Original line number Diff line number Diff line
@@ -51,8 +51,9 @@ temp1_max Provides thermal control temperature of the CPU package
temp1_crit		Provides shutdown temperature of the CPU package which
			is also known as the maximum processor junction
			temperature, Tjmax or Tprochot.
temp1_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
			the CPU package.
temp1_crit_hyst		Provides the hysteresis temperature of the CPU
			package. Returns Tcontrol, the temperature at which
			the critical condition clears.

temp2_label		"DTS"
temp2_input		Provides current temperature of the CPU package scaled
@@ -62,8 +63,9 @@ temp2_max Provides thermal control temperature of the CPU package
temp2_crit		Provides shutdown temperature of the CPU package which
			is also known as the maximum processor junction
			temperature, Tjmax or Tprochot.
temp2_crit_hyst		Provides the hysteresis value from Tcontrol to Tjmax of
			the CPU package.
temp2_crit_hyst		Provides the hysteresis temperature of the CPU
			package. Returns Tcontrol, the temperature at which
			the critical condition clears.

temp3_label		"Tcontrol"
temp3_input		Provides current Tcontrol temperature of the CPU
+31 −23
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@
#include <linux/hwmon.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/math64.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>

@@ -33,7 +35,7 @@
struct adm1177_state {
	struct i2c_client	*client;
	u32			r_sense_uohm;
	u32			alert_threshold_ua;
	u64			alert_threshold_ua;
	bool			vrange_high;
};

@@ -48,7 +50,7 @@ static int adm1177_write_cmd(struct adm1177_state *st, u8 cmd)
}

static int adm1177_write_alert_thr(struct adm1177_state *st,
				   u32 alert_threshold_ua)
				   u64 alert_threshold_ua)
{
	u64 val;
	int ret;
@@ -91,8 +93,8 @@ static int adm1177_read(struct device *dev, enum hwmon_sensor_types type,
			*val = div_u64((105840000ull * dummy),
				       4096 * st->r_sense_uohm);
			return 0;
		case hwmon_curr_max_alarm:
			*val = st->alert_threshold_ua;
		case hwmon_curr_max:
			*val = div_u64(st->alert_threshold_ua, 1000);
			return 0;
		default:
			return -EOPNOTSUPP;
@@ -126,9 +128,10 @@ static int adm1177_write(struct device *dev, enum hwmon_sensor_types type,
	switch (type) {
	case hwmon_curr:
		switch (attr) {
		case hwmon_curr_max_alarm:
			adm1177_write_alert_thr(st, val);
			return 0;
		case hwmon_curr_max:
			val = clamp_val(val, 0,
					div_u64(105840000ULL, st->r_sense_uohm));
			return adm1177_write_alert_thr(st, (u64)val * 1000);
		default:
			return -EOPNOTSUPP;
		}
@@ -156,7 +159,7 @@ static umode_t adm1177_is_visible(const void *data,
			if (st->r_sense_uohm)
				return 0444;
			return 0;
		case hwmon_curr_max_alarm:
		case hwmon_curr_max:
			if (st->r_sense_uohm)
				return 0644;
			return 0;
@@ -170,7 +173,7 @@ static umode_t adm1177_is_visible(const void *data,

static const struct hwmon_channel_info * const adm1177_info[] = {
	HWMON_CHANNEL_INFO(curr,
			   HWMON_C_INPUT | HWMON_C_MAX_ALARM),
			   HWMON_C_INPUT | HWMON_C_MAX),
	HWMON_CHANNEL_INFO(in,
			   HWMON_I_INPUT),
	NULL
@@ -192,7 +195,8 @@ static int adm1177_probe(struct i2c_client *client)
	struct device *dev = &client->dev;
	struct device *hwmon_dev;
	struct adm1177_state *st;
	u32 alert_threshold_ua;
	u64 alert_threshold_ua;
	u32 prop;
	int ret;

	st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL);
@@ -208,22 +212,26 @@ static int adm1177_probe(struct i2c_client *client)
	if (device_property_read_u32(dev, "shunt-resistor-micro-ohms",
				     &st->r_sense_uohm))
		st->r_sense_uohm = 0;
	if (device_property_read_u32(dev, "adi,shutdown-threshold-microamp",
				     &alert_threshold_ua)) {
		if (st->r_sense_uohm)
	if (!device_property_read_u32(dev, "adi,shutdown-threshold-microamp",
				      &prop)) {
		alert_threshold_ua = prop;
	} else if (st->r_sense_uohm) {
		/*
		 * set maximum default value from datasheet based on
		 * shunt-resistor
		 */
			alert_threshold_ua = div_u64(105840000000,
		alert_threshold_ua = div_u64(105840000000ULL,
					     st->r_sense_uohm);
		else
	} else {
		alert_threshold_ua = 0;
	}
	st->vrange_high = device_property_read_bool(dev,
						    "adi,vrange-high-enable");
	if (alert_threshold_ua && st->r_sense_uohm)
		adm1177_write_alert_thr(st, alert_threshold_ua);
	if (alert_threshold_ua && st->r_sense_uohm) {
		ret = adm1177_write_alert_thr(st, alert_threshold_ua);
		if (ret)
			return ret;
	}

	ret = adm1177_write_cmd(st, ADM1177_CMD_V_CONT |
				    ADM1177_CMD_I_CONT |
+2 −2
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ static int get_temp_target(struct peci_cputemp *priv, enum peci_temp_target_type
		*val = priv->temp.target.tjmax;
		break;
	case crit_hyst_type:
		*val = priv->temp.target.tjmax - priv->temp.target.tcontrol;
		*val = priv->temp.target.tcontrol;
		break;
	default:
		ret = -EOPNOTSUPP;
@@ -319,7 +319,7 @@ static umode_t cputemp_is_visible(const void *data, enum hwmon_sensor_types type
{
	const struct peci_cputemp *priv = data;

	if (channel > CPUTEMP_CHANNEL_NUMS)
	if (channel >= CPUTEMP_CHANNEL_NUMS)
		return 0;

	if (channel < channel_core)
+2 −1
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page,

		/* Adjust returned value to match VIN coefficients */
		/* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */
		ret = DIV_ROUND_CLOSEST(ret * 25, 12500);
		ret = clamp_val(DIV_ROUND_CLOSEST((s16)ret * 25, 12500),
				S16_MIN, S16_MAX) & 0xffff;
		break;
	default:
		ret = -ENODATA;
Loading