From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A7AAC5B572 for ; Thu, 13 Aug 2026 11:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sFnA6Ef7ubnQ2/hX+qzCf4AYCihzuJoRE0dgbY1LGCE=; b=M7vx44jTNTfmsIKcdGxsCW+D6l 8Ns8RDt3ObIZxoDo+GKwXKKHeh2oxgTDfrk8JhUxuk9T0efrh/y4Q9CUtFzxOGxr0advldEIlaEpM a6wteaz1JQOJxvVSIhiJlHcQCsatXT3bICBGO2ZIR3rF10JPkJnivAWeMTDy/q1qwpiBLUJXoC7yV Etbdb07U4WMDpTRPZIEzTpS5cpf8GLIbLlqxo2i+OphV+ZIHnENHGBk2k0ghsfdEcyesfKxwma4KP pwfbK88pcQHMDzBS3HDKbUPMBhh6C4RFDbcaIWpr4uvqmYVe1k9+GiTxshDugz5GYXFe15jiWOZcA CvVXqqAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wuTgx-00000000YYy-12Q2; Thu, 13 Aug 2026 11:33:47 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wuTgo-00000000YUE-13Nc for linux-arm-kernel@lists.infradead.org; Thu, 13 Aug 2026 11:33:38 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0792D42DA0; Thu, 13 Aug 2026 11:33:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F0141F00AC4; Thu, 13 Aug 2026 11:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786620817; bh=sFnA6Ef7ubnQ2/hX+qzCf4AYCihzuJoRE0dgbY1LGCE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=h79y3UimKev9g0XE2GkoUt5TZHI3tZe9g74UkHcs7Xgl2TfT9R46VhsGhK7RZ8yyg +/5jTS9Mahtj+4qaIxaCInF/VhIZJ3HzfkTVPbQJQZMFsxR0AAxYYFRNdu7OJ2xmMz ViwSmEzbJDQzW5Wz9Zdz/QVrJ08Hs3LrRJk/mJ4p0i0PyIV4DRU+h5zWyeNXYbHK/P 1RzLMEfDdEbDqWx34OZT6op4fArhkhgb0WUrOxwznFCIS0fV7tx4l7MtQklz0nnLjs 7Ag8OWjrHdT8eQ0OgWNAWuJwAYeBdBGY07rvcsGIdXuZNs/gc+XbDLuOV19pyNYe7S mZ38lw0sxefGQ== From: Sudeep Holla Date: Thu, 13 Aug 2026 12:33:01 +0100 Subject: [PATCH v3 6/9] firmware: arm_scmi: Refactor protocol device creation logic MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260813-acpi_scmi_pcc-v3-6-cb6b88b4ebb3@kernel.org> References: <20260813-acpi_scmi_pcc-v3-0-cb6b88b4ebb3@kernel.org> In-Reply-To: <20260813-acpi_scmi_pcc-v3-0-cb6b88b4ebb3@kernel.org> To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@meta.com Cc: Cristian Marussi , Breno Leitao X-Mailer: b4 0.15.2 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 60 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index aad678db0f6e..951ba3df6ba6 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -3244,6 +3244,40 @@ 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; + } + + fwnode_handle_get(fwnode); + scmi_create_protocol_devices(fwnode, info, prot_id, NULL); +} + static int scmi_probe(struct platform_device *pdev) { int ret; @@ -3372,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; - } - - fwnode_handle_get(child); - scmi_create_protocol_devices(child, info, prot_id, NULL); + scmi_device_check_create(child, prot_id, info); } return 0; -- 2.43.0