#include <linux/cdk.h>
#include <linux/comstats.h>
#include <linux/delay.h>
+#include <linux/bitops.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
-#include <asm/bitops.h>
#include <linux/vmalloc.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
static int ip2_read_procmem(char *, char **, off_t, int);
-int ip2_read_proc(char *, char **, off_t, int, int *, void * );
+static int ip2_read_proc(char *, char **, off_t, int, int *, void * );
/********************/
/* Type Definitions */
static void ip2_wait_until_sent(PTTY,int);
static void set_params (i2ChanStrPtr, struct termios *);
-static int set_modem_info(i2ChanStrPtr, unsigned int, unsigned int *);
-static int get_serial_info(i2ChanStrPtr, struct serial_struct *);
-static int set_serial_info(i2ChanStrPtr, struct serial_struct *);
+static int get_serial_info(i2ChanStrPtr, struct serial_struct __user *);
+static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *);
-static ssize_t ip2_ipl_read(struct file *, char *, size_t, loff_t *);
-static ssize_t ip2_ipl_write(struct file *, const char *, size_t, loff_t *);
+static ssize_t ip2_ipl_read(struct file *, char __user *, size_t, loff_t *);
+static ssize_t ip2_ipl_write(struct file *, const char __user *, size_t, loff_t *);
static int ip2_ipl_ioctl(struct inode *, struct file *, UINT, ULONG);
static int ip2_ipl_open(struct inode *, struct file *);
-static int DumpTraceBuffer(char *, int);
-static int DumpFifoBuffer( char *, int);
+static int DumpTraceBuffer(char __user *, int);
+static int DumpFifoBuffer( char __user *, int);
static void ip2_init_board(int);
static unsigned short find_eisa_board(int);
// free memory
for (i = 0; i < IP2_MAX_BOARDS; i++) {
void *pB;
+#ifdef CONFIG_PCI
+ if (ip2config.type[i] == PCI && ip2config.pci_dev[i]) {
+ pci_disable_device(ip2config.pci_dev[i]);
+ ip2config.pci_dev[i] = NULL;
+ }
+#endif
if ((pB = i2BoardPtrTable[i]) != 0 ) {
kfree ( pB );
i2BoardPtrTable[i] = NULL;
PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
if (pci_dev_i != NULL) {
unsigned int addr;
- unsigned char pci_irq;
+ if (pci_enable_device(pci_dev_i)) {
+ printk( KERN_ERR "IP2: can't enable PCI device at %s\n",
+ pci_name(pci_dev_i));
+ break;
+ }
ip2config.type[i] = PCI;
+ ip2config.pci_dev[i] = pci_dev_i;
status =
pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr);
if ( addr & 1 ) {
} else {
printk( KERN_ERR "IP2: PCI I/O address error\n");
}
- status =
- pci_read_config_byte(pci_dev_i, PCI_INTERRUPT_LINE, &pci_irq);
// If the PCI BIOS assigned it, lets try and use it. If we
// can't acquire it or it screws up, deal with it then.
// printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq);
// pci_irq = 0;
// }
- ip2config.irq[i] = pci_irq;
+ ip2config.irq[i] = pci_dev_i->irq;
} else { // ann error
ip2config.addr[i] = 0;
if (status == PCIBIOS_DEVICE_NOT_FOUND) {
/******************************************************************************/
static inline void
-service_all_boards()
+service_all_boards(void)
{
int i;
i2eBordStrPtr pB;
if (pCh->wopen) {
if (pCh->ClosingDelay) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(pCh->ClosingDelay);
+ msleep_interruptible(jiffies_to_msecs(pCh->ClosingDelay));
}
wake_up_interruptible(&pCh->open_wait);
}
wait_queue_t wait;
i2ChanStrPtr pCh = DevTable[tty->index];
struct async_icount cprev, cnow; /* kernel counter temps */
- struct serial_icounter_struct *p_cuser; /* user space */
+ struct serial_icounter_struct __user *p_cuser;
int rc = 0;
unsigned long flags;
+ void __user *argp = (void __user *)arg;
if ( pCh == NULL ) {
return -ENODEV;
ip2trace (CHANN, ITRC_IOCTL, 2, 1, rc );
- rc = get_serial_info(pCh, (struct serial_struct *) arg);
+ rc = get_serial_info(pCh, argp);
if (rc)
return rc;
break;
ip2trace (CHANN, ITRC_IOCTL, 3, 1, rc );
- rc = set_serial_info(pCh, (struct serial_struct *) arg);
+ rc = set_serial_info(pCh, argp);
if (rc)
return rc;
break;
ip2trace (CHANN, ITRC_IOCTL, 6, 1, rc );
- rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
+ rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
if (rc)
return rc;
break;
ip2trace (CHANN, ITRC_IOCTL, 7, 1, rc );
- rc = get_user(arg,(unsigned long *) arg);
+ rc = get_user(arg,(unsigned long __user *) argp);
if (rc)
return rc;
tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL)
save_flags(flags);cli();
cnow = pCh->icount;
restore_flags(flags);
- p_cuser = (struct serial_icounter_struct *) arg;
+ p_cuser = argp;
rc = put_user(cnow.cts, &p_cuser->cts);
rc = put_user(cnow.dsr, &p_cuser->dsr);
rc = put_user(cnow.rng, &p_cuser->rng);
/* standard Linux serial structure. */
/******************************************************************************/
static int
-get_serial_info ( i2ChanStrPtr pCh, struct serial_struct *retinfo )
+get_serial_info ( i2ChanStrPtr pCh, struct serial_struct __user *retinfo )
{
struct serial_struct tmp;
- int rc;
-
- if ( !retinfo ) {
- return -EFAULT;
- }
memset ( &tmp, 0, sizeof(tmp) );
tmp.type = pCh->pMyBord->channelBtypes.bid_value[(pCh->port_index & (IP2_PORTS_PER_BOARD-1))/16];
tmp.close_delay = pCh->ClosingDelay;
tmp.closing_wait = pCh->ClosingWaitTime;
tmp.custom_divisor = pCh->BaudDivisor;
- rc = copy_to_user(retinfo,&tmp,sizeof(*retinfo));
- return rc;
+ return copy_to_user(retinfo,&tmp,sizeof(*retinfo));
}
/******************************************************************************/
/* change the IRQ, address or type of the port the ioctl fails. */
/******************************************************************************/
static int
-set_serial_info( i2ChanStrPtr pCh, struct serial_struct *new_info )
+set_serial_info( i2ChanStrPtr pCh, struct serial_struct __user *new_info )
{
struct serial_struct ns;
int old_flags, old_baud_divisor;
- if ( !new_info ) {
- return -EFAULT;
- }
-
- if (copy_from_user(&ns, new_info, sizeof (ns))) {
+ if (copy_from_user(&ns, new_info, sizeof (ns)))
return -EFAULT;
- }
/*
* We don't allow setserial to change IRQ, board address, type or baud
static
ssize_t
-ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off )
+ip2_ipl_read(struct file *pFile, char __user *pData, size_t count, loff_t *off )
{
unsigned int minor = iminor(pFile->f_dentry->d_inode);
int rc = 0;
}
static int
-DumpFifoBuffer ( char *pData, int count )
+DumpFifoBuffer ( char __user *pData, int count )
{
#ifdef DEBUG_FIFO
int rc;
}
static int
-DumpTraceBuffer ( char *pData, int count )
+DumpTraceBuffer ( char __user *pData, int count )
{
#ifdef IP2DEBUG_TRACE
int rc;
int dumpcount;
int chunk;
- int *pIndex = (int*)pData;
+ int *pIndex = (int __user *)pData;
if ( count < (sizeof(int) * 6) ) {
return -EIO;
/* */
/******************************************************************************/
static ssize_t
-ip2_ipl_write(struct file *pFile, const char *pData, size_t count, loff_t *off)
+ip2_ipl_write(struct file *pFile, const char __user *pData, size_t count, loff_t *off)
{
#ifdef IP2DEBUG_IPL
printk (KERN_DEBUG "IP2IPL: write %p, %d bytes\n", pData, count );
{
unsigned int iplminor = iminor(pInode);
int rc = 0;
- ULONG *pIndex = (ULONG*)arg;
+ void __user *argp = (void __user *)arg;
+ ULONG __user *pIndex = argp;
i2eBordStrPtr pB = i2BoardPtrTable[iplminor / 4];
i2ChanStrPtr pCh;
case 65: /* Board - ip2stat */
if ( pB ) {
- rc = copy_to_user((char*)arg, (char*)pB, sizeof(i2eBordStr) );
+ rc = copy_to_user(argp, pB, sizeof(i2eBordStr));
rc = put_user(INB(pB->i2eStatus),
- (ULONG*)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) );
+ (ULONG __user *)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) );
} else {
rc = -ENODEV;
}
pCh = DevTable[cmd];
if ( pCh )
{
- rc = copy_to_user((char*)arg, (char*)pCh, sizeof(i2ChanStr) );
+ rc = copy_to_user(argp, pCh, sizeof(i2ChanStr));
} else {
rc = -ENODEV;
}
* different sources including ip2mkdev.c and a couple of other drivers.
* The bugs are all mine. :-) =mhw=
*/
-int ip2_read_proc(char *page, char **start, off_t off,
+static int ip2_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int i, j, box;