@@ -22,8 +22,6 @@ enum chips { zl2004, zl2005, zl2006, zl2008, zl2105, zl2106, zl6100, zl6105,
2222
2323struct zl6100_data {
2424 int id ;
25- ktime_t access ; /* chip access time */
26- int delay ; /* Delay between chip accesses in uS */
2725 struct pmbus_driver_info info ;
2826};
2927
@@ -122,16 +120,6 @@ static u16 zl6100_d2l(long val)
122120 return (mantissa & 0x7ff ) | ((exponent << 11 ) & 0xf800 );
123121}
124122
125- /* Some chips need a delay between accesses */
126- static inline void zl6100_wait (const struct zl6100_data * data )
127- {
128- if (data -> delay ) {
129- s64 delta = ktime_us_delta (ktime_get (), data -> access );
130- if (delta < data -> delay )
131- udelay (data -> delay - delta );
132- }
133- }
134-
135123static int zl6100_read_word_data (struct i2c_client * client , int page ,
136124 int phase , int reg )
137125{
@@ -174,9 +162,7 @@ static int zl6100_read_word_data(struct i2c_client *client, int page,
174162 break ;
175163 }
176164
177- zl6100_wait (data );
178165 ret = pmbus_read_word_data (client , page , phase , vreg );
179- data -> access = ktime_get ();
180166 if (ret < 0 )
181167 return ret ;
182168
@@ -195,14 +181,11 @@ static int zl6100_read_word_data(struct i2c_client *client, int page,
195181static int zl6100_read_byte_data (struct i2c_client * client , int page , int reg )
196182{
197183 const struct pmbus_driver_info * info = pmbus_get_driver_info (client );
198- struct zl6100_data * data = to_zl6100_data (info );
199184 int ret , status ;
200185
201186 if (page >= info -> pages )
202187 return - ENXIO ;
203188
204- zl6100_wait (data );
205-
206189 switch (reg ) {
207190 case PMBUS_VIRT_STATUS_VMON :
208191 ret = pmbus_read_byte_data (client , 0 ,
@@ -225,7 +208,6 @@ static int zl6100_read_byte_data(struct i2c_client *client, int page, int reg)
225208 ret = pmbus_read_byte_data (client , page , reg );
226209 break ;
227210 }
228- data -> access = ktime_get ();
229211
230212 return ret ;
231213}
@@ -234,8 +216,7 @@ static int zl6100_write_word_data(struct i2c_client *client, int page, int reg,
234216 u16 word )
235217{
236218 const struct pmbus_driver_info * info = pmbus_get_driver_info (client );
237- struct zl6100_data * data = to_zl6100_data (info );
238- int ret , vreg ;
219+ int vreg ;
239220
240221 if (page >= info -> pages )
241222 return - ENXIO ;
@@ -265,27 +246,7 @@ static int zl6100_write_word_data(struct i2c_client *client, int page, int reg,
265246 vreg = reg ;
266247 }
267248
268- zl6100_wait (data );
269- ret = pmbus_write_word_data (client , page , vreg , word );
270- data -> access = ktime_get ();
271-
272- return ret ;
273- }
274-
275- static int zl6100_write_byte (struct i2c_client * client , int page , u8 value )
276- {
277- const struct pmbus_driver_info * info = pmbus_get_driver_info (client );
278- struct zl6100_data * data = to_zl6100_data (info );
279- int ret ;
280-
281- if (page >= info -> pages )
282- return - ENXIO ;
283-
284- zl6100_wait (data );
285- ret = pmbus_write_byte (client , page , value );
286- data -> access = ktime_get ();
287-
288- return ret ;
249+ return pmbus_write_word_data (client , page , vreg , word );
289250}
290251
291252static const struct i2c_device_id zl6100_id [] = {
@@ -363,14 +324,7 @@ static int zl6100_probe(struct i2c_client *client)
363324 * supported chips are known to require a wait time between I2C
364325 * accesses.
365326 */
366- data -> delay = delay ;
367-
368- /*
369- * Since there was a direct I2C device access above, wait before
370- * accessing the chip again.
371- */
372- data -> access = ktime_get ();
373- zl6100_wait (data );
327+ udelay (delay );
374328
375329 info = & data -> info ;
376330
@@ -404,8 +358,7 @@ static int zl6100_probe(struct i2c_client *client)
404358 if (ret < 0 )
405359 return ret ;
406360
407- data -> access = ktime_get ();
408- zl6100_wait (data );
361+ udelay (delay );
409362
410363 if (ret & ZL8802_MFR_PHASES_MASK )
411364 info -> func [1 ] |= PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT ;
@@ -418,8 +371,7 @@ static int zl6100_probe(struct i2c_client *client)
418371 if (ret < 0 )
419372 return ret ;
420373
421- data -> access = ktime_get ();
422- zl6100_wait (data );
374+ udelay (delay );
423375
424376 ret = i2c_smbus_read_word_data (client , ZL8802_MFR_USER_CONFIG );
425377 if (ret < 0 )
@@ -428,8 +380,7 @@ static int zl6100_probe(struct i2c_client *client)
428380 if (ret & ZL8802_MFR_XTEMP_ENABLE_2 )
429381 info -> func [i ] |= PMBUS_HAVE_TEMP2 ;
430382
431- data -> access = ktime_get ();
432- zl6100_wait (data );
383+ udelay (delay );
433384 }
434385 ret = i2c_smbus_read_word_data (client , ZL8802_MFR_USER_GLOBAL_CONFIG );
435386 if (ret < 0 )
@@ -446,13 +397,12 @@ static int zl6100_probe(struct i2c_client *client)
446397 info -> func [0 ] |= PMBUS_HAVE_TEMP2 ;
447398 }
448399
449- data -> access = ktime_get ();
450- zl6100_wait (data );
400+ udelay (delay );
451401
402+ info -> access_delay = delay ;
452403 info -> read_word_data = zl6100_read_word_data ;
453404 info -> read_byte_data = zl6100_read_byte_data ;
454405 info -> write_word_data = zl6100_write_word_data ;
455- info -> write_byte = zl6100_write_byte ;
456406
457407 return pmbus_do_probe (client , info );
458408}
0 commit comments