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