소스 검색

USB: serial: fix interface data use

The interface data should not be used as a flag to signal disconnect.

Now that all serial drivers use the usb_serial disconnect flag and
mutex, we can set the interface data prior to registering the ports and
there's no need to clear it at disconnect.

This should hopefully also make it more clear that the interface data is
not a flag, which could prevent future misuse.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Johan Hovold 13 년 전
부모
커밋
bdce6612a0
1개의 변경된 파일2개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 4
      drivers/usb/serial/usb-serial.c

+ 2 - 4
drivers/usb/serial/usb-serial.c

@@ -1043,6 +1043,8 @@ int usb_serial_probe(struct usb_interface *interface,
 		dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
 		dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
 	}
 	}
 
 
+	usb_set_intfdata(interface, serial);
+
 	/* if this device type has an attach function, call it */
 	/* if this device type has an attach function, call it */
 	if (type->attach) {
 	if (type->attach) {
 		retval = type->attach(serial);
 		retval = type->attach(serial);
@@ -1087,10 +1089,7 @@ int usb_serial_probe(struct usb_interface *interface,
 	serial->disconnected = 0;
 	serial->disconnected = 0;
 
 
 	usb_serial_console_init(debug, minor);
 	usb_serial_console_init(debug, minor);
-
 exit:
 exit:
-	/* success */
-	usb_set_intfdata(interface, serial);
 	module_put(type->driver.owner);
 	module_put(type->driver.owner);
 	return 0;
 	return 0;
 
 
@@ -1112,7 +1111,6 @@ void usb_serial_disconnect(struct usb_interface *interface)
 	dbg("%s", __func__);
 	dbg("%s", __func__);
 
 
 	mutex_lock(&serial->disc_mutex);
 	mutex_lock(&serial->disc_mutex);
-	usb_set_intfdata(interface, NULL);
 	/* must set a flag, to signal subdrivers */
 	/* must set a flag, to signal subdrivers */
 	serial->disconnected = 1;
 	serial->disconnected = 1;
 	mutex_unlock(&serial->disc_mutex);
 	mutex_unlock(&serial->disc_mutex);