diff mbox series

[v2,10/11] drm/msm: Convert to drm_of_get_data_lanes_count

Message ID 20220524010522.528569-10-marex@denx.de (mailing list archive)
State New, archived
Headers show
Series [v2,01/11] drm: of: Add drm_of_get_data_lanes_count and drm_of_get_data_lanes_ep | expand

Commit Message

Marek Vasut May 24, 2022, 1:05 a.m. UTC
Convert driver to use this new helper to standardize
OF "data-lanes" parsing.

Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Robert Foss <robert.foss@linaro.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sean Paul <sean@poorly.run>
To: dri-devel@lists.freedesktop.org
---
V2: - Use drm/msm prefix
    - Rename drm_of_get_data_lanes{,_ep} to drm_of_get_data_lanes_count{,_ep}
    - Add RB from Andrzej and Dmitry
---
 drivers/gpu/drm/msm/dp/dp_parser.c | 6 ++----
 drivers/gpu/drm/msm/dsi/dsi_host.c | 7 +++----
 2 files changed, 5 insertions(+), 8 deletions(-)

Comments

Abhinav Kumar May 24, 2022, 1:07 a.m. UTC | #1
On 5/23/2022 6:05 PM, Marek Vasut wrote:
> Convert driver to use this new helper to standardize
> OF "data-lanes" parsing.
> 
> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Marek Vasut <marex@denx.de>

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>

> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Cc: Andrzej Hajda <andrzej.hajda@intel.com>
> Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Robert Foss <robert.foss@linaro.org>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Sean Paul <sean@poorly.run>
> To: dri-devel@lists.freedesktop.org
> ---
> V2: - Use drm/msm prefix
>      - Rename drm_of_get_data_lanes{,_ep} to drm_of_get_data_lanes_count{,_ep}
>      - Add RB from Andrzej and Dmitry
> ---
>   drivers/gpu/drm/msm/dp/dp_parser.c | 6 ++----
>   drivers/gpu/drm/msm/dsi/dsi_host.c | 7 +++----
>   2 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c
> index 8f9fed9fdafc4..346556c5706d7 100644
> --- a/drivers/gpu/drm/msm/dp/dp_parser.c
> +++ b/drivers/gpu/drm/msm/dp/dp_parser.c
> @@ -102,11 +102,9 @@ static int dp_parser_ctrl_res(struct dp_parser *parser)
>   static int dp_parser_misc(struct dp_parser *parser)
>   {
>   	struct device_node *of_node = parser->pdev->dev.of_node;
> -	int len = 0;
> -	const char *data_lane_property = "data-lanes";
> +	int len;
>   
> -	len = of_property_count_elems_of_size(of_node,
> -			 data_lane_property, sizeof(u32));
> +	len = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES);
>   	if (len < 0) {
>   		DRM_WARN("Invalid property %s, default max DP lanes = %d\n",
>   				data_lane_property, DP_MAX_NUM_DP_LANES);
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index a95d5df52653c..90f9d3daa9a6d 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1779,11 +1779,10 @@ static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host,
>   		return 0;
>   	}
>   
> -	num_lanes = len / sizeof(u32);
> -
> -	if (num_lanes < 1 || num_lanes > 4) {
> +	num_lanes = drm_of_get_data_lanes_count(ep, 1, 4);
> +	if (num_lanes < 0) {
>   		DRM_DEV_ERROR(dev, "bad number of data lanes\n");
> -		return -EINVAL;
> +		return num_lanes;
>   	}
>   
>   	msm_host->num_data_lanes = num_lanes;
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 8f9fed9fdafc4..346556c5706d7 100644
--- a/drivers/gpu/drm/msm/dp/dp_parser.c
+++ b/drivers/gpu/drm/msm/dp/dp_parser.c
@@ -102,11 +102,9 @@  static int dp_parser_ctrl_res(struct dp_parser *parser)
 static int dp_parser_misc(struct dp_parser *parser)
 {
 	struct device_node *of_node = parser->pdev->dev.of_node;
-	int len = 0;
-	const char *data_lane_property = "data-lanes";
+	int len;
 
-	len = of_property_count_elems_of_size(of_node,
-			 data_lane_property, sizeof(u32));
+	len = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES);
 	if (len < 0) {
 		DRM_WARN("Invalid property %s, default max DP lanes = %d\n",
 				data_lane_property, DP_MAX_NUM_DP_LANES);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index a95d5df52653c..90f9d3daa9a6d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1779,11 +1779,10 @@  static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host,
 		return 0;
 	}
 
-	num_lanes = len / sizeof(u32);
-
-	if (num_lanes < 1 || num_lanes > 4) {
+	num_lanes = drm_of_get_data_lanes_count(ep, 1, 4);
+	if (num_lanes < 0) {
 		DRM_DEV_ERROR(dev, "bad number of data lanes\n");
-		return -EINVAL;
+		return num_lanes;
 	}
 
 	msm_host->num_data_lanes = num_lanes;