• Jean Delvare's avatar
    [PATCH] I2C: Prevent misdetections in adm1021 driver · 9f3e7af6
    Jean Delvare authored
    Yet another patch for the adm1021 chip driver. I refined the detection
    code a bit in order to prevent chip misdetection. Some chips handled
    by the adm1021 driver are hard to detect and identify (LM84 and
    MAX1617) so we tend to accept any chip it the valid I2C address range
    as one of these. It has caused much, much trouble already. See these
    threads for example:
    
    http://archives.andrew.net.au/lm-sensors/msg04448.html
    http://archives.andrew.net.au/lm-sensors/msg04624.html
    http://archives.andrew.net.au/lm-sensors/msg05560.html
    http://archives.andrew.net.au/lm-sensors/msg05871.html
    http://archives.andrew.net.au/lm-sensors/msg06754.html
    http://archives.andrew.net.au/lm-sensors/msg07181.html
    
    And this ticket:
    
    http://www2.lm-sensors.nu/~lm78/readticket.cgi?ticket=1434
    
    So I thought it would be good to prevent this kind of problems if
    possible, and read the 8 datasheets again in search for ways to refine
    the detection method.
    
    I changed it in sensors-detect already, and had positive feedback from
    one user. I will also backport the changes to the driver to the 2.4
    version we have in CVS.
    
    What the patch does:
    
    * 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.
    
    Note that I couldn't test the changes on any supported chip since I
    don't own any. Still I believe that they should be applied, since the
    current code already broke one system and seriously harmed several
    others. I believe it's not critical if it turns out that we reject
    valid chips (which shouldn't happen if the datasheets are correct,
    anyway). People will simply let us know and we'll be less restrictive.
    In the meantime they can force the driver. That said, testers are
    welcome, as usual.
    9f3e7af6
adm1021.c 13.8 KB