Skip to content

Commit f707d6b

Browse files
hkallweitwsakernel
authored andcommitted
i2c: i801: replace acpi_lock with I2C bus lock
I2C core ensures in i2c_smbus_xfer() that the I2C bus lock is held when calling the smbus_xfer callback. That's i801_access() in our case. I think it's safe in general to assume that the I2C bus lock is held when the smbus_xfer callback is called. Therefore I see no need to define an own mutex. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent d0d0f82 commit f707d6b

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

drivers/i2c/busses/i2c-i801.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ struct i801_priv {
293293

294294
/*
295295
* If set to true the host controller registers are reserved for
296-
* ACPI AML use. Protected by acpi_lock.
296+
* ACPI AML use.
297297
*/
298298
bool acpi_reserved;
299-
struct mutex acpi_lock;
300299
};
301300

302301
#define FEATURE_SMBUS_PEC BIT(0)
@@ -874,11 +873,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
874873
int hwpec, ret;
875874
struct i801_priv *priv = i2c_get_adapdata(adap);
876875

877-
mutex_lock(&priv->acpi_lock);
878-
if (priv->acpi_reserved) {
879-
mutex_unlock(&priv->acpi_lock);
876+
if (priv->acpi_reserved)
880877
return -EBUSY;
881-
}
882878

883879
pm_runtime_get_sync(&priv->pci_dev->dev);
884880

@@ -919,7 +915,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
919915

920916
pm_runtime_mark_last_busy(&priv->pci_dev->dev);
921917
pm_runtime_put_autosuspend(&priv->pci_dev->dev);
922-
mutex_unlock(&priv->acpi_lock);
923918
return ret;
924919
}
925920

@@ -1571,7 +1566,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
15711566
* further access from the driver itself. This device is now owned
15721567
* by the system firmware.
15731568
*/
1574-
mutex_lock(&priv->acpi_lock);
1569+
i2c_lock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
15751570

15761571
if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
15771572
priv->acpi_reserved = true;
@@ -1591,7 +1586,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
15911586
else
15921587
status = acpi_os_write_port(address, (u32)*value, bits);
15931588

1594-
mutex_unlock(&priv->acpi_lock);
1589+
i2c_unlock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
15951590

15961591
return status;
15971592
}
@@ -1651,7 +1646,6 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
16511646
priv->adapter.dev.parent = &dev->dev;
16521647
ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&dev->dev));
16531648
priv->adapter.retries = 3;
1654-
mutex_init(&priv->acpi_lock);
16551649

16561650
priv->pci_dev = dev;
16571651
priv->features = id->driver_data;

0 commit comments

Comments
 (0)