Update Android USB Gadgets to latest from the Legend tree
/drivers/usb/gadget/f_mass_storage.c
blob:cfaf0af25a5e0a27a37f396c62b3ee099d4f82d9 -> blob:d205953b12fa9bd5dd19c61b8ce7cc112de5dbb2
--- drivers/usb/gadget/f_mass_storage.c
+++ drivers/usb/gadget/f_mass_storage.c
@@ -74,6 +74,7 @@
#include <linux/usb/ch9.h>
#include <linux/usb/android_composite.h>
#include <mach/board.h>
+#include <mach/msm_hsusb.h>
#include "gadget_chips.h"
@@ -201,6 +202,7 @@ struct bulk_cs_wrap {
#define SC_WRITE_6 0x0a
#define SC_WRITE_10 0x2a
#define SC_WRITE_12 0xaa
+#define SC_PASCAL_MODE 0xff
/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
#define SS_NO_SENSE 0
@@ -357,7 +359,6 @@ struct fsg_dev {
u32 usb_amount_left;
unsigned int nluns;
- unsigned int board_nluns;
struct lun *luns;
struct lun *curlun;
@@ -415,7 +416,8 @@ static void fsg_set_ums_state(int connec
printk(KERN_INFO "%s: %d\n", __func__, connect_status);
/* USB connected */
if (connect_status == 1) {
- if (!the_fsg->ums_state) {
+ /* only need to change state when connect to USB host */
+ if (!the_fsg->ums_state && usb_get_connect_type() == 1) {
the_fsg->ums_state = 1;
printk(KERN_INFO "ums: set state 1\n");
switch_set_state(&the_fsg->sdev, 1);
@@ -1541,7 +1543,7 @@ static int do_start_stop(struct fsg_dev
if (backing_file_is_open(curlun)) {
close_backing_file(fsg, curlun);
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
- if (curlun->cdrom || board_mfg_mode() == 1) {
+ if (curlun->cdrom) {
printk(KERN_INFO "ums: eject\n");
kobject_uevent_env(&fsg->sdev.dev->kobj,
KOBJ_CHANGE, envp);
@@ -2164,6 +2166,15 @@ static int do_scsi_command(struct fsg_de
"RESERVE(6)")) == 0)
reply = do_reserve(fsg, bh);
break;
+#ifdef CONFIG_USB_ANDROID_ACM
+ case SC_PASCAL_MODE:
+ printk(KERN_INFO "SC_PASCAL_MODE\n");
+ if (!strncmp("RDEVCHG=PASCAL", (char *)&fsg->cmnd[1], 14)) {
+ printk(KERN_INFO "usb: switch to CDC ACM\n");
+ android_switch_function(0x400);
+ }
+ break;
+#endif
/* Some mandatory commands that we recognize but don't implement.
* They don't mean much in this setting. It's left as an exercise
* for anyone interested to implement RESERVE and RELEASE in terms
@@ -3081,38 +3092,10 @@ static void fsg_function_disable(struct
raise_exception(fsg, FSG_STATE_CONFIG_CHANGE);
}
-static ssize_t store_lun_num(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- unsigned nluns;
- struct fsg_dev *fsg = the_fsg;
- nluns = simple_strtoul(buf, NULL, 10);
- if (nluns > 0 && nluns <= fsg->board_nluns && (nluns != fsg->nluns)) {
- fsg->nluns = nluns;
- android_usb_set_connected(0);
- msleep(10);
- android_usb_set_connected(1);
- }
- return count;
-}
-
-static ssize_t show_lun_num(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- unsigned length;
- struct fsg_dev *fsg = the_fsg;
- length = sprintf(buf, "%d\n", fsg->nluns);
- return length;
-}
-
-static DEVICE_ATTR(lun_num, 0644, show_lun_num, store_lun_num);
-
-
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 rc;
fsg->pdev = pdev;
printk(KERN_INFO "fsg_probe pdata: %p\n", pdata);
@@ -3126,13 +3109,9 @@ static int __init fsg_probe(struct platf
if (pdata->release)
fsg->release = pdata->release;
- fsg->nluns = fsg->board_nluns = pdata->nluns;
+ fsg->nluns = pdata->nluns;
fsg->cdrom_lun = pdata->cdrom_lun;
}
- rc = device_create_file(&the_fsg->pdev->dev,
- &dev_attr_lun_num);
- if (rc != 0)
- printk(KERN_WARNING "dev_attr_lun_num failed\n");
return 0;
}