diff options
author | Heikki Krogerus <heikki.krogerus@linux.intel.com> | 2018-03-02 11:20:47 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-09 09:46:18 -0800 |
commit | cf6e06cddf29722a4e54b9d66df24c381b231600 (patch) | |
tree | 527f052a6e57703685bb7d66d744c2704c56adc9 /drivers/usb/typec/tcpm.c | |
parent | ad70f937e9d0bdc580e390db3a047f9e58863b6e (diff) | |
download | linux-cf6e06cddf29722a4e54b9d66df24c381b231600.tar.gz linux-cf6e06cddf29722a4e54b9d66df24c381b231600.tar.bz2 linux-cf6e06cddf29722a4e54b9d66df24c381b231600.zip |
usb: typec: Start using ERR_PTR
In order to allow the USB Type-C Class driver take care of
things like muxes and other possible dependencies for the
port drivers, returning ERR_PTR instead of NULL from the
registration functions in case of failure.
The reason for taking over control of the muxes for example
is because handling them in the port drivers would be just
boilerplate.
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec/tcpm.c')
-rw-r--r-- | drivers/usb/typec/tcpm.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index a163ba55b061..cd48a99ee913 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -1033,7 +1033,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, break; case CMDT_RSP_ACK: /* silently drop message if we are not connected */ - if (!port->partner) + if (IS_ERR_OR_NULL(port->partner)) break; switch (cmd) { @@ -3732,8 +3732,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->port_type = tcpc->config->type; port->typec_port = typec_register_port(port->dev, &port->typec_caps); - if (!port->typec_port) { - err = -ENOMEM; + if (IS_ERR(port->typec_port)) { + err = PTR_ERR(port->typec_port); goto out_destroy_wq; } @@ -3742,15 +3742,17 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) i = 0; while (paltmode->svid && i < ARRAY_SIZE(port->port_altmode)) { - port->port_altmode[i] = - typec_port_register_altmode(port->typec_port, - paltmode); - if (!port->port_altmode[i]) { + struct typec_altmode *alt; + + alt = typec_port_register_altmode(port->typec_port, + paltmode); + if (IS_ERR(alt)) { tcpm_log(port, "%s: failed to register port alternate mode 0x%x", dev_name(dev), paltmode->svid); break; } + port->port_altmode[i] = alt; i++; paltmode++; } |