Commit Graph
643 Commits
Author SHA1 Message Date
Michal Suchanek b76cd8a5f6 sysfs: Specific match has to go before generic match
This is not really a problem when the specific scaling factors happen to
be for factors not matched by a generic match but this may not hold in
general over time.

Fixes: 1bd92120 ("Fill the magnitude field of dynamically generated device entries.")
2023-12-27 13:17:16 +01:00
Michal Suchanek 43b6101bb0 sysfs: Expand filename buffer to quiet warning
The GCC heurisitc says that the buffer can overflow by 2 bytes, expand
it.
2023-12-26 16:35:46 +01:00
Michal Suchanek 82ca61b38a sysfs: remove unused variable
Fixes: e5e053bb ("libsensors: Avoid non-symlink sysfs device entries")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2023-12-25 19:34:29 +01:00
hramrach 7602fa5ff7 Merge pull request 'Add support for static only build' (#254) from ffontaine/master into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/254
2023-12-24 12:43:47 +01:00
hramrach b5f7b4c7c1 Merge pull request 'Tiny cleanup' (#361) from a1346054/fixes into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/361
2023-12-24 12:41:54 +01:00
Michal Suchanek c91425c121 Merge branch 'thomab/freq' of ~/gitea/data/gitea-repositories/hramrach/lm-sensors 2023-12-24 12:28:52 +01:00
hramrach fbdf135806 Merge pull request 'sensors: Add support for rated values' (#358) from cpackham-atlnz/rated-values into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/358
2023-12-24 12:24:56 +01:00
hramrach e7ecb0b92f Merge pull request 'Pwm' (#363) from Wer-Wolf/pwm into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/363
2023-12-24 12:06:18 +01:00
hramrach 9b1a3974bb Merge pull request 'Add support for dev_name formatted like "a000000.wifi"' (#410) from 7217043955/master into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/410
2023-12-24 11:59:38 +01:00
hramrach 6386d4632e Merge pull request 'Fix sensors.conf syntax documentation' (#437) from Camille019/master into master
Reviewed-on: http://localhost:8888/hramrach/lm-sensors/pulls/437
2023-12-24 11:54:00 +01:00
hramrach 5ef5910943 Merge pull request 'libsensors: support SDIO devices' (#444) from wens/libsensors-sdio into master 2023-12-24 11:51:36 +01:00
Fred aa2dbf2501 Allow subfeatures to be ignored too 2023-11-06 12:29:33 -05:00
Chen-Yu Tsai c3ce1320aa libsensors: Add support for SENSORS_BUS_TYPE_SDIO
Some SDIO drivers, namely WiFi adapter drivers, include hwmon support.

Add support for parsing the device name, so they don't get treated as
platform / virtual devices.

Signed-off-by: Chen-Yu Tsai <wenst@google.com>
2023-05-08 15:03:26 +08:00
Chen-Yu Tsai e5e053bbb7 libsensors: Avoid non-symlink sysfs device entries
Devices under the MMC / SDIO bus have a "device" entry that is not a
symbolic link; instead it contains the device ID of the SDIO device.
This causes the sysfs parsing code in libsensors to error out, as it
expects all "device" entries be symbolic links to the underlying device.

Check for non-symlink entries before calling realpath() to avoid using
it as a valid device link.

Signed-off-by: Chen-Yu Tsai <wenst@google.com>
2023-05-08 14:38:41 +08:00
Camille019 ecb9779243 Fix sensors.conf syntax documentation
Removes an extra third NAME in the bus syntax description to match the Bus statement documentation and implementation.
2023-04-01 17:01:14 +02:00
7217043955 6da486d741 Add support for dev_name formatted like "a000000.wifi" 2022-09-06 15:48:11 +08:00
Armin Wolf 109b988f1a libsensors: Add support for pwm
Add support for the pwm sensor interface.
This includes support for pwm[1-*], pwm[1-*]_enable,
pwm[1-*]_mode and pwm[1-*]_freq.
2021-08-28 07:58:54 +02:00
a1346054 92e1538a19 Trim trailing whitespace
Making sure that none of the actual test files were touched.
2021-08-24 22:19:37 +00:00
Chris Packham 88f6c5ec9b sensors: Add support for rated values
Sysfs attributes for rated values were recently added to the kernel[1].
This adds support for displaying them in lm-sensors.

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e8e61235

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
2021-08-12 15:07:38 +12:00
thomb 543632712e libsensors + sensors: Add freq_input support 2021-06-21 20:54:18 +02:00
Hoan Tran 00a5fadd2e Add ISA ACPI sensor driver name support
ACPI hwmon sensor driver name has a different format such as
	APMC0D29:00
	APMC0D29:01
compared with DTB. This patch supports this format and gives
the correct device address as below

apm_xgene-isa-0000   => APMC0D29:00
Adapter: ISA adapter
SoC Temperature:  +35.0°C
CPU power:        11.00 W
IO power:         20.00 W

apm_xgene-isa-0001   => APMC0D29:01
Adapter: ISA adapter
SoC Temperature:  +33.0°C
CPU power:        13.00 W
IO power:         23.83 W

Signed-off-by: Hoan Tran <hoan@os.amperecomputing.com>
2020-08-20 18:28:17 +02:00
Fabrice Fontaine e31cb3b2f8 Add support for static only build
This patch adds support for a BUILD_SHARED_LIB variable that allows to
enable/disable the build of the shared library, in order to support
static-only builds.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/lm-sensors/0001-static-build.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-07-13 11:30:36 +02:00
Jean Delvare 4ab7331755 libsensors: Prevent warning with glibc >= 2.20
Since glibc 2.20, the usage of _BSD_SOURCE is deprecated. Fix it like
described here:

https://sourceware.org/glibc/wiki/Release/2.20#Deprecation_of__BSD_SOURCE_and__SVID_SOURCE_feature_macros

Inspired from a similar patch by Wolfram Sang for i2c-tools.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
2019-09-02 13:42:00 +02:00
Ondřej Lysoněk e8afbda10f 3.5.0 release
soname was bumped due to commit dcf23676cc which introduced an ABI
change.

Fixes #29

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 18:05:48 +01:00
Ondřej Lysoněk f22b411652 Clarify how to update SENSORS_API_VERSION
My understanding is that SENSORS_API_VERSION should be the same
as $(LIBMAINVER)$(LIBMINORVER) in lib/Module.mk. This means that
the first digit of SENSORS_API_VERSION needs to be incremented whenever
API *or* ABI changes, because we have to increment LIBMAINVER even if
only ABI changes to avoid program breakage.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 17:23:56 +01:00
Ondřej Lysoněk 7e976f1325 libsensors: Treat devices without a known ancestor bus as virtual
Currently only hwmon devices that don't have a parent device are treated
as virtual. Let's extend the concept to hwmon devices, that don't have
a *recognized ancestor* device (hwmon devices that according to the kernel
don't reside on a bus that we recognize). This change is meant to address
cases where a hwmon device has a thermal class device for a parent, but
the thermal class device doesn't have a parent device.

These kind of hwmon devices started appearing in the 4.19 kernel
due to commit f6b6b52ef7a54160c0. It was not reported as a kernel
regression and fixed in the kernel, because according to
Documentation/admin-guide/sysfs-rules.rst, the change was OK to make
(it says "Position of devices along device chain can change").

Fixes #139

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 12:17:01 +01:00
Ondřej Lysoněk d4cb932567 libsensors: Consider all ancestor devices when determining bus type
Go through all ancestor devices of a hwmon device until we find a device
that resides on a bus that we recognize. This change is meant to address
hwmon devices that don't reside directly on a bus, but have another
device in the middle of the hiearchy. For example:
ACPI device -> thermal device -> hwmon device

These kind of hwmon devices started appearing in the 4.19 kernel
due to commit f6b6b52ef7a54160c0. It was not reported as a kernel
regression and fixed in the kernel, because according to
Documentation/admin-guide/sysfs-rules.rst, the change was OK to make
(it says "Position of devices along device chain can change").

Fixes #133

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 12:16:52 +01:00
Ondřej Lysoněk 567e6a3b36 libsensors: Pass a resolved device path to sensors_read_one_sysfs_chip
According to Documentation/admin-guide/sysfs-rules.rst, the "device"
link "must never appear in any path as an element". This patch makes
lm_sensors respect that.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 11:33:05 +01:00
Ondřej Lysoněk 6ac43308b5 libsensors: Rename a local variable
Rename a local variable to make it consistent with other parts of the
code. The variable is called (more descriptively) "dev_name"
in sensors_read_one_sysfs_chip(), so let's rename it to that.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 11:33:05 +01:00
Ondřej Lysoněk 0fbfc3b6e0 libsensors: Refactor bus type identification into a separate function
Refactor bus type identification into a separate function in order to
make the code more readable and easier to maintain.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 11:33:05 +01:00
Ondřej Lysoněk 0cb449735f libsensors: Refactor device classification into a separate function
Refactor device classification into a separate function in order to
make the code more readable and easier to maintain.

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-11-23 11:33:05 +01:00
Ondřej Lysoněk 6413b80847 Fix stale links
Fixes #8

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
2018-09-01 19:38:55 +02:00
Guenter Roeck 09a60b9065 libsensors: Add support for SENSORS_BUS_TYPE_SCSI
Upcoming kernel drivers may add SCSI bus based sensors.
Add support for it to libsensors.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-08-11 11:59:14 -07:00
Andrew Lunn dcf23676cc sensors: Add support for power min, lcrit, min_alarm, lcrit_alarm
SFP modules measure the transmit power of the lazer. The sensor has
expected minimum values, and alarms when these minimams are reached.
Add support to sensors to print these.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
2018-06-29 12:29:46 -07:00
Elliott Johnson 70f7e08484 Adding documentation of the chip_name to bus_id relationship. 2018-05-24 14:55:27 -07:00
Andrew Lunn 0880db23b9 Add support for MDIO busses
Marvell Ethernet PHYs can contain a temperature sensor, which the kernel
exports as an HWMON device. The PHY is on an MDIO bus. Add support for
this bus types to libsensors. The sensor is then displayed by sensors(1):

socaipsbus02100000ethernet02188000mdioswitch0mdio01-mdio-1
Adapter: MDIO adapter
temp1:        +54.0°C  (crit = +100.0°C)

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
2017-07-08 20:19:13 -07:00
David Frey 7035d7bec4 Make include guards consistent in libsensors
Signed-off-by: David Frey <dpfrey@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-04-14 08:11:01 -07:00
Jean Delvare b200f794b3 libsensors: Fix sparse warnings
Sparse wants forward declarations of static functions to be static as
well. For sensors_eval_expr, do that. For the error callbacks,
rearrange the code so that the forward declarations are no longer
needed.
2015-05-15 11:24:28 +00:00
Jean Delvare e0abfe8c5d Add libsensors.map to the list of dependencies for libsensors.so. 2014-05-09 05:53:10 +00:00
Jean Delvare da5b14dc0c sensors.conf.5: Enhance the hysteresis documentation
Mention all supported temperature hysteresis attributes. Recommend
setting each limit before its hysteresis.
2014-04-23 15:17:24 +00:00
Jean Delvare f09b1c6483 libsensors: Add support for temp[1-*]_min_hyst and temp[1-*]_lcrit_hyst
Add support for sysfs attributes temp[1-*]_min_hyst (already
implemented by drivers adt7x10, lm77 and lm92) and
temp[1-*]_lcrit_hyst (no known users yet.)
2014-04-22 08:05:14 +00:00
Jean Delvare eb5cf8b2ec Update my e-mail address and copyright years 2014-03-20 10:23:35 +00:00
Jean Delvare c29be769f1 libsensors: Avoid insane memory allocations
While there is no longer a hard limit to the number of sensor of a
given type per chip, I feel a little uncomfortable having no limit at
all on the amount of memory we may try to allocate. Add an arbitrary
safety limit so that a design error or a bug in a hwmon driver can't
result into an insane memory allocation.
2014-01-30 12:45:23 +00:00
Jean Delvare b9361dc088 libsensors: Adjust memory pre-allocation steps
Make memory pre-allocation steps depend on the sensor type. Things like
voltages, temperatures or fans are typically plenty, however vid and
chassis intrusion are typically only a few, and there can only be one
beep_enable by design. This saves a small amount of temporary memory
for cheap.
2014-01-29 14:39:34 +00:00
Jean Delvare 0159202226 libsensors: Get rid of FEATURE_SIZE
max_subfeatures is computed the first time it is needed, we can do
exactly the same with FEATURE_SIZE. Introduce feature_size as a static
variable so that we don't have to recompute it again and again.
2014-01-29 14:11:12 +00:00
Jean Delvare 8b4299252b Bumb libsensors version, part 2 2014-01-29 09:28:08 +00:00
Jean Delvare ff7e16dafa Bump libsensors version 2014-01-29 09:27:23 +00:00
Jean Delvare 883f4e49a3 libsensors: Get rid of arbitrary limit on per-type sensor count
When gathering the attributes of each hwmon chip, libsensors uses a
temporary structure in memory to order and group all the attributes
into features. This temporary structure used to be a single array with
room for every possible attribute/subfeature. While simple, this
approach required to predefine a maximum number of per-type sensor
that could be handled.

In order to get rid of this arbitrary limit, which we hit and had to
raise three times already, I changed the temporary structure to an
array of dynamically allocated per-type subattribute arrays. This lets
us not allocate any memory for types which aren't implemented by a
given chip, and more importantly, this lets us reallocate room for
more attributes of a given type as needed.

I decided to allocate chunks of 8 attributes at a time, as this seemed
a good compromise between two frequent reallocations and
over-provisioning. It could be tweaked if needed.

Icing on the cake, I benchmarked this change on two different systems
and it results in performance gains. The total heap usage as reported
by valgrind is down by 50% on average, with peak memory consumption
(as reported by valgrind's massif) also down by 43% on average. The
total instructions count (as reported by valgrind's callgrind) is down
by 11% on average, with measured execution time also down by a few
percents. Valgrind rocks, BTW.

I have some ideas to optimize the memory allocations further, but I do
not expect such a huge gain from them. They may not even improve peak
memory consumption as massif shows the peak is somewhere else now at
least in some cases.
2014-01-29 09:25:31 +00:00
Jean Delvare 18853526ec libsensors: rename function sensors_compute_max
The new function name, sensors_compute_max_sf, better reflects what
the function is actually doing.
2014-01-28 21:47:41 +00:00
Jean Delvare 2252b49e2b libsensors: Increase MAX_SENSORS_PER_TYPE to 33
This is needed to properly support all temperatures reported by the
coretemp driver on recent hardware.
2014-01-14 14:49:04 +00:00