2021-11-16 01:44:05

by 赵军奎

[permalink] [raw]
Subject: [PATCH] drm/amd/display: cleanup the code a bit

In function dc_sink_destruct, kfree will check pointer, no need
to check again.
This change is to cleanup the code a bit.

Signed-off-by: Bernard Zhao <[email protected]>
---
drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index a249a0e5edd0..4b5e4d8e7735 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -33,14 +33,6 @@
* Private functions
******************************************************************************/

-static void dc_sink_destruct(struct dc_sink *sink)
-{
- if (sink->dc_container_id) {
- kfree(sink->dc_container_id);
- sink->dc_container_id = NULL;
- }
-}
-
static bool dc_sink_construct(struct dc_sink *sink, const struct dc_sink_init_data *init_params)
{

@@ -75,7 +67,7 @@ void dc_sink_retain(struct dc_sink *sink)
static void dc_sink_free(struct kref *kref)
{
struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
- dc_sink_destruct(sink);
+ kfree(sink->dc_container_id);
kfree(sink);
}

--
2.33.1



2021-11-16 09:19:52

by Christian König

[permalink] [raw]
Subject: Re: [PATCH] drm/amd/display: cleanup the code a bit

Am 16.11.21 um 02:34 schrieb Bernard Zhao:
> In function dc_sink_destruct, kfree will check pointer, no need
> to check again.
> This change is to cleanup the code a bit.
>
> Signed-off-by: Bernard Zhao <[email protected]>

This one and the other patch are Acked-by: Christian König
<[email protected]>

> ---
> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> index a249a0e5edd0..4b5e4d8e7735 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> @@ -33,14 +33,6 @@
> * Private functions
> ******************************************************************************/
>
> -static void dc_sink_destruct(struct dc_sink *sink)
> -{
> - if (sink->dc_container_id) {
> - kfree(sink->dc_container_id);
> - sink->dc_container_id = NULL;
> - }
> -}
> -
> static bool dc_sink_construct(struct dc_sink *sink, const struct dc_sink_init_data *init_params)
> {
>
> @@ -75,7 +67,7 @@ void dc_sink_retain(struct dc_sink *sink)
> static void dc_sink_free(struct kref *kref)
> {
> struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
> - dc_sink_destruct(sink);
> + kfree(sink->dc_container_id);
> kfree(sink);
> }
>


2021-11-17 21:37:20

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] drm/amd/display: cleanup the code a bit

Applied. Thanks!

On Tue, Nov 16, 2021 at 4:19 AM Christian König
<[email protected]> wrote:
>
> Am 16.11.21 um 02:34 schrieb Bernard Zhao:
> > In function dc_sink_destruct, kfree will check pointer, no need
> > to check again.
> > This change is to cleanup the code a bit.
> >
> > Signed-off-by: Bernard Zhao <[email protected]>
>
> This one and the other patch are Acked-by: Christian König
> <[email protected]>
>
> > ---
> > drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 10 +---------
> > 1 file changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> > index a249a0e5edd0..4b5e4d8e7735 100644
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> > @@ -33,14 +33,6 @@
> > * Private functions
> > ******************************************************************************/
> >
> > -static void dc_sink_destruct(struct dc_sink *sink)
> > -{
> > - if (sink->dc_container_id) {
> > - kfree(sink->dc_container_id);
> > - sink->dc_container_id = NULL;
> > - }
> > -}
> > -
> > static bool dc_sink_construct(struct dc_sink *sink, const struct dc_sink_init_data *init_params)
> > {
> >
> > @@ -75,7 +67,7 @@ void dc_sink_retain(struct dc_sink *sink)
> > static void dc_sink_free(struct kref *kref)
> > {
> > struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
> > - dc_sink_destruct(sink);
> > + kfree(sink->dc_container_id);
> > kfree(sink);
> > }
> >
>