From: Luiz Fernando N. Capitulino <[EMAIL PROTECTED]> Moves the driver's probe call code to its new function, this makes usb_serial_probe() simpler.
Signed-off-by: Luiz Fernando N. Capitulino <[EMAIL PROTECTED]> --- drivers/usb/serial/usb-serial.c | 52 +++++++++++++++++++++++++-------------- 1 files changed, 33 insertions(+), 19 deletions(-) 6ae74f41c94cc2d8809ca1dd4e54c6cdadc0ce09 diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index c8cd664..b43f30d 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -622,6 +622,33 @@ static int port_create_all(int max_ports return 0; } +static int driver_probe(struct usb_serial *serial, + struct usb_interface *interface) +{ + int ret; + const struct usb_device_id *id; + + dbg("%s", __FUNCTION__); + + if (!serial->type->probe) + return 0; + + if (!try_module_get(serial->type->driver.owner)) { + dev_err(&interface->dev, "%s - module get failed, exiting\n", + __FUNCTION__); + return -EIO; + } + + id = usb_match_id(interface, serial->type->id_table); + ret = serial->type->probe(serial, id); + if (ret) + dev_err(&interface->dev, "%s - driver rejected device\n", + __FUNCTION__); + + module_put(serial->type->driver.owner); + return ret; +} + int usb_serial_probe(struct usb_interface *interface, const struct usb_device_id *id) { @@ -658,25 +685,12 @@ int usb_serial_probe(struct usb_interfac return -ENOMEM; } - /* if this device type has a probe function, call it */ - if (type->probe) { - const struct usb_device_id *id; - - if (!try_module_get(type->driver.owner)) { - dev_err(&interface->dev, "module get failed, exiting\n"); - kfree (serial); - return -EIO; - } - - id = usb_match_id(interface, type->id_table); - retval = type->probe(serial, id); - module_put(type->driver.owner); - - if (retval) { - dbg ("sub driver rejected device"); - kfree (serial); - return retval; - } + retval = driver_probe(serial, interface); + if (retval) { + dev_err(&interface->dev, "%s - driver's probe method failed\n", + __FUNCTION__); + kfree(serial); + return retval; } /* descriptor matches, let's find the endpoints needed */ -- 1.3.3 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel