From: Jakub Kicinski <kuba@kernel.org>
To: jelonek.jonas@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
maxime.chevallier@bootlin.com, bjorn@mork.no,
davem@davemloft.net, linux@armlinux.org.uk, pabeni@redhat.com,
linux-kernel@vger.kernel.org, andrew@lunn.ch,
netdev@vger.kernel.org, hkallweit1@gmail.com,
edumazet@google.com
Subject: Re: [net-next,v5] net: sfp: extend SMBus support
Date: Mon, 19 Jan 2026 11:41:17 -0800 [thread overview]
Message-ID: <20260119194117.1258120-1-kuba@kernel.org> (raw)
In-Reply-To: <20260116113105.244592-1-jelonek.jonas@gmail.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: sfp: extend SMBus support
This patch extends SMBus support in the SFP driver from single-byte
accesses to also support SMBus I2C block and word access, enabling more
SMBus controllers to work with SFP modules.
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 84bef5099dda..8f0b34a93ae8 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
[ ... ]
> @@ -759,31 +773,55 @@ static int sfp_smbus_byte_write(struct sfp *sfp, bool a2, u8 dev_addr,
> +static int sfp_smbus_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
> + size_t len)
> {
> union i2c_smbus_data smbus_data;
> u8 bus_addr = a2 ? 0x51 : 0x50;
> + size_t this_len, transferred;
> + u32 functionality;
> u8 *data = buf;
> int ret;
>
> + functionality = i2c_get_functionality(sfp->i2c);
> +
> while (len) {
> - smbus_data.byte = *data;
> - ret = i2c_smbus_xfer(sfp->i2c, bus_addr, 0,
> - I2C_SMBUS_WRITE, dev_addr,
> - I2C_SMBUS_BYTE_DATA, &smbus_data);
> - if (ret)
> + this_len = min(len, sfp->i2c_max_block_size);
> +
> + if (this_len > 2 &&
> + functionality & I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) {
> + smbus_data.block[0] = this_len;
> + memcpy(&smbus_data.block[1], data, this_len);
> +
> + ret = i2c_smbus_xfer(sfp->i2c, bus_addr, 0,
> + I2C_SMBUS_WRITE, dev_addr,
> + I2C_SMBUS_WORD_DATA, &smbus_data);
^^^^^^^^^^^^^^^^^
Should this be I2C_SMBUS_I2C_BLOCK_DATA instead of I2C_SMBUS_WORD_DATA?
The code checks for I2C_FUNC_SMBUS_WRITE_I2C_BLOCK support and sets up
smbus_data.block[] with the length byte and data for a block transfer,
but then calls i2c_smbus_xfer() with I2C_SMBUS_WORD_DATA protocol.
For comparison, the read function correctly uses I2C_SMBUS_I2C_BLOCK_DATA
when I2C_FUNC_SMBUS_READ_I2C_BLOCK is supported:
if (this_len > 2 &&
functionality & I2C_FUNC_SMBUS_READ_I2C_BLOCK) {
smbus_data.block[0] = this_len;
ret = i2c_smbus_xfer(sfp->i2c, bus_addr, 0,
I2C_SMBUS_READ, dev_addr,
I2C_SMBUS_I2C_BLOCK_DATA, &smbus_data);
With I2C_SMBUS_WORD_DATA, only 2 bytes from smbus_data.word would be
written instead of the this_len bytes set up in smbus_data.block[].
The pointer then advances by transferred (this_len) bytes, effectively
skipping data that was never written to the device.
> + transferred = this_len;
[ ... ]
--
pw-bot: cr
prev parent reply other threads:[~2026-01-19 19:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 11:31 [PATCH net-next v5] net: sfp: extend SMBus support Jonas Jelonek
2026-01-16 13:23 ` Maxime Chevallier
2026-01-16 13:43 ` Jonas Jelonek
2026-01-16 14:00 ` Maxime Chevallier
2026-01-16 14:07 ` Andrew Lunn
2026-01-16 14:16 ` Maxime Chevallier
2026-01-16 14:25 ` Andrew Lunn
2026-01-18 9:43 ` Jonas Jelonek
2026-01-18 10:08 ` Russell King (Oracle)
2026-01-18 15:36 ` Andrew Lunn
2026-01-18 15:39 ` Andrew Lunn
2026-01-22 10:14 ` Jonas Jelonek
2026-01-22 16:04 ` Andrew Lunn
2026-01-22 16:22 ` Russell King (Oracle)
2026-01-16 13:57 ` Russell King (Oracle)
2026-01-19 19:41 ` Jakub Kicinski [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=20260119194117.1258120-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=jelonek.jonas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.