mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ali Ahmet Memis <ali@iusegentoo.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Inochi Amaoto <inochiama@outlook.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (sg2042-mcu) reject short uptime reads
Date: Sun,  2 Aug 2026 15:11:02 +0000	[thread overview]
Message-ID: <20260802151102.37600-1-ali@iusegentoo.com> (raw)
In-Reply-To: <8f25c37b-8408-47f2-8069-87a1ef96ce7e@roeck-us.net>

On Sun, Aug 02 2026, Guenter Roeck wrote:

> Please refrain from sending fixes for non-issues.

You are right. Please drop it.

I checked what i2c_smbus_read_i2c_block_data() returns without checking
which protocol it runs, and the two block protocols do not behave the
same. In i2c_smbus_xfer_emulated(), I2C_SMBUS_BLOCK_DATA sets
I2C_M_RECV_LEN and reads back with

	memcpy(data->block, msg[1].buf, msg[1].buf[0] + 1);

so there the device supplies the count and a short reply is a real
thing. I2C_SMBUS_I2C_BLOCK_DATA, which is what this call uses, sets no
I2C_M_RECV_LEN, sends msg[1].len = data->block[0] and reads back with

	memcpy(data->block + 1, msg[1].buf, data->block[0]);

which never touches data->block[0]. An I2C block read carries no length
byte on the wire, so nothing can shorten it, and a transfer that is cut
short fails with an errno rather than returning a smaller count. time_val
is fully written whenever the call succeeds.

I should have read that before sending, rather than reasoning from the
return value alone. Sorry for the noise, and for the stable Cc on top of
it.

--
Ali

      reply	other threads:[~2026-08-02 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02 13:07 Ali Ahmet Memis
2026-08-02 15:00 ` Guenter Roeck
2026-08-02 15:11   ` Ali Ahmet Memis [this message]

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=20260802151102.37600-1-ali@iusegentoo.com \
    --to=ali@iusegentoo.com \
    --cc=inochiama@outlook.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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

all inboxes | Powered by JetHome®