ChangeSet 1.946.3.17, 2002/12/26 18:24:58-08:00, greg@kroah.com [PATCH] USB: use usb_get_serial_data() and usb_set_serial_data() functions. diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c --- a/drivers/usb/serial/digi_acceleport.c Fri Dec 27 23:57:01 2002 +++ b/drivers/usb/serial/digi_acceleport.c Fri Dec 27 23:57:01 2002 @@ -650,7 +650,7 @@ int ret = 0; int len; - struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)port->serial->private)->ds_oob_port; + struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); unsigned long flags = 0; @@ -806,7 +806,7 @@ int ret; struct digi_port *port_priv = usb_get_serial_port_data(port); - struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)port->serial->private)->ds_oob_port; + struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); unsigned char *data = oob_port->write_urb->transfer_buffer; unsigned long flags = 0; @@ -1353,6 +1353,7 @@ struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial *serial; struct digi_port *priv; + struct digi_serial *serial_priv; int ret = 0; @@ -1365,14 +1366,13 @@ return; } serial = port->serial; - if( serial == NULL || serial->private == NULL ) { + if( serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL ) { err("%s: serial or serial->private is NULL, status=%d", __FUNCTION__, urb->status ); return; } /* handle oob callback */ - if( priv->dp_port_num - == ((struct digi_serial *)(serial->private))->ds_oob_port_num ) { + if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { dbg( "digi_write_bulk_callback: oob callback" ); spin_lock( &priv->dp_port_lock ); priv->dp_write_urb_in_use = 0; @@ -1641,7 +1641,7 @@ { int i,ret = 0; - struct digi_serial *serial_priv = (struct digi_serial *)serial->private; + struct digi_serial *serial_priv = usb_get_serial_data(serial); struct usb_serial_port *port; @@ -1723,8 +1723,7 @@ } /* allocate serial private structure */ - serial_priv = serial->private = - (struct digi_serial *)kmalloc( sizeof(struct digi_serial), + serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial), GFP_KERNEL ); if( serial_priv == (struct digi_serial *)0 ) { for( i=0; itype->num_ports+1; i++ ) @@ -1737,6 +1736,7 @@ serial_priv->ds_oob_port_num = serial->type->num_ports; serial_priv->ds_oob_port = &serial->port[serial_priv->ds_oob_port_num]; serial_priv->ds_device_started = 0; + usb_set_serial_data(serial, serial_priv); return( 0 ); @@ -1761,8 +1761,7 @@ /* number of regular ports + 1 for the out-of-band port */ for( i=0; itype->num_ports+1; i++ ) kfree( usb_get_serial_port_data(&serial->port[i]) ); - kfree( serial->private ); - + kfree( usb_get_serial_data(serial) ); } @@ -1771,6 +1770,7 @@ struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct digi_port *priv; + struct digi_serial *serial_priv; int ret; @@ -1784,7 +1784,7 @@ } if( port->serial == NULL || serial_paranoia_check( port->serial, __FUNCTION__ ) - || port->serial->private == NULL ) { + || (serial_priv=usb_get_serial_data(port->serial)) == NULL ) { err("%s: serial is bad or serial->private is NULL, status=%d", __FUNCTION__, urb->status ); return; } @@ -1796,8 +1796,7 @@ } /* handle oob or inb callback, do not resubmit if error */ - if( priv->dp_port_num - == ((struct digi_serial *)(port->serial->private))->ds_oob_port_num ) { + if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { if( digi_read_oob_callback( urb ) != 0 ) return; } else { diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c --- a/drivers/usb/serial/io_edgeport.c Fri Dec 27 23:57:01 2002 +++ b/drivers/usb/serial/io_edgeport.c Fri Dec 27 23:57:01 2002 @@ -932,7 +932,7 @@ edge_port->write_in_progress = FALSE; // Check if more data needs to be sent - send_more_port_data((struct edgeport_serial *)(edge_port->port->serial->private), edge_port); + send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port); } @@ -1019,7 +1019,7 @@ /* see if we've set up our endpoint info yet (can't set it up in edge_startup as the structures were not set up at that time.) */ serial = port->serial; - edge_serial = (struct edgeport_serial *)serial->private; + edge_serial = usb_get_serial_data(serial); if (edge_serial == NULL) { return -ENODEV; } @@ -1247,7 +1247,7 @@ if (!serial) return; - edge_serial = (struct edgeport_serial *)serial->private; + edge_serial = usb_get_serial_data(serial); edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; @@ -1381,7 +1381,7 @@ usb_serial_debug_data (__FILE__, __FUNCTION__, copySize, data); } - send_more_port_data((struct edgeport_serial *)port->serial->private, edge_port); + send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port); dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count); @@ -2489,7 +2489,7 @@ *****************************************************************************/ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length) { - struct edgeport_serial *edge_serial = (struct edgeport_serial *)edge_port->port->serial->private; + struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial); int status = 0; struct urb *urb; int timeout; @@ -2979,7 +2979,7 @@ } memset (edge_serial, 0, sizeof(struct edgeport_serial)); edge_serial->serial = serial; - serial->private = edge_serial; + usb_set_serial_data(serial, edge_serial); /* get the name for the device from the device */ if ( (i = get_string(dev, dev->descriptor.iManufacturer, &edge_serial->name[0])) != 0) { @@ -3031,7 +3031,7 @@ edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); if (edge_port == NULL) { dev_err(serial->dev->dev, "%s - Out of memory", __FUNCTION__); - serial->private = NULL; + usb_set_serial_data(serial, NULL); kfree(edge_serial); return -ENOMEM; } @@ -3060,8 +3060,8 @@ kfree (usb_get_serial_port_data(&serial->port[i])); usb_set_serial_port_data(&serial->port[i], NULL); } - kfree (serial->private); - serial->private = NULL; + kfree (usb_get_serial_data(serial)); + usb_set_serial_data(serial, NULL); } diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c --- a/drivers/usb/serial/io_ti.c Fri Dec 27 23:57:01 2002 +++ b/drivers/usb/serial/io_ti.c Fri Dec 27 23:57:01 2002 @@ -1990,7 +1990,7 @@ if (!serial) return; - edge_serial = (struct edgeport_serial *)serial->private; + edge_serial = usb_get_serial_data(serial); edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; @@ -2595,7 +2595,7 @@ } memset (edge_serial, 0, sizeof(struct edgeport_serial)); edge_serial->serial = serial; - serial->private = edge_serial; + usb_set_serial_data(serial, edge_serial); status = TIDownloadFirmware (edge_serial); if (status) { @@ -2629,8 +2629,8 @@ kfree (usb_get_serial_port_data(&serial->port[i])); usb_set_serial_port_data(&serial->port[i], NULL); } - kfree (serial->private); - serial->private = NULL; + kfree (usb_get_serial_data(serial)); + usb_set_serial_data(serial, NULL); } diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c --- a/drivers/usb/serial/keyspan.c Fri Dec 27 23:57:01 2002 +++ b/drivers/usb/serial/keyspan.c Fri Dec 27 23:57:01 2002 @@ -867,7 +867,7 @@ int i, err; struct urb *urb; - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; @@ -927,7 +927,7 @@ return; dbg("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); p_priv->rts_state = 0; @@ -1139,7 +1139,7 @@ dbg ("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; /* Setup values for the various callback routines */ @@ -1375,7 +1375,7 @@ dbg ("%s reset=%d", __FUNCTION__, reset_port); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; device_port = port->number - port->serial->minor; @@ -1530,7 +1530,7 @@ dbg ("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; device_port = port->number - port->serial->minor; @@ -1655,7 +1655,7 @@ dbg ("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; @@ -1815,7 +1815,7 @@ dbg ("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); d_details = s_priv->device_details; switch (d_details->msg_format) { @@ -1852,17 +1852,16 @@ } /* Setup private data for serial driver */ - serial->private = kmalloc(sizeof(struct keyspan_serial_private), - GFP_KERNEL); - if (!serial->private) { + s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); + if (!s_priv) { dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__); - return (1); + return -ENOMEM; } - memset(serial->private, 0, sizeof(struct keyspan_serial_private)); + memset(s_priv, 0, sizeof(struct keyspan_serial_private)); - s_priv = (struct keyspan_serial_private *)(serial->private); s_priv->device_details = d_details; - + usb_set_serial_data(serial, s_priv); + /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = &serial->port[i]; @@ -1895,7 +1894,7 @@ dbg("%s", __FUNCTION__); - s_priv = (struct keyspan_serial_private *)(serial->private); + s_priv = usb_get_serial_data(serial); /* Stop reading/writing urbs */ stop_urb(s_priv->instat_urb); @@ -1932,7 +1931,7 @@ } /* dbg("Freeing serial->private."); */ - kfree(serial->private); + kfree(s_priv); /* dbg("Freeing port->private."); */ /* Now free per port private data */ diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c --- a/drivers/usb/serial/visor.c Fri Dec 27 23:57:01 2002 +++ b/drivers/usb/serial/visor.c Fri Dec 27 23:57:01 2002 @@ -654,7 +654,7 @@ dev_info(*dev, "%s: port %d, is for %s use\n", serial->type->name, connection_info->connections[i].port, string); /* save off our num_ports info so that we can use it in the calc_num_ports call */ - serial->private = (void *)(long)num_ports; + usb_set_serial_data(serial, (void *)(long)num_ports); } } @@ -697,12 +697,11 @@ static int visor_calc_num_ports (struct usb_serial *serial) { - int num_ports = 0; + int num_ports = (int)(long)(usb_get_serial_data(serial)); + + if (num_ports) + usb_set_serial_data(serial, NULL); - if (serial->private) { - num_ports = (int)(long)serial->private; - serial->private = NULL; - } return num_ports; }