Commit 201d0a4a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB serial: cleaned up the rest of the __MOD_INC and __MOD_DEC calls...

[PATCH] USB serial: cleaned up the rest of the __MOD_INC and __MOD_DEC calls to use the new module API
parent 8f19ea83
......@@ -469,7 +469,6 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
/* lock this module before we call it,
this may, which means we must bail out, safe because we are called with BKL held */
if (serial->type->owner)
if (!try_module_get(serial->type->owner)) {
retval = -ENODEV;
goto bailout;
......@@ -485,8 +484,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
retval = usb_serial_generic_open(port, filp);
if (retval) {
port->open_count = 0;
if (serial->type->owner)
__MOD_DEC_USE_COUNT(serial->type->owner);
module_put(serial->type->owner);
}
}
bailout:
......@@ -513,8 +511,7 @@ static void __serial_close(struct usb_serial_port *port, struct file *filp)
port->open_count = 0;
}
if (port->serial->type->owner)
__MOD_DEC_USE_COUNT(port->serial->type->owner);
module_put(port->serial->type->owner);
}
static void serial_close(struct tty_struct *tty, struct file * filp)
......@@ -904,11 +901,13 @@ int usb_serial_probe(struct usb_interface *interface,
/* if this device type has a probe function, call it */
if (type->probe) {
if (type->owner)
__MOD_INC_USE_COUNT(type->owner);
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
kfree (serial);
return -EIO;
}
retval = type->probe (serial);
if (type->owner)
__MOD_DEC_USE_COUNT(type->owner);
module_put(type->owner);
if (retval < 0) {
dbg ("sub driver rejected device");
......@@ -1001,11 +1000,13 @@ int usb_serial_probe(struct usb_interface *interface,
if (!num_ports) {
/* if this device type has a calc_num_ports function, call it */
if (type->calc_num_ports) {
if (type->owner)
__MOD_INC_USE_COUNT(type->owner);
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
kfree (serial);
return -EIO;
}
num_ports = type->calc_num_ports (serial);
if (type->owner)
__MOD_DEC_USE_COUNT(type->owner);
module_put(type->owner);
}
if (!num_ports)
num_ports = type->num_ports;
......@@ -1115,11 +1116,12 @@ int usb_serial_probe(struct usb_interface *interface,
/* if this device type has an attach function, call it */
if (type->attach) {
if (type->owner)
__MOD_INC_USE_COUNT(type->owner);
if (!try_module_get(type->owner)) {
err ("module get failed, exiting");
goto probe_error;
}
retval = type->attach (serial);
if (type->owner)
__MOD_DEC_USE_COUNT(type->owner);
module_put(type->owner);
if (retval < 0)
goto probe_error;
if (retval > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment