diff mbox series

[v3,5/6] i2c: i801: Call i801_check_pre() from i801_access()

Message ID 20230216171451.2e87b061@endymion.delvare
State New
Headers show
Series [v3,1/6] i2c: i801: Add i801_simple_transaction(), complementing i801_block_transaction() | expand

Commit Message

Jean Delvare Feb. 16, 2023, 4:14 p.m. UTC
From: Heiner Kallweit <hkallweit1@gmail.com>

This avoids code duplication, in a next step we'll call
i801_check_post() from i801_transaction() as well.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
---
 drivers/i2c/busses/i2c-i801.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Wolfram Sang Feb. 17, 2023, 9:41 p.m. UTC | #1
On Thu, Feb 16, 2023 at 05:14:51PM +0100, Jean Delvare wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
> 
> This avoids code duplication, in a next step we'll call
> i801_check_post() from i801_transaction() as well.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>

Applied to for-next, thanks!
diff mbox series

Patch

--- linux-6.1.orig/drivers/i2c/busses/i2c-i801.c
+++ linux-6.1/drivers/i2c/busses/i2c-i801.c
@@ -462,10 +462,6 @@  static int i801_transaction(struct i801_
 	unsigned long result;
 	const struct i2c_adapter *adap = &priv->adapter;
 
-	status = i801_check_pre(priv);
-	if (status < 0)
-		return status;
-
 	if (priv->features & FEATURE_IRQ) {
 		reinit_completion(&priv->done);
 		outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START,
@@ -653,10 +649,6 @@  static int i801_block_transaction_byte_b
 	if (command == I2C_SMBUS_BLOCK_PROC_CALL)
 		return -EOPNOTSUPP;
 
-	status = i801_check_pre(priv);
-	if (status < 0)
-		return status;
-
 	len = data->block[0];
 
 	if (read_write == I2C_SMBUS_WRITE) {
@@ -891,6 +883,10 @@  static s32 i801_access(struct i2c_adapte
 
 	pm_runtime_get_sync(&priv->pci_dev->dev);
 
+	ret = i801_check_pre(priv);
+	if (ret)
+		goto out;
+
 	hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC)
 		&& size != I2C_SMBUS_QUICK
 		&& size != I2C_SMBUS_I2C_BLOCK_DATA;
@@ -913,6 +909,7 @@  static s32 i801_access(struct i2c_adapte
 	 */
 	if (hwpec)
 		outb_p(inb_p(SMBAUXCTL(priv)) & ~SMBAUXCTL_CRC, SMBAUXCTL(priv));
+out:
 	/*
 	 * Unlock the SMBus device for use by BIOS/ACPI,
 	 * and clear status flags if not done already.