therm_adt746x sensor broken

Bug #2498 reported by Francesco Accattapà
4
Affects Status Importance Assigned to Milestone
torsmo (Ubuntu)
Invalid
Medium
MOTU Reviewers Team

Bug Description

Torsmo is unable to monitor cpu temperature and fan speed on my iBook G4. This is due to two different problems:

1) the $adt746xcpu and $adt746xfan keyword are not parsed, although it exists some code to handle them.

2) after kernel 2.6.12 the therm_adt746x modules changed the name of some files in /sys/devices/temperatures: in detail, "cpu_temperature" became "sensor1_temperature" and "cpu_fan_speed" became "sensor1_fan_speed".

Another (minor) issue is that torsmo could not monitor the GPU sensor temperature (namely /sys/devices/temperatures/sensor2_temperature).

I wrote a small patch that solves the first two issues and add support for the GPU sensor with the $adt746xgpu keyword: it seems to work well, so I decided to post it in this report. It is diffed against the full debian source of torsmo 0.18-5.

Here it is:

---------------------------------------------------------------------
diff -ur torsmo-0.18/linux.c torsmo-0.18.new/linux.c
--- torsmo-0.18/linux.c 2004-12-21 22:20:07.000000000 +0100
+++ torsmo-0.18.new/linux.c 2005-09-22 17:23:16.000000000 +0200
@@ -377,7 +377,7 @@
     return val;
 }

-#define ADT746X_FAN "/sys/devices/temperatures/cpu_fan_speed"
+#define ADT746X_FAN "/sys/devices/temperatures/sensor1_fan_speed"

 static char *adt746x_fan_state;

@@ -401,7 +401,7 @@
   return adt746x_fan_state;
 }

-#define ADT746X_CPU "/sys/devices/temperatures/cpu_temperature"
+#define ADT746X_CPU "/sys/devices/temperatures/sensor1_temperature"

 static char *adt746x_cpu_state;

@@ -415,12 +415,40 @@
   }

   fp = open_file(ADT746X_CPU, &rep);
- fscanf(fp, "%2s", adt746x_cpu_state);
- fclose(fp);
+ if (fp != NULL) {
+ fscanf(fp, "%2s", adt746x_cpu_state);
+ fclose(fp);
+ }
+ else
+ strcpy(adt746x_cpu_state, "No CPU sensor found.");

   return adt746x_cpu_state;
 }

+#define ADT746X_GPU "/sys/devices/temperatures/sensor2_temperature"
+
+static char *adt746x_gpu_state;
+
+char* get_adt746x_gpu() {
+ static int rep;
+ FILE *fp;
+
+ if (adt746x_gpu_state == NULL) {
+ adt746x_gpu_state = (char*)malloc(100);
+ assert(adt746x_gpu_state!=NULL);
+ }
+
+ fp = open_file(ADT746X_GPU, &rep);
+ if (fp != NULL) {
+ fscanf(fp, "%2s", adt746x_gpu_state);
+ fclose(fp);
+ }
+ else
+ strcpy(adt746x_gpu_state, "No GPU sensor found.");
+
+ return adt746x_gpu_state;
+}
+
 static char *frequency;

 char* get_freq()
diff -ur torsmo-0.18/torsmo.c torsmo-0.18.new/torsmo.c
--- torsmo-0.18/torsmo.c 2005-09-22 17:10:43.000000000 +0200
+++ torsmo-0.18.new/torsmo.c 2005-09-22 17:13:08.000000000 +0200
@@ -283,6 +283,7 @@
   OBJ_acpiacadapter,
   OBJ_adt746xcpu,
   OBJ_adt746xfan,
+ OBJ_adt746xgpu,
   OBJ_acpifan,
   OBJ_acpitemp,
   OBJ_battery,
@@ -477,6 +478,12 @@
   END
   OBJ(acpiacadapter, 0)
   END
+ OBJ(adt746xcpu, 0)
+ END
+ OBJ(adt746xfan, 0)
+ END
+ OBJ(adt746xgpu, 0)
+ END
   OBJ(freq, 0)
   END
   OBJ(acpifan, 0)
@@ -894,6 +901,9 @@
     OBJ(adt746xfan) {
       snprintf(p, n, "%s", get_adt746x_fan());
     }
+ OBJ(adt746xgpu) {
+ snprintf(p, n, "%s", get_adt746x_gpu());
+ }
     OBJ(acpifan) {
       snprintf(p, n, "%s", get_acpi_fan());
     }
diff -ur torsmo-0.18/torsmo.h torsmo-0.18.new/torsmo.h
--- torsmo-0.18/torsmo.h 2004-12-21 22:49:17.000000000 +0100
+++ torsmo-0.18.new/torsmo.h 2005-09-22 17:13:08.000000000 +0200
@@ -177,6 +177,7 @@

 char* get_adt746x_cpu(void);
 char* get_adt746x_fan(void);
+char* get_adt746x_gpu(void);

 int open_acpi_temperature(const char *name);
 double get_acpi_temperature(int fd);
---------------------------------------------------------------------

Revision history for this message
Francesco Accattapà (callipeo) wrote : therm_adt746x

Ops. Including the patch inline in the report was not a good idea. Sorry.

Changed in torsmo:
assignee: nobody → motu
Zak B. Elep (zakame)
Changed in torsmo:
assignee: motu → motureviewers
Revision history for this message
Barry deFreese (bddebian) wrote :

My apologies but torsmo is no longer in the archive in Debian or Ubuntu. If you would like to see this package come back, please ask for someone to package it. Thank you.

Changed in torsmo:
status: Unconfirmed → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.