diff mbox series

[2/2] drm/dp_mst: Slightly optimize drm_dp_mst_i2c_write() (2/2)

Message ID 123bc9f79f60de14aad6f46e1c2268cf6f1c27a5.1722945487.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/dp_mst: Slightly optimize drm_dp_mst_i2c_write() (1/2) | expand

Commit Message

Christophe JAILLET Aug. 6, 2024, 11:59 a.m. UTC
'msg' is only used with drm_dp_encode_sideband_req() which takes a
"const struct drm_dp_sideband_msg_req_body *".

So some initializations can be done only once outside of the for loop.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
In case of interest, on x86_64, with allmodconfig, sizeof(*msg) is 420
bytes.
---
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
index 7bf6157eb3a3..a149ff3f70ad 100644
--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
@@ -5891,10 +5891,16 @@  static int drm_dp_mst_i2c_write(struct drm_dp_mst_branch *mstb,
 		ret = -ENOMEM;
 		goto out;
 	}
+
+	/*
+	 * 'msg' is not modified by drm_dp_encode_sideband_req(). So
+	 * some initializations can be done only once.
+	 */
+	memset(&msg, 0, sizeof(msg));
+	msg.req_type = DP_REMOTE_I2C_WRITE;
+	msg.u.i2c_write.port_number = port->port_num;
+
 	for (i = 0; i < num; i++) {
-		memset(&msg, 0, sizeof(msg));
-		msg.req_type = DP_REMOTE_I2C_WRITE;
-		msg.u.i2c_write.port_number = port->port_num;
 		msg.u.i2c_write.write_i2c_device_id = msgs[i].addr;
 		msg.u.i2c_write.num_bytes = msgs[i].len;
 		msg.u.i2c_write.bytes = msgs[i].buf;