Re: [PATCH net-next v11 3/4] net: pse-pd: realtek-pse-mcu: add I2C transport

[email protected]
Newsgroups org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The `const` qualifier is discarded via casting when passing `req` to `i2c_smbus_write_i2c_block_data`.
--

--- Patch [3]: [PATCH net-next v11 3/4] net: pse-pd: realtek-pse-mcu: add I2C transport ---
commit 3cb487f7edfeb05d920f7d12d74317a730a8187a
Author: Jonas Jelonek <[email protected]>

net: pse-pd: realtek-pse-mcu: add I2C transport

Add the I2C/SMBus transport for the Realtek PSE MCU core. It registers
the MCU on an I2C bus and provides the send/recv callbacks the core
uses to exchange the 12-byte frames.

Acked-by: Oleksij Rempel <[email protected]>
Reviewed-by: Kory Maincent <[email protected]>

> diff --git a/drivers/net/pse-pd/realtek-pse-mcu-i2c.c b/drivers/net/pse-pd/realtek-pse-mcu-i2c.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/net/pse-pd/realtek-pse-mcu-i2c.c

[ ... ]

> +static int rtpse_mcu_i2c_smbus_send(struct rtpse_mcu_ctrl *pse, const struct rtpse_mcu_msg *req)
> +{
> +	struct i2c_client *client = to_i2c_client(pse->dev);
> +
> +	/* Send opcode as SMBus command byte; remaining 11 bytes as block data */
> +	return i2c_smbus_write_i2c_block_data(client, req->opcode, RTPSE_MCU_MSG_SIZE - 1,
> +					      (u8 *)req + 1);

[Severity: Low]
This isn't a bug, but could we use a const cast here to avoid discarding the
const qualifier from the req parameter?

The i2c_smbus_write_i2c_block_data() function takes a const u8 * for the
values array, so a cast to (const u8 *) would preserve the const-correctness
of the req pointer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.