Skip to content

Commit 16620b4

Browse files
committed
USB: serial: sierra: fix bogus alternate-setting assumption
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 <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent a6bb1e1 commit 16620b4

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

drivers/usb/serial/sierra.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,9 @@ static int is_himemory(const u8 ifnum,
137137
return 0;
138138
}
139139

140-
static int sierra_calc_interface(struct usb_serial *serial)
140+
static u8 sierra_interface_num(struct usb_serial *serial)
141141
{
142-
int interface;
143-
struct usb_interface *p_interface;
144-
struct usb_host_interface *p_host_interface;
145-
146-
/* Get the interface structure pointer from the serial struct */
147-
p_interface = serial->interface;
148-
149-
/* Get a pointer to the host interface structure */
150-
p_host_interface = p_interface->cur_altsetting;
151-
152-
/* read the interface descriptor for this active altsetting
153-
* to find out the interface number we are on
154-
*/
155-
interface = p_host_interface->desc.bInterfaceNumber;
156-
157-
return interface;
142+
return serial->interface->cur_altsetting->desc.bInterfaceNumber;
158143
}
159144

160145
static int sierra_probe(struct usb_serial *serial,
@@ -165,7 +150,7 @@ static int sierra_probe(struct usb_serial *serial,
165150
u8 ifnum;
166151

167152
udev = serial->dev;
168-
ifnum = sierra_calc_interface(serial);
153+
ifnum = sierra_interface_num(serial);
169154

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

181-
/* ifnum could have changed - by calling usb_set_interface */
182-
ifnum = sierra_calc_interface(serial);
183-
184166
if (is_blacklisted(ifnum,
185167
(struct sierra_iface_info *)id->driver_info)) {
186168
dev_dbg(&serial->dev->dev,
@@ -342,7 +324,7 @@ static int sierra_send_setup(struct usb_serial_port *port)
342324

343325
/* If composite device then properly report interface */
344326
if (serial->num_ports == 1) {
345-
interface = sierra_calc_interface(serial);
327+
interface = sierra_interface_num(serial);
346328
/* Control message is sent only to interfaces with
347329
* interrupt_in endpoints
348330
*/
@@ -916,7 +898,7 @@ static int sierra_port_probe(struct usb_serial_port *port)
916898
/* Determine actual memory requirements */
917899
if (serial->num_ports == 1) {
918900
/* Get interface number for composite device */
919-
ifnum = sierra_calc_interface(serial);
901+
ifnum = sierra_interface_num(serial);
920902
himemoryp = &typeB_interface_list;
921903
} else {
922904
/* This is really the usb-serial port number of the interface

0 commit comments

Comments
 (0)