Commit 5c30c3cc authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hwmon-for-linus-v3.20' of...

Merge tag 'hwmon-for-linus-v3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
 "Explicit support for ina231 added to ina2xx driver.

  Minor improvements, cleanup and fixes in various drivers"

* tag 'hwmon-for-linus-v3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (tmp102) add hibernation callbacks
  hwmon: (ads2828) Only keep data in device data structure if needed
  hwmon: (ads2828) Convert to use regmap
  hwmon: (jc42) Allow negative hysteresis temperatures
  hwmon: (adc128d818) Do proper sign extension
  hwmon: (ad7314) Do proper sign extension
  hwmon: (abx500) Fix format string warnings
  hwmon: (jc42) Fix integer overflow when writing hysteresis value
  hwmon: (jc42) Fix integer overflow
  hwmon: (jc42) Use sign_extend32 for sign extension
  hwmon: (ina2xx) Add ina231 compatible string
  hwmon: (ina2xx) use DIV_ROUND_CLOSEST() to avoid rounding errors
  hwmon: (ina2xx) remove an unnecessary dev_get_drvdata() result check
  hwmon: (ina2xx) implement update_interval attribute for ina226
  hwmon: (ina2xx) make shunt resistance configurable at run-time
  hwmon: (ina2xx) don't accept shunt values greater than the calibration factor
  hwmon: (ina2xx) remove a stray new line
  hwmon: (ina2xx) reinitialize the chip in case it's been reset
  hwmon: (nct7802) Constify struct regmap_config
parents 19acc77a dd378b1b
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -26,6 +26,12 @@ Supported chips:
    Datasheet: Publicly available at the Texas Instruments website
               http://www.ti.com/

  * Texas Instruments INA231
    Prefix: 'ina231'
    Addresses: I2C 0x40 - 0x4f
    Datasheet: Publicly available at the Texas Instruments website
               http://www.ti.com/

Author: Lothar Felten <l-felten@ti.com>

Description
@@ -41,9 +47,18 @@ interface. The INA220 monitors both shunt drop and supply voltage.
The INA226 is a current shunt and power monitor with an I2C interface.
The INA226 monitors both a shunt voltage drop and bus supply voltage.

The INA230 is a high or low side current shunt and power monitor with an I2C
interface. The INA230 monitors both a shunt voltage drop and bus supply voltage.
INA230 and INA231 are high or low side current shunt and power monitors
with an I2C interface. The chips monitor both a shunt voltage drop and
bus supply voltage.

The shunt value in micro-ohms can be set via platform data or device tree.
Please refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
The shunt value in micro-ohms can be set via platform data or device tree at
compile-time or via the shunt_resistor attribute in sysfs at run-time. Please
refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
if the device tree is used.

Additionally ina226 supports update_interval attribute as described in
Documentation/hwmon/sysfs-interface. Internally the interval is the sum of
bus and shunt voltage conversion times multiplied by the averaging rate. We
don't touch the conversion times and only modify the number of averages. The
lower limit of the update_interval is 2 ms, the upper limit is 2253 ms.
The actual programmed interval may vary from the desired value.
+3 −2
Original line number Diff line number Diff line
@@ -1389,6 +1389,7 @@ config SENSORS_ADS1015
config SENSORS_ADS7828
	tristate "Texas Instruments ADS7828 and compatibles"
	depends on I2C
	select REGMAP_I2C
	help
	  If you say yes here you get support for Texas Instruments ADS7828 and
	  ADS7830 8-channel A/D converters. ADS7828 resolution is 12-bit, while
@@ -1430,8 +1431,8 @@ config SENSORS_INA2XX
	tristate "Texas Instruments INA219 and compatibles"
	depends on I2C
	help
	  If you say yes here you get support for INA219, INA220, INA226, and
	  INA230 power monitor chips.
	  If you say yes here you get support for INA219, INA220, INA226,
	  INA230, and INA231 power monitor chips.

	  The INA2xx driver is configured for the default configuration of
	  the part as described in the datasheet.
+3 −3
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ static ssize_t show_min(struct device *dev,
	struct abx500_temp *data = dev_get_drvdata(dev);
	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);

	return sprintf(buf, "%ld\n", data->min[attr->index]);
	return sprintf(buf, "%lu\n", data->min[attr->index]);
}

static ssize_t show_max(struct device *dev,
@@ -230,7 +230,7 @@ static ssize_t show_max(struct device *dev,
	struct abx500_temp *data = dev_get_drvdata(dev);
	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);

	return sprintf(buf, "%ld\n", data->max[attr->index]);
	return sprintf(buf, "%lu\n", data->max[attr->index]);
}

static ssize_t show_max_hyst(struct device *dev,
@@ -239,7 +239,7 @@ static ssize_t show_max_hyst(struct device *dev,
	struct abx500_temp *data = dev_get_drvdata(dev);
	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);

	return sprintf(buf, "%ld\n", data->max_hyst[attr->index]);
	return sprintf(buf, "%lu\n", data->max_hyst[attr->index]);
}

static ssize_t show_min_alarm(struct device *dev,
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/bitops.h>

/*
 * AD7314 temperature masks
@@ -67,7 +68,7 @@ static ssize_t ad7314_show_temperature(struct device *dev,
	switch (spi_get_device_id(chip->spi_dev)->driver_data) {
	case ad7314:
		data = (ret & AD7314_TEMP_MASK) >> AD7314_TEMP_SHIFT;
		data = (data << 6) >> 6;
		data = sign_extend32(data, 9);

		return sprintf(buf, "%d\n", 250 * data);
	case adt7301:
@@ -78,7 +79,7 @@ static ssize_t ad7314_show_temperature(struct device *dev,
		 * register.  1lsb - 31.25 milli degrees centigrade
		 */
		data = ret & ADT7301_TEMP_MASK;
		data = (data << 2) >> 2;
		data = sign_extend32(data, 13);

		return sprintf(buf, "%d\n",
			       DIV_ROUND_CLOSEST(data * 3125, 100));
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <linux/err.h>
#include <linux/regulator/consumer.h>
#include <linux/mutex.h>
#include <linux/bitops.h>

/* Addresses to scan
 * The chip also supports addresses 0x35..0x37. Don't scan those addresses
@@ -189,7 +190,7 @@ static ssize_t adc128_show_temp(struct device *dev,
	if (IS_ERR(data))
		return PTR_ERR(data);

	temp = (data->temp[index] << 7) >> 7;	/* sign extend */
	temp = sign_extend32(data->temp[index], 8);
	return sprintf(buf, "%d\n", temp * 500);/* 0.5 degrees C resolution */
}

Loading