From: Frank Li <Frank.li@nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: Lakshay Piplani <lakshay.piplani@nxp.com>,
robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v10 3/9] i3c: master: Add APIs for I3C hub support
Date: Tue, 2 Jun 2026 13:27:54 -0400 [thread overview]
Message-ID: <ah8Smqrbk3mZi9t4@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260525080045.6E09E1F000E9@smtp.kernel.org>
On Mon, May 25, 2026 at 08:00:44AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] Incorrect logic and API contract violation in `i3c_master_supports_ccc_cmd()`.
> - [Medium] `i3c_master_direct_attach_i3c_dev_locked()` incorrectly returns `-EINVAL` for devices without addresses.
> --
>
> commit e1382a24562500ebcc8529e9a5fff3016b719a36
> Author: Aman Kumar Pandey <aman.kumarpandey@nxp.com>
>
> i3c: master: Add APIs for I3C hub support
>
> This commit adds helpers for attaching and detaching I3C devices, as well as
> helpers to check CCC support and send CCC commands. These additions prepare the
> subsystem for I3C hub support.
>
> > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> > index ec3547f75469e..4f0565faa182f 100644
> > --- a/drivers/i3c/master.c
> > +++ b/drivers/i3c/master.c
>
> [ ... ]
>
> > +/**
> > + * i3c_master_direct_attach_i3c_dev_locked() - attach an I3C device to a master
> > + * @master: I3C master controller to attach the device to
> > + * @dev: I3C device descriptor representing the device
> > + *
> > + * This function attaches an I3C device to its master controller once the
> > + * device has a valid address on the bus. Devices without an assigned address
> > + * are ignored. The master device itself is never attached through this bus.
> > + *
> > + * Context: Caller must hold master->bus.lock in write mode.
> > + *
> > + * Return: 0 on success, or a negative error code if the attach operation
> > + * fails in the master controller driver.
> > + */
> > +int i3c_master_direct_attach_i3c_dev_locked(struct i3c_master_controller *master,
> > + struct i3c_dev_desc *dev)
> > +{
> > + int ret = 0;
> > +
> > + /*
> > + * We don't attach devices to the controller until they are
> > + * addressable on the bus.
> > + */
> > +
> > + if (!dev->info.static_addr && !dev->info.dyn_addr)
> > + return -EINVAL;
>
> [Severity: Medium]
> The documentation for this function states that "Devices without an assigned
> address are ignored." However, this code returns -EINVAL instead of 0.
>
> Looking at the internal i3c_master_attach_i3c_dev(), it returns 0 to safely
> ignore unaddressed devices until they acquire an address. Should this new
> helper also return 0 to match both its documentation and the subsystem's
> existing convention?
Suppose AI is correct, please check it.
>
> > +
> > + /* Do not attach the master device itself. */
> > + if (master->this != dev && master->ops->attach_i3c_dev)
> > + ret = master->ops->attach_i3c_dev(dev);
> > +
> > + return ret;
> > +}
> > +EXPORT_SYMBOL_GPL(i3c_master_direct_attach_i3c_dev_locked);
>
> [ ... ]
>
> > +/**
> > + * i3c_master_supports_ccc_cmd() - check CCC command support
> > + * @master: I3C master controller
> > + * @cmd: CCC command to verify
> > + *
> > + * This function verifies whether the given I3C master controller supports
> > + * the specified Common Command Code (CCC).
> > + *
> > + * Return: 0 if the CCC command is supported and executed successfully,
> > + * -EINVAL if arguments are invalid,
> > + * -EOPNOTSUPP if the master does not support CCC commands,
> > + * or another negative error code from the master's operation.
> > + */
> > +int i3c_master_supports_ccc_cmd(struct i3c_master_controller *master,
> > + const struct i3c_ccc_cmd *cmd)
> > +{
> > + if (!cmd || !master)
> > + return -EINVAL;
> > +
> > + if (!master->ops->supports_ccc_cmd)
> > + return -EOPNOTSUPP;
> > +
> > + return master->ops->supports_ccc_cmd(master, cmd);
> > +}
>
> [Severity: Medium]
> Does this function's logic and return value match its documentation and the I3C
> subsystem semantics?
>
> The docstring states it returns 0 if a command is supported, but it actually
> returns the boolean result of the supports_ccc_cmd callback (1 for supported,
> 0 for unsupported). A caller checking for 0 as success would incorrectly treat
> supported commands as unsupported.
AI said correct, please fix it.
Frank
>
> Additionally, if the callback is absent, this returns -EOPNOTSUPP. However, in
> other places like i3c_master_send_ccc_cmd_locked(), the core I3C logic assumes
> all commands are supported if the callback is NULL. Could returning -EOPNOTSUPP
> here falsely indicate no commands are supported?
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260525064209.2263045-1-lakshay.piplani@nxp.com?part=3
next prev parent reply other threads:[~2026-06-02 17:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 6:42 [PATCH v10 0/9] Add support for NXP P3H2x4x I3C hub driver Lakshay Piplani
2026-05-25 6:42 ` [PATCH v10 1/9] i3c: master: rename i3c_master_reattach_i3c_dev() to *_locked Lakshay Piplani
2026-05-25 7:05 ` sashiko-bot
2026-06-02 17:14 ` Frank Li
2026-05-25 6:42 ` [PATCH v10 2/9] i3c: master: Expose the APIs to support I3C hub Lakshay Piplani
2026-05-25 7:39 ` sashiko-bot
2026-06-02 17:16 ` Frank Li
2026-05-25 6:42 ` [PATCH v10 3/9] i3c: master: Add APIs for I3C hub support Lakshay Piplani
2026-05-25 8:00 ` sashiko-bot
2026-06-02 17:27 ` Frank Li [this message]
2026-05-25 6:42 ` [PATCH v10 4/9] dt-bindings: i3c: Add NXP P3H2x4x i3c-hub support Lakshay Piplani
2026-05-25 8:08 ` sashiko-bot
2026-05-25 6:42 ` [PATCH v10 5/9] mfd: p3h2x4x: Add driver for NXP P3H2x4x i3c hub and on-die regulator Lakshay Piplani
2026-05-25 8:43 ` sashiko-bot
2026-06-11 16:30 ` Lee Jones
2026-05-25 6:42 ` [PATCH v10 6/9] regulator: p3h2x4x: Add driver for on-die regulators in NXP P3H2x4x i3c hub Lakshay Piplani
2026-05-25 9:06 ` sashiko-bot
2026-05-26 18:16 ` Mark Brown
2026-05-25 6:42 ` [PATCH v10 7/9] i3c: hub: Add support for the I3C interface in the I3C hub Lakshay Piplani
2026-05-25 9:31 ` sashiko-bot
2026-05-25 6:42 ` [PATCH v10 8/9] i3c: hub: p3h2x4x: Add support for NXP P3H2x4x I3C hub functionality Lakshay Piplani
2026-05-25 9:56 ` sashiko-bot
2026-05-25 6:42 ` [PATCH v10 9/9] i3c: hub: p3h2x4x: Add SMBus slave mode support Lakshay Piplani
2026-05-25 10:29 ` sashiko-bot
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=ah8Smqrbk3mZi9t4@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lakshay.piplani@nxp.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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