[PATCH] specialix.c: get rid of verify_area and 2.0 compat

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Sat Aug 26 2000 - 17:53:10 EST


Rogier,

        Please take a look and consider applying.

                        - Arnaldo

--- linux-2.4.0-test7/drivers/char/specialix.c Wed Jul 5 14:56:13 2000
+++ linux-2.4.0-test7.acme/drivers/char/specialix.c Sat Aug 26 19:51:46 2000
@@ -63,10 +63,13 @@
  * Revision 1.10: Oct 22 1999 / Jan 21 2000.
  * Added stuff for setserial.
  * Nicolas Mailhot (Nicolas.Mailhot@email.enst.fr)
+ * Revision 1.11: Aug/2000
+ * get rid of verify_area and 2.0 compat
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
  */
 
-#define VERSION "1.10"
+#define VERSION "1.11"
 
 
 /*
@@ -95,35 +98,6 @@
 #include <linux/pci.h>
 
 
-/* ************************************************************** */
-/* * This section can be removed when 2.0 becomes outdated.... * */
-/* ************************************************************** */
-
-#if LINUX_VERSION_CODE < 131328 /* Less than 2.1.0 */
-#define TWO_ZERO
-#else
-#if LINUX_VERSION_CODE < 131371 /* less than 2.1.43 */
-/* This has not been extensively tested yet. Sorry. */
-#warning "You're on your own between 2.1.0 and 2.1.43.... "
-#warning "Please use a recent kernel."
-#endif
-#endif
-
-
-#ifdef TWO_ZERO
-#define Get_user(a,b) a = get_user(b)
-#define copy_from_user(a,b,c) memcpy_fromfs(a,b,c)
-#define copy_to_user(a,b,c) memcpy_tofs(a,b,c)
-#define queue_task queue_task_irq_off
-#else
-#define Get_user(a,b) get_user(a,b)
-#endif
-
-/* ************************************************************** */
-/* * End of compatibility section.. * */
-/* ************************************************************** */
-
-
 #ifndef TWO_ZERO
 #include <asm/uaccess.h>
 #endif
@@ -1770,24 +1744,19 @@
                           |/* ((status & MSVR_DSR) ? */ TIOCM_DSR /* : 0) */
                           | ((status & MSVR_CTS) ? TIOCM_CTS : 0);
         }
- put_user(result,(unsigned int *) value);
- return 0;
+ return put_user(result,(unsigned int *) value);
 }
 
 
 static int sx_set_modem_info(struct specialix_port * port, unsigned int cmd,
                              unsigned int *value)
 {
- int error;
         unsigned int arg;
         unsigned long flags;
         struct specialix_board *bp = port_Board(port);
 
- error = verify_area(VERIFY_READ, value, sizeof(int));
- if (error)
- return error;
-
- Get_user(arg, (unsigned long *) value);
+ if (get_user(arg, (unsigned long *) value))
+ return -EFAULT;
         switch (cmd) {
         case TIOCMBIS:
            /* if (arg & TIOCM_RTS)
@@ -1868,12 +1837,7 @@
         struct specialix_board *bp = port_Board(port);
         int change_speed;
         unsigned long flags;
- int error;
         
- error = verify_area(VERIFY_READ, (void *) newinfo, sizeof(tmp));
- if (error)
- return error;
-
         if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
                 return -EFAULT;
         
@@ -1922,12 +1886,7 @@
 {
         struct serial_struct tmp;
         struct specialix_board *bp = port_Board(port);
- int error;
         
- error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp));
- if (error)
- return error;
-
         memset(&tmp, 0, sizeof(tmp));
         tmp.type = PORT_CIRRUS;
         tmp.line = port - sx_port;
@@ -1939,9 +1898,7 @@
         tmp.closing_wait = port->closing_wait * HZ/100;
         tmp.custom_divisor = port->custom_divisor;
         tmp.xmit_fifo_size = CD186x_NFIFO;
- if (copy_to_user(retinfo, &tmp, sizeof(tmp)))
- return -EFAULT;
- return 0;
+ return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
 }
 
 
@@ -1949,7 +1906,6 @@
                     unsigned int cmd, unsigned long arg)
 {
         struct specialix_port *port = (struct specialix_port *)tty->driver_data;
- int error;
         int retval;
                                 
         if (sx_paranoia_check(port, tty->device, "sx_ioctl"))
@@ -1972,23 +1928,15 @@
                 sx_send_break(port, arg ? arg*(HZ/10) : HZ/4);
                 return 0;
          case TIOCGSOFTCAR:
- error = verify_area(VERIFY_WRITE, (void *) arg, sizeof(long));
- if (error)
- return error;
- put_user(C_CLOCAL(tty) ? 1 : 0,
- (unsigned long *) arg);
- return 0;
+ return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
          case TIOCSSOFTCAR:
- Get_user(arg, (unsigned long *) arg);
+ if (get_user(arg, (unsigned long *) arg))
+ return -EFAULT;
                 tty->termios->c_cflag =
                         ((tty->termios->c_cflag & ~CLOCAL) |
                         (arg ? CLOCAL : 0));
                 return 0;
          case TIOCMGET:
- error = verify_area(VERIFY_WRITE, (void *) arg,
- sizeof(unsigned int));
- if (error)
- return error;
                 return sx_get_modem_info(port, (unsigned int *) arg);
          case TIOCMBIS:
          case TIOCMBIC:
@@ -2245,17 +2193,14 @@
         specialix_callout_driver.subtype = SPECIALIX_TYPE_CALLOUT;
         
         if ((error = tty_register_driver(&specialix_driver))) {
- free_page((unsigned long)tmp_buf);
                 printk(KERN_ERR "sx: Couldn't register specialix IO8+ driver, error = %d\n",
                        error);
- return 1;
+ goto cleanup_tmp_buf;
         }
         if ((error = tty_register_driver(&specialix_callout_driver))) {
- free_page((unsigned long)tmp_buf);
- tty_unregister_driver(&specialix_driver);
                 printk(KERN_ERR "sx: Couldn't register specialix IO8+ callout driver, error = %d\n",
                        error);
- return 1;
+ goto cleanup_tty_driver;
         }
         
         memset(sx_port, 0, sizeof(sx_port));
@@ -2274,14 +2219,22 @@
         }
         
         return 0;
+cleanup_tty_driver:
+ if (tty_unregister_driver(&specialix_driver))
+ printk(KERN_ERR "specialix: unable to unregister serial driver\n");
+cleanup_tmp_buf:
+ free_page((unsigned long)tmp_buf);
+ return 1;
 }
 
 
 static void sx_release_drivers(void)
 {
         free_page((unsigned long)tmp_buf);
- tty_unregister_driver(&specialix_driver);
- tty_unregister_driver(&specialix_callout_driver);
+ if (tty_unregister_driver(&specialix_driver))
+ printk(KERN_ERR "specialix: unable to unregister serial driver\n");
+ if (tty_unregister_driver(&specialix_callout_driver))
+ printk(KERN_ERR "specialix: unable to unregister callout driver\n");
 }
 
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:18 EST