aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_fs.c')
-rw-r--r--drivers/usb/gadget/f_fs.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 2aaa0f75c6cf..e4f595055208 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -714,9 +714,7 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
714 struct ffs_function *func = ffs->func; 714 struct ffs_function *func = ffs->func;
715 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; 715 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV;
716 } else if (gadget->ops->ioctl) { 716 } else if (gadget->ops->ioctl) {
717 lock_kernel();
718 ret = gadget->ops->ioctl(gadget, code, value); 717 ret = gadget->ops->ioctl(gadget, code, value);
719 unlock_kernel();
720 } else { 718 } else {
721 ret = -ENOTTY; 719 ret = -ENOTTY;
722 } 720 }
@@ -1377,7 +1375,8 @@ static void ffs_data_reset(struct ffs_data *ffs)
1377 1375
1378static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) 1376static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
1379{ 1377{
1380 unsigned i, count; 1378 struct usb_gadget_strings **lang;
1379 int first_id;
1381 1380
1382 ENTER(); 1381 ENTER();
1383 1382
@@ -1385,7 +1384,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
1385 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) 1384 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags)))
1386 return -EBADFD; 1385 return -EBADFD;
1387 1386
1388 ffs_data_get(ffs); 1387 first_id = usb_string_ids_n(cdev, ffs->strings_count);
1388 if (unlikely(first_id < 0))
1389 return first_id;
1389 1390
1390 ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); 1391 ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
1391 if (unlikely(!ffs->ep0req)) 1392 if (unlikely(!ffs->ep0req))
@@ -1393,25 +1394,16 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
1393 ffs->ep0req->complete = ffs_ep0_complete; 1394 ffs->ep0req->complete = ffs_ep0_complete;
1394 ffs->ep0req->context = ffs; 1395 ffs->ep0req->context = ffs;
1395 1396
1396 /* Get strings identifiers */ 1397 lang = ffs->stringtabs;
1397 for (count = ffs->strings_count, i = 0; i < count; ++i) { 1398 for (lang = ffs->stringtabs; *lang; ++lang) {
1398 struct usb_gadget_strings **lang; 1399 struct usb_string *str = (*lang)->strings;
1399 1400 int id = first_id;
1400 int id = usb_string_id(cdev); 1401 for (; str->s; ++id, ++str)
1401 if (unlikely(id < 0)) { 1402 str->id = id;
1402 usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req);
1403 ffs->ep0req = NULL;
1404 return id;
1405 }
1406
1407 lang = ffs->stringtabs;
1408 do {
1409 (*lang)->strings[i].id = id;
1410 ++lang;
1411 } while (*lang);
1412 } 1403 }
1413 1404
1414 ffs->gadget = cdev->gadget; 1405 ffs->gadget = cdev->gadget;
1406 ffs_data_get(ffs);
1415 return 0; 1407 return 0;
1416} 1408}
1417 1409
@@ -1480,9 +1472,9 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)
1480} 1472}
1481 1473
1482 1474
1483static int functionfs_add(struct usb_composite_dev *cdev, 1475static int functionfs_bind_config(struct usb_composite_dev *cdev,
1484 struct usb_configuration *c, 1476 struct usb_configuration *c,
1485 struct ffs_data *ffs) 1477 struct ffs_data *ffs)
1486{ 1478{
1487 struct ffs_function *func; 1479 struct ffs_function *func;
1488 int ret; 1480 int ret;