Commit acad5f8f authored by Paul Fulghum's avatar Paul Fulghum Committed by Linus Torvalds

[PATCH] synclink_cs update

- Remove MODULE_USE_COUNT macros
- Add owner member
- Add tiocmget/tiocmset tty callbacks
parent 4e4ab5fe
/* /*
* linux/drivers/char/pcmcia/synclink_cs.c * linux/drivers/char/pcmcia/synclink_cs.c
* *
* $Id: synclink_cs.c,v 4.4 2002/10/10 14:53:37 paulkf Exp $ * $Id: synclink_cs.c,v 4.6 2003/04/21 17:46:55 paulkf Exp $
* *
* Device driver for Microgate SyncLink PC Card * Device driver for Microgate SyncLink PC Card
* multiprotocol serial adapter. * multiprotocol serial adapter.
...@@ -442,9 +442,9 @@ static void bh_status(MGSLPC_INFO *info); ...@@ -442,9 +442,9 @@ static void bh_status(MGSLPC_INFO *info);
/* /*
* ioctl handlers * ioctl handlers
*/ */
static int set_modem_info(MGSLPC_INFO *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(MGSLPC_INFO *info, unsigned int *value); unsigned int set, unsigned int clear);
static int get_stats(MGSLPC_INFO *info, struct mgsl_icount *user_icount); static int get_stats(MGSLPC_INFO *info, struct mgsl_icount *user_icount);
static int get_params(MGSLPC_INFO *info, MGSL_PARAMS *user_params); static int get_params(MGSLPC_INFO *info, MGSL_PARAMS *user_params);
static int set_params(MGSLPC_INFO *info, MGSL_PARAMS *new_params); static int set_params(MGSLPC_INFO *info, MGSL_PARAMS *new_params);
...@@ -496,7 +496,7 @@ MODULE_PARM(maxframe,"1-" __MODULE_STRING(MAX_DEVICE_COUNT) "i"); ...@@ -496,7 +496,7 @@ MODULE_PARM(maxframe,"1-" __MODULE_STRING(MAX_DEVICE_COUNT) "i");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static char *driver_name = "SyncLink PC Card driver"; static char *driver_name = "SyncLink PC Card driver";
static char *driver_version = "$Revision: 4.4 $"; static char *driver_version = "$Revision: 4.6 $";
static struct tty_driver serial_driver, callout_driver; static struct tty_driver serial_driver, callout_driver;
static int serial_refcount; static int serial_refcount;
...@@ -2326,89 +2326,51 @@ static int modem_input_wait(MGSLPC_INFO *info,int arg) ...@@ -2326,89 +2326,51 @@ static int modem_input_wait(MGSLPC_INFO *info,int arg)
return rc; return rc;
} }
/* Return state of the serial control/status signals /* return the state of the serial control and status signals
*
* 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(MGSLPC_INFO * info, unsigned int *value) static int tiocmget(struct tty_struct *tty, struct file *file)
{ {
MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
unsigned int result; unsigned int result;
unsigned long flags; unsigned long flags;
int err;
spin_lock_irqsave(&info->lock,flags); spin_lock_irqsave(&info->lock,flags);
get_signals(info); get_signals(info);
spin_unlock_irqrestore(&info->lock,flags); spin_unlock_irqrestore(&info->lock,flags);
result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) | result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) +
((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) | ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) +
((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) | ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) +
((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) | ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) +
((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) | ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) +
((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0);
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_get_modem_info %s value=%08X\n", info->device_name, result); printk("%s(%d):%s tiocmget() value=%08X\n",
__FILE__,__LINE__, info->device_name, result );
PUT_USER(err,result,value); return result;
return err ? -EFAULT : 0;
} }
/* Set the state of the modem control signals (DTR/RTS) /* set 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(MGSLPC_INFO * 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; MGSLPC_INFO *info = (MGSLPC_INFO *)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("mgslpc_set_modem_info %s\n", info->device_name); printk("%s(%d):%s tiocmset(%x,%x)\n",
__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;
if (arg & TIOCM_DTR)
info->serial_signals &= ~SerialSignal_DTR;
break;
case TIOCMSET:
if (arg & TIOCM_RTS)
info->serial_signals |= SerialSignal_RTS;
else
info->serial_signals &= ~SerialSignal_RTS; info->serial_signals &= ~SerialSignal_RTS;
if (clear & TIOCM_DTR)
if (arg & TIOCM_DTR)
info->serial_signals |= SerialSignal_DTR;
else
info->serial_signals &= ~SerialSignal_DTR; info->serial_signals &= ~SerialSignal_DTR;
break;
default:
return -EINVAL;
}
spin_lock_irqsave(&info->lock,flags); spin_lock_irqsave(&info->lock,flags);
set_signals(info); set_signals(info);
...@@ -2482,12 +2444,6 @@ int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) ...@@ -2482,12 +2444,6 @@ int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg)
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 get_params(info,(MGSL_PARAMS *)arg); return get_params(info,(MGSL_PARAMS *)arg);
case MGSL_IOCSPARAMS: case MGSL_IOCSPARAMS:
...@@ -2687,7 +2643,6 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) ...@@ -2687,7 +2643,6 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__, printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
tty->driver.name, info->count); tty->driver.name, info->count);
MOD_DEC_USE_COUNT;
} }
/* Wait until the transmitter is empty. /* Wait until the transmitter is empty.
...@@ -2939,8 +2894,6 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) ...@@ -2939,8 +2894,6 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", printk("%s(%d):mgslpc_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)
...@@ -2995,7 +2948,6 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) ...@@ -2995,7 +2948,6 @@ static int mgslpc_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--;
} }
...@@ -3247,6 +3199,7 @@ static int __init synclink_cs_init(void) ...@@ -3247,6 +3199,7 @@ static int __init synclink_cs_init(void)
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_cs"; serial_driver.driver_name = "synclink_cs";
serial_driver.name = "ttySLP"; serial_driver.name = "ttySLP";
serial_driver.major = ttymajor; serial_driver.major = ttymajor;
...@@ -3282,6 +3235,8 @@ static int __init synclink_cs_init(void) ...@@ -3282,6 +3235,8 @@ static int __init synclink_cs_init(void)
serial_driver.stop = tx_pause; serial_driver.stop = tx_pause;
serial_driver.start = tx_release; serial_driver.start = tx_release;
serial_driver.hangup = mgslpc_hangup; serial_driver.hangup = mgslpc_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
...@@ -4386,7 +4341,7 @@ int mgslpc_sppp_open(struct net_device *d) ...@@ -4386,7 +4341,7 @@ int mgslpc_sppp_open(struct net_device *d)
{ {
MGSLPC_INFO *info = d->priv; MGSLPC_INFO *info = d->priv;
int err; int err;
long flags; unsigned long flags;
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_sppp_open(%s)\n",info->netname); printk("mgslpc_sppp_open(%s)\n",info->netname);
...@@ -4398,7 +4353,6 @@ int mgslpc_sppp_open(struct net_device *d) ...@@ -4398,7 +4353,6 @@ int mgslpc_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 */
...@@ -4421,7 +4375,6 @@ int mgslpc_sppp_open(struct net_device *d) ...@@ -4421,7 +4375,6 @@ int mgslpc_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;
} }
...@@ -4429,7 +4382,7 @@ int mgslpc_sppp_open(struct net_device *d) ...@@ -4429,7 +4382,7 @@ int mgslpc_sppp_open(struct net_device *d)
void mgslpc_sppp_tx_timeout(struct net_device *dev) void mgslpc_sppp_tx_timeout(struct net_device *dev)
{ {
MGSLPC_INFO *info = dev->priv; MGSLPC_INFO *info = dev->priv;
long flags; unsigned long flags;
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_sppp_tx_timeout(%s)\n",info->netname); printk("mgslpc_sppp_tx_timeout(%s)\n",info->netname);
...@@ -4491,7 +4444,6 @@ int mgslpc_sppp_close(struct net_device *d) ...@@ -4491,7 +4444,6 @@ int mgslpc_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