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>
This commit is contained in:
		
					parent
					
						
							
								f2adc4f8aa
							
						
					
				
			
			
				commit
				
					
						fd7c9a007f
					
				
			
		
					 1 changed files with 12 additions and 18 deletions
				
			
		|  | @ -1375,7 +1375,8 @@ static void ffs_data_reset(struct ffs_data *ffs) | ||||||
| 
 | 
 | ||||||
| static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | ||||||
| { | { | ||||||
| 	unsigned i, count; | 	struct usb_gadget_strings **lang; | ||||||
|  | 	int first_id; | ||||||
| 
 | 
 | ||||||
| 	ENTER(); | 	ENTER(); | ||||||
| 
 | 
 | ||||||
|  | @ -1383,7 +1384,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | ||||||
| 		 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) | 		 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags))) | ||||||
| 		return -EBADFD; | 		return -EBADFD; | ||||||
| 
 | 
 | ||||||
| 	ffs_data_get(ffs); | 	first_id = usb_string_ids_n(cdev, ffs->strings_count); | ||||||
|  | 	if (unlikely(first_id < 0)) | ||||||
|  | 		return first_id; | ||||||
| 
 | 
 | ||||||
| 	ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); | 	ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); | ||||||
| 	if (unlikely(!ffs->ep0req)) | 	if (unlikely(!ffs->ep0req)) | ||||||
|  | @ -1391,25 +1394,16 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) | ||||||
| 	ffs->ep0req->complete = ffs_ep0_complete; | 	ffs->ep0req->complete = ffs_ep0_complete; | ||||||
| 	ffs->ep0req->context = ffs; | 	ffs->ep0req->context = ffs; | ||||||
| 
 | 
 | ||||||
| 	/* Get strings identifiers */ | 	lang = ffs->stringtabs; | ||||||
| 	for (count = ffs->strings_count, i = 0; i < count; ++i) { | 	for (lang = ffs->stringtabs; *lang; ++lang) { | ||||||
| 		struct usb_gadget_strings **lang; | 		struct usb_string *str = (*lang)->strings; | ||||||
| 
 | 		int id = first_id; | ||||||
| 		int id = usb_string_id(cdev); | 		for (; str->s; ++id, ++str) | ||||||
| 		if (unlikely(id < 0)) { | 			str->id = id; | ||||||
| 			usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req); |  | ||||||
| 			ffs->ep0req = NULL; |  | ||||||
| 			return id; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		lang = ffs->stringtabs; |  | ||||||
| 		do { |  | ||||||
| 			(*lang)->strings[i].id = id; |  | ||||||
| 			++lang; |  | ||||||
| 		} while (*lang); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ffs->gadget = cdev->gadget; | 	ffs->gadget = cdev->gadget; | ||||||
|  | 	ffs_data_get(ffs); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Michal Nazarewicz
				Michal Nazarewicz