From patchwork Wed Mar 12 11:14:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013441 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 AB2E6C28B28 for ; Wed, 12 Mar 2025 11:53:18 +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=Wbn8VAPehrDatzTPGSX2t3HLbM kD8oqwD/7mzp2sEgR6ajg95XZkEbFIFh8REd4WND+yR2QNSTaXDr8/jy5iOk2b/OMKhSwSJbopxAA 8s9wCKqJcO5Ll1A7OMHaPpqkCPrz3IVMBA4lPJP1E8mrMw04CDfqHwHiRkz5TnxuH3QBghdEYO1Hd i1Nd/WBsVvPA0FFu5PZm24PH5MT8tkXBr0esHUwzrKo/Y7RGUTS1kAqiiukSH+m8G67IsqJFjvL1h bH+94I4CCLUpxE3hVQY5++/jR48ixWXlhL0EziuGhZdAqBN0EJSvLLW3WPvGUULTWEzuQ7FQ9OOga D23WHTlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsKe4-00000008K7Z-2nCR; Wed, 12 Mar 2025 11:53:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsK38-00000008E5a-0Akb for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:14: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 85F971595; Wed, 12 Mar 2025 04:15:08 -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 340B03F694; Wed, 12 Mar 2025 04:14:57 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:14:32 +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-51a514282794@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> To: 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/ZANAwAIAQBBurwxfuKYAcsmYgBn0Wyv9wb0h9iXqhIZTv5tNhA93oc9d4C+Qyual VrPBlMHEcGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FsrwAKCRAAQbq8MX7i mJhGEADJ5Ql6CA2xG6ytPemPtMmfbYU7br1oH2T8bNMWSViSN0phE24IC8THl5GRuEINKhqV8TR pHWqn63ir8oEC0+abPZpmHprTeobvAQXc+EcSBSgbzdAv3Xr74kyM+mxo1icEjBGLO5ou4N6Qhe kki2mXbNI5fz4xpMNIGg59MbHST+8a4usqMaOUs7OD7MiGcVx/lq7v/PpfT8TCkm26D8rXM/XX2 Uo5zwx6Cf1cMN/Athniadl1/lnjUE4GSg8lCTF2meFCIzQh6Dbev2YH6F4DuiOfVYwN9OllPsX9 UW9M+ShhqbtDsjCkxSNRjvhk9jgiAAkx/ZFk+3xpjqEooH6vea58Txu8538MLOno242lnYtWVQD ZEc5gH3s0mOoaSOieRoMZ2XlaDjRnm33UFwRHu/kC+EDjQLjL+HnFr6AHKTlQb89G7Y86nZkzLQ meGBiZ1DodtyEcd0V1iPxzM9WEJdON1i8iy5xW9waai/q6PAB3XktvW2mwbCyN2hMnhh7++ggJU 2KPbeKQNLKCNCWTQdUyo75GQEx5IK44GTKvqeK3UpnS5znRFDOdy1URc6jlPS3UH87ugfrU45mL LGE4IW4WUKwfrUiBwrsdZnVFmuZmxPCNjjdrhLUQkvQSv3i6AZF8531t6XwvgOldH0q78oDKakC CUjcr1w3mlZ3Frg== 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_041458_123931_B04EAE72 X-CRM114-Status: UNSURE ( 8.74 ) 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:14:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013442 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 C9E66C28B28 for ; Wed, 12 Mar 2025 11:55:00 +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=0eZ1kdQtxW0K2LJ3LL36Ac+BNy y0NhUqXUdCLt+/KhadI2XQXAFIJub/O4TRTBXwB6xEfKqqYKetbNqNKAhLdXDwNSxDooK2qb7Hv/8 7D24MzingDVC0l/YWiKmonwXfGaZOROaHnL4Xb9ROySst2pYjCyuGV6V+siCyltBC0wIaopIAvnwI X9fNU3UBUbK3LZxM3afBiTf2SfNmF7f9KRl73e0Ptwrx4Tad9/hhFnBj+GyzMU7TrjL9wCQ5XM9uO rT2MtSBTTm54odlzueVtWj0kTlnAsmtuE7J6cv1J9J2lZLJQQgbzXvXOVba0FaEwbMSHLSTbfIbuw tj4/gjwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsKfh-00000008KH3-1KFL; Wed, 12 Mar 2025 11:54:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsK38-00000008E5z-44Qr for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:15:00 +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 696E31682; Wed, 12 Mar 2025 04:15:09 -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 177E03F694; Wed, 12 Mar 2025 04:14:57 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:14:33 +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-51a514282794@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> To: 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/ZANAwAIAQBBurwxfuKYAcsmYgBn0Wyvr6uyOPMtIYfBSRGvUA09ueeThVmrNeqKM 736CKQfx/eJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FsrwAKCRAAQbq8MX7i mBfUEADEm3dlUPsPOmlKnq41RIg6xX7lNVp2cLw+hZwaBOmDExX/zT/GOhFeHpRy90unFFMTFnD wyzaDrvbNlTKOBWRPA3sKHyVJY7QMA2TZlP6iaJORYHSUD0esXVYMrOilXeQZBqZ54tdmuOOcsI 8kv6XXosuzpH36DmdaGFyUQKvzpqJcPjN6j8f9CYiiekZL0MxyV3Hury/oRGHvPoUDKo9CI8AI+ 4vom6MmAup/b9m8IqmErJMETpg3h3QM2UOGS0bQw00D5xyDtYw0wR2MeWxqGNqgXfPY6DG32QbL 9SsHqsiVyfsfPwqk0f/RShKDeRCi/b4dsHy6OQXIoHgPkTT8edqUg/wlVqoZ8ICljzIfnSs2h+h vciJ4Xg7zsuGmF2wKKbs+F/KhTfO21/H0JKiVHgBKtZbblf7E/rxRvxfiWkGeEmBPCnGnLEiq0T jJoGQ192bfF0/lpuexh3hNQTPBLKJPHPKDFbJpMJfNZNIuEjnjZfjXQlSL9qZjlo2tD5570VZv3 FWLQT+MlBHRrsXbvAgU6Fg23oPq/guplGL2q1PHg9k5ewK0MSOJAMCIE3YsshOn24pOT3RxFrEO ZGP5oHwrBB1968lv6BRehEMyK9upB7WUeJ0yxEEiLvz+xIqYAHClbAybUu+wasRQ4Di+M6Fmt+B PJSjCX8QscSz9VQ== 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_041459_106325_A56BA943 X-CRM114-Status: GOOD ( 14.20 ) 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:14:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14013505 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 17575C28B28 for ; Wed, 12 Mar 2025 13:05:57 +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=QG02QevU6TiCSk89ArZ4sTKBgX +73VYqJ3nPf/RE9FJQF/6mUYlnbPIMZQOXDPWdHOdTjmEPN/nULpB5mMaDUHgUuYFys7+m4iCNOb4 6BHINLmfgEnvmT3Q18oqAp4IvJv6CSaVyd2VR5wRrLvtuF4SCy0lAHXyaohgHUi4WvMvdMwHxjSEP kxKWRhTbirtvicglS1a/WYiOBjjaDD/EIfgShCsXht6k3S0Qu5op9LKWxkjiwedfIE7hZFF9ajy28 6cXtcoCVXfFLEEGYHkDDXHQDVYgwihl33jmpQ517X7nWoVHucXwvi6fos4desmqmBZMUEGGP4mDk4 qW0pvg1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tsLmM-00000008Ukp-2bYn; Wed, 12 Mar 2025 13:05: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 1tsK39-00000008E6M-3XUU for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2025 11:15:01 +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 4CCD91516; Wed, 12 Mar 2025 04:15:10 -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 EF4903F694; Wed, 12 Mar 2025 04:14:58 -0700 (PDT) From: Sudeep Holla Date: Wed, 12 Mar 2025 11:14:34 +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-51a514282794@arm.com> References: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> In-Reply-To: <20250312-b4-scmi_minor_cleanup-v1-0-51a514282794@arm.com> To: 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/ZANAwAIAQBBurwxfuKYAcsmYgBn0WywkmNMuJyVsypRHtvfrfmPyNGZ4JyQx871N /4f3Pv+OJqJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ9FssAAKCRAAQbq8MX7i mL16D/9grXv2l3vMUtt7/b0gjFh8JtrgFpbcNvJoonjeuOQcMgdiIhbRLEDiTtVm9EUf3TBozl2 j7HXc7Y3daO01ERhEeNs3vrd0twnpi7qQH5TYLKfXpLiBdMZmadx9H47xsCmY1sSmjFBJtrPH2y FRBEM2yNKu48FNbgUH8jkuHXLYNxoC5ZU/q46imasmWrhIe20xF2hlB2IyL/AHRud+Lf7n5b1/D 7MzFOJ/d01FntSuLduDfx/+Bn7ZbpVWKvdZq4LgaRXan81ds+1O1qX8O7R0Kv6gN1Gc3Rt41CPF k95V3vsS+buQm/PDJm9StQ6iYw5P+cNufXJoxr1K47mOl9AUI2qFhVNy/w5l+8Vw57qE6fyVjhy s1NoC/K6rTX1/Wd0FNuHnfXE83TmPedmkS8Fx2/HKMq8bhgQx/0tazBjgxkasRCy7+jiQjJNvc0 YvP4VfbW1x0EHyQiDsP9TSsRZFYOHNedjk8R7e3/zkDV56XElN185lHpfEjCGYBJHDIe1LposOo iHF1e7d5EmaqFjDPF2O8KyA7NjhY5FkhdiCKp0GGqJU9BKqHiBUjleFh6hiasKj46+xyHnZXo7d jhkWeuQzZ6Tue6Hhsi4zEDf57ty7B3Jzk3RBzhYiu3ZeR3j6jwaXc3v0hH1UTCEY2Yx+YUN6MAn mYlrX2C2Y5CZIVA== 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_041459_975669_81A7FB5E X-CRM114-Status: GOOD ( 12.81 ) 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); }