2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-29 13:28:01 +00:00

4039 Commits

Author SHA1 Message Date
Jean Delvare
61686376df Add support for temperature offset files, which are part of the
standard sysfs interface. I don't think it makes much sense to
display the offset values as part of the output of "sensors" (it
would even probably confuse people) but having support for these
in libsensors makes it possible to adjust the offsets in
sensors.conf, which is convenient.

This closes ticket #2248.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4769 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 12:31:12 +00:00
Jean Delvare
6b3803c386 Fix memory leaks in the configuration file parser when a label, set,
compute or ignore statement is found before the first chip statement.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4768 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 12:30:39 +00:00
Jean Delvare
6c4ea89ab9 Renumber SENSORS_FEATURE_VID from 0x300 to 0x1000. If we ever need
to add more "standard" feature types such as current or power,
we want to give them numbers that immediately follow the fan, voltage
and temperature features, so that the code is as simple as possible.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4767 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 12:29:20 +00:00
Jean Delvare
29bea1e843 Add support for the standard beep_enable attribute (#2248).
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4766 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 12:28:31 +00:00
Jean Delvare
3c53f5fa85 Increase MAX_SENSORS_PER_TYPE from 16 to 20: the ADM1026 can have up
to 17 voltage inputs, and bmcsensors used to support up to 20 voltage
values.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4765 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:31:25 +00:00
Jean Delvare
5c121e2b74 Another minor optimization to sensors_read_dynamic_chip():
* We don't need a temporary structure for the feature being
  currently processed. Instead we can work on the large sparse
  array directly.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4764 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:29:36 +00:00
Jean Delvare
75bd19ec34 Minor optimizations in sensors_read_dynamic_chip():
* We don't need to compute the mapping during the first pass: this
  field is overwritten when renumbering the features anyway.
* Only main features have features mapping to them.
* Only subfeatures have mappings, so we can stop the scan at the next
  main feature.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4763 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:26:26 +00:00
Jean Delvare
b836fc0b53 Now that we can deduce the scaling factor required for each feature
from its type, there's no need to store this scaling factor. We can
instead compute it at runtime. This saves some memory (about 10 kB
in my real-world test), and the runtime overhead is totally
negligible.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4762 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:21:19 +00:00
Jean Delvare
ed480f2edd Optimize the memory consumption in sensors_read_dynamic_chip(). The
idea is to have separate indexing for subfeatures with a compute
mapping and for subfeatures without it. They still follow each
other in the big table but this avoids wasting memory due to the
numbering gap between them.

This cuts the amount of memory (temporarily) allocated by
sensors_read_dynamic_chip() almost by half, and also speeds it up
a little as it now takes less iterations to walk the sparse array.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4761 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:20:35 +00:00
Jean Delvare
23f4274010 Store the feature list length separately instead of null-terminating
the list. This make it possible to check for out-of-bound indexes
without walking the entire list, so that direct look-ups are safer.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4760 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:19:42 +00:00
Jean Delvare
7975800ac1 Renumber the features linearly, so that feature number N is at
position N in the array. This allows for O(1) look-ups, as opposed
to O(N) before. This makes sensors_lookup_feature_nr() 2.4 times
faster in my real-world tests, resulting in a 6% performance boost
on average in the runtime part of "sensors".


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4759 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:19:09 +00:00
Jean Delvare
20c98f41b7 The compute mapping value is either SENSORS_NO_MAPPING or the same
feature number as the logical mapping. This means that the compute
mapping can be turned into a simple boolean flag. Doing so makes
struct sensors_feature_data smaller, which saves some memory (about
17 kB in my tests.)


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4758 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:17:22 +00:00
Jean Delvare
87efbc06c5 Rename sensors_feature_data.mode to flags, as we plan to use it to
store non-mode flags soon.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4757 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:13:15 +00:00
Jean Delvare
079ba26574 Drop sensors_strip_of_spaces. There's no rationale for stripping
trailing spaces of bus names and nothing else.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4756 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:07:14 +00:00
Jean Delvare
3d15175ecd Add max6680-* entry.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4755 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 08:06:03 +00:00
Jean Delvare
2a822a2d96 Start numbering the features at 0, not 1. There's nothing wrong with
having a feature number 0, and this makes the code slightly simpler.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4744 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-02 11:15:27 +00:00
Jean Delvare
75859ca9dc Use the feature type rather than the feature name to figure out whether
we need to add "_input" to get the correct sysfs file name. This is
much faster. This is still a ugly hack I'd like to get rid of, but at
least now the slowdown is acceptable.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4743 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-02 11:09:16 +00:00
Jean Delvare
4b012c9f63 Drop useless return.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4742 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-02 10:55:03 +00:00
Jean Delvare
3c602aa03a Remove broken ATI SB700 SMBus PCI ID. The SB700 SMBus actually uses the same
PCI device ID as the SB600 SMBus.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4740 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-01 08:23:21 +00:00
Jean Delvare
27200afa1d Reorder functions so that forward declarations are no longer needed.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4737 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-31 15:09:26 +00:00
Jean Delvare
a82c6b0476 Mass reindent, coding style and whitespace cleanups.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4736 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-31 14:42:20 +00:00
Jean Delvare
02dc2e6679 Add support for the Intel Tolapai SMBus controller. Patch from Jason Gaston.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4735 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-31 14:09:32 +00:00
Jean Delvare
c00e21cf38 Reorder the members of the structures sensors_feature_data and
sensors_bus_id. This prevents wasting space with padding on 64-bit
systems, saving some memory (128 bytes for sensors_bus_id, nothing
yet for sensors_feature_data but it will come later).


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4733 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-30 21:23:22 +00:00
Jean Delvare
b491ba49d4 Make SENSORS_FEATURE_MAX_SUB_FEATURES private (and rename it to
MAX_SUB_FEATURES in the process.) This value could change in the
future so it's not safe to make it part of the libsensors API.
And it isn't needed either, applications shouldn't need to use
this value.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4732 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-30 21:21:15 +00:00
Jean Delvare
ed2b9171ec Allocate the large sparse feature table in sensors_read_dynamic_chip()
dynamically. Having large amounts of data on the stack is generally not
recommended.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4731 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-30 21:10:41 +00:00
Jean Delvare
5b1068a007 Rename SENSORS_FEATURE_TEMP_SENS to SENSORS_FEATURE_TEMP_TYPE. This
better reflects what this feature is, in line with the sysfs file name.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4730 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-29 14:08:47 +00:00
Jean Delvare
38d1d82cec Looking up a mapping can't fail if looking up the feature itself
succeeded (or that would be a bug in the library code.)


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4729 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-29 14:00:47 +00:00
Jean Delvare
2ee12591df Remove "generic" from all printing function names. This is the default
mode now so no need to mention it explicitly.
Rename print_vid_info to print_chip_vid and move it around for
consistency.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4728 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 21:26:20 +00:00
Jean Delvare
eaeaffb89b Fix a memory leak on error in raw print mode.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4726 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 21:14:37 +00:00
Jean Delvare
4e5d695411 Don't print the feature name for subfeatures in raw mode. Subfeatures
typically don't have a label so printing their label is equivalent
to printing their name, so printing it again is redundant.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4725 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 21:10:42 +00:00
Jean Delvare
deb41a945d Move print_chip_raw() at the top of the file, as it is indepdendent from
all the other functions.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4724 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:55:36 +00:00
Jean Delvare
9fe77731a9 Fix error message in print_chip_raw().
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4723 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:52:24 +00:00
Jean Delvare
60b2bafabd Drop function get_feature_value, it wasn't adding much value.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4720 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:41:53 +00:00
Jean Delvare
868fd8d093 Avoid the conversions from double to float.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4719 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:41:03 +00:00
Jean Delvare
4716a8c8f1 Change print_temp_limits() to expose a sane interface. This lets us get
rid of arbitrary constants. Now we can reuse the same code to display
the extra temperature limits.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4718 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:37:15 +00:00
Jean Delvare
9da5883c98 Move the printing of the current temperature out of print_temp_info().
That way we don't need to use an arbitrary value to carry the fault
information.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4717 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:36:46 +00:00
Jean Delvare
02e4d6fe83 print_temp_info is only ever called with precision values of 1, so we
can hard-code this precision for improved performance.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4716 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:35:26 +00:00
Jean Delvare
2cc20c4487 Only consider the main features when computing how much room we need
to print the labels. This is both a fix (beforehand we would leave
enough room to print possibly long subfeature names, even though we
do not actually print subfeature names at all) and a significant
performance boost. This change alone shrinks the CPU cost of a sensors
run by 4.5%.

I am still worried that this feature causes us to allocate each label
string twice, but I guess this overhead is now acceptable.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4715 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:34:55 +00:00
Jean Delvare
f0f3df8a48 Labels do fit in the imparted space by construction now, so no need
to check.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4714 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 20:33:21 +00:00
Jean Delvare
7ba794d9ba Clean up the global variables:
* do_sets, do_raw and hide_adapter are only used in main.c and could
thus be declared static.
* fahrenheit and degstr are used in chips.c as well, so they should be
declared in a header file.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4713 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 13:24:46 +00:00
Jean Delvare
55291db894 Reorder the functions so as to get rid of unneeded forward
declarations.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4712 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 13:22:28 +00:00
Jean Delvare
364bd24c44 config_file doesn't need to be a global. Also move the handling of
the configuration file in a single separate function for clarity.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4711 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 13:21:05 +00:00
Jean Delvare
c649ae5ac3 Merge chips_generic.c into chips.c. The boundary between both files was
only historical, and prevents us from doing a number of cleanups.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4710 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 12:19:07 +00:00
Jean Delvare
7268001a5d libsensors no longer returns ignored features so no need to check for
this in applications anymore.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4709 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 11:45:46 +00:00
Jean Delvare
252c5faf86 Mass reindent and coding style cleanups.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4708 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 10:57:16 +00:00
Jean Delvare
c91457b7de Executing the set statements is an exclusive action.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4706 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:57:48 +00:00
Jean Delvare
5ba408a37f Merge most of the usage help text into a single string. This is way
more efficient.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4705 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:43:30 +00:00
Jean Delvare
ec8ba95b53 Refactor the configuration file path.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4704 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:42:20 +00:00
Jean Delvare
b8b417c51e Thanks to the new prototype of sensors_get_detected_chips, we no
longer need to build an array from the chip names passed on the
command line. Instead, we can process them one after the other
directly. This saves some memory and allows for minor code cleanups.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4703 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:28:10 +00:00
Jean Delvare
a9a48ea2a9 Make sensors_match_chip internal to libsensors. It is no longer used by
applications in practice.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4702 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:26:51 +00:00