Skip to contentSkip to conversation

ADM1030/ADM1031 user-space support

PATCH Jean Delvare 2 participants 8 messages May 19, 2005 Library code

lore
Share & tools
lore
#0 lore raw

Hi Avrel,

Here are my comments on your user-space support for the adm1031 driver.

kernel/chips/adm1031.c +0 -0
diff -urN -x CVS lm_sensors2/kernel/chips/adm1031.c lm_sensors2_mine/kernel/chips/adm1031.c

(...)
+/*
+ * For instance, this file is the placeholder for the SYSFS numbers
+ * needed for libsensors to work with the adm1031 / adm1030 chip. It
+ * does not contains any driver code yet.
+ */

"For instance" means "par exemple". The expression you need here is "For now" or "At the moment" or something similar.

Also, the values are not about Sysfs. Sysfs is for Linux 2.6. The values here are SYSCTL constants, which is something different.

+/*
+ * Addresses to scan
+ * Address is fully defined internally and cannot be changed.
+ */
+
+static unsigned short normal_i2c[] = { SENSORS_I2C_END }; +static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, SENSORS_I2C_END };

The comment doesn't match the code. If there are three possible addresses, then the address is not "fully defined" and can be changed.

kernel/chips/adm1031.c~ +0 -0
diff -urN -x CVS lm_sensors2/kernel/chips/adm1031.c~ lm_sensors2_mine/kernel/chips/adm1031.c~

Please don't include backup files into the diffs ;)

lib/chips.c +14 -0
diff -urN -x CVS lm_sensors2/lib/chips.c lm_sensors2_mine/lib/chips.c
@@ -360,6 +360,110 @@
     { 0 }
   };
 
+
+static sensors_chip_feature adm1030_features[] +  {
+    { SENSORS_ADM1031_TEMP1, "temp1_input", NOMAP, NOMAP,
+                              R, ADM1031_SYSCTL_TEMP1, VALUE(4), 
+                              3 },
+    { SENSORS_ADM1031_TEMP1_MIN, "temp1_min", SENSORS_ADM1031_TEMP1, SENSORS_ADM1031_TEMP1,
+                              RW, ADM1031_SYSCTL_TEMP1_MIN, VALUE(1), 
+                              3 },
+    { SENSORS_ADM1031_TEMP1_MAX, "temp1_max", SENSORS_ADM1031_TEMP1, SENSORS_ADM1031_TEMP1,
+                              RW, ADM1031_SYSCTL_TEMP1_MAX, VALUE(2), 
+                              3 },
+    { SENSORS_ADM1031_TEMP1_CRIT, "temp1_crit", SENSORS_ADM1031_TEMP1, SENSORS_ADM1031_TEMP1,
+                              RW, ADM1031_SYSCTL_TEMP1_CRIT, VALUE(3), 
+                              3 },
 

The usual order is: max, min, crit, current. And you should not include the "_input" in the symbol name. The library knows that readings map to the same symbol with "_input" appended in 2.6. This is important because the symbol name is used by default by "sensors" when no label is given, and long names break the output (I guess you had noticed).

Also, please move the trailing "3" on the previous line each time, it definitely fits.

+ { SENSORS_ADM1031_ALARMS, "alarms", NOMAP,
+ NOMAP, RW,
+ ADM1031_SYSCTL_ALARMS, VALUE(1), 0 },
+ { 0 }

RW, really?

Same applies to the adm1031 table, of course.

lib/chips.h +9 -0
diff -urN -x CVS lm_sensors2/lib/chips.h lm_sensors2_mine/lib/chips.h
@@ -184,6 +184,36 @@
+#define SENSORS_ADM1031_TEMP3 71 /* R */
+#define SENSORS_ADM1031_TEMP3_MIN 72 /* RW */
+#define SENSORS_ADM1031_TEMP3_MAX 73 /* RW */
+#define SENSORS_ADM1031_TEMP3_CRIT 74 /* RW */
+
+#define SENSORS_ADM1031_FAN1 70 /* R */
+#define SENSORS_ADM1031_FAN1_MIN 71 /* R */
+#define SENSORS_ADM1031_FAN2 72 /* R */
+#define SENSORS_ADM1031_FAN2_MIN 73 /* R */
 

Values overlap! I guess you missed it because it doesn't matter for the ADM1030, but it does for the ADM1031.

Also, FAN_MINs are RW.

prog/sensors/chips.c +11 -0
diff -urN -x CVS lm_sensors2/prog/sensors/chips.c lm_sensors2_mine/prog/sensors/chips.c
@@ -4726,6 +4726,117 @@
   free_the_label(&label);
 }
 
+
+void print_adm1031(const sensors_chip_name *name)
+{
+  char *label;
+  double cur, high, low, crit;
+  int valid, alarms;
+  int type = 0;
+
+  if (strncmp("adm1030", name->prefix, 7)){
+      type = 1;
+  }
 

"type" isn't exactly an explicit variable name IMHO. And you should default to the less featured chip. What about:

  int is_1031 = !strncmp("adm1031", name->prefix, 7);

+ if (!sensors_get_label_and_valid(*name, SENSORS_ADM1031_TEMP1,
+ &label, &valid)

+      && !sensors_get_feature(*name, SENSORS_ADM1031_TEMP1, &cur)
+      && !sensors_get_feature(*name, SENSORS_ADM1031_TEMP1_MIN, &low)
+      && !sensors_get_feature(*name, SENSORS_ADM1031_TEMP1_MAX, &high)
+      && !sensors_get_feature(*name, SENSORS_ADM1031_TEMP1_CRIT, &crit)) {
+    if (valid) {
+      print_label(label, 10);
+      print_temp_info(cur, high, crit, CRIT, 0, 0);
+      printf(" %s\n",
+	     alarms&ADM1031_ALARM_TEMP1_CRIT?"CRITICAL":
+	     alarms&(ADM1031_ALARM_TEMP1_HIGH|ADM1031_ALARM_TEMP1_LOW)?"ALARM":"");

+ }
+ } else
+ printf("ERROR: Can't get temp1 temperature data!\n");
+ free_the_label(&label);

You retrieve the MIN value but never display it.

I'd suggest that you display values on two lines: current reading, min and max on the fisrt line, and crit on a second. That's what I do for the PC87366, if you want to take a look.

Also, why do you trim the extra resolution? You should display one decimal place, just like you do for temp2 and temp3.

+ alarms&ADM1031_ALARM_TEMP2_DIODE?"DIODE_ERROR":

Open diode condition is typically displayed "OPEN" or "DISCONNECT" (we should standardize this, BTW).

Additional comment:

It should be possible to refactor part of the code if the various constants have been chosen wisely. At the beginning of the print function, instead of storing the chip type as a boolean, use it to define two integers, representing the number of temperature channels and the number of fans.

Then have two "for" loops, one for fans, one for temperatures (BTW we usually print them in this order).

This of course requires that, for example, SENSORS_ADM1031_TEMP2 is defined as SENSORS_ADM1031_TEMP1 + 1 (or any other constant as long as you are consistent), and the same for all other SENSORS_ constants. This should help reduce the size of the sensors program, which tends to grow out of limit as we add support for more and more chips.

Actually you may not be able to factor temp1 because alarm bits are different... but you should be able to factor temp2 with temp3 and fan1 with fan2. I've done that for the pc87366 and it helped much (it has 11 voltage inputs...) It's not possible to do this for all chips, it really depends how logical the chip designers have been when placing the alarm bits.

Also, please provide a sample configuration section in etc/sensors.conf.eg. It doesn't have to be long and complex, we just need a placeholder so that people can change labels, set limits etc...

A preliminary doc/chips/adm1031 file would be welcome as well, even if there is no 2.4 driver yet. Present the chips briefly, who made them, what they do, and that there is no driver yet ;) Pick any file from this directory for examples.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#1 lore raw

Hi,

Here is attached an updated version of the user-space support for the adm1030 type of chips according to Jean's comments.

Thanks,

Signature · 11 lines
-------------------------------------------------
Alexandre d'ALTON
                              [email protected]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: adm1031_lm_sensors2.diff
Type: application/octet-stream
Size: 19929 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040517/d874e7a9/adm1031_lm_sensors2.obj
#2 lore raw
In reply to Jean Delvare

Hi,

I've taken into acount your comments, fixed them.

I've also added a preliminary driver for the chips with the 2.4 style, It compiles but It is not tested yet.

It supports only temperatures, fans and alarms.

I've not implemented auto_fan stuff nor fan_div or pwm.

Thanks,

Alex.

Quoting Jean Delvare <[email protected]>:

Quoted 65 lines
Quoted 2 lines

