usb: frmnet: Add support to use multiple transport functions
Current driver supports the single instance of control and data
transport. Add support to use multiple control and data transport
pairs per port (interface) basis. Control and data transport pair is
passed by user space from
/sys/class/android_usb/android0/f_rmnet/transports
Also moved and renamed common function str_to_xport and xport_to_str
to header file and updated respecitve callers of the function.
Change-Id: Ib0ceff85a1224336f7f4929235b6a40b8f13e849
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index aa4361f..7cd0288 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -251,31 +251,6 @@
NULL,
};
-static char *transport_to_str(enum transport_type t)
-{
- switch (t) {
- case USB_GADGET_XPORT_TTY:
- return "TTY";
- case USB_GADGET_XPORT_SDIO:
- return "SDIO";
- case USB_GADGET_XPORT_SMD:
- return "SMD";
- default:
- return "NONE";
- }
-}
-
-static enum transport_type serial_str_to_transport(const char *name)
-{
- if (!strcasecmp("SDIO", name))
- return USB_GADGET_XPORT_SDIO;
- if (!strcasecmp("SMD", name))
- return USB_GADGET_XPORT_SMD;
-
- return USB_GADGET_XPORT_TTY;
-}
-
-
static int gport_setup(struct usb_configuration *c)
{
int ret = 0;
@@ -298,7 +273,7 @@
unsigned port_num;
pr_debug("%s: transport:%s f_gser:%p gserial:%p port_num:%d\n",
- __func__, transport_to_str(gser->transport),
+ __func__, xport_to_str(gser->transport),
gser, &gser->port, gser->port_num);
port_num = gserial_ports[gser->port_num].client_port_num;
@@ -315,7 +290,7 @@
break;
default:
pr_err("%s: Un-supported transport: %s\n", __func__,
- transport_to_str(gser->transport));
+ xport_to_str(gser->transport));
return -ENODEV;
}
@@ -327,7 +302,7 @@
unsigned port_num;
pr_debug("%s: transport:%s f_gser:%p gserial:%p port_num:%d\n",
- __func__, transport_to_str(gser->transport),
+ __func__, xport_to_str(gser->transport),
gser, &gser->port, gser->port_num);
port_num = gserial_ports[gser->port_num].client_port_num;
@@ -344,7 +319,7 @@
break;
default:
pr_err("%s: Un-supported transport:%s\n", __func__,
- transport_to_str(gser->transport));
+ xport_to_str(gser->transport));
return -ENODEV;
}
@@ -888,9 +863,9 @@
if (port_num >= GSERIAL_NO_PORTS)
return -ENODEV;
- transport = serial_str_to_transport(name);
+ transport = str_to_xport(name);
pr_debug("%s, port:%d, transport:%s\n", __func__,
- port_num, transport_to_str(transport));
+ port_num, xport_to_str(transport));
gserial_ports[port_num].transport = transport;
gserial_ports[port_num].port_num = port_num;