Commit 2cf69930 authored by Bjørn Mork's avatar Bjørn Mork Committed by Greg Kroah-Hartman

USB: qcserial: consolidate usb_set_interface calls

No need to replicate the same code all over the place.
Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2c026e2b
...@@ -127,6 +127,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -127,6 +127,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
__u8 nintf; __u8 nintf;
__u8 ifnum; __u8 ifnum;
bool is_gobi1k = id->driver_info ? true : false; bool is_gobi1k = id->driver_info ? true : false;
int altsetting = -1;
dev_dbg(dev, "Is Gobi 1000 = %d\n", is_gobi1k); dev_dbg(dev, "Is Gobi 1000 = %d\n", is_gobi1k);
...@@ -160,15 +161,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -160,15 +161,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
retval = 0; /* Success */ retval = 0; /* Success */
break; break;
} }
altsetting = 1;
retval = usb_set_interface(serial->dev, ifnum, 1);
if (retval < 0) {
dev_err(dev,
"Could not set interface, error %d\n",
retval);
retval = -ENODEV;
kfree(data);
}
} }
break; break;
...@@ -193,24 +186,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -193,24 +186,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
if (ifnum == 1 && !is_gobi1k) { if (ifnum == 1 && !is_gobi1k) {
dev_dbg(dev, "Gobi 2K+ DM/DIAG interface found\n"); dev_dbg(dev, "Gobi 2K+ DM/DIAG interface found\n");
retval = usb_set_interface(serial->dev, ifnum, 0); altsetting = 0;
if (retval < 0) {
dev_err(dev,
"Could not set interface, error %d\n",
retval);
retval = -ENODEV;
kfree(data);
}
} else if (ifnum == 2) { } else if (ifnum == 2) {
dev_dbg(dev, "Modem port found\n"); dev_dbg(dev, "Modem port found\n");
retval = usb_set_interface(serial->dev, ifnum, 0); altsetting = 0;
if (retval < 0) {
dev_err(dev,
"Could not set interface, error %d\n",
retval);
retval = -ENODEV;
kfree(data);
}
} else if (ifnum==3 && !is_gobi1k) { } else if (ifnum==3 && !is_gobi1k) {
/* /*
* NMEA (serial line 9600 8N1) * NMEA (serial line 9600 8N1)
...@@ -218,14 +197,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -218,14 +197,7 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
* # echo "\$GPS_STOP" > /dev/ttyUSBx * # echo "\$GPS_STOP" > /dev/ttyUSBx
*/ */
dev_dbg(dev, "Gobi 2K+ NMEA GPS interface found\n"); dev_dbg(dev, "Gobi 2K+ NMEA GPS interface found\n");
retval = usb_set_interface(serial->dev, ifnum, 0); altsetting = 0;
if (retval < 0) {
dev_err(dev,
"Could not set interface, error %d\n",
retval);
retval = -ENODEV;
kfree(data);
}
} }
break; break;
...@@ -235,6 +207,17 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) ...@@ -235,6 +207,17 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
retval = -ENODEV; retval = -ENODEV;
} }
if (altsetting >= 0) {
retval = usb_set_interface(serial->dev, ifnum, altsetting);
if (retval < 0) {
dev_err(dev,
"Could not set interface, error %d\n",
retval);
retval = -ENODEV;
kfree(data);
}
}
/* Set serial->private if not returning -ENODEV */ /* Set serial->private if not returning -ENODEV */
if (retval != -ENODEV) if (retval != -ENODEV)
usb_set_serial_data(serial, data); usb_set_serial_data(serial, data);
......
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