diff options
Diffstat (limited to 'drivers/usb/serial/io_edgeport.c')
-rw-r--r-- | drivers/usb/serial/io_edgeport.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 8e6faaf3580c..5acc0d13864a 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -225,6 +225,8 @@ static int edge_get_icount(struct tty_struct *tty, | |||
225 | static int edge_startup(struct usb_serial *serial); | 225 | static int edge_startup(struct usb_serial *serial); |
226 | static void edge_disconnect(struct usb_serial *serial); | 226 | static void edge_disconnect(struct usb_serial *serial); |
227 | static void edge_release(struct usb_serial *serial); | 227 | static void edge_release(struct usb_serial *serial); |
228 | static int edge_port_probe(struct usb_serial_port *port); | ||
229 | static int edge_port_remove(struct usb_serial_port *port); | ||
228 | 230 | ||
229 | #include "io_tables.h" /* all of the devices that this driver supports */ | 231 | #include "io_tables.h" /* all of the devices that this driver supports */ |
230 | 232 | ||
@@ -2875,10 +2877,9 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) | |||
2875 | static int edge_startup(struct usb_serial *serial) | 2877 | static int edge_startup(struct usb_serial *serial) |
2876 | { | 2878 | { |
2877 | struct edgeport_serial *edge_serial; | 2879 | struct edgeport_serial *edge_serial; |
2878 | struct edgeport_port *edge_port; | ||
2879 | struct usb_device *dev; | 2880 | struct usb_device *dev; |
2880 | struct device *ddev = &serial->dev->dev; | 2881 | struct device *ddev = &serial->dev->dev; |
2881 | int i, j; | 2882 | int i; |
2882 | int response; | 2883 | int response; |
2883 | bool interrupt_in_found; | 2884 | bool interrupt_in_found; |
2884 | bool bulk_in_found; | 2885 | bool bulk_in_found; |
@@ -2961,25 +2962,6 @@ static int edge_startup(struct usb_serial *serial) | |||
2961 | /* we set up the pointers to the endpoints in the edge_open function, | 2962 | /* we set up the pointers to the endpoints in the edge_open function, |
2962 | * as the structures aren't created yet. */ | 2963 | * as the structures aren't created yet. */ |
2963 | 2964 | ||
2964 | /* set up our port private structures */ | ||
2965 | for (i = 0; i < serial->num_ports; ++i) { | ||
2966 | edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); | ||
2967 | if (edge_port == NULL) { | ||
2968 | dev_err(ddev, "%s - Out of memory\n", __func__); | ||
2969 | for (j = 0; j < i; ++j) { | ||
2970 | kfree(usb_get_serial_port_data(serial->port[j])); | ||
2971 | usb_set_serial_port_data(serial->port[j], | ||
2972 | NULL); | ||
2973 | } | ||
2974 | usb_set_serial_data(serial, NULL); | ||
2975 | kfree(edge_serial); | ||
2976 | return -ENOMEM; | ||
2977 | } | ||
2978 | spin_lock_init(&edge_port->ep_lock); | ||
2979 | edge_port->port = serial->port[i]; | ||
2980 | usb_set_serial_port_data(serial->port[i], edge_port); | ||
2981 | } | ||
2982 | |||
2983 | response = 0; | 2965 | response = 0; |
2984 | 2966 | ||
2985 | if (edge_serial->is_epic) { | 2967 | if (edge_serial->is_epic) { |
@@ -3120,14 +3102,36 @@ static void edge_disconnect(struct usb_serial *serial) | |||
3120 | static void edge_release(struct usb_serial *serial) | 3102 | static void edge_release(struct usb_serial *serial) |
3121 | { | 3103 | { |
3122 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); | 3104 | struct edgeport_serial *edge_serial = usb_get_serial_data(serial); |
3123 | int i; | ||
3124 | |||
3125 | for (i = 0; i < serial->num_ports; ++i) | ||
3126 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
3127 | 3105 | ||
3128 | kfree(edge_serial); | 3106 | kfree(edge_serial); |
3129 | } | 3107 | } |
3130 | 3108 | ||
3109 | static int edge_port_probe(struct usb_serial_port *port) | ||
3110 | { | ||
3111 | struct edgeport_port *edge_port; | ||
3112 | |||
3113 | edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); | ||
3114 | if (!edge_port) | ||
3115 | return -ENOMEM; | ||
3116 | |||
3117 | spin_lock_init(&edge_port->ep_lock); | ||
3118 | edge_port->port = port; | ||
3119 | |||
3120 | usb_set_serial_port_data(port, edge_port); | ||
3121 | |||
3122 | return 0; | ||
3123 | } | ||
3124 | |||
3125 | static int edge_port_remove(struct usb_serial_port *port) | ||
3126 | { | ||
3127 | struct edgeport_port *edge_port; | ||
3128 | |||
3129 | edge_port = usb_get_serial_port_data(port); | ||
3130 | kfree(edge_port); | ||
3131 | |||
3132 | return 0; | ||
3133 | } | ||
3134 | |||
3131 | module_usb_serial_driver(serial_drivers, id_table_combined); | 3135 | module_usb_serial_driver(serial_drivers, id_table_combined); |
3132 | 3136 | ||
3133 | MODULE_AUTHOR(DRIVER_AUTHOR); | 3137 | MODULE_AUTHOR(DRIVER_AUTHOR); |