aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/opticon.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2012-11-18 07:23:32 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-21 16:33:55 -0500
commite32d82bcdb78f502f58d0b078395ed3864aaa223 (patch)
tree29b6c87ed9a2cc601c3bdb8f40a8f38a2cdef224 /drivers/usb/serial/opticon.c
parent56be1a17d76d8517fe56e0e3da63d1d203b45d1e (diff)
USB: opticon: use port as urb context
Use port rather than private data as urb context, as the latter may be accessed as port data, and remove the port field from the private data. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/opticon.c')
-rw-r--r--drivers/usb/serial/opticon.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 92f56e476f28..2c9137c95730 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -40,7 +40,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
40 40
41/* This structure holds all of the individual device information */ 41/* This structure holds all of the individual device information */
42struct opticon_private { 42struct opticon_private {
43 struct usb_serial_port *port;
44 unsigned char *bulk_in_buffer; 43 unsigned char *bulk_in_buffer;
45 struct urb *bulk_read_urb; 44 struct urb *bulk_read_urb;
46 int buffer_size; 45 int buffer_size;
@@ -57,9 +56,9 @@ struct opticon_private {
57 56
58static void opticon_read_bulk_callback(struct urb *urb) 57static void opticon_read_bulk_callback(struct urb *urb)
59{ 58{
60 struct opticon_private *priv = urb->context; 59 struct usb_serial_port *port = urb->context;
60 struct opticon_private *priv = usb_get_serial_port_data(port);
61 unsigned char *data = urb->transfer_buffer; 61 unsigned char *data = urb->transfer_buffer;
62 struct usb_serial_port *port = priv->port;
63 int status = urb->status; 62 int status = urb->status;
64 struct tty_struct *tty; 63 struct tty_struct *tty;
65 int result; 64 int result;
@@ -175,7 +174,6 @@ static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port)
175 spin_lock_irqsave(&priv->lock, flags); 174 spin_lock_irqsave(&priv->lock, flags);
176 priv->throttled = false; 175 priv->throttled = false;
177 priv->actually_throttled = false; 176 priv->actually_throttled = false;
178 priv->port = port;
179 priv->rts = false; 177 priv->rts = false;
180 spin_unlock_irqrestore(&priv->lock, flags); 178 spin_unlock_irqrestore(&priv->lock, flags);
181 179
@@ -206,7 +204,8 @@ static void opticon_close(struct usb_serial_port *port)
206 204
207static void opticon_write_control_callback(struct urb *urb) 205static void opticon_write_control_callback(struct urb *urb)
208{ 206{
209 struct opticon_private *priv = urb->context; 207 struct usb_serial_port *port = urb->context;
208 struct opticon_private *priv = usb_get_serial_port_data(port);
210 int status = urb->status; 209 int status = urb->status;
211 unsigned long flags; 210 unsigned long flags;
212 211
@@ -217,7 +216,7 @@ static void opticon_write_control_callback(struct urb *urb)
217 kfree(urb->setup_packet); 216 kfree(urb->setup_packet);
218 217
219 if (status) 218 if (status)
220 dev_dbg(&priv->port->dev, 219 dev_dbg(&port->dev,
221 "%s - non-zero urb status received: %d\n", 220 "%s - non-zero urb status received: %d\n",
222 __func__, status); 221 __func__, status);
223 222
@@ -225,7 +224,7 @@ static void opticon_write_control_callback(struct urb *urb)
225 --priv->outstanding_urbs; 224 --priv->outstanding_urbs;
226 spin_unlock_irqrestore(&priv->lock, flags); 225 spin_unlock_irqrestore(&priv->lock, flags);
227 226
228 usb_serial_port_softint(priv->port); 227 usb_serial_port_softint(port);
229} 228}
230 229
231static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, 230static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -285,7 +284,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
285 usb_fill_control_urb(urb, serial->dev, 284 usb_fill_control_urb(urb, serial->dev,
286 usb_sndctrlpipe(serial->dev, 0), 285 usb_sndctrlpipe(serial->dev, 0),
287 (unsigned char *)dr, buffer, count, 286 (unsigned char *)dr, buffer, count,
288 opticon_write_control_callback, priv); 287 opticon_write_control_callback, port);
289 288
290 /* send it down the pipe */ 289 /* send it down the pipe */
291 status = usb_submit_urb(urb, GFP_ATOMIC); 290 status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -488,7 +487,6 @@ static int opticon_port_probe(struct usb_serial_port *port)
488 return -ENOMEM; 487 return -ENOMEM;
489 488
490 spin_lock_init(&priv->lock); 489 spin_lock_init(&priv->lock);
491 priv->port = port;
492 490
493 priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL); 491 priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
494 if (!priv->bulk_read_urb) 492 if (!priv->bulk_read_urb)
@@ -505,7 +503,7 @@ static int opticon_port_probe(struct usb_serial_port *port)
505 usb_rcvbulkpipe(serial->dev, 503 usb_rcvbulkpipe(serial->dev,
506 priv->bulk_address), 504 priv->bulk_address),
507 priv->bulk_in_buffer, priv->buffer_size, 505 priv->bulk_in_buffer, priv->buffer_size,
508 opticon_read_bulk_callback, priv); 506 opticon_read_bulk_callback, port);
509 507
510 usb_set_serial_port_data(port, priv); 508 usb_set_serial_port_data(port, priv);
511 509