diff mbox series

[15/17] drm/vc4: Convert to using __drm_atomic_helper_crtc_reset() for reset.

Message ID 20190301125627.7285-16-maarten.lankhorst@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm: Start subclassing crtc_state. | expand

Commit Message

Maarten Lankhorst March 1, 2019, 12:56 p.m. UTC
Convert vc4 to using __drm_atomic_helper_crtc_reset(), instead of
writing its own version. Instead of open coding destroy_state(),
call it directly for freeing the old state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Eric Anholt March 1, 2019, 10:47 p.m. UTC | #1
Maarten Lankhorst <maarten.lankhorst@linux.intel.com> writes:

> Convert vc4 to using __drm_atomic_helper_crtc_reset(), instead of
> writing its own version. Instead of open coding destroy_state(),
> call it directly for freeing the old state.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Eric Anholt <eric@anholt.net>
> ---
>  drivers/gpu/drm/vc4/vc4_crtc.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index e7c04a9eb219..fdf21594b050 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -1041,12 +1041,13 @@ static void vc4_crtc_destroy_state(struct drm_crtc *crtc,
>  static void
>  vc4_crtc_reset(struct drm_crtc *crtc)
>  {
> -	if (crtc->state)
> -		vc4_crtc_destroy_state(crtc->state);
> +	struct vc4_crtc_state *crtc_state =
> +		kzalloc(sizeof(*crtc_state), GFP_KERNEL);
>  
> -	crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL);
>  	if (crtc->state)
> -		crtc->state->crtc = crtc;
> +		vc4_crtc_destroy_state(crtc, crtc->state);
> +
> +	__drm_atomic_helper_crtc_reset(crtc, &crtc_state->base);

Wouldn't it be much easier if __drm_atomic_helper_crtc_reset took in a
new state and destroyed the old state for you?  It seems like hardly a
helper as is.
Maarten Lankhorst March 4, 2019, 1:51 p.m. UTC | #2
Op 01-03-2019 om 23:47 schreef Eric Anholt:
> Maarten Lankhorst <maarten.lankhorst@linux.intel.com> writes:
>
>> Convert vc4 to using __drm_atomic_helper_crtc_reset(), instead of
>> writing its own version. Instead of open coding destroy_state(),
>> call it directly for freeing the old state.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Eric Anholt <eric@anholt.net>
>> ---
>>  drivers/gpu/drm/vc4/vc4_crtc.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
>> index e7c04a9eb219..fdf21594b050 100644
>> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
>> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
>> @@ -1041,12 +1041,13 @@ static void vc4_crtc_destroy_state(struct drm_crtc *crtc,
>>  static void
>>  vc4_crtc_reset(struct drm_crtc *crtc)
>>  {
>> -	if (crtc->state)
>> -		vc4_crtc_destroy_state(crtc->state);
>> +	struct vc4_crtc_state *crtc_state =
>> +		kzalloc(sizeof(*crtc_state), GFP_KERNEL);
>>  
>> -	crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL);
>>  	if (crtc->state)
>> -		crtc->state->crtc = crtc;
>> +		vc4_crtc_destroy_state(crtc, crtc->state);
>> +
>> +	__drm_atomic_helper_crtc_reset(crtc, &crtc_state->base);
> Wouldn't it be much easier if __drm_atomic_helper_crtc_reset took in a
> new state and destroyed the old state for you?  It seems like hardly a
> helper as is.

Yes it would, but the plane/connector reset is the same. If you want to convert them all it would be nice. :)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index e7c04a9eb219..fdf21594b050 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -1041,12 +1041,13 @@  static void vc4_crtc_destroy_state(struct drm_crtc *crtc,
 static void
 vc4_crtc_reset(struct drm_crtc *crtc)
 {
-	if (crtc->state)
-		vc4_crtc_destroy_state(crtc->state);
+	struct vc4_crtc_state *crtc_state =
+		kzalloc(sizeof(*crtc_state), GFP_KERNEL);
 
-	crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL);
 	if (crtc->state)
-		crtc->state->crtc = crtc;
+		vc4_crtc_destroy_state(crtc, crtc->state);
+
+	__drm_atomic_helper_crtc_reset(crtc, &crtc_state->base);
 }
 
 static const struct drm_crtc_funcs vc4_crtc_funcs = {