aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/nokia.c
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-05-23 10:51:12 +0200
committerFelipe Balbi <balbi@ti.com>2013-06-10 17:31:39 +0300
commit83167f12da059799072128e91ab692613d8237ee (patch)
tree4a1adf86f5a16bc4e8f023ca9da621dc39c36df4 /drivers/usb/gadget/nokia.c
parentusb: gadget: f_phonet: convert to new function interface with backward compatibility (diff)
downloadlinux-dev-83167f12da059799072128e91ab692613d8237ee.tar.xz
linux-dev-83167f12da059799072128e91ab692613d8237ee.zip
usb: gadget: nokia: convert to new interface of f_phonet
use the new interface which will allow us to deprecate the legacy way of binding functions. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/nokia.c')
-rw-r--r--drivers/usb/gadget/nokia.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index a20bcbfe4a6e..084f947ffd79 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -40,8 +40,6 @@
*/
#define USBF_ECM_INCLUDED
#include "f_ecm.c"
-#define USBF_PHONET_INCLUDED
-#include "f_phonet.c"
#include "u_ether.h"
/*-------------------------------------------------------------------------*/
@@ -106,8 +104,9 @@ 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 struct eth_dev *the_dev;
-static struct net_device *phonet_dev;
static struct usb_configuration nokia_config_500ma_driver = {
@@ -129,19 +128,24 @@ static struct usb_configuration nokia_config_100ma_driver = {
static struct usb_function_instance *fi_acm;
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_phonet = NULL;
struct usb_function *f_obex1 = NULL;
struct usb_function *f_obex2 = NULL;
int status = 0;
int obex1_stat = 0;
int obex2_stat = 0;
+ int phonet_stat = 0;
- status = phonet_bind_config(c, phonet_dev);
- if (status)
- pr_debug("could not bind phonet config\n");
+ if (!IS_ERR(fi_phonet)) {
+ f_phonet = usb_get_function(fi_phonet);
+ if (IS_ERR(f_phonet))
+ pr_debug("could not get phonet function\n");
+ }
if (!IS_ERR(fi_obex1)) {
f_obex1 = usb_get_function(fi_obex1);
@@ -161,6 +165,12 @@ static int __init nokia_bind_config(struct usb_configuration *c)
goto err_get_acm;
}
+ if (!IS_ERR_OR_NULL(f_phonet)) {
+ phonet_stat = usb_add_function(c, f_phonet);
+ if (phonet_stat)
+ pr_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)
@@ -184,10 +194,12 @@ static int __init nokia_bind_config(struct usb_configuration *c)
}
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
+ f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
+ f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
}
@@ -200,12 +212,16 @@ 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_acm);
err_get_acm:
if (!IS_ERR_OR_NULL(f_obex2))
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;
}
@@ -214,12 +230,6 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
struct usb_gadget *gadget = cdev->gadget;
int status;
- phonet_dev = gphonet_setup(cdev->gadget);
- if (IS_ERR(phonet_dev)) {
- status = PTR_ERR(phonet_dev);
- goto err_phonet;
- }
-
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
qmult);
if (IS_ERR(the_dev)) {
@@ -239,6 +249,10 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
if (!gadget_supports_altsettings(gadget))
goto err_usb;
+ fi_phonet = usb_get_function_instance("phonet");
+ if (IS_ERR(fi_phonet))
+ pr_debug("could not find phonet function\n");
+
fi_obex1 = usb_get_function_instance("obex");
if (IS_ERR(fi_obex1))
pr_debug("could not find obex function 1\n");
@@ -273,6 +287,8 @@ err_put_cfg1:
usb_put_function(f_obex1_cfg1);
if (!IS_ERR_OR_NULL(f_obex2_cfg1))
usb_put_function(f_obex2_cfg1);
+ if (!IS_ERR_OR_NULL(f_phonet_cfg1))
+ usb_put_function(f_phonet_cfg1);
err_acm_inst:
usb_put_function_instance(fi_acm);
err_obex2_inst:
@@ -280,11 +296,11 @@ err_obex2_inst:
usb_put_function_instance(fi_obex2);
if (!IS_ERR(fi_obex1))
usb_put_function_instance(fi_obex1);
+ if (!IS_ERR(fi_phonet))
+ usb_put_function_instance(fi_phonet);
err_usb:
gether_cleanup(the_dev);
err_ether:
- gphonet_cleanup(phonet_dev);
-err_phonet:
return status;
}
@@ -298,14 +314,20 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)
usb_put_function(f_obex1_cfg1);
if (!IS_ERR_OR_NULL(f_obex2_cfg1))
usb_put_function(f_obex2_cfg1);
+ if (!IS_ERR_OR_NULL(f_phonet_cfg1))
+ usb_put_function(f_phonet_cfg1);
+ if (!IS_ERR_OR_NULL(f_phonet_cfg2))
+ usb_put_function(f_phonet_cfg2);
usb_put_function(f_acm_cfg1);
usb_put_function(f_acm_cfg2);
- if (!IS_ERR(fi_obex1))
- usb_put_function_instance(fi_obex1);
+
if (!IS_ERR(fi_obex2))
usb_put_function_instance(fi_obex2);
+ if (!IS_ERR(fi_obex1))
+ usb_put_function_instance(fi_obex1);
+ if (!IS_ERR(fi_phonet))
+ usb_put_function_instance(fi_phonet);
usb_put_function_instance(fi_acm);
- gphonet_cleanup(phonet_dev);
gether_cleanup(the_dev);