From patchwork Mon Mar 17 10:31:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14019039 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 5EE12C282EC for ; Mon, 17 Mar 2025 10:37:39 +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=xInay13bpNRSfWPsipWy1OwoA7 ZssJD5KmTzfva+MarZ1dKH8G7UZ8LChWl+IKd/yDF4fc3tw+scghSRBbAsGwYBpOQ3Leek+Pvq40r cQmKvNz9kMA05J9ZhAGpRDUxMyPtwARmVunWgtOs0zh368cxzzIizj3ojP3E2d20exm81yIeOK4o7 5rCDWlySfsziAzHz76Hx2UEjilLPIxH36E2vihDM36sXLSnr74wuT4ON/q2a+9JOkpZznaKFxrVlD gjWNkmPZZN2fcjK0ChhG/3SISfPnXIsBtOsoyXouNtRcew18V0y7O9UrM+RgPWxh+rAOwzwkPN300 rRdI8fzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7qd-00000002CF5-20TL; Mon, 17 Mar 2025 10:37:31 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7lE-00000002ASN-0jeq for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2025 10:31:57 +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 D3A45169E; Mon, 17 Mar 2025 03:32:02 -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 352E73F673; Mon, 17 Mar 2025 03:31:53 -0700 (PDT) From: Sudeep Holla Date: Mon, 17 Mar 2025 10:31:21 +0000 Subject: [PATCH v2 1/5] firmware: arm_scmi: Ensure scmi_devices are always matched by name as well MIME-Version: 1.0 Message-Id: <20250317-b4-scmi_minor_cleanup-v2-1-f4be99bd9864@arm.com> References: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@arm.com> In-Reply-To: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@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/ZANAwAIAQBBurwxfuKYAcsmYgBn1/oXaCG+TDZZOhTJY9TOzNiRDmh/ASClooXQS ULvaQc4/RGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9f6FwAKCRAAQbq8MX7i mDlcD/91WvfqsEDo8QCGDSrZP0K5rqejcpFZa1tHSr8VIDVtwcPHu7663QvlQvroM1N2tX+Ktk2 xBpVmOVwD+fW+hgbPyo6h1DegKGCJtr4LVcZEsWxvNwlCpbQh6QVo3Fa9+d/o+qIf5DaVR17lud H3rNbLrzV0h1ZyHZJEPKlBj3HKwtiQLMQVXzsq9isyceXlYhqA06AFE9oDjWsItf0VmAqdPqpHR MdaA5VXOweATiNwoONMmE1j67BzBLmW9zg2E/DIxd8/5O0ACOSGFyswqqPHF1A9AiF7ewFxPPpx vKHkysRwFMWAMZ9s8wqjqhnyrvSy9xNytGd55d1B8pF9kdc3fZ879z9MkaJHc+09pTEa5azo3zv 9WyvR9wIPnYKcMkYt+LFoP89jNwKWbr3zzf2osdZ6KfJq/iwk+ie2v+0hzfXrt8Wk9zGoDY6NfU whaJa358FDrHscdlDCAiPRM4wsggk/Bs9v4hQVIkgcapBkB2KvXufFo3m3+QvIgrawIg7cZzfT0 IuMDJFvpAtzDBp9MXdzaZc+WAc3QhFwj4IQDBL+YungCViVlDuAfem6EIzdfzKghNauE2EYoijJ Ix5kvOvm/Wzkr8sED/BiMahO+CdKOXUZm9bNjtr+KiWHyQgUkTcSYc/9mROtuTb6xIjt92Wo/af LwY/K6iJPZHg3/A== 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-20250317_033156_269309_E12A36FA X-CRM114-Status: UNSURE ( 8.62 ) 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 Mon Mar 17 10:31:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14019041 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 918EDC282EC for ; Mon, 17 Mar 2025 10:41:05 +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=w7p0BRNFgsOAu2X5HZpMAIRHBR HIeMzTR3XRCtsrlF8IGTivl6GOwnl7duXo1uL1syOIxq2rKecioVcDdn5uP/KhawLGJhqEclEjb2p k0xvjrAY1ltxDV3uQ8uEAYwSMy5hMDUflZHjysVmAlp2DEpadw0eqFCLax5C/JHLgyxVNi74m60i0 R+kohq19ZAEeRAXnOAOxgSf94FRycStEgCJFB9Vv8hMhJKZudKDxrukbXgvZ8kJLX+XCXpbmyQNTn od7UXXX2t9uEKgi0eZeVOpAV95m7AVXkL2uWzRXXBJ/FHSViXAavU49fDzCqomTBoL+UzF7dS10gg /MOv6cTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7tx-00000002D98-0GTp; Mon, 17 Mar 2025 10:40:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7lF-00000002ATB-02Mt for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2025 10:31:58 +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 DA9DB22FA; Mon, 17 Mar 2025 03:32:03 -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 3BB323F673; Mon, 17 Mar 2025 03:31:54 -0700 (PDT) From: Sudeep Holla Date: Mon, 17 Mar 2025 10:31:22 +0000 Subject: [PATCH v2 2/5] firmware: arm_scmi: Refactor device matching logic to eliminate duplication MIME-Version: 1.0 Message-Id: <20250317-b4-scmi_minor_cleanup-v2-2-f4be99bd9864@arm.com> References: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@arm.com> In-Reply-To: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@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/ZANAwAIAQBBurwxfuKYAcsmYgBn1/oX/bDNN6C4OIcuzQDIH8p91pkEVI67HPAN/ vlg5PqJOeGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9f6FwAKCRAAQbq8MX7i mCmRD/91EUqn0e5HHr299UU4qQo8JTS92BhxmGSjlM3JhRUrGRsLUWP1eQUN3LmTaIpHBou9Ebm ZDXdsInfZazZYiZXTjMhHx8sk0leJqewwu5XUshKn7zX1vyWiT8sZgkKwE0yyAPvJkLt7tB8nzr R7KF6mQM9N1YyLfNRJaVDhwXtf7U7QGVbPQLxYUmZZbj6K927KFil/ecXDlhMY540nY5pavtF44 MkwmekOjWz8/3iZuojsBpGvHBntZl/QO7uKzqAXLWXSEJFOBfPVWRyDkrD6NOMAwxo/G3giIUhF HhCVnLyQNCqt1g9+XbKKifXT/A1dKMbq0uv2UZVyfqiTEy7N48E7IAMKskxpwhbu8XdiccfHT4M thzORyH7uqNl3rMkRkgfZUW4IMeQ4M5aszRltf13Z2jjkZQpP+IpC8tjBHdWv31BzGHFvg2IrX7 ApuGphOsEEFBa9UcRXe90N7C1W15wdLFnatNztq34L7eT7qadgyfLhzL281Mr4qCtuXP6w1uRaJ GykV5jkRAe4EwCVIy5lTkljp59OOkvU7GxF/77AmJgsp1Tpz753KgIwkVDJssyxSbBgnlvVh2b5 flssMoWVuCzwbAb3YScQLA4IyPe0VUGq8eHZFe18+/LDXrMVLtNLa0yk5O3h8sdw+zBVdcPPRE8 OzVVylSi6KhnZcA== 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-20250317_033157_178109_373B8D0C X-CRM114-Status: GOOD ( 13.90 ) 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 Mon Mar 17 10:31:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14019040 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 F0C90C282EC for ; Mon, 17 Mar 2025 10:39:25 +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=u6coAm+xOaQO6OHlbGUholBENQ qgHUOtolFAnLdfMoO/huFfVtZRt00No180B2MlU9CQ0M28Kf+eagQiNu5z4F/ALMao0MKnNNEa5T7 V9EqtWUlV98m7Q3a3ELmqWwva7lw1Q2Y6EWra7CbvilICfE32/+2seLh5esm0KITkIwN/TXINy6lD L5jG/x5QYnZHPuRZfgPCtehJD9fyLTzZ1T7SDuGoxo1Hl7zeH2gpS4LZt1CAkloFrm2St0wEqrxan fhFL5cVAzlJ3zgG308FaDDm7rgqx2lNV4k11r1SHh/OjZ7QxmClcyCj8TbZgkveF2SmLrF8ip6zOw dOQfTB4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7sJ-00000002Cf0-1Ygg; Mon, 17 Mar 2025 10:39:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7lE-00000002AUL-1lrn for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2025 10:31:57 +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 E15D42573; Mon, 17 Mar 2025 03:32:04 -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 42A9A3F673; Mon, 17 Mar 2025 03:31:55 -0700 (PDT) From: Sudeep Holla Date: Mon, 17 Mar 2025 10:31:23 +0000 Subject: [PATCH v2 3/5] firmware: arm_scmi: Refactor error logging from SCMI device creation to single helper MIME-Version: 1.0 Message-Id: <20250317-b4-scmi_minor_cleanup-v2-3-f4be99bd9864@arm.com> References: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@arm.com> In-Reply-To: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@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/ZANAwAIAQBBurwxfuKYAcsmYgBn1/oXGXo6nMyBXZwcB8PiBW//97hd3w0Y4eLpj OODF0LBRDKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9f6FwAKCRAAQbq8MX7i mMEhEACwMbFPuziNNpyehwRtN3ACLpifBgRPCfhGpDGXyaBp+mfbHySNr74yMDxG8Gjy3tao/k8 aAg1Eq75qKeN1BkYxLMAmgdWu1zZ5QPanx4F2f5TjkMR98j9Tl8ecGU10SgvSUKv1OY8UG6n3tn Lcw9hW2U/M5lLNwESg36UK3EP3IGEkv2hyxFIOnD+bnVGx3i6k5UkKYmEvJioIvVjvu1lj35Svu YLkjbms/SaVe69/+2PtZlwr79kK86Bv1gdZUSU2rUvwLiejNZodQTns3HbKJGlJUTO6BsIHbGJF cp2Bf8RG0Gz3U2YLObpWmFTCUYJ2Zz4HzNmzhUlgdI1QYyaVACyOCKgQeXfCBUabq42n2npBgHy tHlC0qaMAejiznWvXj6HH5sFzDH13EPRtyDXxP7HPf0EySE41Y+ldkpUtY/w7aHrrddzOo/UiEG PSL6B4Xe5hARTtGYPdMEY8m+WIlhon4JF6qMXQiLQ+BRxDLLZt/saL418yqQb4McuPdPX4sSHvS BKUMuPZnqxnrMfWVcEaEeQPqt2oyiDKSrH0P2/Zf1wztrvyTUzRbZ+rjcVc9uUM+SEw1ml9rhT4 AVQNSb1D72QleBfEm5QZOl/yutVX7q1kX3M0DXwrx3SoAq5z0ju7wrcIeS9FP5D9wQ7JFY7OLDM chBzVQgZI4M+F7g== 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-20250317_033156_555440_124DDDF8 X-CRM114-Status: GOOD ( 12.59 ) 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); } From patchwork Mon Mar 17 10:31: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: 14019042 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 2B42DC282EC for ; Mon, 17 Mar 2025 10:42:48 +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=nkyt0LQ6+PWNMydY4CY0uDodtVkrVIBAaQP66/+/Z98=; b=ph628BQu8F7KuHMjQGTuC9pVHe 96JgCxYXfVGLj0OofaWyinAAIEZr8MO4f3Leq1Kgi9Z9CM1BmyRzrVMBfGphCKf356V5gThlwfJQ8 F1JZJkiufeqb/cJWkdlE9nCyMiIqxjxqbkGHW4QhfL1SUP93O2eprc/Y51yO9a1cZkgYWmMQAA+WR dSR8mf0VwW0rFD2IDiEb2PWKo944yNGULd3rm64NxJqvLvphw4qgG+bZhALV5PHWtyLMSJrIYJr9C XygpKcFzjm4ztEqt7IvHbeCBh4Cdpm8gdJb8OoXYOyDMl37Buqs4RvbeVFDghIGyZNQwCzaYjQNlR IDUICITA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7vZ-00000002Dbg-4984; Mon, 17 Mar 2025 10:42:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7lF-00000002AVK-1aGS for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2025 10:31:58 +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 E854F2576; Mon, 17 Mar 2025 03:32:05 -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 4982B3F673; Mon, 17 Mar 2025 03:31:56 -0700 (PDT) From: Sudeep Holla Date: Mon, 17 Mar 2025 10:31:24 +0000 Subject: [PATCH v2 4/5] firmware: arm_scmi: Assign correct parent to arm-scmi platform device MIME-Version: 1.0 Message-Id: <20250317-b4-scmi_minor_cleanup-v2-4-f4be99bd9864@arm.com> References: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@arm.com> In-Reply-To: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@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=1404; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=mZZiNnV+dVw+v9KoptYJu4F6GYbaOFq2eVdf689ZBD4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn1/oXyNMrXg9MnZVuIKmNMGEYZ4lnH674QgePH UGbz08fcQmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9f6FwAKCRAAQbq8MX7i mGU1D/sHfBvDC7UistySWK57S4vengY/pgahfQwNwjYmXCgjIqLNZPi4MQfhiA+gsTy2cR+ZjAN jcJa1FxtzTUZvuGli502xsMomnHpcPaLUwptgXxxOfwy3dsxK9fxUTNodN0Cw/iq/+JTr1zfV9T 0MMMWgODB2KcuSfBR/BjgXZAuDfgSTZmqPYDtH2MB7N3dim8tSI1gC/zKvphLusxCGglkOVQTDH 5axyAgB84u4ZFyRZn1h7/epyWEE9MUzrf/3M2gkOQreGCcWPJyyxPYWRZ66vauw0gfmtL42wTuG HDoEcs8gk6XKdRfof7iXLT4HdHqWkYtv52sOPT78xzcZ/ZkXdZODHozJe1Ac6VhUK9Hwx+rnSgQ OzzWBjfYvn4LRGLuoilv0PTSjEiQWnsRvdQmkjQ9U+oSgZBloSDLc8iRq8RgEsyquere6sn3laq +zjD35IOARKxj0m2gwhZuVylyecbr8C1H+cr5kTHt4HSFGWCFzYF3LoenEJjRKWnP5tu/T2xJU/ ehFrT/11fF4l3cZ1G26IZy9ZSlnavPJDPWrCJcstv6Pl1nTtZqm5a22t+TFo78SS5ncZqfbA3TF wvyX37/oy3UXj4fyFZgSycCwww3a6IP5QdG4lKjxPEXT/Hz82M36MJ2pvmlTTx8OFiRoTcX6DJS wSUhgD5WxGJMeLQ== 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-20250317_033157_548126_2133EDAE X-CRM114-Status: UNSURE ( 9.87 ) 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 With the decoupling of transport drivers from the SCMI core, the "arm-scmi" platform device is now created dynamically from the probed transport driver. Currently, this "arm-scmi" platform device is added to the root of the platform bus since no parent is assigned. However, the transport platform device, created from the "firmware:scmi" node in the device tree, should be considered its parent. Ensure that the parent device is correctly set for the "arm-scmi" platform device, aligning it with the correct transport hierarchy. This will be more useful on systems with multiple transport and/or SCMI firmware instances as the hierarchy is maintained correctly. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index 10ea7962323e43e03e7c5636c56d707803d4ea55..dab758c5fdea3aa34188ef7d424ba8a43ada46d8 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -475,6 +475,7 @@ static int __tag##_probe(struct platform_device *pdev) \ if (ret) \ goto err; \ \ + spdev->dev.parent = dev; \ ret = platform_device_add(spdev); \ if (ret) \ goto err; \ From patchwork Mon Mar 17 10:31: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: 14019043 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 80A5AC282EC for ; Mon, 17 Mar 2025 10:44:28 +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=ktj08HwZWDlq7QXhBXMDnAVn5XN6gSbDlXpuqM7y2m0=; b=xo7yi9uWVLYTyErWQVd6ffWKjF cqexhppPgJq39cgr7gpojP+SH/Gegne7rEqsBbVzljS/PIDCu+/2HlWnMt183zxCrghSULdoXxdA9 f+mAupzahGF/2HCVMZiTh1Qm2GLlh9Ik2WTahzsi2ka8cdjrJemAtW44zCL3/Z1zp1viCqP9wWFLU 9VechLnYn7pce+4jtJ7QYdZ/RN0FDlFb8U4BKsUqjkhHzgy2vddgS0bhmirZe4JiWjWkZJkSCXkMd 2SBT2lN7V7F5YsIiT7Y5rMYsKFzQ3EanL3cZcqGHB0vTkkb3xmvKYRy2ZPCpO6pnSbS9lARygGei/ 9ewL6k+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7xE-00000002E77-2xz1; Mon, 17 Mar 2025 10:44:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tu7lG-00000002AW7-2WJm for linux-arm-kernel@lists.infradead.org; Mon, 17 Mar 2025 10:31:59 +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 EF31213D5; Mon, 17 Mar 2025 03:32:06 -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 505DB3F673; Mon, 17 Mar 2025 03:31:57 -0700 (PDT) From: Sudeep Holla Date: Mon, 17 Mar 2025 10:31:25 +0000 Subject: [PATCH v2 5/5] firmware: arm_scmi: Exclude transport devices from bus matching MIME-Version: 1.0 Message-Id: <20250317-b4-scmi_minor_cleanup-v2-5-f4be99bd9864@arm.com> References: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@arm.com> In-Reply-To: <20250317-b4-scmi_minor_cleanup-v2-0-f4be99bd9864@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=2251; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=+0Mtk2eBncY1WYJIQ+eI2xyXGHa8QgJ27kWhxHLl+WI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBn1/oXALW1n2ivxHeilduro5z69613W2Hqp+07J mNXudCgjA2JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9f6FwAKCRAAQbq8MX7i mId1D/0YKECS/00M0g5dqAooVvQLpBQeZBw13JMvcgLmYOPdGDU40hANEjQWoUVwuQEh1/ErpJ3 6GvuVuQl9+rjRp8l4E84rejwzedl7gveG0Vi2UMwobEPR8fVIZlmbOJcwmeiszSv7f/aQygG79O BSHAVXRmm2uvMqOqgiB1jx96uwLmjx/uJh73T/oFsHc1dsdBlYl28C5nPIcWhTQck1nhvh8kogt VqIzM5ylytyIW8euWA3PChiegAcfFmABMPMOrEFTMhV/H8RYOYVmH4+gh/hIX5jWnuws2Nnv1ZQ 6JLhvXOZ3W48SKzvRIUd03yxSy9ANKuCHp80/7ncHDoh5pdVhRW7DUPjvA5YkSJmu1p3gA16Nna X0N85SkPqqgxN10wNeLc865lAKbQahnLm/CEnNezzC5Yf9LZGMs5RAX7lVOaEsLmm1YOjbVuVBv HgCwNQvHOa4FeUJUcw1T+cNU+jBMUspTp5l+Bp8xgGM6prol+4kmjL1PPmbc0pscBTK34IXMrov em01vHrF1Z3HuPpHtJPq2L3LbNu2TkzErQvD+CBH42dSgqJ438wxkugr3cHi9hSnoEK5Imvnk5u J7awQq/5MiIb6ZL1RfPfPt9gZARP+PE73rnvI1lYcsmMRT4+TktHijWtP2jz+LYlKacVqsOcXn4 roshAtm/2hhktGg== 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-20250317_033158_779726_CAEAD6C4 X-CRM114-Status: GOOD ( 10.83 ) 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 Transport devices are currently being unintentionally matched to drivers with the same name, allowing their probe function to be invoked. However, the bus notifier prevents them from setting up handles, rendering them unable to utilize SCMI core functionality. Instead of relying on the bus notifier which can't prevent bus matching even if it returns early or error, move the check into the bus matching logic itself. This change ensures that transport devices are entirely excluded from driver matching, preventing any unintended probe attempts. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/bus.c | 2 ++ drivers/firmware/arm_scmi/driver.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 493e2c63b107fd9063f11034b71d65f567bb0778..17b0e6e2cb0a65d88079346b3da319ce6356b42b 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -212,8 +212,10 @@ static int scmi_dev_match_by_id_table(struct scmi_device *scmi_dev, if (!id_table || !id_table->name) return 0; + /* Always skip transport devices from matching */ for (; id_table->protocol_id && id_table->name; id_table++) if (id_table->protocol_id == scmi_dev->protocol_id && + strncmp(scmi_dev->name, "__scmi_transport_device", 23) && !strcmp(id_table->name, scmi_dev->name)) return 1; return 0; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index b80c574cb3bb2f12b2980fc844ea3da10abdc9f1..2b567f29c83493487b8b0998886dcf75827017ef 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2829,9 +2829,8 @@ static int scmi_bus_notifier(struct notifier_block *nb, struct scmi_info *info = bus_nb_to_scmi_info(nb); struct scmi_device *sdev = to_scmi_dev(data); - /* Skip transport devices and devices of different SCMI instances */ - if (!strncmp(sdev->name, "__scmi_transport_device", 23) || - sdev->dev.parent != info->dev) + /* Skip devices of different SCMI instances */ + if (sdev->dev.parent != info->dev) return NOTIFY_DONE; switch (action) {