Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: f81534: clean up port bulk-out setup

Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.

Signed-off-by: Johan Hovold <johan@kernel.org>

+11 -51
+11 -51
drivers/usb/serial/f81534.c
··· 687 687 num_port = 4; /* Nothing found, oldest version IC */ 688 688 } 689 689 690 + /* 691 + * Setup bulk-out endpoint multiplexing. All ports share the same 692 + * bulk-out endpoint. 693 + */ 694 + BUILD_BUG_ON(ARRAY_SIZE(epds->bulk_out) < F81534_NUM_PORT); 695 + 696 + for (i = 1; i < num_port; ++i) 697 + epds->bulk_out[i] = epds->bulk_out[0]; 698 + 699 + epds->num_bulk_out = num_port; 700 + 690 701 return num_port; 691 702 } 692 703 ··· 1089 1078 } 1090 1079 } 1091 1080 1092 - static int f81534_setup_ports(struct usb_serial *serial) 1093 - { 1094 - struct usb_serial_port *port; 1095 - u8 port0_out_address; 1096 - int buffer_size; 1097 - size_t i; 1098 - 1099 - /* 1100 - * In our system architecture, we had 2 or 4 serial ports, 1101 - * but only get 1 set of bulk in/out endpoints. 1102 - * 1103 - * The usb-serial subsystem will generate port 0 data, 1104 - * but port 1/2/3 will not. It's will generate write URB and buffer 1105 - * by following code and use the port0 read URB for read operation. 1106 - */ 1107 - for (i = 1; i < serial->num_ports; ++i) { 1108 - port0_out_address = serial->port[0]->bulk_out_endpointAddress; 1109 - buffer_size = serial->port[0]->bulk_out_size; 1110 - port = serial->port[i]; 1111 - 1112 - if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) 1113 - return -ENOMEM; 1114 - 1115 - port->bulk_out_size = buffer_size; 1116 - port->bulk_out_endpointAddress = port0_out_address; 1117 - 1118 - port->write_urbs[0] = usb_alloc_urb(0, GFP_KERNEL); 1119 - if (!port->write_urbs[0]) 1120 - return -ENOMEM; 1121 - 1122 - port->bulk_out_buffers[0] = kzalloc(buffer_size, GFP_KERNEL); 1123 - if (!port->bulk_out_buffers[0]) 1124 - return -ENOMEM; 1125 - 1126 - usb_fill_bulk_urb(port->write_urbs[0], serial->dev, 1127 - usb_sndbulkpipe(serial->dev, 1128 - port0_out_address), 1129 - port->bulk_out_buffers[0], buffer_size, 1130 - serial->type->write_bulk_callback, port); 1131 - 1132 - port->write_urb = port->write_urbs[0]; 1133 - port->bulk_out_buffer = port->bulk_out_buffers[0]; 1134 - } 1135 - 1136 - return 0; 1137 - } 1138 - 1139 1081 static int f81534_attach(struct usb_serial *serial) 1140 1082 { 1141 1083 struct f81534_serial_private *serial_priv; ··· 1104 1140 usb_set_serial_data(serial, serial_priv); 1105 1141 1106 1142 mutex_init(&serial_priv->urb_mutex); 1107 - 1108 - status = f81534_setup_ports(serial); 1109 - if (status) 1110 - return status; 1111 1143 1112 1144 /* Check had custom setting */ 1113 1145 status = f81534_find_config_idx(serial, &serial_priv->setting_idx);