Skip to contentSkip to conversation

drm/nouveau/disp: add a comment on confusing loop

PATCH In review Dan Carpenter 2 participants 2 messages Nov 13, 2013 – Nov 20, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau/disp: add a comment on confusing loop

The "ret = -EIO" is deliberate. It's a very uncommon thing to do and it upsets static checkers because they normally would expect "ret == -EIO".

drivers/gpu/drm/nouveau/core/engine/disp/dport.c +1 -0
index 1bd4c63..2bc45ae 100644
@@ -322,6 +322,7 @@ nouveau_dp_train(struct nouveau_disp *disp, const struct nouveau_dp_func *func,
 	while (*link_bw > (dp->dpcd[1] * 27000))
 		link_bw++;
 
+	/* set ret to -EIO on the last loop iteration */
 	while ((ret = -EIO) && link_bw[0]) {
 		/* find minimum required lane count at this link rate */
 		dp->link_nr = dp->dpcd[2] & DPCD_RC02_MAX_LANE_COUNT;
#1 lore raw

Am 13.11.2013 08:45, schrieb Dan Carpenter:

Quoted 10 lines

The "ret = -EIO" is deliberate. It's a very uncommon thing to do and it upsets static checkers because they normally would expect "ret == -EIO".

drivers/gpu/drm/nouveau/core/engine/disp/dport.c +0 -0
index 1bd4c63..2bc45ae 100644

drivers/gpu/drm/nouveau/core/engine/disp/dport.c nouveau_dp_train(struct nouveau_disp *disp, const struct nouveau_dp_func *func, · line 328

Quoted 7 lines
drivers/gpu/drm/nouveau/core/engine/disp/dport.c +1 -0
@@ -322,6 +322,7 @@ nouveau_dp_train(struct nouveau_disp *disp, const struct nouveau_dp_func *func,
 	while (*link_bw > (dp->dpcd[1] * 27000))
 		link_bw++;
 
+	/* set ret to -EIO on the last loop iteration */
 	while ((ret = -EIO) && link_bw[0]) {
 		/* find minimum required lane count at this link rate */
 		dp->link_nr = dp->dpcd[2] & DPCD_RC02_MAX_LANE_COUNT;

It is sensible to do so now,
but in the long runs it pays to rewrite that as it confuses not only static checkers but also the brains of people trying to understand the code.

just my 2 cents,
re,
wh