diff options
Diffstat (limited to 'drivers/usb/gadget/file_storage.c')
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index cf3be299e353..6f887478b148 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -71,6 +71,12 @@ | |||
71 | * requirement amounts to two 16K buffers, size configurable by a parameter. | 71 | * requirement amounts to two 16K buffers, size configurable by a parameter. |
72 | * Support is included for both full-speed and high-speed operation. | 72 | * Support is included for both full-speed and high-speed operation. |
73 | * | 73 | * |
74 | * Note that the driver is slightly non-portable in that it assumes a | ||
75 | * single memory/DMA buffer will be useable for bulk-in, bulk-out, and | ||
76 | * interrupt-in endpoints. With most device controllers this isn't an | ||
77 | * issue, but there may be some with hardware restrictions that prevent | ||
78 | * a buffer from being used by more than one endpoint. | ||
79 | * | ||
74 | * Module options: | 80 | * Module options: |
75 | * | 81 | * |
76 | * file=filename[,filename...] | 82 | * file=filename[,filename...] |
@@ -108,6 +114,14 @@ | |||
108 | * setting are not allowed when the medium is loaded. | 114 | * setting are not allowed when the medium is loaded. |
109 | * | 115 | * |
110 | * This gadget driver is heavily based on "Gadget Zero" by David Brownell. | 116 | * This gadget driver is heavily based on "Gadget Zero" by David Brownell. |
117 | * The driver's SCSI command interface was based on the "Information | ||
118 | * technology - Small Computer System Interface - 2" document from | ||
119 | * X3T9.2 Project 375D, Revision 10L, 7-SEP-93, available at | ||
120 | * <http://www.t10.org/ftp/t10/drafts/s2/s2-r10l.pdf>. The single exception | ||
121 | * is opcode 0x23 (READ FORMAT CAPACITIES), which was based on the | ||
122 | * "Universal Serial Bus Mass Storage Class UFI Command Specification" | ||
123 | * document, Revision 1.0, December 14, 1998, available at | ||
124 | * <http://www.usb.org/developers/devclass_docs/usbmass-ufi10.pdf>. | ||
111 | */ | 125 | */ |
112 | 126 | ||
113 | 127 | ||
@@ -334,11 +348,9 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
334 | 348 | ||
335 | #define MAX_LUNS 8 | 349 | #define MAX_LUNS 8 |
336 | 350 | ||
337 | /* Arggh! There should be a module_param_array_named macro! */ | ||
338 | static char *file[MAX_LUNS]; | ||
339 | static int ro[MAX_LUNS]; | ||
340 | |||
341 | static struct { | 351 | static struct { |
352 | char *file[MAX_LUNS]; | ||
353 | int ro[MAX_LUNS]; | ||
342 | int num_filenames; | 354 | int num_filenames; |
343 | int num_ros; | 355 | int num_ros; |
344 | unsigned int nluns; | 356 | unsigned int nluns; |
@@ -370,10 +382,11 @@ static struct { | |||
370 | }; | 382 | }; |
371 | 383 | ||
372 | 384 | ||
373 | module_param_array(file, charp, &mod_data.num_filenames, S_IRUGO); | 385 | module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames, |
386 | S_IRUGO); | ||
374 | MODULE_PARM_DESC(file, "names of backing files or devices"); | 387 | MODULE_PARM_DESC(file, "names of backing files or devices"); |
375 | 388 | ||
376 | module_param_array(ro, bool, &mod_data.num_ros, S_IRUGO); | 389 | module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO); |
377 | MODULE_PARM_DESC(ro, "true to force read-only"); | 390 | MODULE_PARM_DESC(ro, "true to force read-only"); |
378 | 391 | ||
379 | module_param_named(luns, mod_data.nluns, uint, S_IRUGO); | 392 | module_param_named(luns, mod_data.nluns, uint, S_IRUGO); |
@@ -1795,6 +1808,7 @@ static int do_write(struct fsg_dev *fsg) | |||
1795 | * the bulk-out maxpacket size */ | 1808 | * the bulk-out maxpacket size */ |
1796 | bh->outreq->length = bh->bulk_out_intended_length = | 1809 | bh->outreq->length = bh->bulk_out_intended_length = |
1797 | amount; | 1810 | amount; |
1811 | bh->outreq->short_not_ok = 1; | ||
1798 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 1812 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
1799 | &bh->outreq_busy, &bh->state); | 1813 | &bh->outreq_busy, &bh->state); |
1800 | fsg->next_buffhd_to_fill = bh->next; | 1814 | fsg->next_buffhd_to_fill = bh->next; |
@@ -2398,6 +2412,7 @@ static int throw_away_data(struct fsg_dev *fsg) | |||
2398 | * the bulk-out maxpacket size */ | 2412 | * the bulk-out maxpacket size */ |
2399 | bh->outreq->length = bh->bulk_out_intended_length = | 2413 | bh->outreq->length = bh->bulk_out_intended_length = |
2400 | amount; | 2414 | amount; |
2415 | bh->outreq->short_not_ok = 1; | ||
2401 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 2416 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
2402 | &bh->outreq_busy, &bh->state); | 2417 | &bh->outreq_busy, &bh->state); |
2403 | fsg->next_buffhd_to_fill = bh->next; | 2418 | fsg->next_buffhd_to_fill = bh->next; |
@@ -3029,6 +3044,7 @@ static int get_next_command(struct fsg_dev *fsg) | |||
3029 | 3044 | ||
3030 | /* Queue a request to read a Bulk-only CBW */ | 3045 | /* Queue a request to read a Bulk-only CBW */ |
3031 | set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN); | 3046 | set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN); |
3047 | bh->outreq->short_not_ok = 1; | ||
3032 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 3048 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
3033 | &bh->outreq_busy, &bh->state); | 3049 | &bh->outreq_busy, &bh->state); |
3034 | 3050 | ||
@@ -3859,7 +3875,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3859 | 3875 | ||
3860 | for (i = 0; i < fsg->nluns; ++i) { | 3876 | for (i = 0; i < fsg->nluns; ++i) { |
3861 | curlun = &fsg->luns[i]; | 3877 | curlun = &fsg->luns[i]; |
3862 | curlun->ro = ro[i]; | 3878 | curlun->ro = mod_data.ro[i]; |
3863 | curlun->dev.parent = &gadget->dev; | 3879 | curlun->dev.parent = &gadget->dev; |
3864 | curlun->dev.driver = &fsg_driver.driver; | 3880 | curlun->dev.driver = &fsg_driver.driver; |
3865 | dev_set_drvdata(&curlun->dev, fsg); | 3881 | dev_set_drvdata(&curlun->dev, fsg); |
@@ -3876,8 +3892,9 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3876 | kref_get(&fsg->ref); | 3892 | kref_get(&fsg->ref); |
3877 | } | 3893 | } |
3878 | 3894 | ||
3879 | if (file[i] && *file[i]) { | 3895 | if (mod_data.file[i] && *mod_data.file[i]) { |
3880 | if ((rc = open_backing_file(curlun, file[i])) != 0) | 3896 | if ((rc = open_backing_file(curlun, |
3897 | mod_data.file[i])) != 0) | ||
3881 | goto out; | 3898 | goto out; |
3882 | } else if (!mod_data.removable) { | 3899 | } else if (!mod_data.removable) { |
3883 | ERROR(fsg, "no file given for LUN%d\n", i); | 3900 | ERROR(fsg, "no file given for LUN%d\n", i); |
@@ -3953,6 +3970,9 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
3953 | for (i = 0; i < NUM_BUFFERS; ++i) { | 3970 | for (i = 0; i < NUM_BUFFERS; ++i) { |
3954 | struct fsg_buffhd *bh = &fsg->buffhds[i]; | 3971 | struct fsg_buffhd *bh = &fsg->buffhds[i]; |
3955 | 3972 | ||
3973 | /* Allocate for the bulk-in endpoint. We assume that | ||
3974 | * the buffer will also work with the bulk-out (and | ||
3975 | * interrupt-in) endpoint. */ | ||
3956 | bh->buf = usb_ep_alloc_buffer(fsg->bulk_in, mod_data.buflen, | 3976 | bh->buf = usb_ep_alloc_buffer(fsg->bulk_in, mod_data.buflen, |
3957 | &bh->dma, GFP_KERNEL); | 3977 | &bh->dma, GFP_KERNEL); |
3958 | if (!bh->buf) | 3978 | if (!bh->buf) |