From aa382e22fb1ff34df15ec71d14182c11264526d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Sat, 30 Jul 2011 15:28:49 +0800 Subject: [PATCH] temp revert usb gadget change --- drivers/usb/gadget/android.c | 6 +- drivers/usb/gadget/composite.c | 8 +- drivers/usb/gadget/f_adb.c | 3 +- drivers/usb/gadget/f_mass_storage.c | 119 ++-------------------------- 4 files changed, 18 insertions(+), 118 deletions(-) diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index bbb8402abfcf..4d1c3fbecfe5 100755 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -54,8 +54,8 @@ MODULE_VERSION("1.0"); static const char longname[] = "Gadget Android"; /* Default vendor and product IDs, overridden by platform data */ -#define VENDOR_ID 0x2207//0x18D1 -#define PRODUCT_ID 0x2910 +#define VENDOR_ID 0x18D1 +#define PRODUCT_ID 0x0001 struct android_dev { struct usb_composite_dev *cdev; @@ -150,7 +150,7 @@ static int __init android_bind_config(struct usb_configuration *c) { struct android_dev *dev = _android_dev; - printk("android_bind_config\n"); + printk(KERN_DEBUG "android_bind_config\n"); dev->config = c; /* bind our functions if they have all registered */ diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 2b224c973e6a..ec83040cd449 100755 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -113,7 +113,7 @@ void usb_composite_force_reset(struct usb_composite_dev *cdev) if (cdev && cdev->gadget && cdev->gadget->speed != USB_SPEED_UNKNOWN) { /* avoid sending a disconnect switch event until after we disconnect */ -// cdev->mute_switch = 1;// yk 20110505 rk29 don't need to mute switch + cdev->mute_switch = 1; spin_unlock_irqrestore(&cdev->lock, flags); usb_gadget_disconnect(cdev->gadget); @@ -307,6 +307,7 @@ static int config_buf(struct usb_configuration *config, int status; int interfaceCount = 0; u8 *dest; + /* write the config descriptor */ c = buf; c->bLength = USB_DT_CONFIG_SIZE; @@ -559,11 +560,11 @@ int __init usb_add_config(struct usb_composite_dev *cdev, /* Prevent duplicate configuration identifiers */ list_for_each_entry(c, &cdev->configs, list) { if (c->bConfigurationValue == config->bConfigurationValue) { - printk("usb_add_config, already configed,everest\n"); status = -EBUSY; goto done; } } + config->cdev = cdev; list_add_tail(&config->list, &cdev->configs); @@ -787,6 +788,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) req->complete = composite_setup_complete; req->length = USB_BUFSIZ; gadget->ep0->driver_data = cdev; + switch (ctrl->bRequest) { /* we handle all standard USB descriptors */ @@ -1208,7 +1210,7 @@ static struct usb_gadget_driver composite_driver = { .speed = USB_SPEED_HIGH, .bind = composite_bind, - .unbind = composite_unbind,//__exit_p(composite_unbind), + .unbind = __exit_p(composite_unbind), .setup = composite_setup, .disconnect = composite_disconnect, diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c index 1cd22a57550a..a0b0774b9556 100644 --- a/drivers/usb/gadget/f_adb.c +++ b/drivers/usb/gadget/f_adb.c @@ -77,7 +77,7 @@ static struct usb_endpoint_descriptor adb_highspeed_in_desc = { .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_DIR_IN, .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = __constant_cpu_to_le16(64), + .wMaxPacketSize = __constant_cpu_to_le16(512), }; static struct usb_endpoint_descriptor adb_highspeed_out_desc = { @@ -486,6 +486,7 @@ adb_function_bind(struct usb_configuration *c, struct usb_function *f) dev->cdev = cdev; DBG(cdev, "adb_function_bind dev: %p\n", dev); + /* allocate interface ID(s) */ id = usb_interface_id(c, f); if (id < 0) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 934e1bcc3c68..72a6a1087aaa 100755 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -68,11 +68,6 @@ #include #include #include -#include -#ifdef CONFIG_ARCH_RK29 -#include -#include -#endif #include #include @@ -81,7 +76,8 @@ #include "gadget_chips.h" -#define BULK_BUFFER_SIZE 16384 * 4//4096 + +#define BULK_BUFFER_SIZE 4096 /* flush after every 4 meg of writes to avoid excessive block level caching */ #define MAX_UNFLUSHED_BYTES (4 * 1024 * 1024) @@ -226,7 +222,7 @@ struct bulk_cs_wrap { #define ASC(x) ((u8) ((x) >> 8)) #define ASCQ(x) ((u8) (x)) -static int usb_msc_connected; /*usb charge status*/ + /*-------------------------------------------------------------------------*/ struct lun { @@ -471,20 +467,6 @@ static void put_be32(u8 *buf, u32 val) buf[3] = val & 0xff; } -static void set_msc_connect_flag( int connected ) -{ - printk("%s status = %d 20101216\n" , __func__, connected); - if( usb_msc_connected == connected ) - return; - usb_msc_connected = connected;//usb mass storage is ok -} - -int get_msc_connect_flag( void ) -{ - return usb_msc_connected; -} -EXPORT_SYMBOL(get_msc_connect_flag); - /*-------------------------------------------------------------------------*/ /* @@ -1151,7 +1133,6 @@ static int do_synchronize_cache(struct fsg_dev *fsg) /*-------------------------------------------------------------------------*/ -#if 0 static void invalidate_sub(struct lun *curlun) { struct file *filp = curlun->filp; @@ -1257,7 +1238,7 @@ static int do_verify(struct fsg_dev *fsg) } return 0; } -#endif + /*-------------------------------------------------------------------------*/ @@ -1830,15 +1811,6 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size, } -#ifdef CONFIG_ARCH_RK29 -static void deferred_restart(struct work_struct *dummy) -{ - sys_sync(); - kernel_restart("loader"); -} -static DECLARE_WORK(restart_work, deferred_restart); -#endif - static int do_scsi_command(struct fsg_dev *fsg) { struct fsg_buffhd *bh; @@ -1989,7 +1961,7 @@ static int do_scsi_command(struct fsg_dev *fsg) if ((reply = check_command(fsg, 10, DATA_DIR_NONE, (1<<1) | (0xf<<2) | (3<<7), 1, "VERIFY")) == 0) - reply = 0;//do_verify(fsg);//zyf 20100302 + reply = do_verify(fsg); break; case SC_WRITE_6: @@ -2036,15 +2008,6 @@ static int do_scsi_command(struct fsg_dev *fsg) reply = -EINVAL; } break; -#ifdef CONFIG_ARCH_RK29 - case 0xff: - if (fsg->cmnd_size >= 6 && fsg->cmnd[1] == 0xe0 && - fsg->cmnd[2] == 0xff && fsg->cmnd[3] == 0xff && - fsg->cmnd[4] == 0xff && fsg->cmnd[5] == 0xfe) { - schedule_work(&restart_work); - } - break; -#endif } up_read(&fsg->filesem); @@ -2311,8 +2274,6 @@ static int do_set_config(struct fsg_dev *fsg, u8 new_config) fsg->config = new_config; if ((rc = do_set_interface(fsg, 0)) != 0) fsg->config = 0; // Reset on errors - else - set_msc_connect_flag( 1 ); } switch_set_state(&fsg->sdev, new_config); @@ -2322,6 +2283,7 @@ static int do_set_config(struct fsg_dev *fsg, u8 new_config) /*-------------------------------------------------------------------------*/ + static void handle_exception(struct fsg_dev *fsg) { siginfo_t info; @@ -2671,7 +2633,6 @@ static ssize_t store_file(struct device *dev, struct device_attribute *attr, int rc = 0; DBG(fsg, "store_file: \"%s\"\n", buf); - printk("store_file: \"%s\"\n", buf); #if 0 /* disabled because we need to allow closing the backing file if the media was removed */ if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) { @@ -2955,67 +2916,12 @@ static void fsg_function_disable(struct usb_function *f) DBG(fsg, "fsg_function_disable\n"); fsg->new_config = 0; raise_exception(fsg, FSG_STATE_CONFIG_CHANGE); - // yk 201009 - set_msc_connect_flag(0); -} - -static enum power_supply_property usb_props[] = { -// POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_ONLINE, -}; - -static int usb_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int ret = 0; - - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - #ifndef CONFIG_DWC_OTG_HOST_ONLY - val->intval = get_msc_connect_flag(); - #else - val->intval = 0; - #endif - break; - default: - return -EINVAL; - } - - return ret; -} - -int usb_power_supply_register(struct device* parent) -{ - struct power_supply *ps; - int retval = 0; - - ps = kzalloc(sizeof(*ps), GFP_KERNEL); - if (!ps) { - dev_err(parent, "failed to allocate power supply data\n"); - retval = -ENOMEM; - goto out; - } - ps->name = "usb"; - ps->type = POWER_SUPPLY_TYPE_USB; - ps->properties = usb_props; - ps->num_properties = ARRAY_SIZE(usb_props); - ps->get_property = usb_get_property; - ps->external_power_changed = NULL; - retval = power_supply_register(parent, ps); - if (retval) { - dev_err(parent, "failed to register battery\n"); - goto out; - } -out: - return retval; } static int __init fsg_probe(struct platform_device *pdev) { struct usb_mass_storage_platform_data *pdata = pdev->dev.platform_data; struct fsg_dev *fsg = the_fsg; - int retval = 0; fsg->pdev = pdev; printk(KERN_INFO "fsg_probe pdata: %p\n", pdata); @@ -3032,16 +2938,7 @@ static int __init fsg_probe(struct platform_device *pdev) fsg->nluns = pdata->nluns; } - /* - * Initialize usb power supply - */ - retval = usb_power_supply_register(&pdev->dev); - if (retval != 0) - { - dev_err(&pdev->dev, "usb_power_supply_register failed\n"); - } - - return retval; + return 0; } static struct platform_driver fsg_platform_driver = { @@ -3054,7 +2951,7 @@ int mass_storage_bind_config(struct usb_configuration *c) int rc; struct fsg_dev *fsg; - printk("mass_storage_bind_config\n"); + printk(KERN_INFO "mass_storage_bind_config\n"); rc = fsg_alloc(); if (rc) return rc; -- 2.34.1