ChangeSet 1.946.3.15, 2002/12/26 17:38:55-08:00, greg@kroah.com [PATCH] USB: fix up the usb-serial drivers due to the removal of the struct usb_serial_port private pointer. diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c --- a/drivers/usb/serial/belkin_sa.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/belkin_sa.c Fri Dec 27 23:57:12 2002 @@ -171,10 +171,9 @@ struct belkin_sa_private *priv; /* allocate the private data structure */ - serial->port->private = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); - if (!serial->port->private) + priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); + if (!priv) return (-1); /* error */ - priv = (struct belkin_sa_private *)serial->port->private; /* set initial values for control structures */ priv->control_state = 0; priv->last_lsr = 0; @@ -184,6 +183,7 @@ info("bcdDevice: %04x, bfc: %d", dev->descriptor.bcdDevice, priv->bad_flow_control); init_waitqueue_head(&serial->port->write_wait); + usb_set_serial_port_data(serial->port, priv); return (0); } @@ -191,6 +191,7 @@ static void belkin_sa_shutdown (struct usb_serial *serial) { + struct belkin_sa_private *priv; int i; dbg ("%s", __FUNCTION__); @@ -198,8 +199,9 @@ /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ - if (serial->port[i].private) - kfree(serial->port[i].private); + priv = usb_get_serial_port_data(&serial->port[i]); + if (priv) + kfree(priv); } } @@ -286,7 +288,7 @@ /* Handle known interrupt data */ /* ignore data[0] and data[1] */ - priv = (struct belkin_sa_private *)port->private; + priv = usb_get_serial_port_data(port); priv->last_msr = data[BELKIN_SA_MSR_INDEX]; /* Record Control Line states */ @@ -344,7 +346,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios *old_termios) { struct usb_serial *serial = port->serial; - struct belkin_sa_private *priv = (struct belkin_sa_private *)port->private; + struct belkin_sa_private *priv = usb_get_serial_port_data(port); unsigned int iflag; unsigned int cflag; unsigned int old_iflag = 0; @@ -485,7 +487,7 @@ { struct usb_serial *serial = port->serial; __u16 urb_value; /* Will hold the new flags */ - struct belkin_sa_private *priv = (struct belkin_sa_private *)port->private; + struct belkin_sa_private *priv = usb_get_serial_port_data(port); int ret, mask; /* Based on code from acm.c and others */ diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c --- a/drivers/usb/serial/cyberjack.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/cyberjack.c Fri Dec 27 23:57:12 2002 @@ -114,15 +114,15 @@ dbg("%s", __FUNCTION__); /* allocate the private data structure */ - serial->port->private = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); - if (!serial->port->private) - return (-1); /* error */ + priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); + if (!priv) + return -ENOMEM; /* set initial values */ - priv = (struct cyberjack_private *)serial->port->private; priv->rdtodo = 0; priv->wrfilled = 0; priv->wrsent = 0; + usb_set_serial_port_data(serial->port, priv); init_waitqueue_head(&serial->port->write_wait); @@ -137,8 +137,8 @@ for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ - if (serial->port[i].private) - kfree(serial->port[i].private); + kfree(usb_get_serial_port_data(&serial->port[i])); + usb_set_serial_port_data(&serial->port[i], NULL); } } @@ -158,7 +158,7 @@ */ port->tty->low_latency = 1; - priv = (struct cyberjack_private *)port->private; + priv = usb_get_serial_port_data(port); priv->rdtodo = 0; priv->wrfilled = 0; priv->wrsent = 0; @@ -192,7 +192,7 @@ static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; - struct cyberjack_private *priv = (struct cyberjack_private *)port->private; + struct cyberjack_private *priv = usb_get_serial_port_data(port); int result; int wrexpected; @@ -280,7 +280,7 @@ static void cyberjack_read_int_callback( struct urb *urb, struct pt_regs *regs ) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct cyberjack_private *priv = (struct cyberjack_private *)port->private; + struct cyberjack_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial; unsigned char *data = urb->transfer_buffer; @@ -334,7 +334,7 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct cyberjack_private *priv = (struct cyberjack_private *)port->private; + struct cyberjack_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -389,7 +389,7 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct cyberjack_private *priv = (struct cyberjack_private *)port->private; + struct cyberjack_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); dbg("%s - port %d", __FUNCTION__, port->number); 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:12 2002 +++ b/drivers/usb/serial/digi_acceleport.c Fri Dec 27 23:57:12 2002 @@ -604,7 +604,7 @@ { unsigned long flags; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); spin_lock_irqsave( &priv->dp_port_lock, flags ); @@ -651,7 +651,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 digi_port *oob_priv = (struct digi_port *)oob_port->private; + struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); unsigned long flags = 0; @@ -719,7 +719,7 @@ int ret = 0; int len; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned char *data = port->write_urb->transfer_buffer; unsigned long flags = 0; @@ -805,9 +805,9 @@ { int ret; - struct digi_port *port_priv = (struct digi_port *)port->private; + 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 digi_port *oob_priv = (struct digi_port *)oob_port->private; + 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; @@ -884,7 +884,7 @@ int ret; unsigned char buf[2]; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned long flags = 0; @@ -924,7 +924,7 @@ { unsigned long flags; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); dbg( "digi_rx_throttle: TOP: port=%d", priv->dp_port_num ); @@ -945,7 +945,7 @@ int ret = 0; int len; unsigned long flags; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; @@ -989,7 +989,7 @@ struct termios *old_termios ) { - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned int iflag = port->tty->termios->c_iflag; unsigned int cflag = port->tty->termios->c_cflag; unsigned int old_iflag = old_termios->c_iflag; @@ -1213,7 +1213,7 @@ unsigned int cmd, unsigned long arg ) { - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned int val; unsigned long flags = 0; @@ -1265,7 +1265,7 @@ { int ret,data_len,new_len; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned char *data = port->write_urb->transfer_buffer; unsigned char user_buf[64]; /* 64 bytes is max USB bulk packet */ unsigned long flags = 0; @@ -1359,7 +1359,7 @@ dbg( "digi_write_bulk_callback: TOP, urb->status=%d", urb->status ); /* port and serial sanity check */ - if( port == NULL || (priv=(struct digi_port *)(port->private)) == NULL ) { + if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { err("%s: port or port->private is NULL, status=%d", __FUNCTION__, urb->status ); return; @@ -1432,7 +1432,7 @@ { int room; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); unsigned long flags = 0; @@ -1455,7 +1455,7 @@ static int digi_chars_in_buffer( struct usb_serial_port *port ) { - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); if( port->write_urb->status == -EINPROGRESS @@ -1476,7 +1476,7 @@ int ret; unsigned char buf[32]; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); struct termios not_termios; unsigned long flags = 0; @@ -1542,7 +1542,7 @@ int ret; unsigned char buf[32]; struct tty_struct *tty = port->tty; - struct digi_port *priv = (struct digi_port *)port->private; + struct digi_port *priv = usb_get_serial_port_data(port); unsigned long flags = 0; @@ -1690,12 +1690,11 @@ for( i=0; itype->num_ports+1; i++ ) { /* allocate port private structure */ - priv = serial->port[i].private = - (struct digi_port *)kmalloc( sizeof(struct digi_port), + priv = (struct digi_port *)kmalloc( sizeof(struct digi_port), GFP_KERNEL ); if( priv == (struct digi_port *)0 ) { while( --i >= 0 ) - kfree( serial->port[i].private ); + kfree( usb_get_serial_port_data(&serial->port[i]) ); return( 1 ); /* error */ } @@ -1720,6 +1719,7 @@ /* initialize write wait queue for this port */ init_waitqueue_head( &serial->port[i].write_wait ); + usb_set_serial_port_data(&serial->port[i], priv); } /* allocate serial private structure */ @@ -1728,7 +1728,7 @@ GFP_KERNEL ); if( serial_priv == (struct digi_serial *)0 ) { for( i=0; itype->num_ports+1; i++ ) - kfree( serial->port[i].private ); + kfree( usb_get_serial_port_data(&serial->port[i]) ); return( 1 ); /* error */ } @@ -1760,7 +1760,7 @@ /* free the private data structures for all ports */ /* number of regular ports + 1 for the out-of-band port */ for( i=0; itype->num_ports+1; i++ ) - kfree( serial->port[i].private ); + kfree( usb_get_serial_port_data(&serial->port[i]) ); kfree( serial->private ); } @@ -1777,7 +1777,7 @@ dbg( "digi_read_bulk_callback: TOP" ); /* port sanity check, do not resubmit if port is not valid */ - if( port == NULL || (priv=(struct digi_port *)(port->private)) == NULL ) { + if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { err("%s: port or port->private is NULL, status=%d", __FUNCTION__, urb->status ); return; @@ -1830,7 +1830,7 @@ struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct tty_struct *tty = port->tty; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); int opcode = ((unsigned char *)urb->transfer_buffer)[0]; int len = ((unsigned char *)urb->transfer_buffer)[1]; int status = ((unsigned char *)urb->transfer_buffer)[2]; @@ -1942,7 +1942,7 @@ struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial *serial = port->serial; - struct digi_port *priv = (struct digi_port *)(port->private); + struct digi_port *priv = usb_get_serial_port_data(port); int opcode, line, status, val; int i; @@ -1967,7 +1967,7 @@ port = &serial->port[line]; if( port_paranoia_check( port, __FUNCTION__ ) - || (priv=port->private) == NULL ) + || (priv=usb_get_serial_port_data(port)) == NULL ) return( -1 ); if( opcode == DIGI_CMD_READ_INPUT_SIGNALS ) { diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c --- a/drivers/usb/serial/ftdi_sio.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/ftdi_sio.c Fri Dec 27 23:57:12 2002 @@ -267,7 +267,7 @@ struct ftdi_private *priv; - priv = serial->port->private = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); + priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); if (!priv){ err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); return -ENOMEM; @@ -275,7 +275,8 @@ priv->ftdi_type = sio; priv->write_offset = 1; - + usb_set_serial_port_data(serial->port, priv); + return (0); } @@ -285,7 +286,7 @@ struct ftdi_private *priv; - priv = serial->port->private = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); + priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL); if (!priv){ err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private)); return -ENOMEM; @@ -293,17 +294,21 @@ priv->ftdi_type = F8U232AM; priv->write_offset = 0; - + usb_set_serial_port_data(serial->port, priv); + return (0); } static void ftdi_sio_shutdown (struct usb_serial *serial) { + void *priv; + dbg("%s", __FUNCTION__); - if (serial->port[0].private){ - kfree(serial->port[0].private); - serial->port[0].private = NULL; + priv = usb_get_serial_port_data(&serial->port[0]); + if (priv){ + kfree(priv); + usb_set_serial_port_data(&serial->port[0], NULL); } } @@ -405,7 +410,7 @@ const unsigned char *buf, int count) { /* ftdi_sio_write */ struct usb_serial *serial = port->serial; - struct ftdi_private *priv = (struct ftdi_private *)port->private; + struct ftdi_private *priv = usb_get_serial_port_data(port); unsigned char *first_byte = port->write_urb->transfer_buffer; int data_offset ; int result; @@ -491,7 +496,7 @@ static int ftdi_sio_write_room( struct usb_serial_port *port ) { - struct ftdi_private *priv = (struct ftdi_private *)port->private; + struct ftdi_private *priv = usb_get_serial_port_data(port); int room; if ( port->write_urb->status == -EINPROGRESS) { @@ -670,7 +675,7 @@ static void ftdi_sio_break_ctl( struct usb_serial_port *port, int break_state ) { struct usb_serial *serial = port->serial; - struct ftdi_private *priv = (struct ftdi_private *)port->private; + struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value = 0; char buf[1]; @@ -709,7 +714,7 @@ { /* ftdi_sio_set_termios */ struct usb_serial *serial = port->serial; unsigned int cflag = port->tty->termios->c_cflag; - struct ftdi_private *priv = (struct ftdi_private *)port->private; + struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value; /* will hold the new flags */ char buf[1]; /* Perhaps I should dynamically alloc this? */ @@ -819,7 +824,7 @@ static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) { struct usb_serial *serial = port->serial; - struct ftdi_private *priv = (struct ftdi_private *)port->private; + struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value=0; /* Will hold the new flags */ char buf[2]; int ret, mask; 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:12 2002 +++ b/drivers/usb/serial/io_edgeport.c Fri Dec 27 23:57:12 2002 @@ -818,7 +818,7 @@ if (txCredits) { port = &edge_serial->serial->port[portNumber]; if (port_paranoia_check (port, __FUNCTION__) == 0) { - edge_port = (struct edgeport_port *)port->private; + edge_port = usb_get_serial_port_data(port); if (edge_port->open) { edge_port->txCredits += txCredits; dbg("%s - txcredits for port%d = %d", __FUNCTION__, portNumber, edge_port->txCredits); @@ -996,7 +996,7 @@ *****************************************************************************/ static int edge_open (struct usb_serial_port *port, struct file * filp) { - struct edgeport_port *edge_port = (struct edgeport_port *)port->private; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct usb_serial *serial; struct edgeport_serial *edge_serial; int response; @@ -1248,7 +1248,7 @@ return; edge_serial = (struct edgeport_serial *)serial->private; - edge_port = (struct edgeport_port *)port->private; + edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; @@ -1307,7 +1307,7 @@ *****************************************************************************/ static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count) { - struct edgeport_port *edge_port = (struct edgeport_port *)port->private; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct TxFifo *fifo; int copySize; int bytesleft; @@ -1508,7 +1508,7 @@ *****************************************************************************/ static int edge_write_room (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int room; dbg("%s", __FUNCTION__); @@ -1544,7 +1544,7 @@ *****************************************************************************/ static int edge_chars_in_buffer (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int num_chars; dbg("%s", __FUNCTION__); @@ -1575,7 +1575,7 @@ *****************************************************************************/ static void edge_throttle (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty; int status; @@ -1624,7 +1624,7 @@ *****************************************************************************/ static void edge_unthrottle (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty; int status; @@ -1672,7 +1672,7 @@ *****************************************************************************/ static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; unsigned int cflag; @@ -1862,7 +1862,7 @@ *****************************************************************************/ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct async_icount cnow; struct async_icount cprev; struct serial_icounter_struct icount; @@ -1953,7 +1953,7 @@ *****************************************************************************/ static void edge_break (struct usb_serial_port *port, int break_state) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status; /* flush and chase */ @@ -2086,7 +2086,7 @@ if (rxLen) { port = &edge_serial->serial->port[edge_serial->rxPort]; if (port_paranoia_check (port, __FUNCTION__) == 0) { - edge_port = (struct edgeport_port *)port->private; + edge_port = usb_get_serial_port_data(port); if (edge_port->open) { tty = edge_port->port->tty; if (tty) { @@ -2141,7 +2141,7 @@ if (port_paranoia_check (port, __FUNCTION__)) { return; } - edge_port = (struct edgeport_port *)port->private; + edge_port = usb_get_serial_port_data(port); if (edge_port == NULL) { dev_err(edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __FUNCTION__, edge_serial->rxPort); return; @@ -3037,7 +3037,7 @@ } memset (edge_port, 0, sizeof(struct edgeport_port)); edge_port->port = &serial->port[i]; - serial->port[i].private = edge_port; + usb_set_serial_port_data(&serial->port[i], edge_port); } return 0; @@ -3057,8 +3057,8 @@ /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { - kfree (serial->port[i].private); - serial->port[i].private = NULL; + kfree (usb_get_serial_port_data(&serial->port[i])); + usb_set_serial_port_data(&serial->port[i], NULL); } kfree (serial->private); serial->private = 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:12 2002 +++ b/drivers/usb/serial/io_ti.c Fri Dec 27 23:57:12 2002 @@ -1672,7 +1672,7 @@ __FUNCTION__); return; } - edge_port = port->private; + edge_port = usb_get_serial_port_data(port); if (!edge_port) { dbg ("%s - edge_port not found", __FUNCTION__); return; @@ -1821,7 +1821,7 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) { - struct edgeport_port *edge_port = (struct edgeport_port *)port->private; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct edgeport_serial *edge_serial; struct usb_device *dev; struct urb *urb; @@ -1991,7 +1991,7 @@ return; edge_serial = (struct edgeport_serial *)serial->private; - edge_port = (struct edgeport_port *)port->private; + edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; @@ -2030,7 +2030,7 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count) { struct usb_serial *serial = port->serial; - struct edgeport_port *edge_port = port->private; + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int result; dbg("%s - port %d", __FUNCTION__, port->number); @@ -2084,7 +2084,7 @@ static int edge_write_room (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int room = 0; dbg("%s", __FUNCTION__); @@ -2105,7 +2105,7 @@ static int edge_chars_in_buffer (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int chars = 0; dbg("%s", __FUNCTION__); @@ -2126,7 +2126,7 @@ static void edge_throttle (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty; int status; @@ -2159,7 +2159,7 @@ static void edge_unthrottle (struct usb_serial_port *port) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty; int status; @@ -2350,7 +2350,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct termios *old_termios) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; unsigned int cflag; @@ -2484,7 +2484,7 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); struct async_icount cnow; struct async_icount cprev; @@ -2558,7 +2558,7 @@ static void edge_break (struct usb_serial_port *port, int break_state) { - struct edgeport_port *edge_port = (struct edgeport_port *)(port->private); + struct edgeport_port *edge_port = usb_get_serial_port_data(port); int status; dbg ("%s - state = %d", __FUNCTION__, break_state); @@ -2613,7 +2613,7 @@ memset (edge_port, 0, sizeof(struct edgeport_port)); edge_port->port = &serial->port[i]; edge_port->edge_serial = edge_serial; - serial->port[i].private = edge_port; + usb_set_serial_port_data(&serial->port[i], edge_port); } return 0; @@ -2626,8 +2626,8 @@ dbg ("%s", __FUNCTION__); for (i=0; i < serial->num_ports; ++i) { - kfree (serial->port[i].private); - serial->port[i].private = NULL; + kfree (usb_get_serial_port_data(&serial->port[i])); + usb_set_serial_port_data(&serial->port[i], NULL); } kfree (serial->private); serial->private = NULL; diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c --- a/drivers/usb/serial/ipaq.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/ipaq.c Fri Dec 27 23:57:12 2002 @@ -186,7 +186,7 @@ err("%s - Out of memory", __FUNCTION__); return -ENOMEM; } - port->private = (void *)priv; + usb_set_serial_port_data(port, priv); priv->active = 0; priv->queue_len = 0; INIT_LIST_HEAD(&priv->queue); @@ -281,7 +281,7 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; - struct ipaq_private *priv = port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); if (port_paranoia_check(port, __FUNCTION__)) { return; @@ -301,7 +301,7 @@ usb_unlink_urb(port->read_urb); ipaq_destroy_lists(port); kfree(priv); - port->private = NULL; + usb_set_serial_port_data(port, NULL); /* Uncomment the following line if you want to see some statistics in your syslog */ /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ @@ -385,7 +385,7 @@ static int ipaq_write_bulk(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { - struct ipaq_private *priv = port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); struct ipaq_packet *pkt = NULL; int result = 0; unsigned long flags; @@ -436,7 +436,7 @@ static void ipaq_write_gather(struct usb_serial_port *port) { - struct ipaq_private *priv = (struct ipaq_private *)port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; int count, room; struct ipaq_packet *pkt; @@ -478,7 +478,7 @@ static void ipaq_write_bulk_callback(struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct ipaq_private *priv = (struct ipaq_private *)port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); unsigned long flags; int result; @@ -510,7 +510,7 @@ static int ipaq_write_room(struct usb_serial_port *port) { - struct ipaq_private *priv = (struct ipaq_private *)port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - freelen %d", __FUNCTION__, priv->free_len); return priv->free_len; @@ -518,7 +518,7 @@ static int ipaq_chars_in_buffer(struct usb_serial_port *port) { - struct ipaq_private *priv = (struct ipaq_private *)port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - queuelen %d", __FUNCTION__, priv->queue_len); return priv->queue_len; @@ -526,7 +526,7 @@ static void ipaq_destroy_lists(struct usb_serial_port *port) { - struct ipaq_private *priv = (struct ipaq_private *)port->private; + struct ipaq_private *priv = usb_get_serial_port_data(port); struct list_head *tmp; struct ipaq_packet *pkt; 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:12 2002 +++ b/drivers/usb/serial/keyspan.c Fri Dec 27 23:57:12 2002 @@ -220,7 +220,7 @@ dbg("%s", __FUNCTION__); - p_priv = (struct keyspan_port_private *)port->private; + p_priv = usb_get_serial_port_data(port); if (break_state == -1) p_priv->break_on = 1; @@ -241,7 +241,7 @@ dbg("%s", __FUNCTION__); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; cflag = port->tty->termios->c_cflag; device_port = port->number - port->serial->minor; @@ -270,7 +270,7 @@ unsigned int value, set; struct keyspan_port_private *p_priv; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); switch (cmd) { case TIOCMGET: @@ -321,7 +321,7 @@ struct urb *this_urb; int err; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; dbg("%s - for port %d (%d chars [%x]), flip=%d", @@ -444,7 +444,7 @@ struct keyspan_port_private *p_priv; port = (struct usb_serial_port *) urb->context; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); dbg ("%s - urb %d", __FUNCTION__, urb == p_priv->out_urbs[1]); if (port->open_count) @@ -463,7 +463,7 @@ struct keyspan_port_private *p_priv; port = (struct usb_serial_port *) urb->context; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { dbg ("%s - sending setup", __FUNCTION__); @@ -508,7 +508,7 @@ goto exit; } port = &serial->port[msg->port]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; @@ -551,7 +551,7 @@ dbg ("%s", __FUNCTION__); port = (struct usb_serial_port *) urb->context; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; if (urb != p_priv->in_urbs[p_priv->in_flip]) @@ -565,7 +565,7 @@ } port = (struct usb_serial_port *) urb->context; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); data = urb->transfer_buffer; tty = port->tty; @@ -599,7 +599,7 @@ struct keyspan_port_private *p_priv; port = (struct usb_serial_port *) urb->context; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { dbg ("%s - sending setup", __FUNCTION__); @@ -643,7 +643,7 @@ goto exit; } port = &serial->port[msg->port]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; @@ -686,7 +686,7 @@ serial = (struct usb_serial *) urb->context; for (i = 0; i < serial->num_ports; ++i) { port = &serial->port[i]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); if (p_priv->resend_cont) { dbg ("%s - sending setup", __FUNCTION__); @@ -735,7 +735,7 @@ goto exit; } port = &serial->port[msg->portNumber]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); /* Update handshaking pin state information */ old_dcd_state = p_priv->dcd_state; @@ -834,7 +834,7 @@ struct urb *this_urb; dbg("%s", __FUNCTION__); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = p_priv->device_details; flip = p_priv->out_flip; @@ -868,13 +868,11 @@ struct urb *urb; s_priv = (struct keyspan_serial_private *)(serial->private); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; dbg("%s - port%d.", __FUNCTION__, port->number); - p_priv = (struct keyspan_port_private *)(port->private); - /* Set some sane defaults */ p_priv->rts_state = 1; p_priv->dtr_state = 1; @@ -930,7 +928,7 @@ dbg("%s", __FUNCTION__); s_priv = (struct keyspan_serial_private *)(serial->private); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); p_priv->rts_state = 0; p_priv->dtr_state = 0; @@ -1162,7 +1160,7 @@ /* Setup endpoints for each port specific thing */ for (i = 0; i < d_details->num_ports; i ++) { port = &serial->port[i]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); /* Do indat endpoints first, once for each flip */ endp = d_details->indat_endpoints[i]; @@ -1378,7 +1376,7 @@ dbg ("%s reset=%d", __FUNCTION__, reset_port); s_priv = (struct keyspan_serial_private *)(serial->private); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; device_port = port->number - port->serial->minor; @@ -1533,7 +1531,7 @@ dbg ("%s", __FUNCTION__); s_priv = (struct keyspan_serial_private *)(serial->private); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; device_port = port->number - port->serial->minor; @@ -1658,7 +1656,7 @@ dbg ("%s", __FUNCTION__); s_priv = (struct keyspan_serial_private *)(serial->private); - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); d_details = s_priv->device_details; glocont_urb = d_details->glocont_endpoint; @@ -1868,15 +1866,14 @@ /* Now setup per port private data */ for (i = 0; i < serial->num_ports; i++) { port = &serial->port[i]; - port->private = kmalloc(sizeof(struct keyspan_port_private), - GFP_KERNEL); - if (!port->private) { + p_priv = kmalloc(sizeof(struct keyspan_port_private), GFP_KERNEL); + if (!p_priv) { dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i); return (1); } - memset(port->private, 0, sizeof(struct keyspan_port_private)); - p_priv = (struct keyspan_port_private *)(port->private); + memset(p_priv, 0, sizeof(struct keyspan_port_private)); p_priv->device_details = d_details; + usb_set_serial_port_data(port, p_priv); } keyspan_setup_urbs(serial); @@ -1905,7 +1902,7 @@ stop_urb(s_priv->glocont_urb); for (i = 0; i < serial->num_ports; ++i) { port = &serial->port[i]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); stop_urb(p_priv->inack_urb); stop_urb(p_priv->outcont_urb); for (j = 0; j < 2; j++) { @@ -1921,7 +1918,7 @@ usb_free_urb(s_priv->glocont_urb); for (i = 0; i < serial->num_ports; ++i) { port = &serial->port[i]; - p_priv = (struct keyspan_port_private *)(port->private); + p_priv = usb_get_serial_port_data(port); if (p_priv->inack_urb) usb_free_urb(p_priv->inack_urb); if (p_priv->outcont_urb) @@ -1941,7 +1938,7 @@ /* Now free per port private data */ for (i = 0; i < serial->num_ports; i++) { port = &serial->port[i]; - kfree(port->private); + kfree(usb_get_serial_port_data(port)); } } diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c --- a/drivers/usb/serial/keyspan_pda.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/keyspan_pda.c Fri Dec 27 23:57:12 2002 @@ -231,7 +231,7 @@ int i; int status; struct keyspan_pda_private *priv; - priv = (struct keyspan_pda_private *)(port->private); + priv = usb_get_serial_port_data(port); switch (urb->status) { case 0: @@ -532,7 +532,7 @@ int rc = 0; struct keyspan_pda_private *priv; - priv = (struct keyspan_pda_private *)(port->private); + priv = usb_get_serial_port_data(port); /* guess how much room is left in the device's ring buffer, and if we want to send more than that, check first, updating our notion of what is left. If our write will result in no room left, ask the @@ -643,7 +643,7 @@ struct usb_serial *serial; struct keyspan_pda_private *priv; - priv = (struct keyspan_pda_private *)(port->private); + priv = usb_get_serial_port_data(port); if (port_paranoia_check (port, "keyspan_pda_rx_interrupt")) { return; @@ -662,7 +662,8 @@ static int keyspan_pda_write_room (struct usb_serial_port *port) { struct keyspan_pda_private *priv; - priv = (struct keyspan_pda_private *)(port->private); + + priv = usb_get_serial_port_data(port); /* used by n_tty.c for processing of tabs and such. Giving it our conservative guess is probably good enough, but needs testing by @@ -675,7 +676,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) { struct keyspan_pda_private *priv; - priv = (struct keyspan_pda_private *)(port->private); + + priv = usb_get_serial_port_data(port); /* when throttled, return at least WAKEUP_CHARS to tell select() (via n_tty.c:normal_poll() ) that we're not writeable. */ @@ -711,7 +713,7 @@ rc = -EIO; goto error; } - priv = (struct keyspan_pda_private *)(port->private); + priv = usb_get_serial_port_data(port); priv->tx_room = room; priv->tx_throttled = room ? 0 : 1; @@ -803,10 +805,10 @@ /* allocate the private data structures for all ports. Well, for all one ports. */ - priv = serial->port[0].private - = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); + priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); if (!priv) return (1); /* error */ + usb_set_serial_port_data(&serial->port[0], priv); init_waitqueue_head(&serial->port[0].write_wait); INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, (void *)(&serial->port[0])); @@ -820,7 +822,7 @@ { dbg("%s", __FUNCTION__); - kfree(serial->port[0].private); + kfree(usb_get_serial_port_data(&serial->port[0])); } #ifdef KEYSPAN diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c --- a/drivers/usb/serial/kl5kusb105.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/kl5kusb105.c Fri Dec 27 23:57:12 2002 @@ -265,13 +265,12 @@ /* allocate the private data structure */ for (i=0; inum_ports; i++) { - serial->port[i].private = kmalloc(sizeof(struct klsi_105_private), + priv = kmalloc(sizeof(struct klsi_105_private), GFP_KERNEL); - if (!serial->port[i].private) { + if (!priv) { dbg("%skmalloc for klsi_105_private failed.", __FUNCTION__); - return (-1); /* error */ + return -ENOMEM; } - priv = (struct klsi_105_private *)serial->port[i].private; /* set initial values for control structures */ priv->cfg.pktlen = 5; priv->cfg.baudrate = kl5kusb105a_sio_b9600; @@ -283,6 +282,7 @@ priv->bytes_in = 0; priv->bytes_out = 0; + usb_set_serial_port_data(&serial->port[i], priv); spin_lock_init (&priv->write_urb_pool_lock); for (i=0; inum_ports; ++i) { - struct klsi_105_private *priv = - (struct klsi_105_private*) serial->port[i].private; + struct klsi_105_private *priv = usb_get_serial_port_data(&serial->port[i]); unsigned long flags; if (priv) { @@ -347,7 +346,8 @@ spin_unlock_irqrestore (&priv->write_urb_pool_lock, flags); - kfree(serial->port[i].private); + kfree(priv); + usb_set_serial_port_data(&serial->port[i], NULL); } } } /* klsi_105_shutdown */ @@ -355,7 +355,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; - struct klsi_105_private *priv = (struct klsi_105_private *)port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); int retval = 0; int rc; int i; @@ -436,8 +436,7 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial; - struct klsi_105_private *priv - = (struct klsi_105_private *)port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); int rc; dbg("%s port %d", __FUNCTION__, port->number); @@ -481,8 +480,7 @@ const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; - struct klsi_105_private *priv = - (struct klsi_105_private*) port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); int result, size; int bytes_sent=0; @@ -588,8 +586,7 @@ int chars = 0; int i; unsigned long flags; - struct klsi_105_private *priv = - (struct klsi_105_private*) port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); spin_lock_irqsave (&priv->write_urb_pool_lock, flags); @@ -610,8 +607,7 @@ unsigned long flags; int i; int room = 0; - struct klsi_105_private *priv = - (struct klsi_105_private*) port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); spin_lock_irqsave (&priv->write_urb_pool_lock, flags); for (i = 0; i < NUM_URBS; ++i) { @@ -632,8 +628,7 @@ { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial *serial = port->serial; - struct klsi_105_private *priv = - (struct klsi_105_private*) port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int rc; @@ -715,7 +710,7 @@ struct termios *old_termios) { struct usb_serial *serial = port->serial; - struct klsi_105_private *priv = (struct klsi_105_private *)port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); unsigned int iflag = port->tty->termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag; unsigned int cflag = port->tty->termios->c_cflag; @@ -869,7 +864,7 @@ unsigned int cmd, unsigned long arg) { struct usb_serial *serial = port->serial; - struct klsi_105_private *priv = (struct klsi_105_private *)port->private; + struct klsi_105_private *priv = usb_get_serial_port_data(port); int mask; dbg("%scmd=0x%x", __FUNCTION__, cmd); diff -Nru a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c --- a/drivers/usb/serial/kobil_sct.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/kobil_sct.c Fri Dec 27 23:57:12 2002 @@ -136,12 +136,11 @@ struct usb_host_interface *altsetting; struct usb_host_endpoint *endpoint; - serial->port->private = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); - if (!serial->port->private){ - return -1; + priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL); + if (!priv){ + return -ENOMEM; } - priv = (struct kobil_private *) serial->port->private; priv->filled = 0; priv->cur_pos = 0; priv->device_type = serial->product; @@ -158,6 +157,7 @@ printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); break; } + usb_set_serial_port_data(serial->port, priv); // search for the neccessary endpoints pdev = serial->dev; @@ -192,9 +192,8 @@ while (serial->port[i].open_count > 0) { kobil_close (&serial->port[i], NULL); } - if (serial->port[i].private) { - kfree(serial->port[i].private); - } + kfree(usb_get_serial_port_data(&serial->port[i])); + usb_set_serial_port_data(&serial->port[i], NULL); } } @@ -208,7 +207,7 @@ int write_urb_transfer_buffer_length = 8; dbg("%s - port %d", __FUNCTION__, port->number); - priv = (struct kobil_private *) port->private; + priv = usb_get_serial_port_data(port); priv->line_state = 0; if (port_paranoia_check (port, __FUNCTION__)) @@ -413,7 +412,7 @@ return 0; } - priv = (struct kobil_private *) port->private; + priv = usb_get_serial_port_data(port); if (count > (KOBIL_BUF_LENGTH - priv->filled)) { dbg("%s - port %d Error: write request bigger than buffer size", __FUNCTION__, port->number); @@ -513,7 +512,7 @@ int transfer_buffer_length = 8; char *settings; - priv = (struct kobil_private *) port->private; + priv = usb_get_serial_port_data(port); if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) { // This device doesn't support ioctl calls return 0; diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c --- a/drivers/usb/serial/mct_u232.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/mct_u232.c Fri Dec 27 23:57:12 2002 @@ -304,40 +304,40 @@ struct mct_u232_private *priv; /* allocate the private data structure */ - serial->port->private = kmalloc(sizeof(struct mct_u232_private), - GFP_KERNEL); - if (!serial->port->private) + priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL); + if (!priv) return (-1); /* error */ - priv = (struct mct_u232_private *)serial->port->private; /* set initial values for control structures */ priv->control_state = 0; priv->last_lsr = 0; priv->last_msr = 0; + usb_set_serial_port_data(serial->port, priv); init_waitqueue_head(&serial->port->write_wait); - + return (0); } /* mct_u232_startup */ static void mct_u232_shutdown (struct usb_serial *serial) { + struct mct_u232_private *priv; int i; dbg("%s", __FUNCTION__); - /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { /* My special items, the standard routines free my urbs */ - if (serial->port[i].private) - kfree(serial->port[i].private); + priv = usb_get_serial_port_data(&serial->port[i]); + if (priv) + kfree(priv); } } /* mct_u232_shutdown */ static int mct_u232_open (struct usb_serial_port *port, struct file *filp) { struct usb_serial *serial = port->serial; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = usb_get_serial_port_data(port); int retval = 0; dbg("%s port %d", __FUNCTION__, port->number); @@ -375,7 +375,7 @@ struct usb_serial_port *rport; rport = &serial->port[1]; rport->tty = port->tty; - rport->private = port->private; + usb_set_serial_port_data(rport, usb_get_serial_port_data(port)); port->read_urb = rport->interrupt_in_urb; } @@ -518,7 +518,7 @@ static void mct_u232_read_int_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -609,7 +609,7 @@ struct termios *old_termios) { struct usb_serial *serial = port->serial; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned int iflag = port->tty->termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag; unsigned int cflag = port->tty->termios->c_cflag; @@ -725,7 +725,7 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) { struct usb_serial *serial = port->serial; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = usb_get_serial_port_data(port); unsigned char lcr = priv->last_lcr; dbg("%sstate=%d", __FUNCTION__, break_state); @@ -741,7 +741,7 @@ unsigned int cmd, unsigned long arg) { struct usb_serial *serial = port->serial; - struct mct_u232_private *priv = (struct mct_u232_private *)port->private; + struct mct_u232_private *priv = usb_get_serial_port_data(port); int mask; dbg("%scmd=0x%x", __FUNCTION__, cmd); diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c --- a/drivers/usb/serial/omninet.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/omninet.c Fri Dec 27 23:57:12 2002 @@ -168,7 +168,7 @@ return -ENOMEM; } - port->private = od; + usb_set_serial_port_data(port, od); wport = &serial->port[1]; wport->tty = port->tty; @@ -205,7 +205,7 @@ usb_unlink_urb (port->read_urb); } - od = (struct omninet_data *)port->private; + od = usb_get_serial_port_data(port); if (od) kfree(od); } @@ -272,7 +272,7 @@ struct usb_serial *serial = port->serial; struct usb_serial_port *wport = &serial->port[1]; - struct omninet_data *od = (struct omninet_data *) port->private; + struct omninet_data *od = usb_get_serial_port_data(port); struct omninet_header *header = (struct omninet_header *) wport->write_urb->transfer_buffer; int result; diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c --- a/drivers/usb/serial/pl2303.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/pl2303.c Fri Dec 27 23:57:12 2002 @@ -163,7 +163,7 @@ if (!priv) return -ENOMEM; memset (priv, 0x00, sizeof (struct pl2303_private)); - serial->port[i].private = priv; + usb_set_serial_port_data(&serial->port[i], priv); } return 0; } @@ -216,24 +216,23 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios) { struct usb_serial *serial = port->serial; - struct pl2303_private *priv; + struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned int cflag; unsigned char *buf; int baud; int i; - dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number, - ((struct pl2303_private *) port->private)->termios_initialized); + dbg("%s - port %d, initialized = %d", __FUNCTION__, port->number, priv->termios_initialized); if ((!port->tty) || (!port->tty->termios)) { dbg("%s - no tty structures", __FUNCTION__); return; } - if (!(((struct pl2303_private *) port->private)->termios_initialized)) { + if (!priv->termios_initialized) { *(port->tty->termios) = tty_std_termios; port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; - ((struct pl2303_private *) port->private)->termios_initialized = 1; + priv->termios_initialized = 1; } cflag = port->tty->termios->c_cflag; /* check that they really want us to change something */ @@ -341,7 +340,6 @@ dbg ("0x21:0x20:0:0 %d", i); if (cflag && CBAUD) { - priv = port->private; if ((cflag && CBAUD) == B0) priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); else @@ -450,7 +448,7 @@ c_cflag = port->tty->termios->c_cflag; if (c_cflag & HUPCL) { /* drop DTR and RTS */ - priv = port->private; + priv = usb_get_serial_port_data(port); priv->line_control = 0; set_control_lines (port->serial->dev, priv->line_control); @@ -481,7 +479,7 @@ static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned int *value) { - struct pl2303_private *priv = port->private; + struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned int arg; if (copy_from_user(&arg, value, sizeof(int))) @@ -516,7 +514,7 @@ static int get_modem_info (struct usb_serial_port *port, unsigned int *value) { - struct pl2303_private *priv = port->private; + struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned int mcr = priv->line_control; unsigned int result; @@ -583,8 +581,10 @@ dbg("%s", __FUNCTION__); - for (i = 0; i < serial->num_ports; ++i) - kfree (serial->port[i].private); + for (i = 0; i < serial->num_ports; ++i) { + kfree (usb_get_serial_port_data(&serial->port[i])); + usb_set_serial_port_data(&serial->port[i], NULL); + } } diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c --- a/drivers/usb/serial/whiteheat.c Fri Dec 27 23:57:12 2002 +++ b/drivers/usb/serial/whiteheat.c Fri Dec 27 23:57:12 2002 @@ -464,7 +464,7 @@ list_add(&wrap->list, &info->tx_urbs_free); } - port->private = info; + usb_set_serial_port_data(port, info); } command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); @@ -476,7 +476,7 @@ spin_lock_init(&command_info->lock); command_info->port_running = 0; init_waitqueue_head(&command_info->wait_command); - command_port->private = command_info; + usb_set_serial_port_data(command_port, command_info); command_port->write_urb->complete = command_port_write_callback; command_port->read_urb->complete = command_port_read_callback; @@ -492,7 +492,7 @@ no_command_private: for (i = serial->num_ports - 1; i >= 0; i--) { port = &serial->port[i]; - info = port->private; + info = usb_get_serial_port_data(port); for (j = urb_pool_size - 1; j >= 0; j--) { tmp = list_first(&info->tx_urbs_free); list_del(tmp); @@ -539,11 +539,11 @@ /* free up our private data for our command port */ command_port = &serial->port[COMMAND_PORT]; - kfree (command_port->private); + kfree (usb_get_serial_port_data(command_port)); for (i = 0; i < serial->num_ports; i++) { port = &serial->port[i]; - info = port->private; + info = usb_get_serial_port_data(port); list_for_each_safe(tmp, tmp2, &info->rx_urbs_free) { list_del(tmp); wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); @@ -620,7 +620,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp) { - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; struct urb *urb; struct list_head *tmp; @@ -686,7 +686,7 @@ static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; struct urb *urb; int result; @@ -749,7 +749,7 @@ static int whiteheat_write_room(struct usb_serial_port *port) { - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct list_head *tmp; int room = 0; unsigned long flags; @@ -769,7 +769,7 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) { - struct whiteheat_private *info = (struct whiteheat_private *)port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned int modem_signals = 0; struct serial_struct serstruct; @@ -903,7 +903,7 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port) { - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct list_head *tmp; struct whiteheat_urb_wrap *wrap; int chars = 0; @@ -925,7 +925,7 @@ static void whiteheat_throttle (struct usb_serial_port *port) { - struct whiteheat_private *info = (struct whiteheat_private *)port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); unsigned long flags; dbg("%s - port %d", __FUNCTION__, port->number); @@ -940,7 +940,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port) { - struct whiteheat_private *info = (struct whiteheat_private *)port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); int actually_throttled; unsigned long flags; @@ -999,7 +999,7 @@ usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); - command_info = (struct whiteheat_command_private *)command_port->private; + command_info = usb_get_serial_port_data(command_port); if (!command_info) { dbg ("%s - command_info is NULL, exiting.", __FUNCTION__); return; @@ -1038,7 +1038,7 @@ struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct whiteheat_urb_wrap *wrap; unsigned char *data = urb->transfer_buffer; - struct whiteheat_private *info = (struct whiteheat_private *)port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); dbg("%s - port %d", __FUNCTION__, port->number); @@ -1087,7 +1087,7 @@ { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; dbg("%s - port %d", __FUNCTION__, port->number); @@ -1135,7 +1135,7 @@ dbg("%s - command %d", __FUNCTION__, command); command_port = &port->serial->port[COMMAND_PORT]; - command_info = (struct whiteheat_command_private *)command_port->private; + command_info = usb_get_serial_port_data(command_port); spin_lock_irqsave(&command_info->lock, flags); command_info->command_finished = FALSE; @@ -1175,7 +1175,7 @@ dbg("%s - command completed.", __FUNCTION__); switch (command) { case WHITEHEAT_GET_DTR_RTS: - info = (struct whiteheat_private *)port->private; + info = usb_get_serial_port_data(port); memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info)); break; } @@ -1339,7 +1339,7 @@ int retval = 0; command_port = &serial->port[COMMAND_PORT]; - command_info = (struct whiteheat_command_private *)command_port->private; + command_info = usb_get_serial_port_data(command_port); spin_lock_irqsave(&command_info->lock, flags); if (!command_info->port_running) { /* Work around HCD bugs */ @@ -1367,7 +1367,7 @@ unsigned long flags; command_port = &serial->port[COMMAND_PORT]; - command_info = (struct whiteheat_command_private *)command_port->private; + command_info = usb_get_serial_port_data(command_port); spin_lock_irqsave(&command_info->lock, flags); command_info->port_running--; if (!command_info->port_running) @@ -1376,8 +1376,9 @@ } -static int start_port_read(struct usb_serial_port *port) { - struct whiteheat_private *info = port->private; +static int start_port_read(struct usb_serial_port *port) +{ + struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; struct urb *urb; int retval = 0; @@ -1413,7 +1414,8 @@ } -static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) { +static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) +{ struct whiteheat_urb_wrap *wrap; struct list_head *tmp; @@ -1427,14 +1429,16 @@ } -static struct list_head *list_first(struct list_head *head) { +static struct list_head *list_first(struct list_head *head) +{ return head->next; } -static void rx_data_softint(void *private) { +static void rx_data_softint(void *private) +{ struct usb_serial_port *port = (struct usb_serial_port *)private; - struct whiteheat_private *info = port->private; + struct whiteheat_private *info = usb_get_serial_port_data(port); struct tty_struct *tty = port->tty; struct whiteheat_urb_wrap *wrap; struct urb *urb;