[PATCH v12 07/10] drm/bridge: anx7625: Register Type C mode switches

Pin-yen Lin treapking at chromium.org
Wed Feb 22 05:05:13 UTC 2023


Hi Andy,

Thanks for the review.

On Tue, Feb 21, 2023 at 7:36 PM Andy Shevchenko
<andriy.shevchenko at linux.intel.com> wrote:
>
> On Tue, Feb 21, 2023 at 05:50:51PM +0800, Pin-yen Lin wrote:
> > Register USB Type-C mode switches when the "mode-switch" property and
> > relevant ports are available in Device Tree. Configure the crosspoint
> > switch based on the entered alternate mode for a specific Type-C
> > connector.
> >
> > Crosspoint switch can also be used for switching the output signal for
> > different orientations of a single USB Type-C connector, but the
> > orientation switch is not implemented yet. A TODO is added for this.
>
> ...
>
> > +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx)
> > +{
> > +     int i;
>
> unsigned?
>
> + Blank line.
>
> > +     /* Check if both ports available and do nothing to retain the current one */
> > +     if (ctx->port_data[0].dp_connected && ctx->port_data[1].dp_connected)
> > +             return;
> > +
> > +     for (i = 0; i < 2; i++) {
> > +             if (ctx->port_data[i].dp_connected)
> > +                     anx7625_set_crosspoint_switch(ctx,
> > +                                                   ctx->port_data[i].orientation);
> > +     }
> > +}
>
> ...
>
> > +     ctx->port_data[port->port_num].dp_connected =
> > +             state->alt && state->alt->svid == USB_TYPEC_DP_SID &&
>
> I would move the first parameter of && to the separate line for slightly better
> readability.
>
> > +             state->alt->mode == USB_TYPEC_DP_MODE;
>
> ...
>
> > +     for (i = 0; i < switch_desc->num_typec_switches; i++) {
> > +             struct drm_dp_typec_port_data *port = &switch_desc->typec_ports[i];
> > +             struct fwnode_handle *fwnode = port->fwnode;
> > +
> > +             num_lanes = fwnode_property_count_u32(fwnode, "data-lanes");
>
> > +
>
> Redundant blank line.
>
> > +             if (num_lanes < 0) {
> > +                     dev_err(dev,
> > +                             "Error on getting data lanes count from %pfwP: %d\n",
> > +                             fwnode, num_lanes);
>
> > +                     ret = num_lanes;
>
> Can be written differently:
>
> > +                     goto unregister_mux;
> > +             }
>
>                 ret = ...
>                 if (ret < 0) {
>                         ...
>                 }
>                 num_lanes = ret;
>
>
> What if it's 0?

The binding does not allow that, so I don't think we should check it here.

I'll address other comments in the next version.

Regards,
Pin-yen
>
> > +             ret = fwnode_property_read_u32_array(fwnode, "data-lanes",
> > +                                                  dp_lanes, num_lanes);
> > +             if (ret) {
> > +                     dev_err(dev,
> > +                             "Failed to read the data-lanes variable: %d\n",
> > +                             ret);
> > +                     goto unregister_mux;
> > +             }
> > +
> > +             ctx->port_data[i].orientation = (dp_lanes[0] / 2 == 0) ?
> > +                     TYPEC_ORIENTATION_REVERSE : TYPEC_ORIENTATION_NORMAL;
> > +             ctx->port_data[i].dp_connected = false;
> > +     }
> > +     complete_all(&ctx->mux_register);
> > +
> > +     return 0;
> > +
> > +unregister_mux:
> > +     complete_all(&ctx->mux_register);
> > +     anx7625_unregister_typec_switches(ctx);
> > +     return ret;
> > +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
>


More information about the dri-devel mailing list