[PATCHv2 3/3] usb: gadget: nokia: Add MTP function interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the MTP interface to g_nokia.

Signed-off-by: Arnaud Mandy <ext-arnaud.2.mandy@xxxxxxxxx>
---
 drivers/usb/gadget/nokia.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index f1c2647..7525e30 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -50,6 +50,7 @@
 #include "f_obex.c"
 #include "f_serial.c"
 #include "f_phonet.c"
+#include "f_mtp.c"
 #include "u_ether.c"
 
 /*-------------------------------------------------------------------------*/
@@ -63,6 +64,11 @@
 #define STRING_PRODUCT_IDX		1
 #define STRING_DESCRIPTION_IDX		2
 
+static unsigned use_mtp;
+
+module_param(use_mtp, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(use_mtp, "whether to bind the MTP function driver");
+
 static char manufacturer_nokia[] = "Nokia";
 static const char product_nokia[] = NOKIA_LONG_NAME;
 static const char description_nokia[] = "PC-Suite Configuration";
@@ -119,6 +125,12 @@ static int __init nokia_bind_config(struct usb_configuration *c)
 {
 	int status = 0;
 
+	if (use_mtp) {
+		status = mtp_bind_config(c);
+		if (status)
+			printk(KERN_DEBUG "could not bind mtp config\n");
+	}
+
 	status = phonet_bind_config(c);
 	if (status)
 		printk(KERN_DEBUG "could not bind phonet config\n");
@@ -172,6 +184,12 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
 	struct usb_gadget	*gadget = cdev->gadget;
 	int			status;
 
+	if (use_mtp) {
+		status = gmtp_setup(cdev->gadget);
+		if (status < 0)
+			goto err_char;
+	}
+
 	status = gphonet_setup(cdev->gadget);
 	if (status < 0)
 		goto err_phonet;
@@ -240,11 +258,16 @@ err_ether:
 err_serial:
 	gphonet_cleanup();
 err_phonet:
+	if (use_mtp)
+		gmtp_cleanup();
+err_char:
 	return status;
 }
 
 static int __exit nokia_unbind(struct usb_composite_dev *cdev)
 {
+	if (use_mtp)
+		gmtp_cleanup();
 	gphonet_cleanup();
 	gserial_cleanup();
 	gether_cleanup();
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux