summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--etc/sensors.conf.eg4
-rw-r--r--prog/sensors/main.c38
-rw-r--r--prog/sensors/sensors.115
4 files changed, 50 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 6b25ae3f..cff06701 100644
--- a/CHANGES
+++ b/CHANGES
@@ -55,6 +55,7 @@ SVN HEAD
Fix alignment of alarm for one-limit temperatures
Drop option -U
Fix a memory leak on error (with -u)
+ New option --bus-list
Program sensors-detect: Stop Super-I/O probe after first family success
Fix SMSC DME1737 detection
Add /usr/sbin to the PATH (#2199)
diff --git a/etc/sensors.conf.eg b/etc/sensors.conf.eg
index b007cd01..ffc21c10 100644
--- a/etc/sensors.conf.eg
+++ b/etc/sensors.conf.eg
@@ -237,9 +237,7 @@
#
# chip "lm75-i2c-0-*"
#
-# You should really use the output of /proc/bus/chips to generate bus lines,
-# because one mistyped characted will inhibit the match. Wildcards are not
-# yet supported; spaces at the end are ignored, though.
+# You can use "sensors --bus-list" to generate bus lines for your system.
#
#
# BEEPS
diff --git a/prog/sensors/main.c b/prog/sensors/main.c
index f441981a..22f3efb1 100644
--- a/prog/sensors/main.c
+++ b/prog/sensors/main.c
@@ -59,6 +59,7 @@ static void print_long_help(void)
" -s, --set Execute `set' statements (root only)\n"
" -f, --fahrenheit Show temperatures in degrees fahrenheit\n"
" -A, --no-adapter Do not show adapter for each chip\n"
+ " --bus-list Generate bus statements for sensors.conf\n"
" -u Raw output (debugging only)\n"
" -v, --version Display the program version\n"
"\n"
@@ -207,9 +208,35 @@ static int do_the_real_work(const sensors_chip_name *match, int *error)
return cnt;
}
+/* List the buses in a format suitable for sensors.conf. We only list
+ bus types for which bus statements are actually useful and supported.
+ Known bug: i2c buses with number >= 32 or 64 could be listed several
+ times. Very unlikely to ever happen, though. */
+static void print_bus_list(void)
+{
+ const sensors_chip_name *chip;
+ int chip_nr;
+ unsigned long seen_i2c = 0;
+
+ chip_nr = 0;
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+ switch (chip->bus.type) {
+ case SENSORS_BUS_TYPE_I2C:
+ if (chip->bus.nr < (int)sizeof(unsigned long) * 8) {
+ if (seen_i2c & (1 << chip->bus.nr))
+ break;
+ seen_i2c |= 1 << chip->bus.nr;
+ }
+ printf("bus \"i2c-%d\" \"%s\"\n", chip->bus.nr,
+ sensors_get_adapter_name(&chip->bus));
+ break;
+ }
+ }
+}
+
int main(int argc, char *argv[])
{
- int c, res, i, error;
+ int c, res, i, error, do_bus_list;
const char *config_file_name = DEFAULT_CONFIG_FILE;
struct option long_opts[] = {
@@ -219,6 +246,7 @@ int main(int argc, char *argv[])
{ "fahrenheit", no_argument, NULL, 'f' },
{ "no-adapter", no_argument, NULL, 'A' },
{ "config-file", required_argument, NULL, 'c' },
+ { "bus-list", no_argument, NULL, 'B' },
{ 0, 0, 0, 0 }
};
@@ -226,6 +254,7 @@ int main(int argc, char *argv[])
do_raw = 0;
do_sets = 0;
+ do_bus_list = 0;
hide_adapter = 0;
while (1) {
c = getopt_long(argc, argv, "hsvfAc:u", long_opts, NULL);
@@ -257,6 +286,9 @@ int main(int argc, char *argv[])
case 'u':
do_raw = 1;
break;
+ case 'B':
+ do_bus_list = 1;
+ break;
default:
fprintf(stderr,
"Internal error while parsing options!\n");
@@ -271,7 +303,9 @@ int main(int argc, char *argv[])
/* build the degrees string */
set_degstr();
- if (optind == argc) { /* No chip name on command line */
+ if (do_bus_list) {
+ print_bus_list();
+ } else if (optind == argc) { /* No chip name on command line */
if (!do_the_real_work(NULL, &error)) {
fprintf(stderr,
"No sensors found!\n"
diff --git a/prog/sensors/sensors.1 b/prog/sensors/sensors.1
index a4d2b558..0a5525a3 100644
--- a/prog/sensors/sensors.1
+++ b/prog/sensors/sensors.1
@@ -22,7 +22,7 @@
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
-.TH sensors 1 "August 2007" "lm-sensors 3" "Linux User's Manual"
+.TH sensors 1 "September 2007" "lm-sensors 3" "Linux User's Manual"
.SH NAME
sensors \- print sensors information
.SH SYNOPSIS
@@ -33,10 +33,10 @@ sensors \- print sensors information
.B ]
.br
.B sensors -s [
-.I options
-.B ] [
.I chips
.B ]
+.br
+.B sensors --bus-list
.SH DESCRIPTION
.B sensors
@@ -44,6 +44,9 @@ is used to show the current readings of all sensor chips.
.br
.B sensors -s
is used to set all limits as specified in the configuration file.
+.br
+.B sensors --bus-list
+is used to generate bus statements suitable for the configuration file.
.SH OPTIONS
.IP "-c config-file"
@@ -64,6 +67,12 @@ Raw output. This mode is only meant for debugging.
Print the program version and exit.
.IP -f
Print the temperatures in degrees Fahrenheit instead of Celsius.
+.IP --bus-list
+Generate bus statements suitable for using in sensors.conf. Such bus statements
+are only needed if you have several chips sharing the same address on different
+buses of the same type. As bus numbers are usually not guaranteed to be stable
+over reboots, these statements let you refer to each bus by its name rather
+than numbers.
.SH FILES
.I /etc/sensors.conf
.RS