If dev_kcalloc fails to allocate hw_dev->groups then the current
exit path is a direct return, causing a leak of resources such
as hwdev and ida is not removed. Fix this by exiting via the
free_hwmon exit path that performs the necessary resource cleanup.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
We should only dereference "data" after we check if it is an error
pointer.
Fixes: 54187ff9d7 ('hwmon: (max31790) Convert to use new hwmon registration API')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Unlike the temperature thresholds the temperature data is a 9-bit signed
value. This allows and additional 0.5 degrees of precision on the
reading but makes handling negative values slightly harder. In order to
have sign-extension applied correctly the 9-bit value is stored in the
upper bits of a signed 16-bit value. When presenting this in sysfs the
value is shifted and scaled appropriately.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
- New hwmon registration API, including ports of several drivers
to the new API
- New hwmon driver for APM X-Gene SoC
- Added support for UCD90160, DPS-460, DPS-800, and SGD009 PMBUs chips
- Various cleanups, minor improvements, and fixes in several drivers
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJX8cQ6AAoJEMsfJm/On5mBlWIP/RpA4b05gsYOG1SVW/SuZZPu
IJfFkvGgOORgMS0gg8bNk3WyNNnqinbB4A6xucR/7Q7gRyk+3NYR6mNIsyP3UcAm
KHJF9jgUr02vO6reMGGrqrR3cQ14omHgHqXBWQny7JkZ3/6Xyvg/LuarAZ+ZsUfp
cNALIBsHoxyBSF4W7g5PJILtVbA+aW854CQ7UU/S0I2rjR9cqLu9HHvPUeYIazfO
Tn4XM1vZCPLH5OhvIRURCy7FaZjwmxhPZhgF5fqAgDUF0VTQAhiOZB9jcz5NQq2q
sSzlXSd2qqdJSTabtaBDl3O9GsfFrtT0LsFT0Rycx9JedgbV+Euy240uGVUnbHdT
Gh8TVmOYx6qldDj/Hu5DF+kKnIH8vL6fp5blA6b/3EKwv14MUBNC/hxrmOcxyo5T
qBnos0FlF9Ut4QLdRWM0rorZkCWxJWCXV8CvPX79b8iospKD/+Fgr69z7UgZuljA
rcXZJR65oz4cJGMFr4dR+CcC0y2Jqqn5mcQAaGSR0RcII6EpSa+3Zb+2nBE4VGyQ
vZpmxEEjMu9C8SI5DAczLwIMOsW4/pTTB6f8lLKiKRM2eJ7mAyk0KCF+9JIaKjaL
qigWHlJI9FpXQiuek+pMXTVBTzs6fO/NSVfPUfEyAoyyuQePCjqVsQdn/h+lzQHC
1FiFIvnzlxb4ESZ5pfS1
=FLdn
-----END PGP SIGNATURE-----
Merge tag 'hwmon-for-linus-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
- New hwmon registration API, including ports of several drivers to the
new API
- New hwmon driver for APM X-Gene SoC
- Added support for UCD90160, DPS-460, DPS-800, and SGD009 PMBUs chips
- Various cleanups, minor improvements, and fixes in several drivers
* tag 'hwmon-for-linus-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (54 commits)
hwmon: (nct6775) Add support for multiple virtual temperature sources
hwmon: (adt7470) No need for additional synchronization on kthread_stop()
hwmon: (lm95241) Update module description to include LM95231
hwmon: (lm95245) Select REGMAP_I2C
hwmon: (ibmpowernv) Fix label for cores numbers not threads
hwmon: (adt7470) Allow faster removal
hwmon: (adt7470) Add write support to alarm_mask
hwmon: (xgene) access mailbox as RAM
hwmon: (lm95245) Use new hwmon registration API
hwmon: (lm95241) Convert to use new hwmon registration API
hwmon: (jc42) Convert to use new hwmon registration API
hwmon: (max31790) Convert to use new hwmon registration API
hwmon: (nct7904) Convert to use new hwmon registration API
hwmon: (ltc4245) Convert to use new hwmon registration API
hwmon: (tmp421) Convert to use new hwmon registration API
hwmon: (tmp102) Convert to use new hwmon registration API
hwmon: (lm90) Convert to use new hwmon registration API
hwmon: (lm75) Convert to use new hwmon registration API
hwmon: (xgene) Fix crash when alarm occurs before driver probe
hwmon: (iio_hwmon) defer probe when no channel is found
...
For virtual temperatures, the actual temperature values are written
by software, presumably by the BIOS. This functionality is (as of
right now) supported on NCT6791D, NCT6792D, and NCT6793D. On those chips,
the temperatures are written into registers 0xea..0xef on page 0.
This is known to be used on some Asus motherboards, where the actual
temperature source can be configured in the BIOS.
Report the 'virtual' temperatures for all monotoring sources to address
this situation.
Example for the resulting output (as seen with the 'sensors' command):
nct6791-isa-0290
Adapter: ISA adapter
...
Virtual_TEMP: +31.0°C
PECI Agent 0: +38.5°C
Virtual_TEMP: +32.0°C
...
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
The kthread_stop() waits for the thread to exit. There is no need for an
additional synchronization needed to join on the kthread.
The completion was added by 89fac11cb3 ("adt7470: make automatic fan
control really work").
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This driver now uses regmap APIs, so it needs to select REGMAP_I2C.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Currently the label says "Core" but lists the thread numbers. This
ends up looking like this:
# cat /sys/class/hwmon/hwmon0/temp[1-4]_label
Core 0-7
Core 8-15
Core 16-23
Core 24-31
This is misleading as it looks like it's cores 0-7 when it's actually
threads 0-7.
This changes the print to just give the core number, so the output now
looks like this:
# cat /sys/class/hwmon/hwmon0/temp[1-4]_label
Core 0
Core 8
Core 16
Core 24
Signed-off-by: Michael Neuling <mikey@neuling.org>
Acked-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
adt7470_remove will wait for the update thread to complete before
returning. This had a worst-case time of up to the user-configurable
auto_update_interval.
Replace msleep_interruptible with set_current_state and schedule_timeout
so that kthread_stop will interrupt the sleep.
Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Add write support for the alarm_mask. A base of 0 is provided so that
either hex or decimal can be used. The hex format when reading alarm_mask
is unchanged.
Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
The newly added hwmon driver fails to build in an allmodconfig
kernel:
ERROR: "memblock_is_memory" [drivers/hwmon/xgene-hwmon.ko] undefined!
According to comments in the code, the mailbox is a shared memory region,
not a set of MMIO registers, so we should use memremap() for mapping it
instead of ioremap or acpi_os_ioremap, and pointer dereferences instead
of readl/writel.
The driver already uses plain kernel pointers, so it's a bit unusual
to work with functions that operate on __iomem pointers, and this
fixes that part too.
I'm using READ_ONCE/WRITE_ONCE here to keep the existing behavior
regarding the ordering of the accesses from the CPU, but note that
there are no barriers (also unchanged from before).
I'm also keeping the endianness behavior, though I'm unsure whether
the message data was supposed to be in LE32 format in the first
place, it's possible this was meant to be interpreted as a byte
stream instead.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Hoan Tran <hotran@apm.com>
Tested-by: Hoan Tran <hotran@apm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Simplify code and reduce code size by using the new hwmon
registration API.
Other changes:
- Convert to use regmap, and drop local caching. This avoids reading
registers unnecessarily, and uses regmap for caching of non-volatile
registers.
- Add support for temp2_max, temp2_max_alarm, temp2_max_hyst, and
temp2_offset.
- Order include files alphabetically
- Drop FSF address
- Check errors from register read and write functions and report
to userspace.
- Accept negative hysteresis values. While unlikely, a maximum limit
_can_ be set to a value smaller than 31 degrees C, which makes negative
hysteresis values possible.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>