Commit cbfe9d56 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by sanglipeng1
Browse files

i2c: s3c24xx: fix read transfers in polling mode

stable inclusion
from stable-v5.10.209
commit da60686bab6beaa718f14b9964277cd61bb74bbb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9U3NW

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=da60686bab6beaa718f14b9964277cd61bb74bbb



--------------------------------

[ Upstream commit 0d9cf23ed55d7ba3ab26d617a3ae507863674c8f ]

To properly handle read transfers in polling mode, no waiting for the ACK
state is needed as it will never come. Just wait a bit to ensure start
state is on the bus and continue processing next bytes.

Fixes: 117053f7 ("i2c: s3c2410: Add polling mode support")
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarChanho Park <chanho61.park@samsung.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent bcee7559
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -223,8 +223,17 @@ static bool is_ack(struct s3c24xx_i2c *i2c)
	int tries;

	for (tries = 50; tries; --tries) {
		if (readl(i2c->regs + S3C2410_IICCON)
			& S3C2410_IICCON_IRQPEND) {
		unsigned long tmp = readl(i2c->regs + S3C2410_IICCON);

		if (!(tmp & S3C2410_IICCON_ACKEN)) {
			/*
			 * Wait a bit for the bus to stabilize,
			 * delay estimated experimentally.
			 */
			usleep_range(100, 200);
			return true;
		}
		if (tmp & S3C2410_IICCON_IRQPEND) {
			if (!(readl(i2c->regs + S3C2410_IICSTAT)
				& S3C2410_IICSTAT_LASTBIT))
				return true;