[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEXTbpeObyd1uKd3Qp9c3A9z9BX8R_SiH7okVrgmV+fMfaRaYQ@mail.gmail.com>
Date: Wed, 22 Feb 2023 13:05:13 +0800
From: Pin-yen Lin <treapking@...omium.org>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Andrzej Hajda <andrzej.hajda@...el.com>,
Neil Armstrong <neil.armstrong@...aro.org>,
Robert Foss <rfoss@...nel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jonas Karlman <jonas@...boo.se>,
Jernej Skrabec <jernej.skrabec@...il.com>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Prashant Malani <pmalani@...omium.org>,
Benson Leung <bleung@...omium.org>,
Guenter Roeck <groeck@...omium.org>,
linux-kernel@...r.kernel.org, Hsin-Yi Wang <hsinyi@...omium.org>,
Marek Vasut <marex@...x.de>,
Thomas Zimmermann <tzimmermann@...e.de>,
dri-devel@...ts.freedesktop.org, Xin Ji <xji@...logixsemi.com>,
Lyude Paul <lyude@...hat.com>,
Allen Chen <allen.chen@....com.tw>, devicetree@...r.kernel.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Nícolas F . R . A . Prado
<nfraprado@...labora.com>, chrome-platform@...ts.linux.dev,
Javier Martinez Canillas <javierm@...hat.com>,
linux-acpi@...r.kernel.org, Stephen Boyd <swboyd@...omium.org>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
Subject: Re: [PATCH v12 07/10] drm/bridge: anx7625: Register Type C mode switches
Hi Andy,
Thanks for the review.
On Tue, Feb 21, 2023 at 7:36 PM Andy Shevchenko
<andriy.shevchenko@...ux.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
>
>
Powered by blists - more mailing lists