[PATCH v2 7/8] usb/gadget: nokia: convert to new interface of f_phonet

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

 



Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
---
 drivers/usb/gadget/Kconfig |    1 +
 drivers/usb/gadget/nokia.c |   51 +++++++++++++++++++++++++++++--------------
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a4cb286..2fdc78b 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -939,6 +939,7 @@ config USB_G_NOKIA
 	select USB_F_ACM
 	select USB_F_ECM
 	select USB_F_OBEX
+	select USB_F_PHONET
 	help
 	  The Nokia composite gadget provides support for acm, obex
 	  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index be8d747..f20e55f 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -30,19 +30,6 @@
 #define NOKIA_VERSION_NUM		0x0211
 #define NOKIA_LONG_NAME			"N900 (PC-Suite Mode)"
 
-/*-------------------------------------------------------------------------*/
-
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
- */
-#define USBF_PHONET_INCLUDED
-#include "f_phonet.c"
-
-/*-------------------------------------------------------------------------*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 #define NOKIA_VENDOR_ID			0x0421	/* Nokia */
@@ -103,6 +90,8 @@ static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
+static struct usb_function *f_phonet_cfg1;
+static struct usb_function *f_phonet_cfg2;
 static u8 hostaddr[ETH_ALEN];
 static struct eth_dev *the_dev;
 static struct net_device *phonet_dev;
@@ -128,21 +117,30 @@ static struct usb_function_instance *fi_acm;
 static struct usb_function_instance *fi_ecm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
+static struct usb_function_instance *fi_phonet;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
 	struct usb_function *f_acm;
 	struct usb_function *f_ecm;
+	struct usb_function *f_phonet = NULL;
 	struct usb_function *f_obex1 = NULL;
 	struct usb_function *f_obex2 = NULL;
+	struct f_phonet_opts *phonet_opts;
 	struct f_ecm_opts *ecm_opts;
 	int status = 0;
 	int obex1_stat = 0;
 	int obex2_stat = 0;
-
-	status = phonet_bind_config(c, phonet_dev);
-	if (status)
-		printk(KERN_DEBUG "could not bind phonet config\n");
+	int phonet_stat = 0;
+
+	if (!IS_ERR(fi_phonet)) {
+		phonet_opts = container_of(fi_phonet, struct f_phonet_opts,
+					   func_inst);
+		phonet_opts->dev = phonet_dev;
+		f_phonet = usb_get_function(fi_phonet);
+		if (IS_ERR(f_phonet))
+			printk(KERN_DEBUG "could not get phonet function\n");
+	}
 
 	if (!IS_ERR(fi_obex1)) {
 		f_obex1 = usb_get_function(fi_obex1);
@@ -172,6 +170,12 @@ static int __init nokia_bind_config(struct usb_configuration *c)
 		goto err_get_ecm;
 	}
 
+	if (!IS_ERR_OR_NULL(f_phonet)) {
+		phonet_stat = usb_add_function(c, f_phonet);
+		if (phonet_stat)
+			printk(KERN_DEBUG "could not add phonet function\n");
+	}
+
 	if (!IS_ERR_OR_NULL(f_obex1)) {
 		obex1_stat = usb_add_function(c, f_obex1);
 		if (obex1_stat)
@@ -197,11 +201,13 @@ static int __init nokia_bind_config(struct usb_configuration *c)
 	if (c == &nokia_config_500ma_driver) {
 		f_acm_cfg1 = f_acm;
 		f_ecm_cfg1 = f_ecm;
+		f_phonet_cfg1 = f_phonet;
 		f_obex1_cfg1 = f_obex1;
 		f_obex2_cfg1 = f_obex2;
 	} else {
 		f_acm_cfg2 = f_acm;
 		f_ecm_cfg2 = f_ecm;
+		f_phonet_cfg2 = f_phonet;
 		f_obex1_cfg2 = f_obex1;
 		f_obex2_cfg2 = f_obex2;
 	}
@@ -214,6 +220,8 @@ err_conf:
 		usb_remove_function(c, f_obex2);
 	if (!obex1_stat)
 		usb_remove_function(c, f_obex1);
+	if (!phonet_stat)
+		usb_remove_function(c, f_phonet);
 	usb_put_function(f_ecm);
 err_get_ecm:
 	usb_put_function(f_acm);
@@ -222,6 +230,8 @@ err_get_acm:
 		usb_put_function(f_obex2);
 	if (!IS_ERR_OR_NULL(f_obex1))
 		usb_put_function(f_obex1);
+	if (!IS_ERR_OR_NULL(f_phonet))
+		usb_put_function(f_phonet);
 	return status;
 }
 
@@ -256,6 +266,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
 		goto err_usb;
 	}
 
+	fi_phonet = usb_get_function_instance("phonet");
+
 	fi_obex1 = usb_get_function_instance("obex");
 
 	fi_obex2 = usb_get_function_instance("obex");
@@ -300,6 +312,8 @@ err_ecm_inst:
 err_acm_inst:
 	usb_put_function_instance(fi_acm);
 err_obex2_inst:
+	if (!IS_ERR(fi_phonet))
+		usb_put_function_instance(fi_phonet);
 	if (!IS_ERR(fi_obex2))
 		usb_put_function_instance(fi_obex2);
 	if (!IS_ERR(fi_obex1))
@@ -326,6 +340,9 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)
 	usb_put_function(f_acm_cfg2);
 	usb_put_function(f_ecm_cfg1);
 	usb_put_function(f_ecm_cfg2);
+
+	if (!IS_ERR(fi_phonet))
+		usb_put_function_instance(fi_phonet);
 	if (!IS_ERR(fi_obex1))
 		usb_put_function_instance(fi_obex1);
 	if (!IS_ERR(fi_obex2))
-- 
1.7.0.4

--
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