Skip to content

Commit

Permalink
USB: serial: ftdi_sio: clean up jtag quirks
Browse files Browse the repository at this point in the history
Drivers should not assume that interface descriptors have been parsed in
any particular order so match on interface number instead when rejecting
JTAG interfaces.

Also use the interface struct device for notifications so that the
interface number is included.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Johan Hovold committed Oct 1, 2020
1 parent 031f966 commit 75240ac
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2335,12 +2335,11 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
*/
static int ftdi_jtag_probe(struct usb_serial *serial)
{
struct usb_device *udev = serial->dev;
struct usb_interface *interface = serial->interface;
struct usb_interface *intf = serial->interface;
int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;

if (interface == udev->actconfig->interface[0]) {
dev_info(&udev->dev,
"Ignoring serial port reserved for JTAG\n");
if (ifnum == 0) {
dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n");
return -ENODEV;
}

Expand Down Expand Up @@ -2372,12 +2371,11 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
*/
static int ftdi_stmclite_probe(struct usb_serial *serial)
{
struct usb_device *udev = serial->dev;
struct usb_interface *interface = serial->interface;
struct usb_interface *intf = serial->interface;
int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;

if (interface == udev->actconfig->interface[0] ||
interface == udev->actconfig->interface[1]) {
dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
if (ifnum < 2) {
dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n");
return -ENODEV;
}

Expand Down

0 comments on commit 75240ac

Please sign in to comment.