@@ -328,11 +328,27 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features:\n"
328328 "\t\t 0x10 don't use interrupts\n"
329329 "\t\t 0x20 disable SMBus Host Notify " );
330330
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+
331347/* Make sure the SMBus host is ready to start transmitting.
332348 Return 0 if it is, -EBUSY if it is not. */
333349static int i801_check_pre (struct i801_priv * priv )
334350{
335- int status ;
351+ int status , result ;
336352
337353 status = inb_p (SMBHSTSTS (priv ));
338354 if (status & SMBHSTSTS_HOST_BUSY ) {
@@ -353,13 +369,9 @@ static int i801_check_pre(struct i801_priv *priv)
353369 * the hardware was already in this state when the driver
354370 * started.
355371 */
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" );
363375
364376 return 0 ;
365377}
@@ -408,14 +420,12 @@ static int i801_check_post(struct i801_priv *priv, int status)
408420 * bit is harmless as long as it's cleared before
409421 * the next operation.
410422 */
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" );
416426 } else {
417427 result = - ENXIO ;
418- dev_dbg ( & priv -> pci_dev -> dev , "No response\n" );
428+ pci_dbg ( priv -> pci_dev , "No response\n" );
419429 }
420430 }
421431 if (status & SMBHSTSTS_BUS_ERR ) {
0 commit comments