Commit graph

2938 commits

Author SHA1 Message Date
Guenter Roeck
fcc448cfe4 hwmon: (jc42) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:18 -07:00
Guenter Roeck
54187ff9d7 hwmon: (max31790) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:18 -07:00
Guenter Roeck
d65a5102a9 hwmon: (nct7904) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:18 -07:00
Guenter Roeck
a584287cd2 hwmon: (ltc4245) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:18 -07:00
Guenter Roeck
bb43cc45da hwmon: (tmp421) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:18 -07:00
Guenter Roeck
0208531d90 hwmon: (tmp102) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Guenter Roeck
eb1c8f4325 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>
2016-09-08 21:34:17 -07:00
Guenter Roeck
08b0243381 hwmon: (lm75) Convert to use new hwmon registration API
Simplify code and reduce code size by using the new hwmon
registration API.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
hotran
2ca492e22c hwmon: (xgene) Fix crash when alarm occurs before driver probe
The system crashes during probing xgene-hwmon driver when temperature
alarm interrupt occurs before.
It's because
 - xgene_hwmon_probe() requests mailbox channel which also enables
   the mailbox interrupt.
 - As temperature alarm interrupt is pending, ISR runs and crashes when
   accesses into invalid resourse as unmapped PCC shared memory.

This patch fixes this issue by saving this alarm message and scheduling a
bottom handler after xgene_hwmon_probe() finish.

Signed-off-by: Hoan Tran <hotran@apm.com>
Reported-by: Itaru Kitayama <itaru.kitayama@riken.jp>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Quentin Schulz
9417fefe6f hwmon: (iio_hwmon) defer probe when no channel is found
iio_channel_get_all returns -ENODEV when it cannot find either phandles and
properties in the Device Tree or channels whose consumer_dev_name matches
iio_hwmon in iio_map_list. The iio_map_list is filled in by iio drivers
which might be probed after iio_hwmon.

It is better to defer the probe of iio_hwmon if such error is returned by
iio_channel_get_all in order to let a chance to iio drivers to expose
channels in iio_map_list.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Mike Looijmans
20005cc58d hwmon: (max6650) Allow fan shutdown and initial rpm target
The fan can be stopped by writing "3" to pwm1_enable in sysfs.

Add devicetree property for early initialization of the fan controller
to prevent overheating, for example when resetting the board while the
fan was completely turned off.

Also improve error reporting, I2C failures were ignored while writing
new values.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Mike Looijmans
a6cdeefeca hwmon: (max6650) Add devicetree support
Parse devicetree parameters for voltage and prescaler setting. This allows
using multiple max6550 devices with varying settings, and also makes it
possible to instantiate and configure the device using devicetree.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Jean Delvare
d5f3f6c812 hwmon: (it87) Drop useless comments
Remove the index comments at the end of it87_attributes_in. They
serve no purpose (as there is no reference to them in
it87_in_is_visible) and some of them were obviously wrong.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:17 -07:00
Matt Weber
50b2b02c40 hwmon: (ucd9000) Add support for UCD90160 Power Supply Sequencer
The UCD90160 Power Supply Sequencer reuses the existing register layout,
so just an id addition was required.

Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Ronak Desai <ronak.desai@rockwellcollins.com>
[groeck: Updated description, ordered alphabetically, added documentation]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Markus Elfring
43943ebb9f hwmon: (scpi) Delete unnecessary assignment for the field "owner"
The field "owner" is set by the core.
Thus delete an unneeded initialisation.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Thilo Cestonaro
2d5aee433d hwmon: (ftsteutates) Add i2c detect functionality
Signed-off-by: Thilo Cestonaro <thilo@cestona.ro>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
hotran
ed42cfa881 hwmon: Add xgene hwmon driver
This patch adds hardware temperature and power reading support for
APM X-Gene SoC using the mailbox communication interface.

Signed-off-by: Hoan Tran <hotran@apm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Guenter Roeck
86430c1a66 hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sys
If both hwmon and thermal_sys are built as modules, and
CONFIG_THERMAL_HWMON is enabled, the following cyclic module dependency
is reported.

depmod: ERROR: Found 2 modules in dependency cycles!
depmod: ERROR: Cycle detected: hwmon -> thermal_sys -> hwmon

