diff mbox

[41/58] drm/i915: convert pointless error checks in set_config to BUGs

Message ID 1345403595-9678-42-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State Accepted
Headers show

Commit Message

Daniel Vetter Aug. 19, 2012, 7:12 p.m. UTC
Because they all are, the ioctl command never calls us with any of
these violated. Also drop a equally pointless empty debug message (and
also in set_cursor, while we're at it).

With all these changes, intel_crtc_set_config is neatly condensed down
to it's essence, the actual modeset code (or fb update calling code)

v2: The fb helper code is actually stretching ->set_config semantics a bit,
it calls it with set->mode == NULL but set->fb != NULL.

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_display.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Jesse Barnes Sept. 5, 2012, 4:50 p.m. UTC | #1
On Sun, 19 Aug 2012 21:12:58 +0200
Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

> Because they all are, the ioctl command never calls us with any of
> these violated. Also drop a equally pointless empty debug message (and
> also in set_cursor, while we're at it).
> 
> With all these changes, intel_crtc_set_config is neatly condensed down
> to it's essence, the actual modeset code (or fb update calling code)
> 
> v2: The fb helper code is actually stretching ->set_config semantics a bit,
> it calls it with set->mode == NULL but set->fb != NULL.
> 
> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 125443a..56827d6 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -5462,8 +5462,6 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
>  	uint32_t addr;
>  	int ret;
>  
> -	DRM_DEBUG_KMS("\n");
> -
>  	/* if we want to turn off the cursor ignore width and height */
>  	if (!handle) {
>  		DRM_DEBUG_KMS("cursor off\n");
> @@ -6919,16 +6917,9 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
>  	int ret;
>  	int i;
>  
> -	DRM_DEBUG_KMS("\n");
> -
> -	if (!set)
> -		return -EINVAL;
> -
> -	if (!set->crtc)
> -		return -EINVAL;
> -
> -	if (!set->crtc->helper_private)
> -		return -EINVAL;
> +	BUG_ON(!set);
> +	BUG_ON(!set->crtc);
> +	BUG_ON(!set->crtc->helper_private);
>  
>  	if (!set->mode)
>  		set->fb = NULL;

The BUG_ONs are probably superfluous too, but this is an improvement.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Daniel Vetter Sept. 5, 2012, 7:19 p.m. UTC | #2
On Wed, Sep 5, 2012 at 6:50 PM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
>> @@ -6919,16 +6917,9 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
>>       int ret;
>>       int i;
>>
>> -     DRM_DEBUG_KMS("\n");
>> -
>> -     if (!set)
>> -             return -EINVAL;
>> -
>> -     if (!set->crtc)
>> -             return -EINVAL;
>> -
>> -     if (!set->crtc->helper_private)
>> -             return -EINVAL;
>> +     BUG_ON(!set);
>> +     BUG_ON(!set->crtc);
>> +     BUG_ON(!set->crtc->helper_private);
>>
>>       if (!set->mode)
>>               set->fb = NULL;
>
> The BUG_ONs are probably superfluous too, but this is an improvement.

Actually I want to add even more ;-) One of the follow-up cleanups I'd
like to do is fix all the crazy assumptions in the fb helper (I guess
we'll keep on using that one). And to make sure that no-one violates
these accidentally, I'd like to check them in our code with BUG_ONs
(so that people don't accidentally break i915.ko when they frob the fb
helper or other parts of shared code we still use).

So the BUG_ONs are just interface documentation and enforcement.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 125443a..56827d6 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5462,8 +5462,6 @@  static int intel_crtc_cursor_set(struct drm_crtc *crtc,
 	uint32_t addr;
 	int ret;
 
-	DRM_DEBUG_KMS("\n");
-
 	/* if we want to turn off the cursor ignore width and height */
 	if (!handle) {
 		DRM_DEBUG_KMS("cursor off\n");
@@ -6919,16 +6917,9 @@  static int intel_crtc_set_config(struct drm_mode_set *set)
 	int ret;
 	int i;
 
-	DRM_DEBUG_KMS("\n");
-
-	if (!set)
-		return -EINVAL;
-
-	if (!set->crtc)
-		return -EINVAL;
-
-	if (!set->crtc->helper_private)
-		return -EINVAL;
+	BUG_ON(!set);
+	BUG_ON(!set->crtc);
+	BUG_ON(!set->crtc->helper_private);
 
 	if (!set->mode)
 		set->fb = NULL;