2020-12-07 00:54:56

by Tian Tao

[permalink] [raw]
Subject: [PATCH drm/hisilicon 0/2] Code refactoring

patch #1 is used drmm_mode_config_init() to do code refactoring.
patch #2 is deleted unused variable ‘priv’ to avoid warning.

Tian Tao (2):
drm/hisilicon: Use managed mode-config init
drm/hisilicon: Delete unused local parameters

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)

--
2.7.4


2020-12-07 00:54:56

by Tian Tao

[permalink] [raw]
Subject: [PATCH drm/hisilicon 1/2] drm/hisilicon: Use managed mode-config init

Using drmm_mode_config_init() sets up managed release of modesetting
resources.
Signed-off-by: Tian Tao <[email protected]>
---
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 3687753..d631f82 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -96,7 +96,9 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv)
struct drm_device *dev = &priv->dev;
int ret;

- drm_mode_config_init(dev);
+ ret = drmm_mode_config_init(dev);
+ if (ret)
+ return ret;
priv->mode_config_initialized = true;

dev->mode_config.min_width = 0;
@@ -125,14 +127,6 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv)
return 0;
}

-static void hibmc_kms_fini(struct hibmc_drm_private *priv)
-{
- if (priv->mode_config_initialized) {
- drm_mode_config_cleanup(&priv->dev);
- priv->mode_config_initialized = false;
- }
-}
-
/*
* It can operate in one of three modes: 0, 1 or Sleep.
*/
@@ -262,7 +256,6 @@ static int hibmc_unload(struct drm_device *dev)
drm_atomic_helper_shutdown(dev);

pci_disable_msi(dev->pdev);
- hibmc_kms_fini(priv);
dev->dev_private = NULL;
return 0;
}
--
2.7.4

2020-12-07 00:57:15

by Tian Tao

[permalink] [raw]
Subject: [PATCH drm/hisilicon 2/2] drm/hisilicon: Delete unused local parameters

delete unused variable ‘priv’ to avoid warning.

Signed-off-by: Tian Tao <[email protected]>
---
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index d631f82..772f58e 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -251,12 +251,9 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)

static int hibmc_unload(struct drm_device *dev)
{
- struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
-
drm_atomic_helper_shutdown(dev);
-
pci_disable_msi(dev->pdev);
- dev->dev_private = NULL;
+
return 0;
}

--
2.7.4

2020-12-07 08:06:31

by Thomas Zimmermann

[permalink] [raw]
Subject: Re: [PATCH drm/hisilicon 1/2] drm/hisilicon: Use managed mode-config init

Hi

Am 07.12.20 um 01:49 schrieb Tian Tao:
> Using drmm_mode_config_init() sets up managed release of modesetting
> resources.
> Signed-off-by: Tian Tao <[email protected]>
> ---
> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> index 3687753..d631f82 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> @@ -96,7 +96,9 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv)
> struct drm_device *dev = &priv->dev;
> int ret;
>
> - drm_mode_config_init(dev);
> + ret = drmm_mode_config_init(dev);
> + if (ret)
> + return ret;
> priv->mode_config_initialized = true;

I think mode_config_initialized is only required by hibmc_kms_finit(),
which you remove. You should remove this line and the field from struct
hibmc_drm_private.

Best regards
Thomas

>
> dev->mode_config.min_width = 0;
> @@ -125,14 +127,6 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv)
> return 0;
> }
>
> -static void hibmc_kms_fini(struct hibmc_drm_private *priv)
> -{
> - if (priv->mode_config_initialized) {
> - drm_mode_config_cleanup(&priv->dev);
> - priv->mode_config_initialized = false;
> - }
> -}
> -
> /*
> * It can operate in one of three modes: 0, 1 or Sleep.
> */
> @@ -262,7 +256,6 @@ static int hibmc_unload(struct drm_device *dev)
> drm_atomic_helper_shutdown(dev);
>
> pci_disable_msi(dev->pdev);
> - hibmc_kms_fini(priv);
> dev->dev_private = NULL;
> return 0;
> }
>

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature

2020-12-07 08:08:10

by Thomas Zimmermann

[permalink] [raw]
Subject: Re: [PATCH drm/hisilicon 2/2] drm/hisilicon: Delete unused local parameters



Am 07.12.20 um 01:49 schrieb Tian Tao:
> delete unused variable ‘priv’ to avoid warning.
>
> Signed-off-by: Tian Tao <[email protected]>

Reviewed-by: Thomas Zimmermann <[email protected]>

> ---
> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> index d631f82..772f58e 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
> @@ -251,12 +251,9 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv)
>
> static int hibmc_unload(struct drm_device *dev)
> {
> - struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
> -
> drm_atomic_helper_shutdown(dev);
> -
> pci_disable_msi(dev->pdev);
> - dev->dev_private = NULL;
> +
> return 0;
> }
>
>

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature