[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aVvjyWzKuczNf3lt@shell.armlinux.org.uk>
Date: Mon, 5 Jan 2026 16:16:09 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Jonas Jelonek <jelonek.jonas@...il.com>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Bjørn Mork <bjorn@...k.no>,
Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH v2] net: sfp: add SMBus I2C block support
On Mon, Jan 05, 2026 at 03:46:53PM +0000, Jonas Jelonek wrote:
> @@ -765,26 +794,70 @@ static int sfp_smbus_byte_write(struct sfp *sfp, bool a2, u8 dev_addr,
> dev_addr++;
> }
>
> + return data - (u8 *)buf;
A separate fix is being submitted for this.
> +}
> +
> +static int sfp_smbus_block_write(struct sfp *sfp, bool a2, u8 dev_addr,
> + void *buf, size_t len)
> +{
> + size_t block_size = sfp->i2c_block_size;
> + union i2c_smbus_data smbus_data;
> + u8 bus_addr = a2 ? 0x51 : 0x50;
> + u8 *data = buf;
> + u8 this_len;
> + int ret;
> +
> + while (len) {
> + this_len = min(len, block_size);
> +
> + 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_I2C_BLOCK_DATA, &smbus_data);
> + if (ret)
> + return ret;
> +
> + len -= this_len;
> + data += this_len;
> + dev_addr += this_len;
> + }
> +
> return 0;
This is wrong. As already said, the I2C accessors return the number of
bytes successfully transferred. Zero means no bytes were transferred,
which is an error.
All callers to sfp_write() validate that the expected number of bytes
were written. Thus, returning zero will cause failures.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists