From 3ea4545611b6022e536782f07435966cf91603d0 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 15 Feb 2009 17:19:03 +0000 Subject: [PATCH] Make it possible to only substitute the bus number of a subset of the chip entries. This is a prerequisite to add support for multiple configuration files. Each configuration file can come with its own bus statements and the bus number substitution should only affect chip entries from the same configuration file. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5646 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/data.c | 10 ++++++++-- lib/data.h | 3 ++- lib/init.c | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/data.c b/lib/data.c index df58242d..e30becc1 100644 --- a/lib/data.c +++ b/lib/data.c @@ -1,7 +1,7 @@ /* data.c - Part of libsensors, a Linux library for reading sensor data. Copyright (c) 1998, 1999 Frodo Looijaard - Copyright (C) 2007 Jean Delvare + Copyright (C) 2007, 2009 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ const char *libsensors_version = LM_VERSION; sensors_chip *sensors_config_chips = NULL; int sensors_config_chips_count = 0; +int sensors_config_chips_subst = 0; int sensors_config_chips_max = 0; sensors_bus *sensors_config_busses = NULL; @@ -226,13 +227,17 @@ static int sensors_substitute_chip(sensors_chip_name *name, int lineno) return 0; } +/* Bus substitution is on a per-configuration file basis, so we keep + memory (in sensors_config_chips_subst) of which chip entries have been + already substituted. */ int sensors_substitute_busses(void) { int err, i, j, lineno; sensors_chip_name_list *chips; int res = 0; - for (i = 0; i < sensors_config_chips_count; i++) { + for (i = sensors_config_chips_subst; + i < sensors_config_chips_count; i++) { lineno = sensors_config_chips[i].lineno; chips = &sensors_config_chips[i].chips; for (j = 0; j < chips->fits_count; j++) { @@ -246,5 +251,6 @@ int sensors_substitute_busses(void) res = err; } } + sensors_config_chips_subst = sensors_config_chips_count; return res; } diff --git a/lib/data.h b/lib/data.h index d48d25e7..6f634a92 100644 --- a/lib/data.h +++ b/lib/data.h @@ -1,7 +1,7 @@ /* data.h - Part of libsensors, a Linux library for reading sensor data. Copyright (c) 1998, 1999 Frodo Looijaard - Copyright (C) 2007 Jean Delvare + Copyright (C) 2007, 2009 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -135,6 +135,7 @@ typedef struct sensors_chip_features { extern sensors_chip *sensors_config_chips; extern int sensors_config_chips_count; +extern int sensors_config_chips_subst; extern int sensors_config_chips_max; extern sensors_bus *sensors_config_busses; diff --git a/lib/init.c b/lib/init.c index 71af5aff..f1126dac 100644 --- a/lib/init.c +++ b/lib/init.c @@ -240,6 +240,7 @@ void sensors_cleanup(void) free(sensors_config_chips); sensors_config_chips = NULL; sensors_config_chips_count = sensors_config_chips_max = 0; + sensors_config_chips_subst = 0; for (i = 0; i < sensors_proc_bus_count; i++) free_bus(&sensors_proc_bus[i]);