Пример #1
0
/**
 * gserial_init_port - bind a gserial_port to its transport
 */
static int gserial_init_port(int port_num, const char *name, char *serial_type)
{
	enum transport_type transport;
	enum fserial_func_type func_type;

	if (port_num >= GSERIAL_NO_PORTS)
		return -ENODEV;

	transport = str_to_xport(name);
	func_type = serial_str_to_func_type(serial_type);

	pr_info("%s, port:%d, transport:%s, type:%d\n", __func__,
				port_num, xport_to_str(transport), func_type);



	gserial_ports[port_num].transport = transport;
	gserial_ports[port_num].func_type = func_type;
	gserial_ports[port_num].port_num = port_num;

	switch (transport) {
	case USB_GADGET_XPORT_TTY:
		gserial_ports[port_num].client_port_num = no_tty_ports;
		no_tty_ports++;
		break;
	case USB_GADGET_XPORT_SDIO:
		gserial_ports[port_num].client_port_num = no_sdio_ports;
		no_sdio_ports++;
		break;
	case USB_GADGET_XPORT_SMD:
		gserial_ports[port_num].client_port_num = no_smd_ports;
		no_smd_ports++;
		break;
	case USB_GADGET_XPORT_HSIC:
		/*client port number will be updated in gport_setup*/
		no_hsic_sports++;
		break;
	case USB_GADGET_XPORT_HSUART:
		/*client port number will be updated in gport_setup*/
		no_hsuart_sports++;
		break;
	default:
		pr_err("%s: Un-supported transport transport: %u\n",
				__func__, gserial_ports[port_num].transport);
		return -ENODEV;
	}

	nr_ports++;

	return 0;
}
/**
 * gserial_init_port - bind a gserial_port to its transport
 */
static int gserial_init_port(int port_num, const char *name,
		const char *port_name)
{
	enum transport_type transport;
	int ret = 0;

	if (port_num >= GSERIAL_NO_PORTS)
		return -ENODEV;

	transport = str_to_xport(name);
	pr_debug("%s, port:%d, transport:%s\n", __func__,
			port_num, xport_to_str(transport));

	gserial_ports[port_num].transport = transport;
	gserial_ports[port_num].port_num = port_num;

	switch (transport) {
	case USB_GADGET_XPORT_TTY:
		gserial_ports[port_num].client_port_num = no_tty_ports;
		no_tty_ports++;
		break;
	case USB_GADGET_XPORT_SDIO:
		gserial_ports[port_num].client_port_num = no_sdio_ports;
		no_sdio_ports++;
		break;
	case USB_GADGET_XPORT_SMD:
		gserial_ports[port_num].client_port_num = no_smd_ports;
		no_smd_ports++;
		break;
	case USB_GADGET_XPORT_HSIC:
		ghsic_ctrl_set_port_name(port_name, name);
		ghsic_data_set_port_name(port_name, name);

		/*client port number will be updated in gport_setup*/
		no_hsic_sports++;
		break;
	case USB_GADGET_XPORT_HSUART:
		/*client port number will be updated in gport_setup*/
		no_hsuart_sports++;
		break;
	default:
		pr_err("%s: Un-supported transport transport: %u\n",
				__func__, gserial_ports[port_num].transport);
		return -ENODEV;
	}

	nr_ports++;

	return ret;
}