@@ -328,11 +328,27 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features:\n"
328
328
"\t\t 0x10 don't use interrupts\n"
329
329
"\t\t 0x20 disable SMBus Host Notify " );
330
330
331
+ static int i801_check_and_clear_pec_error (struct i801_priv * priv )
332
+ {
333
+ u8 status ;
334
+
335
+ if (!(priv -> features & FEATURE_SMBUS_PEC ))
336
+ return 0 ;
337
+
338
+ status = inb_p (SMBAUXSTS (priv )) & SMBAUXSTS_CRCE ;
339
+ if (status ) {
340
+ outb_p (status , SMBAUXSTS (priv ));
341
+ return - EBADMSG ;
342
+ }
343
+
344
+ return 0 ;
345
+ }
346
+
331
347
/* Make sure the SMBus host is ready to start transmitting.
332
348
Return 0 if it is, -EBUSY if it is not. */
333
349
static int i801_check_pre (struct i801_priv * priv )
334
350
{
335
- int status ;
351
+ int status , result ;
336
352
337
353
status = inb_p (SMBHSTSTS (priv ));
338
354
if (status & SMBHSTSTS_HOST_BUSY ) {
@@ -353,13 +369,9 @@ static int i801_check_pre(struct i801_priv *priv)
353
369
* the hardware was already in this state when the driver
354
370
* started.
355
371
*/
356
- if (priv -> features & FEATURE_SMBUS_PEC ) {
357
- status = inb_p (SMBAUXSTS (priv )) & SMBAUXSTS_CRCE ;
358
- if (status ) {
359
- pci_dbg (priv -> pci_dev , "Clearing aux status flags (%02x)\n" , status );
360
- outb_p (status , SMBAUXSTS (priv ));
361
- }
362
- }
372
+ result = i801_check_and_clear_pec_error (priv );
373
+ if (result )
374
+ pci_dbg (priv -> pci_dev , "Clearing aux status flag CRCE\n" );
363
375
364
376
return 0 ;
365
377
}
@@ -408,14 +420,12 @@ static int i801_check_post(struct i801_priv *priv, int status)
408
420
* bit is harmless as long as it's cleared before
409
421
* the next operation.
410
422
*/
411
- if ((priv -> features & FEATURE_SMBUS_PEC ) &&
412
- (inb_p (SMBAUXSTS (priv )) & SMBAUXSTS_CRCE )) {
413
- outb_p (SMBAUXSTS_CRCE , SMBAUXSTS (priv ));
414
- result = - EBADMSG ;
415
- dev_dbg (& priv -> pci_dev -> dev , "PEC error\n" );
423
+ result = i801_check_and_clear_pec_error (priv );
424
+ if (result ) {
425
+ pci_dbg (priv -> pci_dev , "PEC error\n" );
416
426
} else {
417
427
result = - ENXIO ;
418
- dev_dbg ( & priv -> pci_dev -> dev , "No response\n" );
428
+ pci_dbg ( priv -> pci_dev , "No response\n" );
419
429
}
420
430
}
421
431
if (status & SMBHSTSTS_BUS_ERR ) {
0 commit comments