Re: [PATCH v7 10/15] drm/rockchip: analogix_dp: Add support to get panel from the DP AUX bus
From: Doug Anderson
Date: Mon Feb 24 2025 - 20:48:30 EST
Hi,
On Mon, Feb 24, 2025 at 12:14 AM Damon Ding <damon.ding@xxxxxxxxxxxxxx> wrote:
>
> @@ -392,11 +393,27 @@ static const struct component_ops rockchip_dp_component_ops = {
> .unbind = rockchip_dp_unbind,
> };
>
> +static int rockchip_dp_link_panel(struct drm_dp_aux *aux)
> +{
> + struct analogix_dp_plat_data *plat_data = analogix_dp_aux_to_plat_data(aux);
> + struct rockchip_dp_device *dp = pdata_encoder_to_dp(plat_data);
> + int ret;
> +
> + ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 1, 0, &plat_data->panel, NULL);
> + if (ret && ret != -ENODEV)
> + return ret;
Can you explain why you treat -ENODEV as a non-error case here? Maybe
this is for the non-eDP case (AKA the DP case) where there's no
further panels or bridges? Maybe a comment would be helpful to remind
us?
> + ret = component_add(dp->dev, &rockchip_dp_component_ops);
> + if (ret)
> + return ret;
> +
> + return ret;
nit: the above could just be:
return component_add(dp->dev, &rockchip_dp_component_ops);
> @@ -448,9 +460,16 @@ static int rockchip_dp_probe(struct platform_device *pdev)
> if (IS_ERR(dp->adp))
> return PTR_ERR(dp->adp);
>
> - ret = component_add(dev, &rockchip_dp_component_ops);
> - if (ret)
> - return ret;
> + ret = devm_of_dp_aux_populate_bus(analogix_dp_get_aux(dp->adp), rockchip_dp_link_panel);
> + if (ret) {
> + if (ret != -ENODEV)
> + return dev_err_probe(dp->dev, ret,
> + "failed to populate aux bus : %d\n", ret);
IIRC this -ENODEV case is for old legacy panels that aren't listed
under the aux bus in the device tree. Maybe a comment would be helpful
to remind us?
nit: don't need the %d in your error message. dev_err_probe() already
prints the error code.
> + ret = rockchip_dp_link_panel(analogix_dp_get_aux(dp->adp));
> + if (ret)
> + return ret;
> + }
>
> return 0;
You can get rid of a few of your return cases by just returning "ret" here.
-Doug