Re: [PATCH 4/8] drm/bridge: it66121: Add a helper function to get the next bridge

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 23 Nov 2023 at 07:25, Sui Jingfeng <sui.jingfeng@xxxxxxxxx> wrote:
>
> Hi,
>
>
> On 2023/11/15 00:05, Dmitry Baryshkov wrote:
> > On Tue, 14 Nov 2023 at 17:09, Sui Jingfeng <sui.jingfeng@xxxxxxxxx> wrote:
> >> From: Sui Jingfeng <suijingfeng@xxxxxxxxxxx>
> >>
> >> Group the code lines(which with the same functional) into one dedicated
> >> function, which reduce the weight of it66121_probe() function. Just trivial
> >> cleanuo, no functional change.
> >>
> >> Signed-off-by: Sui Jingfeng <suijingfeng@xxxxxxxxxxx>
> >> ---
> >>   drivers/gpu/drm/bridge/ite-it66121.c | 53 ++++++++++++++++++----------
> >>   1 file changed, 34 insertions(+), 19 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/ite-it66121.c
> >> index 0f78737adc83..7e473beefc79 100644
> >> --- a/drivers/gpu/drm/bridge/ite-it66121.c
> >> +++ b/drivers/gpu/drm/bridge/ite-it66121.c
> >> @@ -340,6 +340,37 @@ static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width)
> >>          return 0;
> >>   }
> >>
> >> +static int it66121_of_get_next_bridge(struct device *dev,
> >> +                                     struct drm_bridge **next_bridge)
> > it already exists and it is called drm_of_find_panel_or_bridge(),
> > could you please use it instead?
>
> That function is too fat and tangled, and should be untangled.
> it66121 can not connect with a panel, this is a prior knowledge
> and is known at compile time. So this prior knowledge shouldn't
> be dropped.

This prior knowledge is kept by passing NULL as a panel. We already
have a helper. It covers your use case. There is no need to write your
own boilerplate code for it.

>
> >> +{
> >> +       struct device_node *np;
> >> +       struct drm_bridge *bridge;
> >> +
> >> +       np = of_graph_get_remote_node(dev->of_node, 1, -1);
> >> +       if (!np) {
> >> +               dev_err(dev, "The endpoint is unconnected\n");
> >> +               return -EINVAL;
> >> +       }
> >> +
> >> +       if (!of_device_is_available(np)) {
> >> +               of_node_put(np);
> >> +               dev_err(dev, "The remote device is disabled\n");
> >> +               return -ENODEV;
> >> +       }
> >> +
> >> +       bridge = of_drm_find_bridge(np);
> >> +       of_node_put(np);
> >> +
> >> +       if (!bridge) {
> >> +               dev_dbg(dev, "Next bridge not found, deferring probe\n");
> >> +               return -EPROBE_DEFER;
> >> +       }
> >> +
> >> +       *next_bridge = bridge;
> >> +
> >> +       return 0;
> >> +}
> >> +
> >>   static const struct regmap_range_cfg it66121_regmap_banks[] = {
> >>          {
> >>                  .name = "it66121",
> >> @@ -1531,7 +1562,6 @@ static const char * const it66121_supplies[] = {
> >>   static int it66121_probe(struct i2c_client *client)
> >>   {
> >>          u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 };
> >> -       struct device_node *ep;
> >>          int ret;
> >>          struct it66121_ctx *ctx;
> >>          struct device *dev = &client->dev;
> >> @@ -1553,24 +1583,9 @@ static int it66121_probe(struct i2c_client *client)
> >>          if (ret)
> >>                  return ret;
> >>
> >> -       ep = of_graph_get_remote_node(dev->of_node, 1, -1);
> >> -       if (!ep) {
> >> -               dev_err(dev, "The endpoint is unconnected\n");
> >> -               return -EINVAL;
> >> -       }
> >> -
> >> -       if (!of_device_is_available(ep)) {
> >> -               of_node_put(ep);
> >> -               dev_err(dev, "The remote device is disabled\n");
> >> -               return -ENODEV;
> >> -       }
> >> -
> >> -       ctx->next_bridge = of_drm_find_bridge(ep);
> >> -       of_node_put(ep);
> >> -       if (!ctx->next_bridge) {
> >> -               dev_dbg(dev, "Next bridge not found, deferring probe\n");
> >> -               return -EPROBE_DEFER;
> >> -       }
> >> +       ret = it66121_of_get_next_bridge(dev, &ctx->next_bridge);
> >> +       if (ret)
> >> +               return ret;
> >>
> >>          i2c_set_clientdata(client, ctx);
> >>          mutex_init(&ctx->lock);
> >> --
> >> 2.34.1
> >>
> >



-- 
With best wishes
Dmitry



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux