Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
bbe80c9a 684cb4b7

+3 -107
+1 -21
Documentation/driver-api/usb/typec_bus.rst
··· 53 53 needs to notify the bus using :c:func:`typec_altmode_notify()`. The driver 54 54 passes the negotiated SVID specific pin configuration value to the function as 55 55 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. 59 57 60 58 NOTE: The SVID specific pin configuration values must always start from 61 59 ``TYPEC_STATE_MODAL``. USB Type-C specification defines two default states for ··· 77 79 78 80 #define ALTMODEX_CONF_A = TYPEC_MODAL_STATE(0); 79 81 #define ALTMODEX_CONF_B = TYPEC_MODAL_STATE(1); 80 - 81 - Notification chain 82 - ~~~~~~~~~~~~~~~~~~ 83 - 84 - The drivers for the components that the alternate modes are designed for need to 85 - get details regarding the results of the negotiation with the partner, and the 86 - pin configuration of the connector. In case of DisplayPort alternate mode for 87 - example, the GPU drivers will need to know those details. In case of 88 - Thunderbolt alternate mode, the thunderbolt drivers will need to know them, and 89 - so on. 90 - 91 - The notification chain is designed for this purpose. The drivers can register 92 - notifiers with :c:func:`typec_altmode_register_notifier()`. 93 82 94 83 Cable plug alternate modes 95 84 ~~~~~~~~~~~~~~~~~~~~~~~~~~ ··· 114 129 115 130 .. kernel-doc:: drivers/usb/typec/bus.c 116 131 :functions: typec_altmode_get_plug typec_altmode_put_plug 117 - 118 - Notifications 119 - ~~~~~~~~~~~~~ 120 - .. kernel-doc:: drivers/usb/typec/class.c 121 - :functions: typec_altmode_register_notifier typec_altmode_unregister_notifier
+1 -11
drivers/usb/typec/bus.c
··· 30 30 { 31 31 bool is_port = is_typec_port(adev->dev.parent); 32 32 struct altmode *port_altmode; 33 - int ret; 34 33 35 34 port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner; 36 35 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); 44 37 } 45 38 46 39 /* -------------------------------------------------------------------------- */ ··· 74 81 ret = typec_altmode_set_mux(is_port ? altmode : partner, conf, data); 75 82 if (ret) 76 83 return ret; 77 - 78 - blocking_notifier_call_chain(is_port ? &altmode->nh : &partner->nh, 79 - conf, data); 80 84 81 85 if (partner->adev.ops && partner->adev.ops->notify) 82 86 return partner->adev.ops->notify(&partner->adev, conf, data);
-2
drivers/usb/typec/bus.h
··· 22 22 23 23 struct altmode *partner; 24 24 struct altmode *plug[2]; 25 - 26 - struct blocking_notifier_head nh; 27 25 }; 28 26 29 27 #define to_altmode(d) container_of(d, struct altmode, adev)
+1 -66
drivers/usb/typec/class.c
··· 206 206 put_device(&adev->dev); 207 207 } 208 208 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 - 272 209 /** 273 210 * typec_altmode_update_active - Report Enter/Exit mode 274 211 * @adev: Handle to the alternate mode ··· 475 538 dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id); 476 539 477 540 /* Link partners and plugs with the ports */ 478 - if (is_port) 479 - BLOCKING_INIT_NOTIFIER_HEAD(&alt->nh); 480 - else 541 + if (!is_port) 481 542 typec_altmode_set_partner(alt); 482 543 483 544 /* The partners are bind to drivers */
-7
include/linux/usb/typec_altmode.h
··· 126 126 struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes, 127 127 size_t n, u16 svid, u8 mode); 128 128 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 - 136 129 /** 137 130 * typec_altmode_get_orientation - Get cable plug orientation 138 131 * altmode: Handle to the alternate mode