[RFC] firmware: arm_scmi: Optimize the iteration of scmi_requested_devices

Peng Fan (OSS) peng.fan at oss.nxp.com
Sun Jan 5 22:57:24 PST 2025


From: Peng Fan <peng.fan at nxp.com>

scmi_requested_devices is organized in IDR based link lists, so only
need to search the link lists when there is a match protocol_id.

Back to search the next id with 'continue' to save cpu cycles, if
protocol_id does not match.

Signed-off-by: Peng Fan <peng.fan at nxp.com>
---

RFC:
 Tested on i.MX95.

 drivers/firmware/arm_scmi/bus.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 157172a5f2b5..42deab5903fb 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -79,6 +79,8 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
 			if (rdev->id_table->protocol_id ==
 			    id_table->protocol_id)
 				phead = head;
+			else
+				continue;
 		}
 		list_for_each_entry(rdev, head, node) {
 			if (!strcmp(rdev->id_table->name, id_table->name)) {
@@ -89,6 +91,7 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
 				goto out;
 			}
 		}
+		break;
 	}
 
 	/*
-- 
2.37.1




More information about the linux-arm-kernel mailing list