Skip to content

Commit 555716f

Browse files
committed
i2c: phytium: Fix potential divided by zero in i2c_phyt_master_regfile_isr()
deepin inclusion category: bugfix Fixes: 7db4ed0 ("i2c: phytium: Fixed the bug that processed unupdated data") Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 7db4ed0 commit 555716f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/i2c/busses/phytium_i2c_v2/i2c-phyt-master.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,14 @@ static irqreturn_t i2c_phyt_master_regfile_isr(int this_irq, void *dev_id)
462462
return IRQ_NONE;
463463
}
464464

465-
head = i2c_phyt_read_reg(dev, FT_I2C_REGFILE_TX_HEAD) % dev->mng.tx_ring_cnt;
465+
head = i2c_phyt_read_reg(dev, FT_I2C_REGFILE_TX_HEAD);
466466
i2c_phyt_common_regfile_clear_rv2ap_int(dev, stat);
467467
if (!dev->mng.tx_ring_cnt) {
468468
dev_err(dev->dev, "tx_ring_cnt is zero\n");
469469
spin_unlock(&dev->i2c_lock);
470470
return IRQ_NONE;
471471
}
472+
head = head % dev->mng.tx_ring_cnt;
472473

473474
tail = dev->mng.cur_cmd_cnt % dev->mng.tx_ring_cnt;
474475
do {

0 commit comments

Comments
 (0)