aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Nazarewicz <m.nazarewicz@samsung.com>2010-08-12 11:43:51 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:21:22 -0400
commit9cfe745e652eacf57ffc7862b7b3ccbdf336ad19 (patch)
treea81b490c8671e668fd48041fbd55255151ae0a97
parent452ee0eb10bd3581cf667a1db18cb684889ce446 (diff)
usb: gadget: mass_storage: optional SCSI WRITE FUA bit
The nofua parameter (optionally ignore SCSI WRITE FUA) was added to the File Storage Gadget some time ago. This patch adds the same functionality to the Mass Storage Function. Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com> Cc: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/f_mass_storage.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 32cce029f65c..44e5ffed5c08 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -73,6 +73,8 @@
73 * being removable. 73 * being removable.
74 * ->cdrom Flag specifying that LUN shall be reported as 74 * ->cdrom Flag specifying that LUN shall be reported as
75 * being a CD-ROM. 75 * being a CD-ROM.
76 * ->nofua Flag specifying that FUA flag in SCSI WRITE(10,12)
77 * commands for this LUN shall be ignored.
76 * 78 *
77 * lun_name_format A printf-like format for names of the LUN 79 * lun_name_format A printf-like format for names of the LUN
78 * devices. This determines how the 80 * devices. This determines how the
@@ -127,6 +129,8 @@
127 * Default true, boolean for removable media. 129 * Default true, boolean for removable media.
128 * cdrom=b[,b...] Default false, boolean for whether to emulate 130 * cdrom=b[,b...] Default false, boolean for whether to emulate
129 * a CD-ROM drive. 131 * a CD-ROM drive.
132 * nofua=b[,b...] Default false, booleans for ignore FUA flag
133 * in SCSI WRITE(10,12) commands
130 * luns=N Default N = number of filenames, number of 134 * luns=N Default N = number of filenames, number of
131 * LUNs to support. 135 * LUNs to support.
132 * stall Default determined according to the type of 136 * stall Default determined according to the type of
@@ -409,6 +413,7 @@ struct fsg_config {
409 char ro; 413 char ro;
410 char removable; 414 char removable;
411 char cdrom; 415 char cdrom;
416 char nofua;
412 } luns[FSG_MAX_LUNS]; 417 } luns[FSG_MAX_LUNS];
413 418
414 const char *lun_name_format; 419 const char *lun_name_format;
@@ -887,7 +892,7 @@ static int do_write(struct fsg_common *common)
887 curlun->sense_data = SS_INVALID_FIELD_IN_CDB; 892 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
888 return -EINVAL; 893 return -EINVAL;
889 } 894 }
890 if (common->cmnd[1] & 0x08) { /* FUA */ 895 if (!curlun->nofua && (common->cmnd[1] & 0x08)) { /* FUA */
891 spin_lock(&curlun->filp->f_lock); 896 spin_lock(&curlun->filp->f_lock);
892 curlun->filp->f_flags |= O_SYNC; 897 curlun->filp->f_flags |= O_SYNC;
893 spin_unlock(&curlun->filp->f_lock); 898 spin_unlock(&curlun->filp->f_lock);
@@ -2662,6 +2667,7 @@ static int fsg_main_thread(void *common_)
2662 2667
2663/* Write permission is checked per LUN in store_*() functions. */ 2668/* Write permission is checked per LUN in store_*() functions. */
2664static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro); 2669static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro);
2670static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, fsg_store_nofua);
2665static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file); 2671static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file);
2666 2672
2667 2673
@@ -2768,6 +2774,9 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
2768 rc = device_create_file(&curlun->dev, &dev_attr_file); 2774 rc = device_create_file(&curlun->dev, &dev_attr_file);
2769 if (rc) 2775 if (rc)
2770 goto error_luns; 2776 goto error_luns;
2777 rc = device_create_file(&curlun->dev, &dev_attr_nofua);
2778 if (rc)
2779 goto error_luns;
2771 2780
2772 if (lcfg->filename) { 2781 if (lcfg->filename) {
2773 rc = fsg_lun_open(curlun, lcfg->filename); 2782 rc = fsg_lun_open(curlun, lcfg->filename);
@@ -2911,6 +2920,7 @@ static void fsg_common_release(struct kref *ref)
2911 2920
2912 /* In error recovery common->nluns may be zero. */ 2921 /* In error recovery common->nluns may be zero. */
2913 for (; i; --i, ++lun) { 2922 for (; i; --i, ++lun) {
2923 device_remove_file(&lun->dev, &dev_attr_nofua);
2914 device_remove_file(&lun->dev, &dev_attr_ro); 2924 device_remove_file(&lun->dev, &dev_attr_ro);
2915 device_remove_file(&lun->dev, &dev_attr_file); 2925 device_remove_file(&lun->dev, &dev_attr_file);
2916 fsg_lun_close(lun); 2926 fsg_lun_close(lun);
@@ -3069,8 +3079,10 @@ struct fsg_module_parameters {
3069 int ro[FSG_MAX_LUNS]; 3079 int ro[FSG_MAX_LUNS];
3070 int removable[FSG_MAX_LUNS]; 3080 int removable[FSG_MAX_LUNS];
3071 int cdrom[FSG_MAX_LUNS]; 3081 int cdrom[FSG_MAX_LUNS];
3082 int nofua[FSG_MAX_LUNS];
3072 3083
3073 unsigned int file_count, ro_count, removable_count, cdrom_count; 3084 unsigned int file_count, ro_count, removable_count, cdrom_count;
3085 unsigned int nofua_count;
3074 unsigned int luns; /* nluns */ 3086 unsigned int luns; /* nluns */
3075 int stall; /* can_stall */ 3087 int stall; /* can_stall */
3076}; 3088};
@@ -3096,6 +3108,8 @@ struct fsg_module_parameters {
3096 "true to simulate removable media"); \ 3108 "true to simulate removable media"); \
3097 _FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \ 3109 _FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \
3098 "true to simulate CD-ROM instead of disk"); \ 3110 "true to simulate CD-ROM instead of disk"); \
3111 _FSG_MODULE_PARAM_ARRAY(prefix, params, nofua, bool, \
3112 "true to ignore SCSI WRITE(10,12) FUA bit"); \
3099 _FSG_MODULE_PARAM(prefix, params, luns, uint, \ 3113 _FSG_MODULE_PARAM(prefix, params, luns, uint, \
3100 "number of LUNs"); \ 3114 "number of LUNs"); \
3101 _FSG_MODULE_PARAM(prefix, params, stall, bool, \ 3115 _FSG_MODULE_PARAM(prefix, params, stall, bool, \