aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/file_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/file_storage.c')
-rw-r--r--drivers/usb/gadget/file_storage.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index c98316ce8384..f04a29a46646 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -253,7 +253,7 @@
253#include <linux/freezer.h> 253#include <linux/freezer.h>
254#include <linux/utsname.h> 254#include <linux/utsname.h>
255 255
256#include <linux/usb_ch9.h> 256#include <linux/usb/ch9.h>
257#include <linux/usb_gadget.h> 257#include <linux/usb_gadget.h>
258 258
259#include "gadget_chips.h" 259#include "gadget_chips.h"
@@ -1148,7 +1148,7 @@ static int ep0_queue(struct fsg_dev *fsg)
1148 1148
1149static void ep0_complete(struct usb_ep *ep, struct usb_request *req) 1149static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
1150{ 1150{
1151 struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; 1151 struct fsg_dev *fsg = ep->driver_data;
1152 1152
1153 if (req->actual > 0) 1153 if (req->actual > 0)
1154 dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); 1154 dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual);
@@ -1170,8 +1170,8 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
1170 1170
1171static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) 1171static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
1172{ 1172{
1173 struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; 1173 struct fsg_dev *fsg = ep->driver_data;
1174 struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; 1174 struct fsg_buffhd *bh = req->context;
1175 1175
1176 if (req->status || req->actual != req->length) 1176 if (req->status || req->actual != req->length)
1177 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1177 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__,
@@ -1190,8 +1190,8 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
1190 1190
1191static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) 1191static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
1192{ 1192{
1193 struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; 1193 struct fsg_dev *fsg = ep->driver_data;
1194 struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; 1194 struct fsg_buffhd *bh = req->context;
1195 1195
1196 dump_msg(fsg, "bulk-out", req->buf, req->actual); 1196 dump_msg(fsg, "bulk-out", req->buf, req->actual);
1197 if (req->status || req->actual != bh->bulk_out_intended_length) 1197 if (req->status || req->actual != bh->bulk_out_intended_length)
@@ -1214,8 +1214,8 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
1214#ifdef CONFIG_USB_FILE_STORAGE_TEST 1214#ifdef CONFIG_USB_FILE_STORAGE_TEST
1215static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) 1215static void intr_in_complete(struct usb_ep *ep, struct usb_request *req)
1216{ 1216{
1217 struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; 1217 struct fsg_dev *fsg = ep->driver_data;
1218 struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; 1218 struct fsg_buffhd *bh = req->context;
1219 1219
1220 if (req->status || req->actual != req->length) 1220 if (req->status || req->actual != req->length)
1221 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, 1221 DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__,
@@ -1909,10 +1909,10 @@ static int fsync_sub(struct lun *curlun)
1909 if (!filp->f_op->fsync) 1909 if (!filp->f_op->fsync)
1910 return -EINVAL; 1910 return -EINVAL;
1911 1911
1912 inode = filp->f_dentry->d_inode; 1912 inode = filp->f_path.dentry->d_inode;
1913 mutex_lock(&inode->i_mutex); 1913 mutex_lock(&inode->i_mutex);
1914 rc = filemap_fdatawrite(inode->i_mapping); 1914 rc = filemap_fdatawrite(inode->i_mapping);
1915 err = filp->f_op->fsync(filp, filp->f_dentry, 1); 1915 err = filp->f_op->fsync(filp, filp->f_path.dentry, 1);
1916 if (!rc) 1916 if (!rc)
1917 rc = err; 1917 rc = err;
1918 err = filemap_fdatawait(inode->i_mapping); 1918 err = filemap_fdatawait(inode->i_mapping);
@@ -1950,7 +1950,7 @@ static int do_synchronize_cache(struct fsg_dev *fsg)
1950static void invalidate_sub(struct lun *curlun) 1950static void invalidate_sub(struct lun *curlun)
1951{ 1951{
1952 struct file *filp = curlun->filp; 1952 struct file *filp = curlun->filp;
1953 struct inode *inode = filp->f_dentry->d_inode; 1953 struct inode *inode = filp->f_path.dentry->d_inode;
1954 unsigned long rc; 1954 unsigned long rc;
1955 1955
1956 rc = invalidate_inode_pages(inode->i_mapping); 1956 rc = invalidate_inode_pages(inode->i_mapping);
@@ -2577,7 +2577,7 @@ static int send_status(struct fsg_dev *fsg)
2577 } 2577 }
2578 2578
2579 if (transport_is_bbb()) { 2579 if (transport_is_bbb()) {
2580 struct bulk_cs_wrap *csw = (struct bulk_cs_wrap *) bh->buf; 2580 struct bulk_cs_wrap *csw = bh->buf;
2581 2581
2582 /* Store and send the Bulk-only CSW */ 2582 /* Store and send the Bulk-only CSW */
2583 csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG); 2583 csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG);
@@ -2596,8 +2596,7 @@ static int send_status(struct fsg_dev *fsg)
2596 return 0; 2596 return 0;
2597 2597
2598 } else { // USB_PR_CBI 2598 } else { // USB_PR_CBI
2599 struct interrupt_data *buf = (struct interrupt_data *) 2599 struct interrupt_data *buf = bh->buf;
2600 bh->buf;
2601 2600
2602 /* Store and send the Interrupt data. UFI sends the ASC 2601 /* Store and send the Interrupt data. UFI sends the ASC
2603 * and ASCQ bytes. Everything else sends a Type (which 2602 * and ASCQ bytes. Everything else sends a Type (which
@@ -2982,7 +2981,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2982static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) 2981static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2983{ 2982{
2984 struct usb_request *req = bh->outreq; 2983 struct usb_request *req = bh->outreq;
2985 struct bulk_cb_wrap *cbw = (struct bulk_cb_wrap *) req->buf; 2984 struct bulk_cb_wrap *cbw = req->buf;
2986 2985
2987 /* Was this a real packet? */ 2986 /* Was this a real packet? */
2988 if (req->status) 2987 if (req->status)
@@ -3428,7 +3427,7 @@ static void handle_exception(struct fsg_dev *fsg)
3428 3427
3429static int fsg_main_thread(void *fsg_) 3428static int fsg_main_thread(void *fsg_)
3430{ 3429{
3431 struct fsg_dev *fsg = (struct fsg_dev *) fsg_; 3430 struct fsg_dev *fsg = fsg_;
3432 3431
3433 /* Allow the thread to be killed by a signal, but set the signal mask 3432 /* Allow the thread to be killed by a signal, but set the signal mask
3434 * to block everything but INT, TERM, KILL, and USR1. */ 3433 * to block everything but INT, TERM, KILL, and USR1. */
@@ -3526,8 +3525,8 @@ static int open_backing_file(struct lun *curlun, const char *filename)
3526 if (!(filp->f_mode & FMODE_WRITE)) 3525 if (!(filp->f_mode & FMODE_WRITE))
3527 ro = 1; 3526 ro = 1;
3528 3527
3529 if (filp->f_dentry) 3528 if (filp->f_path.dentry)
3530 inode = filp->f_dentry->d_inode; 3529 inode = filp->f_path.dentry->d_inode;
3531 if (inode && S_ISBLK(inode->i_mode)) { 3530 if (inode && S_ISBLK(inode->i_mode)) {
3532 if (bdev_read_only(inode->i_bdev)) 3531 if (bdev_read_only(inode->i_bdev))
3533 ro = 1; 3532 ro = 1;
@@ -3600,13 +3599,13 @@ static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char *
3600static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf) 3599static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf)
3601{ 3600{
3602 struct lun *curlun = dev_to_lun(dev); 3601 struct lun *curlun = dev_to_lun(dev);
3603 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3602 struct fsg_dev *fsg = dev_get_drvdata(dev);
3604 char *p; 3603 char *p;
3605 ssize_t rc; 3604 ssize_t rc;
3606 3605
3607 down_read(&fsg->filesem); 3606 down_read(&fsg->filesem);
3608 if (backing_file_is_open(curlun)) { // Get the complete pathname 3607 if (backing_file_is_open(curlun)) { // Get the complete pathname
3609 p = d_path(curlun->filp->f_dentry, curlun->filp->f_vfsmnt, 3608 p = d_path(curlun->filp->f_path.dentry, curlun->filp->f_path.mnt,
3610 buf, PAGE_SIZE - 1); 3609 buf, PAGE_SIZE - 1);
3611 if (IS_ERR(p)) 3610 if (IS_ERR(p))
3612 rc = PTR_ERR(p); 3611 rc = PTR_ERR(p);
@@ -3629,7 +3628,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const
3629{ 3628{
3630 ssize_t rc = count; 3629 ssize_t rc = count;
3631 struct lun *curlun = dev_to_lun(dev); 3630 struct lun *curlun = dev_to_lun(dev);
3632 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3631 struct fsg_dev *fsg = dev_get_drvdata(dev);
3633 int i; 3632 int i;
3634 3633
3635 if (sscanf(buf, "%d", &i) != 1) 3634 if (sscanf(buf, "%d", &i) != 1)
@@ -3652,7 +3651,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const
3652static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 3651static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
3653{ 3652{
3654 struct lun *curlun = dev_to_lun(dev); 3653 struct lun *curlun = dev_to_lun(dev);
3655 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3654 struct fsg_dev *fsg = dev_get_drvdata(dev);
3656 int rc = 0; 3655 int rc = 0;
3657 3656
3658 if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) { 3657 if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) {
@@ -3700,7 +3699,7 @@ static void fsg_release(struct kref *ref)
3700 3699
3701static void lun_release(struct device *dev) 3700static void lun_release(struct device *dev)
3702{ 3701{
3703 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3702 struct fsg_dev *fsg = dev_get_drvdata(dev);
3704 3703
3705 kref_put(&fsg->ref, fsg_release); 3704 kref_put(&fsg->ref, fsg_release);
3706} 3705}
@@ -4030,8 +4029,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
4030 if (backing_file_is_open(curlun)) { 4029 if (backing_file_is_open(curlun)) {
4031 p = NULL; 4030 p = NULL;
4032 if (pathbuf) { 4031 if (pathbuf) {
4033 p = d_path(curlun->filp->f_dentry, 4032 p = d_path(curlun->filp->f_path.dentry,
4034 curlun->filp->f_vfsmnt, 4033 curlun->filp->f_path.mnt,
4035 pathbuf, PATH_MAX); 4034 pathbuf, PATH_MAX);
4036 if (IS_ERR(p)) 4035 if (IS_ERR(p))
4037 p = NULL; 4036 p = NULL;
@@ -4100,7 +4099,7 @@ static struct usb_gadget_driver fsg_driver = {
4100#endif 4099#endif
4101 .function = (char *) longname, 4100 .function = (char *) longname,
4102 .bind = fsg_bind, 4101 .bind = fsg_bind,
4103 .unbind = __exit_p(fsg_unbind), 4102 .unbind = fsg_unbind,
4104 .disconnect = fsg_disconnect, 4103 .disconnect = fsg_disconnect,
4105 .setup = fsg_setup, 4104 .setup = fsg_setup,
4106 .suspend = fsg_suspend, 4105 .suspend = fsg_suspend,