Update Android USB Gadgets to latest from the Legend tree
/drivers/usb/gadget/diag.c
blob:28723f60f628c27d591907fa005f12fe2ee766f3 -> blob:78253430b80e5c3b4daaaa15907ff7d4e7930d9d
--- drivers/usb/gadget/diag.c
+++ drivers/usb/gadget/diag.c
@@ -29,6 +29,8 @@
#include <linux/usb/android_composite.h>
+/*#define DIAG_DEBUG*/
+
#define NO_HDLC 1
#define ROUTE_TO_USERSPACE 1
@@ -72,6 +74,9 @@ static void TRACE(const char *tag, const
}
#endif
+
+
+
#define HDLC_MAX 4096
#define SMD_MAX 8192
@@ -79,8 +84,8 @@ static void TRACE(const char *tag, const
#define RX_REQ_BUF_SZ 8192
/* number of tx/rx requests to allocate */
-#define TX_REQ_NUM 4
-#define RX_REQ_NUM 4
+#define TX_REQ_NUM 32
+#define RX_REQ_NUM 32
struct diag_context {
struct usb_function function;
@@ -219,6 +224,7 @@ static inline struct diag_context *func_
return container_of(f, struct diag_context, function);
}
+static int msm_diag_probe(struct platform_device *pdev);
static void smd_try_to_send(struct diag_context *ctxt);
static void smd_diag_notify(void *priv, unsigned event);
@@ -334,6 +340,10 @@ static long diag_ioctl(struct file *file
unsigned char temp_id_table[ID_TABLE_SZ];
printk(KERN_INFO "diag:diag_ioctl() cmd=%d\n", cmd);
+#ifdef DIAG_DEBUG
+ printk(KERN_INFO "%s:%s(parent:%s): tgid=%d\n", __func__,
+ current->comm, current->parent->comm, current->tgid);
+#endif
if (_IOC_TYPE(cmd) != USB_DIAG_IOC_MAGIC)
return -ENOTTY;
@@ -343,7 +353,7 @@ static long diag_ioctl(struct file *file
if (copy_from_user(&tmp_value, argp, sizeof(int)))
return -EFAULT;
printk(KERN_INFO "diag: enable %d\n", tmp_value);
- android_enable_function(&_context.function, tmp_value, true);
+ android_enable_function(&_context.function, tmp_value);
smd_diag_enable("diag_ioctl", tmp_value);
/* force diag_read to return error when disable diag */
if (tmp_value == 0)
@@ -456,6 +466,7 @@ static ssize_t diag_write(struct file *f
((req = req_get(ctxt, &ctxt->tx_req_idle)) || !ctxt->online));
mutex_lock(&ctxt->user_lock);
+
if (ret < 0) {
pr_err("%s: wait_event_interruptible error %d\n",
__func__, ret);
@@ -503,11 +514,14 @@ static int diag_open(struct inode *ip, s
int rc = 0;
mutex_lock(&ctxt->user_lock);
+
if (ctxt->opened) {
pr_err("%s: already opened\n", __func__);
rc = -EBUSY;
goto done;
}
+
+
ctxt->user_read_len = 0;
ctxt->user_readp = 0;
if (!ctxt->user_read_buf) {
@@ -605,6 +619,7 @@ static int diag2arm9_release(struct inod
printk(KERN_INFO "%s\n", __func__);
mutex_lock(&ctxt->diag2arm9_lock);
ctxt->diag2arm9_opened = false;
+ ctxt->is2ARM11 = 0;
wake_up(&ctxt->read_arm9_wq);
mutex_lock(&ctxt->diag2arm9_read_lock);
while ((req = req_get(ctxt, &ctxt->rx_arm9_idle)))
@@ -909,6 +924,7 @@ again:
ctxt->rx_count += r;
if (!ctxt->online) {
+ /* printk("$$$ discard %d\n", r);*/
req_put(ctxt, &ctxt->tx_req_idle, req);
goto again;
}
@@ -1161,7 +1177,6 @@ static void diag_function_disable(struct
usb_ep_disable(ctxt->in);
usb_ep_disable(ctxt->out);
}
-
#if defined(CONFIG_MSM_N_WAY_SMD)
static void diag_qdsp_send(struct diag_context *ctxt)
{
@@ -1208,31 +1223,33 @@ static void diag_qdsp_notify(void *priv,
diag_qdsp_send(ctxt);
}
+static struct platform_driver msm_smd_qdsp_ch1_driver = {
+ .probe = msm_diag_probe,
+ .driver = {
+ .name = "DSP_DIAG",
+ .owner = THIS_MODULE,
+ },
+};
+#endif
+
static int msm_diag_probe(struct platform_device *pdev)
{
struct diag_context *ctxt = &_context;
ctxt->pdev = pdev;
printk(KERN_INFO "diag:msm_diag_probe(), pdev->id=0x%x\n", pdev->id);
+#if defined(CONFIG_MSM_N_WAY_SMD)
if (pdev->id == 1)
smd_open("DSP_DIAG", &ctxt->chqdsp, ctxt, diag_qdsp_notify);
+#endif
return 0;
}
-static struct platform_driver msm_smd_qdsp_ch1_driver = {
- .probe = msm_diag_probe,
- .driver = {
- .name = "DSP_DIAG",
- .owner = THIS_MODULE,
- },
-};
-#endif
-
static int diag_set_enabled(const char *val, struct kernel_param *kp)
{
int enabled = simple_strtol(val, NULL, 0);
if (_context.cdev)
- android_enable_function(&_context.function, enabled, true);
+ android_enable_function(&_context.function, enabled);
_context.function_enable = !!enabled;
smd_diag_enable("diag_set_enabled", enabled);
return 0;
@@ -1278,7 +1295,12 @@ int diag_bind_config(struct usb_configur
ctxt->function.set_alt = diag_function_set_alt;
ctxt->function.disable = diag_function_disable;
+/* Workaround: enable diag first */
+#ifdef CONFIG_MACH_MECHA
+ ctxt->function.hidden = 0;
+#else
ctxt->function.hidden = !_context.function_enable;
+#endif
if (!ctxt->function.hidden)
smd_diag_enable("diag_bind_config", 1);