Commit graph

2542 commits

Author SHA1 Message Date
Axel Lin
fa642d9d6e hwmon: (lm87) Fix vrm write operation
vrm is an u8, so the written value needs to be limited to [0, 255].

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:44:42 -07:00
Axel Lin
db59ac4342 hwmon: (asb100) Fix vrm write operation
vrm is an u8, so the written value needs to be limited to [0, 255].

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:44:36 -07:00
Axel Lin
a4461647f6 hwmon: (adm1026) Fix vrm write operation
vrm is an u8, so the written value needs to be limited to [0, 255].

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:44:36 -07:00
Axel Lin
9c8ae7287a hwmon: (adm1025) Fix vrm write operation
vrm is an u8, so the written value needs to be limited to [0, 255].

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:44:36 -07:00
Axel Lin
eeeafd384f hwmon: (hih6130) Fix missing hih6130->write_length setting
The hih6130->write_length setting was accidently removed by commit
ebc6b9383f3e "hwmon: (hih6130) Convert to devm_hwmon_device_register_with_groups",
fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:40:27 -07:00
Axel Lin
d58e47d787 hwmon: (dme1737) Prevent overflow problem when writing large limits
On platforms with sizeof(int) < sizeof(long), writing a temperature
limit larger than MAXINT will result in unpredictable limit values
written to the chip. Avoid auto-conversion from long to int to fix
the problem.

Voltage limits, fan minimum speed, pwm frequency, pwm ramp rate, and
other attributes have the same problem, fix them as well.

Zone temperature limits are signed, but were cached as u8, causing
unepected values to be reported for negative temperatures. Cache as
s8 to fix the problem.

vrm is an u8, so the written value needs to be limited to [0, 255].

Signed-off-by: Axel Lin <axel.lin@ingics.com>
[Guenter Roeck: Fix zone temperature cache]
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 19:40:15 -07:00
Guenter Roeck
539a719f9b hwmon: (emc6w201) Fix temperature limit range
Temperature limit range is [-127, 127], not [-127, 128].
The wrong range caused a bad limit to be written into the chip
if the limit was set to a value of 128 degrees C or above.

Also use DIV_ROUND_CLOSEST instead of a plain divide operation
to reduce the rounding error when writing temperature limits.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
2014-08-05 17:49:12 -07:00
Axel Lin
e981429557 hwmon: (ads1015) Fix out-of-bounds array access
Current code uses data_rate as array index in ads1015_read_adc() and uses pga
as array index in ads1015_reg_to_mv, so we must make sure both data_rate and
pga settings are in valid value range.
Return -EINVAL if the setting is out-of-range.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 17:49:01 -07:00
Axel Lin
5b96308916 hwmon: (lm92) Prevent overflow problem when writing large limits
On platforms with sizeof(int) < sizeof(long), writing a temperature
limit larger than MAXINT will result in unpredictable limit values
written to the chip. Avoid auto-conversion from long to int to fix
the problem.

The hysteresis temperature range depends on the value of
data->temp[attr->index], since val is subtracted from it.
Use a wider clamp, [-120000, 220000] should do to cover the
possible range. Also add missing TEMP_TO_REG() on writes into
cached hysteresis value.

