summaryrefslogtreecommitdiff
path: root/drivers/hwmon
AgeCommit message (Collapse)AuthorFilesLines
2016-09-09hwmon: (lm95241) Drop FSF addressGuenter Roeck1-4/+0
The FSF address may change, and providing it does not add any value. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Order include files alphabeticallyGuenter Roeck1-4/+4
Simplify detecting duplicate include files and finding the right place for adding new ones. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Add support for fault attributesGuenter Roeck1-1/+19
The chip reports if remote diodes are present, which can be used for the fault attrributes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-09hwmon: (lm95241) Fix overflow problems, write conversion rate to chipGuenter Roeck1-7/+33
Writing the update_interval attribute could result in an overflow if a number close to the maximum unsigned long was written. At the same time, even though the chip supports setting the conversion rate, the selected conversion rate was not actually written to the chip. Fix the second problem by selecting valid (supported) conversion rates, and writing the selected conversion rate to the chip. This also fixes the first problem, since arbitrary conversion rates are now converted to actually supported conversion rates. Also, set the default chip conversion rate to 1 second. Previously, the chip was configured for continuous conversion, but readings were only retrieved every seond, which doesn't make much sense. If we only read a value from the chip every second, we can as well save some power and only convert in one-second intervals. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-05hwmon: Use smp_call_on_cpu() for dell-smm i8kJuergen Gross1-16/+20
Use the smp_call_on_cpu() function to call system management mode on CPU 0. Make call secure by adding get_online_cpus() to avoid e.g. suspend resume cycles in between. Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Douglas_Warzecha@dell.com Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: akataria@vmware.com Cc: boris.ostrovsky@oracle.com Cc: chrisw@sous-sol.org Cc: david.vrabel@citrix.com Cc: hpa@zytor.com Cc: jdelvare@suse.com Cc: jeremy@goop.org Cc: linux@roeck-us.net Cc: pali.rohar@gmail.com Cc: rusty@rustcorp.com.au Cc: virtualization@lists.linux-foundation.org Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/1472453327-19050-7-git-send-email-jgross@suse.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-29hwmon: (it87) Add missing sysfs attribute group terminatorJean Delvare1-0/+1
Attribute array it87_attributes_in lacks its NULL terminator, causing random behavior when operating on the attribute group. Fixes: 52929715634a ("hwmon: (it87) Use is_visible for voltage sensors") Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-12hwmon: (it87) Features mask must be 32 bit wideGuenter Roeck1-1/+1
Coverity reports: result_independent_of_operands: data->features & (65536UL /* 1UL << 16 */) is always 0 regardless of the values of its operands. This occurs as the logical operand of if. data->features needs to be 32 bit wide since there are more than 16 features. Fixes: cc18da79d9b7 ("hwmon: (it87) Support up to 6 temperature sensors ... "); Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01Merge tag 'hwmon-for-linus-v4.8-2' of ↵Linus Torvalds7-27/+73
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull more hwmon updates from Guenter Roeck: - Improved error handling in tmp102, lm75, and lm90 drivers - Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers * tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (adt7411) set sane values for CFG1 and CFG3 hwmon: (iio_hwmon) fix memory leak in name attribute hwmon: (ftsteutates) Fix potential memory access error hwmon: (tmp102) Improve error handling hwmon: (lm75) Improve error handling hwmon: (lm90) Improve error handling hwmon: (lm90) Add missing assignment hwmon: (sht3x) set initial jiffies to last_update
2016-08-01hwmon: (adt7411) set sane values for CFG1 and CFG3Michael Walle1-4/+44
According to the datasheet we have to set some bits as 0 and others as 1. Make sure we do this for CFG1 and CFG3. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (iio_hwmon) fix memory leak in name attributeQuentin Schulz1-12/+12
The "name" variable's memory is now freed when the device is destructed thanks to devm function. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Reported-by: Guenter Roeck <linux@roeck-us.net> Fixes: e0f8a24e0edfd ("staging:iio::hwmon interface client driver.") Fixes: 61bb53bcbdd86 ("hwmon: (iio_hwmon) Add support for humidity sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (ftsteutates) Fix potential memory access errorGuenter Roeck1-1/+1
Using set_bit() to set a bit in an integer is not a good idea, since the function expects an unsigned long as argument, which can be 64 bit wide. Coverity reports this problem as >>> CID 1364488: Memory - illegal accesses (INCOMPATIBLE_CAST) >>> Pointer "&ret" points to an object whose effective type is "int" >>> (32 bits, signed) but is dereferenced as a wider "unsigned +long" (64 bits, unsigned). This may lead to memory corruption. 245 set_bit(1, (unsigned long *)&ret); Just use BIT instead. Cc: Thilo Cestonaro <thilo@cestona.ro> Fixes: 08426eda58e0 ("hwmon: Add driver for FTS BMC chip "Teutates"") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (tmp102) Improve error handlingGuenter Roeck1-1/+3
Use devm_add_action_or_reset() instead of devm_add_action(), and check its return code. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (lm75) Improve error handlingGuenter Roeck1-2/+4
Use devm_add_action_or_reset() instead of devm_add_action(), and check its return value. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (lm90) Improve error handlingGuenter Roeck1-5/+7
Replace devm_add_action() with devm_add_action_or_reset(), and check its return value. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (lm90) Add missing assignmentGuenter Roeck1-1/+1
Coverity reports the following error. >>> CID 1364474: Error handling issues (CHECKED_RETURN) >>> Calling "lm90_read_reg" without checking return value (as is done >>> elsewhere 28 out of 29 times). 532 lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); 533 if (val < 0) 534 return val; Fixes: 10bfef47bd259 ("hwmon: (lm90) Read limit registers only once") Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-01hwmon: (sht3x) set initial jiffies to last_updateMatt Ranostay1-1/+1
Handling the wraparound requires the data->last_update to be set to an initial jiffies value. Otherwise on 32-bit systems you will not be able to request a reading till the 5 minute jiffies rollover happens. Cc: Guenter Roeck <linux@roeck-us.net> Cc: David Frey <david.frey@sensirion.com> Signed-off-by: Matt Ranostay <mranostay@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Fixes: 7c84f7f80d6fc ("hwmon: add support for Sensirion SHT3x sensors") Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-28Merge branch 'i2c/for-4.8' of ↵Linus Torvalds1-1/+5
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux Pull i2c updates from Wolfram Sang: "Here is the I2C pull request for 4.8: - the core and i801 driver gained support for SMBus Host Notify - core support for more than one address in DT - i2c_add_adapter() has now better error messages. We can remove all error messages from drivers calling it as a next step. - bigger updates to rk3x driver to support rk3399 SoC - the at24 eeprom driver got refactored and can now read special variants with unique serials or fixed MAC addresses. The rest is regular driver updates and bugfixes" * 'i2c/for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (66 commits) i2c: i801: use IS_ENABLED() instead of checking for built-in or module Documentation: i2c: slave: give proper example for pm usage Documentation: i2c: slave: describe buffer problems a bit better i2c: bcm2835: Don't complain on -EPROBE_DEFER from getting our clock i2c: i2c-smbus: drop useless stubs i2c: efm32: fix a failure path in efm32_i2c_probe() Revert "i2c: core: Cleanup I2C ACPI namespace" Revert "i2c: core: Add function for finding the bus speed from ACPI" i2c: Update the description of I2C_SMBUS i2c: i2c-smbus: fix i2c_handle_smbus_host_notify documentation eeprom: at24: tweak the loop_until_timeout() macro eeprom: at24: add support for at24mac series eeprom: at24: support reading the serial number for 24csxx eeprom: at24: platform_data: use BIT() macro eeprom: at24: split at24_eeprom_write() into specialized functions eeprom: at24: split at24_eeprom_read() into specialized functions eeprom: at24: hide the read/write loop behind a macro eeprom: at24: call read/write functions via function pointers eeprom: at24: coding style fixes eeprom: at24: move at24_read() below at24_eeprom_write() ...
2016-07-20hwmon: (ftsteutates) Remove unused including <linux/version.h>Wei Yongjun1-1/+0
Remove including <linux/version.h> that don't need it. Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-20hwmon: (adt7411) set bit 3 in CFG1 registerMichael Walle1-1/+4
According to the datasheet you should only write 1 to this bit. If it is not set, at least AIN3 will return bad values on newer silicon revisions. Fixes: d84ca5b345c2 ("hwmon: Add driver for ADT7411 voltage and temperature sensor") Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-20hwmon: Add driver for FTS BMC chip "Teutates"Thilo Cestonaro3-0/+833
This driver implements hardware monitoring and watchdog support for the FTS BMC Chip "Teutates". Signed-off-by: Thilo Cestonaro <thilo@cestona.ro> [groeck: Updated subject and description; fixed dependencies] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-16hwmon: (sht3x) add humidity heater element controlMatt Ranostay1-0/+50
The enables control of the SHT31 sensors heating element that can turned on to remove excess humidity. Cc: Guenter Roeck <linux@roeck-us.net> Cc: David Frey <david.frey@sensirion.com> Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-13hwmon: (jc42) Add support for generic JC-42.4 devicetree bindingGuenter Roeck1-0/+10
With this change, JC-42.4 compatible temperature sensors can be configured in devicetree by providing a generic "jedec,jc-42.4-temp" binding. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-13hwmon: (tmp102) Convert to use regmap, and drop local cacheGuenter Roeck2-78/+71
By converting the driver to regmap, we can use regmap to cache non-volatile registers. Stop caching the temperature register; while potentially reading it more often can result in reading it more often than necessary, this is offset by the gain due to not re-reading the limit registers. A positive side effect of this change is that limit registers can now be read and updated before the first temperature conversion is complete. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-13hwmon: (tmp102) Rework chip configurationGuenter Roeck1-15/+22
So far the chip was forced into polarity 0, even if it was preconfigured differently. Do not touch the polarity when configuring the chip. Also, the configuration register was read beack to check if the configuration 'sticks'. Ultimately, that is similar to checking if the chip is a tmp102 in the first place. Checking if a write into the configuration register was successful is really not the way to do it, and quite risky if the chip is not a tmp102, so drop that check. Instead, verify if the configuration register has unexpected bits set before writing into it. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-13hwmon: (tmp102) Improve handling of initial read delayGuenter Roeck1-14/+30
If the chip was in shutdown mode when the driver was loaded, the first conversion is ready no more than 35 milli-seconds after the chip was taken out of shutdown. The driver delay was so far set to 333 ms (HZ / 3), which is much higher than the maximum time needed by the chip. Reduce the time to 35 milli-seconds. Introduce a 'valid' flag to ensure that sensor data is actually read even if requested less than 333 ms after the driver was loaded. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Drop unnecessary else statementsGuenter Roeck1-16/+12
checkpatch rightfully complains that else after return is unnecessary. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use bool for valid flagGuenter Roeck1-3/+3
Use bool for valid flag and leave it up to the compiler to find an optimal representation. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Read limit registers only onceGuenter Roeck1-72/+105
Read limit registers only once at startup or after errors to improve driver performance. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Simplify read functionsGuenter Roeck1-115/+193
Return both error code and register value as return code from read functions, and always check for errors. This reduces code size on x86_64 by more than 1k while at the same time improving error resiliency. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use devm_hwmon_device_register_with_groupsGuenter Roeck1-20/+6
Since all other cleanup handled with devm_add_action, we can use devm_hwmon_device_register_with_groups() to register the hwmon device, and drop the remove function. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm90) Use devm_add_action for cleanupGuenter Roeck1-18/+22
Use devm_add_action where possible to simplify error handling and cleanup on remove. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Convert to use regmapGuenter Roeck2-94/+69
Convert to use regmap. Leave caching to regmap and drop the register update function. While this can result in additional read operations if the temperature register is read continuously, it avoids re-reading the limit registers and thus overall reduces complexity. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Add update_interval attributeGuenter Roeck1-0/+13
Since we know the chip's update interval, let's make it available to the user. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Drop lm75_read_value and lm75_write_valueGuenter Roeck1-33/+9
lm75_read_value and lm75_write_value don't really add any value. Replace with direct smbus access functions. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-09hwmon: (lm75) Handle cleanup with devm_add_actionGuenter Roeck1-19/+19
Use devm_add_action() to register the function to restore the original chip configuration. Use devm_hwmon_device_register_with_groups() to register the hwmon device, and drop the remove function as no longer needed. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-05hwmon: (jc42) Add I2C_CLASS_HWMON to detection classAlison Schofield1-1/+1
In 2011, commit 774466add7c ("hwmon: (jc42) Change detection class") changed the detection class of these chips to I2C_CLASS_SPD based on this premise: "makes more sense because these chips always live on memory modules" Today these chips have applications beyond memory modules. Examples are JC42.4 compatible chips such as MCP9804 and MCP9808, but also MCP9805, which is marked as JC42.4 compliant and suggested for use not only for DIMMS, but also as generic temperature sensor. Add I2C_CLASS_HWMON as an additional detection class to allow detection by hwmon class i2c adapters. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (tmp102) Drop FSF addressGuenter Roeck1-4/+0
The FSF address can change, so drop it from the driver. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (tmp102) Use devm_add_action to register cleanup functionGuenter Roeck1-35/+19
By registering a cleanup function with devm_add_action(), we can simplify the error path in the probe function and drop the remove function entirely. Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (jc42) Add support for Microchip MCP9808 temperature sensorAlison Schofield2-2/+6
MCP9808 is not officially compliant to JC-42, similar to MCP9804, but its registers are compatible to JC-42. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (ina3221) Fix negative limitsGuenter Roeck1-7/+6
The result of an integer divide by an unsigned is undefined. This causes unexpected results when writing negative values into the limit registers. Maintain the shunt_resistors variables as signed integer to avoid the problem. Also, for simplicity and ease of use, clamp shunt resistor value on writes instead of rejecting bad values. Cc: Andrew F. Davis <afd@ti.com> Acked-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (emc6w201): trivial fix of spelling mistake "Unknwown" -> "Unknown"Colin Ian King1-1/+1
trivial fix to spelling mistake in dev_dbg message Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (dell-smm) In debug mode log duration of SMM callsPali Rohár1-0/+17
This allow us to debug how long take each SMM call and how long is system frozen in SMM handler. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (dell-smm) Detect fan with index=2Pali Rohár1-2/+22
Some Dell machines (e.g. Dell Precision M3800) have two fans, first with index=0 and second with index=2. So export also attributes for third fan device with index=2. Reported-by: Tolga Cakir <cevelnet@gmail.com> Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Tested-by: Tolga Cakir <cevelnet@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (ads7871) Convert to devm_hwmon_device_register_with_groupsAxel Lin1-50/+15
Use ATTRIBUTE_GROUPS macro and devm_hwmon_device_register_with_groups() to simplify the code a bit. The update_lock mutex is not used, so remove it. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (jz4740) Convert to devm_hwmon_device_register_with_groupsAxel Lin1-51/+14
Use ATTRIBUTE_GROUPS macro and devm_hwmon_device_register_with_groups() to simplify the code a bit. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (ad7314) Convert to devm_hwmon_device_register_with_groupsAxel Lin1-41/+7
Use ATTRIBUTE_GROUPS macro and devm_hwmon_device_register_with_groups() to simplify the code a bit. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: Add support for INA3221 Triple Current/Voltage MonitorsAndrew F. Davis3-0/+458
Add support for the the INA3221 26v capable, Triple channel, Bi-Directional, Zero-Drift, Low-/High-Side, Current/Voltage Monitor with I2C interface. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: (tmp401) Add support for TI TMP461Andrew F. Davis2-7/+30
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-28hwmon: add support for Sensirion SHT3x sensorsDavid Frey3-0/+737
This driver implements support for the Sensirion SHT3x-DIS chip, a humidity and temperature sensor. Temperature is measured in degrees celsius, relative humidity is expressed as a percentage. In the sysfs interface, all values are scaled by 1000, i.e. the value for 31.5 degrees celsius is 31500. Signed-off-by: Pascal Sachs <pascal.sachs@sensirion.com> [groeck: Fixed 'Variable length array is used' gcc warning] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-23hwmon: (dell-smm) Cache fan_type() calls and change fan detectionPali Rohár1-5/+20
On more Dell machines (e.g. Dell Precision M3800) fan_type() call is too expensive (CPU is too long in SMM mode) and cause kernel to hang. This is bug in Dell SMM or BIOS. This patch caches type for each fan (as it should not change) and changes the way how fan presense is detected. First it try function fan_status() as was before commit f989e55452c7 ("i8k: Add support for fan labels"). And if that fails fallback to fan_type(). *_status() functions can fail in case fan is not currently accessible (e.g. present on GPU which is currently turned off). Reported-by: Tolga Cakir <cevelnet@gmail.com> Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Link: https://bugzilla.kernel.org/show_bug.cgi?id=112021 Cc: stable@vger.kernel.org # v4.0+, will need backport Tested-by: Tolga Cakir <cevelnet@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>