All of lore.kernel.org
 help / color / mirror / Atom feed
From: Satendra Singh Thakur <satendra.t@samsung.com>
To: Gustavo Padovan <gustavo@padovan.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Sean Paul <seanpaul@chromium.org>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: vineet.j@samsung.com, hemanshu.s@samsung.com, sst2005@gmail.com,
	Satendra Singh Thakur <satendra.t@samsung.com>
Subject: [PATCH v1] drm/kms/atomic: Improving func drm_atomic_plane_check
Date: Fri, 27 Jul 2018 16:34:05 +0530	[thread overview]
Message-ID: <20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c~FNQK6sJPs2704827048epcas5p1Q@epcas5p1.samsung.com> (raw)
In-Reply-To: <0fe3bbc5-d10b-7c95-e77d-f4cd5ee6016b@linux.intel.com>

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@samsung.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


  parent reply	other threads:[~2018-07-27 11:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180727083812epcas5p39f97180e85def2b4b4c1b68af2e83b41@epcas5p3.samsung.com>
2018-07-27  8:38 ` [PATCH] drm/kms/atomic: Used existing func for checking fb geometry Satendra Singh Thakur
2018-07-27  9:51   ` Maarten Lankhorst
2018-07-27  9:51     ` Maarten Lankhorst
     [not found]     ` <CGME20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c@epcas5p1.samsung.com>
2018-07-27 11:04       ` Satendra Singh Thakur [this message]
     [not found]     ` <CGME20180727111112epcas5p35e49be90453d18c560207d6ab34661ec@epcas5p3.samsung.com>
2018-07-27 11:11       ` [PATCH v1] drm/kms/atomic: Using existing func for checking framebuffer dimensions Satendra Singh Thakur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20180727110534epcas5p1b5d48f9f92b7d6874bbe15c2f80dce1c~FNQK6sJPs2704827048epcas5p1Q@epcas5p1.samsung.com' \
    --to=satendra.t@samsung.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=hemanshu.s@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=seanpaul@chromium.org \
    --cc=sst2005@gmail.com \
    --cc=vineet.j@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.