[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c~FNQK6sJPs2704827048epcas5p1Q@epcas5p1.samsung.com>
Date: Fri, 27 Jul 2018 16:34:05 +0530
From: Satendra Singh Thakur <satendra.t@...sung.com>
To: Gustavo Padovan <gustavo@...ovan.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Sean Paul <seanpaul@...omium.org>,
David Airlie <airlied@...ux.ie>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Cc: vineet.j@...sung.com, hemanshu.s@...sung.com, sst2005@...il.com,
Satendra Singh Thakur <satendra.t@...sung.com>
Subject: [PATCH v1] drm/kms/atomic: Improving func drm_atomic_plane_check
Currently, in the func drm_atomic_plane_check;
there are 3 if statements in the beginning with total 5 conditions.
these conditions are
crtc is NULL but fb is non-NULL
if (state->crtc && !state->fb)
crtc is non-NULL but fb is NULL
if (state->fb && !state->crtc)
crtc is NULL (and fb is also NULL)
if (!state->crtc)
The same code can be re-written using 2 if statements and 4 conditions.
first we check whether crtc and fb both are NULL
if (!state->crtc && !state->fb)
then we check either crtc or fb is NULL
if (!state->crtc || !state->fb)
Signed-off-by: Satendra Singh Thakur <satendra.t@...sung.com>
---
v1: Hi Mr Maarten, Thanks for the comments.
I have splitted them into two patches.
drivers/gpu/drm/drm_atomic.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 895741e..0415bbf 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -912,18 +912,15 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
unsigned int fb_width, fb_height;
int ret;
- /* either *both* CRTC and FB must be set, or neither */
- if (state->crtc && !state->fb) {
- DRM_DEBUG_ATOMIC("CRTC set but no FB\n");
- return -EINVAL;
- } else if (state->fb && !state->crtc) {
- DRM_DEBUG_ATOMIC("FB set but no CRTC\n");
- return -EINVAL;
- }
-
/* if disabled, we don't care about the rest of the state: */
- if (!state->crtc)
+ if (!state->crtc && !state->fb)
return 0;
+ /* both CRTC and FB must be set*/
+ if (!state->crtc || !state->fb) {
+ DRM_DEBUG_ATOMIC("Either invalid CRTC [%p] or invalid FB [%p]\n",
+ state->crtc, state->fb);
+ return -EINVAL;
+ }
/* Check whether this plane is usable on this CRTC */
if (!(plane->possible_crtcs & drm_crtc_mask(state->crtc))) {
--
2.7.4
Powered by blists - more mailing lists