usb: typec: altmode: Remove the notification chain
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Tue, 11 Feb 2020 11:25:30 +0000 (14:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 Feb 2020 18:51:21 +0000 (10:51 -0800)
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>
Documentation/driver-api/usb/typec_bus.rst
drivers/usb/typec/bus.c
drivers/usb/typec/bus.h
drivers/usb/typec/class.c
include/linux/usb/typec_altmode.h

index f47a69b..03dfa9c 100644 (file)
@@ -53,9 +53,7 @@ in need to reconfigure the pins on the connector, the alternate mode driver
 needs to notify the bus using :c:func:`typec_altmode_notify()`. The driver
 passes the negotiated SVID specific pin configuration value to the function as
 parameter. The bus driver will then configure the mux behind the connector using
-that value as the state value for the mux, and also call blocking notification
-chain to notify the external drivers about the state of the connector that need
-to know it.
+that value as the state value for the mux.
 
 NOTE: The SVID specific pin configuration values must always start from
 ``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::
 #define ALTMODEX_CONF_A = TYPEC_MODAL_STATE(0);
 #define ALTMODEX_CONF_B = TYPEC_MODAL_STATE(1);
 
-Notification chain
-~~~~~~~~~~~~~~~~~~
-
-The drivers for the components that the alternate modes are designed for need to
-get details regarding the results of the negotiation with the partner, and the
-pin configuration of the connector. In case of DisplayPort alternate mode for
-example, the GPU drivers will need to know those details. In case of
-Thunderbolt alternate mode, the thunderbolt drivers will need to know them, and
-so on.
-
-The notification chain is designed for this purpose. The drivers can register
-notifiers with :c:func:`typec_altmode_register_notifier()`.
-
 Cable plug alternate modes
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -129,8 +114,3 @@ Cable Plug operations
 
 .. kernel-doc:: drivers/usb/typec/bus.c
    :functions: typec_altmode_get_plug typec_altmode_put_plug
-
-Notifications
-~~~~~~~~~~~~~
-.. kernel-doc:: drivers/usb/typec/class.c
-   :functions: typec_altmode_register_notifier typec_altmode_unregister_notifier
index 2e45eb4..c823122 100644 (file)
@@ -30,17 +30,10 @@ static int typec_altmode_set_state(struct typec_altmode *adev,
 {
        bool is_port = is_typec_port(adev->dev.parent);
        struct altmode *port_altmode;
-       int ret;
 
        port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner;
 
-       ret = typec_altmode_set_mux(port_altmode, conf, data);
-       if (ret)
-               return ret;
-
-       blocking_notifier_call_chain(&port_altmode->nh, conf, NULL);
-
-       return 0;
+       return typec_altmode_set_mux(port_altmode, conf, data);
 }
 
 /* -------------------------------------------------------------------------- */
@@ -82,9 +75,6 @@ int typec_altmode_notify(struct typec_altmode *adev,
        if (ret)
                return ret;
 
-       blocking_notifier_call_chain(is_port ? &altmode->nh : &partner->nh,
-                                    conf, data);
-
        if (partner->adev.ops && partner->adev.ops->notify)
                return partner->adev.ops->notify(&partner->adev, conf, data);
 
index 0c9661c..8ba8112 100644 (file)
@@ -22,8 +22,6 @@ struct altmode {
 
        struct altmode                  *partner;
        struct altmode                  *plug[2];
-
-       struct blocking_notifier_head   nh;
 };
 
 #define to_altmode(d) container_of(d, struct altmode, adev)
index 9cf4f6d..12be5bb 100644 (file)
@@ -206,69 +206,6 @@ static void typec_altmode_put_partner(struct altmode *altmode)
        put_device(&adev->dev);
 }
 
-static void *typec_port_match(struct device_connection *con, int ep, void *data)
-{
-       struct device *dev;
-
-       /*
-        * FIXME: Check does the fwnode supports the requested SVID. If it does
-        * we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
-        */
-       if (con->fwnode)
-               return class_find_device_by_fwnode(typec_class, con->fwnode);
-
-       dev = class_find_device_by_name(typec_class, con->endpoint[ep]);
-
-       return dev ? dev : ERR_PTR(-EPROBE_DEFER);
-}
-
-struct typec_altmode *
-typec_altmode_register_notifier(struct device *dev, u16 svid, u8 mode,
-                               struct notifier_block *nb)
-{
-       struct typec_device_id id = { svid, mode, };
-       struct device *altmode_dev;
-       struct device *port_dev;
-       struct altmode *altmode;
-       int ret;
-
-       /* Find the port linked to the caller */
-       port_dev = device_connection_find_match(dev, NULL, NULL,
-                                               typec_port_match);
-       if (IS_ERR_OR_NULL(port_dev))
-               return port_dev ? ERR_CAST(port_dev) : ERR_PTR(-ENODEV);
-
-       /* Find the altmode with matching svid */
-       altmode_dev = device_find_child(port_dev, &id, altmode_match);
-
-       put_device(port_dev);
-
-       if (!altmode_dev)
-               return ERR_PTR(-ENODEV);
-
-       altmode = to_altmode(to_typec_altmode(altmode_dev));
-
-       /* Register notifier */
-       ret = blocking_notifier_chain_register(&altmode->nh, nb);
-       if (ret) {
-               put_device(altmode_dev);
-               return ERR_PTR(ret);
-       }
-
-       return &altmode->adev;
-}
-EXPORT_SYMBOL_GPL(typec_altmode_register_notifier);
-
-void typec_altmode_unregister_notifier(struct typec_altmode *adev,
-                                      struct notifier_block *nb)
-{
-       struct altmode *altmode = to_altmode(adev);
-
-       blocking_notifier_chain_unregister(&altmode->nh, nb);
-       put_device(&adev->dev);
-}
-EXPORT_SYMBOL_GPL(typec_altmode_unregister_notifier);
-
 /**
  * typec_altmode_update_active - Report Enter/Exit mode
  * @adev: Handle to the alternate mode
@@ -538,9 +475,7 @@ typec_register_altmode(struct device *parent,
        dev_set_name(&alt->adev.dev, "%s.%u", dev_name(parent), id);
 
        /* Link partners and plugs with the ports */
-       if (is_port)
-               BLOCKING_INIT_NOTIFIER_HEAD(&alt->nh);
-       else
+       if (!is_port)
                typec_altmode_set_partner(alt);
 
        /* The partners are bind to drivers */
index 923ff3a..d834e23 100644 (file)
@@ -126,13 +126,6 @@ void typec_altmode_put_plug(struct typec_altmode *plug);
 struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes,
                                          size_t n, u16 svid, u8 mode);
 
-struct typec_altmode *
-typec_altmode_register_notifier(struct device *dev, u16 svid, u8 mode,
-                               struct notifier_block *nb);
-
-void typec_altmode_unregister_notifier(struct typec_altmode *adev,
-                                      struct notifier_block *nb);
-
 /**
  * typec_altmode_get_orientation - Get cable plug orientation
  * altmode: Handle to the alternate mode