1313s32 i2c_smbus_nct6775::nct6775_access (u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data)
1414{
1515 int i, len, status, cnt;
16+ i2c_smbus_data tmp_data;
17+ int timeout = 0 ;
18+
19+ tmp_data.word = 0 ;
20+ cnt = 0 ;
21+ len = 0 ;
1622
1723 Out32 (SMBHSTCTL, NCT6775_SOFT_RESET);
1824
@@ -21,13 +27,14 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
2127 case I2C_SMBUS_QUICK:
2228 Out32 (SMBHSTADD, (addr << 1 ) | read_write);
2329 break ;
24- case I2C_SMBUS_BYTE:
2530 case I2C_SMBUS_BYTE_DATA:
31+ tmp_data.byte = data->byte ;
32+ case I2C_SMBUS_BYTE:
2633 Out32 (SMBHSTADD, (addr << 1 ) | read_write);
2734 Out32 (SMBHSTIDX, command);
2835 if (read_write == I2C_SMBUS_WRITE)
2936 {
30- Out32 (SMBHSTDAT, data-> byte );
37+ Out32 (SMBHSTDAT, tmp_data. byte );
3138 Out32 (SMBHSTCMD, NCT6775_WRITE_BYTE);
3239 }
3340 else
@@ -101,7 +108,16 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
101108 {
102109 if (read_write == I2C_SMBUS_WRITE)
103110 {
104- while ((Inp32 (SMBHSTSTS) & NCT6775_FIFO_EMPTY) == 0 );
111+ timeout = 0 ;
112+ while ((Inp32 (SMBHSTSTS) & NCT6775_FIFO_EMPTY) == 0 )
113+ {
114+ if (timeout > NCT6775_MAX_RETRIES)
115+ {
116+ return -ETIMEDOUT;
117+ }
118+ Sleep (1 );
119+ timeout++;
120+ }
105121
106122 // Load more bytes into FIFO
107123 if (len >= 4 )
@@ -124,10 +140,23 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
124140 len = 0 ;
125141 }
126142 }
143+ else
144+ {
145+ return -ENOTSUP;
146+ }
127147 }
128148
129149 // wait for manual mode to complete
130- while ((Inp32 (SMBHSTSTS) & NCT6775_MANUAL_ACTIVE) != 0 );
150+ timeout = 0 ;
151+ while ((Inp32 (SMBHSTSTS) & NCT6775_MANUAL_ACTIVE) != 0 )
152+ {
153+ if (timeout > NCT6775_MAX_RETRIES)
154+ {
155+ return -ETIMEDOUT;
156+ }
157+ Sleep (1 );
158+ timeout++;
159+ }
131160
132161 if ((Inp32 (SMBHSTERR) & NCT6775_NO_ACK) != 0 )
133162 {
0 commit comments