History log of /linux-master/drivers/hwmon/lm90.c
Revision Date Author Comments
# 1ef2ebf2 10-Aug-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

hwmon: (lm90) fix Wvoid-pointer-to-enum-cast warning

'kind' is an enum, thus cast of pointer on 64-bit compile test with W=1
causes:

lm90.c:2768:16: error: cast to smaller integer type 'enum chips' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230810093157.94244-8-krzysztof.kozlowski@linaro.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 39f03438 14-Jul-2023 Rob Herring <robh@kernel.org>

hwmon: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230714174607.4057185-1-robh@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1975d167 05-May-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

hwmon: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230505131718.1210071-1-u.kleine-koenig@pengutronix.de
[groeck: Added missing change in pmbus/acbel-fsg032.c]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 25f98688 06-Nov-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

hwmon: Include <linux/kstrtox.h> when appropriate

The kstrto<something>() functions have been moved from kernel.h to
kstrtox.h.

So, include the latter directly in the appropriate files.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/51688cf50bda44e2731381a31287c62319388783.1667763218.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ad804a4d 21-Oct-2022 Matti Vaittinen <mazziesaccount@gmail.com>

hwmon: (lm90) simplify using devm_regulator_get_enable()

Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(),
add_action_or_reset(regulator_disable)' and use the
devm_regulator_get_enable().

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/a1fa4364cbb775de25478117dd22dda0742089e3.1666357434.git.mazziesaccount@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d025007d 25-Sep-2022 Jonathan Cameron <Jonathan.Cameron@huawei.com>

hwmon: (lm90) Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()

These newer PM macros allow the compiler to see what code it can remove
if !CONFIG_PM_SLEEP. This allows the removal of __maybe_unused markings
whilst achieving the same result.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220925172759.3573439-8-jic23@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f2f394db 18-Aug-2022 Wolfram Sang <wsa+renesas@sang-engineering.com>

hwmon: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20220818210014.6769-1-wsa+renesas@sang-engineering.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 7aeef154 08-Aug-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix error return value from detect function

lm90_detect_nuvoton() is supposed to return NULL if it can not detect
a chip, or a pointer to the chip name if it does. Under some circumstances
it returns an error pointer instead. Some versions of gcc interpret an
ERR_PTR as region of size 0 and generate an error message.

In function ‘__fortify_strlen’,
inlined from ‘strlcpy’ at ./include/linux/fortify-string.h:159:10,
inlined from ‘lm90_detect’ at drivers/hwmon/lm90.c:2550:2:
./include/linux/fortify-string.h:50:33: error:
‘__builtin_strlen’ reading 1 or more bytes from a region of size 0
50 | #define __underlying_strlen __builtin_strlen
| ^
./include/linux/fortify-string.h:141:24: note:
in expansion of macro ‘__underlying_strlen’
141 | return __underlying_strlen(p);
| ^~~~~~~~~~~~~~~~~~~

Returning NULL instead of ERR_PTR() fixes the problem.

Fixes: c7cebce984a2 ("hwmon: (lm90) Rework detect function")
Reported-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Kees Cook <keescook@chromium.org>
Tested-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 5993b988 29-Jun-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use worker for alarm notifications

Reporting alarms using hwmon_notify_event() may result in a callback
from the thermal subsystem. This means that such notifications must
not hold the update lock to avoid a deadlock. To avoid this situation,
use a worker to handle notifications.

Reported-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Fixes: f6d0775119fb ("hwmon: (lm90) Rework alarm/status handling")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 00dc6452 07-Jun-2022 Slawomir Stepien <slawomir.stepien@nokia.com>

hwmon: (lm90) Read the channel's temperature offset from device-tree

Try to read the channel's temperature offset from device-tree. Having
offset in device-tree node is not mandatory. The offset can only be set
for remote channels.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220607063504.1287855-3-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 07845f55 07-Jun-2022 Slawomir Stepien <slawomir.stepien@nokia.com>

hwmon: (lm90) Add support for 2nd remote channel's offset register

The ADT7481 have LM90_HAVE_TEMP3 and LM90_HAVE_OFFSET flags, but the
support of second remote channel's offset is missing. Add that
implementation.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220607063504.1287855-2-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f9938eeb 25-May-2022 Slawomir Stepien <slawomir.stepien@nokia.com>

hwmon: (lm90) Read the channel's label from device-tree

Try to read the channel's label from device-tree. Having label in
device-tree node is not mandatory.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220525073657.573327-7-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 27f04389 25-May-2022 Slawomir Stepien <slawomir.stepien@nokia.com>

hwmon: (lm90) Define maximum number of channels that are supported

Use this define in all the places where literal '3' was used in this
context.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220525073657.573327-6-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b9e7dfde 25-May-2022 Slawomir Stepien <slawomir.stepien@nokia.com>

hwmon: (lm90) Add compatible entry for adt7481

This will allow binding the driver with the device from the device tree.

Signed-off-by: Slawomir Stepien <slawomir.stepien@nokia.com>
Link: https://lore.kernel.org/r/20220525073657.573327-4-sst@poczta.fm
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ca99633a 16-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Support temp_samples attribute

Several of the chips supported by this driver support configuring the
number of samples (or the fault queue depth) necessary before a fault
or alarm is reported. This is done either with a bit in the configuration
register or with a separate "consecutive alert" register. Support this
functionality with the temp_samples attribute.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 018b8287 16-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add table with supported Analog/ONSEMI devices

Add table with device names and known register values for supported
devices from Analog / ON Semiconductor.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 9a198663 06-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support and detection of Philips/NXP NE1618

NE1618 is similar to NE1617 but supports manufacturer and chip ID
registers as well as 11 bit external temperature resolution.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f63f6cce 06-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add explicit support for ADM1020

ADM1020 is compatible with ADM1021 but has a separate chip revision and
a limited I2C address range.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b1526b38 28-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Only disable alerts if not already disabled

It was observed that the alert handler may be called from the i2c core
even after alerts have already been disabled. Only disable alerts if
they have not already been disabled.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 41e6d721 15-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for ADT7421

ADT7421 is similar to ADT7461A but supports configurable Beta Compensation.
Packet Error Checking (PEC) is supported but undocumented.

A devicetree node is not added for the added chip since it is quite
unlikely that such an old chip will ever be used in a devicetree based
system. It can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d8521f82 13-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for ON Semiconductor NCT218

NCT218 is compatible to NCT72 and NCT214. It also supports PEC (packet
error checking). Similar to NCT72 and NCT214, PEC support is undocumented.

Unlike NCT214 and NCT72, NCT218 does not support the undocumented secondary
chip and manufacturer ID registers at 0x3e and 0x3f and returns 0x00 when
reading those registers. The value for the chip revision register is not
documented but was observed to be 0xca. Use that information to improve
chip detection accuracy.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 2c6cb6c5 02-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for ON Semiconductor NCT214 and NCT72

NCT214 and NCT72 are compatible to ADT7461/ADT7461A but have full
PEC (packet error checking) support. PEC support is undocumented.

Both chips support the undocumented secondary chip and manufacturer
ID registers at 0x3e and 0x3f, and return 0x61 as chip ID. Use this
information to improve the accuracy of chip detection code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# af4540b1 06-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add explicit support for NCT210

Unlike ADM1023 and compatible chips, NCT210 does not support a temperature
offset register. A real chip was found to have a chip revision of 0x3f.
Use it to detect NCT210 explicitly.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# df18fccd 27-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Combine lm86 and lm90 configuration

LM86 and LM90 support exactly the same features, so there is no need
to keep their configuration options separate. Combine to reduce data
size.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 37d1dc8d 22-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add remaining chips supported by adm1021 driver

All chips supported by the ADM1021 driver are also supported by the LM90
driver. Make that support official.

After this change, the adm1021 driver is only needed if the lm90 driver
is disabled. Also, the adm1021 driver misdetects a variety of chips as
MAX1617A, which is unwanted if any of those chips is in the system.
For this reason. make the adm1021 driver dependent on !SENSORS_LM90 to
show that it is not needed if the lm90 driver is enabled, and to avoid
misdetection if a chip supported by the lm90 driver is in the system.

Devicetree nodes are not added for the added chips since it is quite
unlikely that such old chips will ever be used in a devicetree based
system. They can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 0c6bffd4 19-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for ADM1021, ADM1021A, and ADM1023

Both chips are quite similar to other chips of this series, so add
support for them to the lm90 driver. Also mention ON Semiconductor NCT210,
which is pin and register compatible to ADM1021A.

None of the chips support the secondary manufacturer and chip ID registers
at 0x3e and 0x3f, but return 0 when reading from those registers.
Use that information to improve the accuracy of chip detection code.

Devicetree nodes are not added for the added chips since it is quite
unlikely that such old chips will ever be used in a devicetree based
system. They can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c09472fc 19-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Support MAX1617 and LM84

MAX1617 and LM84 are stripped-down versions of LM90, so they can easily
be supported by the LM90 driver. The most difficult part is chip detection,
since those old chips do not support manufacturer ID or chip ID registers.

The "alarms" attribute is enabled for both chips to match the functionality
of the adm1021 driver. Chip detection was improved and is less prone to
misdetection than the chip detection in the adm1021 driver.

Devicetree nodes are not added for the added chips since it is quite
unlikely that such old chips will ever be used in a devicetree based
system. They can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 6be4b1a4 20-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Introduce 16-bit register write function

Introduce 16-bit register write function to simplify the code in
some places.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c9933a44 19-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Let lm90_read16() handle 8-bit read operations

Simplify the code a bit by handling single-register read operations
in lm90_read16(). All we need to do is to skip the low-byte read
operation if the register address is 0.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 3c1ecccb 15-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for MAX6642

MAX6642 is a reduced version of LM90 with no low limits and no conversion
rate register. Its alert functionality is broken, similar to many other
chips supported by the lm90 driver.

After this change, the stand-alone max6642 driver is only needed if the
lm90 driver is disabled. Make it dependent on SENSORS_LM90=n to show that
it is not needed if the lm90 driver is enabled.

A devicetree node is not added for this chip since it is quite unlikely
that such an old chip will ever be used in a devicetree based system.
It can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ca6bfa3b 15-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add flag to indicate conversion rate support

A flag indicating support for setting the conversion rate doesn't cost
much and will enable us to add support for MAX6642 to the lm90 driver.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 2cb8d9d8 15-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add flag to indicate support for minimum temperature limits

A flag indicating support for minimum temperature limits doesn't cost much
and will enable us to add support for MAX6642 to the lm90 driver.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 399a8a00 12-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for MAX6690

MAX6690 is all but identical to MAX6654. Revision 1 of its
datasheet lists the same chip ID as MAX6654, and a chip labeled
MAX6654 was found to have the chip ID listed as MAX6690 chip ID
in Revision 2 of its datasheet.

A devicetree node is not added for this chip since it is quite unlikely
that such an old chip will ever be used in a devicetree based system.
It can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 9888775b 10-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Strengthen chip detection for ADM1032, ADT7461(A), and NCT1008

ADT7461A and NCT1008 support the undocumented manufacturer and chip ID
registers at 0x3e and 0x3f, and return 0x61 as chip ID. ADM1032 and
ADT7461 do not support those registers but return 0 when reading them.
Use this information to improve the accuracy of the chip detection code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a9f3d3a8 06-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for ADT7481, ADT7482, and ADT7483

ADT7481, ADT7482, and ADT7483 are similar to ADT7461, but support two
external temperature sensors, similar to MAX6695/6696. They support an
extended temperature range similar to ADT7461. Registers for the second
external channel can be accessed directly or by using the same method as
used by MAX6695/6696. For simplicity, the access method implemented for
MAX6695/6696 is used.

The chips support PEC (packet error checking). Set the PEC feature flag
and let the user decide if it should be enabled or not (it is by default
disabled).

Even though it is only documented for ADT7483, all three chips support a
secondary manufacturer ID register at 0x3e and a chip ID register at 0x3f.
Use the contents of those registers register for improved chip detection
accuracy. Add the same check to the ADT7461A detection code since this chip
also supports the same (undocumented) registers.

Devicetree nodes are not added for the added chips since it is quite
unlikely that such old chips will ever be used in a devicetree based
system. They can be added later if needed.

Reviewed-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 904a6fe6 05-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add explicit support for MAX6648/MAX6692

Unlike MAX6646/MAX6647/MAX6649, MAX6648 and MAX6692 only support
a temperature range of 0..127 degrees C. Separate support for the
two sets of chips to be able to support maximum temperature ranges
correctly for all chips. Introduce new feature flag to indicate
temperature support up to 255 degrees C.

Since the chips are almost identical except for the supported temperature
range, automatic chip detection is limited. Effectively this means that
MAX6648 may be mis-detected as MAX6649 when auto-detected, but there is
nothing we can do about that.

Devicetree nodes are not added for the added chips since it is quite
unlikely that such old chips will ever be used in a devicetree based
system. They can be added later if needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e9684fdb 17-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add flag to indicate 'alarms' attribute support

We don't want to support the obsolete 'alarms' attribute for new
chips supported by this driver. Add flag to indicate 'alarms' attribute
support and use it for existing chips. This flag will not be set for
additional chips supported by this driver in the future.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 0707dda6 02-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix/Add detection of G781-1

When support for G781 was added, chips with ID 0x01 were found at I2C
addresses 0x4c and 0x4d. The G781 datasheet (version 1.3 from October 2003)
says that the device ID for G781-1 is 0x03, not 0x01. Also, the datasheet
states that the chip at I2C address is G781 and the chip at I2C address
0x4d is G781-1.

A G781-1 at I2C address 0x4d was now found to have a chip ID of 0x03
as suggested by the datasheet. Accept both 0x01 and 0x03 chip IDs at both
addresses to ensure that all variants of G781 are detected properly.

While at it, improve chip detection accuracy by reading two additional
registers and ensuring that only expected bits are set in those registers.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d277fbd5 20-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for additional chip revision of NCT1008

The NCT1008 datasheet, Revision 3, states that its chip revision is
0x57. This matches the ADT7461A chip revision, and NCT1008 is therefore
detected as ADT7461A. In revision 6 of the datasheet, the chip revision
register is no longer documented. Multiple samples of NCT1008 were found
to report a chip revision of 0x54. As it turns out, one of the patches
submitted to add NCT1008 support to the lm90 driver already included a
check for chip revision 0x54. Unfortunately, that patch never made it into
the kernel. Remedy the situation and explicitly detect chips with revision
0x54 as NCT1008.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c7cebce9 09-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Rework detect function

The detect function is getting larger and larger and difficult to
understand or review. Split it into per-manufacturer detect functions
to improve readability.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b977ed27 22-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use single flag to indicate extended temperature support

Since temperature conversion functions are now unified, there is no need
to keep "the chip supports a configurable extended temperature range" and
"the chip has extended temperature range enabled" flags separate.
Use a single flag instead to reflect both.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a8ddcc57 02-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Support multiple temperature resolutions

While most LM90 compatible chips support a temperature sensor resolution
of 11 bit, this is not the case for all chips. ADT7461 only supports a
resolution of 10 bit, and TMP451/TMP461 support a resolution of 12 bit.

Add support for various temperature sensor resolutions. To do this,
model all temperature sensors as 16 bit sensors, and use unified
temperature conversion functions which take the sensor resolution
as parameter.

While enhancing functionality, this has the positive side effect of
reducing code size by about 5%.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 8f19501d 05-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Only re-read registers if volatile

When reading 16-bit volatile registers, the code uses a trick to
determine if a temperature is consistent: It reads the high part
of the register twice. If the values are the same, the code assumes
that the reading is consistent. If the value differs, the code
re-reads the second register as well and assumes that it now has
correct values.

This is only necessary for volatile registers. Add a parameter to
lm90_read16() to indicate if the register is volatile to avoid the
extra overhead for non-volatile registers.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b2644494 04-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for unsigned and signed temperatures

ADT7461 and TMP451 temperature sensors support extended temperature ranges.
If standard temperature range is selected, the temperature range is
unsigned and limited to 0 .. 127 degrees C. For TMP461, the standard
temperature range is -128000 ... 127000 degrees C. Distinguish between
the two chips by introducing a feature flag indicating if the standard
temperature range is signed or unsigned. Use the same flag for MAX6646/
MAX6647 as well since those chips also support unsigned temperatures.

Note that while the datasheet for ADT7461 suggests that the default
temperature range is unsigned, tests with a real chip suggest that this
is not the case: If the temperature offset is set to a value << 0,
the temperature register does report negative values.

Tests with real chips show that MAX6680/MAX6681 and SA56004 report
temperatures of 128 degrees C and higher as negative temperatures.
Add respective comments to the code.

Also use clamp_val() and DIV_ROUND_CLOSEST where appropriate in
calculations.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d70fa73d 10-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Enable full PEC support for ADT7461A

Experiments show that ADT7461A and NCT1008 support PEC, even though it is
not documented. Enable support for it in the driver. Since ADT7461 only
supports partial PEC, this means that the configuration for ADT7461A
needs to be separated from ADT7461.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 425f5b5d 08-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add partial PEC support for ADT7461

Revision 0 of the ADT7461 datasheet suggests that the chip supports PEC
(packet error checking). This information is gone in later versions of the
datasheet. Experiments show that PEC support on ADT7461 is similar to PEC
support in ADM1032, ie it is only supported for read operations. Add
support for it to the driver.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 3b0982ff 31-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Improve PEC support

PEC (packet error checking) support for ADM1032 is currently only enabled
if the chip was auto-detected, but not if a chip is instantiated
explicitly. Always enable PEC support by introducing a chip feature flag
indicating partial PEC support. Also, for consistency, disable PEC support
by default to match existing functionality if the chip was not auto-
detected.

At the same time, introduce generic support for PEC with a separate feature
flag. This will be used when support for chips with full PEC functionality
is added.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f68480cc 31-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Stop using R_/W_ register prefix

The register write address either matches the read address, or it is the
read address plus 6. Simplify the code and resolve the write address
programmatically instead of having two defines for each register.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ca7b9b14 29-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Move status register bit shifts to compile time

Handling bit shifts necessary to extract status bits during compile time
reduces code and data size by almost 5% when building for x86_64.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ddf2a609 30-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use BIT macro

Use BIT macro instead of shift operation to improve readability.
No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ff8f0a65 30-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Reorder chip enumeration to be in alphabetical order

Reorder chip enumeration in alphabetical order to make it easier to
see which chips are supported, and to clarify where to add support
new chip types. No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 479f21d4 30-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Reorder include files in alphabetical order

Reorder include files in alphabetical order to reduce the chance of
duplicates and to make it clear where new include files should be
added. Drop the unnecessary include of linux/sysfs.h. Include
linux/device.h instead because that is what is actually used.

No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f6d07751 09-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Rework alarm/status handling

Many chips supported by this driver clear status registers after it
is read and update it in the next measurement cycle. Normally this falls
under the radar because all registers are only read once per measurement
cycle. However, there is an exception: Status registers are always read
during interrupt and laert handling. This can result in invalid status
reports if userspace reads an alarm attribute immediately afterwards.

Rework alarm/status handling by keeping a shadow register with 'current'
alarms, and by ensuring that the register is either only updated once per
measurement cycle or not cleared.

A second problem is related to alert handling: Alert handling is disabled
for chips with broken alert after an alert was reported, but only
re-enabled if attributes are read by the user. This means that alert
conditions may appear and disappear unnoticed. Remedy the situation
by introducing a worker to periodically read the status register(s) while
alert handling is disabled, and re-enable alerts after the alert condition
clears.

Yet another problem is that sysfs and udev events are currently only
reported to userspace if an alarm is raised, but not if an alarm condition
clears. Use the new worker to detect that situation and also generate
sysfs and udev events in that case.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# eaf87c00 11-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Generate sysfs and udev events for all alarms

So far the driver only generated sysfs and udev events for minimum and
maximum alarms. Also generate events for critical and emergency alarms.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 45988d90 17-May-2022 Holger Brunck <holger.brunck@hitachienergy.com>

hwmon: (lm90) enable extended range according to DTS node

Some lm90 compatible devices can operate in an extended temperature mode.
This feature is now enabled if the property is set in the corresponding
device tree node.

Signed-off-by: Holger Brunck <holger.brunck@hitachienergy.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220517135614.8185-2-holger.brunck@hitachienergy.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d379880d 11-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix sysfs and udev notifications

sysfs and udev notifications need to be sent to the _alarm
attributes, not to the value attributes.

Fixes: 94dbd23ed88c ("hwmon: (lm90) Use hwmon_notify_event()")
Cc: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f614629f 07-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Mark alert as broken for MAX6646/6647/6649

Experiments with MAX6646 and MAX6648 show that the alert function of those
chips is broken, similar to other chips supported by the lm90 driver.
Mark it accordingly.

Fixes: 4667bcb8d8fc ("hwmon: (lm90) Introduce chip parameter structure")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 94746b0b 07-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Mark alert as broken for MAX6680

Experiments with MAX6680 and MAX6681 show that the alert function of those
chips is broken, similar to other chips supported by the lm90 driver.
Mark it accordingly.

Fixes: 4667bcb8d8fc ("hwmon: (lm90) Introduce chip parameter structure")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a53fff96 07-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Mark alert as broken for MAX6654

Experiments with MAX6654 show that its alert function is broken,
similar to other chips supported by the lm90 driver. Mark it accordingly.

Fixes: 229d495d8189 ("hwmon: (lm90) Add max6654 support to lm90 driver")
Cc: Josh Lehan <krellan@google.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# bc341a1a 08-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Re-enable interrupts after alert clears

If alert handling is broken, interrupts are disabled after an alert and
re-enabled after the alert clears. However, if there is an interrupt
handler, this does not apply if alerts were originally disabled and enabled
when the driver was loaded. In that case, interrupts will stay disabled
after an alert was handled though the alert handler even after the alert
condition clears. Address the situation by always re-enabling interrupts
after the alert condition clears if there is an interrupt handler.

Fixes: 2abdc357c55d9 ("hwmon: (lm90) Unmask hardware interrupt")
Cc: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a66c5ed5 06-Jan-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Reduce maximum conversion rate for G781

According to its datasheet, G781 supports a maximum conversion rate value
of 8 (62.5 ms). However, chips labeled G781 and G780 were found to only
support a maximum conversion rate value of 7 (125 ms). On the other side,
chips labeled G781-1 and G784 were found to support a conversion rate value
of 8. There is no known means to distinguish G780 from G781 or G784; all
chips report the same manufacturer ID and chip revision.
Setting the conversion rate register value to 8 on chips not supporting
it causes unexpected behavior since the real conversion rate is set to 0
(16 seconds) if a value of 8 is written into the conversion rate register.
Limit the conversion rate register value to 7 for all G78x chips to avoid
the problem.