Also uses clamp_val to simplify the code a bit.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
[Guenter Roeck: Fixed double TEMP_TO_REG on hysteresis updates]
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-05 17:48:52 -07:00
Axel Lin
fce9626cd9 hwmon: (g762) Use of_property_read_u32 at appropriate place
Simplify the code a bit and also improve readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 11:35:40 -07:00
Axel Lin
cc336546dd hwmon: (sis5595) Prevent overflow problem when writing large limits
On platforms with sizeof(int) < sizeof(long), writing a temperature
limit larger than MAXINT will result in unpredictable limit values
written to the chip. Avoid auto-conversion from long to int to fix
the problem.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 09:15:46 -07:00
Axel Lin
2565fb05d1 hwmon: (gpio-fan) Prevent overflow problem when writing large limits
On platforms with sizeof(int) < sizeof(unsigned long), writing a rpm value
larger than MAXINT will result in unpredictable limit values written to the
chip. Avoid auto-conversion from unsigned long to int to fix the problem.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:27:50 -07:00
Axel Lin
18d03f3cbd hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place
Simplify the code a bit and also improve readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Tested-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:03:05 -07:00
Axel Lin
746f68841a hwmon: (lm85) Convert to devm_hwmon_device_register_with_groups
Use 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>
2014-08-04 07:01:41 -07:00
Axel Lin
6fd5dd5837 hwmon: (lm85) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
8eb406100c hwmon: (lm78) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:40 -07:00
Axel Lin
8de2dcc9a1 hwmon: (max6697) Use of_property_read_bool at appropriate places
This slightly improves readability.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
dbd1db7d42 hwmon: (pwm-fan) Make SENSORS_PWM_FAN depend on OF
This driver won't instantiate if OF is not configured, thus add OF dependency.
Also add COMPILE_TEST to increase build testing coverage.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
4e8e75f6a4 hwmon: (pwm-fan) Remove duplicate dev_set_drvdata call
The dev_set_drvdata() call is equivalent to the platform_set_drvdata() call in
next line.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
55bdee69cd hwmon: (nct6775) Remove num_attr_groups from struct nct6775_data
num_attr_groups is only used in nct6775_probe(), make it to be local variable.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
78313b9542 hwmon: (nct6775) Update module description and Kconfig for NCT6106D and NCT6791D
This driver also supports NCT6106D and NCT6791D, thus update module description
and Kconfig accordingly.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
eac83cd9dc hwmon: (adt7411) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:40 -07:00
Axel Lin
398e16db62 hwmon: (g762) Convert to hwmon_device_register_with_groups
Use ATTRIBUTE_GROUPS macro and hwmon_device_register_with_groups() to simplify
the code a bit.

Use hwmon_device_register_with_groups rather than the device managed version to
ensure g762_of_clock_disable() is called after hwmon_device_unregister().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:40 -07:00
Axel Lin
9dd304f86b hwmon: (emc2103) Convert to devm_hwmon_device_register_with_groups
Use 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>
2014-08-04 07:01:40 -07:00
Axel Lin
e70198acf8 hwmon: (smsc47m1) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
166f72966d hwmon: (smsc47m192) Convert to devm_hwmon_device_register_with_groups
Use 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>
2014-08-04 07:01:39 -07:00
Axel Lin
94314e2593 hwmon: (smsc47m192) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
28681d71e1 hwmon: (max1668) Make max1668_addr_list array const
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
7edc8cc19f hwmon: (max6639) Make normal_i2c array const
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Roland Stigge <stigge@antcom.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
86fd260e0b hwmon: (thmc50) Convert to devm_hwmon_device_register_with_groups
Use 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>
2014-08-04 07:01:39 -07:00
Axel Lin
9b38a66e1a hwmon: (thmc50) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
3048577609 hwmon: (adt7470) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:39 -07:00
Axel Lin
9027d933a9 hwmon: (adt7470) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Axel Lin
573bfe67ca hwmon: (adt7462) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:39 -07:00
Axel Lin
a2cc242823 hwmon: (adt7462) Avoid forward declaration
Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:39 -07:00
Kamil Debski
d82d57767c hwmon: Add pwm-fan driver
The pwm-fan driver enables control of fans connected to PWM lines.
This driver uses the PWM framework, so it is compatible with all
PWM devices that provide drivers through the PWM framework.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Reviewed-by: Varka Bhadram <varkabhadram@gmail.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
[Guenter Roeck: Last argument to devm_of_pwm_get is pointer, use NULL]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Axel Lin
7a7176aa4b hwmon: (asc7621) Make map tables const
Map tables are never changed, so it is safe to make them const.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: George Joseph <george.joseph@fairview5.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Axel Lin
f073b99427 hwmon: (ds620) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:38 -07:00
Axel Lin
a7b30ea500 hwmon: (max16065) Use PTR_ERR_OR_ZERO
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Axel Lin
b8d5689830 hwmon: (sht21) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:38 -07:00
Aravind Gopalakrishnan
4395d78056 hwmon: (fam15h_power) Remove needless pci dev id
PCI_DEVICE_ID_AMD_16H_NB_F4 can be obtained from it's
definition in pci_ids.h. So we don't have to define it
again here.

Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Neelesh Gupta
24c1aa8587 hwmon: (powerpc/powernv) hwmon driver for power, fan rpm, voltage and temperature
This patch adds basic kernel support for reading power values, fan
speed rpm, voltage and temperature data on powernv platforms which
will be exported to user space through sysfs interface.

