Skip to contentSkip to conversation

usb: typec: WUSB3801 devicetree bindings and driver

PATCH Superseded Samuel Holland 3 participants 10 messages Feb 2, 2022 – Feb 9, 2022

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover usb: typec: WUSB3801 devicetree bindings and driver

This series adds bindings and a driver for the Willsemi WUSB3801. This chip's bindings use the standard USB Type-C connector bindings, but the driver does not use the TCPM library, so a refactoring patch is included to avoid duplicating some fwnode parsing code.

Changes in v2:
- Always put the return values from typec_find_* in a signed variable for error checking.
- License the driver as GPL 2 only; probably best anyway as I used a lot of other drivers/usb/typec code as inspiration
- Don't try to be clever; use default instead of unreachable
- Free the IRQ before unregistering the partner/port

Samuel Holland (4):
dt-bindings: vendor-prefixes: Add willsemi
dt-bindings: usb: Add WUSB3801 Type-C Port Controller
usb: typec: Factor out non-PD fwnode properties
usb: typec: Support the WUSB3801 port controller

 .../bindings/usb/willsemi,wusb3801.yaml       |  75 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/usb/typec/Kconfig                     |  10 +
 drivers/usb/typec/Makefile                    |   1 +
 drivers/usb/typec/class.c                     |  52 ++
 drivers/usb/typec/tcpm/tcpm.c                 |  32 +-
 drivers/usb/typec/wusb3801.c                  | 445 ++++++++++++++++++
 include/linux/usb/typec.h                     |   3 +
 8 files changed, 589 insertions(+), 31 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/willsemi,wusb3801.yaml
 create mode 100644 drivers/usb/typec/wusb3801.c
Signature · 1 line
2.33.1
#1 lore raw

PATCH v2 1/4 dt-bindings: vendor-prefixes: Add willsemi

Add prefix for Will Semiconductor Co. Ltd. (http://www.willsemi.com/)

---

(no changes since v1)

 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 294093d45a23..a8ab97717a46 100644
@@ -1340,6 +1340,8 @@ patternProperties:
     description: Wi2Wi, Inc.
   "^wiligear,.*":
     description: Wiligear, Ltd.
+  "^willsemi,.*":
+    description: Will Semiconductor Ltd.
   "^winbond,.*":
     description: Winbond Electronics corp.
   "^wingtech,.*":
Signature · 1 line
2.33.1
#3 lore raw

PATCH v2 2/4 dt-bindings: usb: Add WUSB3801 Type-C Port Controller

In reply to Samuel Holland

Add devicetree support for the Will Semiconductor WUSB3801. This is a basic non-PD Type-C port controller.

---

(no changes since v1)

 .../bindings/usb/willsemi,wusb3801.yaml       | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/willsemi,wusb3801.yaml
Documentation/devicetree/bindings/usb/willsemi,wusb3801.yaml new file +75 -0
new file mode 100644
index 000000000000..c2b2243c7892
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/willsemi,wusb3801.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: WUSB3801 Type-C port controller DT bindings
+
+description:
+  The Will Semiconductor WUSB3801 is a USB Type-C port controller which
+  supports role and plug orientation detection using the CC pins. It is
+  compatible with the USB Type-C Cable and Connector Specification v1.2.
+
+maintainers:
+  - Samuel Holland <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - willsemi,wusb3801
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  connector:
+    type: object
+    $ref: ../connector/usb-connector.yaml#
+    description:
+      The managed USB Type-C connector. Since WUSB3801 does not support
+      Power Delivery, the node should have the "pd-disable" property.
+
+    properties:
+      compatible:
+        const: usb-c-connector
+
+    required:
+      - pd-disable
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - connector
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      tcpc@60 {
+        compatible = "willsemi,wusb3801";
+        reg = <0x60>;
+        interrupt-parent = <&gpio0>;
+        interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
+
+        connector {
+          compatible = "usb-c-connector";
+          label = "USB-C";
+          vbus-supply = <&otg_switch>;
+          power-role = "dual";
+          try-power-role = "sink";
+          data-role = "dual";
+          typec-power-opmode = "default";
+          pd-disable;
+        };
+      };
+    };
Signature · 1 line
2.33.1
maintainer Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] dt-bindings: usb: Add WUSB3801 Type-C Port Controller

Quoted 12 lines · Samuel Holland

Add devicetree support for the Will Semiconductor WUSB3801. This is a basic non-PD Type-C port controller.

---

(no changes since v1)

 .../bindings/usb/willsemi,wusb3801.yaml       | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/willsemi,wusb3801.yaml
#5 lore raw