Fixes: ae544f64cc7b ("hwmon: (lm90) Add support for GMT G781")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# cdc5287a 03-Dec-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Do not report 'busy' status bit as alarm

Bit 7 of the status register indicates that the chip is busy
doing a conversion. It does not indicate an alarm status.
Stop reporting it as alarm status bit.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# da7dc056 26-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmom: (lm90) Fix citical alarm status for MAX6680/MAX6681

Tests with a real chip and a closer look into the datasheet reveals
that the local and remote critical alarm status bits are swapped for
MAX6680/MAX6681.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 16ba51b5 13-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Drop critical attribute support for MAX6654

Tests with a real chip and a closer look into the datasheet show that
MAX6654 does not support CRIT/THERM/OVERTEMP limits, so drop support
of the respective attributes for this chip.

Introduce LM90_HAVE_CRIT flag and use it to instantiate critical limit
attributes to solve the problem.

Cc: Josh Lehan <krellan@google.com>
Fixes: 229d495d8189 ("hwmon: (lm90) Add max6654 support to lm90 driver")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 55840b9e 17-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations

Commit b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of
temperature calculations") addressed a number of underflow situations
when writing temperature limits. However, it missed one situation, seen
when an attempt is made to set the hysteresis value to MAX_LONG and the
critical temperature limit is negative.

Use clamp_val() when setting the hysteresis temperature to ensure that
the provided value can never overflow or underflow.

Fixes: b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of temperature calculations")
Cc: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# fce15c45 06-Nov-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix usage of CONFIG2 register in detect function

The detect function had a comment "Make compiler happy" when id did not
read the second configuration register. As it turns out, the code was
checking the contents of this register for manufacturer ID 0xA1 (NXP
Semiconductor/Philips), but never actually read the register. So it
wasn't surprising that the compiler complained, and it indeed had a point.
Fix the code to read the register contents for manufacturer ID 0xa1.

At the same time, the code was reading the register for manufacturer ID
0x41 (Analog Devices), but it was not using the results. In effect it was
just checking if reading the register returned an error. That doesn't
really add much if any value, so stop doing that.

Fixes: f90be42fb383 ("hwmon: (lm90) Refactor reading of config2 register")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f8344f76 18-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add basic support for TI TMP461

TMP461 is almost identical to TMP451 and was actually detected as TMP451
with the existing lm90 driver if its I2C address is 0x4c. Add support
for it to the lm90 driver. At the same time, improve the chip detection
function to at least try to distinguish between TMP451 and TMP461.

As a side effect, this fixes commit 24333ac26d01 ("hwmon: (tmp401) use
smb word operations instead of 2 smb byte operations"). TMP461 does not
support word operations on temperature registers, which causes bad
temperature readings with the tmp401 driver. The lm90 driver does not
perform word operations on temperature registers and thus does not have
this problem.

Support is listed as basic because TMP461 supports a sensor resolution
of 0.0625 degrees C, while the lm90 driver assumes a resolution of 0.125
degrees C. Also, the TMP461 supports negative temperatures with its
default temperature range, which is not the case for similar chips
supported by the lm90 and the tmp401 drivers. Those limitations will be
addressed with follow-up patches.

Fixes: 24333ac26d01 ("hwmon: (tmp401) use smb word operations instead of 2 smb byte operations")
Reported-by: David T. Wilson <david.wilson@nasa.gov>
Cc: David T. Wilson <david.wilson@nasa.gov>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# f347e249 21-Oct-2021 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Introduce flag indicating extended temperature support

A flag indicating extended temperature support makes it easier
to add support for additional chips with this functionality.

Cc: David T. Wilson <david.wilson@nasa.gov>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b50aa496 22-Jun-2021 Dmitry Osipenko <digetx@gmail.com>

hwmon: (lm90) Prevent integer underflows of temperature calculations

The min/max/crit and all other temperature values that are passed to
the driver are unlimited and value that is close to INT_MIN results in
integer underflow of the temperature calculations made by the driver
for LM99 sensor. Temperature hysteresis is among those values that need
to be limited, but limiting of hysteresis is independent from the sensor
version. Add the missing limits.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210623042231.16008-2-digetx@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 4c7f85a3 18-Jun-2021 Dmitry Osipenko <digetx@gmail.com>

hwmon: (lm90) Disable interrupt on suspend

I2C accesses are prohibited and will error out after suspending of the
I2C controller, hence we need to ensure that interrupt won't fire on
suspend when it's too late. Disable interrupt across suspend/resume.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 2abdc357 18-Jun-2021 Dmitry Osipenko <digetx@gmail.com>

hwmon: (lm90) Unmask hardware interrupt

The ALERT interrupt is enabled by default after power-on, but it could
be masked by bootloader. For example this is the case on Acer A500 tablet
device. Unmask the hardware interrupt if interrupt is provided.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 94dbd23e 18-Jun-2021 Dmitry Osipenko <digetx@gmail.com>

hwmon: (lm90) Use hwmon_notify_event()

Use hwmon_notify_event() to notify userspace and thermal core about
temperature changes.

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# d97fb837 18-Jun-2021 Dmitry Osipenko <digetx@gmail.com>

hwmon: (lm90) Don't override interrupt trigger type

The lm90 driver sets interrupt trigger type to level-low. This type is
not suitable for sensors like NCT1008 that don't deassert interrupt line
until temperature is back to normal, resulting in interrupt storm. The
appropriate trigger type should come from OF device description and
currently it's overridden by the driver's trigger type. Don't specify
the trigger type in the driver code, letting interrupt core to use the
device-specific trigger type.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 67487038 13-Aug-2020 Stephen Kitt <steve@sk2.org>

hwmon: use simple i2c probe function

Many hwmon drivers don't use the id information provided by the old
i2c probe function, and the remainder can easily be adapted to the new
form ("probe_new") by calling i2c_match_id explicitly.

This avoids scanning the identifier tables during probes.

Drivers which didn't use the id are converted as-is; drivers which did
are modified as follows:

* if the information in i2c_client is sufficient, that's used instead
(client->name);
* anything else is handled by calling i2c_match_id() with the same
level of error-handling (if any) as before.

A few drivers aren't included in this patch because they have a
different set of maintainers. They will be covered by other patches.

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20200813160222.1503401-1-steve@sk2.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 229d495d 13-May-2020 Josh Lehan <krellan@google.com>

hwmon: (lm90) Add max6654 support to lm90 driver

Add support for the Maxim MAX6654 to the lm90 driver.

The MAX6654 is a temperature sensor, similar to the others,
but with some differences regarding the configuration
register, and the sampling rate at which extended resolution
becomes possible.

Signed-off-by: Josh Lehan <krellan@google.com>
Link: https://lore.kernel.org/r/20200513184248.145765-1-krellan@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 7a1d220c 30-Jun-2019 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Introduce function to update configuration register

The code to update the configuration register is repeated several times.
Move it into a separate function. At the same time, un-inline
lm90_select_remote_channel() and leave it up to the compiler to decide
what to do with it. Also remove the 'client' argument from
lm90_select_remote_channel() and from lm90_write_convrate() and take
it from struct lm90_data instead where needed.

This patch reduces code size by more than 800 bytes on x86_64.

Cc: Boyang Yu <byu@arista.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b849e5d1 30-Jun-2019 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Cache configuration register value

The configuration register does not change on its own. Yet, it is read
in various locations, modified, and written back. Simplify and optimize
the code by caching its value and by only writing it back when needed.

Cc: Boyang Yu <byu@arista.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 62456189 28-Jun-2019 Boyang Yu <byu@arista.com>

hwmon: (lm90) Fix max6658 sporadic wrong temperature reading

max6658 may report unrealistically high temperature during
the driver initialization, for which, its overtemp alarm pin
also gets asserted. For certain devices implementing overtemp
protection based on that pin, it may further trigger a reset to
the device. By reproducing the problem, the wrong reading is
found to be coincident with changing the conversion rate.

To mitigate this issue, set the stop bit before changing the
conversion rate and unset it thereafter. After such change, the
wrong reading is not reproduced. Apply this change only to the
max6657 kind for now, controlled by flag LM90_PAUSE_ON_CONFIG.

Signed-off-by: Boyang Yu <byu@arista.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e67776cc 10-Jun-2019 Wolfram Sang <wsa+renesas@sang-engineering.com>

hwmon: (lm90) simplify getting the adapter of a client

We have a dedicated pointer for that, so use it. Much easier to read and
less computation involved.

Reported-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 74ba9207 20-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not write to the free software foundation inc
675 mass ave cambridge ma 02139 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 441 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190520071858.739733335@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 787afaa3 04-Apr-2019 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix build warning

If CONFIG_OF is not enabled, the following build warning is observed.

drivers/hwmon/lm90.c:239:34: warning:
‘lm90_of_match’ defined but not used

Mark lm90_of_match as __maybe_unused to fix the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# a4d41e67 31-Mar-2019 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use HWMON_CHANNEL_INFO macro

The HWMON_CHANNEL_INFO macro simplifies the code, reduces the likelihood
of errors, and makes the code easier to read.

The conversion was done automatically with coccinelle. The semantic patch
used to make this change is as follows.

@r@
initializer list elements;
identifier i;
@@

-u32 i[] = {
- elements,
- 0
-};

@s@
identifier r.i,j,ty;
@@

-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};

