USB: serial: drop bogus to_usb_serial_port() checks
authorJohan Hovold <johan@kernel.org>
Mon, 8 Feb 2021 15:48:06 +0000 (16:48 +0100)
committerJohan Hovold <johan@kernel.org>
Tue, 9 Feb 2021 12:14:30 +0000 (13:14 +0100)
The to_usb_serial_port() macro is implemented using container_of() so
there's no need to check for NULL.

Note that neither bus match() or probe() is ever called with a NULL
struct device pointer so the checks weren't just misplaced.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/bus.c

index 1a8c782..7133818 100644 (file)
 static int usb_serial_device_match(struct device *dev,
                                                struct device_driver *drv)
 {
-       struct usb_serial_driver *driver;
-       const struct usb_serial_port *port;
+       const struct usb_serial_port *port = to_usb_serial_port(dev);
+       struct usb_serial_driver *driver = to_usb_serial_driver(drv);
 
        /*
         * drivers are already assigned to ports in serial_probe so it's
         * a simple check here.
         */
-       port = to_usb_serial_port(dev);
-       if (!port)
-               return 0;
-
-       driver = to_usb_serial_driver(drv);
-
        if (driver == port->serial->type)
                return 1;
 
@@ -37,16 +31,12 @@ static int usb_serial_device_match(struct device *dev,
 
 static int usb_serial_device_probe(struct device *dev)
 {
+       struct usb_serial_port *port = to_usb_serial_port(dev);
        struct usb_serial_driver *driver;
-       struct usb_serial_port *port;
        struct device *tty_dev;
        int retval = 0;
        int minor;
 
-       port = to_usb_serial_port(dev);
-       if (!port)
-               return -ENODEV;
-
        /* make sure suspend/resume doesn't race against port_probe */
        retval = usb_autopm_get_interface(port->serial->interface);
        if (retval)