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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'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@xxxxxxxxxx>
---
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 --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;
-- 
2.45.2




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux