Skip to content

Commit

Permalink
USB: serial: sierra: fix bogus alternate-setting assumption
Browse files Browse the repository at this point in the history
Interface numbers do not change when enabling alternate settings as
comment and code in this driver suggested.

Remove the confusing comment and redundant retrieval of the interface
number in probe, while simplifying and renaming the interface-number
helper.

Fixes: 4db2299 ("sierra: driver interface blacklisting")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Johan Hovold committed Feb 6, 2017
1 parent a6bb1e1 commit 16620b4
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions drivers/usb/serial/sierra.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,9 @@ static int is_himemory(const u8 ifnum,
return 0;
}

static int sierra_calc_interface(struct usb_serial *serial)
static u8 sierra_interface_num(struct usb_serial *serial)
{
int interface;
struct usb_interface *p_interface;
struct usb_host_interface *p_host_interface;

/* Get the interface structure pointer from the serial struct */
p_interface = serial->interface;

/* Get a pointer to the host interface structure */
p_host_interface = p_interface->cur_altsetting;

/* read the interface descriptor for this active altsetting
* to find out the interface number we are on
*/
interface = p_host_interface->desc.bInterfaceNumber;

return interface;
return serial->interface->cur_altsetting->desc.bInterfaceNumber;
}

static int sierra_probe(struct usb_serial *serial,
Expand All @@ -165,7 +150,7 @@ static int sierra_probe(struct usb_serial *serial,
u8 ifnum;

udev = serial->dev;
ifnum = sierra_calc_interface(serial);
ifnum = sierra_interface_num(serial);

/*
* If this interface supports more than 1 alternate
Expand All @@ -178,9 +163,6 @@ static int sierra_probe(struct usb_serial *serial,
usb_set_interface(udev, ifnum, 1);
}

/* ifnum could have changed - by calling usb_set_interface */
ifnum = sierra_calc_interface(serial);

if (is_blacklisted(ifnum,
(struct sierra_iface_info *)id->driver_info)) {
dev_dbg(&serial->dev->dev,
Expand Down Expand Up @@ -342,7 +324,7 @@ static int sierra_send_setup(struct usb_serial_port *port)

/* If composite device then properly report interface */
if (serial->num_ports == 1) {
interface = sierra_calc_interface(serial);
interface = sierra_interface_num(serial);
/* Control message is sent only to interfaces with
* interrupt_in endpoints
*/
Expand Down Expand Up @@ -916,7 +898,7 @@ static int sierra_port_probe(struct usb_serial_port *port)
/* Determine actual memory requirements */
if (serial->num_ports == 1) {
/* Get interface number for composite device */
ifnum = sierra_calc_interface(serial);
ifnum = sierra_interface_num(serial);
himemoryp = &typeB_interface_list;
} else {
/* This is really the usb-serial port number of the interface
Expand Down

0 comments on commit 16620b4

Please sign in to comment.