From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: neil.armstrong@linaro.org, vkoul@kernel.org,
linux-phy@lists.infradead.org, olteanv@gmail.com
Subject: Re: [PATCH v13 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant
Date: Tue, 21 Jul 2026 09:49:15 +0000 [thread overview]
Message-ID: <20260721094916.49C831F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721093626.96264-6-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The new `spmi_subdevice` acts as a dummy parent device but does not enable runtime PM, breaking PM propagation from child devices.
- [High] `spmi_subdevice_alloc_and_add()` conflates device allocation and registration, preventing callers from safely configuring matching properties (e.g., `of_node`) before `device_add()`.
--
--- Patch [5]: [PATCH v13 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant ---
commit 09395afcc62824fab7f184ceae90afb8ac488cec
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
spmi: Implement spmi_subdevice_alloc_and_add() and devm variant
This commit introduces new functions to allocate and add sub-devices to an
SPMI device. It is intended for complex PMICs with multiple sub-devices on
the SPMI bus, and includes devm variants exported under the SPMI namespace.
> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
> index ba4a980a35ebb..bafb4c3e6c174 100644
> --- a/drivers/spmi/spmi.c
> +++ b/drivers/spmi/spmi.c
[ ... ]
> @@ -429,6 +455,58 @@ struct spmi_device *spmi_device_alloc(struct spmi_controller *ctrl)
> }
> EXPORT_SYMBOL_GPL(spmi_device_alloc);
>
> +/**
> + * spmi_subdevice_alloc_and_add(): Allocate and add a new SPMI sub-device
> + * @sparent: SPMI parent device with previously registered SPMI controller
> + *
> + * Returns:
> + * Pointer to newly allocated SPMI sub-device for success or error pointer.
> + */
> +struct spmi_subdevice *spmi_subdevice_alloc_and_add(struct spmi_device *sparent)
> +{
> + struct spmi_subdevice *sub_sdev;
> + struct spmi_device *sdev;
> + int ret;
> +
> + sub_sdev = kzalloc_obj(*sub_sdev);
> + if (!sub_sdev)
> + return ERR_PTR(-ENOMEM);
> +
> + sdev = &sub_sdev->sdev;
> + sdev->ctrl = sparent->ctrl;
> + sdev->usid = sparent->usid;
> +
> + ret = ida_alloc(&spmi_subdevice_ida, GFP_KERNEL);
> + if (ret < 0) {
> + kfree(sub_sdev);
> + return ERR_PTR(ret);
> + }
> + sub_sdev->devid = ret;
> +
> + device_initialize(&sdev->dev);
> + sdev->dev.parent = &sparent->dev;
> + sdev->dev.bus = &spmi_bus_type;
> + sdev->dev.type = &spmi_subdev_type;
> +
> + ret = dev_set_name(&sdev->dev, "%u-%02x.%u.auto",
> + sdev->ctrl->nr, sdev->usid, sub_sdev->devid);
> + if (ret)
> + goto err_put_dev;
> +
> + ret = device_add(&sdev->dev);
[Severity: High]
Does this allocation and registration sequence prevent callers from configuring
device properties before calling device_add?
Because device_initialize and device_add are conflated into a single function
without any opportunity to configure properties like of_node or fwnode, it
seems this might prevent bus matching and sysfs symlink creation.
Without an of_node, wouldn't the MFD core fail to assign DT nodes to child
cells, causing module autoloading to fail for statically named drivers?
[Severity: High]
Also, does this new subdevice properly propagate runtime PM requests?
When a child device (like an MFD cell) calls pm_runtime_get_sync, the driver
core's __pm_runtime_resume checks the parent. Since this subdevice is added
without pm_runtime_enable, its disable_depth will be 1.
Will the driver core see the disabled state, skip resuming the subdevice, and
stop propagating the resume request up to the actual parent PMIC, causing
hardware accesses to fail or time out?
Should this call pm_runtime_no_callbacks and pm_runtime_enable before
device_add?
> + if (ret) {
> + dev_err(&sdev->dev, "Can't add device, status %pe\n", ERR_PTR(ret));
> + goto err_put_dev;
> + }
> +
> + return sub_sdev;
> +
> +err_put_dev:
> + put_device(&sdev->dev);
> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL_NS_GPL(spmi_subdevice_alloc_and_add, "SPMI");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721093626.96264-1-angelogioacchino.delregno@collabora.com?part=5
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-21 9:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 9:36 [PATCH v13 00/12] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 01/12] spmi: Fix potential use-after-free by grabbing of_node reference AngeloGioacchino Del Regno
2026-07-21 9:49 ` sashiko-bot
2026-07-21 9:36 ` [PATCH v13 02/12] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 03/12] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 04/12] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-07-21 9:49 ` sashiko-bot [this message]
2026-07-21 9:36 ` [PATCH v13 06/12] spmi: Add helper to get a parent SPMI device AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 07/12] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 08/12] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 09/12] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 10/12] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 11/12] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-21 9:36 ` [PATCH v13 12/12] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
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=20260721094916.49C831F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@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