diff options
Diffstat (limited to 'drivers/usb/serial/sierra.c')
-rw-r--r-- | drivers/usb/serial/sierra.c | 88 |
1 files changed, 34 insertions, 54 deletions
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index a43263a0edd8..57fc3c31712e 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c @@ -45,10 +45,9 @@ static bool nmea; -/* Used in interface blacklisting */ -struct sierra_iface_info { - const u32 infolen; /* number of interface numbers on blacklist */ - const u8 *ifaceinfo; /* pointer to the array holding the numbers */ +struct sierra_iface_list { + const u8 *nums; /* array of interface numbers */ + size_t count; /* number of elements in array */ }; struct sierra_intf_private { @@ -101,38 +100,19 @@ static int sierra_calc_num_ports(struct usb_serial *serial, return num_ports; } -static int is_blacklisted(const u8 ifnum, - const struct sierra_iface_info *blacklist) +static bool is_listed(const u8 ifnum, const struct sierra_iface_list *list) { - const u8 *info; int i; - if (blacklist) { - info = blacklist->ifaceinfo; + if (!list) + return false; - for (i = 0; i < blacklist->infolen; i++) { - if (info[i] == ifnum) - return 1; - } + for (i = 0; i < list->count; i++) { + if (list->nums[i] == ifnum) + return true; } - return 0; -} - -static int is_himemory(const u8 ifnum, - const struct sierra_iface_info *himemorylist) -{ - const u8 *info; - int i; - if (himemorylist) { - info = himemorylist->ifaceinfo; - - for (i=0; i < himemorylist->infolen; i++) { - if (info[i] == ifnum) - return 1; - } - } - return 0; + return false; } static u8 sierra_interface_num(struct usb_serial *serial) @@ -143,6 +123,7 @@ static u8 sierra_interface_num(struct usb_serial *serial) static int sierra_probe(struct usb_serial *serial, const struct usb_device_id *id) { + const struct sierra_iface_list *ignore_list; int result = 0; struct usb_device *udev; u8 ifnum; @@ -161,10 +142,10 @@ static int sierra_probe(struct usb_serial *serial, usb_set_interface(udev, ifnum, 1); } - if (is_blacklisted(ifnum, - (struct sierra_iface_info *)id->driver_info)) { - dev_dbg(&serial->dev->dev, - "Ignoring blacklisted interface #%d\n", ifnum); + ignore_list = (const struct sierra_iface_list *)id->driver_info; + + if (is_listed(ifnum, ignore_list)) { + dev_dbg(&serial->dev->dev, "Ignoring interface #%d\n", ifnum); return -ENODEV; } @@ -173,22 +154,22 @@ static int sierra_probe(struct usb_serial *serial, /* interfaces with higher memory requirements */ static const u8 hi_memory_typeA_ifaces[] = { 0, 2 }; -static const struct sierra_iface_info typeA_interface_list = { - .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces), - .ifaceinfo = hi_memory_typeA_ifaces, +static const struct sierra_iface_list typeA_interface_list = { + .nums = hi_memory_typeA_ifaces, + .count = ARRAY_SIZE(hi_memory_typeA_ifaces), }; static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 }; -static const struct sierra_iface_info typeB_interface_list = { - .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces), - .ifaceinfo = hi_memory_typeB_ifaces, +static const struct sierra_iface_list typeB_interface_list = { + .nums = hi_memory_typeB_ifaces, + .count = ARRAY_SIZE(hi_memory_typeB_ifaces), }; -/* 'blacklist' of interfaces not served by this driver */ +/* 'ignorelist' of interfaces not served by this driver */ static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 }; -static const struct sierra_iface_info direct_ip_interface_blacklist = { - .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), - .ifaceinfo = direct_ip_non_serial_ifaces, +static const struct sierra_iface_list direct_ip_interface_ignore = { + .nums = direct_ip_non_serial_ifaces, + .count = ARRAY_SIZE(direct_ip_non_serial_ifaces), }; static const struct usb_device_id id_table[] = { @@ -264,19 +245,19 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */ /* Sierra Wireless Direct IP modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */ /* AT&T Direct IP LTE modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, /* Airprime/Sierra Wireless Direct IP modems */ { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF), - .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist + .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore }, { } @@ -589,8 +570,7 @@ static void sierra_instat_callback(struct urb *urb) urb, port, portdata); if (status == 0) { - struct usb_ctrlrequest *req_pkt = - (struct usb_ctrlrequest *)urb->transfer_buffer; + struct usb_ctrlrequest *req_pkt = urb->transfer_buffer; if (!req_pkt) { dev_dbg(&port->dev, "%s: NULL req_pkt\n", @@ -879,7 +859,7 @@ static int sierra_port_probe(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; struct sierra_port_private *portdata; - const struct sierra_iface_info *himemoryp; + const struct sierra_iface_list *himemory_list; u8 ifnum; portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); @@ -898,16 +878,16 @@ static int sierra_port_probe(struct usb_serial_port *port) if (serial->num_ports == 1) { /* Get interface number for composite device */ ifnum = sierra_interface_num(serial); - himemoryp = &typeB_interface_list; + himemory_list = &typeB_interface_list; } else { /* This is really the usb-serial port number of the interface * rather than the interface number. */ ifnum = port->port_number; - himemoryp = &typeA_interface_list; + himemory_list = &typeA_interface_list; } - if (is_himemory(ifnum, himemoryp)) { + if (is_listed(ifnum, himemory_list)) { portdata->num_out_urbs = N_OUT_URB_HM; portdata->num_in_urbs = N_IN_URB_HM; } |