Commit 3e52f135 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Vojtech Pavlik

[PATCH] USB: fix up the usb-serial drivers due to the removal of the struct...

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