Commit Graph
116 Commits
Author SHA1 Message Date
Jean Delvare 6868367764 sensors_get_label: Merge pathname and label buffers (patch from
George Spelvin).
    
The lifetimes of the path and label name buffers are
disjoint, so a single buffer can be used for both purposes.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5748 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-30 20:52:20 +00:00
Jean Delvare b3f39211b2 Consolidate strdup calls in sensors_get_label (patch from George Spelvin).
There were multiple in-line calls that then fell through to
a common exit.  Instead, set up a pointer to the original
strings, and have a single strdup in the common code.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5747 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-30 20:47:53 +00:00
Andre Prendel a03ec09359 Use __func__ in sensors_fatal_error() to get function name.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5674 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-03-02 13:07:23 +00:00
Jean Delvare 0efe346b80 Include the configuration file name when reporting parse errors.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5649 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 17:26:57 +00:00
Jean Delvare 6a7286464d Keep track of configuration file names so that we can later generate
better error reports.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5648 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 17:24:31 +00:00
Jean Delvare 30499dc899 Fix inclusion of general.h.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5639 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-11 10:12:45 +00:00
Hans de Goede 11eec21555 Add ACPI bus
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5593 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-01-13 08:06:32 +00:00
Jean Delvare c80aefd222 Detect excessive recursion depth during expression evaluation.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5582 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-01-11 12:19:32 +00:00
Jean Delvare e4d51acf7d Fix error propagation during expression evaluation.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5581 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-01-11 10:00:19 +00:00
Jean Delvare 39b96fa477 Add support for virtual hwmon devices. This closes Red Hat bug #437637
and ticket #2305.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5176 7894878c-1315-0410-8ee3-d5d059ff63e0
2008-04-14 15:27:59 +00:00
Jean Delvare c84fd9820e We start at the end of the chip list, going backwards, and we want the
late compute statements to override the early ones (as documented in the
sensors.conf manual page), so we must stop as soon as any match is found.

This fixes Debian bug #474596:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474596


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5175 7894878c-1315-0410-8ee3-d5d059ff63e0
2008-04-11 20:41:31 +00:00
Jean Delvare f2e518511d Patch from Aurelien Jarno:
I have just noticed that the FSF address is the old one in all files
except COPYING. Please find a patch below to fix that.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5163 7894878c-1315-0410-8ee3-d5d059ff63e0
2008-03-26 13:37:12 +00:00
Jean Delvare 32cc1171bc Returned error values are supposed to be negative.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5077 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-12-18 10:06:58 +00:00
Jean Delvare 06a8d04b5d Preserve error values returned by sensors_read_sysfs_attr() and
sensors_write_sysfs_attr().


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4851 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 13:17:53 +00:00
Jean Delvare e01466d993 New public library function: sensors_get_subfeature(). Applications can
use it to retrieve a specific subfeature by type. While it is slighly
less efficient than looping over sensors_get_all_subfeatures(), it
often makes the application code much more elegant.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4846 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:30:28 +00:00
Jean Delvare c08a168342 Use sensors_lookup_chip() wherever possible, it makes the code
more readable.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4845 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:24:13 +00:00
Jean Delvare e55b84392b Use sensors_lookup_chip() to speed up sensors_lookup_subfeature_name()
as well.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4844 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:23:38 +00:00
Jean Delvare 36f5b0dc4d New internal library function: sensors_lookup_chip(). It looks up a
chip in the detected chip list. It is more efficient to do it once
and for all than to do it over and over again in
sensors_lookup_feature_nr() and sensors_lookup_subfeature_nr() as
was done before.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4843 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:23:06 +00:00
Jean Delvare 586cec7fa1 sensors_lookup_subfeature_nr() can now be made static.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4842 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:20:48 +00:00
Jean Delvare e7c345f4cf Pass a subfeature structure to sensors_read_sysfs_attr() and
sensors_write_sysfs_attr(), rather than a subfeature number, so that
we do not have to lookup the feature number again.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4841 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:20:07 +00:00
Jean Delvare ba6614624b There's no rationale for preventing against setting the same
subfeature value several times. If the user asks for that, let's just
do it. Otherwise we have a performance penalty for all other users.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4840 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:19:29 +00:00
Jean Delvare 67d3060317 We can plain skip the feature lookup and compute statement search for
subfeatures with no compute mapping.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4839 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:18:46 +00:00
Jean Delvare da7b4e48da Introduce a separate type for main features. Make subfeatures map to
the real main feature rather than the first subfeature.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4838 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:16:50 +00:00
Jean Delvare e13c11d353 Update the comments and symbols in the whole library code to refer to
features and subfeatures as appropriate.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4836 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:07:53 +00:00
Jean Delvare 9fe2b3c714 sensors_get_all_features has a single caller now, so fold
it thereinto.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4835 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:06:51 +00:00
Jean Delvare 96c914bfda Define a separate structure to represent main features. This allows
for faster main features lookup. One side effect of this change is
that subfeatures can no longer have labels nor be ignored. I do not
think that this is a problem in practice, and actually this makes a
lot of sense.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4834 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:05:16 +00:00
Jean Delvare 79086fb7b8 Rename struct sensors_feature_data to sensors_subfeature. This is a
first step towards a clean separation between main features and
subfeatures.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4832 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:02:22 +00:00
Jean Delvare eba601a964 Split sensors_get_all_features() into two distinct functions, one to
get the list of all main features, and one to get the list of all the
subfeatures of a given main feature. This is a more logical interface for
applications to use. The current implementation is admittedly less than
optimal, because the storage structures weren't meant for it, but this
issue can (and will) be addressed later.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4831 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 12:00:59 +00:00
Jean Delvare 08a686e3cc sensors_feature_data and sensors_chip_feature are now the exact
same structure, so we can get rid of the former for simpler code.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4830 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-23 11:59:51 +00:00
Mark M. Hoffman 91866b3ea1 Make sensors.conf entirely case-sensitive.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4796 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-16 15:34:52 +00:00
Jean Delvare 65b9d4dd92 Move sensors_feature_get_type() from access.c to sysfs.c, it's only called
from this file. This lets the compiler do additional optimizations.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4776 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-09-05 16:14:53 +00:00
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 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 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 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 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 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
Jean Delvare 4d6bec8bb2 Add a parameter to sensors_get_detected_chips(), to optionally let the
caller select which subset of chips it wants. This is slightly better
size-wise than letting all applications do the filtering by themselves.

