[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y/SvhxgjTM2cYZa+@smile.fi.intel.com>
Date: Tue, 21 Feb 2023 13:48:23 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Pin-yen Lin <treapking@...omium.org>
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>,
Douglas Anderson <dianders@...omium.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Imre Deak <imre.deak@...el.com>,
Jani Nikula <jani.nikula@...el.com>,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH v12 03/10] drm/display: Add Type-C switch helpers
On Tue, Feb 21, 2023 at 05:50:47PM +0800, Pin-yen Lin wrote:
> Add helpers to register and unregister Type-C "switches" for bridges
> capable of switching their output between two downstream devices.
>
> The helper registers USB Type-C mode switches when the "mode-switch"
> and the "reg" properties are available in Device Tree.
>
> Signed-off-by: Pin-yen Lin <treapking@...omium.org>
...
> + fwnode_for_each_typec_mode_switch(port, sw)
> + switch_desc->num_typec_switches++;
> +
> + if (!switch_desc->num_typec_switches) {
> + dev_dbg(dev, "No Type-C switches node found\n");
> + return 0;
> + }
What about
static inline unsigned int typec_mode_switch_node_count(... *port)
{
... *sw;
unsigned int count = 0;
for_each_typec_mode_switch_node(port, sw)
count++;
return count;
}
And then it seems something like
unsigned int count;
count = typec_mode_switch_node_count(port);
if (!count) {
...
}
_switches = count;
...
> + switch_desc->typec_ports = devm_kcalloc(
> + dev, switch_desc->num_typec_switches,
Strange indentation.
> + sizeof(struct drm_dp_typec_port_data), GFP_KERNEL);
> +
Redundant blank line.
> + if (!switch_desc->typec_ports)
> + return -ENOMEM;
...
> +void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc)
> +{
> + int i;
unsigned?
> + for (i = 0; i < switch_desc->num_typec_switches; i++)
> + typec_mux_unregister(switch_desc->typec_ports[i].typec_mux);
> +}
...
> #include <linux/delay.h>
> #include <linux/i2c.h>
> +#include <linux/usb/typec_mux.h>
I don't see users of this.
But a few forward declarations are missing.
> #include <drm/display/drm_dp.h>
> #include <drm/drm_connector.h>
...
> +#define fwnode_for_each_typec_mode_switch(port, sw) \
> + fwnode_for_each_child_node((port), (sw)) \
> + for_each_if(fwnode_property_present((sw), "mode-switch"))
Please don't use fwnode namespace (see above), something like
#define for_each_typec_mode_switch_node(port, sw) \
...
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists