From: Sudeep Holla <sudeep.holla@kernel.org>
To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kernel-team@meta.com
Cc: Cristian Marussi <cristian.marussi@arm.com>,
Breno Leitao <leitao@debian.org>,
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Subject: [PATCH v4 6/9] firmware: arm_scmi: Refactor protocol device creation logic
Date: Fri, 04 Sep 2026 16:58:01 +0100 [thread overview]
Message-ID: <20260904-acpi_scmi_pcc-v4-6-6ebe9755606e@kernel.org> (raw)
In-Reply-To: <20260904-acpi_scmi_pcc-v4-0-6ebe9755606e@kernel.org>
Move the protocol validation and device creation logic in scmi_probe()
into a reusable scmi_device_check_create() helper.
The helper centralizes checks for the protocol ID range, implementation
availability and duplicate activation before invoking
scmi_create_protocol_devices(). This preserves the existing behavior
while allowing the logic to be reused by the ACPI path, where protocol
child fwnodes are absent.
No functional change intended.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/firmware/arm_scmi/driver.c | 59 ++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 4fbedd9be852..10e660da440c 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -3244,6 +3244,39 @@ static void scmi_enable_matching_quirks(struct scmi_info *info)
rev->sub_vendor_id, rev->impl_ver);
}
+static void scmi_device_check_create(struct fwnode_handle *fwnode, int prot_id,
+ struct scmi_info *info)
+{
+ int ret;
+ struct device *dev = info->dev;
+ struct scmi_handle *handle = &info->handle;
+
+ if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id)) {
+ dev_err(dev, "Out of range protocol %d\n", prot_id);
+ return;
+ }
+
+ if (!scmi_is_protocol_implemented(handle, prot_id)) {
+ dev_err(dev, "SCMI protocol %d not implemented\n", prot_id);
+ return;
+ }
+
+ /*
+ * Save this valid fwnode protocol descriptor amongst
+ * @active_protocols for this SCMI instance.
+ */
+ ret = idr_alloc(&info->active_protocols, fwnode,
+ prot_id, prot_id + 1, GFP_KERNEL);
+ if (ret != prot_id) {
+ dev_err(dev, "SCMI protocol %d already activated. Skip\n",
+ prot_id);
+ return;
+ }
+
+ scmi_create_protocol_devices(fwnode_handle_get(fwnode), info, prot_id,
+ NULL);
+}
+
static int scmi_probe(struct platform_device *pdev)
{
int ret;
@@ -3373,31 +3406,7 @@ static int scmi_probe(struct platform_device *pdev)
if (fwnode_property_read_u32(child, "reg", &prot_id))
continue;
- if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id)) {
- dev_err(dev, "Out of range protocol %d\n", prot_id);
- continue;
- }
-
- if (!scmi_is_protocol_implemented(handle, prot_id)) {
- dev_err(dev, "SCMI protocol %d not implemented\n",
- prot_id);
- continue;
- }
-
- /*
- * Save this valid fwnode protocol descriptor amongst
- * @active_protocols for this SCMI instance.
- */
- ret = idr_alloc(&info->active_protocols, child,
- prot_id, prot_id + 1, GFP_KERNEL);
- if (ret != prot_id) {
- dev_err(dev, "SCMI protocol %d already activated. Skip\n",
- prot_id);
- continue;
- }
-
- scmi_create_protocol_devices(fwnode_handle_get(child), info,
- prot_id, NULL);
+ scmi_device_check_create(child, prot_id, info);
}
return 0;
--
2.43.0
next prev parent reply other threads:[~2026-09-04 16:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 15:57 [PATCH v4 0/9] firmware: arm_scmi: Refactoring and enablement of ACPI PCC transport Sudeep Holla
2026-09-04 15:57 ` [PATCH v4 1/9] firmware: arm_scmi: Set generated device fwnode with platform helpers Sudeep Holla
2026-09-04 15:57 ` [PATCH v4 2/9] firmware: arm_scmi: Extend transport driver macro to support ACPI Sudeep Holla
2026-09-04 15:57 ` [PATCH v4 3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core Sudeep Holla
2026-09-04 15:57 ` [PATCH v4 4/9] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent Sudeep Holla
2026-09-04 15:58 ` [PATCH v4 5/9] firmware: arm_scmi: Pass protocol ID to transport chan_available() Sudeep Holla
2026-09-04 15:58 ` Sudeep Holla [this message]
2026-09-04 15:58 ` [PATCH v4 7/9] firmware: arm_scmi: Add ACPI PCC transport Sudeep Holla
2026-09-04 15:58 ` [PATCH v4 8/9] firmware: arm_scmi: Initialise known ACPI protocol devices and channels Sudeep Holla
2026-09-04 15:58 ` [PATCH v4 9/9] firmware: arm_scmi: Validate PCC shared memory signature Sudeep Holla
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=20260904-acpi_scmi_pcc-v4-6-6ebe9755606e@kernel.org \
--to=sudeep.holla@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-arm-kernel@lists.infradead.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