Fixes: e4bce763adb2 ("hwmon: (core) New hwmon registration API")
Reported-by: Vignesh R <vigneshr@ti.com>
Cc: Keerthy J <j-keerthy@ti.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Joshua Scott
aa18cc911a hwmon: (adt7470) Expose PWM frequency to sysfs
The ADT7470 supports a variety of PWM frequencies. This patch allows the
frequency to be configured and viewed through the sysfs entry pwm1_freq.

Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Daniel Golle
30fe976fe7 hwmon: (ltc4151) Make shunt-resistor configurable
Allow to specify the resistance of the attached shunt via DT by
adding the shunt-resistor property. Fall-back to the previous
default (1 mOhm) if unset.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
[groeck: Fixed 'line over 80 columns' checkpatch warning]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Guenter Roeck
fc72af3ad4 hwmon: (nct6775) Do not accept force_id unless chip is found
Since commit 698a7c24a5 ("hwmon: (nct6775) Support two SuperIO chips
in the same system"), the driver supports two Super-IO chips. This has
the undesirable side effect that force_id always detects a second chip
at address 0xfff8, even if no chip exists at that address.

nct6775: Found NCT6793D or compatible chip at 0x4e:0xfff8

If no chip at all is found at a given SIO address, it does not make sense
to instantiate it. Limit force_id to only work if some chip is found,
that is if the chip ID returns a value other than 0xffff.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:16 -07:00
Guenter Roeck
f9f7bb3a0e hwmon: (core) Add basic pwm attribute support to new API
Add basic pwm attribute support (no auto attributes) to new API.

Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
8faee73f92 hwmon: (core) Add fan attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
6bfcca44a6 hwmon: (core) Add energy and humidity attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
b308f5c744 hwmon: (core) Add power attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
9b26947ce5 hwmon: (core) Add current attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
00d616cf87 hwmon: (core) Add voltage attribute support to new API
Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
d560168b5d hwmon: (core) New hwmon registration API
Up to now, each hwmon driver has to implement its own sysfs attributes.
This requires a lot of template code, and distracts from the driver's core
function to read and write chip registers.

To be able to reduce driver complexity, move sensor attribute handling
and thermal zone registration into hwmon core. By using the new API,
driver code and data size is typically reduced by 20-70%, depending
on driver complexity and the number of sysfs attributes supported.

With this patch, the new API only supports thermal sensors. Support for
other sensor types will be added with subsequent patches.

Acked-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
c9ebbe6f23 hwmon: (core) Order include files alphabetically
Ordering include files alphabetically makes it easier to add new ones.
Stop including linux/spinlock.h and linux/kdev_t.h since both are not
needed.

Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
5e7f5994bd hwmon: (ntc_thermistor) Use devm_hwmon_device_register_with_groups
Simplify code, reduce code size, and drop remove function as no longer
needed.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:15 -07:00
Guenter Roeck
48001525c9 hwmon: (ntc_thermistor) Use dev instead of &pdev->dev where possible
Instead of repeatedly accessing &pdev->dev, use a local variable dev
instead where possible. Also drop 'dev' from private data since it is
unnecessary.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
6402085676 hwmon: (ntc_thermistor) Use devm_iio_channel_get
Use devm_iio_channel_get() instead of iio_channel_get to simplify error
handling and device removal.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Vadim Pasternak
cc00decf0e hwmon: (pmbus) Add explicit support for DPS-460, DPS-800, and SGD009
Provide support for PSU DPS-460, DPS-800 from Delta Electronics, INC
and for SGD009 from Acbel Polytech, INC.

These devices do not support the STATUS_CML register, and reports a
communication error in response to this command. For this reason,
the status register check is disabled for these controllers.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Michael Walle
a95da110cd hwmon: (adt7411) add external thermal diode support
If the EXT_TDM bit is set, the chip supports a second temperature sensor
instead of two voltage sensors.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
637ab157d4 hwmon: (lm95241) Use more accurate limits
The lower temperature limit is -128 degrees C. The supported upper limits
are 127.875 or 255.875 degrees C. Also, don't fail if a value outside
the supported range is provided when setting a temperature limit.
Instead, clamp the provided value to the available value range.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
e8172a9381 hwmon: (lm95241) Use BIT macro where appropriate
Drop some of the SHIFT defines since shift is implied with BIT().

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
054f3040e4 hwmon: (lm95241) Drop FSF address
The FSF address may change, and providing it does not add any value.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
4b2ea08be9 hwmon: (lm95241) Order include files alphabetically
Simplify detecting duplicate include files and finding the right place
for adding new ones.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
090a7f8efe hwmon: (lm95241) Add support for fault attributes
The chip reports if remote diodes are present, which can be used for
the fault attrributes.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Guenter Roeck
f48ccb26e2 hwmon: (lm95241) Fix overflow problems, write conversion rate to chip
Writing the update_interval attribute could result in an overflow if
a number close to the maximum unsigned long was written. At the same
time, even though the chip supports setting the conversion rate,
the selected conversion rate was not actually written to the chip.

Fix the second problem by selecting valid (supported) conversion rates,
and writing the selected conversion rate to the chip. This also fixes the
first problem, since arbitrary conversion rates are now converted to
actually supported conversion rates.

Also, set the default chip conversion rate to 1 second. Previously, the
chip was configured for continuous conversion, but readings were only
retrieved every seond, which doesn't make much sense. If we only read a
value from the chip every second, we can as well save some power and only
convert in one-second intervals.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08 21:34:14 -07:00
Jean Delvare
3c3292634f hwmon: (it87) Add missing sysfs attribute group terminator
Attribute array it87_attributes_in lacks its NULL terminator,
causing random behavior when operating on the attribute group.

Fixes: 5292971563 ("hwmon: (it87) Use is_visible for voltage sensors")
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-29 05:31:31 -07:00
Guenter Roeck
aa8b187eea hwmon: (it87) Features mask must be 32 bit wide
Coverity reports:

result_independent_of_operands: data->features & (65536UL /* 1UL << 16 */)
is always 0 regardless of the values of its operands. This occurs as the
logical operand of if.

data->features needs to be 32 bit wide since there are more than 16 features.

Fixes: cc18da79d9 ("hwmon: (it87) Support up to 6 temperature sensors ... ");
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-08-11 18:35:47 -07:00
Linus Torvalds
2790aed095 hwmon updates for v4.8 (take 2)
Improved error handling in  tmp102, lm75, and lm90 drivers
 Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXnnZHAAoJEMsfJm/On5mBIgsQAK1o7j1ODYlvA4MONJ1MtBpq
 ojO7iELtpqeR2EIB1vHE3bNvIpwH7gdYcPAnXKeWj5OKCnliAYlYhC1RptZpyvaX
 6/GQrn93G2KHkkktbtlrs2pSzuzt8eFLrgzrvkPzNFjMEAa73hi7yO1Tt67urS0H
 t3crr0rbX4448l1taqjiB8vMKvBK6pL9Nq61oPks0FVaBewRQKnmHqyZsKd6CtcN
 Wlqy0D0ZASs0xWI1MlVVOqvBHXEAHb0UGpBlHtUeU+oTDpX7EMPbhev5vZYlBa95
 ot7PfGo+gh5f/oiFoIJ1m96+zdvujT+apAHZrquFzlBn0WhkQRMZlItoXqOkw/cn
 W+ybTgDbxvU/vmldPZk5eSej8RCK8omA0wx9d1zNWpRERUiUjwjetFZAnNltQarN
 twMor52GM1L7frLeno0gYyo3VqrCWQspmE4UDqhsLln0Z1k7aMKxW61Ev4xRKEMX
 MNaBAG83J7TPDpFKV3A/yT0nOgfmz915QQ9MFFa0RpY5ob439tC/wRsOib09AsNm
 hbCbyzNH3WnSxB7hZ1iaj9QpymmKt7G1BuKob2gA4S5VS1UtWXx9SHOYS3rmCgwV
 CGY3EpocTtjDkmx0v7aYoDmebLj117CXXFOK73tGmcK48CWjLt4RduR28Q5RyEgz
 1wSA31hiF++O+g+SvKlT
 =cv+q
 -----END PGP SIGNATURE-----

Merge tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull more hwmon updates from Guenter Roeck:

 - Improved error handling in tmp102, lm75, and lm90 drivers

 - Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers

* tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (adt7411) set sane values for CFG1 and CFG3
  hwmon: (iio_hwmon) fix memory leak in name attribute
  hwmon: (ftsteutates) Fix potential memory access error
  hwmon: (tmp102) Improve error handling
  hwmon: (lm75) Improve error handling
  hwmon: (lm90) Improve error handling
  hwmon: (lm90) Add missing assignment
  hwmon: (sht3x) set initial jiffies to last_update
2016-08-01 16:49:13 -04:00
Michael Walle
601807bbb7 hwmon: (adt7411) set sane values for CFG1 and CFG3
According to the datasheet we have to set some bits as 0 and others as 1.
Make sure we do this for CFG1 and CFG3.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:02:52 -07:00
Quentin Schulz
5d17d3b4bb hwmon: (iio_hwmon) fix memory leak in name attribute
The "name" variable's memory is now freed when the device is destructed
thanks to devm function.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: e0f8a24e0e ("staging:iio::hwmon interface client driver.")
Fixes: 61bb53bcbd ("hwmon: (iio_hwmon) Add support for humidity sensors")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:02:52 -07:00
Guenter Roeck
4c8702b3cd hwmon: (ftsteutates) Fix potential memory access error
Using set_bit() to set a bit in an integer is not a good idea, since
the function expects an unsigned long as argument, which can be 64 bit
wide. Coverity reports this problem as

>>>     CID 1364488:  Memory - illegal accesses  (INCOMPATIBLE_CAST)
>>>     Pointer "&ret" points to an object whose effective type is "int"
>>>	(32 bits, signed) but is dereferenced as a wider "unsigned
+long" (64 bits, unsigned).  This may lead to memory corruption.
245                     set_bit(1, (unsigned long *)&ret);

Just use BIT instead.

Cc: Thilo Cestonaro <thilo@cestona.ro>
Fixes: 08426eda58 ("hwmon: Add driver for FTS BMC chip "Teutates"")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:02:51 -07:00
Guenter Roeck
1aa4f0289f hwmon: (tmp102) Improve error handling
Use devm_add_action_or_reset() instead of devm_add_action(), and
check its return code.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:02:51 -07:00
Guenter Roeck
90e2b545ce hwmon: (lm75) Improve error handling
Use devm_add_action_or_reset() instead of devm_add_action(), and
check its return value.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:02:51 -07:00
Guenter Roeck
c5fcf01bcf 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>
2016-07-31 15:02:51 -07:00
Guenter Roeck
be9d6374a7 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: 10bfef47bd ("hwmon: (lm90) Read limit registers only once")
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-07-31 15:01:06 -07:00