diff --git a/brick/kernel/computil.c b/brick/kernel/computil.c index f60c4bc0..341d2c56 100644 --- a/brick/kernel/computil.c +++ b/brick/kernel/computil.c @@ -38,12 +38,6 @@ // Keep Eclipse happy #endif -#undef dev_vdbg -#undef dev_dbg -#define dev_vdbg(d, args...) printk(args) -#define dev_dbg(d, args...) printk(args) - - /* big enough to hold our biggest descriptor */ #define USB_BUFSIZ 1024 @@ -873,12 +867,6 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) req->length = USB_BUFSIZ; gadget->ep0->driver_data = cdev; - - VDBG(cdev, - "setup req %02x.%02x v%04x i%04x l%d\n", - ctrl->bRequestType, ctrl->bRequest, - w_value, w_index, w_length); - switch (ctrl->bRequest) { /* we handle all standard USB descriptors */ case USB_REQ_GET_DESCRIPTOR: diff --git a/brick/kernel/d_usbdev.c b/brick/kernel/d_usbdev.c index 32bbdb42..26fa690f 100644 --- a/brick/kernel/d_usbdev.c +++ b/brick/kernel/d_usbdev.c @@ -40,8 +40,8 @@ #include #endif -#include "source/lms2012.h" -#include "source/am1808.h" +#include "../../lms2012/source/lms2012.h" +#include "../../lms2012/source/am1808.h" #define MODULE_NAME "usbdev_module" @@ -80,18 +80,12 @@ static void ModuleExit(void); #include #include -void myReset(void); -static int dUsbInit(void); -static void dUsbExit(void); -static struct fsg_common *fsg_common; - #include "computil.c" // The composite framework used as utility file #include <../drivers/usb/gadget/gadget_chips.h> #include <../drivers/usb/gadget/usbstring.c> #include <../drivers/usb/gadget/config.c> #include <../drivers/usb/gadget/epautoconf.c> -#include "f_mass_storage.c" /*-------------------------------------------------------------------------*/ @@ -176,10 +170,9 @@ static struct usb_device_descriptor device_desc = { .bDescriptorType = USB_DT_DEVICE, .bcdUSB = cpu_to_le16(0x0200), - .bDeviceClass = 0xEF, - .bDeviceSubClass = 2, - .bDeviceProtocol = 1, - + .bDeviceClass = 0, + .bDeviceSubClass = 0, + .bDeviceProtocol = 0, /*.bMaxPacketSize0 = f(hardware) */ .idVendor = cpu_to_le16(DRIVER_VENDOR_NUM), .idProduct = cpu_to_le16(DRIVER_PRODUCT_NUM), @@ -337,9 +330,6 @@ static void zero_resume(struct usb_composite_dev *cdev) /*-------------------------------------------------------------------------*/ -static int msg_bind(struct usb_composite_dev *cdev); -static void msg_bind2(struct usb_composite_dev *cdev); - static int zero_bind(struct usb_composite_dev *cdev) { int gcnum; @@ -372,10 +362,6 @@ static int zero_bind(struct usb_composite_dev *cdev) strings_dev[STRING_SERIAL_IDX].id = id; device_desc.iSerialNumber = id; - id = msg_bind(cdev); - if (id < 0) - return id; - setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); rudolf_add(cdev, autoresume != 0); @@ -395,9 +381,6 @@ static int zero_bind(struct usb_composite_dev *cdev) longname, gadget->name); device_desc.bcdDevice = cpu_to_le16(0x9999); } - - msg_bind2(cdev); - return 0; } @@ -713,43 +696,3 @@ static void ModuleExit(void) } - - - -// MSG - - -/****************************** Configurations ******************************/ - -static struct fsg_module_parameters fsg_mod_data = { - .stall = 1 -}; -FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); - -/****************************** Gadget Bind ******************************/ - - -static void msg_bind2(struct usb_composite_dev *cdev) -{ - fsg_common_put(fsg_common); -} - -static int msg_bind(struct usb_composite_dev *cdev) -{ - /* set up mass storage function */ - fsg_common = fsg_common_from_params(0, cdev, &fsg_mod_data); - if (IS_ERR(fsg_common)) { - return PTR_ERR(fsg_common); - } - return 0; -} - - -static int msg_config(struct usb_configuration *c) { - return fsg_add(c->cdev, c, fsg_common); -} - -void myReset() { - dUsbExit(); - dUsbInit(); -} \ No newline at end of file diff --git a/brick/kernel/f_mass_storage.c b/brick/kernel/f_mass_storage.c index c08a31ce..a37640eb 100644 --- a/brick/kernel/f_mass_storage.c +++ b/brick/kernel/f_mass_storage.c @@ -705,7 +705,7 @@ static int do_read(struct fsg_common *common) u32 amount_left; loff_t file_offset, file_offset_tmp; unsigned int amount; - //unsigned int partial_page; + unsigned int partial_page; ssize_t nread; /* Get the starting Logical Block Address and check that it's @@ -747,12 +747,11 @@ static int do_read(struct fsg_common *common) amount = min(amount_left, FSG_BUFLEN); amount = min((loff_t) amount, curlun->file_length - file_offset); - /* partial_page = file_offset & (PAGE_CACHE_SIZE - 1); if (partial_page > 0) amount = min(amount, (unsigned int) PAGE_CACHE_SIZE - partial_page); - */ + /* Wait for the next buffer to become available */ bh = common->next_buffhd_to_fill; while (bh->state != BUF_STATE_EMPTY) { @@ -835,7 +834,7 @@ static int do_write(struct fsg_common *common) u32 amount_left_to_req, amount_left_to_write; loff_t usb_offset, file_offset, file_offset_tmp; unsigned int amount; - //unsigned int partial_page; + unsigned int partial_page; ssize_t nwritten; int rc; @@ -844,7 +843,7 @@ static int do_write(struct fsg_common *common) return -EINVAL; } spin_lock(&curlun->filp->f_lock); - curlun->filp->f_flags |= O_SYNC; /* Default is to wait */ + curlun->filp->f_flags &= ~O_SYNC; /* Default is not to wait */ spin_unlock(&curlun->filp->f_lock); /* Get the starting Logical Block Address and check that it's @@ -897,12 +896,10 @@ static int do_write(struct fsg_common *common) amount = min(amount_left_to_req, FSG_BUFLEN); amount = min((loff_t) amount, curlun->file_length - usb_offset); - /* partial_page = usb_offset & (PAGE_CACHE_SIZE - 1); if (partial_page > 0) amount = min(amount, (unsigned int) PAGE_CACHE_SIZE - partial_page); - */ if (amount == 0) { get_some_more = 0; @@ -2632,54 +2629,6 @@ static int fsg_main_thread(void *common_) static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro); static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file); -static struct fsg_dev *_fsg; - -static int isActive(void) { - return _fsg->function.config->cdev->deactivations == 0 ? 1 : 0; -} - -static ssize_t fsg_show_active(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%d\n", isActive()); -} - -static ssize_t fsg_store_active(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int i; - - if (sscanf(buf, "%d", &i) != 1) - return -EINVAL; - - /* - if (i == 0) { - dUsbExit(); - dUsbInit(); - } - else if (i == 1) { - do_set_config(fsg_common, 0); - } - else if (i == 2) { - raise_exception(fsg_common, FSG_STATE_CONFIG_CHANGE); - } - */ - - if (isActive() != i) { - if (i == 0) { - usb_function_deactivate(&_fsg->function); - } else if (i == 1) { - usb_function_activate(&_fsg->function); - } else { - return -EINVAL; - } - } - - return count; -} - -static DEVICE_ATTR(active, 0644, fsg_show_active, fsg_store_active); - /****************************** FSG COMMON ******************************/ @@ -2786,10 +2735,6 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, if (rc) goto error_luns; - rc = device_create_file(&curlun->dev, &dev_attr_active); - if (rc) - goto error_luns; - if (lcfg->filename) { rc = fsg_lun_open(curlun, lcfg->filename); if (rc) @@ -3021,7 +2966,6 @@ static int fsg_add(struct usb_composite_dev *cdev, int rc; fsg = kzalloc(sizeof *fsg, GFP_KERNEL); - _fsg = fsg; if (unlikely(!fsg)) return -ENOMEM; diff --git a/brick/kernel/storage_common.c b/brick/kernel/storage_common.c index 9dfd1792..868d8ee8 100644 --- a/brick/kernel/storage_common.c +++ b/brick/kernel/storage_common.c @@ -749,13 +749,11 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr, struct fsg_lun *curlun = fsg_lun_from_dev(dev); struct rw_semaphore *filesem = dev_get_drvdata(dev); int rc = 0; - - #if 0 + if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) { LDBG(curlun, "eject attempt prevented\n"); return -EBUSY; /* "Door is locked" */ } - #endif /* Remove a trailing newline */ if (count > 0 && buf[count-1] == '\n') diff --git a/brick/kernel/usb_function.c b/brick/kernel/usb_function.c index 8bb2b6b8..034af915 100644 --- a/brick/kernel/usb_function.c +++ b/brick/kernel/usb_function.c @@ -551,8 +551,6 @@ static void f_rudolf_disable(struct usb_function *f) /*-------------------------------------------------------------------------*/ -static int msg_config(struct usb_configuration *c); - static int rudolf_bind_config(struct usb_configuration *c) { struct f_rudolf *rudolf; @@ -570,18 +568,8 @@ static int rudolf_bind_config(struct usb_configuration *c) rudolf->function.disable = f_rudolf_disable; status = usb_add_function(c, &rudolf->function); - if (status) { + if (status) kfree(rudolf); - return status; - } - - - status = msg_config(c); - if (status) { - kfree(rudolf); - return status; - } - return status; } @@ -734,6 +722,5 @@ int rudolf_add(struct usb_composite_dev *cdev, bool autoresume) rudolf_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - return usb_add_config(cdev, &rudolf_driver); }