diff mbox series

[2/5] drm/msm/dp: Use devres for ioremap()

Message ID 20210722024227.3313096-3-bjorn.andersson@linaro.org (mailing list archive)
State Superseded
Headers show
Series drm/msm/dp: Allow variation in register regions | expand

Commit Message

Bjorn Andersson July 22, 2021, 2:42 a.m. UTC
The non-devres version of ioremap is used, which requires manual
cleanup. But the code paths leading here is mixed with other devres
users, so rely on this for ioremap as well to simplify the code.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/gpu/drm/msm/dp/dp_parser.c | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

Comments

Stephen Boyd July 22, 2021, 8:06 p.m. UTC | #1
Quoting Bjorn Andersson (2021-07-21 19:42:24)
> The non-devres version of ioremap is used, which requires manual
> cleanup. But the code paths leading here is mixed with other devres
> users, so rely on this for ioremap as well to simplify the code.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

>  drivers/gpu/drm/msm/dp/dp_parser.c | 29 ++++-------------------------
>  1 file changed, 4 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c
> index 0519dd3ac3c3..c064ced78278 100644
> --- a/drivers/gpu/drm/msm/dp/dp_parser.c
> +++ b/drivers/gpu/drm/msm/dp/dp_parser.c
> @@ -32,7 +32,7 @@ static int msm_dss_ioremap(struct platform_device *pdev,
>         }
>
>         io_data->len = (u32)resource_size(res);
> -       io_data->base = ioremap(res->start, io_data->len);
> +       io_data->base = devm_ioremap(&pdev->dev, res->start, io_data->len);
>         if (!io_data->base) {
>                 DRM_ERROR("%pS->%s: ioremap failed\n",
>                         __builtin_return_address(0), __func__);

I don't think we need this print either, but that can come later in
addition to using devm_platform_get_and_ioremap_resource().
Abhinav Kumar July 23, 2021, 8:11 p.m. UTC | #2
On 2021-07-21 19:42, Bjorn Andersson wrote:
> The non-devres version of ioremap is used, which requires manual
> cleanup. But the code paths leading here is mixed with other devres
> users, so rely on this for ioremap as well to simplify the code.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/dp/dp_parser.c | 29 ++++-------------------------
>  1 file changed, 4 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c
> b/drivers/gpu/drm/msm/dp/dp_parser.c
> index 0519dd3ac3c3..c064ced78278 100644
> --- a/drivers/gpu/drm/msm/dp/dp_parser.c
> +++ b/drivers/gpu/drm/msm/dp/dp_parser.c
> @@ -32,7 +32,7 @@ static int msm_dss_ioremap(struct platform_device 
> *pdev,
>  	}
> 
>  	io_data->len = (u32)resource_size(res);
> -	io_data->base = ioremap(res->start, io_data->len);
> +	io_data->base = devm_ioremap(&pdev->dev, res->start, io_data->len);
>  	if (!io_data->base) {
>  		DRM_ERROR("%pS->%s: ioremap failed\n",
>  			__builtin_return_address(0), __func__);
> @@ -42,22 +42,6 @@ static int msm_dss_ioremap(struct platform_device 
> *pdev,
>  	return 0;
>  }
> 
> -static void msm_dss_iounmap(struct dss_io_data *io_data)
> -{
> -	if (io_data->base) {
> -		iounmap(io_data->base);
> -		io_data->base = NULL;
> -	}
> -	io_data->len = 0;
> -}
> -
> -static void dp_parser_unmap_io_resources(struct dp_parser *parser)
> -{
> -	struct dp_io *io = &parser->io;
> -
> -	msm_dss_iounmap(&io->dp_controller);
> -}
> -
>  static int dp_parser_ctrl_res(struct dp_parser *parser)
>  {
>  	int rc = 0;
> @@ -67,19 +51,14 @@ static int dp_parser_ctrl_res(struct dp_parser 
> *parser)
>  	rc = msm_dss_ioremap(pdev, &io->dp_controller);
>  	if (rc) {
>  		DRM_ERROR("unable to remap dp io resources, rc=%d\n", rc);
> -		goto err;
> +		return rc;
>  	}
> 
>  	io->phy = devm_phy_get(&pdev->dev, "dp");
> -	if (IS_ERR(io->phy)) {
> -		rc = PTR_ERR(io->phy);
> -		goto err;
> -	}
> +	if (IS_ERR(io->phy))
> +		return PTR_ERR(io->phy);
> 
>  	return 0;
> -err:
> -	dp_parser_unmap_io_resources(parser);
> -	return rc;
>  }
> 
>  static int dp_parser_misc(struct dp_parser *parser)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c
index 0519dd3ac3c3..c064ced78278 100644
--- a/drivers/gpu/drm/msm/dp/dp_parser.c
+++ b/drivers/gpu/drm/msm/dp/dp_parser.c
@@ -32,7 +32,7 @@  static int msm_dss_ioremap(struct platform_device *pdev,
 	}
 
 	io_data->len = (u32)resource_size(res);
-	io_data->base = ioremap(res->start, io_data->len);
+	io_data->base = devm_ioremap(&pdev->dev, res->start, io_data->len);
 	if (!io_data->base) {
 		DRM_ERROR("%pS->%s: ioremap failed\n",
 			__builtin_return_address(0), __func__);
@@ -42,22 +42,6 @@  static int msm_dss_ioremap(struct platform_device *pdev,
 	return 0;
 }
 
-static void msm_dss_iounmap(struct dss_io_data *io_data)
-{
-	if (io_data->base) {
-		iounmap(io_data->base);
-		io_data->base = NULL;
-	}
-	io_data->len = 0;
-}
-
-static void dp_parser_unmap_io_resources(struct dp_parser *parser)
-{
-	struct dp_io *io = &parser->io;
-
-	msm_dss_iounmap(&io->dp_controller);
-}
-
 static int dp_parser_ctrl_res(struct dp_parser *parser)
 {
 	int rc = 0;
@@ -67,19 +51,14 @@  static int dp_parser_ctrl_res(struct dp_parser *parser)
 	rc = msm_dss_ioremap(pdev, &io->dp_controller);
 	if (rc) {
 		DRM_ERROR("unable to remap dp io resources, rc=%d\n", rc);
-		goto err;
+		return rc;
 	}
 
 	io->phy = devm_phy_get(&pdev->dev, "dp");
-	if (IS_ERR(io->phy)) {
-		rc = PTR_ERR(io->phy);
-		goto err;
-	}
+	if (IS_ERR(io->phy))
+		return PTR_ERR(io->phy);
 
 	return 0;
-err:
-	dp_parser_unmap_io_resources(parser);
-	return rc;
 }
 
 static int dp_parser_misc(struct dp_parser *parser)