linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / char / ip2main.c
index 043cff4..48fcfba 100644 (file)
@@ -99,6 +99,7 @@
 #include <linux/slab.h>
 #include <linux/major.h>
 #include <linux/wait.h>
+#include <linux/device.h>
 
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #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 <asm/serial.h>
 
 #include <asm/uaccess.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 */
@@ -172,7 +172,7 @@ static int Fip_firmware_size;
 /* Private (static) functions */
 static int  ip2_open(PTTY, struct file *);
 static void ip2_close(PTTY, struct file *);
-static int  ip2_write(PTTY, int, const unsigned char *, int);
+static int  ip2_write(PTTY, const unsigned char *, int);
 static void ip2_putchar(PTTY, unsigned char);
 static void ip2_flush_chars(PTTY);
 static int  ip2_write_room(PTTY);
@@ -201,17 +201,16 @@ static void do_status(void *p);
 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);
@@ -255,7 +254,7 @@ static unsigned long bh_counter = 0;
  * selected, the board is serviced periodically to see if anything needs doing.
  */
 #define  POLL_TIMEOUT   (jiffies + 1)
-static struct timer_list PollTimer = TIMER_INITIALIZER(ip2_poll, 0, 0);
+static DEFINE_TIMER(PollTimer, ip2_poll, 0, 0);
 static char  TimerOn;
 
 #ifdef IP2DEBUG_TRACE
@@ -301,6 +300,9 @@ static int iindx;
 static char rirqs[IP2_MAX_BOARDS];
 static int Valid_Irqs[] = { 3, 4, 5, 7, 10, 11, 12, 15, 0};
 
+/* for sysfs class support */
+static struct class *ip2_class;
+
 // Some functions to keep track of what irq's we have
 
 static int __init
@@ -411,7 +413,9 @@ cleanup_module(void)
                        iiResetDelay( i2BoardPtrTable[i] );
                        /* free io addresses and Tibet */
                        release_region( ip2config.addr[i], 8 );
+                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
                        devfs_remove("ip2/ipl%d", i);
+                       class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
                        devfs_remove("ip2/stat%d", i);
                }
                /* Disable and remove interrupt handler. */
@@ -420,6 +424,7 @@ cleanup_module(void)
                        clear_requested_irq( ip2config.irq[i]);
                }
        }
+       class_destroy(ip2_class);
        devfs_remove("ip2");
        if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) {
                printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err);
@@ -433,6 +438,12 @@ cleanup_module(void)
        // 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;
@@ -494,7 +505,7 @@ int
 ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) 
 {
        int i, j, box;
-       int err;
+       int err = 0;
        int status = 0;
        static int loaded;
        i2eBordStrPtr pB = NULL;
@@ -587,9 +598,14 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                                          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 ) {
@@ -597,8 +613,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                        } 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.
@@ -607,7 +621,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
 //                                             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) {
@@ -683,7 +697,14 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
        /* Register the IPL driver. */
        if ( ( err = register_chrdev ( IP2_IPL_MAJOR, pcIpl, &ip2_ipl ) ) ) {
                printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err );
-       } else
+       } else {
+               /* create the sysfs class */
+               ip2_class = class_create(THIS_MODULE, "ip2");
+               if (IS_ERR(ip2_class)) {
+                       err = PTR_ERR(ip2_class);
+                       goto out_chrdev;        
+               }
+       }
        /* Register the read_procmem thing */
        if (!create_proc_info_entry("ip2mem",0,&proc_root,ip2_read_procmem)) {
                printk(KERN_ERR "IP2: failed to register read_procmem\n");
@@ -700,13 +721,29 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                        }
 
                        if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
-                               devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
+                               class_device_create(ip2_class, NULL,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i),
+                                               NULL, "ipl%d", i);
+                               err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
                                                S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
                                                "ip2/ipl%d", i);
+                               if (err) {
+                                       class_device_destroy(ip2_class,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i));
+                                       goto out_class;
+                               }
 
-                               devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
+                               class_device_create(ip2_class, NULL,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
+                                               NULL, "stat%d", i);
+                               err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
                                                S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
                                                "ip2/stat%d", i);
+                               if (err) {
+                                       class_device_destroy(ip2_class,
+                                               MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
+                                       goto out_class;
+                               }
 
                            for ( box = 0; box < ABS_MAX_BOXES; ++box )
                            {
@@ -759,8 +796,14 @@ retry:
                }
        }
        ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_RETURN, 0 );
-
-       return 0;
+       goto out;
+
+out_class:
+       class_destroy(ip2_class);
+out_chrdev:
+       unregister_chrdev(IP2_IPL_MAJOR, "ip2");
+out:
+       return err;
 }
 
 EXPORT_SYMBOL(ip2_loadmain);
