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);
int status;
int interfaceCount = 0;
u8 *dest;
+
/* write the config descriptor */
c = buf;
c->bLength = USB_DT_CONFIG_SIZE;
/* 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);
req->complete = composite_setup_complete;
req->length = USB_BUFSIZ;
gadget->ep0->driver_data = cdev;
+
switch (ctrl->bRequest) {
/* we handle all standard USB descriptors */
.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,
#include <linux/utsname.h>
#include <linux/wakelock.h>
#include <linux/platform_device.h>
-#include <linux/power_supply.h>
-#ifdef CONFIG_ARCH_RK29
-#include <linux/reboot.h>
-#include <linux/syscalls.h>
-#endif
#include <linux/usb.h>
#include <linux/usb_usual.h>
#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)
#define ASC(x) ((u8) ((x) >> 8))
#define ASCQ(x) ((u8) (x))
-static int usb_msc_connected; /*usb charge status*/
+
/*-------------------------------------------------------------------------*/
struct lun {
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);
-
/*-------------------------------------------------------------------------*/
/*
/*-------------------------------------------------------------------------*/
-#if 0
static void invalidate_sub(struct lun *curlun)
{
struct file *filp = curlun->filp;
}
return 0;
}
-#endif
+
/*-------------------------------------------------------------------------*/
}
-#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;
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:
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);
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);
/*-------------------------------------------------------------------------*/
+
static void handle_exception(struct fsg_dev *fsg)
{
siginfo_t info;
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)) {
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);
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 = {
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;