Commit 5cd8de08 authored by Paul Fulghum's avatar Paul Fulghum Committed by Linus Torvalds

[PATCH] synclink update

- Remove MODULE_USE_COUNT macros
- Add owner member
- Add tiocmget/tiocmset tty callbacks
parent 719b6399
/* /*
* linux/drivers/char/synclink.c * linux/drivers/char/synclink.c
* *
* $Id: synclink.c,v 4.4 2002/10/10 14:53:36 paulkf Exp $ * $Id: synclink.c,v 4.6 2003/04/21 17:46:54 paulkf Exp $
* *
* Device driver for Microgate SyncLink ISA and PCI * Device driver for Microgate SyncLink ISA and PCI
* high speed multiprotocol serial adapters. * high speed multiprotocol serial adapters.
...@@ -854,9 +854,9 @@ isr_dispatch_func UscIsrTable[7] = ...@@ -854,9 +854,9 @@ isr_dispatch_func UscIsrTable[7] =
/* /*
* ioctl call handlers * ioctl call handlers
*/ */
static int set_modem_info(struct mgsl_struct * info, unsigned int cmd, static int tiocmget(struct tty_struct *tty, struct file *file);
unsigned int *value); static int tiocmset(struct tty_struct *tty, struct file *file,
static int get_modem_info(struct mgsl_struct * info, unsigned int *value); unsigned int set, unsigned int clear);
static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount
*user_icount); *user_icount);
static int mgsl_get_params(struct mgsl_struct * info, MGSL_PARAMS *user_params); static int mgsl_get_params(struct mgsl_struct * info, MGSL_PARAMS *user_params);
...@@ -917,7 +917,7 @@ MODULE_PARM(txdmabufs,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i"); ...@@ -917,7 +917,7 @@ MODULE_PARM(txdmabufs,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i");
MODULE_PARM(txholdbufs,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i"); MODULE_PARM(txholdbufs,"1-" __MODULE_STRING(MAX_TOTAL_DEVICES) "i");
static char *driver_name = "SyncLink serial driver"; static char *driver_name = "SyncLink serial driver";
static char *driver_version = "$Revision: 4.4 $"; static char *driver_version = "$Revision: 4.6 $";
static int synclink_init_one (struct pci_dev *dev, static int synclink_init_one (struct pci_dev *dev,
const struct pci_device_id *ent); const struct pci_device_id *ent);
...@@ -2921,110 +2921,58 @@ static int modem_input_wait(struct mgsl_struct *info,int arg) ...@@ -2921,110 +2921,58 @@ static int modem_input_wait(struct mgsl_struct *info,int arg)
return rc; return rc;
} }
/* get_modem_info() /* return the state of the serial control and status signals
*
* Read the state of the serial control and
* status signals and return to caller.
*
* Arguments: info pointer to device instance data
* value pointer to int to hold returned info
*
* Return Value: 0 if success, otherwise error code
*/ */
static int get_modem_info(struct mgsl_struct * info, unsigned int *value) static int tiocmget(struct tty_struct *tty, struct file *file)
{ {
unsigned int result = 0; struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
unsigned int result;
unsigned long flags; unsigned long flags;
int err;
spin_lock_irqsave(&info->irq_spinlock,flags); spin_lock_irqsave(&info->irq_spinlock,flags);
usc_get_serial_signals(info); usc_get_serial_signals(info);
spin_unlock_irqrestore(&info->irq_spinlock,flags); spin_unlock_irqrestore(&info->irq_spinlock,flags);
if (info->serial_signals & SerialSignal_RTS) result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) +
result |= TIOCM_RTS; ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) +
if (info->serial_signals & SerialSignal_DTR) ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) +
result |= TIOCM_DTR; ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) +
if (info->serial_signals & SerialSignal_DCD) ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) +
result |= TIOCM_CAR; ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
if (info->serial_signals & SerialSignal_RI)
result |= TIOCM_RNG;
if (info->serial_signals & SerialSignal_DSR)
result |= TIOCM_DSR;
if (info->serial_signals & SerialSignal_CTS)
result |= TIOCM_CTS;
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgsl_get_modem_info %s value=%08X\n", printk("%s(%d):%s tiocmget() value=%08X\n",
__FILE__,__LINE__, info->device_name, result ); __FILE__,__LINE__, info->device_name, result );
return result;
}
PUT_USER(err,result,value); /* set modem control signals (DTR/RTS)
return err;
} /* end of get_modem_info() */
/* set_modem_info()
*
* Set the state of the modem control signals (DTR/RTS)
*
* Arguments:
*
* info pointer to device instance data
* cmd signal command: TIOCMBIS = set bit TIOCMBIC = clear bit
* TIOCMSET = set/clear signal values
* value bit mask for command
*
* Return Value: 0 if success, otherwise error code
*/ */
static int set_modem_info(struct mgsl_struct * info, unsigned int cmd, static int tiocmset(struct tty_struct *tty, struct file *file,
unsigned int *value) unsigned int set, unsigned int clear)
{ {
int error; struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
unsigned int arg;
unsigned long flags; unsigned long flags;
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgsl_set_modem_info %s\n", __FILE__,__LINE__, printk("%s(%d):%s tiocmset(%x,%x)\n",
info->device_name ); __FILE__,__LINE__,info->device_name, set, clear);
GET_USER(error,arg,value);
if (error)
return error;
switch (cmd) { if (set & TIOCM_RTS)
case TIOCMBIS:
if (arg & TIOCM_RTS)
info->serial_signals |= SerialSignal_RTS; info->serial_signals |= SerialSignal_RTS;
if (arg & TIOCM_DTR) if (set & TIOCM_DTR)
info->serial_signals |= SerialSignal_DTR; info->serial_signals |= SerialSignal_DTR;
break; if (clear & TIOCM_RTS)
case TIOCMBIC:
if (arg & TIOCM_RTS)
info->serial_signals &= ~SerialSignal_RTS; info->serial_signals &= ~SerialSignal_RTS;
if (arg & TIOCM_DTR) if (clear & TIOCM_DTR)
info->serial_signals &= ~SerialSignal_DTR; info->serial_signals &= ~SerialSignal_DTR;
break;
case TIOCMSET:
if (arg & TIOCM_RTS)
info->serial_signals |= SerialSignal_RTS;
else
info->serial_signals &= ~SerialSignal_RTS;
if (arg & TIOCM_DTR)
info->serial_signals |= SerialSignal_DTR;
else
info->serial_signals &= ~SerialSignal_DTR;
break;
default:
return -EINVAL;
}
spin_lock_irqsave(&info->irq_spinlock,flags); spin_lock_irqsave(&info->irq_spinlock,flags);
usc_set_serial_signals(info); usc_set_serial_signals(info);
spin_unlock_irqrestore(&info->irq_spinlock,flags); spin_unlock_irqrestore(&info->irq_spinlock,flags);
return 0; return 0;
}
} /* end of set_modem_info() */
/* mgsl_break() Set or clear transmit break condition /* mgsl_break() Set or clear transmit break condition
* *
...@@ -3093,12 +3041,6 @@ int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long ...@@ -3093,12 +3041,6 @@ int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long
unsigned long flags; unsigned long flags;
switch (cmd) { switch (cmd) {
case TIOCMGET:
return get_modem_info(info, (unsigned int *) arg);
case TIOCMBIS:
case TIOCMBIC:
case TIOCMSET:
return set_modem_info(info, cmd, (unsigned int *) arg);
case MGSL_IOCGPARAMS: case MGSL_IOCGPARAMS:
return mgsl_get_params(info,(MGSL_PARAMS *)arg); return mgsl_get_params(info,(MGSL_PARAMS *)arg);
case MGSL_IOCSPARAMS: case MGSL_IOCSPARAMS:
...@@ -3323,7 +3265,6 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp) ...@@ -3323,7 +3265,6 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__, printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
tty->driver.name, info->count); tty->driver.name, info->count);
MOD_DEC_USE_COUNT;
} /* end of mgsl_close() */ } /* end of mgsl_close() */
...@@ -3615,8 +3556,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) ...@@ -3615,8 +3556,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
printk("%s(%d):mgsl_open(%s), old ref count = %d\n", printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
__FILE__,__LINE__,tty->driver.name, info->count); __FILE__,__LINE__,tty->driver.name, info->count);
MOD_INC_USE_COUNT;
/* If port is closing, signal caller to try again */ /* If port is closing, signal caller to try again */
if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
if (info->flags & ASYNC_CLOSING) if (info->flags & ASYNC_CLOSING)
...@@ -3683,7 +3622,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) ...@@ -3683,7 +3622,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
cleanup: cleanup:
if (retval) { if (retval) {
MOD_DEC_USE_COUNT;
if(info->count) if(info->count)
info->count--; info->count--;
} }
...@@ -4571,6 +4509,7 @@ int mgsl_init_tty() ...@@ -4571,6 +4509,7 @@ int mgsl_init_tty()
memset(&serial_driver, 0, sizeof(struct tty_driver)); memset(&serial_driver, 0, sizeof(struct tty_driver));
serial_driver.magic = TTY_DRIVER_MAGIC; serial_driver.magic = TTY_DRIVER_MAGIC;
serial_driver.owner = THIS_MODULE;
serial_driver.driver_name = "synclink"; serial_driver.driver_name = "synclink";
serial_driver.name = "ttySL"; serial_driver.name = "ttySL";
serial_driver.major = ttymajor; serial_driver.major = ttymajor;
...@@ -4606,6 +4545,8 @@ int mgsl_init_tty() ...@@ -4606,6 +4545,8 @@ int mgsl_init_tty()
serial_driver.stop = mgsl_stop; serial_driver.stop = mgsl_stop;
serial_driver.start = mgsl_start; serial_driver.start = mgsl_start;
serial_driver.hangup = mgsl_hangup; serial_driver.hangup = mgsl_hangup;
serial_driver.tiocmget = tiocmget;
serial_driver.tiocmset = tiocmset;
/* /*
* The callout device is just like normal device except for * The callout device is just like normal device except for
...@@ -8003,7 +7944,6 @@ int mgsl_sppp_open(struct net_device *d) ...@@ -8003,7 +7944,6 @@ int mgsl_sppp_open(struct net_device *d)
return -EBUSY; return -EBUSY;
} }
info->netcount=1; info->netcount=1;
MOD_INC_USE_COUNT;
spin_unlock_irqrestore(&info->netlock, flags); spin_unlock_irqrestore(&info->netlock, flags);
/* claim resources and init adapter */ /* claim resources and init adapter */
...@@ -8026,7 +7966,6 @@ int mgsl_sppp_open(struct net_device *d) ...@@ -8026,7 +7966,6 @@ int mgsl_sppp_open(struct net_device *d)
open_fail: open_fail:
spin_lock_irqsave(&info->netlock, flags); spin_lock_irqsave(&info->netlock, flags);
info->netcount=0; info->netcount=0;
MOD_DEC_USE_COUNT;
spin_unlock_irqrestore(&info->netlock, flags); spin_unlock_irqrestore(&info->netlock, flags);
return err; return err;
} }
...@@ -8092,7 +8031,6 @@ int mgsl_sppp_close(struct net_device *d) ...@@ -8092,7 +8031,6 @@ int mgsl_sppp_close(struct net_device *d)
spin_lock_irqsave(&info->netlock, flags); spin_lock_irqsave(&info->netlock, flags);
info->netcount=0; info->netcount=0;
MOD_DEC_USE_COUNT;
spin_unlock_irqrestore(&info->netlock, flags); spin_unlock_irqrestore(&info->netlock, flags);
return 0; return 0;
} }
......
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