i2c: core: use I2C locking behaviour also for SMBUS
[linux-block.git] / drivers / i2c / i2c-core.h
index 9d8526415b2649728e3d86d39682ba1c36fb53a4..deea47c576e50c7ca6107f632bd215d564d376b2 100644 (file)
@@ -39,6 +39,18 @@ static inline bool i2c_in_atomic_xfer_mode(void)
        return system_state > SYSTEM_RUNNING && irqs_disabled();
 }
 
+static inline int __i2c_lock_bus_helper(struct i2c_adapter *adap)
+{
+       int ret = 0;
+
+       if (i2c_in_atomic_xfer_mode())
+               ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT) ? 0 : -EAGAIN;
+       else
+               i2c_lock_bus(adap, I2C_LOCK_SEGMENT);
+
+       return ret;
+}
+
 #ifdef CONFIG_ACPI
 const struct acpi_device_id *
 i2c_acpi_match_device(const struct acpi_device_id *matches,