USB: serial: add probe callback to generic driver
authorJohan Hovold <johan@kernel.org>
Thu, 16 Mar 2017 16:13:31 +0000 (17:13 +0100)
committerJohan Hovold <johan@kernel.org>
Tue, 28 Mar 2017 08:54:39 +0000 (10:54 +0200)
Add a probe callback to the generic driver and print the
only-for-testing message there.

This is a first step in getting rid of the CONFIG_USB_SERIAL_GENERIC
ifdef from usb-serial core.

Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/generic.c
drivers/usb/serial/usb-serial.c

index 49ce2be90fa00e5b4305784f2532e34069752072..8c7600472019ef0f8ea3a886437778c0e8c321a9 100644 (file)
@@ -37,6 +37,17 @@ MODULE_PARM_DESC(product, "User specified USB idProduct");
 
 static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
 
+static int usb_serial_generic_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id)
+{
+       struct device *dev = &serial->interface->dev;
+
+       dev_info(dev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n");
+       dev_info(dev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n");
+
+       return 0;
+}
+
 struct usb_serial_driver usb_serial_generic_device = {
        .driver = {
                .owner =        THIS_MODULE,
@@ -44,6 +55,7 @@ struct usb_serial_driver usb_serial_generic_device = {
        },
        .id_table =             generic_device_ids,
        .num_ports =            1,
+       .probe =                usb_serial_generic_probe,
        .throttle =             usb_serial_generic_throttle,
        .unthrottle =           usb_serial_generic_unthrottle,
        .resume =               usb_serial_generic_resume,
index f0761f491c5f393480653637fe0195dea2d90250..f8ae09e2cff5897174740b1f13cfb1a9a1bfa887 100644 (file)
@@ -858,8 +858,6 @@ static int usb_serial_probe(struct usb_interface *interface,
                        retval = -EIO;
                        goto err_free_epds;
                }
-               dev_info(ddev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n");
-               dev_info(ddev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n");
        }
 #endif
        if (!num_ports) {