From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>,
barebox@lists.infradead.org
Subject: Re: [PATCH v2] i2c: at91: Fix driver for SAMA5D2 SoC
Date: Mon, 13 Jan 2025 14:17:37 +0100 [thread overview]
Message-ID: <757d2274-534a-4cf4-b6fc-0e990c5dd601@pengutronix.de> (raw)
In-Reply-To: <20250113070216.16303-1-eagle.alexander923@gmail.com>
On 13.01.25 08:02, Alexander Shiyan wrote:
> Most bits of the AT91 SR status register are cleared after reading,
> so we may lose the status at the end of the wait loop.
> Let's use the value already readed to check for "completed" status.
>
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
> drivers/i2c/busses/i2c-at91.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index dbc5aa4ddf..8929dbaede 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -276,7 +276,7 @@ static int at91_twi_wait_completion(struct at91_twi_dev *dev)
>
> dev->transfer_status |= status;
>
> - } while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP));
> + } while (!(status & AT91_TWI_TXCOMP));
This makes the function harder to reason about, because the status read
is done at the start, but only acted upon at the very end.
Would it make sense to change this to a while loop or move it into the
loop directly after the other status read and early exit if it's true?
>
> at91_disable_twi_interrupts(dev);
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-01-13 13:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 7:02 Alexander Shiyan
2025-01-13 13:17 ` Ahmad Fatoum [this message]
2025-01-13 13:37 ` Alexander Shiyan
2025-01-14 9:27 ` Ahmad Fatoum
2025-01-14 9:52 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=757d2274-534a-4cf4-b6fc-0e990c5dd601@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=eagle.alexander923@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox