2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 05:48:07 +00:00

342 Commits

Author SHA1 Message Date
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
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
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
0c24a60643 Drop the CONFORMING TO sections from the man pages. lm-sensors is in no way
an official standard so it doesn't make much sense. Instead, use the 4th
field of .TH to mention that these tools are part of lm-sensors.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4699 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-23 08:14:48 +00:00
Jean Delvare
bf1ff10ab4 Relabel "sensors -u" from "unknown chip" to "raw chip". sensors uses generic
code to display all the chips now so the notion of "unknown chip" no longer
exists, however this raw output format can still be useful for debugging.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4698 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-23 07:45:58 +00:00
Jean Delvare
90c2942bef Drop sensors option -U, --hide-unknown. libsensors no longer exposes
chips with no features, and it builds the features list dynamically, so
applications no longer get to see unknown chips.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4697 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-22 18:43:48 +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
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
4695755d89 Drop unneeded frees.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4682 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-17 21:11:57 +00:00
Jean Delvare
557feb2696 Fix error message when a chip is specified on the command line
with no prefix and that chip isn't found.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4681 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-17 11:36:01 +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
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
Jean Delvare
3b25c8dc22 Pass structures by reference in sensors and sensord, again for a
small performance gain and better consistency with the new
libsensors API.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4668 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-13 20:19:44 +00:00
Jean Delvare
3bab00fff9 Change the libsensors API so that all structures are passed by
reference. This is more efficient that way.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4666 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-08-13 20:16:03 +00:00
Jean Delvare
9896986247 We no longer need sensors_get_label_and_valid(), as it does hardly
more than sensors_get_label(). This allows for some cleanups.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4645 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-24 08:21:23 +00:00
Jean Delvare
e9c8c5fb06 Let libsensors handle ignore statements by itself, rather than
delegating the task to the user applications.

For now, I am calling sensors_get_ignored() in
sensors_get_all_features(), because this is the least intrusive way.
This is in no way optimal though, it would be better to not add
ignored features to the feature list in the first place. However,
doing so would require that the configuration file is read before
sysfs is scanned for features, which isn't currently the case. So
this improvement is left for later.

Note that this patch adds a small cost in terms of performance. This
is because we now honor ignore statements on all features (main ones
and subfeatures) while in practice "sensors" was only checking for
main features. It would be trivial to stop checking for subfeatures,
but it seems to me that supporting ignore on subfeatures is a good
move, as the user may actually want to ignore a specific subfeature.
Individual alarms come to mind. This will also be handy to debug the
generic print code in "sensors".


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4644 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-24 08:20:53 +00:00
Jean Delvare
6505fef0fd The way we build the feature lists guarantees that subfeatures always
immediately follow their main feature. This makes it possible to simplify
sensors_get_all_features() quite a bit. We no longer need to maintain
separate pointers for the last main feature and the last subfeature,
we can simply walk the list linearly.

Note that I am still not entirely happy with this API. It was obviously
designed for debugging purposes (sensors -u) and without performance
concernes nor interface cleanliness in mind. I believe that we want to
tag main features and subfeatures as such, and let the application ask
specifically for the list of main features, and for each feature, for
its list of subfeatures (i.e. two functions instead of one.)


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4643 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-24 08:19:59 +00:00
Jean Delvare
462e7d81df Unify error reporting messages. Fix a memory leak in error path.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4639 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-22 12:25:15 +00:00
Jean Delvare
834cd70e14 Drop redundant test.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4632 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-20 19:09:00 +00:00
Jean Delvare
70317e1a0e The way we use sensors_feature_get_type() is rather suboptimal. It is
first called during the library initialization to generate the feature
tables. Then it is called again by sensors itself. This is because we
do not store the result the first time. I propose that we add a type
field to struct sensors_feature_data, where libsensors would store
the result of sensors_feature_get_type(). That way, the application
can get the information without calling sensors_feature_get_type()
again.

This change has the following benefits:
* Obviously, a small speed-up.
* sensors_feature_get_type() can be removed from the public interface.
  This means that we can turn it into something that fits the
  libsensors needs better, allowing for more optimizations (see next
  patches.)

Note: the patch looks bigger that it really is, because I had to move
definitions around in sensors.h.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4629 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-19 20:46:09 +00:00
Jean Delvare
7b8fdf0188 Advertise and document libsensors_version.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4602 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-10 19:55:06 +00:00
Jean Delvare
e45b873981 Delete unused function sensors_get_sub_feature_by_type().
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4598 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-09 11:20:47 +00:00
Hans de Goede
712748f659 Handle chips who return the beta value as temp sensor type
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4595 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-08 18:59:16 +00:00
Jean Delvare
3549a94232 Right-align FAULT flags.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4578 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-07 15:26:12 +00:00
Hans de Goede
b1281bf669 improve generic print of temp inputs with so many limits they span 2 lines
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4564 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-06 13:19:00 +00:00
Hans de Goede
4d2fa4eadd Better generic print fault handling
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4559 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-05 21:03:06 +00:00
Jean Delvare
83fe82736d Prevent a potential array overrun.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4556 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-05 16:19:51 +00:00
Hans de Goede
7cb36ef6d2 add AMDSI PECI sensortype support to generic_temp_print()
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4552 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-05 11:22:57 +00:00
Hans de Goede
3e37149f04 generic in and fan print routine fixes
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4549 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-03 19:38:37 +00:00
Jean Delvare
b79274babd Add some more warning flags, and fix these warnings.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4545 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-03 16:03:22 +00:00
Jean Delvare
7cc03f5029 Drop VRM reporting and selection support from libsensors. Since kernel
2.6.9, the right VID conversion formula is selected automatically
depending on the CPU model, so the user shouldn't have to care.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4543 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-03 13:22:28 +00:00
Jean Delvare
5b8b0a0ede Drop a bogus comment.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4534 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-07-02 15:16:02 +00:00
Hans de Goede
184ad7e23e long promised print_generic_chip_in() fixes
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4514 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-28 21:00:08 +00:00
Jean Delvare
4c905e1632 Drop the --generic option. This is the default now, so the option has
no effect.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4512 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-28 17:47:18 +00:00
Jean Delvare
a6c3c36f00 Warning fix ("index" is a standard libc function.)
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4511 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-28 14:46:08 +00:00
Jean Delvare
56e9e2da88 Delete needless forward declarations and wrapper.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4505 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-28 09:02:12 +00:00
Jean Delvare
6a6cf217d4 Drop all the chip-specific handling and printing code from sensors. The
generic printing code should work now, and what doesn't work, will get
fixed.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4503 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-28 08:52:37 +00:00
Jean Delvare
24f6b62c3f Delete all remnants of algorithm names.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4465 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-25 14:21:01 +00:00
Jean Delvare
f00aef9271 Return with an explicit error code/message if sysfs isn't mounted.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4464 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-25 13:58:55 +00:00
Jean Delvare
c8b02ddfa3 Install libsensors as libsensors.so.4, and sensors as sensors3. This makes
it possible to install both the old and the new libsensors and sensors,
making testing much easier. sensors3 will be renamed back to sensors before
we release.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4461 7894878c-1315-0410-8ee3-d5d059ff63e0
2007-06-25 11:39:08 +00:00