Commit Graph
660 Commits
Author SHA1 Message Date
Michal Suchanek 4bf8e37e0f Update API description
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2024-01-08 22:21:05 +01:00
Michal Suchanek 89548dab2a Add SENSORS_SYSFS_ROOT environment support
With this the hardcoded /sys location for reading sensor data can be
changed. In particular it makes it possible to tar up the /sys directory
when a problem is encountered, and then reproduce it on another system.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2024-01-07 21:20:39 +01:00
Michal Suchanek 25108fe4a4 More robust reading of labels
When the sysfs file is copied to a plain file it may contain trailing
zeroes which is not handled well by the label reading code.
2024-01-07 21:20:39 +01:00
Michal Suchanek 3bbd975860 quantity: Add enumeration type
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2024-01-06 23:05:07 +01:00
Michal Suchanek 502ce051fe sensors_temperature_type_name: New library function
Decode temperature sensor type to a string.

Add enum for temperature types.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2024-01-06 23:04:46 +01:00
Michal Suchanek 0c097bfca4 parser: Strip trailing whitespace 2024-01-06 20:26:05 +01:00
Michal Suchanek 10c6068b3e sensors_parse_chip_name: Initialize path
sensors_parse_chip_name claims to overwrite all of result but path is
not set. This is generally not a problem when using statically allocated
data that is pre-zeroed but the parser uses dynamic allocation and the
chip name may contain garbage depending on the specific code flow
resulting from compiling the parser.
Setting the path was dropped when it was renamed from busname.

Fixes: 8896ba3b ("Rename sensors_chip_name.busname to path, as this is
		  what we are using it for by now.")
2023-12-30 19:05:13 +01:00
Michal Suchanek 39d3145da9 test: Generate dependency files 2023-12-30 18:58:32 +01:00
Michal Suchanek 7a4b9b98c0 Correct dependencies for generated parser
The parser needs to be regenerated when makefile changes
2023-12-30 18:58:32 +01:00
Michal Suchanek c829b4c7fb Add LDFLAGS handling similar to CFLAGS 2023-12-29 15:37:00 +01:00
Michal Suchanek d60d6beebf Correct parser file dependencies
The dependencies for the parser files are not correct.

There is baroque irule adding header prerequisites to the parser but the
parser may still fail to build.

The real dependency is on conf-parse.h

There is no way to tell make that a rule produces two targets, such as
parse.c and parse.h. However, the dependency files are generated by a
separate rule, and not as a byproduct of building the source so they can
themselves have dependencies.

And dependencies they do have: when the header is generated it's in lib
but when the header is missing while generating dependency file it's
searched in top directory, and then the file that depends on it cannot
be built because the header neveer appears there.

When the generated .c file is addded as prerequisite to the dependency
file that should reference the header generated together with the .c
file the dependency file is generated correctly with the header present.

This is not easily reproducible with the current source but adding
conf-lex.h generated with conf-lex.c and including it in conf-parse.c
now makes both conf-lex.ad depend on conf-parse.h and conf-lex.ad on
conf-lex.h making the build 100% fail.
2023-12-29 15:11:49 +01:00
Michal Suchanek 9c66c7b59e Remove special build rules for parser
The parser can be generated warning-free, no need to suppress warnings.
2023-12-29 15:11:49 +01:00
Michal Suchanek 0d9ea7f031 Move temperature sensor type translation to library 2023-12-28 13:03:50 +01:00
Michal Suchanek 297b050d3d sysfs: Add function for determining feature quantity 2023-12-28 13:02:33 +01:00
Michal Suchanek 6fa5cba2e3 sysfs: Do not prescale frequency to MHz
Add autoscaling in the output instead.

Fixes: 54363271 ("libsensors + sensors: Add freq_input support")
2023-12-27 14:57:05 +01:00
Michal Suchanek fceeee0543 sysfs: Multiplier 1 is the default, no need to list it.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2023-12-27 13:40:53 +01:00
Michal Suchanek c1a1f4ff20 pwm: Move scaling factor from sensors prog to library
Fixes: a6ec549e ("sensors: Add support for pwm sensors")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2023-12-27 13:17:28 +01:00
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