PATCH v2 3/4 usb: typec: Factor out non-PD fwnode properties

In reply to Samuel Holland

Basic programmable non-PD Type-C port controllers do not need the full TCPM library, but they share the same devicetree binding and the same typec_capability structure. Factor out a helper for parsing those properties which map to fields in struct typec_capability, so the code can be shared between TCPM and basic non-TCPM drivers.

---

Changes in v2:
- Always put the return values from typec_find_* in a signed variable for error checking.

 drivers/usb/typec/class.c     | 52 +++++++++++++++++++++++++++++++++++
 drivers/usb/typec/tcpm/tcpm.c | 32 +--------------------
 include/linux/usb/typec.h     |  3 ++
 3 files changed, 56 insertions(+), 31 deletions(-)
drivers/usb/typec/class.c +52 -0
index 45a6f0c807cb..b67ba9478c82 100644
@@ -1894,6 +1894,58 @@ void *typec_get_drvdata(struct typec_port *port)
 }
 EXPORT_SYMBOL_GPL(typec_get_drvdata);
 
+int typec_get_fw_cap(struct typec_capability *cap,
+		     struct fwnode_handle *fwnode)
+{
+	const char *cap_str;
+	int ret;
+
+	/*
+	 * This fwnode has a "compatible" property, but is never populated as a
+	 * struct device. Instead we simply parse it to read the properties.
+	 * This it breaks fw_devlink=on. To maintain backward compatibility
+	 * with existing DT files, we work around this by deleting any
+	 * fwnode_links to/from this fwnode.
+	 */
+	fw_devlink_purge_absent_suppliers(fwnode);
+
+	cap->fwnode = fwnode;
+
+	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	ret = typec_find_port_power_role(cap_str);
+	if (ret < 0)
+		return ret;
+	cap->type = ret;
+
+	/* USB data support is optional */
+	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
+	if (ret == 0) {
+		ret = typec_find_port_data_role(cap_str);
+		if (ret < 0)
+			return ret;
+		cap->data = ret;
+	}
+
+	/* Get the preferred power role for a DRP */
+	if (cap->type == TYPEC_PORT_DRP) {
+		cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
+
+		ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
+		if (ret == 0) {
+			ret = typec_find_power_role(cap_str);
+			if (ret < 0)
+				return ret;
+			cap->prefer_role = ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(typec_get_fw_cap);
+
 /**
  * typec_port_register_altmode - Register USB Type-C Port Alternate Mode
  * @port: USB Type-C Port that supports the alternate mode
drivers/usb/typec/tcpm/tcpm.c +1 -31
index 5fce795b69c7..8b58aa6e3509 100644
@@ -5935,32 +5935,10 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
 	if (!fwnode)
 		return -EINVAL;
 
-	/*
-	 * This fwnode has a "compatible" property, but is never populated as a
-	 * struct device. Instead we simply parse it to read the properties.
-	 * This it breaks fw_devlink=on. To maintain backward compatibility
-	 * with existing DT files, we work around this by deleting any
-	 * fwnode_links to/from this fwnode.
-	 */
-	fw_devlink_purge_absent_suppliers(fwnode);
-
-	/* USB data support is optional */
-	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
-	if (ret == 0) {
-		ret = typec_find_port_data_role(cap_str);
-		if (ret < 0)
-			return ret;
-		port->typec_caps.data = ret;
-	}
-
-	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	ret = typec_get_fw_cap(&port->typec_caps, fwnode);
 	if (ret < 0)
 		return ret;
 
-	ret = typec_find_port_power_role(cap_str);
-	if (ret < 0)
-		return ret;
-	port->typec_caps.type = ret;
 	port->port_type = port->typec_caps.type;
 	port->pd_supported = !fwnode_property_read_bool(fwnode, "pd-disable");
 
@@ -5997,14 +5975,6 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
 	if (port->port_type == TYPEC_PORT_SRC)
 		return 0;
 
-	/* Get the preferred power role for DRP */
-	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
-	if (ret < 0)
-		return ret;
-
-	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
-	if (port->typec_caps.prefer_role < 0)
-		return -EINVAL;
 sink:
 	port->self_powered = fwnode_property_read_bool(fwnode, "self-powered");
 
include/linux/usb/typec.h +3 -0
index 7ba45a97eeae..fdf737d48b3b 100644
@@ -295,6 +295,9 @@ int typec_set_mode(struct typec_port *port, int mode);
 
 void *typec_get_drvdata(struct typec_port *port);
 
+int typec_get_fw_cap(struct typec_capability *cap,
+		     struct fwnode_handle *fwnode);
+
 int typec_find_pwr_opmode(const char *name);
 int typec_find_orientation(const char *name);
 int typec_find_port_power_role(const char *name);
Signature · 1 line
2.33.1
maintainer
#6 lore raw

Re: [PATCH v2 3/4] usb: typec: Factor out non-PD fwnode properties

Hi,

Quoted 30 lines · Samuel Holland

Basic programmable non-PD Type-C port controllers do not need the full TCPM library, but they share the same devicetree binding and the same typec_capability structure. Factor out a helper for parsing those properties which map to fields in struct typec_capability, so the code can be shared between TCPM and basic non-TCPM drivers.

---

Changes in v2:
- Always put the return values from typec_find_* in a signed variable for error checking.

 drivers/usb/typec/class.c     | 52 +++++++++++++++++++++++++++++++++++
 drivers/usb/typec/tcpm/tcpm.c | 32 +--------------------
 include/linux/usb/typec.h     |  3 ++
 3 files changed, 56 insertions(+), 31 deletions(-)
drivers/usb/typec/class.c +4 -0
index 45a6f0c807cb..b67ba9478c82 100644
@@ -1894,6 +1894,58 @@ void *typec_get_drvdata(struct typec_port *port)
 }
 EXPORT_SYMBOL_GPL(typec_get_drvdata);
 
+int typec_get_fw_cap(struct typec_capability *cap,
+		     struct fwnode_handle *fwnode)
+{
+	const char *cap_str;

drivers/usb/typec/class.c void *typec_get_drvdata(struct typec_port *port) · line 1910

Quoted 10 lines
drivers/usb/typec/class.c +10 -0
+	int ret;
+
+	/*
+	 * This fwnode has a "compatible" property, but is never populated as a
+	 * struct device. Instead we simply parse it to read the properties.
+	 * This it breaks fw_devlink=on. To maintain backward compatibility
+	 * with existing DT files, we work around this by deleting any
+	 * fwnode_links to/from this fwnode.
+	 */
+	fw_devlink_purge_absent_suppliers(fwnode);

Let's not put that call here. That function is broken. I think it in practice assumes that there can only be one device linked to fwnode, but that's not true. The fwnodes can be, and are, shared. So by using it we may end up doing things to some completely wrong devices.

So let's keep that call in the drivers that really have to have it for now. I think that function - fw_devlink_purge_absent_suppliers() - needs some serious rethinking.

There is some deeper problem. I have a feeling that all the functions that rely on the fwnode->dev member are broken. We need a proper reverce search mechanism that can be used to find the devices linked to fwnodes. But I have no idea how to that could be done.

Quoted 26 lines
drivers/usb/typec/class.c +26 -0
+	cap->fwnode = fwnode;
+
+	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	if (ret < 0)
+		return ret;
+
+	ret = typec_find_port_power_role(cap_str);
+	if (ret < 0)
+		return ret;
+	cap->type = ret;
+
+	/* USB data support is optional */
+	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
+	if (ret == 0) {
+		ret = typec_find_port_data_role(cap_str);
+		if (ret < 0)
+			return ret;
+		cap->data = ret;
+	}
+
+	/* Get the preferred power role for a DRP */
+	if (cap->type == TYPEC_PORT_DRP) {
+		cap->prefer_role = TYPEC_NO_PREFERRED_ROLE;
+
+		ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
+		if (ret == 0) {

drivers/usb/typec/class.c void *typec_get_drvdata(struct typec_port *port) · line 1947

Quoted 10 lines
drivers/usb/typec/class.c +10 -0
+			ret = typec_find_power_role(cap_str);
+			if (ret < 0)
+				return ret;
+			cap->prefer_role = ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(typec_get_fw_cap);

thanks,

Signature · 1 line
heikki
maintainer
#7 lore raw

Re: [PATCH v2 3/4] usb: typec: Factor out non-PD fwnode properties

In reply to Samuel Holland
Quoted 42 lines · Samuel Holland
drivers/usb/typec/tcpm/tcpm.c +1 -23
index 5fce795b69c7..8b58aa6e3509 100644
@@ -5935,32 +5935,10 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
 	if (!fwnode)
 		return -EINVAL;
 
-	/*
-	 * This fwnode has a "compatible" property, but is never populated as a
-	 * struct device. Instead we simply parse it to read the properties.
-	 * This it breaks fw_devlink=on. To maintain backward compatibility
-	 * with existing DT files, we work around this by deleting any
-	 * fwnode_links to/from this fwnode.
-	 */
-	fw_devlink_purge_absent_suppliers(fwnode);
-
-	/* USB data support is optional */
-	ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
-	if (ret == 0) {
-		ret = typec_find_port_data_role(cap_str);
-		if (ret < 0)
-			return ret;
-		port->typec_caps.data = ret;
-	}
-
-	ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
+	ret = typec_get_fw_cap(&port->typec_caps, fwnode);
 	if (ret < 0)
 		return ret;
 
-	ret = typec_find_port_power_role(cap_str);
-	if (ret < 0)
-		return ret;
-	port->typec_caps.type = ret;
 	port->port_type = port->typec_caps.type;
 	port->pd_supported = !fwnode_property_read_bool(fwnode, "pd-disable");
 
@@ -5997,14 +5975,6 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
 	if (port->port_type == TYPEC_PORT_SRC)
 		return 0;
 

drivers/usb/typec/tcpm/tcpm.c static int tcpm_fw_get_caps(struct tcpm_port *port, · line 5979

Quoted 10 lines
drivers/usb/typec/tcpm/tcpm.c +0 -8
-	/* Get the preferred power role for DRP */
-	ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str);
-	if (ret < 0)
-		return ret;
-
-	port->typec_caps.prefer_role = typec_find_power_role(cap_str);
-	if (port->typec_caps.prefer_role < 0)
-		return -EINVAL;
 sink:
 	port->self_powered = fwnode_property_read_bool(fwnode, "self-powered");

It looks like after this there are no more users for that cap_str variable. You need to remove that too.

thanks,

Signature · 1 line
heikki
#8 lore raw

PATCH v2 4/4 usb: typec: Support the WUSB3801 port controller

In reply to Samuel Holland

WUSB3801 features a configurable port type, accessory detection, and plug orientation detection. It provides a hardware "ID" pin output for compatibility with USB 2.0 OTG PHYs. Add a typec class driver for it.

---

Changes in v2:
- License the driver as GPL 2 only; probably best anyway as I used a lot of other drivers/usb/typec code as inspiration
- Don't try to be clever; use default instead of unreachable
- Free the IRQ before unregistering the partner/port

 drivers/usb/typec/Kconfig    |  10 +
 drivers/usb/typec/Makefile   |   1 +
 drivers/usb/typec/wusb3801.c | 445 +++++++++++++++++++++++++++++++++++
 3 files changed, 456 insertions(+)
 create mode 100644 drivers/usb/typec/wusb3801.c
drivers/usb/typec/Kconfig +10 -0
index ab480f38523a..74acde9fc09f 100644
@@ -88,6 +88,16 @@ config TYPEC_QCOM_PMIC
 	  It will also enable the VBUS output to connected devices when a
 	  DFP connection is made.
 
+config TYPEC_WUSB3801
+	tristate "Willsemi WUSB3801 Type-C port controller driver"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y or M here if your system has a WUSB3801 Type-C port controller.
+
+	  If you choose to build this driver as a dynamically linked module, the
+	  module will be called wusb3801.ko.
+
 source "drivers/usb/typec/mux/Kconfig"
 
 source "drivers/usb/typec/altmodes/Kconfig"
drivers/usb/typec/Makefile +1 -0
index 57870a2bd787..3b722ec28d99 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_TYPEC_TPS6598X)	+= tipd/
 obj-$(CONFIG_TYPEC_HD3SS3220)	+= hd3ss3220.o
 obj-$(CONFIG_TYPEC_QCOM_PMIC)	+= qcom-pmic-typec.o
 obj-$(CONFIG_TYPEC_STUSB160X) 	+= stusb160x.o
+obj-$(CONFIG_TYPEC_WUSB3801)	+= wusb3801.o
 obj-$(CONFIG_TYPEC)		+= mux/
drivers/usb/typec/wusb3801.c new file +445 -0

445 lines not on this page · raw message

Signature · 1 line
2.33.1
maintainer
#9 lore raw

Re: [PATCH v2 4/4] usb: typec: Support the WUSB3801 port controller

Quoted 13 lines · Samuel Holland

WUSB3801 features a configurable port type, accessory detection, and plug orientation detection. It provides a hardware "ID" pin output for compatibility with USB 2.0 OTG PHYs. Add a typec class driver for it.

---

Changes in v2:
- License the driver as GPL 2 only; probably best anyway as I used a lot of other drivers/usb/typec code as inspiration
- Don't try to be clever; use default instead of unreachable
- Free the IRQ before unregistering the partner/port

Quoted 5 lines
 drivers/usb/typec/Kconfig    |  10 +
 drivers/usb/typec/Makefile   |   1 +
 drivers/usb/typec/wusb3801.c | 445 +++++++++++++++++++++++++++++++++++
 3 files changed, 456 insertions(+)
 create mode 100644 drivers/usb/typec/wusb3801.c

This looked mostly OK to me. One nitpick below.

Quoted 17 lines
drivers/usb/typec/wusb3801.c new file +17 -0
+static int wusb3801_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct fwnode_handle *connector;
+	unsigned int device_id, test01;
+	struct wusb3801 *wusb3801;
+	const char *cap_str;
+	int ret;
+
+	wusb3801 = devm_kzalloc(dev, sizeof(*wusb3801), GFP_KERNEL);
+	if (!wusb3801)
+		return -ENOMEM;
+
+	i2c_set_clientdata(client, wusb3801);
+
+	wusb3801->dev = dev;
+

drivers/usb/typec/wusb3801.c line 348

Quoted 10 lines
drivers/usb/typec/wusb3801.c new file +10 -0
+	wusb3801->regmap = devm_regmap_init_i2c(client, &config);
+	if (IS_ERR(wusb3801->regmap))
+		return PTR_ERR(wusb3801->regmap);
+
+	regmap_read(wusb3801->regmap, WUSB3801_REG_DEVICE_ID, &device_id);
+	regmap_read(wusb3801->regmap, WUSB3801_REG_TEST01, &test01);
+	dev_info(dev, "Vendor ID: %ld, Version ID: %ld, Vendor SubID: 0x%02lx\n",
+		 device_id & WUSB3801_DEVICE_ID_VENDOR_ID,
+		 (device_id & WUSB3801_DEVICE_ID_VERSION_ID) >> 3,
+		 test01 & WUSB3801_TEST01_VENDOR_SUB_ID);

That is just noise.

drivers/usb/typec/wusb3801.c line 358

Quoted 9 lines
drivers/usb/typec/wusb3801.c new file +9 -0
+	wusb3801->vbus_supply = devm_regulator_get(dev, "vbus");
+	if (IS_ERR(wusb3801->vbus_supply))
+		return PTR_ERR(wusb3801->vbus_supply);
+
+	connector = device_get_named_child_node(dev, "connector");
+	if (!connector)
+		return -ENODEV;
+
+	ret = typec_get_fw_cap(&wusb3801->cap, connector);

One note here: Don't use fw_devlink_purge_absent_suppliers() here either unless you really see some problem yourself!

That function is broken like I said. What ever it's fixing, it's doing it wrong. That function seems to be just a broken hack that most likely covered some individual case that was reported at the time. Instead of hacks like that, we need to figure out a solution for the core problem, what ever that might be.

Quoted 40 lines
drivers/usb/typec/wusb3801.c new file +40 -0
+	if (ret)
+		goto err_put_connector;
+	wusb3801->port_type = wusb3801->cap.type;
+
+	ret = fwnode_property_read_string(connector, "typec-power-opmode", &cap_str);
+	if (ret)
+		goto err_put_connector;
+
+	ret = typec_find_pwr_opmode(cap_str);
+	if (ret < 0 || ret == TYPEC_PWR_MODE_PD)
+		goto err_put_connector;
+	wusb3801->pwr_opmode = ret;
+
+	/* Initialize the hardware with the devicetree settings. */
+	ret = wusb3801_hw_init(wusb3801);
+	if (ret)
+		return ret;
+
+	wusb3801->cap.revision		= USB_TYPEC_REV_1_2;
+	wusb3801->cap.accessory[0]	= TYPEC_ACCESSORY_AUDIO;
+	wusb3801->cap.accessory[1]	= TYPEC_ACCESSORY_DEBUG;
+	wusb3801->cap.orientation_aware	= true;
+	wusb3801->cap.driver_data	= wusb3801;
+	wusb3801->cap.ops		= &wusb3801_typec_ops;
+
+	wusb3801->port = typec_register_port(dev, &wusb3801->cap);
+	if (IS_ERR(wusb3801->port)) {
+		ret = PTR_ERR(wusb3801->port);
+		goto err_put_connector;
+	}
+
+	/* Initialize the port attributes from the hardware state. */
+	wusb3801_hw_update(wusb3801);
+
+	ret = request_threaded_irq(client->irq, NULL, wusb3801_irq,
+				   IRQF_ONESHOT, dev_name(dev), wusb3801);
+	if (ret)
+		goto err_unregister_port;
+
+	fwnode_handle_put(connector);

drivers/usb/typec/wusb3801.c line 408

Quoted 10 lines
drivers/usb/typec/wusb3801.c new file +10 -0
+
+	return 0;
+
+err_unregister_port:
+	typec_unregister_port(wusb3801->port);
+err_put_connector:
+	fwnode_handle_put(connector);
+
+	return ret;
+}

thanks,

Signature · 1 line
heikki