public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@riscstar.com>
To: Troy Mitchell <troymitchell988@gmail.com>,
	andi.shyti@kernel.org, dlan@gentoo.org
Cc: linux-i2c@vger.kernel.org, spacemit@lists.linux.dev,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	Troy Mitchell <troy.mitchell@linux.dev>
Subject: Re: [PATCH] i2c: k1: check for transfer error
Date: Thu, 12 Jun 2025 21:16:05 -0500	[thread overview]
Message-ID: <d7f7dc4c-5d2a-4f63-9451-5e4d2e53cf1b@riscstar.com> (raw)
In-Reply-To: <aEuI9-QWCv6CRUyX@troy-wujie14pro-arch>

On 6/12/25 9:12 PM, Troy Mitchell wrote:
> On Thu, Jun 12, 2025 at 05:56:25PM -0500, Alex Elder wrote:
>> If spacemit_i2c_xfer_msg() times out waiting for a message transfer to
>> complete, or if the hardware reports an error, it returns a negative
>> error code (-ETIMEDOUT, -EAGAIN, -ENXIO. or -EIO).
>>
>> The sole caller of spacemit_i2c_xfer_msg() is spacemit_i2c_xfer(),
>> which is the i2c_algorithm->xfer callback function.  It currently
>> does not save the value returned by spacemit_i2c_xfer_msg().
>>
>> The result is that transfer errors go unreported, and a caller
>> has no indication anything is wrong.
>>
>> When this code was out for review, the return value *was* checked
>> in early versions.  But for some reason, that assignment got dropped
>> between versions 5 and 6 of the series, perhaps related to reworking
>> the code to merge spacemit_i2c_xfer_core() into spacemit_i2c_xfer().
>>
>> Simply assigning the value returned to "ret" fixes the problem.
>>
>> Fixes: 5ea558473fa31 ("i2c: spacemit: add support for SpacemiT K1 SoC")
>> Signed-off-by: Alex Elder <elder@riscstar.com>
>> Reviewed-by: Troy Mitchell <troymitchell988@gmail.com>
>> ---
>> v2: Added Troy's Reviewed-by
> Hi Alex, you added the changelog, but the subject line
> doesn't have the "V2" suffix. Is this a mistake?

Yes it's a mistake.  I contemplated sending an immediate
"oops, this was v2!!!" but opted to wait until someone
like you asked about it.

This *is* version 2, and I made the updates I describe.

					-Alex
> 
>              - Troy
> 
>>
>>   drivers/i2c/busses/i2c-k1.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
>> index 5965b4cf6220e..b68a21fff0b56 100644
>> --- a/drivers/i2c/busses/i2c-k1.c
>> +++ b/drivers/i2c/busses/i2c-k1.c
>> @@ -477,7 +477,7 @@ static int spacemit_i2c_xfer(struct i2c_adapter *adapt, struct i2c_msg *msgs, in
>>   
>>   	ret = spacemit_i2c_wait_bus_idle(i2c);
>>   	if (!ret)
>> -		spacemit_i2c_xfer_msg(i2c);
>> +		ret = spacemit_i2c_xfer_msg(i2c);
>>   	else if (ret < 0)
>>   		dev_dbg(i2c->dev, "i2c transfer error: %d\n", ret);
>>   	else
>>
>> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
>> -- 
>> 2.45.2
>>


  reply	other threads:[~2025-06-13  2:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12 22:56 [PATCH] i2c: k1: check for transfer error Alex Elder
2025-06-13  2:12 ` Troy Mitchell
2025-06-13  2:16   ` Alex Elder [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-05-29 12:22 Alex Elder
2025-05-29 14:58 ` Troy Mitchell

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=d7f7dc4c-5d2a-4f63-9451-5e4d2e53cf1b@riscstar.com \
    --to=elder@riscstar.com \
    --cc=andi.shyti@kernel.org \
    --cc=dlan@gentoo.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=spacemit@lists.linux.dev \
    --cc=troy.mitchell@linux.dev \
    --cc=troymitchell988@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