Blame SOURCES/lm_sensors-3.4.0-allow_no_sensors.patch

2527a2
diff --git a/prog/sensors/main.c b/prog/sensors/main.c
2527a2
index f535b66..a19b919 100644
2527a2
--- a/prog/sensors/main.c
2527a2
+++ b/prog/sensors/main.c
2527a2
@@ -54,15 +54,16 @@ static void print_short_help(void)
2527a2
 static void print_long_help(void)
2527a2
 {
2527a2
 	printf("Usage: %s [OPTION]... [CHIP]...\n", PROGRAM);
2527a2
-	puts("  -c, --config-file     Specify a config file\n"
2527a2
-	     "  -h, --help            Display this help text\n"
2527a2
-	     "  -s, --set             Execute `set' statements (root only)\n"
2527a2
-	     "  -f, --fahrenheit      Show temperatures in degrees fahrenheit\n"
2527a2
-	     "  -A, --no-adapter      Do not show adapter for each chip\n"
2527a2
-	     "      --bus-list        Generate bus statements for sensors.conf\n"
2527a2
-	     "  -u                    Raw output\n"
2527a2
-	     "  -j                    Json output\n"
2527a2
-	     "  -v, --version         Display the program version\n"
2527a2
+	puts("  -c, --config-file      Specify a config file\n"
2527a2
+	     "  -h, --help             Display this help text\n"
2527a2
+	     "  -s, --set              Execute `set' statements (root only)\n"
2527a2
+	     "  -f, --fahrenheit       Show temperatures in degrees fahrenheit\n"
2527a2
+	     "  -A, --no-adapter       Do not show adapter for each chip\n"
2527a2
+	     "      --bus-list         Generate bus statements for sensors.conf\n"
2527a2
+	     "  -u                     Raw output\n"
2527a2
+	     "  -j                     Json output\n"
2527a2
+	     "  -v, --version          Display the program version\n"
2527a2
+	     "  -n, --allow-no-sensors Do not fail if no sensors found\n"
2527a2
 	     "\n"
2527a2
 	     "Use `-' after `-c' to read the config file from stdin.\n"
2527a2
 	     "If no chips are specified, all chip info will be printed.\n"
2527a2
@@ -270,7 +271,7 @@ static void print_bus_list(void)
2527a2
 
2527a2
 int main(int argc, char *argv[])
2527a2
 {
2527a2
-	int c, i, err, do_bus_list;
2527a2
+	int c, i, err, do_bus_list, allow_no_sensors;
2527a2
 	const char *config_file_name = NULL;
2527a2
 
2527a2
 	struct option long_opts[] =  {
2527a2
@@ -281,6 +282,7 @@ int main(int argc, char *argv[])
2527a2
 		{ "no-adapter", no_argument, NULL, 'A' },
2527a2
 		{ "config-file", required_argument, NULL, 'c' },
2527a2
 		{ "bus-list", no_argument, NULL, 'B' },
2527a2
+		{ "allow-no-sensors", no_argument, NULL, 'n' },
2527a2
 		{ 0, 0, 0, 0 }
2527a2
 	};
2527a2
 
2527a2
@@ -291,8 +293,9 @@ int main(int argc, char *argv[])
2527a2
 	do_sets = 0;
2527a2
 	do_bus_list = 0;
2527a2
 	hide_adapter = 0;
2527a2
+	allow_no_sensors = 0;
2527a2
 	while (1) {
2527a2
-		c = getopt_long(argc, argv, "hsvfAc:uj", long_opts, NULL);
2527a2
+		c = getopt_long(argc, argv, "hsvfAc:ujn", long_opts, NULL);
2527a2
 		if (c == EOF)
2527a2
 			break;
2527a2
 		switch(c) {
2527a2
@@ -327,6 +330,9 @@ int main(int argc, char *argv[])
2527a2
 		case 'B':
2527a2
 			do_bus_list = 1;
2527a2
 			break;
2527a2
+		case 'n':
2527a2
+			allow_no_sensors = 1;
2527a2
+			break;
2527a2
 		default:
2527a2
 			fprintf(stderr,
2527a2
 				"Internal error while parsing options!\n");
2527a2
@@ -349,7 +355,9 @@ int main(int argc, char *argv[])
2527a2
 				"No sensors found!\n"
2527a2
 				"Make sure you loaded all the kernel drivers you need.\n"
2527a2
 				"Try sensors-detect to find out which these are.\n");
2527a2
-			err = 1;
2527a2
+			if (!allow_no_sensors) {
2527a2
+				err = 1;
2527a2
+			}
2527a2
 		}
2527a2
 	} else {
2527a2
 		int cnt = 0;
2527a2
diff --git a/prog/sensors/sensors.1 b/prog/sensors/sensors.1
2527a2
index 7d66e4b..d207aa1 100644
2527a2
--- a/prog/sensors/sensors.1
2527a2
+++ b/prog/sensors/sensors.1
2527a2
@@ -78,6 +78,8 @@ are only needed if you have several chips sharing the same address on different
2527a2
 buses of the same type. As bus numbers are usually not guaranteed to be stable
2527a2
 over reboots, these statements let you refer to each bus by its name rather
2527a2
 than numbers.
2527a2
+.IP "-n, --allow-no-sensors"
2527a2
+Do not fail if no sensors found. The error message will be printed in the log.
2527a2
 .SH FILES
2527a2
 .I /etc/sensors3.conf
2527a2
 .br