From: Andi Shyti <andi.shyti@kernel.org>
To: Carlos Song <carlos.song@nxp.com>
Cc: frank.li@nxp.com, aisheng.dong@nxp.com, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, vz@mleia.com, wsa@kernel.org,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] i2c: imx-lpi2c: support smbus block read feature
Date: Tue, 20 Jan 2026 12:30:38 +0100 [thread overview]
Message-ID: <aW9jUs2-kiVIxTfn@zenone.zhora.eu> (raw)
In-Reply-To: <20251121110100.1909603-1-carlos.song@nxp.com>
Hi Carlos,
On Fri, Nov 21, 2025 at 07:01:00PM +0800, Carlos Song wrote:
> The LPI2C controller automatically sends a NACK after the last byte of a
> receive command unless the next command in MTDR is also a receive command.
> If MTDR is empty when a receive completes, NACK is transmitted by default.
>
> To comply with SMBus block read, start with a 2-byte read:
> - The first byte is the block length. Once received, update MTDR
> immediately to keep MTDR non-empty.
> - Issue a new receive command for the remaining data before the second
> byte arrives ensuring continuous ACK instead of NACK.
What is the real fix you are addressing here? Can you be a bit
more descriptive?
> Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver")
Is this tag really needed?
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
...
> #define MRDR_RXEMPTY BIT(14)
> #define MDER_TDDE BIT(0)
> #define MDER_RDDE BIT(1)
> +#define MSR_RDF_ASSERT(x) FIELD_GET(MSR_RDF, (x))
This name sounds more as an imperative action, do you mean
something like MSR_RDF_ASSERTED(x)?
> #define SCR_SEN BIT(0)
> #define SCR_RST BIT(1)
...
> +static unsigned int lpi2c_SMBus_block_read_single_byte(struct lpi2c_imx_struct *lpi2c_imx)
> +{
> + unsigned int val, data;
> + int ret;
> +
> + ret = readl_poll_timeout(lpi2c_imx->base + LPI2C_MSR, val,
> + MSR_RDF_ASSERT(val), 1, 1000);
What is the value of val here?
> + if (ret) {
> + dev_err(&lpi2c_imx->adapter.dev, "SMBus read count timeout %d\n", ret);
> + return ret;
This is an unsigned function and you are trying to return a
negative number.
Can we also add a comment saying that readl_poll_timeout() fails
only if it times out?
> + }
> +
...
> + /* Read the first byte as block len */
> + block_len = lpi2c_SMBus_block_read_single_byte(lpi2c_imx);
> + if (block_len < 0) {
both block_len and lpi2c_SMBus_block_read_single_byte() are
unsigned, but you are comparing for negative value.
> + dev_err(&lpi2c_imx->adapter.dev, "SMBus read data length timeout\n");
> + return;
> + }
> +
...
> + if (block_len == 1) {
> + ret = lpi2c_SMBus_block_read_single_byte(lpi2c_imx);
> + if (ret < 0)
> + dev_err(&lpi2c_imx->adapter.dev, "SMBus read data timeout\n");
> + return;
do we need to increment msglen here?
> + }
> +
> + /* Block read other length data need to update command again*/
Please fix the commenting style here.
> + writel((RECV_DATA << 8) | (block_len - 2), lpi2c_imx->base + LPI2C_MTDR);
> + lpi2c_imx->msglen += block_len;
> + }
Thanks,
Andi
next prev parent reply other threads:[~2026-01-20 11:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 11:01 [PATCH v2] i2c: imx-lpi2c: support smbus block read feature Carlos Song
2025-11-21 15:59 ` Frank Li
2026-01-20 11:30 ` Andi Shyti [this message]
2026-01-21 6:41 ` Carlos Song
2026-01-21 6:43 ` Carlos Song
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=aW9jUs2-kiVIxTfn@zenone.zhora.eu \
--to=andi.shyti@kernel.org \
--cc=aisheng.dong@nxp.com \
--cc=carlos.song@nxp.com \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vz@mleia.com \
--cc=wsa@kernel.org \
/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