Subject: [PATCH 004/004] USB: serial: sierra driver interface blacklisting From: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> The following is summary of changes we have made to sierra.c driver in [PATCH 004/004] dealing with interface blacklisting support: - Modified sierra_probe() and sierra_calc_interface() to handle blacklisted interfaces accordingly - Added data list structure and function to support blacklisting - Improved comments in id_table Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> --- drivers/usb/serial/sierra.c | 45 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) --- a/drivers/usb/serial/sierra.c 2009-05-01 13:17:14.000000000 -0700 +++ b/drivers/usb/serial/sierra.c 2009-05-01 17:30:05.000000000 -0700 @@ -47,6 +47,12 @@ static int debug; static int nmea; +/* list of interface numbers - used for constructing interface blacklists */ +struct list { + const u32 listlen; /* number of interface numbers on list */ + const u8 *list; /* pointer to the array holding the numbers */ +}; + static int sierra_set_power_state(struct usb_device *udev, __u16 swiState) { int result; @@ -97,6 +103,22 @@ static int sierra_calc_num_ports(struct return num_ports; } +static int is_blacklisted(const u8 ifnum, const struct list *blacklist) +{ + const u8 *list; + int i; + + if (blacklist) { + list = blacklist->list; + + for (i = 0; i < blacklist->listlen; i++) { + if (list[i] == ifnum) + return 1; + } + } + return 0; +} + static int sierra_calc_interface(struct usb_serial *serial) { int interface; @@ -140,9 +162,24 @@ static int sierra_probe(struct usb_seria 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 list *)id->driver_info)) { + dev_dbg(&serial->dev->dev, + "Ignoring blacklisted interface #%d\n", ifnum); + return -ENODEV; + } + return result; } +static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9 }; +static const struct list direct_ip_interface_blacklist = { + .listlen = ARRAY_SIZE(direct_ip_non_serial_ifaces), + .list = direct_ip_non_serial_ifaces, +}; + static struct usb_device_id id_table [] = { { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ @@ -175,9 +212,11 @@ static struct usb_device_id id_table [] { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */ { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ - { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ - { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ - { USB_DEVICE(0x1199, 0x683E) }, /* Sierra Wireless MC8790 */ + /* Sierra Wireless MC8790, MC8791, MC8792 Composite */ + { USB_DEVICE(0x1199, 0x683C) }, + { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8791 Composite */ + /* Sierra Wireless MC8790, MC8791, MC8792 */ + { USB_DEVICE(0x1199, 0x683E) }, { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */ { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */ { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html