Here is attached an updated version of the user-space support for the adm1030 type of chips according to Jean's comments.

diff -urN -x CVS lm_sensors2/etc/sensors.conf.eg
lm_sensors2_mine/etc/sensors.conf.eg

etc/sensors.conf.eg +12 -0
@@ -2113,3 +2113,15 @@
    set fan1_min 2000
    set fan2_min 2000
    set fan3_min 2000
+
+chip "adm1030-*"
+label temp1_input "SYS Temp"
+label temp2_input "CPU Temp"
+label fan1_input "CPU Fan"
+
+chip "adm1031-*"
+label temp1_input "SYS Temp"
+label temp2_input "CPU Temp1"
+label temp3_input "CPU Temp2"
+label fan1_input "Fan1"
+label fan2_input "Fan2"

Please indent the same way the other sections are. You forgot to remove the "_input" suffixes.

diff -urN -x CVS lm_sensors2/lib/chips.c lm_sensors2_mine/lib/chips.c

lib/chips.c +3 -0
@@ -360,6 +360,90 @@
+    { SENSORS_ADM1031_FAN1, "fan1_input", NOMAP, 
+                              NOMAP, R, 
+                              ADM1031_SYSCTL_FAN1, VALUE(2), 0 },
 

Here too you forgot to remove "_input". Same for the adm1031 right below.

diff -urN -x CVS lm_sensors2/prog/sensors/chips.c
lm_sensors2_mine/prog/sensors/chips.c

prog/sensors/chips.c +4 -0
+0200
+  for(i=0; i<(is_1031?2:1);i++) {
+      if (!sensors_get_label_and_valid(*name, SENSORS_ADM1031_FAN1,
+				       &label, &valid)

You always get fan1 label.

prog/sensors/chips.c +6 -0
+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1+i*2, &cur)
+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1_MIN+i*2, &low)
+	  ) {
+	  if (valid) {
+	      print_label(label, 10);
+	      printf("%4.0f RPM  (min = %4.0f )", cur, low);

"RPM" missing for low limit.

The rest of it looks good to me.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
Signature · 11 lines
-------------------------------------------------
Alexandre d'ALTON
                              [email protected]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: adm1031_lm_sensors2.diff
Type: application/octet-stream
Size: 34062 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040518/873db4b8/adm1031_lm_sensors2.obj
#3 lore raw
In reply to Jean Delvare
Quoted 2 lines

Here is attached an updated version of the user-space support for the adm1030 type of chips according to Jean's comments.

etc/sensors.conf.eg +12 -0
diff -urN -x CVS lm_sensors2/etc/sensors.conf.eg lm_sensors2_mine/etc/sensors.conf.eg
@@ -2113,3 +2113,15 @@
    set fan1_min 2000
    set fan2_min 2000
    set fan3_min 2000
+
+chip "adm1030-*"
+label temp1_input "SYS Temp"
+label temp2_input "CPU Temp"
+label fan1_input "CPU Fan"
+
+chip "adm1031-*"
+label temp1_input "SYS Temp"
+label temp2_input "CPU Temp1"
+label temp3_input "CPU Temp2"
+label fan1_input "Fan1"
+label fan2_input "Fan2"

Please indent the same way the other sections are. You forgot to remove the "_input" suffixes.

lib/chips.c +3 -0
diff -urN -x CVS lm_sensors2/lib/chips.c lm_sensors2_mine/lib/chips.c
@@ -360,6 +360,90 @@
+    { SENSORS_ADM1031_FAN1, "fan1_input", NOMAP, 
+                              NOMAP, R, 
+                              ADM1031_SYSCTL_FAN1, VALUE(2), 0 },
 

Here too you forgot to remove "_input". Same for the adm1031 right below.

prog/sensors/chips.c +0 -0
diff -urN -x CVS lm_sensors2/prog/sensors/chips.c lm_sensors2_mine/prog/sensors/chips.c

+ for(i=0; i<(is_1031?2:1);i++) {
+ if (!sensors_get_label_and_valid(*name, SENSORS_ADM1031_FAN1,
+ &label, &valid)

You always get fan1 label.

+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1+i*2, &cur)
+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1_MIN+i*2, &low)
+	  ) {
+	  if (valid) {

+ print_label(label, 10);
+ printf("%4.0f RPM (min = %4.0f )", cur, low);

"RPM" missing for low limit.

The rest of it looks good to me.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#4 lore raw
In reply to Jean Delvare

Hi Alexandre,

Here are my comments about your latest 2.4 and user-space code (from your website, *not* from the previous post).

doc/chips/adm1031 +2 -0
diff -urN -x CVS lm_sensors2/doc/chips/adm1031 lm_sensors2_mine/doc/chips/adm1031
@@ -0,0 +1,100 @@
+Kernel driver `adm1031.o'
+===========

Please extend the underline as needed.

+Status: User space support and preliminary 2.4 driver.

The status is supposed to be about the 2.4 driver. User-space support is almost mandatory anyway. "Preliminary, untested" is probably fine (for now).

+Supported chips:
+ * Analog Devices ADM1030

+    Prefix: `adm1030'
+    Addresses scanned: I2C 0x2c 0x2e
+    Datasheet: Publicly available at the Analog Devices website
+               http://products.analog.com/products/info.asp?product­M1030
+
+  * Analog Devices ADM1031
+    Prefix: `adm1031'
+    Addresses scanned: I2C 0x2c 0x2e
+    Datasheet: Publicly available at the Analog Devices website

+ http://products.analog.com/products/info.asp?product­M1031

Please express the fact that this is the range from 0x2c to 0x2e, not only these two addresses.

+ADM1030 and ADM1031 are digital temperature sensors and fan controllers. +They senses their own temperature as well as the temperature of up to two
+ external diodes.

No indentation please.

+Each sensor has its own high and low limits, plus a critical limit.

This only applies to temperature sensors. Fan sensors only have a low limit.

+LABEL                 LABEL CLASS           COMPUTE CLASS          MODE  MAGN
+temp1                 -                     -                       R-     0
+temp1_high            temp1                 temp1                   RW     0
+temp1_low             temp1                 temp1                   RW     0
+temp1_crit
+temp2                 -                     -                       R-     1
+temp2_high            temp2                 temp2                   RW     1
+temp2_low             temp2                 temp2                   RW     1

+temp2_crit

Data missing for critical limits.

The driver seems to export all temperatures with a magnitude of 3, not 0 and 1 as documented above.

(Same for adm1031.)

kernel/chips/Module.mk +1 -0
@@ -39,6 +39,7 @@
 KERNELCHIPSTARGETS += $(MODULE_DIR)/w83627hf.o
 KERNELCHIPSTARGETS += $(MODULE_DIR)/w83l785ts.o
 KERNELCHIPSTARGETS += $(MODULE_DIR)/xeontemp.o
+KERNELCHIPSTARGETS += $(MODULE_DIR)/adm1031.o
 

Please respect the alphabetical order.

kernel/chips/adm1031.c +0 -0
diff -urN -x CVS lm_sensors2/kernel/chips/adm1031.c lm_sensors2_mine/kernel/chips/adm1031.c

(...)
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/i2c-proc.h>

Please include "version.h" as well, and use it. This is very helpful for helping users.

+/* Following macros takes channel parameter starting from 0 to 2 */
+#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
+

+#define ADM1031_REG_FAN_DIV(nr)         (0x20  + (nr))
+#define ADM1031_REG_PWM                 (0x22)
+#define ADM1031_REG_FAN_MIN(nr)         (0x10 + (nr))

These are from 0 to 1 only. Maybe "starting from 0" would be enough.

+#define ADM1031_CONF2_PWM1_ENABLE 0x01
+#define ADM1031_CONF2_PWM2_ENABLE 0x02

Indentation. Btw, you are supposed to align constants using tabs, not spaces.

+#define ADM1031_SYSCTL_FAN1        1230
+#define ADM1031_SYSCTL_FAN1_MIN    1231
+#define ADM1031_SYSCTL_FAN1_DIV    1233
+#define ADM1031_SYSCTL_FAN2        1240
+#define ADM1031_SYSCTL_FAN2_MIN    1241
+#define ADM1031_SYSCTL_FAN2_DIV    1242

Strange choices for fan divisors. Shouldn't ADM1031_SYSCTL_FAN2_DIV be 1243?

+static ctl_table adm1031_dir_table_template[] = {
+ {ADM1031_SYSCTL_TEMP1, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_temp},
+ {ADM1031_SYSCTL_TEMP2, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_temp},
+ {ADM1031_SYSCTL_TEMP3, "temp3", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_temp},
+ {ADM1031_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan},
+ {ADM1031_SYSCTL_FAN1_DIV, "fan1_div", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan_div},
+ {ADM1031_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan},
+ {ADM1031_SYSCTL_FAN2_DIV, "fan2_div", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan_div},
+ {ADM1031_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_alarms},
+};
+
+static ctl_table adm1030_dir_table_template[] = {
+ {ADM1031_SYSCTL_TEMP1, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_temp},
+ {ADM1031_SYSCTL_TEMP2, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_temp},
+ {ADM1031_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan},
+ {ADM1031_SYSCTL_FAN1_DIV, "fan1_div", NULL, 0, 0644, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_fan_div},
+ {ADM1031_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real,
+ &i2c_sysctl_real, NULL, &adm1031_alarms},
+};

Both tables miss their trailing {0}. As a result, I am seeing both lists of files for my ADM1031. This means that some files appear twice in the procfs directory, which is no good.

+/* Each client has this additional data */
+struct adm1031_data {
+ struct i2c_client client;
+ int sysctl_id;

Indentation.

+ /* The chan_select_table contains the possible configurations for
+ * auto fan control.
+ */

Comment is irrelevant for this version of the driver.

+ s8 temp[3];
+ u8 ext_temp[3];

I'm a bit surprised. Wouldn't it be easier to store these temperatures in a 16-bit integer?

+#define TEMP_TO_REG(val) ((val < 0 ? ((val - 500) / 1000) & 0xff : \
+ ((val + 500) / 1000) & 0xff))

The "& 0xff" is completely irrelevant. It doesn't limit the value. If the user selects a value outside of the allowed range (which by the way is probably -55,+127, not -128,+127) he/she will get some random value. This is no good.

+#define TEMP_FROM_REG(val) (val * 1000)
+
+#define TEMP_FROM_REG_EXT(val, ext) (TEMP_FROM_REG(val) + (ext) * 125)
+
+#define FAN_FROM_REG(reg, div) ((reg) ? (11250 * 60) / ((reg) * (div)) : 0)
+
+#define FAN_TO_REG(reg, div) FAN_FROM_REG(SENSORS_LIMIT(reg, 0, 65535), div)

You parameter name choices are confusing. You should use reg for FROM_REG macros, and val for TO_REG ones. BTW, don't forget to surround the parameters with parentheses each time you use them.

+#define FAN_DIV_TO_REG(val) \

+            val = 8 ? 0xc0 :        \
+            val = 4 ? 0x80 :        \
+            val = 2 ? 0x40 :        \
+            val = 1 ? 0x00 :  0xFF

You don't handle 0xFF specially in your code. So you should just default to some value (2).

+#ifdef DEBUG
+ oldh + adm1031_read_value(client,
+ ADM1031_REG_TEMP(chan));
+
+ /* oldh is actually newer */
+ if (newh != oldh)
+ dev_warn(&client->dev,
+ "Remote temperature may be "
+ "wrong.\n");
+#endif

I don't think that dev_warn exists in 2.4.

+ if (data->chip_type = adm1031) {
+ data->alarms + (adm1031_read_value(client, ADM1031_REG_STATUS(0)) &
+ 0xff) |
+ ((adm1031_read_value(client, ADM1031_REG_STATUS(1))
+ << 8) & 0xff00);
+ } else if (data->chip_type = adm1030) {
+ data->alarms + (adm1031_read_value(client, ADM1031_REG_STATUS(0)) &
+ 0xff) |
+ ((adm1031_read_value(client, ADM1031_REG_STATUS(1))
+ << 8) & 0xc000);
+ }

You probably can simplify this. For one thing, & 0xff and & 0xff00 are useless. Second, you can read both registers regardless of the chip type, and mask the result afterwards.

+
+ data->fan_div[0] + adm1031_read_value(client, ADM1031_REG_FAN_DIV(0));
+ data->fan_min[0] + adm1031_read_value(client, ADM1031_REG_FAN_MIN(0));
+ data->fan[0] + adm1031_read_value(client, ADM1031_REG_FAN_SPEED(0));
+
+ data->conf1 = adm1031_read_value(client, ADM1031_REG_CONF1);
+
+ data->conf2 = adm1031_read_value(client, ADM1031_REG_CONF2);
+
+ if (data->chip_type = adm1031) {
+ data->fan_div[1] + adm1031_read_value(client, ADM1031_REG_FAN_DIV(1));
+ data->fan_min[1] + adm1031_read_value(client, ADM1031_REG_FAN_MIN(1));
+ data->fan[1] + adm1031_read_value(client,
+ ADM1031_REG_FAN_SPEED(1));

Please merge fan codes. Same as for temperatures, do a for look those upper limit depends on the chip type.

+static void adm1031_temp(struct i2c_client *client, int operation, int ctl_name,
+ int *nrels_mag, long *results)
+{
+ int ext;
+ struct adm1031_data * data = client->data;
+ int nr = (ctl_name - ADM1031_SYSCTL_TEMP1) / 10;

This is not clever. You are free to chose the SYSCTL constants as you want, so pick them in such a way that values sharing the same callback function have consecutive numbers.

+ if (*nrels_mag >=2) {
+ data->temp_crit[nr] = TEMP_TO_REG(results[2]);
+ adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), data->temp_crit[nr]);
+ }

Bug, this should be >= 3.

+ else if (operation = SENSORS_PROC_REAL_READ) {
+ adm1031_update_client(client);
+ results[0] = FAN_FROM_REG(data->fan_min[nr], FAN_DIV_FROM_REG(data->fan_div[nr]));
+ results[1] = FAN_FROM_REG(data->fan[nr], FAN_DIV_FROM_REG(data->fan_div[nr]));
+ } else if (operation = SENSORS_PROC_REAL_WRITE) {

Bug, you forget to set *nrels_mag to 2.

+ else if (operation = SENSORS_PROC_REAL_READ) {
+ adm1031_update_client(client);
+ results[0] = FAN_DIV_FROM_REG(data->fan_min[nr]);
+ } else if (operation = SENSORS_PROC_REAL_WRITE) {

Same problem here.

+ if(operation = SENSORS_PROC_REAL_INFO)
+ *nrels_mag = 1;

No, magnitude for fan divisors is 0.

+ if (*nrels_mag >= 1) {

+		    int old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
+		    data->fan_div[nr] = FAN_DIV_TO_REG(results[0]);
+		    adm1031_write_value(client, ADM1031_REG_FAN_DIV(nr), data->fan_div[nr]);
+		    data->fan_min[nr] = data->fan_min[nr] * old_div / data->fan_div[nr];

I think there's a problem there. old_div contains a real divider value (1 to 8), while data->fan_div[nr] contains a "packed" value (0 to 3). So the new fan_min value you compute promises to be bogus.

lib/chips.c +0 -0
diff -urN -x CVS lm_sensors2/lib/chips.c lm_sensors2_mine/lib/chips.c

+ { SENSORS_ADM1031_FAN1, "fan1", NOMAP,
+ NOMAP, R,
+ ADM1031_SYSCTL_FAN1, VALUE(2), 0 },
+ { SENSORS_ADM1031_FAN1_MIN, "fan1_min", SENSORS_ADM1031_FAN1,
+ SENSORS_ADM1031_FAN1, RW,
+ ADM1031_SYSCTL_FAN1_MIN, VALUE(1), 0 },
+ { SENSORS_ADM1031_FAN1_DIV, "fan1_div", SENSORS_ADM1031_FAN1,
+ SENSORS_ADM1031_FAN1, RW,
+ ADM1031_SYSCTL_FAN1_DIV, VALUE(1), 0 },
+ { SENSORS_ADM1031_FAN2, "fan2", NOMAP,
+ NOMAP, R,
+ ADM1031_SYSCTL_FAN2, VALUE(2), 0 },
+ { SENSORS_ADM1031_FAN2_MIN, "fan2_min", SENSORS_ADM1031_FAN2,
+ SENSORS_ADM1031_FAN2, RW,
+ ADM1031_SYSCTL_FAN2_MIN, VALUE(1), 0 },
+ { SENSORS_ADM1031_FAN2_DIV, "fan2_div", SENSORS_ADM1031_FAN2,
+ SENSORS_ADM1031_FAN2, RW,
+ ADM1031_SYSCTL_FAN2_DIV, VALUE(1), 0 },

Not quite. In 2.4, there is a single fan_div file, with as many values as fans.

prog/sensors/chips.c +0 -0
diff -urN -x CVS lm_sensors2/prog/sensors/chips.c lm_sensors2_mine/prog/sensors/chips.c

(...)
+ } else
+ printf("ERROR: Can't get temp1 temperature data!\n");
+ free_the_label(&label);

Please use different error messages for temp1 problems and temp1_crit problems.

Also, please print fan information before temperatures, this is how other drivers do.

I also have a problem with the 2.4 driver. I can't seem to get the limits values. sensors -u displays the readings OK, but there's an error on each limit. No idea what the problem is. Reading the procfs files directly is OK.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#5 lore raw
In reply to Jean Delvare
Quoted 4 lines

I also have a problem with the 2.4 driver. I can't seem to get the limits values. sensors -u displays the readings OK, but there's an error on each limit. No idea what the problem is. Reading the procfs files directly is OK.

Aha, just found why. You define one different SYSCTL number for each symbol. You are supposed to have one SYSCTL value per procfs file only. See how other drivers do.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#6 lore raw
In reply to Jean Delvare

Hi Alexandre,

I am testing your new adm1031 2.4 driver and userspace support at the moment. Here are my comments:

1* In sensors:

+ for(i=0; i<(is_1031?2:1);i++) {
+ if (!sensors_get_label_and_valid(*name, SENSORS_ADM1031_FAN1+i*10,
+ &label, &valid)

+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1+i*10, &cur)
+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1_MIN+i*10, &low)
+	  && !sensors_get_feature(*name, SENSORS_ADM1031_FAN1_DIV+i*10, &div)
+	  ) {
+	  if (valid) {
+	      print_label(label, 10);
+	      printf("%4.0f RPM  (min = %4.0f RPM, div = %1.0f)", cur, low, div);
+	      printf(" %s\n",
+		     alarms&(ADM1031_ALARM_FAN1_FLT<<(i*8))?"FAN_FAULT":
+		     alarms&((ADM1031_ALARM_FAN1_MIN<<(i*8)))?"ALARM":"");
+	      printf("\n");

Please drop this extra new line, it breaks the display.

+ }
+ } else
+ printf("ERROR: Can't get fan%d data!\n", i+1);
+ free_the_label(&label);
+ }

Also, please update the default configuration file. Providing a "Fan1" label for fan1 doesn't add much value. OTOH, labelling critical temperatures to anything less than 10 characters would be welcome, since long labels break the display as well.

Would be great if you could put sample limit set lines too, so that I can test this easily.

2* I don't have fan readings. After loading the driver, I have the following output:

fan1:     1323 RPM  (min = 1323 RPM, div = 8) 
fan2:        0 RPM  (min = 1323 RPM, div = 8) 

While both fans are spinning, rather fact as far as I can tell.

Chip dump follows:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 91 7f 00 00 5d 5d 01 00 ff 00 1f 21 1e 00 00 00    ??..]]?...?!?...
10: ff ff 5d 5d 3c 00 46 5d 50 00 64 5d 50 00 64 5d    ..]]<.F]P.d]P.d]
20: 5d 5d 55 50 41 61 61 5d 5d 5d 5d 5d 5d 5d 5d 5d    ]]UPAaa]]]]]]]]]
30: 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 5d 31 41 83    ]]]]]]]]]]]]]1A?

As you can see, registers read fan1=0xff, fan1_min=0xff, fan2=0x00 and fan2_min=0xff, which almost matches the sensors output, except that divisors are 2, not 8. So there's something broken somewhere. I don't know if both issues (no readings and bogus divider) are related or not).

And it looks like you did not fix the 2.4 driver interface... fan* files still yield two dozen (random) values each. This is because you forget to set *nrels_mag to the number of values in both adm1031_fan and adm1031_fan_div.

Temperatures readings are OK, OTOH.

Please fix these problems.

And PLEASE try your driver YOURSELF before sending it to me. You would have noticed at least some of these problems, had you tested it. Not that I don't like testing but we are wasting time. I'm busy so I'm slow testing and I'd like the adm1031 stuff to be ready before we can release lm_sensors 2.8.7. And I'd like this to happen ASAP.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#7 lore raw
In reply to Jean Delvare

Jean,

I will not be able to wor on the driver until tuesday evening. But I think
that tuesday evening I'll have fixed everything and the driver would be ready to release for the end of the week.

Thanks,
--
Alexandre d'Alton

Quoted 13 lines

And PLEASE try your driver YOURSELF before sending it to me. You would have noticed at least some of these problems, had you tested it. Not that I don't like testing but we are wasting time. I'm busy so I'm slow testing and I'd like the adm1031 stuff to be ready before we can release lm_sensors 2.8.7. And I'd like this to happen ASAP.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/