Skip to content

Commit 4f7275f

Browse files
hkallweitwsakernel
authored andcommitted
i2c: i801: Don't clear status flags twice in interrupt mode
In interrupt mode we clear the status flags twice, in the interrupt handler and in i801_check_post(). Remove clearing the status flags from i801_check_post() and handle polling mode by using the SMBus unlocking write to also clear the status flags if still set. To be precise: One could still argue that the status flags are cleared twice in interrupt mode, but it comes for free. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Jean Delvare <[email protected]> Tested-by: Jean Delvare <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 8c7a896 commit 4f7275f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,6 @@ static int i801_check_pre(struct i801_priv *priv)
356356
return 0;
357357
}
358358

359-
/*
360-
* Convert the status register to an error code, and clear it.
361-
* Note that status only contains the bits we want to clear, not the
362-
* actual register value.
363-
*/
364359
static int i801_check_post(struct i801_priv *priv, int status)
365360
{
366361
int result = 0;
@@ -385,7 +380,6 @@ static int i801_check_post(struct i801_priv *priv, int status)
385380
!(status & SMBHSTSTS_FAILED))
386381
dev_err(&priv->pci_dev->dev,
387382
"Failed terminating the transaction\n");
388-
outb_p(STATUS_FLAGS, SMBHSTSTS(priv));
389383
return -ETIMEDOUT;
390384
}
391385

@@ -424,9 +418,6 @@ static int i801_check_post(struct i801_priv *priv, int status)
424418
dev_dbg(&priv->pci_dev->dev, "Lost arbitration\n");
425419
}
426420

427-
/* Clear status flags except BYTE_DONE, to be cleared by caller */
428-
outb_p(status, SMBHSTSTS(priv));
429-
430421
return result;
431422
}
432423

@@ -923,8 +914,11 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
923914
}
924915

925916
out:
926-
/* Unlock the SMBus device for use by BIOS/ACPI */
927-
outb_p(SMBHSTSTS_INUSE_STS, SMBHSTSTS(priv));
917+
/*
918+
* Unlock the SMBus device for use by BIOS/ACPI,
919+
* and clear status flags if not done already.
920+
*/
921+
outb_p(SMBHSTSTS_INUSE_STS | STATUS_FLAGS, SMBHSTSTS(priv));
928922

929923
pm_runtime_mark_last_busy(&priv->pci_dev->dev);
930924
pm_runtime_put_autosuspend(&priv->pci_dev->dev);

0 commit comments

Comments
 (0)