@script:ocaml t@
ty << s.ty;
elements << r.elements;
shorter;
elems;
@@

shorter :=
make_ident (List.hd(List.rev (Str.split (Str.regexp "_") ty)));
elems :=
make_ident
(String.concat ","
(List.map (fun x -> Printf.sprintf "\n\t\t\t %s" x)
(Str.split (Str.regexp " , ") elements)))

@@
identifier s.j,t.shorter;
identifier t.elems;
@@

- &j
+ HWMON_CHANNEL_INFO(shorter,elems)

This patch does not introduce functional changes. Many thanks to
Julia Lawall for providing the semantic patch.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 3334851d 10-Dec-2018 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Replace S_<PERMS> with octal values

Replace S_<PERMS> with octal values.

The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/hwmon/.

This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# df8d57bf 24-Feb-2017 Javier Martinez Canillas <javier@osg.samsung.com>

hwmon: (lm90) Add OF device ID table

The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e57959a6 22-Dec-2016 Julia Lawall <Julia.Lawall@lip6.fr>

hwmon: (lm90) use permission-specific DEVICE_ATTR variants

Use DEVICE_ATTR_RW for read/write attributes. This simplifies the source
code, improves readbility, and reduces the chance of inconsistencies.

The conversion was done automatically using coccinelle. It was validated
by compiling both the old and the new source code and comparing its text,
data, and bss size.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
[groeck: Updated description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e9572fdd 02-Jan-2017 Michael Walle <michael@walle.cc>

hwmon: (lm90) fix temp1_max_alarm attribute

Since commit commit eb1c8f4325d5 ("hwmon: (lm90) Convert to use new hwmon
registration API") the temp1_max_alarm and temp1_crit_alarm attributes are
mapped to the same alarm bit. Fix the typo.

Fixes: eb1c8f4325d5 ("hwmon: (lm90) Convert to use new hwmon registration API")
Signed-off-by: Micehael Walle <michael@walle.cc>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# eb1c8f43 18-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Convert to use new hwmon registration API

Reduce driver complexity and size by converting it to
the new hwmon API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c5fcf01b 25-Jul-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Improve error handling

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>


# be9d6374 25-Jul-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add missing assignment

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>


# 589f707c 18-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Drop unnecessary else statements

checkpatch rightfully complains that else after return is unnecessary.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 2f83ab77 18-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use bool for valid flag

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>


# 10bfef47 13-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Read limit registers only once

Read limit registers only once at startup or after errors to improve
driver performance.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 37ad04d7 13-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Simplify read functions

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>


# 6e5f62b9 13-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use devm_hwmon_device_register_with_groups

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>


# 1f17a444 13-Jun-2016 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Use devm_add_action for cleanup

Use devm_add_action where possible to simplify error handling and
cleanup on remove.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b4f21054 09-Jun-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

i2c: add a protocol parameter to the alert callback

.alert() is meant to be generic, but there is currently no way
for the device driver to know which protocol generated the alert.
Add a parameter in .alert() to help the device driver to understand
what is given in data.

This patch is required to have the support of SMBus Host Notify protocol
through .alert().

Tested-by: Andrew Duggan <aduggan@synaptics.com>
For hwmon:
Acked-by: Guenter Roeck <linux@roeck-us.net>
For IPMI:
Acked-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 38bab98a 05-Jun-2016 Wolfram Sang <wsa@kernel.org>

hwmon: (lm90) use proper type for update_interval

The code handles this variable always as unsigned, so adapt the type.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1de8b250 04-Apr-2014 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Convert to use hwmon_device_register_with_groups

Simplify code, reduce code size, and attach hwmon attributes to hwmon device.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <jdelvare@suse.de>


# 084489e6 04-Apr-2014 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Create all sysfs groups in one call

Create all sysfs groups in one call by using sysfs_create_groups
instead of calling sysfs_create_group individually for each group.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <jdelvare@suse.de>


# d89fa686 04-Apr-2014 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Always use the dev variable in the probe function

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <jdelvare@suse.de>


# 742192f5 04-Apr-2014 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Create most optional attributes with sysfs_create_group

With the new hwmon API, all attributes have to be created as groups.
Use sysfs_create_group and sysfs_remove_group instead of device_create_file
and device_remove_file to prepare for the new API.

Exception is the 'pec' attribute which will stay with the i2c device.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <jdelvare@suse.de>


# 7c81c60f 29-Jan-2014 Jean Delvare <khali@linux-fr.org>

Update Jean Delvare's e-mail address

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 3d489ac0 12-Dec-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Unregister hwmon device if interrupt setup fails

Commit 109b1283fb (hwmon: (lm90) Add support to handle IRQ) introduced
interrupt support. Its error handling code fails to unregister the already
registered hwmon device.

Fixes: 109b1283fb532ac773a076748ffccf76a7067cab
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 3e0f964f 15-Nov-2013 Wei Ni <wni@nvidia.com>

hwmon: (lm90) Add power control

The device lm90 can be controlled by the vcc rail.
Adding the regulator support to power on/off the vcc rail.
Enable the "vcc" regulator before accessing the device.

[JD: Rename variables to avoid confusion with registers.]

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 1daaceb2 15-Nov-2013 Wei Ni <wni@nvidia.com>

hwmon: (lm90) Add support for TI TMP451

TI TMP451 is mostly compatible with ADT7461, except for
local temperature low byte and max conversion rate.
Add support to the LM90 driver.

Signed-off-by: Wei Ni <wni@nvidia.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 40465d94 15-Nov-2013 Wei Ni <wni@nvidia.com>

hwmon: (lm90) Use enums for the indexes of temp8 and temp11

Using enums for the indexes and nrs of temp8 and temp11.
This make the code much more readable.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 109b1283 15-Nov-2013 Wei Ni <wni@nvidia.com>

hwmon: (lm90) Add support to handle IRQ

When the temperature exceed the limit range value,
the driver can handle the interrupt.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 072de496 15-Nov-2013 Wei Ni <wni@nvidia.com>

hwmon: (lm90) Define status bits

Add bit defines for the status register. And add a function
lm90_is_tripped() which will read status register and return
tripped or not, then lm90_alert can call it directly, and in the
future the IRQ thread also can use it.

[JD: Adjusted to include all the new MAX6696 status flags.]

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# e41fae2b 15-Nov-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix max6696 alarm handling

Bit 2 of status register 2 on MAX6696 (external diode 2 open)
sets ALERT; the bit thus has to be listed in alert_alarms.
Also display a message in the alert handler if the condition
is encountered.

Even though not all overtemperature conditions cause ALERT
to be set, we should not ignore them in the alert handler.
Display messages for all out-of-range conditions.

Reported-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 78c2c2fe 08-Jul-2013 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Drop redundant safety on cache lifetime

time_after (as opposed to time_after_equal) already ensures that the
cache lifetime is at least as much as requested. There is no point in
manually adding another jiffy to that value, and this can confuse the
reader into wrong interpretation.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Imre Deak <imre.deak@intel.com>


# 2a844c14 09-Jan-2013 Guenter Roeck <linux@roeck-us.net>

hwmon: Replace SENSORS_LIMIT with clamp_val

SENSORS_LIMIT and the generic clamp_val have the same functionality,
and clamp_val is more efficient.

This patch reduces text size by 9052 bytes and bss size by 11624 bytes
for x86_64 builds.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: George Joseph <george.joseph@fairview5.com>
Acked-by: Jean Delvare <khali@linux-fr.org>


# 20f426ff 02-Jun-2012 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Convert to use devm_ functions

Convert to use devm_ functions to reduce code size and simplify the code.

Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>


# f7001bb0 23-Mar-2012 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Restore original configuration if probe function fails

The lm90 driver restores the original chip configuration in its exit function.
However, the chip configuration is not restored if the probe function fails.
Restore it there as well.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# ae544f64 23-Mar-2012 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add support for GMT G781

GMT G781 is a ADM1032-compatible temperature sensor chip.
Add support to the LM90 driver.

Cc: Mike Gorchak <lestat@i.com.ua>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# f36ffeab 23-Mar-2012 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Fix multi-line comments

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# f0967eea 20-Jan-2012 Axel Lin <axel.lin@gmail.com>

hwmon: convert drivers/hwmon/* to use module_i2c_driver()

This patch converts the drivers in drivers/hwmon/* to use the
module_i2c_driver() macro which makes the code smaller and a bit simpler.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Corentin Labbe <corentin.labbe@geomatys.fr>
Cc: Dirk Eibach <eibach@gdsys.de>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Cc: Steve Glendinning <steve.glendinning@smsc.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Guillaume Ligneul <guillaume.ligneul@gmail.com>
Cc: David George <david.george@ska.ac.za>
Cc: "Hans J. Koch" <hjk@hansjkoch.de>
Cc: Marc Hulsman <m.hulsman@tudelft.nl>
Cc: Rudolf Marek <r.marek@assembler.cz>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 6b101116 16-Jan-2012 Guenter Roeck <linux@roeck-us.net>

hwmon: (lm90) Add range check to set_update_interval

When writing the update_interval attribute, the parameter value was
not range checked, which could cause an integer overflow and result
in an arbitrary update interval. Fix by limiting the value range to
<0, 100000>.

Reported-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 179c4fdb 04-Jan-2012 Frans Meulenbroeks <fransmeulenbroeks@gmail.com>

hwmon: replaced strict_str* with kstr*

replaced strict_strtol with kstrtol and
replaced strict_strtuol with kstrtuol

This satisfies checkpatch -f
Compile tested only: no warnings or errors given

Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# b2589ab0 03-Nov-2011 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Make code more readable

Clean up the code to make it more readable:
* Remove reg_ and new_ prefixes from variable names, they made the
names longer, causing extra line breaks, while not adding much
value.
* Introduce struct device dev* = &client->dev in two functions, to
avoid repeating client->dev everywhere in these functions.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 8dc089d6 03-Nov-2011 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Fix warnings

With some configuration option combinations, we get the following
warnings:

drivers/hwmon/lm90.c: In function 'lm90_detect':
drivers/hwmon/lm90.c:1114: warning: 'chip_id' may be used uninitialized
in this function
drivers/hwmon/lm90.c:1114: warning: 'reg_config1' may be used
uninitialized in this function
drivers/hwmon/lm90.c:1114: warning: 'reg_convrate' may be used
uninitialized in this function
drivers/hwmon/lm90.c:1187: warning: 'reg_emerg2' may be used
uninitialized in this function
drivers/hwmon/lm90.c:1187: warning: 'reg_status2' may be used
uninitialized in this function

We can solve these easily by reading the register values first and
checking for errors later. These errors should be very rare, even in
the case of failed detection, so this change has no impact on
performance. And this makes checkpatch.pl happier.

Reported-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>


# f90be42f 24-Jul-2011 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Refactor reading of config2 register

Several vendors implement a second configuration register, which we
check during device detection. Refactor the code to avoid duplication.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Stijn Devriendt <sdevrien@cisco.com>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 6d101c58 24-Jul-2011 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Make SA56004 detection more robust

With a device ID register value of 0, the SA56004 detection is rather
weak. Check several other register too to confirm the detection, as we
do for other supported devices.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Stijn Devriendt <sdevrien@cisco.com>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Stijn Devriendt <sdevrien@cisco.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# a095f687 28-Jul-2011 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Simplify handling of extended local temp register

The optional extended local temperature register can never have
address 0, as this address is already used by another register. Thus
we can get rid of flag LM90_HAVE_LOCAL_EXT and simply rely on
reg_local_ext being non-zero to determine if a given chip has this
extension or not. This makes the code more simple.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Stijn Devriendt <sdevrien@cisco.com>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 2ef01793 06-Jun-2011 Stijn Devriendt <sdevrien@cisco.com>

hwmon: (lm90) Add support for Philips SA56004

Add support for Philips SA56004, an LM86 compatible temperature sensor.

Signed-off-by: Stijn Devriendt <sdevrien@cisco.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 5a4e5e6a 29-Apr-2011 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Add support for ADT7461A and NCT1008

This patch adds support for ADT7461A and NCT1008 to the lm90 driver.
Both chips have identical functionality and report the same manufacturing ID
and device ID values.

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 25985edc 30-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi>

Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>


# c4f99a2b 28-Oct-2010 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Add support for the W83L771W/G

I was wondering if that chip ever existed publicly... Apparently yes,
so add support for it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>


# 0c01b644 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Add support for update_interval sysfs attribute

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 1179324c 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Introduce capability flag to indicate broken ALERT functionality

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 4667bcb8 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Introduce chip parameter structure

Instead of using switch/case and if statements in probe, define chip specific
functionality in a parameter structure array.

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 15b66ab6 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Rearrange code to no longer require forward declarations

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 06e1c0a2 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Add support for max6695 and max6696

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 6948708d 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Add support for extra features of max6659

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 13c84951 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Add explicit support for max6659

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 96512861 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Simplify set_temp11 register calculations

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# b6fc1bac 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Introduce function to delete sysfs files

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 88073bb1 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Introduce device feature bits

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 11e57812 28-Oct-2010 Guenter Roeck <guenter.roeck@ericsson.com>

hwmon: (lm90) Fix checkpatch errors

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 8c3c7a25 27-May-2010 Ira W. Snyder <iws@ovro.caltech.edu>

hwmon: (lm90) Use programmed update rate

The lm90 driver programs the sensor chip to update its readings at 2 Hz
(500 ms between readings). However, the driver only does reads from the
chip at intervals of 2 * HZ (2000 ms between readings). Change the driver
update rate to the programmed update rate.

Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 53de3342 05-Mar-2010 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Add SMBus alert support

Tested successfully with an ADM1032 chip on its evaluation board. It
should work fine with all other chips as well.

At this point this is more of a proof-of-concept, we don't do anything
terribly useful on SMBus alert: we simply log the event. But this could
later evolve into libsensors signaling so that user-space applications
can take an appropriate action.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Trent Piepho <tpiepho@freescale.com>


# 95238364 05-Mar-2010 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Restore configuration on exit

Restore the chip configuration when unloading the driver. This ensures
we don't leave the chip running if it was initially stopped.

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 6771ea1f 05-Mar-2010 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Add support for the Winbond/Nuvoton W83L771AWG/ASG

This chips is found on several Zotac Ion ITX boards, amongst others.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: MC Matti <mcmatti17@googlemail.com>
Cc: Manuel Lamotte-Schubert <mls@pronego.com>


# e5e9f44c 14-Dec-2009 Jean Delvare <khali@linux-fr.org>

i2c: Drop I2C_CLIENT_INSMOD_2 to 8

These macros simply declare an enum, so drivers might as well declare
it themselves. This puts an end to the arbitrary limit of 8 chip types
per i2c driver.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Wolfram Sang <w.sang@pengutronix.de>


# c3813d6a 14-Dec-2009 Jean Delvare <khali@linux-fr.org>

i2c: Get rid of struct i2c_client_address_data

Struct i2c_client_address_data only contains one field at this point,
which makes its usefulness questionable. Get rid of it and pass simple
address lists around instead.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Wolfram Sang <w.sang@pengutronix.de>


# 310ec792 14-Dec-2009 Jean Delvare <khali@linux-fr.org>

i2c: Drop the kind parameter from detect callbacks

The "kind" parameter always has value -1, and nobody is using it any
longer, so we can remove it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Wolfram Sang <w.sang@pengutronix.de>


# 8f2fa77c 09-Dec-2009 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Clean up detect function

As kind is now hard-coded to -1, there is room for code clean-ups.

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 1a51e068 12-Mar-2009 Darrick J. Wong <djwong@us.ibm.com>

hwmon: (lm90) Document support for the MAX6648/6692 chips

Update documentation to prevent further confusion/duplication.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 97ae60bb 26-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Add support for the LM99 16 degree offset

The LM99 differs from the LM86, LM89 and LM90 in that it reports
remote temperatures (temp2) 16 degrees lower than they really are. So
far we have been cheating and handled this in userspace but it really
should be handled by the driver directly.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>


# ec38fa2b 26-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Fix handling of hysteresis value

There are several problems in the way the hysteresis value is handled
by the lm90 driver:

* In show_temphyst(), specific handling of the MAX6646 is missing, so
the hysteresis is reported incorrectly if the critical temperature
is over 127 degrees C.
* In set_temphyst(), the new hysteresis register value is written to
the chip but data->temp_hyst isn't updated accordingly, so there is
a short period of time (up to 2 seconds) where the old hystereris
value will be returned while the new one is already active.
* In set_temphyst(), the critical temperature which is used as a base
to compute the value of the hysteresis register lacks
device-specific handling. As a result, the value of the hysteresis
register might be incorrect for the ADT7461 and MAX6646 chips.

Fix these 3 bugs.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Nate Case <ncase@xes-inc.com>


# 4b4e7a72 17-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Don't spam the kernel log

Degrade the "Unsupported chip" message from info to debug level.
There's nothing wrong with this, so no need to bother the user.
Also make the message slightly more descriptive.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Martyn Welch <martyn.welch@gefanuc.com>


# 271dabf5 17-Oct-2008 Ben Hutchings <bhutchings@solarflare.com>

hwmon: (lm90) Support MAX6646, MAX6647 and MAX6649

These Maxim chips are similar to MAX6657 but use unsigned temperature
values to allow for readings up to 145 degrees.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 9d4d3834 17-Oct-2008 Ben Hutchings <bhutchings@solarflare.com>

hwmon: (lm90) Rename temperature conversion functions to match usage

The encoding of temperatures varies between chips and modes. So do not
use "temp1" or "temp2" in the names of the conversion functions, but
specify the encoding.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Martyn Welch <martyn.welch@gefanuc.com>


# 23b2d477 17-Oct-2008 Nate Case <ncase@xes-inc.com>

hwmon: (lm90) Support ADT7461 in extended mode

Support ADT7461 in extended temperature range mode, which will change
the range of readings from 0..127 to -64..191 degC. Adjust the
register conversion functions accordingly.

Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Martyn Welch <martyn.welch@gefanuc.com>


# cea50fe2 17-Oct-2008 Nate Case <ncase@xes-inc.com>

hwmon: (lm90) Convert some macros to static functions

Use static functions instead of the TEMPx_FROM_REG* and TEMPx_TO_REG*
macros. This will ensure type safety and eliminate any side effects
from arguments passed in since the macros referenced 'val' multiple
times. This change should not affect functionality.

Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Martyn Welch <martyn.welch@gefanuc.com>


# a874a10c 17-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Update datasheet links

Update the links to the datasheet of some of the devices supported by
the lm90 driver. Also remove the links from the driver itself, so that
we don't have to update them twice each time they change.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Martyn Welch <martyn.welch@gefanuc.com>


# 5f502a83 17-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Don't access nonexistent registers on Maxim chips

The Maxim chips supported by the lm90 driver have 8-bit high and low
remote limit values, not 11-bit as the other chips have. So stop reading
from and writing to registers that do not exist on these chips. Also
round the limit values set by the user properly.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Martyn Welch <martyn.welch@gefanuc.com>


# f65e1708 17-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Support the extra resolution bits of MAX6657

The Maxim MAX6657, MAX6658 and MAX6659 have extra resolution bits for
the local temperature measurement. Let the lm90 driver read them and
export them to user-space.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Martyn Welch <martyn.welch@gefanuc.com>


# 6388a388 17-Oct-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Move 16-bit value read to a separate function

Move the code which aggregates two 8-bit register values into a 16-bit
value to a separate function. We'll need to do it a second time soon and
I don't want to duplicate the code.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Martyn Welch <martyn.welch@gefanuc.com>


# 9b0e8526 16-Jul-2008 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Convert to a new-style i2c driver

The new-style lm90 driver implements the optional detect() callback
to cover the use cases of the legacy driver.

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 25e9c86d 17-Feb-2008 Mark M. Hoffman <mhoffman@lightlink.com>

hwmon: normal_i2c arrays should be const

Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# 7b501b1f 03-Jan-2008 Jean Delvare <khali@linux-fr.org>

hwmon: Discard useless I2C driver IDs

Many I2C hwmon drivers define a driver ID but no other code references
these, meaning that they are useless. Discard them, along with a few
IDs which are defined but never used at all.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# e0ae87a4 25-Nov-2007 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Use generic i2c reads during detection

As indirectly reported by Olof Johansson, the lm90 driver uses a
custom i2c read function even during detection, at which point we
don't know yet what device we're talking with. It would make more
sense to only use the generic i2c read function at this point, so
that we don't log irrelevant errors on misdetection.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# 69f2f96d 05-Sep-2007 Jean Delvare <khali@linux-fr.org>

hwmon: (lm90) Export temperature offset values

Now that we have standard sysfs names to export temperature offset
values, add this feature to the lm90 driver. All supported chips
except the MAX6657, MAX6658 and MAX6659 support it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# 1beeffe4 20-Aug-2007 Tony Jones <tonyj@suse.de>

hwmon: Convert from class_device to device

Convert from class_device to device for hwmon_device_register/unregister

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# f5744e37 26-Jul-2007 Guillaume Chazarain <guichaz@yahoo.fr>

hwmon: Fix regression caused by typo in lm90.c

The commit http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=32c82a934759b2c9939c9e25865c2d7d1204b9e8
broke lm90 for my (Asus V6VA) laptop.

Before 2.6.23-rc1 and with the following patch, I get:

[g ~]$ sensors
max6657-i2c-0-4c
Adapter: SMBus I801 adapter at 0400
M/B Temp: +64°C (low = +0°C, high = +127°C)
CPU Temp: +78.9°C (low = +73.2°C, high = +88.2°C)
M/B Crit: +105°C (hyst = +95°C)
CPU Crit: +105°C (hyst = +95°C)

Which regressed into:

[g ~]$ sensors
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.
zsh: 2701 exit 1 sensors

and dmesg contains:

i2c-adapter i2c-0: Unsupported chip (man_id=0x4D, chip_id=0x4D).

It seems to be a typo, as address 0X4F is mentionned nowhere else in the file,
and my chip is actually at 0x4C.

Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>


# 7817a39e 09-Jun-2007 Jean Delvare <khali@linux-fr.org>

hwmon: Fault files naming convention

We have the following naming convention documented in
Documentation/hwmon/sysfs-interface for fault files:

in[0-*]_input_fault
fan[1-*]_input_fault
temp[1-*]_input_fault

Some drivers follow this convention (lm63, lm83, lm90, smsc47m192).
However some drivers omit the "input" part and create files named
fan1_fault (pc87427) or temp1_fault (dme1737). And the new "generic"
libsensors follows this second (non-standard) convention, so it fails
to report fault conditions for drivers which follow the standard.

We want a single naming scheme, and everyone seems to prefer the
shorter variant, so let's go for it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 32c82a93 09-Jun-2007 Rainer Birkenmaier <rainer.birkenmaier@siemens.com>

hwmon/lm90: Add support for the Maxim MAX6680/MAX6681

Signed-off-by: Rainer Birkenmaier <rainer.birkenmaier@siemens.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 0966415d 09-Jun-2007 Jean Delvare <khali@linux-fr.org>

hwmon/lm90: Spelling fix: explicitly

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 0e39e01c 24-Sep-2006 Jean Delvare <khali@linux-fr.org>

hwmon: Fix unchecked return status, batch 4

hwmon: Fix unchecked return status, batch 4

Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().

Note: f71805f actually checked the status from device_create_file
already. However it did not remove the files on device destruction.
It was also an opportunity to use sysfs_create/remove_group instead
of hand-made loops. This makes the changes much more important but
I think the result is worth it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2d45771e 24-Sep-2006 Jean Delvare <khali@linux-fr.org>

hwmon: Add individual alarm files to 4 drivers

hwmon: Add individual alarm files to 4 drivers

Add individual sysfs files for all f71805f, lm63, lm83 and lm90 alarm
and fault conditions. This is a requirement for the planned
chip-independent libsensors. Almost all other hwmon drivers will need
the same improvement.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 9a61bf63 18-Jan-2006 Ingo Molnar <mingo@elte.hu>

[PATCH] hwmon: Semaphore to mutex conversions

convert drivers/hwmon/*.c semaphore use to mutexes.

the conversion was generated via scripts, and the result was validated
automatically via a script as well.

all affected hwmon drivers were build-tested.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2b48716d 06-Dec-2005 Greg Kroah-Hartman <gregkh@suse.de>

[PATCH] I2C: Remove .owner setting from i2c_driver as it's no longer needed

Now that i2c_add_driver() doesn't need the module owner to be set by
hand, we can delete it from the drivers. This patch catches all of the
drivers that I found in the current tree (if a driver sets the .owner by
hand, it's not a problem, just not needed.)

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jean Delvare <khali@linux-fr.org>


# cdaf7934 26-Nov-2005 Laurent Riffard <laurent.riffard@free.fr>

[PATCH] i2c: Drop i2c_driver.{owner,name}, 3 of 11

We should use the i2c_driver.driver's .name and .owner fields
instead of the i2c_driver's ones.

This patch updates the hwmon drivers.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8a994755 26-Nov-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] i2c: Drop i2c_driver.flags, 2 of 3

Just about every i2c chip driver sets the I2C_DF_NOTIFY flag, so we
can simply make it the default and drop the flag. If any driver really
doesn't want to be notified when i2c adapters are added, that driver
can simply omit to set .attach_adapter. This approach is also more
robust as it prevents accidental NULL pointer dereferences.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 90209b42 26-Oct-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: lm90 documentation update

Update the I2C addresses for the ADM1032 and ADT7461 chips.
Also update the links to the Analog Devices web site.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# c3df5806 26-Oct-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: Add PEC support to the lm90 driver

Add PEC support to the lm90 driver. Only the ADM1032 chip supports it,
and in a rather tricky way, which is why this patch comes with
documentation reinforcements. At least, this demonstrates that the new
PEC support logic in i2c-core can properly deal with chips with partial
PEC support.

As enabling PEC causes a significant performance drop, it can be
disabled through a sysfs file (unsurprisingly named "pec").

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8256fe0f 26-Oct-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: Separate the lm90 register read function

Preparatory patch to add PEC support to the lm90 driver. We need a
centralized function to read register values, where the PEC code will
be later inserted. A positive side effect is that read errors are now
handled properly.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# ba9c2e8d 17-Oct-2005 Deepak Saxena <dsaxena@plexity.net>

[PATCH] hwmon: kzalloc conversion

Use kzalloc instead of kmalloc+memset in all hardware monitoring
drivers.

Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# f4b50261 31-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: hwmon vs i2c, second round (06/11)

The only thing left in i2c-sensor.h are module parameter definition
macros. It's only an extension of what i2c.h offers, and this extension
is not sensors-specific. As a matter of fact, a few non-sensors drivers
use them. So we better merge them in i2c.h, and get rid of i2c-sensor.h
altogether.

Signed-off-by: Jean Delvare <khali@linux-fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 2ed2dc3c 31-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] hwmon: hwmon vs i2c, second round (04/11)

i2c_probe and i2c_detect now do the exact same thing and operate on
the same data structure, so we can have everyone call i2c_probe.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 7bef5594 27-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] I2C: refactor message in i2c_detach_client

We could refactor the error message 34 different i2c drivers print if
i2c_detach_client() fails in this function itself. Saves quite a few
lines of code. Documentation is updated to reflect that change.

Note that this patch should be applied after Rudolf Marek's w83792d
patches.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 5071860a 19-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (7/9)

Kill normal_isa in header files, documentation and all chip drivers, as
it is no more used.

normal_i2c could be renamed to normal, but I decided not to do so at the
moment, so as to limit the number of changes. This might be done later
as part of the i2c_probe/i2c_detect merge.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 943b0830 15-Jul-2005 Mark M. Hoffman <mhoffman@lightlink.com>

[PATCH] I2C hwmon: add hwmon sysfs class to drivers

This patch modifies sensors chip drivers to make use of the new
sysfs class "hwmon".

Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 8d5d45fb 02-Jul-2005 Jean Delvare <khali@linux-fr.org>

[PATCH] I2C: Move hwmon drivers (2/3)

Part 2: Move the driver files themselves.

Note that the patch "adds trailing whitespace", because it does move the
files as-is, and some files happen to have trailing whitespace.

From: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>