rpms/gkrellm/devel gkrellm-2.3.0-libsensors4.patch, NONE, 1.1 gkrellm.spec, 1.11, 1.12

Hans de Goede (jwrdegoede) fedora-extras-commits at redhat.com
Sun Oct 28 10:23:02 UTC 2007


Author: jwrdegoede

Update of /cvs/extras/rpms/gkrellm/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv28496

Modified Files:
	gkrellm.spec 
Added Files:
	gkrellm-2.3.0-libsensors4.patch 
Log Message:
Add support for lm_sensors-3.0.0 (not building yet as lm_sensors-3.0.0 isn't in the repo yet)

gkrellm-2.3.0-libsensors4.patch:

--- NEW FILE gkrellm-2.3.0-libsensors4.patch ---
diff -up gkrellm-2.3.0/src/sysdeps/linux.c.libsensors4 gkrellm-2.3.0/src/sysdeps/linux.c
--- gkrellm-2.3.0/src/sysdeps/linux.c.libsensors4	2007-07-07 01:57:20.000000000 +0200
+++ gkrellm-2.3.0/src/sysdeps/linux.c	2007-10-28 11:08:47.000000000 +0100
@@ -2055,14 +2055,14 @@ check_voltage_name(const gchar *name, gi
 static gboolean
 libsensors_init(void)
 	{
-	gint			nr, nr1, nr2, len;
-	const sensors_chip_name		*name;
-	const sensors_feature_data	*feature;
-	gchar			*label, *s;
-	FILE			*f;
+	gint			nr, len, iodev;
+	const sensors_chip_name	*name;
+	gchar			*label, *busname, *s;
 	gchar			id_name[512], sensor_path[512];
 	gint			type, n_sensors_added;
 	ConfigMap		*config_map;
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
+	FILE			*f;
 
 	f = fopen("/etc/sensors.conf", "r");
 	if (!f)
@@ -2087,7 +2087,8 @@ libsensors_init(void)
 	nr = 0;
 	while ((name = sensors_get_detected_chips(&nr)))
 		{
-		nr1 = 0, nr2 = 0;
+		const sensors_feature_data	*feature;
+		gint nr1 = 0, nr2 = 0;
 		while ((feature = sensors_get_all_features(*name, &nr1, &nr2)))
 			{
 			if (   sensors_get_ignored(*name, feature->number)
@@ -2137,6 +2138,11 @@ libsensors_init(void)
 					continue;
 					}
 
+				/* notice that we store the bus and addr both in iodev as
+				|  2 _signed 16 bit ints. */
+				iodev = (name->bus & 0xFFFF) | (name->addr << 16);
+				busname = name->busname;
+				
 				if (sensors_get_label(*name, feature->number, &label) != 0)
 					{
 					if (_GK.debug_level & DEBUG_SENSORS)
@@ -2144,7 +2150,119 @@ libsensors_init(void)
 								id_name);
 					label = NULL;
 					}
+#else /* libsensors4 code */
+	if (sensors_init(NULL) != 0)
+		{
+		if (_GK.debug_level & DEBUG_SENSORS)
+			printf("libsensors: init failed!\n");
+		return FALSE;
+		}
+
+	if (_GK.debug_level & DEBUG_SENSORS)
+		printf("libsensors: init OK\n");
+
+	n_sensors_added = 0;
+	nr = 0;
+	while ((name = sensors_get_detected_chips(NULL, &nr)))
+		{
+		const sensors_subfeature *feature;
+		const sensors_feature *main_feature;
+		gint nr1 = 0;
+		while ((main_feature = sensors_get_features(name, &nr1)))
+			{
+			switch (name->bus.type)
+			  {
+			  case SENSORS_BUS_TYPE_I2C:
+			  case SENSORS_BUS_TYPE_SPI:
+				snprintf(id_name, sizeof(id_name), "%s@%d:%x/%s",
+					name->prefix, name->bus.nr, name->addr, main_feature->name);
+				break;
+			  default:
+				snprintf(id_name, sizeof(id_name), "%s@%x/%s",
+					name->prefix, name->addr, main_feature->name);
+			          
+			  }
+			/* We need to store both the prefix and the path, but we
+			|  only have one string, so concat them together separated by :
+			*/
+			snprintf(sensor_path, sizeof (sensor_path), "%s:%s",
+				name->prefix, name->path ? name->path : "NULL");
+
+			switch (main_feature->type)
+			  {
+			  case SENSORS_FEATURE_IN:
+				type = SENSOR_VOLTAGE;
+				feature = sensors_get_subfeature(name, 
+						main_feature, SENSORS_SUBFEATURE_IN_INPUT);
+			  	break;
+			  case SENSORS_FEATURE_FAN:
+				type = SENSOR_FAN;
+				feature = sensors_get_subfeature(name, 
+						main_feature, SENSORS_SUBFEATURE_FAN_INPUT);
+				break;
+			  case SENSORS_FEATURE_TEMP:
+				type = SENSOR_TEMPERATURE;
+				feature = sensors_get_subfeature(name, 
+						main_feature, SENSORS_SUBFEATURE_TEMP_INPUT);
+				break;
+			  default:
+				if (_GK.debug_level & DEBUG_SENSORS)
+					printf("libsensors: error determining type for: %s\n",
+							id_name);
+				continue;
+			  }
+
+			if (!feature)
+				{
+				if (_GK.debug_level & DEBUG_SENSORS)
+					printf("libsensors: error could not get input subfeature for: %s\n",
+							id_name);
+				continue;
+				}
+
+			/* failsafe tests, will bus type and nr fit in 8 bits
+			   signed and addr fit in 16 bits signed ?
+			*/
+			if (name->bus.type != ((name->bus.type << 24) >> 24))
+				{
+				if (_GK.debug_level & DEBUG_SENSORS)
+					printf("libsensors: bus-type bigger than 8 bits: %s\n",
+							id_name);
+				continue;
+				}
+			if (name->bus.nr != ((name->bus.nr << 24) >> 24))
+				{
+				if (_GK.debug_level & DEBUG_SENSORS)
+					printf("libsensors: bus-nr bigger than 8 bits: %s\n",
+							id_name);
+				continue;
+				}
+			if (name->addr != ((name->addr << 16) >> 16))
+				{
+				if (_GK.debug_level & DEBUG_SENSORS)
+					printf("libsensors: addr bigger than 16 bits: %s\n",
+							id_name);
+				continue;
+				}
 
+			/* notice that we store the bus id, type and addr in
+			   iodev as 2 signed 8 bit ints and one 16 bit int */
+			iodev = (name->bus.type & 0xFF) |
+				((name->bus.nr & 0xFF) << 8) |
+				(name->addr << 16);
+			busname = name->path;
+
+			label = sensors_get_label(name, main_feature);
+			if (!label && (_GK.debug_level & DEBUG_SENSORS))
+				printf("libsensors: error getting label for: %s\n",
+						id_name);
+
+			/* additional { to match "if (get_ignored(..) {"
+			   from libsensors3 code */
+				{
+#endif
+				if (label)
+				{
 				/* Strip some common post/prefixes for smaller default labels
 				*/
 				len = strlen(label);
@@ -2171,14 +2289,13 @@ libsensors_init(void)
 						memmove(label, label + 4, strlen (label + 4) + 1);
 					break;
 				  }
-				/* notice that we store the bus and addr both in iodev as
-				|  2 _signed 16 bit ints.  Default factor of zero tells
-				|  sensor.c that sensor formula is handled, ie via
+				}
+				/* Default factor of zero tells sensor.c
+				|  that sensor formula is handled, ie via
 				|  /etc/sensors.conf.
 				*/
 				gkrellm_sensors_add_sensor(type, sensor_path, id_name,
-							feature->number,
-							(name->bus & 0xFFFF) | (name->addr << 16),
+							feature->number, iodev,
 							LIBSENSORS_INTERFACE, 0.0, 0.0,
 							NULL, label);
 				++n_sensors_added;
@@ -2188,10 +2305,10 @@ libsensors_init(void)
 				if (_GK.debug_level & DEBUG_SENSORS)
 					printf("%s %s %x\n",
 							sensor_path, id_name,
-							(name->bus & 0xFFFF) | (name->addr << 16));
+							iodev);
 
-				if (   name->busname
-				    && (s = strrchr(name->busname, '/')) != NULL
+				if (   busname
+				    && (s = strrchr(busname, '/')) != NULL
 				    && *(s + 1)
 				   )
 					{
@@ -2229,8 +2346,9 @@ libsensors_get_value(char *sensor_path, 
 		}
 	*p = 0;						/* We must undo this !! (or make a copy) */
 	name.prefix = sensor_path;
-	name.bus = (iodev << 16) >> 16;	/* sign extend the low 16 bits */
 	name.addr = iodev >> 16;
+#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
+	name.bus = (iodev << 16) >> 16;	/* sign extend the low 16 bits */
 	name.busname = p + 1;
 	if (!strcmp(name.busname, "NULL"))
 		name.busname = NULL;
@@ -2248,6 +2366,32 @@ libsensors_get_value(char *sensor_path, 
 					name.prefix, name.addr, id);
 		}
 
+#else /* libsensors4 code */
+	name.bus.type = (iodev << 24) >> 24; /* sign extend the low 8 bits */
+	name.bus.nr   = (iodev << 16) >> 24; /* sign extend the 2nd byte */
+	name.path = p + 1;
+	if (!strcmp(name.path, "NULL"))
+		name.path = NULL;
+
+	result = sensors_get_value(&name, id, &val) == 0;
+	
+	if (!result && (_GK.debug_level & DEBUG_SENSORS))
+		{
+			switch (name.bus.type)
+			  {
+			  case SENSORS_BUS_TYPE_I2C:
+			  case SENSORS_BUS_TYPE_SPI:
+				printf(
+					"libsensors: error getting value for: %s@%d:%x feature: %d\n",
+					name.prefix, (int)name.bus.nr, name.addr, id);
+				break;
+			  default:
+				printf("libsensors: error getting value for: %s@%x feature: %d\n",
+					name.prefix, name.addr, id);
+			  }
+		}
+#endif
+
 	if (value)
 		*value = val;
 


Index: gkrellm.spec
===================================================================
RCS file: /cvs/extras/rpms/gkrellm/devel/gkrellm.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- gkrellm.spec	5 Sep 2007 15:01:26 -0000	1.11
+++ gkrellm.spec	28 Oct 2007 10:22:29 -0000	1.12
@@ -1,6 +1,6 @@
 Name:           gkrellm
 Version:        2.3.0
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Multiple stacked system monitors in one process
 Group:          Applications/System
 License:        GPLv3+
@@ -14,6 +14,7 @@
 Patch2:         gkrellm-2.2.4-sansfont.patch
 Patch3:         gkrellm-2.2.7-width.patch
 Patch4:         gkrellm-2.2.9-libdir.patch
+Patch5:         gkrellm-2.3.0-libsensors4.patch
 BuildRequires:  gtk2-devel gnutls-devel libSM-devel desktop-file-utils gettext
 BuildRequires:  lm_sensors-devel
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -63,6 +64,7 @@
 %patch2 -p1 -z .sansfont
 %patch3 -p1 -z .width
 %patch4 -p1 -z .libdir2
+%patch5 -p1 -z .libsensors4
 
 for i in gkrellmd.1 gkrellm.1 README Changelog Changelog-plugins.html; do
    sed -i -e "s@/usr/lib/gkrellm2/plugins@%{_libdir}/gkrellm2/plugins@" $i
@@ -169,6 +171,9 @@
 
 
 %changelog
+* Wed Oct 24 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 2.3.0-5
+- Add support for lm_sensors-3.0.0
+
 * Wed Sep  5 2007 Ville Skyttä <ville.skytta at iki.fi> - 2.3.0-4
 - Rewrite gkrellmd init script: better LSB compliance, hddtemp
   interoperability, avoidance of X error messages, general cleanup.




More information about the fedora-extras-commits mailing list