Test results:
-------------
[root@tul163p1 ~]# sensors
ibmpowernv-isa-0000
Adapter: ISA adapter
fan1:        5465 RPM  (min =    0 RPM)
fan2:        5152 RPM  (min =    0 RPM)
fan3:        5521 RPM  (min =    0 RPM)
fan4:        4891 RPM  (min =    0 RPM)
fan5:           0 RPM  (min =    0 RPM)
fan6:           0 RPM  (min =    0 RPM)
fan7:        7480 RPM  (min =    0 RPM)
fan8:        7944 RPM  (min =    0 RPM)
temp1:        +39.0°C  (high =  +0.0°C)
power1:      190.00 W

[root@tul163p1 ~]# ls /sys/devices/platform/
alarmtimer  ibmpowernv.0  power  rtc-generic  serial8250  uevent
[root@tul163p1 ~]# ls /sys/devices/platform/ibmpowernv.0/hwmon/hwmon0/
device	    fan2_min	fan4_min    fan6_min	fan8_min   power
fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent
[root@tul163p1 ~]# ls /sys/class/hwmon/hwmon0/
device	    fan2_min	fan4_min    fan6_min	fan8_min   power
fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent
[root@tul163p1 ~]#

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Zhu, Richard \(NSN - CN/Beijing\)
a8bfeceb0c hwmon: (pmbus) Add tps40422 front-end driver
For TI power management chip TPS40422, READ_TEMPERATURE_2 command is supported on
page 1 of the chip, but the original driver(pmbus.c) only tried to detect this command
on page 0, this will lead to a result that the temperature sensor in page 1 couldn't
be detected. This change is to isolate the tps40422 driver from pmbus.c into a solo
front-end driver.

Signed-off-by: Zhu Laiwen <richard.zhu@nsn.com>
[Guenter Roeck: Dropped unnecessary license text (fixes checkpatch warning)]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:38 -07:00
Guenter Roeck
012cb5e257 hwmon: (tmp421) Drop FSF mailing address
The FSF mailing address can and will change over time,
so drop it.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
2014-08-04 07:01:38 -07:00
Guenter Roeck
05c77ab240 hwmon: (tmp421) Add support for TMP441 and TMP442
TMP441 and TMP442 are compatible to TMP421 and TMP422.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
2014-08-04 07:01:38 -07:00
Guenter Roeck
a63ee9d83b hwmon: (tmp421) Strengthen detect function
Not all supported chips support the entire I2C address range.
Only accept specific chips at the addresses supported by that chip.
Check for invalid values in conversion rate and status registers.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
2014-08-04 07:01:37 -07:00
Axel Lin
e47c39b3a8 hwmon: (g760a) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:37 -07:00
Axel Lin
15ac4ddb32 hwmon: (g760a) Avoid forward declaration
Move g760a_driver to proper place to avoid forward declaration.
Also move g760a_id table close to g760a_driver.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04 07:01:37 -07:00
Axel Lin
715f69bef1 hwmon: (adm9240) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:37 -07:00
Axel Lin
8280325288 hwmon: (lineage-pem) Convert to devm_hwmon_device_register_with_groups
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>
2014-08-04 07:01:37 -07:00