aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/metro-usb.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 16:55:41 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 16:55:41 -0500
commit9fbd1649d54edc614c64ab075f7485622fd6450a (patch)
tree5d4426972545fdbdd77e9abc2f378c2ad92083af /drivers/usb/serial/metro-usb.c
parentd4cbd6e990a798d21577ee2f42a3880da09edf3a (diff)
USB: serial: metro-usb: remove function prototypes
By rearranging the functions a bit, we can remove all function prototypes. Note, this also deleted the _close function, as it wasn't needed, it was doing the same thing the cleanup function did, so just call that instead. Cc: Aleksey Babahin <tamerlan311@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/metro-usb.c')
-rw-r--r--drivers/usb/serial/metro-usb.c263
1 files changed, 117 insertions, 146 deletions
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 66e9355cfd00..8758e01289b9 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -56,89 +56,115 @@ MODULE_DEVICE_TABLE(usb, id_table);
56/* Input parameter constants. */ 56/* Input parameter constants. */
57static bool debug; 57static bool debug;
58 58
59/* Function prototypes. */
60static void metrousb_cleanup(struct usb_serial_port *port);
61static void metrousb_close(struct usb_serial_port *port);
62static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port);
63static void metrousb_read_int_callback(struct urb *urb);
64static void metrousb_shutdown(struct usb_serial *serial);
65static int metrousb_startup(struct usb_serial *serial);
66static void metrousb_throttle(struct tty_struct *tty);
67static int metrousb_tiocmget(struct tty_struct *tty);
68static int metrousb_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear);
69static void metrousb_unthrottle(struct tty_struct *tty);
70
71/* Driver structure. */
72static struct usb_driver metrousb_driver = {
73 .name = "metro-usb",
74 .probe = usb_serial_probe,
75 .disconnect = usb_serial_disconnect,
76 .id_table = id_table
77};
78
79/* Device structure. */
80static struct usb_serial_driver metrousb_device = {
81 .driver = {
82 .owner = THIS_MODULE,
83 .name = "metro-usb",
84 },
85 .description = "Metrologic USB to serial converter.",
86 .id_table = id_table,
87 .num_ports = 1,
88 .open = metrousb_open,
89 .close = metrousb_close,
90 .read_int_callback = metrousb_read_int_callback,
91 .attach = metrousb_startup,
92 .release = metrousb_shutdown,
93 .throttle = metrousb_throttle,
94 .unthrottle = metrousb_unthrottle,
95 .tiocmget = metrousb_tiocmget,
96 .tiocmset = metrousb_tiocmset,
97};
98
99static struct usb_serial_driver * const serial_drivers[] = {
100 &metrousb_device,
101 NULL,
102};
103
104/* ---------------------------------------------------------------------------------------------- 59/* ----------------------------------------------------------------------------------------------
105 Description: 60 Description:
106 Clean up any urbs and port information. 61 Read the port from the read interrupt.
107 62
108 Input: 63 Input:
109 struct usb_serial_port *: pointer to a usb_serial_port structure. 64 struct urb *: urb structure to get data.
65 struct pt_regs *: pt_regs structure.
110 66
111 Output: 67 Output:
112 int: Returns true (0) if successful, false otherwise. 68 None:
113*/ 69*/
114static void metrousb_cleanup(struct usb_serial_port *port) 70static void metrousb_read_int_callback(struct urb *urb)
115{ 71{
72 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
73 struct metrousb_private *metro_priv = usb_get_serial_port_data(port);
74 struct tty_struct *tty;
75 unsigned char *data = urb->transfer_buffer;
76 int throttled = 0;
77 int result = 0;
78 unsigned long flags = 0;
79
116 dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number); 80 dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
117 81
118 if (port->serial->dev) { 82 switch (urb->status) {
119 /* Shutdown any interrupt in urbs. */ 83 case 0:
120 if (port->interrupt_in_urb) { 84 /* Success status, read from the port. */
121 usb_unlink_urb(port->interrupt_in_urb); 85 break;
122 usb_kill_urb(port->interrupt_in_urb); 86 case -ECONNRESET:
87 case -ENOENT:
88 case -ESHUTDOWN:
89 /* urb has been terminated. */
90 dbg("METRO-USB - %s - urb shutting down, port number=%d, error code=%d",
91 __FUNCTION__, port->number, result);
92 return;
93 default:
94 dbg("METRO-USB - %s - non-zero urb received, port number=%d, error code=%d",
95 __FUNCTION__, port->number, result);
96 goto exit;
97 }
98
99
100 /* Set the data read from the usb port into the serial port buffer. */
101 tty = tty_port_tty_get(&port->port);
102 if (!tty) {
103 dbg("%s - bad tty pointer - exiting", __func__);
104 return;
105 }
106
107 if (tty && urb->actual_length) {
108 /* Loop through the data copying each byte to the tty layer. */
109 tty_insert_flip_string(tty, data, urb->actual_length);
110
111 /* Force the data to the tty layer. */
112 tty_flip_buffer_push(tty);
113 }
114 tty_kref_put(tty);
115
116 /* Set any port variables. */
117 spin_lock_irqsave(&metro_priv->lock, flags);
118 throttled = metro_priv->throttled;
119 spin_unlock_irqrestore(&metro_priv->lock, flags);
120
121 /* Continue trying to read if set. */
122 if (!throttled) {
123 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
124 usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress),
125 port->interrupt_in_urb->transfer_buffer,
126 port->interrupt_in_urb->transfer_buffer_length,
127 metrousb_read_int_callback, port, 1);
128
129 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
130
131 if (result) {
132 dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
133 __FUNCTION__, port->number, result);
123 } 134 }
124 } 135 }
136 return;
137
138exit:
139 /* Try to resubmit the urb. */
140 result = usb_submit_urb(urb, GFP_ATOMIC);
141 if (result) {
142 dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
143 __FUNCTION__, port->number, result);
144 }
125} 145}
126 146
127/* ---------------------------------------------------------------------------------------------- 147/* ----------------------------------------------------------------------------------------------
128 Description: 148 Description:
129 Close the open serial port. Cleanup any open serial port information. 149 Clean up any urbs and port information.
130 150
131 Input: 151 Input:
132 struct usb_serial_port *: pointer to a usb_serial_port structure. 152 struct usb_serial_port *: pointer to a usb_serial_port structure.
133 struct file *: pointer to a file structure.
134 153
135 Output: 154 Output:
136 int: Returns true (0) if successful, false otherwise. 155 int: Returns true (0) if successful, false otherwise.
137*/ 156*/
138static void metrousb_close(struct usb_serial_port *port) 157static void metrousb_cleanup(struct usb_serial_port *port)
139{ 158{
140 dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number); 159 dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
141 metrousb_cleanup(port); 160
161 if (port->serial->dev) {
162 /* Shutdown any interrupt in urbs. */
163 if (port->interrupt_in_urb) {
164 usb_unlink_urb(port->interrupt_in_urb);
165 usb_kill_urb(port->interrupt_in_urb);
166 }
167 }
142} 168}
143 169
144/* ---------------------------------------------------------------------------------------------- 170/* ----------------------------------------------------------------------------------------------
@@ -205,94 +231,6 @@ exit:
205 231
206/* ---------------------------------------------------------------------------------------------- 232/* ----------------------------------------------------------------------------------------------
207 Description: 233 Description:
208 Read the port from the read interrupt.
209
210 Input:
211 struct urb *: urb structure to get data.
212 struct pt_regs *: pt_regs structure.
213
214 Output:
215 None:
216*/
217static void metrousb_read_int_callback(struct urb *urb)
218{
219 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
220 struct metrousb_private *metro_priv = usb_get_serial_port_data(port);
221 struct tty_struct *tty;
222 unsigned char *data = urb->transfer_buffer;
223 int throttled = 0;
224 int result = 0;
225 unsigned long flags = 0;
226
227 dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
228
229 switch (urb->status) {
230 case 0:
231 /* Success status, read from the port. */
232 break;
233 case -ECONNRESET:
234 case -ENOENT:
235 case -ESHUTDOWN:
236 /* urb has been terminated. */
237 dbg("METRO-USB - %s - urb shutting down, port number=%d, error code=%d",
238 __FUNCTION__, port->number, result);
239 return;
240 default:
241 dbg("METRO-USB - %s - non-zero urb received, port number=%d, error code=%d",
242 __FUNCTION__, port->number, result);
243 goto exit;
244 }
245
246
247 /* Set the data read from the usb port into the serial port buffer. */
248 tty = tty_port_tty_get(&port->port);
249 if (!tty) {
250 dbg("%s - bad tty pointer - exiting", __func__);
251 return;
252 }
253
254 if (tty && urb->actual_length) {
255 /* Loop through the data copying each byte to the tty layer. */
256 tty_insert_flip_string(tty, data, urb->actual_length);
257
258 /* Force the data to the tty layer. */
259 tty_flip_buffer_push(tty);
260 }
261 tty_kref_put(tty);
262
263 /* Set any port variables. */
264 spin_lock_irqsave(&metro_priv->lock, flags);
265 throttled = metro_priv->throttled;
266 spin_unlock_irqrestore(&metro_priv->lock, flags);
267
268 /* Continue trying to read if set. */
269 if (!throttled) {
270 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
271 usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress),
272 port->interrupt_in_urb->transfer_buffer,
273 port->interrupt_in_urb->transfer_buffer_length,
274 metrousb_read_int_callback, port, 1);
275
276 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
277
278 if (result) {
279 dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
280 __FUNCTION__, port->number, result);
281 }
282 }
283 return;
284
285exit:
286 /* Try to resubmit the urb. */
287 result = usb_submit_urb(urb, GFP_ATOMIC);
288 if (result) {
289 dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
290 __FUNCTION__, port->number, result);
291 }
292}
293
294/* ----------------------------------------------------------------------------------------------
295 Description:
296 Set the modem control state for the entered serial port. 234 Set the modem control state for the entered serial port.
297 235
298 Input: 236 Input:
@@ -522,6 +460,39 @@ static void metrousb_unthrottle(struct tty_struct *tty)
522 } 460 }
523} 461}
524 462
463/* Driver structure. */
464static struct usb_driver metrousb_driver = {
465 .name = "metro-usb",
466 .probe = usb_serial_probe,
467 .disconnect = usb_serial_disconnect,
468 .id_table = id_table
469};
470
471/* Device structure. */
472static struct usb_serial_driver metrousb_device = {
473 .driver = {
474 .owner = THIS_MODULE,
475 .name = "metro-usb",
476 },
477 .description = "Metrologic USB to serial converter.",
478 .id_table = id_table,
479 .num_ports = 1,
480 .open = metrousb_open,
481 .close = metrousb_cleanup,
482 .read_int_callback = metrousb_read_int_callback,
483 .attach = metrousb_startup,
484 .release = metrousb_shutdown,
485 .throttle = metrousb_throttle,
486 .unthrottle = metrousb_unthrottle,
487 .tiocmget = metrousb_tiocmget,
488 .tiocmset = metrousb_tiocmset,
489};
490
491static struct usb_serial_driver * const serial_drivers[] = {
492 &metrousb_device,
493 NULL,
494};
495
525module_usb_serial_driver(metrousb_driver, serial_drivers); 496module_usb_serial_driver(metrousb_driver, serial_drivers);
526 497
527MODULE_LICENSE("GPL"); 498MODULE_LICENSE("GPL");