From patchwork Wed Mar 12 11:40:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013481 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 879B0C28B2F for ; Wed, 12 Mar 2025 12:40:15 +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=XVdb8TcZcGiLA11zLQgwOEi2kMI+zynrBhvgvBD5Jyg=; b=E1e6jW3NIWqudRVrcxeCgftki5 oYp1NdaW26upzgdtA9zvRg+UCKdK5pNEHNpC9Ups8otBf/T7CoB4u59U0Px/elWYuUirz0H8oXTmC RnfSoVxhwbrdD6OICWuxdCxRBIMEFMLIrHpPXShp0CZ5NX/4j3NJBzo/S8SXEgxR4GurkH2/2b4gA ++foKP3MwqdkCSLHzaXJ8X9rzIrOQIleVpny1XAiL9RyMRGQxgivBZ+3LqGFsZlFFiXtGUpmJMBNY cr/xt1IYxgEnpSpcJs+7h4zflaTiXAfdd0tuEfB93RUo9NY1PSskSkSqZVN80qnrVY43e+8bgbjAk 0qeVOHPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsLNV-00000008Qee-3hMi; Wed, 12 Mar 2025 12:40:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsKS6-00000008ILt-1z2d for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:40:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D78D51595; Wed, 12 Mar 2025 04:40:54 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6377E3F694; Wed, 12 Mar 2025 04:40:43 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:40:24 +0000 Subject: [PATCH 1/3] firmware: arm_scmi: Ensure scmi_devices are always matched by name as well MIME-Version: 1.0 Message-Id: <20250312-b4-scmi_minor_cleanup-v1-1-c62c6cb4111a@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1346; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=WbYcwPFa1V2cCGxOBvupgDD2HrO3B51Gf6RHdYRG7bU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn0XK5a49E9ckMH5JeP7jTH0gvShMQEq4jn82J4 ec11jSt4ACJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FyuQAKCRAAQbq8MX7i mMMsEAC+cqTkFyWVy5IMGOTm2WMfFGHZvA7sGj8pbABqiG5Lvjg/4UFrDlzYtavxi2QUdtrRxPM AqadNtOWIncN8IFopCUza4A6Bi/W3uL0kht7JRL0DEFPpmFSsGUVkz1Zflz+A6cIuLbgtjXekXv qmAKqgMh/O091e+pJGdg9zC0T+TBG7jWklDCrag4n6LO9BnXZAUBmK59QsoUoGD/usLpzcf082u ve9a0oof56G0k4IYfNDQ9zgVTKdV4uEEkHr37GMJPxPgJQr0Bk2E24E5qKM/C6YTrl3Xi2kYu3Q XUmR/2y13zlONP1F7vl66rsd5aNLe3S5QsEZn90+2zZC5hrecxnl0rb/q9/REo7zvsMsXNWjP3a LYHT7sdy4VfTLHwR1L6zuussCGxCF+AGxidsTAtKrERgjwX9YH/24cCHZAS1T/jV9xSWUvNc0tP 9yc1m7qJYOBwUMkZElYcIfzHUUXifG+s96SddJGXv3G2c421aCydaVf+nFDpcY9kR0tqXpvqfbb WzIUAAow1R6ubZcE1x6RM6qh+QIOEpNteExuKcpmb7k+XweYSUDmMVc4x55uTSee+X3E9hJm0na 5wEq/FdnkaYQ8+JZxUpZqnPe0aQOzFV1RVGR4Q6/CSHM220A9xGG5PxVMgbHc8Kf/gCDyDGbEZL McUDlSDtp2nK2yA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250312_044046_549978_06DA7218 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. 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 Currently, devices without a name in the id_table cannot register drivers, and no scmi_device is created without a name via scmi_device_create(). However, the function __scmi_device_create() allows devices with no name, which are then labeled as "unknown." Removes support for matching scmi_device instances without a name, ensuring consistency across the driver registration and probing process. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index a3386bf36de508d312e2c4fa2e27ba62ba3776a0..050a5ff5dc96a7df58edff5faeb8c1ec6228b97d 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -214,13 +214,10 @@ scmi_dev_match_id(struct scmi_device *scmi_dev, const struct scmi_driver *scmi_d if (!id) return NULL; - for (; id->protocol_id; id++) - if (id->protocol_id == scmi_dev->protocol_id) { - if (!id->name) - return id; - else if (!strcmp(id->name, scmi_dev->name)) - return id; - } + for (; id->protocol_id && id->name; id++) + if (id->protocol_id == scmi_dev->protocol_id && + !strcmp(id->name, scmi_dev->name)) + return id; return NULL; } From patchwork Wed Mar 12 11:40:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013480 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 09BCAC28B28 for ; Wed, 12 Mar 2025 12:38:38 +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=Bzvtd/vhZp03AeLcq3w4TqXtf5We5BXq0EDS3aEITVY=; b=pvzK0I6b0+vavfwnvifGgFZoVI APJ5KRm/GP4knPZfBQ89rJPEHz+rEZR8xR8NDd8iX7vA58PiQXTbE9jHDSxkvOo7rtN4EeUwVlbJ1 DcE4QnOtJgeoAlCyH8vBmxvN0FFCUCl3I6fGuBSPwMHVFcgEhDsqg7pH7my1iq7Dltx9jNQ+P/xPZ 2x6iMntWddzvDxn3QKz4MQC0MLq1qkCKjqg/FmrJTS/UgiO9ZSboSuGPeOlRbBD8p+ui66pngYs4o vUU3CXwIPJObGPqxBoB87N3HobxXhIObGRVz86biSTTXWjZYHgOufQcy0ms+KGiHW5xMGf/jx+nPb NCXnyEhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsLLt-00000008QL8-0yo3; Wed, 12 Mar 2025 12:38:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsKS5-00000008ILz-1wQW for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:40:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DFFF81682; Wed, 12 Mar 2025 04:40:55 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6A6B03F694; Wed, 12 Mar 2025 04:40:44 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:40:25 +0000 Subject: [PATCH 2/3] firmware: arm_scmi: Refactor device matching logic to eliminate duplication MIME-Version: 1.0 Message-Id: <20250312-b4-scmi_minor_cleanup-v1-2-c62c6cb4111a@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3252; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=das9EqDKBZfkwRTCcRMlY6ZRJ43jXpNz8KtuySsJ6qI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn0XK5z/fs3X3oDJq9HA9QiNv5A7RlmIcK15Wrl yCNgaVjE0WJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FyuQAKCRAAQbq8MX7i mCUKEAC1kwHaHEpBrFARMxPMM9ht7SRbhw2is+y359Y0j7nt3IM6SfW1S70kydfWvKplIA41gGg zqyoE9QcXZ7d8Wpn5s8JYJapkp91cu4m6XSxVX+gl2U8piW81vy3wSDY0pl1DdZLNJUykwD26qO GEdLleN6F5DuiCgRlPSRkKny7GnjVSTvTCe2Q7AFmSB4odg4BcE3q8M5Q4YznMNuBu9r4df/PfF aM280+1e245K4vUgw/5eUrh8Ewh7F1D375/Yg1LA+h4iQ3luHsQ9Fx5Dg1SskZ84Ss47QAK1cOh RibFdEhl6dG6PKD7PZ8FxHWR9r0ygS5f2s2hyGNJae8+jxPKpljze++l7Y0ajKyBeboHBYEr6TN 3R9gqwh7oHzmK0BNBjcLisOUOHgnIfev6Ls/qGdnEyyXbOdxdKVvSxgrGO0qrF1YWaQyJo5kzM+ r8L6I66BiGtIZAK+VazhkdEPVdrZdDp+m+Pe1dK4tr1VQpNEz43btSCVNm93Zk0eGXmWc7ljMuZ uazIOr+fGI15D4TT7yfg5ClaaDjE8O2k1yTjCfcCCkgV76YEmmyFbVORECcWzs3i9JDeOGZOUuX k2ahs//phoSXwFQdpzFfy6O+HtzdX+x772ssigRbcsyloCll3ZnrDJ4Q3vP1MJ25O+8lAWlH8VU 4/BfX2H0isuUA+Q== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250312_044045_589175_6B531BCE X-CRM114-Status: GOOD ( 14.14 ) 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 Currently, the device matching logic is duplicated in two functions: - scmi_dev_match() used by the scmi_bus to match scmi_devices with scmi_drivers. - scmi_child_dev_find() used to check for the presence of a device with the same name and protocol_id to avoid adding duplicates to the bus. Refactor the code to eliminate the redundant matching logic and consolidates the functionality for better maintainability and efficiency. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 43 +++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 050a5ff5dc96a7df58edff5faeb8c1ec6228b97d..a30fd8e05e423e226a63833f309d8d30c400fabd 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -206,52 +206,49 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table) scmi_protocol_device_unrequest(entry); } -static const struct scmi_device_id * -scmi_dev_match_id(struct scmi_device *scmi_dev, const struct scmi_driver *scmi_drv) +static int scmi_dev_match_by_id_table(struct scmi_device *scmi_dev, + const struct scmi_device_id *id_table) { - const struct scmi_device_id *id = scmi_drv->id_table; + if (!id_table || !id_table->name) + return 0; - if (!id) - return NULL; - - for (; id->protocol_id && id->name; id++) - if (id->protocol_id == scmi_dev->protocol_id && - !strcmp(id->name, scmi_dev->name)) - return id; + for (; id_table->protocol_id && id_table->name; id_table++) + if (id_table->protocol_id == scmi_dev->protocol_id && + !strcmp(id_table->name, scmi_dev->name)) + return 1; + return 0; +} - return NULL; +static int scmi_dev_match_id(struct scmi_device *scmi_dev, + const struct scmi_driver *scmi_drv) +{ + return scmi_dev_match_by_id_table(scmi_dev, scmi_drv->id_table); } static int scmi_dev_match(struct device *dev, const struct device_driver *drv) { const struct scmi_driver *scmi_drv = to_scmi_driver(drv); struct scmi_device *scmi_dev = to_scmi_dev(dev); - const struct scmi_device_id *id; - - id = scmi_dev_match_id(scmi_dev, scmi_drv); - if (id) - return 1; - return 0; + return scmi_dev_match_id(scmi_dev, scmi_drv); } static int scmi_match_by_id_table(struct device *dev, const void *data) { - struct scmi_device *sdev = to_scmi_dev(dev); + struct scmi_device *scmi_dev = to_scmi_dev(dev); const struct scmi_device_id *id_table = data; - return sdev->protocol_id == id_table->protocol_id && - (id_table->name && !strcmp(sdev->name, id_table->name)); + return scmi_dev_match_by_id_table(scmi_dev, id_table); } static struct scmi_device *scmi_child_dev_find(struct device *parent, int prot_id, const char *name) { - struct scmi_device_id id_table; + struct scmi_device_id id_table[2] = { 0 }; struct device *dev; - id_table.protocol_id = prot_id; - id_table.name = name; + id_table[0].protocol_id = prot_id; + id_table[0].name = name; dev = device_find_child(parent, &id_table, scmi_match_by_id_table); if (!dev) From patchwork Wed Mar 12 11:40:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013488 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 A2E3EC28B28 for ; Wed, 12 Mar 2025 12:41:59 +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=YTLAF0tIpFzXbv7BL0TTLvyumrvT+IHuJUXwb+Jj2tI=; b=yRayuvq47/S+yUhXgdV2/7Hg+F jKsDxORL2Prlrcf3Rz5KQKIYwdScRE1inyc2+6B4lblbwDPydIEKAQ0R1X/bflfPwCwLATRMxYkTH YBwSx6RYoC3Rwbjx0xjn1Pn0DkX7j6hHdYqRznbNOH8RQGDbNwSEbln7MQHrKxgt3RKVnZypPUcp3 14r70PlHZR5GDnQ8CNt6Wco5N+yrr1jSZbdxs6IVCUiWsLz961McvNqU1VEEOuZap6TWCWXcvEpTx M/2/xQuc2GAfPrbxgEjtvlV+9SnS7LcNfYJSbiiNwkNbOMoLeITeTuLHseT1PF2wJaS4mfi86zI7f HzymW8AQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsLP8-00000008R2T-2J5f; Wed, 12 Mar 2025 12:41:46 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsKS6-00000008IMT-23Ay for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:40:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E59D116A3; Wed, 12 Mar 2025 04:40:56 -0700 (PDT) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 71C343F694; Wed, 12 Mar 2025 04:40:45 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:40:26 +0000 Subject: [PATCH 3/3] firmware: arm_scmi: Refactor error logging from SCMI device creation to single helper MIME-Version: 1.0 Message-Id: <20250312-b4-scmi_minor_cleanup-v1-3-c62c6cb4111a@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-c62c6cb4111a@arm.com> To: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Cristian Marussi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3348; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=0VunvKId+eIYxYj8ySEheQ8DibsTe7qSHuPUkpqsZwU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn0XK6Jdwi+oy667VHsmKiUVy0gTlQ8w3gayKT3 UPcvu/qiy6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FyugAKCRAAQbq8MX7i mPXnD/4ht/Ofjlu9URm34XojyW+8Gu/WXXcEh6WPL3RDaVtqTo7NcJds4KqaAOXwy/LnJk82b3Y pOGEiTyG2fs/sGJ4aN2B1yIC9pspkeDrfIWNbwguFFVD2/9EE6O4fdGp83EAxpy0m3bG26pKF1H R5JuFHx0Rz3yBxm1vxEc43Le1eWYWY16sv3VGX5eY/L+iDwGpX3FnVAAheo/WrrJ0VheKXsibv2 SMZwjsIXZsPlRNJmGvbM4tS7v5G6jJr0BqLyVxw8mw1CA7GVLtfj85Lq3Ji4mDrMPv533jZuPXS 6WSofQ/63CbsoJ/FxGl718nvHEuzHsJYG/NpiNzvdz8S0NAvl/4Zfk3knyLmYjyPHqzPPoXTTmn Mjv84bhL7d8VN8d0v7cJmp7ZHol24jF66jVG/dm/TVjXwNODlijTrtnkbTSus4FaDLhHPk7ve5h FadtXrc6dDBIgeg+f2iy4RNdTgSa3wY/w9Y6vDiDPIlbBINbFKnPdQQF34VfM2ZSyT07QFellcL 7haa8Q+figqNXU4/Fmh/kZkPB3/BVyGNluBWCUvdPIEGg7/Jmt4PnxNPSM0039gUjpP2BQ0w0pM 8tWrV+P5q3crTEa+UDgWdmNpefxD4YTwYhXlmbz70mdNcXhoSztOsD+CO8kNgvUJOKMnEXnJiWd FiC/MvGBeyMtf0Q== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250312_044046_623593_5DA6FEEB X-CRM114-Status: GOOD ( 12.64 ) 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 Refactors the error logging related to SCMI device creation. The goal is to remove duplicated error-handling code and centralize it into a single helper function: _scmi_device_create(). By doing so, any code redundancy around error logging is avoided, as error logging during device creation will now be handled by a unified helper function. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 29 +++++++++++++++++++---------- drivers/firmware/arm_scmi/driver.c | 8 +------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index a30fd8e05e423e226a63833f309d8d30c400fabd..493e2c63b107fd9063f11034b71d65f567bb0778 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -411,6 +411,20 @@ __scmi_device_create(struct device_node *np, struct device *parent, return NULL; } +static struct scmi_device * +_scmi_device_create(struct device_node *np, struct device *parent, + int protocol, const char *name) +{ + struct scmi_device *sdev; + + sdev = __scmi_device_create(np, parent, protocol, name); + if (!sdev) + pr_err("(%s) Failed to create device for protocol 0x%x (%s)\n", + of_node_full_name(parent->of_node), protocol, name); + + return sdev; +} + /** * scmi_device_create - A method to create one or more SCMI devices * @@ -443,7 +457,7 @@ struct scmi_device *scmi_device_create(struct device_node *np, struct scmi_device *scmi_dev = NULL; if (name) - return __scmi_device_create(np, parent, protocol, name); + return _scmi_device_create(np, parent, protocol, name); mutex_lock(&scmi_requested_devices_mtx); phead = idr_find(&scmi_requested_devices, protocol); @@ -457,18 +471,13 @@ struct scmi_device *scmi_device_create(struct device_node *np, list_for_each_entry(rdev, phead, node) { struct scmi_device *sdev; - sdev = __scmi_device_create(np, parent, - rdev->id_table->protocol_id, - rdev->id_table->name); - /* Report errors and carry on... */ + sdev = _scmi_device_create(np, parent, + rdev->id_table->protocol_id, + rdev->id_table->name); if (sdev) scmi_dev = sdev; - else - pr_err("(%s) Failed to create device for protocol 0x%x (%s)\n", - of_node_full_name(parent->of_node), - rdev->id_table->protocol_id, - rdev->id_table->name); } + mutex_unlock(&scmi_requested_devices_mtx); return scmi_dev; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 60050da54bf24c0245290e846f91aea62392855b..b80c574cb3bb2f12b2980fc844ea3da10abdc9f1 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -439,14 +439,8 @@ static void scmi_create_protocol_devices(struct device_node *np, struct scmi_info *info, int prot_id, const char *name) { - struct scmi_device *sdev; - mutex_lock(&info->devreq_mtx); - sdev = scmi_device_create(np, info->dev, prot_id, name); - if (name && !sdev) - dev_err(info->dev, - "failed to create device for protocol 0x%X (%s)\n", - prot_id, name); + scmi_device_create(np, info->dev, prot_id, name); mutex_unlock(&info->devreq_mtx); }