Commit 7013dfc3 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Vojtech Pavlik

[PATCH] USB: use usb_get_serial_data() and usb_set_serial_data() functions.

parent 1433db3d
...@@ -650,7 +650,7 @@ static int digi_write_oob_command( struct usb_serial_port *port, ...@@ -650,7 +650,7 @@ static int digi_write_oob_command( struct usb_serial_port *port,
int ret = 0; int ret = 0;
int len; 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); struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
unsigned long flags = 0; unsigned long flags = 0;
...@@ -806,7 +806,7 @@ static int digi_set_modem_signals( struct usb_serial_port *port, ...@@ -806,7 +806,7 @@ static int digi_set_modem_signals( struct usb_serial_port *port,
int ret; int ret;
struct digi_port *port_priv = usb_get_serial_port_data(port); 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); struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
unsigned char *data = oob_port->write_urb->transfer_buffer; unsigned char *data = oob_port->write_urb->transfer_buffer;
unsigned long flags = 0; unsigned long flags = 0;
...@@ -1353,6 +1353,7 @@ static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs ) ...@@ -1353,6 +1353,7 @@ static void digi_write_bulk_callback( struct urb *urb, struct pt_regs *regs )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial; struct usb_serial *serial;
struct digi_port *priv; struct digi_port *priv;
struct digi_serial *serial_priv;
int ret = 0; int ret = 0;
...@@ -1365,14 +1366,13 @@ dbg( "digi_write_bulk_callback: TOP, urb->status=%d", urb->status ); ...@@ -1365,14 +1366,13 @@ dbg( "digi_write_bulk_callback: TOP, urb->status=%d", urb->status );
return; return;
} }
serial = port->serial; 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 ); err("%s: serial or serial->private is NULL, status=%d", __FUNCTION__, urb->status );
return; return;
} }
/* handle oob callback */ /* handle oob callback */
if( priv->dp_port_num if( priv->dp_port_num == serial_priv->ds_oob_port_num ) {
== ((struct digi_serial *)(serial->private))->ds_oob_port_num ) {
dbg( "digi_write_bulk_callback: oob callback" ); dbg( "digi_write_bulk_callback: oob callback" );
spin_lock( &priv->dp_port_lock ); spin_lock( &priv->dp_port_lock );
priv->dp_write_urb_in_use = 0; priv->dp_write_urb_in_use = 0;
...@@ -1641,7 +1641,7 @@ static int digi_startup_device( struct usb_serial *serial ) ...@@ -1641,7 +1641,7 @@ static int digi_startup_device( struct usb_serial *serial )
{ {
int i,ret = 0; 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; struct usb_serial_port *port;
...@@ -1723,8 +1723,7 @@ dbg( "digi_startup: TOP" ); ...@@ -1723,8 +1723,7 @@ dbg( "digi_startup: TOP" );
} }
/* allocate serial private structure */ /* allocate serial private structure */
serial_priv = serial->private = serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial),
(struct digi_serial *)kmalloc( sizeof(struct digi_serial),
GFP_KERNEL ); GFP_KERNEL );
if( serial_priv == (struct digi_serial *)0 ) { if( serial_priv == (struct digi_serial *)0 ) {
for( i=0; i<serial->type->num_ports+1; i++ ) for( i=0; i<serial->type->num_ports+1; i++ )
...@@ -1737,6 +1736,7 @@ dbg( "digi_startup: TOP" ); ...@@ -1737,6 +1736,7 @@ dbg( "digi_startup: TOP" );
serial_priv->ds_oob_port_num = serial->type->num_ports; 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_oob_port = &serial->port[serial_priv->ds_oob_port_num];
serial_priv->ds_device_started = 0; serial_priv->ds_device_started = 0;
usb_set_serial_data(serial, serial_priv);
return( 0 ); return( 0 );
...@@ -1761,8 +1761,7 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() ); ...@@ -1761,8 +1761,7 @@ dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() );
/* number of regular ports + 1 for the out-of-band port */ /* number of regular ports + 1 for the out-of-band port */
for( i=0; i<serial->type->num_ports+1; i++ ) for( i=0; i<serial->type->num_ports+1; i++ )
kfree( usb_get_serial_port_data(&serial->port[i]) ); kfree( usb_get_serial_port_data(&serial->port[i]) );
kfree( serial->private ); kfree( usb_get_serial_data(serial) );
} }
...@@ -1771,6 +1770,7 @@ static void digi_read_bulk_callback( struct urb *urb, struct pt_regs *regs ) ...@@ -1771,6 +1770,7 @@ static void digi_read_bulk_callback( struct urb *urb, struct pt_regs *regs )
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct digi_port *priv; struct digi_port *priv;
struct digi_serial *serial_priv;
int ret; int ret;
...@@ -1784,7 +1784,7 @@ dbg( "digi_read_bulk_callback: TOP" ); ...@@ -1784,7 +1784,7 @@ dbg( "digi_read_bulk_callback: TOP" );
} }
if( port->serial == NULL if( port->serial == NULL
|| serial_paranoia_check( port->serial, __FUNCTION__ ) || 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 ); err("%s: serial is bad or serial->private is NULL, status=%d", __FUNCTION__, urb->status );
return; return;
} }
...@@ -1796,8 +1796,7 @@ dbg( "digi_read_bulk_callback: TOP" ); ...@@ -1796,8 +1796,7 @@ dbg( "digi_read_bulk_callback: TOP" );
} }
/* handle oob or inb callback, do not resubmit if error */ /* handle oob or inb callback, do not resubmit if error */
if( priv->dp_port_num if( priv->dp_port_num == serial_priv->ds_oob_port_num ) {
== ((struct digi_serial *)(port->serial->private))->ds_oob_port_num ) {
if( digi_read_oob_callback( urb ) != 0 ) if( digi_read_oob_callback( urb ) != 0 )
return; return;
} else { } else {
......
...@@ -932,7 +932,7 @@ static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs) ...@@ -932,7 +932,7 @@ static void edge_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs)
edge_port->write_in_progress = FALSE; edge_port->write_in_progress = FALSE;
// Check if more data needs to be sent // 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 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1019,7 +1019,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
/* see if we've set up our endpoint info yet (can't set it up in edge_startup /* 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.) */ as the structures were not set up at that time.) */
serial = port->serial; serial = port->serial;
edge_serial = (struct edgeport_serial *)serial->private; edge_serial = usb_get_serial_data(serial);
if (edge_serial == NULL) { if (edge_serial == NULL) {
return -ENODEV; return -ENODEV;
} }
...@@ -1247,7 +1247,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1247,7 +1247,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
edge_serial = (struct edgeport_serial *)serial->private; edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port); edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL)) if ((edge_serial == NULL) || (edge_port == NULL))
return; return;
...@@ -1381,7 +1381,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign ...@@ -1381,7 +1381,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
usb_serial_debug_data (__FILE__, __FUNCTION__, copySize, data); 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); dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __FUNCTION__, copySize, edge_port->txCredits, fifo->count);
...@@ -2489,7 +2489,7 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u ...@@ -2489,7 +2489,7 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
*****************************************************************************/ *****************************************************************************/
static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length) 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; int status = 0;
struct urb *urb; struct urb *urb;
int timeout; int timeout;
...@@ -2979,7 +2979,7 @@ static int edge_startup (struct usb_serial *serial) ...@@ -2979,7 +2979,7 @@ static int edge_startup (struct usb_serial *serial)
} }
memset (edge_serial, 0, sizeof(struct edgeport_serial)); memset (edge_serial, 0, sizeof(struct edgeport_serial));
edge_serial->serial = 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 */ /* get the name for the device from the device */
if ( (i = get_string(dev, dev->descriptor.iManufacturer, &edge_serial->name[0])) != 0) { if ( (i = get_string(dev, dev->descriptor.iManufacturer, &edge_serial->name[0])) != 0) {
...@@ -3031,7 +3031,7 @@ static int edge_startup (struct usb_serial *serial) ...@@ -3031,7 +3031,7 @@ static int edge_startup (struct usb_serial *serial)
edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL); edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
if (edge_port == NULL) { if (edge_port == NULL) {
dev_err(serial->dev->dev, "%s - Out of memory", __FUNCTION__); dev_err(serial->dev->dev, "%s - Out of memory", __FUNCTION__);
serial->private = NULL; usb_set_serial_data(serial, NULL);
kfree(edge_serial); kfree(edge_serial);
return -ENOMEM; return -ENOMEM;
} }
...@@ -3060,8 +3060,8 @@ static void edge_shutdown (struct usb_serial *serial) ...@@ -3060,8 +3060,8 @@ static void edge_shutdown (struct usb_serial *serial)
kfree (usb_get_serial_port_data(&serial->port[i])); kfree (usb_get_serial_port_data(&serial->port[i]));
usb_set_serial_port_data(&serial->port[i], NULL); usb_set_serial_port_data(&serial->port[i], NULL);
} }
kfree (serial->private); kfree (usb_get_serial_data(serial));
serial->private = NULL; usb_set_serial_data(serial, NULL);
} }
......
...@@ -1990,7 +1990,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1990,7 +1990,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
if (!serial) if (!serial)
return; return;
edge_serial = (struct edgeport_serial *)serial->private; edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port); edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL)) if ((edge_serial == NULL) || (edge_port == NULL))
return; return;
...@@ -2595,7 +2595,7 @@ static int edge_startup (struct usb_serial *serial) ...@@ -2595,7 +2595,7 @@ static int edge_startup (struct usb_serial *serial)
} }
memset (edge_serial, 0, sizeof(struct edgeport_serial)); memset (edge_serial, 0, sizeof(struct edgeport_serial));
edge_serial->serial = serial; edge_serial->serial = serial;
serial->private = edge_serial; usb_set_serial_data(serial, edge_serial);
status = TIDownloadFirmware (edge_serial); status = TIDownloadFirmware (edge_serial);
if (status) { if (status) {
...@@ -2629,8 +2629,8 @@ static void edge_shutdown (struct usb_serial *serial) ...@@ -2629,8 +2629,8 @@ static void edge_shutdown (struct usb_serial *serial)
kfree (usb_get_serial_port_data(&serial->port[i])); kfree (usb_get_serial_port_data(&serial->port[i]));
usb_set_serial_port_data(&serial->port[i], NULL); usb_set_serial_port_data(&serial->port[i], NULL);
} }
kfree (serial->private); kfree (usb_get_serial_data(serial));
serial->private = NULL; usb_set_serial_data(serial, NULL);
} }
......
...@@ -867,7 +867,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp) ...@@ -867,7 +867,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
int i, err; int i, err;
struct urb *urb; 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); p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details; d_details = s_priv->device_details;
...@@ -927,7 +927,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) ...@@ -927,7 +927,7 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
return; return;
dbg("%s", __FUNCTION__); 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 = usb_get_serial_port_data(port);
p_priv->rts_state = 0; p_priv->rts_state = 0;
...@@ -1139,7 +1139,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial) ...@@ -1139,7 +1139,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
dbg ("%s", __FUNCTION__); dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private); s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details; d_details = s_priv->device_details;
/* Setup values for the various callback routines */ /* Setup values for the various callback routines */
...@@ -1375,7 +1375,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, ...@@ -1375,7 +1375,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
dbg ("%s reset=%d", __FUNCTION__, reset_port); 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); p_priv = usb_get_serial_port_data(port);
d_details = s_priv->device_details; d_details = s_priv->device_details;
device_port = port->number - port->serial->minor; device_port = port->number - port->serial->minor;
...@@ -1530,7 +1530,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial, ...@@ -1530,7 +1530,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
dbg ("%s", __FUNCTION__); 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 = usb_get_serial_port_data(port);
d_details = s_priv->device_details; d_details = s_priv->device_details;
device_port = port->number - port->serial->minor; device_port = port->number - port->serial->minor;
...@@ -1655,7 +1655,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial, ...@@ -1655,7 +1655,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
dbg ("%s", __FUNCTION__); 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 = usb_get_serial_port_data(port);
d_details = s_priv->device_details; d_details = s_priv->device_details;
...@@ -1815,7 +1815,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port) ...@@ -1815,7 +1815,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
dbg ("%s", __FUNCTION__); dbg ("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private); s_priv = usb_get_serial_data(serial);
d_details = s_priv->device_details; d_details = s_priv->device_details;
switch (d_details->msg_format) { switch (d_details->msg_format) {
...@@ -1852,17 +1852,16 @@ static int keyspan_startup (struct usb_serial *serial) ...@@ -1852,17 +1852,16 @@ static int keyspan_startup (struct usb_serial *serial)
} }
/* Setup private data for serial driver */ /* Setup private data for serial driver */
serial->private = kmalloc(sizeof(struct keyspan_serial_private), s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
GFP_KERNEL); if (!s_priv) {
if (!serial->private) {
dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__); 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; s_priv->device_details = d_details;
usb_set_serial_data(serial, s_priv);
/* Now setup per port private data */ /* Now setup per port private data */
for (i = 0; i < serial->num_ports; i++) { for (i = 0; i < serial->num_ports; i++) {
port = &serial->port[i]; port = &serial->port[i];
...@@ -1895,7 +1894,7 @@ static void keyspan_shutdown (struct usb_serial *serial) ...@@ -1895,7 +1894,7 @@ static void keyspan_shutdown (struct usb_serial *serial)
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
s_priv = (struct keyspan_serial_private *)(serial->private); s_priv = usb_get_serial_data(serial);
/* Stop reading/writing urbs */ /* Stop reading/writing urbs */
stop_urb(s_priv->instat_urb); stop_urb(s_priv->instat_urb);
...@@ -1932,7 +1931,7 @@ static void keyspan_shutdown (struct usb_serial *serial) ...@@ -1932,7 +1931,7 @@ static void keyspan_shutdown (struct usb_serial *serial)
} }
/* dbg("Freeing serial->private."); */ /* dbg("Freeing serial->private."); */
kfree(serial->private); kfree(s_priv);
/* dbg("Freeing port->private."); */ /* dbg("Freeing port->private."); */
/* Now free per port private data */ /* Now free per port private data */
......
...@@ -654,7 +654,7 @@ static int visor_probe (struct usb_serial *serial) ...@@ -654,7 +654,7 @@ static int visor_probe (struct usb_serial *serial)
dev_info(*dev, "%s: port %d, is for %s use\n", serial->type->name, dev_info(*dev, "%s: port %d, is for %s use\n", serial->type->name,
connection_info->connections[i].port, string); connection_info->connections[i].port, string);
/* save off our num_ports info so that we can use it in the calc_num_ports call */ /* 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_probe (struct usb_serial *serial) ...@@ -697,12 +697,11 @@ static int visor_probe (struct usb_serial *serial)
static int visor_calc_num_ports (struct usb_serial *serial) 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; return num_ports;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment