aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2010-06-16 06:08:00 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 17:35:36 -0400
commitfd7c9a007f7d45df86974c3f83d67ab21cc21f1f (patch)
tree143a1c3d28d83c3cadf8962bac139259b8d69aff /drivers/usb/gadget
parentf2adc4f8aaf272de9ac71dcb18d95ebe05fc3f94 (diff)
USB: gadget: f_fs: use usb_string_ids_n()
Use usb_string_ids_n() function to simplify string ids registeration. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/f_fs.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 282b49e336be..e4f595055208 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -1375,7 +1375,8 @@ static void ffs_data_reset(struct ffs_data *ffs)
1375 1375
1376static 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)
1377{ 1377{
1378 unsigned i, count; 1378 struct usb_gadget_strings **lang;
1379 int first_id;
1379 1380
1380 ENTER(); 1381 ENTER();
1381 1382
@@ -1383,7 +1384,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
1383 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) 1384 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags)))
1384 return -EBADFD; 1385 return -EBADFD;
1385 1386
1386 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;
1387 1390
1388 ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); 1391 ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
1389 if (unlikely(!ffs->ep0req)) 1392 if (unlikely(!ffs->ep0req))
@@ -1391,25 +1394,16 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
1391 ffs->ep0req->complete = ffs_ep0_complete; 1394 ffs->ep0req->complete = ffs_ep0_complete;
1392 ffs->ep0req->context = ffs; 1395 ffs->ep0req->context = ffs;
1393 1396
1394 /* Get strings identifiers */ 1397 lang = ffs->stringtabs;
1395 for (count = ffs->strings_count, i = 0; i < count; ++i) { 1398 for (lang = ffs->stringtabs; *lang; ++lang) {
1396 struct usb_gadget_strings **lang; 1399 struct usb_string *str = (*lang)->strings;
1397 1400 int id = first_id;
1398 int id = usb_string_id(cdev); 1401 for (; str->s; ++id, ++str)
1399 if (unlikely(id < 0)) { 1402 str->id = id;
1400 usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req);
1401 ffs->ep0req = NULL;
1402 return id;
1403 }
1404
1405 lang = ffs->stringtabs;
1406 do {
1407 (*lang)->strings[i].id = id;
1408 ++lang;
1409 } while (*lang);
1410 } 1403 }
1411 1404
1412 ffs->gadget = cdev->gadget; 1405 ffs->gadget = cdev->gadget;
1406 ffs_data_get(ffs);
1413 return 0; 1407 return 0;
1414} 1408}
1415 1409