Show
Ignore:
Timestamp:
10/10/04 14:03:48 (10 years ago)
Author:
khali
Message:

Retry on read errors. Contributed by David Knierim.

Files:
1 modified

Legend:

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

    r2717 r2719  
    2828#include <linux/i2c-proc.h> 
    2929#include <linux/init.h> 
     30#include <linux/delay.h> 
    3031#include "version.h" 
    3132#include "sensors_vid.h" 
     
    469470 
    470471        if ((err = i2c_detach_client(client))) { 
    471                 printk 
    472                     ("lm87.o: Client deregistration failed, client not detached.\n"); 
     472                printk(KERN_ERR "lm87.o: Client deregistration failed, " 
     473                       "client not detached\n"); 
    473474                return err; 
    474475        } 
     
    479480} 
    480481 
     482#define MAX_RETRIES 5 
     483 
    481484static int lm87_read_value(struct i2c_client *client, u8 reg) 
    482485{ 
    483         return 0xFF & i2c_smbus_read_byte_data(client, reg); 
     486        int value, i; 
     487 
     488        /* Retry in case of read errors */ 
     489        for (i = 1; i <= MAX_RETRIES; i++) { 
     490                if ((value = i2c_smbus_read_byte_data(client, reg)) >= 0) 
     491                        return value; 
     492 
     493                printk(KERN_WARNING "lm87.o: Read byte data failed, " 
     494                       "address 0x%02x\n", reg); 
     495                mdelay(i); 
     496        } 
     497 
     498        /* <TODO> what to return in case of error? */ 
     499        return 0; 
    484500} 
    485501 
     
    944960static int __init sm_lm87_init(void) 
    945961{ 
    946         printk("lm87.o version %s (%s)\n", LM_VERSION, LM_DATE); 
     962        printk(KERN_INFO "lm87.o version %s (%s)\n", LM_VERSION, LM_DATE); 
    947963        return i2c_add_driver(&LM87_driver); 
    948964}