This will change the way the command line parameters of "sensors" are
interpreted. Beforehand, the chips were always returned in the order
in which they were listed by the library. Also, each chip could be listed
only once. From now on, the chips will be listed in the order in which
they are passed on the command line, which I think makes more sense. A
side effect is that chips can be listed more than once, if that's what
the user asks for. Not very useful though.

This change makes it possible to make sensors_match_chip() internal
to the library. Filtering the list of chips returned by
sensors_get_detected_chips() was the last known external use for this
function.

This patch looks much bigger than it really is, but the largest part is
really only code reindentation.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4701 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-26 08:26:20 +00:00
Jean Delvare b0fb417996 sensors_get_value() and sensors_set_value(), respectively.
The new names better reflect what the functions do.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4695 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-22 17:06:13 +00:00
Jean Delvare 8bcdc331a0 Change the prototype of sensors_get_label(). Errors can be reported
with a NULL pointer.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4694 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-22 17:05:01 +00:00
Jean Delvare 5524486161 Add support for hardware monitoring chips on SPI buses.
SPI bus statements in the configuration file are not yet supported, as
SPI buses don't have a name attribute yet, it's not possible to identify
them and thus no substitution is possible.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4689 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-19 15:07:05 +00:00
Jean Delvare a74addb5d4 Support more bus types (part 2 of 2). Originally libsensors was very
i2c-centric. Make it more neutral so that we can cleanly support
additional bus types such as SPI or One-Wire.

This second part updates sensors_bus to use sensors_bus_id. Thanks
to Mark M. Hoffman for showing me how the configuration file
parser could be modified to support that change.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4687 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-19 15:04:29 +00:00
Jean Delvare 7ee15371df Support more bus types (part 1 of 2). Originally libsensors was very
i2c-centric. Make it more neutral so that we can cleanly support
additional bus types such as SPI or One-Wire.

This first part introduces sensors_bus_id, and updates
sensors_chip_name to use it.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4686 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-19 15:03:50 +00:00
Jean Delvare edb42b3c16 Add a new function to libsensors doing the opposite of
sensors_parse_chip_name(). sensors_snprintf_chip_name() converts
a chip name from its internal representation to a human readable
string. So far, each user program had to reimplement this function.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4676 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-16 10:04:57 +00:00
Jean Delvare 8896ba3b1f Rename sensors_chip_name.busname to path, as this is what we are using
it for by now.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4673 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-16 09:56:07 +00:00
Jean Delvare b52225ffc0 Drop support for "dummy" bus type. The kernel no longer supports
such fake i2c buses, so neither should we. Instead, non-i2c buses are
handled explicitly.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4672 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-16 09:54:53 +00:00