]>
Commit | Line | Data |
---|---|---|
f2086f9b GKH |
1 | From 23481121c81d984193edf1532f5e123637e50903 Mon Sep 17 00:00:00 2001 |
2 | From: Heikki Krogerus <heikki.krogerus@linux.intel.com> | |
3 | Date: Thu, 20 Sep 2018 14:23:44 +0300 | |
4 | Subject: usb: typec: class: Don't use port parent for getting mux handles | |
5 | ||
6 | From: Heikki Krogerus <heikki.krogerus@linux.intel.com> | |
7 | ||
8 | commit 23481121c81d984193edf1532f5e123637e50903 upstream. | |
9 | ||
10 | It is not possible to use the parent of the port device when | |
11 | requesting mux handles as the parent may be a multiport USB | |
12 | Type-C or PD controller. The muxes must be assigned to the | |
13 | ports, not the controllers. | |
14 | ||
15 | This will also move the requesting of the muxes after the | |
16 | port device is initialized. | |
17 | ||
18 | Acked-by: Hans de Goede <hdegoede@redhat.com> | |
19 | Tested-by: Hans de Goede <hdegoede@redhat.com> | |
20 | Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> | |
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
22 | ||
23 | ||
24 | --- | |
25 | drivers/usb/typec/class.c | 38 +++++++++++++++----------------------- | |
26 | 1 file changed, 15 insertions(+), 23 deletions(-) | |
27 | ||
28 | --- a/drivers/usb/typec/class.c | |
29 | +++ b/drivers/usb/typec/class.c | |
30 | @@ -1500,7 +1500,7 @@ typec_port_register_altmode(struct typec | |
31 | ||
32 | sprintf(id, "id%04xm%02x", desc->svid, desc->mode); | |
33 | ||
34 | - mux = typec_mux_get(port->dev.parent, id); | |
35 | + mux = typec_mux_get(&port->dev, id); | |
36 | if (IS_ERR(mux)) | |
37 | return ERR_CAST(mux); | |
38 | ||
39 | @@ -1540,18 +1540,6 @@ struct typec_port *typec_register_port(s | |
40 | return ERR_PTR(id); | |
41 | } | |
42 | ||
43 | - port->sw = typec_switch_get(cap->fwnode ? &port->dev : parent); | |
44 | - if (IS_ERR(port->sw)) { | |
45 | - ret = PTR_ERR(port->sw); | |
46 | - goto err_switch; | |
47 | - } | |
48 | - | |
49 | - port->mux = typec_mux_get(parent, "typec-mux"); | |
50 | - if (IS_ERR(port->mux)) { | |
51 | - ret = PTR_ERR(port->mux); | |
52 | - goto err_mux; | |
53 | - } | |
54 | - | |
55 | switch (cap->type) { | |
56 | case TYPEC_PORT_SRC: | |
57 | port->pwr_role = TYPEC_SOURCE; | |
58 | @@ -1592,13 +1580,26 @@ struct typec_port *typec_register_port(s | |
59 | port->port_type = cap->type; | |
60 | port->prefer_role = cap->prefer_role; | |
61 | ||
62 | + device_initialize(&port->dev); | |
63 | port->dev.class = typec_class; | |
64 | port->dev.parent = parent; | |
65 | port->dev.fwnode = cap->fwnode; | |
66 | port->dev.type = &typec_port_dev_type; | |
67 | dev_set_name(&port->dev, "port%d", id); | |
68 | ||
69 | - ret = device_register(&port->dev); | |
70 | + port->sw = typec_switch_get(&port->dev); | |
71 | + if (IS_ERR(port->sw)) { | |
72 | + put_device(&port->dev); | |
73 | + return ERR_CAST(port->sw); | |
74 | + } | |
75 | + | |
76 | + port->mux = typec_mux_get(&port->dev, "typec-mux"); | |
77 | + if (IS_ERR(port->mux)) { | |
78 | + put_device(&port->dev); | |
79 | + return ERR_CAST(port->mux); | |
80 | + } | |
81 | + | |
82 | + ret = device_add(&port->dev); | |
83 | if (ret) { | |
84 | dev_err(parent, "failed to register port (%d)\n", ret); | |
85 | put_device(&port->dev); | |
86 | @@ -1606,15 +1607,6 @@ struct typec_port *typec_register_port(s | |
87 | } | |
88 | ||
89 | return port; | |
90 | - | |
91 | -err_mux: | |
92 | - typec_switch_put(port->sw); | |
93 | - | |
94 | -err_switch: | |
95 | - ida_simple_remove(&typec_index_ida, port->id); | |
96 | - kfree(port); | |
97 | - | |
98 | - return ERR_PTR(ret); | |
99 | } | |
100 | EXPORT_SYMBOL_GPL(typec_register_port); | |
101 |