diff options
Diffstat (limited to 'drivers/usb/serial/omninet.c')
| -rw-r--r-- | drivers/usb/serial/omninet.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 0216ac12a27d..4adfab988e86 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
| @@ -69,6 +69,7 @@ static void omninet_write_bulk_callback (struct urb *urb); | |||
| 69 | static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 69 | static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count); |
| 70 | static int omninet_write_room (struct usb_serial_port *port); | 70 | static int omninet_write_room (struct usb_serial_port *port); |
| 71 | static void omninet_shutdown (struct usb_serial *serial); | 71 | static void omninet_shutdown (struct usb_serial *serial); |
| 72 | static int omninet_attach (struct usb_serial *serial); | ||
| 72 | 73 | ||
| 73 | static struct usb_device_id id_table [] = { | 74 | static struct usb_device_id id_table [] = { |
| 74 | { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, | 75 | { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, |
| @@ -99,6 +100,7 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
| 99 | .num_bulk_in = 1, | 100 | .num_bulk_in = 1, |
| 100 | .num_bulk_out = 2, | 101 | .num_bulk_out = 2, |
| 101 | .num_ports = 1, | 102 | .num_ports = 1, |
| 103 | .attach = omninet_attach, | ||
| 102 | .open = omninet_open, | 104 | .open = omninet_open, |
| 103 | .close = omninet_close, | 105 | .close = omninet_close, |
| 104 | .write = omninet_write, | 106 | .write = omninet_write, |
| @@ -145,22 +147,30 @@ struct omninet_data | |||
| 145 | __u8 od_outseq; // Sequence number for bulk_out URBs | 147 | __u8 od_outseq; // Sequence number for bulk_out URBs |
| 146 | }; | 148 | }; |
| 147 | 149 | ||
| 150 | static int omninet_attach (struct usb_serial *serial) | ||
| 151 | { | ||
| 152 | struct omninet_data *od; | ||
| 153 | struct usb_serial_port *port = serial->port[0]; | ||
| 154 | |||
| 155 | od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); | ||
| 156 | if( !od ) { | ||
| 157 | err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); | ||
| 158 | return -ENOMEM; | ||
| 159 | } | ||
| 160 | usb_set_serial_port_data(port, od); | ||
| 161 | return 0; | ||
| 162 | } | ||
| 163 | |||
| 148 | static int omninet_open (struct usb_serial_port *port, struct file *filp) | 164 | static int omninet_open (struct usb_serial_port *port, struct file *filp) |
| 149 | { | 165 | { |
| 150 | struct usb_serial *serial = port->serial; | 166 | struct usb_serial *serial = port->serial; |
| 151 | struct usb_serial_port *wport; | 167 | struct usb_serial_port *wport; |
| 152 | struct omninet_data *od; | 168 | struct omninet_data *od = usb_get_serial_port_data(port); |
| 153 | int result = 0; | 169 | int result = 0; |
| 154 | 170 | ||
| 155 | dbg("%s - port %d", __FUNCTION__, port->number); | 171 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 156 | 172 | ||
| 157 | od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); | 173 | od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); |
| 158 | if( !od ) { | ||
| 159 | err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); | ||
| 160 | return -ENOMEM; | ||
| 161 | } | ||
| 162 | |||
| 163 | usb_set_serial_port_data(port, od); | ||
| 164 | wport = serial->port[1]; | 174 | wport = serial->port[1]; |
| 165 | wport->tty = port->tty; | 175 | wport->tty = port->tty; |
| 166 | 176 | ||
| @@ -170,24 +180,17 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) | |||
| 170 | port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, | 180 | port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, |
| 171 | omninet_read_bulk_callback, port); | 181 | omninet_read_bulk_callback, port); |
| 172 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); | 182 | result = usb_submit_urb(port->read_urb, GFP_KERNEL); |
| 173 | if (result) | 183 | if (result) { |
| 174 | err("%s - failed submitting read urb, error %d", __FUNCTION__, result); | 184 | err("%s - failed submitting read urb, error %d", __FUNCTION__, result); |
| 185 | } | ||
| 175 | 186 | ||
| 176 | return result; | 187 | return result; |
| 177 | } | 188 | } |
| 178 | 189 | ||
| 179 | static void omninet_close (struct usb_serial_port *port, struct file * filp) | 190 | static void omninet_close (struct usb_serial_port *port, struct file * filp) |
| 180 | { | 191 | { |
| 181 | struct usb_serial *serial = port->serial; | ||
| 182 | struct usb_serial_port *wport; | ||
| 183 | |||
| 184 | dbg("%s - port %d", __FUNCTION__, port->number); | 192 | dbg("%s - port %d", __FUNCTION__, port->number); |
| 185 | |||
| 186 | wport = serial->port[1]; | ||
| 187 | usb_kill_urb(wport->write_urb); | ||
| 188 | usb_kill_urb(port->read_urb); | 193 | usb_kill_urb(port->read_urb); |
| 189 | |||
| 190 | kfree(usb_get_serial_port_data(port)); | ||
| 191 | } | 194 | } |
| 192 | 195 | ||
| 193 | 196 | ||
| @@ -326,7 +329,12 @@ static void omninet_write_bulk_callback (struct urb *urb) | |||
| 326 | 329 | ||
| 327 | static void omninet_shutdown (struct usb_serial *serial) | 330 | static void omninet_shutdown (struct usb_serial *serial) |
| 328 | { | 331 | { |
| 332 | struct usb_serial_port *wport = serial->port[1]; | ||
| 333 | struct usb_serial_port *port = serial->port[0]; | ||
| 329 | dbg ("%s", __FUNCTION__); | 334 | dbg ("%s", __FUNCTION__); |
| 335 | |||
| 336 | usb_kill_urb(wport->write_urb); | ||
| 337 | kfree(usb_get_serial_port_data(port)); | ||
| 330 | } | 338 | } |
| 331 | 339 | ||
| 332 | 340 | ||
