drm/simpledrm: Drop superfluous primary plane .atomic_check return logic
Subsystems (2)
PATCH 1/1 drm/simpledrm: Drop superfluous primary plane .atomic_check return logic
The simpledrm_primary_plane_helper_atomic_check() function is more complex than needed. It first checks drm_atomic_helper_check_plane_state() returns value to decide whether to return this or zero.
But it could just return that function return value directly. It also does a check if new_plane_state->visible isn't set, but returns zero regardless.
---
drivers/gpu/drm/tiny/simpledrm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/tiny/simpledrm.c +4 -11
@@ -485,21 +485,14 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane,struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane);struct drm_crtc *new_crtc = new_plane_state->crtc;struct drm_crtc_state *new_crtc_state =NULL ; -int ret;if (new_crtc) new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false); } static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane,
Signature · 1 line
2.37.1
Thomas Zimmermann
maintainerHi Javier
Am 31.08.22 um 13:12 schrieb Javier Martinez Canillas:
Quoted 30 lines
The
simpledrm_primary_plane_helper_atomic_check()function is more complex than needed. It first checksdrm_atomic_helper_check_plane_state()returns value to decide whether to return this or zero.But it could just return that function return value directly. It also does a check if
new_plane_state->visibleisn't set, but returns zero regardless.Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/tiny/simpledrm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/gpu/drm/tiny/simpledrm.c +0
-5@@ -485,21 +485,14 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane,struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane);struct drm_crtc *new_crtc = new_plane_state->crtc;struct drm_crtc_state *new_crtc_state =NULL ; -int ret;if (new_crtc) new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false);
drivers/gpu/drm/tiny/simpledrm.c static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, · line 495
Quoted 10 lines
drivers/gpu/drm/tiny/simpledrm.c +4
-6-if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ; +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false);
I'm undecided on this change. I know it's correct and more to the point. But the call's logic is non-intuitive: the call either returns an error or we have to test ->visible afterwards. So I wrote it explicitly.
I saw that your change to ssd130x also uses the pattern. If we find more such drivers, we could implement the atomic check as a helper. I suggest drm_plane_helper_atomic_check_fixed() in drm_plane_helper.c
Best regards
Thomas
Quoted 3 lines
drivers/gpu/drm/tiny/simpledrm.c +0
-0} static void simpledrm_primary_plane_helper_atomic_update(struct drm_plane *plane,
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Hello Thomas,
Quoted 39 lines · Thomas Zimmermann
Hi Javier
Am 31.08.22 um 13:12 schrieb Javier Martinez Canillas:
Quoted 36 lines
The
simpledrm_primary_plane_helper_atomic_check()function is more complex than needed. It first checksdrm_atomic_helper_check_plane_state()returns value to decide whether to return this or zero.But it could just return that function return value directly. It also does a check if
new_plane_state->visibleisn't set, but returns zero regardless.Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/tiny/simpledrm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/gpu/drm/tiny/simpledrm.c +0
-11@@ -485,21 +485,14 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane,struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane);struct drm_crtc *new_crtc = new_plane_state->crtc;struct drm_crtc_state *new_crtc_state =NULL ; -int ret;if (new_crtc) new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ;
Quoted 9 lines
drivers/gpu/drm/tiny/simpledrm.c static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, · line 495
Quoted 4 lines
drivers/gpu/drm/tiny/simpledrm.c +4
-0+return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false);I'm undecided on this change. I know it's correct and more to the point. But the call's logic is non-intuitive: the call either returns an error or we have to test ->visible afterwards. So I wrote it explicitly.
Yes, but the check has no effect so I found it even less intuitive. Maybe add a comment then if you wan to keep the current code?
Quoted 4 lines
I saw that your change to ssd130x also uses the pattern. If we find more such drivers, we could implement the atomic check as a helper. I suggest
drm_plane_helper_atomic_check_fixed()indrm_plane_helper.c
Sure. I can add a preparatory change in v2 that adds that helper and then use it in the follow-up patch.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat
Thomas Zimmermann
maintainerHi
Am 05.09.22 um 13:06 schrieb Javier Martinez Canillas:
Quoted 55 lines
Hello Thomas,
Quoted 39 lines · Thomas Zimmermann
Hi Javier
Am 31.08.22 um 13:12 schrieb Javier Martinez Canillas:
Quoted 36 lines
The
simpledrm_primary_plane_helper_atomic_check()function is more complex than needed. It first checksdrm_atomic_helper_check_plane_state()returns value to decide whether to return this or zero.But it could just return that function return value directly. It also does a check if
new_plane_state->visibleisn't set, but returns zero regardless.Signed-off-by Javier Martinez Canillas <[email protected]>---
drivers/gpu/drm/tiny/simpledrm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/gpu/drm/tiny/simpledrm.c +0
-11@@ -485,21 +485,14 @@ static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane,struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (new_state, plane);struct drm_crtc *new_crtc = new_plane_state->crtc;struct drm_crtc_state *new_crtc_state =NULL ; -int ret;if (new_crtc) new_crtc_state =drm_atomic_get_new_crtc_state (new_state, new_crtc); - ret =drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, -DRM_PLANE_NO_SCALING , -DRM_PLANE_NO_SCALING , - false, false); -if (ret) -return ret; -else if (!new_plane_state->visible) -return 0 ; - -return 0 ;Quoted 9 lines
drivers/gpu/drm/tiny/simpledrm.c static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, · line 495
Quoted 4 lines
drivers/gpu/drm/tiny/simpledrm.c +4
-0+return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false);I'm undecided on this change. I know it's correct and more to the point. But the call's logic is non-intuitive: the call either returns an error or we have to test ->visible afterwards. So I wrote it explicitly.
Yes, but the check has no effect so I found it even less intuitive. Maybe add a comment then if you wan to keep the current code?
Quoted 8 lines
Quoted 4 lines
I saw that your change to ssd130x also uses the pattern. If we find more such drivers, we could implement the atomic check as a helper. I suggest
drm_plane_helper_atomic_check_fixed()indrm_plane_helper.cSure. I can add a preparatory change in v2 that adds that helper and then use it in the follow-up patch.
Maybe wait for your ssd130x changes to land and then you can convert both drivers to the new helper.
Best regards
Thomas
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Ivo Totev
Quoted 2 lines · Thomas Zimmermann
Hi
[...]
Quoted 19 lines
Quoted 19 lines
Quoted 10 lines
drivers/gpu/drm/tiny/simpledrm.c static int simpledrm_primary_plane_helper_atomic_check(struct drm_plane *plane, · line 495
Quoted 5 lines
drivers/gpu/drm/tiny/simpledrm.c +4
-1-return 0 ; +return drm_atomic_helper_check_plane_state (new_plane_state, new_crtc_state, +DRM_PLANE_NO_SCALING , +DRM_PLANE_NO_SCALING , + false, false);I'm undecided on this change. I know it's correct and more to the point. But the call's logic is non-intuitive: the call either returns an error or we have to test ->visible afterwards. So I wrote it explicitly.
Yes, but the check has no effect so I found it even less intuitive. Maybe add a comment then if you wan to keep the current code?
Quoted 4 lines
I saw that your change to ssd130x also uses the pattern. If we find more such drivers, we could implement the atomic check as a helper. I suggest
drm_plane_helper_atomic_check_fixed()indrm_plane_helper.c
Quoted 7 lines
Quoted 3 lines
Sure. I can add a preparatory change in v2 that adds that helper and then use it in the follow-up patch.
Maybe wait for your ssd130x changes to land and then you can convert both drivers to the new helper.
Makes sense. I'll do that.
Signature · 5 lines
Best regards, Javier Martinez Canillas Core Platforms Red Hat