diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2006-10-04 05:15:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 10:55:13 -0400 |
commit | b3218a79aa3d58b975b066c300153a8520f7051c (patch) | |
tree | ecdbadacd84a00682bf047c0cdae1194cad3c38c | |
parent | 1d2c8eea698514cfaa53fc991b960791d09508e1 (diff) |
[PATCH] char: kill unneeded memsets
char, another tmp_buf cleanup
No need to allocate one page as a side buffer. It's no more used. Clean this
(de)allocs of this useless memory pages in char subtree.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/char/amiserial.c | 30 | ||||
-rw-r--r-- | drivers/char/cyclades.c | 28 | ||||
-rw-r--r-- | drivers/char/epca.c | 17 | ||||
-rw-r--r-- | drivers/char/epca.h | 1 | ||||
-rw-r--r-- | drivers/char/generic_serial.c | 19 | ||||
-rw-r--r-- | drivers/char/riscom8.c | 10 | ||||
-rw-r--r-- | drivers/char/serial167.c | 20 |
7 files changed, 7 insertions, 118 deletions
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index d0e92ed0a367..486f97c3f4e5 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -112,17 +112,6 @@ static struct serial_state rs_table[1]; | |||
112 | 112 | ||
113 | #define NR_PORTS ARRAY_SIZE(rs_table) | 113 | #define NR_PORTS ARRAY_SIZE(rs_table) |
114 | 114 | ||
115 | /* | ||
116 | * tmp_buf is used as a temporary buffer by serial_write. We need to | ||
117 | * lock it in case the copy_from_user blocks while swapping in a page, | ||
118 | * and some other program tries to do a serial write at the same time. | ||
119 | * Since the lock will only come under contention when the system is | ||
120 | * swapping and available memory is low, it makes sense to share one | ||
121 | * buffer across all the serial ports, since it significantly saves | ||
122 | * memory if large numbers of serial ports are open. | ||
123 | */ | ||
124 | static unsigned char *tmp_buf; | ||
125 | |||
126 | #include <asm/uaccess.h> | 115 | #include <asm/uaccess.h> |
127 | 116 | ||
128 | #define serial_isroot() (capable(CAP_SYS_ADMIN)) | 117 | #define serial_isroot() (capable(CAP_SYS_ADMIN)) |
@@ -912,7 +901,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count | |||
912 | if (serial_paranoia_check(info, tty->name, "rs_write")) | 901 | if (serial_paranoia_check(info, tty->name, "rs_write")) |
913 | return 0; | 902 | return 0; |
914 | 903 | ||
915 | if (!info->xmit.buf || !tmp_buf) | 904 | if (!info->xmit.buf) |
916 | return 0; | 905 | return 0; |
917 | 906 | ||
918 | local_save_flags(flags); | 907 | local_save_flags(flags); |
@@ -1778,7 +1767,6 @@ static int rs_open(struct tty_struct *tty, struct file * filp) | |||
1778 | { | 1767 | { |
1779 | struct async_struct *info; | 1768 | struct async_struct *info; |
1780 | int retval, line; | 1769 | int retval, line; |
1781 | unsigned long page; | ||
1782 | 1770 | ||
1783 | line = tty->index; | 1771 | line = tty->index; |
1784 | if ((line < 0) || (line >= NR_PORTS)) { | 1772 | if ((line < 0) || (line >= NR_PORTS)) { |
@@ -1798,17 +1786,6 @@ static int rs_open(struct tty_struct *tty, struct file * filp) | |||
1798 | #endif | 1786 | #endif |
1799 | info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 1787 | info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
1800 | 1788 | ||
1801 | if (!tmp_buf) { | ||
1802 | page = get_zeroed_page(GFP_KERNEL); | ||
1803 | if (!page) { | ||
1804 | return -ENOMEM; | ||
1805 | } | ||
1806 | if (tmp_buf) | ||
1807 | free_page(page); | ||
1808 | else | ||
1809 | tmp_buf = (unsigned char *) page; | ||
1810 | } | ||
1811 | |||
1812 | /* | 1789 | /* |
1813 | * If the port is the middle of closing, bail out now | 1790 | * If the port is the middle of closing, bail out now |
1814 | */ | 1791 | */ |
@@ -2090,11 +2067,6 @@ static __exit void rs_exit(void) | |||
2090 | kfree(info); | 2067 | kfree(info); |
2091 | } | 2068 | } |
2092 | 2069 | ||
2093 | if (tmp_buf) { | ||
2094 | free_page((unsigned long) tmp_buf); | ||
2095 | tmp_buf = NULL; | ||
2096 | } | ||
2097 | |||
2098 | release_mem_region(CUSTOM_PHYSADDR+0x30, 4); | 2070 | release_mem_region(CUSTOM_PHYSADDR+0x30, 4); |
2099 | } | 2071 | } |
2100 | 2072 | ||
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index f85b4eb16618..87b2fb510871 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -748,18 +748,6 @@ static struct cyclades_port cy_port[NR_PORTS]; | |||
748 | static int cy_next_channel; /* next minor available */ | 748 | static int cy_next_channel; /* next minor available */ |
749 | 749 | ||
750 | /* | 750 | /* |
751 | * tmp_buf is used as a temporary buffer by serial_write. We need to | ||
752 | * lock it in case the copy_from_user blocks while swapping in a page, | ||
753 | * and some other program tries to do a serial write at the same time. | ||
754 | * Since the lock will only come under contention when the system is | ||
755 | * swapping and available memory is low, it makes sense to share one | ||
756 | * buffer across all the serial ports, since it significantly saves | ||
757 | * memory if large numbers of serial ports are open. This buffer is | ||
758 | * allocated when the first cy_open occurs. | ||
759 | */ | ||
760 | static unsigned char *tmp_buf; | ||
761 | |||
762 | /* | ||
763 | * This is used to look up the divisor speeds and the timeouts | 751 | * This is used to look up the divisor speeds and the timeouts |
764 | * We're normally limited to 15 distinct baud rates. The extra | 752 | * We're normally limited to 15 distinct baud rates. The extra |
765 | * are accessed via settings in info->flags. | 753 | * are accessed via settings in info->flags. |
@@ -2466,7 +2454,6 @@ cy_open(struct tty_struct *tty, struct file * filp) | |||
2466 | { | 2454 | { |
2467 | struct cyclades_port *info; | 2455 | struct cyclades_port *info; |
2468 | int retval, line; | 2456 | int retval, line; |
2469 | unsigned long page; | ||
2470 | 2457 | ||
2471 | line = tty->index; | 2458 | line = tty->index; |
2472 | if ((line < 0) || (NR_PORTS <= line)){ | 2459 | if ((line < 0) || (NR_PORTS <= line)){ |
@@ -2545,15 +2532,6 @@ cy_open(struct tty_struct *tty, struct file * filp) | |||
2545 | printk("cyc:cy_open (%d): incrementing count to %d\n", | 2532 | printk("cyc:cy_open (%d): incrementing count to %d\n", |
2546 | current->pid, info->count); | 2533 | current->pid, info->count); |
2547 | #endif | 2534 | #endif |
2548 | if (!tmp_buf) { | ||
2549 | page = get_zeroed_page(GFP_KERNEL); | ||
2550 | if (!page) | ||
2551 | return -ENOMEM; | ||
2552 | if (tmp_buf) | ||
2553 | free_page(page); | ||
2554 | else | ||
2555 | tmp_buf = (unsigned char *) page; | ||
2556 | } | ||
2557 | 2535 | ||
2558 | /* | 2536 | /* |
2559 | * If the port is the middle of closing, bail out now | 2537 | * If the port is the middle of closing, bail out now |
@@ -2832,7 +2810,7 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) | |||
2832 | return 0; | 2810 | return 0; |
2833 | } | 2811 | } |
2834 | 2812 | ||
2835 | if (!info->xmit_buf || !tmp_buf) | 2813 | if (!info->xmit_buf) |
2836 | return 0; | 2814 | return 0; |
2837 | 2815 | ||
2838 | CY_LOCK(info, flags); | 2816 | CY_LOCK(info, flags); |
@@ -5490,10 +5468,6 @@ cy_cleanup_module(void) | |||
5490 | #endif | 5468 | #endif |
5491 | } | 5469 | } |
5492 | } | 5470 | } |
5493 | if (tmp_buf) { | ||
5494 | free_page((unsigned long) tmp_buf); | ||
5495 | tmp_buf = NULL; | ||
5496 | } | ||
5497 | } /* cy_cleanup_module */ | 5471 | } /* cy_cleanup_module */ |
5498 | 5472 | ||
5499 | module_init(cy_init); | 5473 | module_init(cy_init); |
diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 3baa2ab8cbd4..c3f95583a120 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c | |||
@@ -1113,11 +1113,8 @@ static void __exit epca_module_exit(void) | |||
1113 | ch = card_ptr[crd]; | 1113 | ch = card_ptr[crd]; |
1114 | for (count = 0; count < bd->numports; count++, ch++) | 1114 | for (count = 0; count < bd->numports; count++, ch++) |
1115 | { /* Begin for each port */ | 1115 | { /* Begin for each port */ |
1116 | if (ch) { | 1116 | if (ch && ch->tty) |
1117 | if (ch->tty) | 1117 | tty_hangup(ch->tty); |
1118 | tty_hangup(ch->tty); | ||
1119 | kfree(ch->tmp_buf); | ||
1120 | } | ||
1121 | } /* End for each port */ | 1118 | } /* End for each port */ |
1122 | } /* End for each card */ | 1119 | } /* End for each card */ |
1123 | pci_unregister_driver (&epca_driver); | 1120 | pci_unregister_driver (&epca_driver); |
@@ -1635,16 +1632,6 @@ static void post_fep_init(unsigned int crd) | |||
1635 | init_waitqueue_head(&ch->close_wait); | 1632 | init_waitqueue_head(&ch->close_wait); |
1636 | 1633 | ||
1637 | spin_unlock_irqrestore(&epca_lock, flags); | 1634 | spin_unlock_irqrestore(&epca_lock, flags); |
1638 | |||
1639 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); | ||
1640 | if (!ch->tmp_buf) { | ||
1641 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); | ||
1642 | release_region((int)bd->port, 4); | ||
1643 | while(i-- > 0) | ||
1644 | kfree((ch--)->tmp_buf); | ||
1645 | return; | ||
1646 | } else | ||
1647 | memset((void *)ch->tmp_buf,0,ch->txbufsize); | ||
1648 | } /* End for each port */ | 1635 | } /* End for each port */ |
1649 | 1636 | ||
1650 | printk(KERN_INFO | 1637 | printk(KERN_INFO |
diff --git a/drivers/char/epca.h b/drivers/char/epca.h index 456d6c8f94a8..a297238cd3ba 100644 --- a/drivers/char/epca.h +++ b/drivers/char/epca.h | |||
@@ -130,7 +130,6 @@ struct channel | |||
130 | unsigned long c_oflag; | 130 | unsigned long c_oflag; |
131 | unsigned char __iomem *txptr; | 131 | unsigned char __iomem *txptr; |
132 | unsigned char __iomem *rxptr; | 132 | unsigned char __iomem *rxptr; |
133 | unsigned char *tmp_buf; | ||
134 | struct board_info *board; | 133 | struct board_info *board; |
135 | struct board_chan __iomem *brdchan; | 134 | struct board_chan __iomem *brdchan; |
136 | struct digi_struct digiext; | 135 | struct digi_struct digiext; |
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c index 4711d9b3a595..87127e49c0db 100644 --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c | |||
@@ -33,8 +33,6 @@ | |||
33 | 33 | ||
34 | #define DEBUG | 34 | #define DEBUG |
35 | 35 | ||
36 | static char * tmp_buf; | ||
37 | |||
38 | static int gs_debug; | 36 | static int gs_debug; |
39 | 37 | ||
40 | #ifdef DEBUG | 38 | #ifdef DEBUG |
@@ -205,7 +203,7 @@ int gs_write(struct tty_struct * tty, | |||
205 | if (!tty) return -EIO; | 203 | if (!tty) return -EIO; |
206 | 204 | ||
207 | port = tty->driver_data; | 205 | port = tty->driver_data; |
208 | if (!port || !port->xmit_buf || !tmp_buf) | 206 | if (!port || !port->xmit_buf) |
209 | return -EIO; | 207 | return -EIO; |
210 | 208 | ||
211 | local_save_flags(flags); | 209 | local_save_flags(flags); |
@@ -837,24 +835,9 @@ void gs_set_termios (struct tty_struct * tty, | |||
837 | int gs_init_port(struct gs_port *port) | 835 | int gs_init_port(struct gs_port *port) |
838 | { | 836 | { |
839 | unsigned long flags; | 837 | unsigned long flags; |
840 | unsigned long page; | ||
841 | 838 | ||
842 | func_enter (); | 839 | func_enter (); |
843 | 840 | ||
844 | if (!tmp_buf) { | ||
845 | page = get_zeroed_page(GFP_KERNEL); | ||
846 | spin_lock_irqsave (&port->driver_lock, flags); /* Don't expect this to make a difference. */ | ||
847 | if (tmp_buf) | ||
848 | free_page(page); | ||
849 | else | ||
850 | tmp_buf = (unsigned char *) page; | ||
851 | spin_unlock_irqrestore (&port->driver_lock, flags); | ||
852 | if (!tmp_buf) { | ||
853 | func_exit (); | ||
854 | return -ENOMEM; | ||
855 | } | ||
856 | } | ||
857 | |||
858 | if (port->flags & ASYNC_INITIALIZED) { | 841 | if (port->flags & ASYNC_INITIALIZED) { |
859 | func_exit (); | 842 | func_exit (); |
860 | return 0; | 843 | return 0; |
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index 214d850112fd..b0ab3f28cc6a 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c | |||
@@ -81,7 +81,6 @@ | |||
81 | 81 | ||
82 | static struct riscom_board * IRQ_to_board[16]; | 82 | static struct riscom_board * IRQ_to_board[16]; |
83 | static struct tty_driver *riscom_driver; | 83 | static struct tty_driver *riscom_driver; |
84 | static unsigned char * tmp_buf; | ||
85 | 84 | ||
86 | static unsigned long baud_table[] = { | 85 | static unsigned long baud_table[] = { |
87 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, | 86 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, |
@@ -1124,7 +1123,7 @@ static int rc_write(struct tty_struct * tty, | |||
1124 | 1123 | ||
1125 | bp = port_Board(port); | 1124 | bp = port_Board(port); |
1126 | 1125 | ||
1127 | if (!tty || !port->xmit_buf || !tmp_buf) | 1126 | if (!tty || !port->xmit_buf) |
1128 | return 0; | 1127 | return 0; |
1129 | 1128 | ||
1130 | save_flags(flags); | 1129 | save_flags(flags); |
@@ -1612,11 +1611,6 @@ static inline int rc_init_drivers(void) | |||
1612 | if (!riscom_driver) | 1611 | if (!riscom_driver) |
1613 | return -ENOMEM; | 1612 | return -ENOMEM; |
1614 | 1613 | ||
1615 | if (!(tmp_buf = (unsigned char *) get_zeroed_page(GFP_KERNEL))) { | ||
1616 | printk(KERN_ERR "rc: Couldn't get free page.\n"); | ||
1617 | put_tty_driver(riscom_driver); | ||
1618 | return 1; | ||
1619 | } | ||
1620 | memset(IRQ_to_board, 0, sizeof(IRQ_to_board)); | 1614 | memset(IRQ_to_board, 0, sizeof(IRQ_to_board)); |
1621 | riscom_driver->owner = THIS_MODULE; | 1615 | riscom_driver->owner = THIS_MODULE; |
1622 | riscom_driver->name = "ttyL"; | 1616 | riscom_driver->name = "ttyL"; |
@@ -1629,7 +1623,6 @@ static inline int rc_init_drivers(void) | |||
1629 | riscom_driver->flags = TTY_DRIVER_REAL_RAW; | 1623 | riscom_driver->flags = TTY_DRIVER_REAL_RAW; |
1630 | tty_set_operations(riscom_driver, &riscom_ops); | 1624 | tty_set_operations(riscom_driver, &riscom_ops); |
1631 | if ((error = tty_register_driver(riscom_driver))) { | 1625 | if ((error = tty_register_driver(riscom_driver))) { |
1632 | free_page((unsigned long)tmp_buf); | ||
1633 | put_tty_driver(riscom_driver); | 1626 | put_tty_driver(riscom_driver); |
1634 | printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, " | 1627 | printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, " |
1635 | "error = %d\n", | 1628 | "error = %d\n", |
@@ -1657,7 +1650,6 @@ static void rc_release_drivers(void) | |||
1657 | 1650 | ||
1658 | save_flags(flags); | 1651 | save_flags(flags); |
1659 | cli(); | 1652 | cli(); |
1660 | free_page((unsigned long)tmp_buf); | ||
1661 | tty_unregister_driver(riscom_driver); | 1653 | tty_unregister_driver(riscom_driver); |
1662 | put_tty_driver(riscom_driver); | 1654 | put_tty_driver(riscom_driver); |
1663 | restore_flags(flags); | 1655 | restore_flags(flags); |
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index b4ea1266b663..48dae5d68dac 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c | |||
@@ -119,17 +119,6 @@ struct cyclades_port cy_port[] = { | |||
119 | #define NR_PORTS ARRAY_SIZE(cy_port) | 119 | #define NR_PORTS ARRAY_SIZE(cy_port) |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * tmp_buf is used as a temporary buffer by serial_write. We need to | ||
123 | * lock it in case the copy_from_user blocks while swapping in a page, | ||
124 | * and some other program tries to do a serial write at the same time. | ||
125 | * Since the lock will only come under contention when the system is | ||
126 | * swapping and available memory is low, it makes sense to share one | ||
127 | * buffer across all the serial ports, since it significantly saves | ||
128 | * memory if large numbers of serial ports are open. | ||
129 | */ | ||
130 | static unsigned char *tmp_buf = 0; | ||
131 | |||
132 | /* | ||
133 | * This is used to look up the divisor speeds and the timeouts | 122 | * This is used to look up the divisor speeds and the timeouts |
134 | * We're normally limited to 15 distinct baud rates. The extra | 123 | * We're normally limited to 15 distinct baud rates. The extra |
135 | * are accessed via settings in info->flags. | 124 | * are accessed via settings in info->flags. |
@@ -1198,7 +1187,7 @@ cy_write(struct tty_struct * tty, | |||
1198 | return 0; | 1187 | return 0; |
1199 | } | 1188 | } |
1200 | 1189 | ||
1201 | if (!tty || !info->xmit_buf || !tmp_buf){ | 1190 | if (!tty || !info->xmit_buf){ |
1202 | return 0; | 1191 | return 0; |
1203 | } | 1192 | } |
1204 | 1193 | ||
@@ -1983,13 +1972,6 @@ cy_open(struct tty_struct *tty, struct file * filp) | |||
1983 | tty->driver_data = info; | 1972 | tty->driver_data = info; |
1984 | info->tty = tty; | 1973 | info->tty = tty; |
1985 | 1974 | ||
1986 | if (!tmp_buf) { | ||
1987 | tmp_buf = (unsigned char *) get_zeroed_page(GFP_KERNEL); | ||
1988 | if (!tmp_buf){ | ||
1989 | return -ENOMEM; | ||
1990 | } | ||
1991 | } | ||
1992 | |||
1993 | /* | 1975 | /* |
1994 | * Start up serial port | 1976 | * Start up serial port |
1995 | */ | 1977 | */ |