Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: neil.armstrong@linaro.org, vkoul@kernel.org, olteanv@gmail.com,
	linux-phy@lists.infradead.org
Subject: Re: [PATCH v12 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant
Date: Tue, 07 Jul 2026 11:31:00 +0000	[thread overview]
Message-ID: <20260707113101.6CEB81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707111829.180158-6-angelogioacchino.delregno@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Combining device allocation and addition into a single `alloc_and_add` function breaks device model configuration semantics for `spmi_bus_type` devices.
--

--- Patch [5]: [PATCH v12 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant ---
commit 07c884decc8feb83970dc7a2fe54a4fbf80be610
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

spmi: Implement spmi_subdevice_alloc_and_add() and devm variant

This patch adds new functions to manage sub-devices of an SPMI device,
including spmi_subdevice_alloc_and_add() and spmi_subdevice_remove().
These are intended to support complex PMICs that feature multiple
sub-devices addressable via SPMI register ranges.

> diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
> index 4050f3614dab8..e218c81405458 100644
> --- a/drivers/spmi/spmi.c
> +++ b/drivers/spmi/spmi.c

[ ... ]

> +struct spmi_subdevice *spmi_subdevice_alloc_and_add(struct spmi_device *sparent)
> +{
> +	struct spmi_subdevice *sub_sdev;
> +	struct spmi_device *sdev;
> +	int 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 combining allocation and registration into a single function prevent
callers from properly configuring device properties?

Since device_add() is called immediately here, the driver core executes bus
matching and broadcasts the KOBJ_ADD uevent before the caller receives the
device pointer. This leaves no window to set properties like of_node or
fwnode.

Will this cause the uevent to be sent without a MODALIAS, breaking userspace
module autoloading and automatic driver probing for these subdevices?

> +	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);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707111829.180158-1-angelogioacchino.delregno@collabora.com?part=5

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-07-07 11:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 11:18 [PATCH v12 00/12] SPMI: Implement sub-devices and migrate drivers AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 01/12] spmi: Fix potential use-after-free by grabbing of_node reference AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 02/12] spmi: Remove redundant dev_name() print in spmi_device_add() AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 03/12] spmi: Print error status with %pe format AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 04/12] spmi: Remove unneeded goto in spmi_device_add() error path AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 05/12] spmi: Implement spmi_subdevice_alloc_and_add() and devm variant AngeloGioacchino Del Regno
2026-07-07 11:31   ` sashiko-bot [this message]
2026-07-07 11:59     ` AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 06/12] spmi: Add helper to get a parent SPMI device AngeloGioacchino Del Regno
2026-07-07 11:27   ` sashiko-bot
2026-07-07 11:57     ` AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 07/12] nvmem: qcom-spmi-sdam: Migrate to devm_spmi_subdevice_alloc_and_add() AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 08/12] power: reset: qcom-pon: " AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 09/12] phy: qualcomm: eusb2-repeater: " AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 10/12] misc: qcom-coincell: " AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 11/12] iio: adc: qcom-spmi-iadc: " AngeloGioacchino Del Regno
2026-07-07 11:18 ` [PATCH v12 12/12] iio: adc: qcom-spmi-iadc: Remove regmap R/W wrapper functions AngeloGioacchino Del Regno
2026-07-07 13:18 ` [PATCH v12 00/12] SPMI: Implement sub-devices and migrate drivers Andy Shevchenko

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=20260707113101.6CEB81F000E9@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