Skip to content

Commit bbe80c9

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: altmode: Remove the notification chain
Using the generic notification chain is not reasonable with the alternate modes because it would require dependencies between the drivers of the components that need the notifications, and the typec drivers. There are no users for the alternate mode notifications, so removing the chain and the API for it completely. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200211112531.86510-6-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 684cb4b commit bbe80c9

5 files changed

Lines changed: 3 additions & 107 deletions

File tree

‎Documentation/driver-api/usb/typec_bus.rst‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ in need to reconfigure the pins on the connector, the alternate mode driver
5353
needs to notify the bus using :c:func:`typec_altmode_notify()`. The driver
5454
passes the negotiated SVID specific pin configuration value to the function as
5555
parameter. The bus driver will then configure the mux behind the connector using
56-
that value as the state value for the mux, and also call blocking notification
57-
chain to notify the external drivers about the state of the connector that need
58-
to know it.
56+
that value as the state value for the mux.
5957

6058
NOTE: The SVID specific pin configuration values must always start from
6159
``TYPEC_STATE_MODAL``. USB Type-C specification defines two default states for
@@ -80,19 +78,6 @@ Helper macro ``TYPEC_MODAL_STATE()`` can also be used::
8078
#define ALTMODEX_CONF_A = TYPEC_MODAL_STATE(0);
8179
#define ALTMODEX_CONF_B = TYPEC_MODAL_STATE(1);
8280

83-
Notification chain
84-
~~~~~~~~~~~~~~~~~~
85-
86-
The drivers for the components that the alternate modes are designed for need to
87-
get details regarding the results of the negotiation with the partner, and the
88-
pin configuration of the connector. In case of DisplayPort alternate mode for
89-
example, the GPU drivers will need to know those details. In case of
90-
Thunderbolt alternate mode, the thunderbolt drivers will need to know them, and
91-
so on.
92-
93-
The notification chain is designed for this purpose. The drivers can register
94-
notifiers with :c:func:`typec_altmode_register_notifier()`.
95-
9681
Cable plug alternate modes
9782
~~~~~~~~~~~~~~~~~~~~~~~~~~
9883

@@ -129,8 +114,3 @@ Cable Plug operations
129114

130115
.. kernel-doc:: drivers/usb/typec/bus.c
131116
:functions: typec_altmode_get_plug typec_altmode_put_plug
132-
133-
Notifications
134-
~~~~~~~~~~~~~
135-
.. kernel-doc:: drivers/usb/typec/class.c
136-
:functions: typec_altmode_register_notifier typec_altmode_unregister_notifier

‎drivers/usb/typec/bus.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@ static int typec_altmode_set_state(struct typec_altmode *adev,
3030
{
3131
bool is_port = is_typec_port(adev->dev.parent);
3232
struct altmode *port_altmode;
33-
int ret;
3433

3534
port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner;
3635

37-
ret = typec_altmode_set_mux(port_altmode, conf, data);
38-
if (ret)
39-
return ret;
40-
41-
blocking_notifier_call_chain(&port_altmode->nh, conf, NULL);
42-
43-
return 0;
36+
return typec_altmode_set_mux(port_altmode, conf, data);
4437
}
4538

4639
/* -------------------------------------------------------------------------- */
@@ -82,9 +75,6 @@ int typec_altmode_notify(struct typec_altmode *adev,
8275
if (ret)
8376
return ret;
8477

85-
blocking_notifier_call_chain(is_port ? &altmode->nh : &partner->nh,
86-
conf, data);
87-
8878
if (partner->adev.ops && partner->adev.ops->notify)
8979
return partner->adev.ops->notify(&partner->adev, conf, data);
9080

‎drivers/usb/typec/bus.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ struct altmode {
2222

2323
struct altmode *partner;
2424
struct altmode *plug[2];
25-
26-
struct blocking_notifier_head nh;
2725
};
2826

2927
#define to_altmode(d) container_of(d, struct altmode, adev)

‎drivers/usb/typec/class.c‎

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -206,69 +206,6 @@ static void typec_altmode_put_partner(struct altmode *altmode)
206206
put_device(&adev->dev);
207207
}
208208

209-
static void *typec_port_match(struct device_connection *con, int ep, void *data)
210-
{
211-
struct device *dev;
212-
213-
/*
214-
* FIXME: Check does the fwnode supports the requested SVID. If it does
215-
* we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
216-
*/
217-
if (con->fwnode)
218-
return class_find_device_by_fwnode(typec_class, con->fwnode);
219-
220-
dev = class_find_device_by_name(typec_class, con->endpoint[ep]);
221-
222-
return dev ? dev : ERR_PTR(-EPROBE_DEFER);
223-
}
224-
225-
struct typec_altmode *
226-
typec_altmode_register_notifier(struct device *dev, u16 svid, u8 mode,
227-
struct notifier_block *nb)
228-
{
229-
struct typec_device_id id = { svid, mode, };
230-
struct device *altmode_dev;
231-
struct device *port_dev;
232-
struct altmode *altmode;
233-
int ret;
234-
235-
/* Find the port linked to the caller */
236-
port_dev = device_connection_find_match(dev, NULL, NULL,
237-
typec_port_match);
238-
if (IS_ERR_OR_NULL(port_dev))
239-
return port_dev ? ERR_CAST(port_dev) : ERR_PTR(-ENODEV);
240-
241-
/* Find the altmode with matching svid */
242-
altmode_dev = device_find_child(port_dev, &id, altmode_match);
243-
244-
put_device(port_dev);
245-
246-
if (!altmode_dev)
247-
return ERR_PTR(-ENODEV);
248-
249-
altmode = to_altmode(to_typec_altmode(altmode_dev));
250-
251-
/* Register notifier */
252-
ret = blocking_notifier_chain_register(&altmode->nh, nb);
253-
if (ret) {
254-
put_device(altmode_dev);
255-
return ERR_PTR(ret);
256-
}
257-
258-
return &altmode->adev;
259-
}
260-
EXPORT_SYMBOL_GPL(typec_altmode_register_notifier);
261-
262-
void typec_altmode_unregister_notifier(struct typec_altmode *adev,
263-
struct notifier_block *nb)
264-
{
265-
struct altmode *altmode = to_altmode(adev);
266-
267-
blocking_notifier_chain_unregister(&altmode->nh, nb);
268-
put_device(&adev->dev);
269-
}
270-
EXPORT_SYMBOL_GPL(typec_altmode_unregister_notifier);
271-
272209
/**
273210
* typec_altmode_update_active - Report Enter/Exit mode
274211
* @adev: Handle to the alternate mode
@@ -538,9 +475,7 @@ typec_register_altmode(struct device *parent,
538475
dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id);
539476

540477
/* Link partners and plugs with the ports */
541-
if (is_port)
542-
BLOCKING_INIT_NOTIFIER_HEAD(&alt->nh);
543-
else
478+
if (!is_port)
544479
typec_altmode_set_partner(alt);
545480

546481
/* The partners are bind to drivers */

‎include/linux/usb/typec_altmode.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,6 @@ void typec_altmode_put_plug(struct typec_altmode *plug);
126126
struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes,
127127
size_t n, u16 svid, u8 mode);
128128

129-
struct typec_altmode *
130-
typec_altmode_register_notifier(struct device *dev, u16 svid, u8 mode,
131-
struct notifier_block *nb);
132-
133-
void typec_altmode_unregister_notifier(struct typec_altmode *adev,
134-
struct notifier_block *nb);
135-
136129
/**
137130
* typec_altmode_get_orientation - Get cable plug orientation
138131
* altmode: Handle to the alternate mode

0 commit comments

Comments
 (0)