aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.com>2016-07-14 09:41:34 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-07-18 11:46:57 -0400
commitcb42b63d893d8d22d1739ddea0d86b10fd921aac (patch)
treeca3f76973e12823a6f1b96d19739390a82501c6f
parent7fae7bfb9a58ae66a29a6017abb7f62d2eb971e2 (diff)
cdc-acm: beautify probe()
This removes some overly long lines by renaming variables and giving them local scope. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/class/cdc-acm.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 2e5dea866b6f..71912301ef7f 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1146,8 +1146,7 @@ static int acm_probe(struct usb_interface *intf,
1146 const struct usb_device_id *id) 1146 const struct usb_device_id *id)
1147{ 1147{
1148 struct usb_cdc_union_desc *union_header = NULL; 1148 struct usb_cdc_union_desc *union_header = NULL;
1149 struct usb_cdc_country_functional_desc *cfd = NULL; 1149 struct usb_cdc_call_mgmt_descriptor *cmgmd = NULL;
1150 struct usb_cdc_call_mgmt_descriptor *cmd = NULL;
1151 unsigned char *buffer = intf->altsetting->extra; 1150 unsigned char *buffer = intf->altsetting->extra;
1152 int buflen = intf->altsetting->extralen; 1151 int buflen = intf->altsetting->extralen;
1153 struct usb_interface *control_interface; 1152 struct usb_interface *control_interface;
@@ -1156,13 +1155,13 @@ static int acm_probe(struct usb_interface *intf,
1156 struct usb_endpoint_descriptor *epread = NULL; 1155 struct usb_endpoint_descriptor *epread = NULL;
1157 struct usb_endpoint_descriptor *epwrite = NULL; 1156 struct usb_endpoint_descriptor *epwrite = NULL;
1158 struct usb_device *usb_dev = interface_to_usbdev(intf); 1157 struct usb_device *usb_dev = interface_to_usbdev(intf);
1159 struct usb_cdc_parsed_header hdr; 1158 struct usb_cdc_parsed_header h;
1160 struct acm *acm; 1159 struct acm *acm;
1161 int minor; 1160 int minor;
1162 int ctrlsize, readsize; 1161 int ctrlsize, readsize;
1163 u8 *buf; 1162 u8 *buf;
1164 int call_interface_num = -1; 1163 int call_intf_num = -1;
1165 int data_interface_num = -1; 1164 int data_intf_num = -1;
1166 unsigned long quirks; 1165 unsigned long quirks;
1167 int num_rx_buf; 1166 int num_rx_buf;
1168 int i; 1167 int i;
@@ -1209,20 +1208,22 @@ static int acm_probe(struct usb_interface *intf,
1209 } 1208 }
1210 } 1209 }
1211 1210
1212 cdc_parse_cdc_header(&hdr, intf, buffer, buflen); 1211 cdc_parse_cdc_header(&h, intf, buffer, buflen);
1213 union_header = hdr.usb_cdc_union_desc; 1212 union_header = h.usb_cdc_union_desc;
1214 cmd = hdr.usb_cdc_call_mgmt_descriptor; 1213 cmgmd = h.usb_cdc_call_mgmt_descriptor;
1215 if (cmd) 1214 if (cmgmd)
1216 call_interface_num = cmd->bDataInterface; 1215 call_intf_num = cmgmd->bDataInterface;
1217 1216
1218 if (!union_header) { 1217 if (!union_header) {
1219 if (call_interface_num > 0) { 1218 if (call_intf_num > 0) {
1220 dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n"); 1219 dev_dbg(&intf->dev, "No union descriptor, using call management descriptor\n");
1221 /* quirks for Droids MuIn LCD */ 1220 /* quirks for Droids MuIn LCD */
1222 if (quirks & NO_DATA_INTERFACE) 1221 if (quirks & NO_DATA_INTERFACE) {
1223 data_interface = usb_ifnum_to_if(usb_dev, 0); 1222 data_interface = usb_ifnum_to_if(usb_dev, 0);
1224 else 1223 } else {
1225 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = call_interface_num)); 1224 data_intf_num = call_intf_num;
1225 data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
1226 }
1226 control_interface = intf; 1227 control_interface = intf;
1227 } else { 1228 } else {
1228 if (intf->cur_altsetting->desc.bNumEndpoints != 3) { 1229 if (intf->cur_altsetting->desc.bNumEndpoints != 3) {
@@ -1236,8 +1237,9 @@ static int acm_probe(struct usb_interface *intf,
1236 } 1237 }
1237 } 1238 }
1238 } else { 1239 } else {
1240 data_intf_num = union_header->bSlaveInterface0;
1239 control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0); 1241 control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
1240 data_interface = usb_ifnum_to_if(usb_dev, (data_interface_num = union_header->bSlaveInterface0)); 1242 data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
1241 } 1243 }
1242 1244
1243 if (!control_interface || !data_interface) { 1245 if (!control_interface || !data_interface) {
@@ -1245,7 +1247,7 @@ static int acm_probe(struct usb_interface *intf,
1245 return -ENODEV; 1247 return -ENODEV;
1246 } 1248 }
1247 1249
1248 if (data_interface_num != call_interface_num) 1250 if (data_intf_num != call_intf_num)
1249 dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n"); 1251 dev_dbg(&intf->dev, "Separate call control interface. That is not fully supported.\n");
1250 1252
1251 if (control_interface == data_interface) { 1253 if (control_interface == data_interface) {
@@ -1340,8 +1342,8 @@ made_compressed_probe:
1340 acm->data = data_interface; 1342 acm->data = data_interface;
1341 acm->minor = minor; 1343 acm->minor = minor;
1342 acm->dev = usb_dev; 1344 acm->dev = usb_dev;
1343 if (hdr.usb_cdc_acm_descriptor) 1345 if (h.usb_cdc_acm_descriptor)
1344 acm->ctrl_caps = hdr.usb_cdc_acm_descriptor->bmCapabilities; 1346 acm->ctrl_caps = h.usb_cdc_acm_descriptor->bmCapabilities;
1345 if (quirks & NO_CAP_LINE) 1347 if (quirks & NO_CAP_LINE)
1346 acm->ctrl_caps &= ~USB_CDC_CAP_LINE; 1348 acm->ctrl_caps &= ~USB_CDC_CAP_LINE;
1347 acm->ctrlsize = ctrlsize; 1349 acm->ctrlsize = ctrlsize;
@@ -1435,8 +1437,10 @@ made_compressed_probe:
1435 if (i < 0) 1437 if (i < 0)
1436 goto alloc_fail7; 1438 goto alloc_fail7;
1437 1439
1438 cfd = hdr.usb_cdc_country_functional_desc; 1440 if (h.usb_cdc_country_functional_desc) { /* export the country data */
1439 if (cfd) { /* export the country data */ 1441 struct usb_cdc_country_functional_desc * cfd =
1442 h.usb_cdc_country_functional_desc;
1443
1440 acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL); 1444 acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
1441 if (!acm->country_codes) 1445 if (!acm->country_codes)
1442 goto skip_countries; 1446 goto skip_countries;