Re: [PATCH v12 03/10] drm/display: Add Type-C switch helpers
From: Pin-yen Lin <hidden>
Date: 2023-02-22 08:54:00
Also in:
chrome-platform, dri-devel, linux-acpi, lkml
Hi Andy, Thanks for the review. On Tue, Feb 21, 2023 at 7:48 PM Andy Shevchenko [off-list ref] wrote:
On Tue, Feb 21, 2023 at 05:50:47PM +0800, Pin-yen Lin wrote:quoted
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 <redacted>...quoted
+ 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; ...quoted
+ switch_desc->typec_ports = devm_kcalloc( + dev, switch_desc->num_typec_switches,Strange indentation.quoted
+ sizeof(struct drm_dp_typec_port_data), GFP_KERNEL);quoted
+Redundant blank line.quoted
+ if (!switch_desc->typec_ports) + return -ENOMEM;...quoted
+void drm_dp_unregister_typec_switches(struct drm_dp_typec_switch_desc *switch_desc) +{ + int i;unsigned?quoted
+ for (i = 0; i < switch_desc->num_typec_switches; i++) + typec_mux_unregister(switch_desc->typec_ports[i].typec_mux); +}...quoted
#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.
I can put a `struct typec_mux_dev;` here, but there is also a usage of typec_mux_set_fn_t. Should I add the typedef into this header file as well? Regards, Pin-yen
quoted
#include <drm/display/drm_dp.h> #include <drm/drm_connector.h>...quoted
+#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