Changeset 2395

Show
Ignore:
Timestamp:
03/27/04 17:12:20 (9 years ago)
Author:
khali
Message:

Backport misdetection prevention patch from 2.6:

* Use unused bits of two more registers (configuration and conversion
rate) to reduce misdetections.

* Return with -ENODEV if the detection fails.

* Change the order in which we try to identify the chips. We better
finish with the LM84 and the MAX1617, in this order, because they are
harder to identify and are more likely to result in false positives.

* Refine LM84 detection. The LM84 has less features than the other chips
(chip cannot be stopped, conversion rate cannot be set, no low limits)
so it has extra unused bits.

* Do not intialize the chip if it was detected as an LM84. This one
cannot be stopped so why would we try to start it again? And as said
right before, conversion rate isn't changeable either.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/adm1021.c

    r2391 r2395  
    229229 
    230230        if (kind < 0) { 
    231                 if ( 
    232                     (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 
    233                      0x03) != 0x00) 
    234                         goto error1; 
     231                if ((adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0x03) != 0x00 
     232                 || (adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x3F) != 0x00 
     233                 || (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) & 0xF8) != 0x00) { 
     234                        err = -ENODEV; 
     235                        goto error1; 
     236                } 
    235237        } 
    236238 
     
    240242                i = adm1021_read_value(new_client, ADM1021_REG_MAN_ID); 
    241243                if (i == 0x41) 
    242                   if ((adm1021_read_value (new_client, ADM1021_REG_DEV_ID) & 0x0F0) == 0x030) 
     244                  if ((adm1021_read_value (new_client, ADM1021_REG_DEV_ID) & 0xF0) == 0x30) 
    243245                        kind = adm1023; 
    244246                  else 
     
    252254                          (new_client, ADM1021_REG_DEV_ID) == 0x01)) 
    253255                        kind = max1617a; 
    254                 /* LM84 Mfr ID in a different place */ 
    255                 else 
    256                     if (adm1021_read_value 
    257                         (new_client, ADM1021_REG_CONV_RATE_R) == 0x00) 
    258                         kind = lm84; 
    259256                else if (i == 0x54) 
    260257                        kind = mc1066; 
     258                /* LM84 Mfr ID in a different place, and it has more unused bits */ 
     259                else if (adm1021_read_value(new_client, ADM1021_REG_CONV_RATE_R) == 0x00 
     260                      && (kind == 0 /* skip extra detection */ 
     261                       || ((adm1021_read_value(new_client, ADM1021_REG_CONFIG_R) & 0x7F) == 0x00 
     262                        && (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 0xAB) == 0x00))) 
     263                        kind = lm84; 
    261264                else 
    262265                        kind = max1617; 
     
    287290                type_name = "mc1066"; 
    288291                client_name = "MC1066 chip"; 
    289         } else { 
    290 #ifdef DEBUG 
    291                 printk("adm1021.o: Internal error: unknown kind (%d)?!?", 
    292                        kind); 
    293 #endif 
    294                 goto error1; 
    295292        } 
    296293 
     
    317314 
    318315        /* Initialize the ADM1021 chip */ 
    319         adm1021_init_client(new_client); 
     316        if (kind != lm84) 
     317                adm1021_init_client(new_client); 
    320318        return 0; 
    321319