Merge tag 'i2c-for-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[linux-2.6-microblaze.git] / drivers / i2c / busses / i2c-stm32f7.c
index abfb83b..9835099 100644 (file)
@@ -1065,9 +1065,10 @@ static int stm32f7_i2c_smbus_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
        /* Configure PEC */
        if ((flags & I2C_CLIENT_PEC) && f7_msg->size != I2C_SMBUS_QUICK) {
                cr1 |= STM32F7_I2C_CR1_PECEN;
-               cr2 |= STM32F7_I2C_CR2_PECBYTE;
-               if (!f7_msg->read_write)
+               if (!f7_msg->read_write) {
+                       cr2 |= STM32F7_I2C_CR2_PECBYTE;
                        f7_msg->count++;
+               }
        } else {
                cr1 &= ~STM32F7_I2C_CR1_PECEN;
                cr2 &= ~STM32F7_I2C_CR2_PECBYTE;
@@ -1155,8 +1156,10 @@ static void stm32f7_i2c_smbus_rep_start(struct stm32f7_i2c_dev *i2c_dev)
        f7_msg->stop = true;
 
        /* Add one byte for PEC if needed */
-       if (cr1 & STM32F7_I2C_CR1_PECEN)
+       if (cr1 & STM32F7_I2C_CR1_PECEN) {
+               cr2 |= STM32F7_I2C_CR2_PECBYTE;
                f7_msg->count++;
+       }
 
        /* Set number of bytes to be transferred */
        cr2 &= ~(STM32F7_I2C_CR2_NBYTES_MASK);