@@ -1087,7 +1130,7 @@ set_irq( int boardnum, int boardIrq )
 /******************************************************************************/
 
 static inline void
-service_all_boards()
+service_all_boards(void)
 {
        int i;
        i2eBordStrPtr  pB;
@@ -1589,8 +1632,7 @@ ip2_close( PTTY tty, struct file *pFile )
 
        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);
        }
@@ -1671,7 +1713,7 @@ ip2_hangup ( PTTY tty )
 /*                                                                            */
 /******************************************************************************/
 static int
-ip2_write( PTTY tty, int user, const unsigned char *pData, int count)
+ip2_write( PTTY tty, const unsigned char *pData, int count)
 {
        i2ChanStrPtr  pCh = tty->driver_data;
        int bytesSent = 0;
@@ -1684,7 +1726,7 @@ ip2_write( PTTY tty, int user, const unsigned char *pData, int count)
 
        /* This is the actual move bit. Make sure it does what we need!!!!! */
        WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags);
-       bytesSent = i2Output( pCh, pData, count, user );
+       bytesSent = i2Output( pCh, pData, count, 0 );
        WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags);
 
        ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent );
@@ -1959,7 +2001,9 @@ ip2_stop ( PTTY tty )
 static int ip2_tiocmget(struct tty_struct *tty, struct file *file)
 {
        i2ChanStrPtr pCh = DevTable[tty->index];
+#ifdef ENABLE_DSSNOW
        wait_queue_t wait;
+#endif
 
        if (pCh == NULL)
                return -ENODEV;
@@ -2047,14 +2091,17 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 {
        wait_queue_t wait;
        i2ChanStrPtr pCh = DevTable[tty->index];
+       i2eBordStrPtr pB;
        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 ) {
+       if ( pCh == NULL )
                return -ENODEV;
-       }
+
+       pB = pCh->pMyBord;
 
        ip2trace (CHANN, ITRC_IOCTL, ITRC_ENTER, 2, cmd, arg );
 
@@ -2067,7 +2114,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 
                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;
@@ -2076,7 +2123,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 
                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;
@@ -2140,7 +2187,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 
                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;
@@ -2149,7 +2196,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 
                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)
@@ -2163,9 +2210,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
         * for masking). Caller should use TIOCGICOUNT to see which one it was
         */
        case TIOCMIWAIT:
-               save_flags(flags);cli();
+               WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags);
                cprev = pCh->icount;     /* note the counters on entry */
-               restore_flags(flags);
+               WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags);
                i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4, 
                                                CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP);
                init_waitqueue_entry(&wait, current);
@@ -2185,9 +2232,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
                                rc = -ERESTARTSYS;
                                break;
                        }
-                       save_flags(flags);cli();
+                       WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags);
                        cnow = pCh->icount; /* atomic copy */
-                       restore_flags(flags);
+                       WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags);
                        if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
                                cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
                                rc =  -EIO; /* no change => rc */
@@ -2225,10 +2272,10 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
        case TIOCGICOUNT:
                ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc );
 
-               save_flags(flags);cli();
+               WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags);
                cnow = pCh->icount;
-               restore_flags(flags);
-               p_cuser = (struct serial_icounter_struct *) arg;
+               WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags);
+               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);
@@ -2277,14 +2324,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
 /* 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];
@@ -2301,8 +2343,7 @@ get_serial_info ( i2ChanStrPtr pCh, struct serial_struct *retinfo )
        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));
 }
 
 /******************************************************************************/
@@ -2317,18 +2358,13 @@ get_serial_info ( i2ChanStrPtr pCh, struct serial_struct *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 ) {
+       if (copy_from_user(&ns, new_info, sizeof (ns)))
                return -EFAULT;
-       }
-
-       if (copy_from_user(&ns, new_info, sizeof (ns))) {
-               return -EFAULT;
-       }
 
        /*
         * We don't allow setserial to change IRQ, board address, type or baud
@@ -2660,16 +2696,6 @@ no_xon:
                pCh->flags      |= ASYNC_CHECK_CD;
        }
 
-#ifdef XXX
-do_flags_thing:        // This is a test, we don't do the flags thing
-       
-       if ( (cflag & CRTSCTS) ) {
-               cflag |= 014000000000;
-       }
-       i2QueueCommands(PTYPE_BYPASS, pCh, 100, 1, 
-                               CMD_UNIX_FLAGS(iflag,cflag,lflag));
-#endif
-               
 service_it:
        i2DrainOutput( pCh, 100 );              
 }
@@ -2693,7 +2719,7 @@ service_it:
 
 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;
@@ -2726,7 +2752,7 @@ ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off )
 }
 
 static int
-DumpFifoBuffer ( char *pData, int count )
+DumpFifoBuffer ( char __user *pData, int count )
 {
 #ifdef DEBUG_FIFO
        int rc;
@@ -2740,13 +2766,13 @@ DumpFifoBuffer ( char *pData, int count )
 }
 
 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;
@@ -2802,7 +2828,7 @@ DumpTraceBuffer ( char *pData, int count )
 /*                                                                            */
 /******************************************************************************/
 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 );
@@ -2827,7 +2853,8 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
 {
        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;
 
@@ -2852,9 +2879,9 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
 
                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;
                        }
@@ -2865,7 +2892,7 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
                                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;
                                }
@@ -2879,65 +2906,16 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
                rc = -EINVAL;
                break;
        case 3:     // Trace device
-               if ( cmd == 1 ) {
-                       rc = put_user(iiSendPendingMail, pIndex++ );
-                       rc = put_user(i2InitChannels, pIndex++ );
-                       rc = put_user(i2QueueNeeds, pIndex++ );
-                       rc = put_user(i2QueueCommands, pIndex++ );
-                       rc = put_user(i2GetStatus, pIndex++ );
-                       rc = put_user(i2Input, pIndex++ );
-                       rc = put_user(i2InputFlush, pIndex++ );
-                       rc = put_user(i2Output, pIndex++ );
-                       rc = put_user(i2FlushOutput, pIndex++ );
-                       rc = put_user(i2DrainWakeup, pIndex++ );
-                       rc = put_user(i2DrainOutput, pIndex++ );
-                       rc = put_user(i2OutputFree, pIndex++ );
-                       rc = put_user(i2StripFifo, pIndex++ );
-                       rc = put_user(i2StuffFifoBypass, pIndex++ );
-                       rc = put_user(i2StuffFifoFlow, pIndex++ );
-                       rc = put_user(i2StuffFifoInline, pIndex++ );
-                       rc = put_user(i2ServiceBoard, pIndex++ );
-                       rc = put_user(serviceOutgoingFifo, pIndex++ );
-                       // rc = put_user(ip2_init, pIndex++ );
-                       rc = put_user(ip2_init_board, pIndex++ );
-                       rc = put_user(find_eisa_board, pIndex++ );
-                       rc = put_user(set_irq, pIndex++ );
-                       rc = put_user(ip2_interrupt, pIndex++ );
-                       rc = put_user(ip2_poll, pIndex++ );
-                       rc = put_user(service_all_boards, pIndex++ );
-                       rc = put_user(do_input, pIndex++ );
-                       rc = put_user(do_status, pIndex++ );
-#ifndef IP2DEBUG_OPEN
-                       rc = put_user(0, pIndex++ );
-#else
-                       rc = put_user(open_sanity_check, pIndex++ );
-#endif
-                       rc = put_user(ip2_open, pIndex++ );
-                       rc = put_user(ip2_close, pIndex++ );
-                       rc = put_user(ip2_hangup, pIndex++ );
-                       rc = put_user(ip2_write, pIndex++ );
-                       rc = put_user(ip2_putchar, pIndex++ );
-                       rc = put_user(ip2_flush_chars, pIndex++ );
-                       rc = put_user(ip2_write_room, pIndex++ );
-                       rc = put_user(ip2_chars_in_buf, pIndex++ );
-                       rc = put_user(ip2_flush_buffer, pIndex++ );
-
-                       //rc = put_user(ip2_wait_until_sent, pIndex++ );
-                       rc = put_user(0, pIndex++ );
-
-                       rc = put_user(ip2_throttle, pIndex++ );
-                       rc = put_user(ip2_unthrottle, pIndex++ );
-                       rc = put_user(ip2_ioctl, pIndex++ );
-                       rc = put_user(0, pIndex++ );
-                       rc = put_user(get_serial_info, pIndex++ );
-                       rc = put_user(set_serial_info, pIndex++ );
-                       rc = put_user(ip2_set_termios, pIndex++ );
-                       rc = put_user(ip2_set_line_discipline, pIndex++ );
-                       rc = put_user(set_params, pIndex++ );
-               } else {
+               /*
+                * akpm: This used to write a whole bunch of function addresses
+                * to userspace, which generated lots of put_user() warnings.
+                * I killed it all.  Just return "success" and don't do
+                * anything.
+                */
+               if (cmd == 1)
+                       rc = 0;
+               else
                        rc = -EINVAL;
-               }
-
                break;
 
        default:
@@ -3064,7 +3042,7 @@ ip2_read_procmem(char *buf, char **start, off_t offset, int len)
  * 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;