aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/atm/eni.c1
-rw-r--r--drivers/auxdisplay/Kconfig109
-rw-r--r--drivers/auxdisplay/Makefile6
-rw-r--r--drivers/auxdisplay/cfag12864b.c383
-rw-r--r--drivers/auxdisplay/cfag12864bfb.c180
-rw-r--r--drivers/auxdisplay/ks0108.c166
-rw-r--r--drivers/base/node.c9
-rw-r--r--drivers/block/DAC960.c72
-rw-r--r--drivers/block/DAC960.h495
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/paride/Kconfig8
-rw-r--r--drivers/block/pktcdvd.c26
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/amiserial.c8
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/epca.c3
-rw-r--r--drivers/char/generic_serial.c1
-rw-r--r--drivers/char/ip2/i2lib.c10
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c30
-rw-r--r--drivers/char/isicom.c108
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/keyboard.c12
-rw-r--r--drivers/char/moxa.c927
-rw-r--r--drivers/char/mxser.c11
-rw-r--r--drivers/char/mxser.h8
-rw-r--r--drivers/char/mxser_new.c236
-rw-r--r--drivers/char/mxser_new.h477
-rw-r--r--drivers/char/n_r3964.c2097
-rw-r--r--drivers/char/pcmcia/synclink_cs.c4
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/char/rio/riointr.c9
-rw-r--r--drivers/char/riscom8.c5
-rw-r--r--drivers/char/rocket.c3
-rw-r--r--drivers/char/serial167.c3322
-rw-r--r--drivers/char/specialix.c4
-rw-r--r--drivers/char/synclink.c5
-rw-r--r--drivers/char/synclink_gt.c5
-rw-r--r--drivers/char/synclinkmp.c5
-rw-r--r--drivers/char/sysrq.c6
-rw-r--r--drivers/char/toshiba.c35
-rw-r--r--drivers/char/tty_io.c87
-rw-r--r--drivers/char/tty_ioctl.c45
-rw-r--r--drivers/char/vt.c3
-rw-r--r--drivers/char/vt_ioctl.c28
-rw-r--r--drivers/firmware/edd.c8
-rw-r--r--drivers/ide/ide-proc.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c3
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c6
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c3
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c3
-rw-r--r--drivers/input/gameport/ns558.c1
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c4
-rw-r--r--drivers/isdn/gigaset/interface.c14
-rw-r--r--drivers/isdn/i4l/isdn_tty.c1
-rw-r--r--drivers/macintosh/via-pmu.c1
-rw-r--r--drivers/md/bitmap.c2
-rw-r--r--drivers/media/video/zoran_driver.c1
-rw-r--r--drivers/misc/hdpuftrs/hdpu_nexus.c2
-rw-r--r--drivers/misc/ioc4.c6
-rw-r--r--drivers/mtd/devices/block2mtd.c3
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/parisc/led.c2
-rw-r--r--drivers/pnp/base.h1
-rw-r--r--drivers/pnp/pnpbios/rsparser.c1
-rw-r--r--drivers/rapidio/rio-scan.c118
-rw-r--r--drivers/rtc/Kconfig25
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-cmos.c725
-rw-r--r--drivers/s390/crypto/zcrypt_api.c1
-rw-r--r--drivers/s390/net/lcs.c6
-rw-r--r--drivers/scsi/53c7xx.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c3
-rw-r--r--drivers/scsi/scsi_lib.c3
-rw-r--r--drivers/serial/8250.c8
-rw-r--r--drivers/serial/8250_pci.c27
-rw-r--r--drivers/serial/Kconfig5
-rw-r--r--drivers/serial/crisv10.c14
-rw-r--r--drivers/serial/ioc4_serial.c6
-rw-r--r--drivers/serial/serial_txx9.c23
-rw-r--r--drivers/sn/ioc3.c6
-rw-r--r--drivers/tc/zs.c4
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/rndis.c1
-rw-r--r--drivers/usb/host/hc_crisv10.c3
-rw-r--r--drivers/usb/host/uhci-q.c4
-rw-r--r--drivers/usb/serial/digi_acceleport.c10
-rw-r--r--drivers/usb/serial/keyspan_pda.c7
-rw-r--r--drivers/usb/serial/mos7720.c14
-rw-r--r--drivers/usb/serial/mos7840.c14
-rw-r--r--drivers/video/sa1100fb.h4
92 files changed, 5512 insertions, 4552 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index e7da9fa724ec..050323fd79e9 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -80,6 +80,8 @@ source "drivers/rtc/Kconfig"
80 80
81source "drivers/dma/Kconfig" 81source "drivers/dma/Kconfig"
82 82
83source "drivers/auxdisplay/Kconfig"
84
83source "drivers/kvm/Kconfig" 85source "drivers/kvm/Kconfig"
84 86
85endmenu 87endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index f28dcb4ec8b3..3a718f51350e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_ATA) += ata/
38obj-$(CONFIG_FUSION) += message/ 38obj-$(CONFIG_FUSION) += message/
39obj-$(CONFIG_IEEE1394) += ieee1394/ 39obj-$(CONFIG_IEEE1394) += ieee1394/
40obj-y += cdrom/ 40obj-y += cdrom/
41obj-y += auxdisplay/
41obj-$(CONFIG_MTD) += mtd/ 42obj-$(CONFIG_MTD) += mtd/
42obj-$(CONFIG_SPI) += spi/ 43obj-$(CONFIG_SPI) += spi/
43obj-$(CONFIG_PCCARD) += pcmcia/ 44obj-$(CONFIG_PCCARD) += pcmcia/
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 5aab7bd473ac..8fccf018f165 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -912,7 +912,6 @@ static int start_rx(struct atm_dev *dev)
912 free_page((unsigned long) eni_dev->free_list); 912 free_page((unsigned long) eni_dev->free_list);
913 return -ENOMEM; 913 return -ENOMEM;
914 } 914 }
915 memset(eni_dev->rx_map,0,PAGE_SIZE);
916 eni_dev->rx_mult = DEFAULT_RX_MULT; 915 eni_dev->rx_mult = DEFAULT_RX_MULT;
917 eni_dev->fast = eni_dev->last_fast = NULL; 916 eni_dev->fast = eni_dev->last_fast = NULL;
918 eni_dev->slow = eni_dev->last_slow = NULL; 917 eni_dev->slow = eni_dev->last_slow = NULL;
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
new file mode 100644
index 000000000000..0300e7f54cc4
--- /dev/null
+++ b/drivers/auxdisplay/Kconfig
@@ -0,0 +1,109 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5# Auxiliary display drivers configuration.
6#
7
8menu "Auxiliary Display support"
9
10config KS0108
11 tristate "KS0108 LCD Controller"
12 depends on PARPORT_PC
13 default n
14 ---help---
15 If you have a LCD controlled by one or more KS0108
16 controllers, say Y. You will need also another more specific
17 driver for your LCD.
18
19 Depends on Parallel Port support. If you say Y at
20 parport, you will be able to compile this as a module (M)
21 and built-in as well (Y).
22
23 To compile this as a module, choose M here:
24 the module will be called ks0108.
25
26 If unsure, say N.
27
28config KS0108_PORT
29 hex "Parallel port where the LCD is connected"
30 depends on KS0108
31 default 0x378
32 ---help---
33 The address of the parallel port where the LCD is connected.
34
35 The first standard parallel port address is 0x378.
36 The second standard parallel port address is 0x278.
37 The third standard parallel port address is 0x3BC.
38
39 You can specify a different address if you need.
40
41 If you don't know what I'm talking about, load the parport module,
42 and execute "dmesg" or "cat /proc/ioports". You can see there how
43 many parallel ports are present and which address each one has.
44
45 Usually you only need to use 0x378.
46
47 If you compile this as a module, you can still override this
48 using the module parameters.
49
50config KS0108_DELAY
51 int "Delay between each control writing (microseconds)"
52 depends on KS0108
53 default "2"
54 ---help---
55 Amount of time the ks0108 should wait between each control write
56 to the parallel port.
57
58 If your driver seems to miss random writings, increment this.
59
60 If you don't know what I'm talking about, ignore it.
61
62 If you compile this as a module, you can still override this
63 value using the module parameters.
64
65config CFAG12864B
66 tristate "CFAG12864B LCD"
67 depends on X86
68 depends on FB
69 depends on KS0108
70 default n
71 ---help---
72 If you have a Crystalfontz 128x64 2-color LCD, cfag12864b Series,
73 say Y. You also need the ks0108 LCD Controller driver.
74
75 For help about how to wire your LCD to the parallel port,
76 check Documentation/auxdisplay/cfag12864b
77
78 Depends on the x86 arch and the framebuffer support.
79
80 The LCD framebuffer driver can be attached to a console.
81 It will work fine. However, you can't attach it to the fbdev driver
82 of the xorg server.
83
84 To compile this as a module, choose M here:
85 the modules will be called cfag12864b and cfag12864bfb.
86
87 If unsure, say N.
88
89config CFAG12864B_RATE
90 int "Refresh rate (hertz)"
91 depends on CFAG12864B
92 default "20"
93 ---help---
94 Refresh rate of the LCD.
95
96 As the LCD is not memory mapped, the driver has to make the work by
97 software. This means you should be careful setting this value higher.
98 If your CPUs are really slow or you feel the system is slowed down,
99 decrease the value.
100
101 Be careful modifying this value to a very high value:
102 You can freeze the computer, or the LCD maybe can't draw as fast as you
103 are requesting.
104
105 If you don't know what I'm talking about, ignore it.
106
107 If you compile this as a module, you can still override this
108 value using the module parameters.
109endmenu
diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile
new file mode 100644
index 000000000000..8a8936a468b9
--- /dev/null
+++ b/drivers/auxdisplay/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the kernel auxiliary displays device drivers.
3#
4
5obj-$(CONFIG_KS0108) += ks0108.o
6obj-$(CONFIG_CFAG12864B) += cfag12864b.o cfag12864bfb.o
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
new file mode 100644
index 000000000000..889583dfc1a6
--- /dev/null
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -0,0 +1,383 @@
1/*
2 * Filename: cfag12864b.c
3 * Version: 0.1.0
4 * Description: cfag12864b LCD driver
5 * License: GPLv2
6 * Depends: ks0108
7 *
8 * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
9 * Date: 2006-10-31
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/fs.h>
30#include <linux/cdev.h>
31#include <linux/delay.h>
32#include <linux/device.h>
33#include <linux/jiffies.h>
34#include <linux/mutex.h>
35#include <linux/uaccess.h>
36#include <linux/vmalloc.h>
37#include <linux/workqueue.h>
38#include <linux/ks0108.h>
39#include <linux/cfag12864b.h>
40
41
42#define CFAG12864B_NAME "cfag12864b"
43
44/*
45 * Module Parameters
46 */
47
48static unsigned int cfag12864b_rate = CONFIG_CFAG12864B_RATE;
49module_param(cfag12864b_rate, uint, S_IRUGO);
50MODULE_PARM_DESC(cfag12864b_rate,
51 "Refresh rate (hertzs)");
52
53unsigned int cfag12864b_getrate(void)
54{
55 return cfag12864b_rate;
56}
57
58/*
59 * cfag12864b Commands
60 *
61 * E = Enable signal
62 * Everytime E switch from low to high,
63 * cfag12864b/ks0108 reads the command/data.
64 *
65 * CS1 = First ks0108controller.
66 * If high, the first ks0108 controller receives commands/data.
67 *
68 * CS2 = Second ks0108 controller
69 * If high, the second ks0108 controller receives commands/data.
70 *
71 * DI = Data/Instruction
72 * If low, cfag12864b will expect commands.
73 * If high, cfag12864b will expect data.
74 *
75 */
76
77#define bit(n) (((unsigned char)1)<<(n))
78
79#define CFAG12864B_BIT_E (0)
80#define CFAG12864B_BIT_CS1 (2)
81#define CFAG12864B_BIT_CS2 (1)
82#define CFAG12864B_BIT_DI (3)
83
84static unsigned char cfag12864b_state;
85
86static void cfag12864b_set(void)
87{
88 ks0108_writecontrol(cfag12864b_state);
89}
90
91static void cfag12864b_setbit(unsigned char state, unsigned char n)
92{
93 if (state)
94 cfag12864b_state |= bit(n);
95 else
96 cfag12864b_state &= ~bit(n);
97}
98
99static void cfag12864b_e(unsigned char state)
100{
101 cfag12864b_setbit(state, CFAG12864B_BIT_E);
102 cfag12864b_set();
103}
104
105static void cfag12864b_cs1(unsigned char state)
106{
107 cfag12864b_setbit(state, CFAG12864B_BIT_CS1);
108}
109
110static void cfag12864b_cs2(unsigned char state)
111{
112 cfag12864b_setbit(state, CFAG12864B_BIT_CS2);
113}
114
115static void cfag12864b_di(unsigned char state)
116{
117 cfag12864b_setbit(state, CFAG12864B_BIT_DI);
118}
119
120static void cfag12864b_setcontrollers(unsigned char first,
121 unsigned char second)
122{
123 if (first)
124 cfag12864b_cs1(0);
125 else
126 cfag12864b_cs1(1);
127
128 if (second)
129 cfag12864b_cs2(0);
130 else
131 cfag12864b_cs2(1);
132}
133
134static void cfag12864b_controller(unsigned char which)
135{
136 if (which == 0)
137 cfag12864b_setcontrollers(1, 0);
138 else if (which == 1)
139 cfag12864b_setcontrollers(0, 1);
140}
141
142static void cfag12864b_displaystate(unsigned char state)
143{
144 cfag12864b_di(0);
145 cfag12864b_e(1);
146 ks0108_displaystate(state);
147 cfag12864b_e(0);
148}
149
150static void cfag12864b_address(unsigned char address)
151{
152 cfag12864b_di(0);
153 cfag12864b_e(1);
154 ks0108_address(address);
155 cfag12864b_e(0);
156}
157
158static void cfag12864b_page(unsigned char page)
159{
160 cfag12864b_di(0);
161 cfag12864b_e(1);
162 ks0108_page(page);
163 cfag12864b_e(0);
164}
165
166static void cfag12864b_startline(unsigned char startline)
167{
168 cfag12864b_di(0);
169 cfag12864b_e(1);
170 ks0108_startline(startline);
171 cfag12864b_e(0);
172}
173
174static void cfag12864b_writebyte(unsigned char byte)
175{
176 cfag12864b_di(1);
177 cfag12864b_e(1);
178 ks0108_writedata(byte);
179 cfag12864b_e(0);
180}
181
182static void cfag12864b_nop(void)
183{
184 cfag12864b_startline(0);
185}
186
187/*
188 * cfag12864b Internal Commands
189 */
190
191static void cfag12864b_on(void)
192{
193 cfag12864b_setcontrollers(1, 1);
194 cfag12864b_displaystate(1);
195}
196
197static void cfag12864b_off(void)
198{
199 cfag12864b_setcontrollers(1, 1);
200 cfag12864b_displaystate(0);
201}
202
203static void cfag12864b_clear(void)
204{
205 unsigned char i, j;
206
207 cfag12864b_setcontrollers(1, 1);
208 for (i = 0; i < CFAG12864B_PAGES; i++) {
209 cfag12864b_page(i);
210 cfag12864b_address(0);
211 for (j = 0; j < CFAG12864B_ADDRESSES; j++)
212 cfag12864b_writebyte(0);
213 }
214}
215
216/*
217 * Update work
218 */
219
220unsigned char *cfag12864b_buffer;
221static unsigned char *cfag12864b_cache;
222static DEFINE_MUTEX(cfag12864b_mutex);
223static unsigned char cfag12864b_updating;
224static void cfag12864b_update(struct work_struct *delayed_work);
225static struct workqueue_struct *cfag12864b_workqueue;
226static DECLARE_DELAYED_WORK(cfag12864b_work, cfag12864b_update);
227
228static void cfag12864b_queue(void)
229{
230 queue_delayed_work(cfag12864b_workqueue, &cfag12864b_work,
231 HZ / cfag12864b_rate);
232}
233
234unsigned char cfag12864b_enable(void)
235{
236 unsigned char ret;
237
238 mutex_lock(&cfag12864b_mutex);
239
240 if (!cfag12864b_updating) {
241 cfag12864b_updating = 1;
242 cfag12864b_queue();
243 ret = 0;
244 } else
245 ret = 1;
246
247 mutex_unlock(&cfag12864b_mutex);
248
249 return ret;
250}
251
252void cfag12864b_disable(void)
253{
254 mutex_lock(&cfag12864b_mutex);
255
256 if (cfag12864b_updating) {
257 cfag12864b_updating = 0;
258 cancel_delayed_work(&cfag12864b_work);
259 flush_workqueue(cfag12864b_workqueue);
260 }
261
262 mutex_unlock(&cfag12864b_mutex);
263}
264
265unsigned char cfag12864b_isenabled(void)
266{
267 return cfag12864b_updating;
268}
269
270static void cfag12864b_update(struct work_struct *work)
271{
272 unsigned char c;
273 unsigned short i, j, k, b;
274
275 if (memcmp(cfag12864b_cache, cfag12864b_buffer, CFAG12864B_SIZE)) {
276 for (i = 0; i < CFAG12864B_CONTROLLERS; i++) {
277 cfag12864b_controller(i);
278 cfag12864b_nop();
279 for (j = 0; j < CFAG12864B_PAGES; j++) {
280 cfag12864b_page(j);
281 cfag12864b_nop();
282 cfag12864b_address(0);
283 cfag12864b_nop();
284 for (k = 0; k < CFAG12864B_ADDRESSES; k++) {
285 for (c = 0, b = 0; b < 8; b++)
286 if (cfag12864b_buffer
287 [i * CFAG12864B_ADDRESSES / 8
288 + k / 8 + (j * 8 + b) *
289 CFAG12864B_WIDTH / 8]
290 & bit(k % 8))
291 c |= bit(b);
292 cfag12864b_writebyte(c);
293 }
294 }
295 }
296
297 memcpy(cfag12864b_cache, cfag12864b_buffer, CFAG12864B_SIZE);
298 }
299
300 if (cfag12864b_updating)
301 cfag12864b_queue();
302}
303
304/*
305 * cfag12864b Exported Symbols
306 */
307
308EXPORT_SYMBOL_GPL(cfag12864b_buffer);
309EXPORT_SYMBOL_GPL(cfag12864b_getrate);
310EXPORT_SYMBOL_GPL(cfag12864b_enable);
311EXPORT_SYMBOL_GPL(cfag12864b_disable);
312EXPORT_SYMBOL_GPL(cfag12864b_isenabled);
313
314/*
315 * Module Init & Exit
316 */
317
318static int __init cfag12864b_init(void)
319{
320 int ret = -EINVAL;
321
322 if (PAGE_SIZE < CFAG12864B_SIZE) {
323 printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
324 "page size (%i) < cfag12864b size (%i)\n",
325 (unsigned int)PAGE_SIZE, CFAG12864B_SIZE);
326 ret = -ENOMEM;
327 goto none;
328 }
329
330 cfag12864b_buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
331 if (cfag12864b_buffer == NULL) {
332 printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
333 "can't get a free page\n");
334 ret = -ENOMEM;
335 goto none;
336 }
337
338 cfag12864b_cache = kmalloc(sizeof(unsigned char) *
339 CFAG12864B_SIZE, GFP_KERNEL);
340 if (cfag12864b_buffer == NULL) {
341 printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
342 "can't alloc cache buffer (%i bytes)\n",
343 CFAG12864B_SIZE);
344 ret = -ENOMEM;
345 goto bufferalloced;
346 }
347
348 cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
349 if (cfag12864b_workqueue == NULL)
350 goto cachealloced;
351
352 memset(cfag12864b_buffer, 0, CFAG12864B_SIZE);
353
354 cfag12864b_clear();
355 cfag12864b_on();
356
357 return 0;
358
359cachealloced:
360 kfree(cfag12864b_cache);
361
362bufferalloced:
363 free_page((unsigned long) cfag12864b_buffer);
364
365none:
366 return ret;
367}
368
369static void __exit cfag12864b_exit(void)
370{
371 cfag12864b_disable();
372 cfag12864b_off();
373 destroy_workqueue(cfag12864b_workqueue);
374 kfree(cfag12864b_cache);
375 free_page((unsigned long) cfag12864b_buffer);
376}
377
378module_init(cfag12864b_init);
379module_exit(cfag12864b_exit);
380
381MODULE_LICENSE("GPL v2");
382MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
383MODULE_DESCRIPTION("cfag12864b LCD driver");
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
new file mode 100644
index 000000000000..94765e78315f
--- /dev/null
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -0,0 +1,180 @@
1/*
2 * Filename: cfag12864bfb.c
3 * Version: 0.1.0
4 * Description: cfag12864b LCD framebuffer driver
5 * License: GPLv2
6 * Depends: cfag12864b
7 *
8 * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
9 * Date: 2006-10-31
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/delay.h>
30#include <linux/errno.h>
31#include <linux/fb.h>
32#include <linux/mm.h>
33#include <linux/platform_device.h>
34#include <linux/slab.h>
35#include <linux/string.h>
36#include <linux/uaccess.h>
37#include <linux/cfag12864b.h>
38
39#define CFAG12864BFB_NAME "cfag12864bfb"
40
41static struct fb_fix_screeninfo cfag12864bfb_fix __initdata = {
42 .id = "cfag12864b",
43 .type = FB_TYPE_PACKED_PIXELS,
44 .visual = FB_VISUAL_MONO10,
45 .xpanstep = 0,
46 .ypanstep = 0,
47 .ywrapstep = 0,
48 .line_length = CFAG12864B_WIDTH / 8,
49 .accel = FB_ACCEL_NONE,
50};
51
52static struct fb_var_screeninfo cfag12864bfb_var __initdata = {
53 .xres = CFAG12864B_WIDTH,
54 .yres = CFAG12864B_HEIGHT,
55 .xres_virtual = CFAG12864B_WIDTH,
56 .yres_virtual = CFAG12864B_HEIGHT,
57 .bits_per_pixel = 1,
58 .red = { 0, 1, 0 },
59 .green = { 0, 1, 0 },
60 .blue = { 0, 1, 0 },
61 .left_margin = 0,
62 .right_margin = 0,
63 .upper_margin = 0,
64 .lower_margin = 0,
65 .vmode = FB_VMODE_NONINTERLACED,
66};
67
68static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
69{
70 return vm_insert_page(vma, vma->vm_start,
71 virt_to_page(cfag12864b_buffer));
72}
73
74static struct fb_ops cfag12864bfb_ops = {
75 .owner = THIS_MODULE,
76 .fb_fillrect = cfb_fillrect,
77 .fb_copyarea = cfb_copyarea,
78 .fb_imageblit = cfb_imageblit,
79 .fb_mmap = cfag12864bfb_mmap,
80};
81
82static int __init cfag12864bfb_probe(struct platform_device *device)
83{
84 int ret = -EINVAL;
85 struct fb_info *info = framebuffer_alloc(0, &device->dev);
86
87 if (!info)
88 goto none;
89
90 info->screen_base = (char __iomem *) cfag12864b_buffer;
91 info->screen_size = CFAG12864B_SIZE;
92 info->fbops = &cfag12864bfb_ops;
93 info->fix = cfag12864bfb_fix;
94 info->var = cfag12864bfb_var;
95 info->pseudo_palette = NULL;
96 info->par = NULL;
97 info->flags = FBINFO_FLAG_DEFAULT;
98
99 if (register_framebuffer(info) < 0)
100 goto fballoced;
101
102 platform_set_drvdata(device, info);
103
104 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
105 info->fix.id);
106
107 return 0;
108
109fballoced:
110 framebuffer_release(info);
111
112none:
113 return ret;
114}
115
116static int cfag12864bfb_remove(struct platform_device *device)
117{
118 struct fb_info *info = platform_get_drvdata(device);
119
120 if (info) {
121 unregister_framebuffer(info);
122 framebuffer_release(info);
123 }
124
125 return 0;
126}
127
128static struct platform_driver cfag12864bfb_driver = {
129 .probe = cfag12864bfb_probe,
130 .remove = cfag12864bfb_remove,
131 .driver = {
132 .name = CFAG12864BFB_NAME,
133 },
134};
135
136static struct platform_device *cfag12864bfb_device;
137
138static int __init cfag12864bfb_init(void)
139{
140 int ret;
141
142 if (cfag12864b_enable()) {
143 printk(KERN_ERR CFAG12864BFB_NAME ": ERROR: "
144 "can't enable cfag12864b refreshing (being used)\n");
145 return -ENODEV;
146 }
147
148 ret = platform_driver_register(&cfag12864bfb_driver);
149
150 if (!ret) {
151 cfag12864bfb_device =
152 platform_device_alloc(CFAG12864BFB_NAME, 0);
153
154 if (cfag12864bfb_device)
155 ret = platform_device_add(cfag12864bfb_device);
156 else
157 ret = -ENOMEM;
158
159 if (ret) {
160 platform_device_put(cfag12864bfb_device);
161 platform_driver_unregister(&cfag12864bfb_driver);
162 }
163 }
164
165 return ret;
166}
167
168static void __exit cfag12864bfb_exit(void)
169{
170 platform_device_unregister(cfag12864bfb_device);
171 platform_driver_unregister(&cfag12864bfb_driver);
172 cfag12864b_disable();
173}
174
175module_init(cfag12864bfb_init);
176module_exit(cfag12864bfb_exit);
177
178MODULE_LICENSE("GPL v2");
179MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
180MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver");
diff --git a/drivers/auxdisplay/ks0108.c b/drivers/auxdisplay/ks0108.c
new file mode 100644
index 000000000000..a637575b9106
--- /dev/null
+++ b/drivers/auxdisplay/ks0108.c
@@ -0,0 +1,166 @@
1/*
2 * Filename: ks0108.c
3 * Version: 0.1.0
4 * Description: ks0108 LCD Controller driver
5 * License: GPLv2
6 * Depends: parport
7 *
8 * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
9 * Date: 2006-10-31
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/delay.h>
30#include <linux/fs.h>
31#include <linux/io.h>
32#include <linux/parport.h>
33#include <linux/uaccess.h>
34#include <linux/ks0108.h>
35
36#define KS0108_NAME "ks0108"
37
38/*
39 * Module Parameters
40 */
41
42static unsigned int ks0108_port = CONFIG_KS0108_PORT;
43module_param(ks0108_port, uint, S_IRUGO);
44MODULE_PARM_DESC(ks0108_port, "Parallel port where the LCD is connected");
45
46static unsigned int ks0108_delay = CONFIG_KS0108_DELAY;
47module_param(ks0108_delay, uint, S_IRUGO);
48MODULE_PARM_DESC(ks0108_delay, "Delay between each control writing (microseconds)");
49
50/*
51 * Device
52 */
53
54static struct parport *ks0108_parport;
55static struct pardevice *ks0108_pardevice;
56
57/*
58 * ks0108 Exported Commands (don't lock)
59 *
60 * You _should_ lock in the top driver: This functions _should not_
61 * get race conditions in any way. Locking for each byte here would be
62 * so slow and useless.
63 *
64 * There are not bit definitions because they are not flags,
65 * just arbitrary combinations defined by the documentation for each
66 * function in the ks0108 LCD controller. If you want to know what means
67 * a specific combination, look at the function's name.
68 *
69 * The ks0108_writecontrol bits need to be reverted ^(0,1,3) because
70 * the parallel port also revert them using a "not" logic gate.
71 */
72
73#define bit(n) (((unsigned char)1)<<(n))
74
75void ks0108_writedata(unsigned char byte)
76{
77 parport_write_data(ks0108_parport, byte);
78}
79
80void ks0108_writecontrol(unsigned char byte)
81{
82 udelay(ks0108_delay);
83 parport_write_control(ks0108_parport, byte ^ (bit(0) | bit(1) | bit(3)));
84}
85
86void ks0108_displaystate(unsigned char state)
87{
88 ks0108_writedata((state ? bit(0) : 0) | bit(1) | bit(2) | bit(3) | bit(4) | bit(5));
89}
90
91void ks0108_startline(unsigned char startline)
92{
93 ks0108_writedata(min(startline,(unsigned char)63) | bit(6) | bit(7));
94}
95
96void ks0108_address(unsigned char address)
97{
98 ks0108_writedata(min(address,(unsigned char)63) | bit(6));
99}
100
101void ks0108_page(unsigned char page)
102{
103 ks0108_writedata(min(page,(unsigned char)7) | bit(3) | bit(4) | bit(5) | bit(7));
104}
105
106EXPORT_SYMBOL_GPL(ks0108_writedata);
107EXPORT_SYMBOL_GPL(ks0108_writecontrol);
108EXPORT_SYMBOL_GPL(ks0108_displaystate);
109EXPORT_SYMBOL_GPL(ks0108_startline);
110EXPORT_SYMBOL_GPL(ks0108_address);
111EXPORT_SYMBOL_GPL(ks0108_page);
112
113/*
114 * Module Init & Exit
115 */
116
117static int __init ks0108_init(void)
118{
119 int result;
120 int ret = -EINVAL;
121
122 ks0108_parport = parport_find_base(ks0108_port);
123 if (ks0108_parport == NULL) {
124 printk(KERN_ERR KS0108_NAME ": ERROR: "
125 "parport didn't find %i port\n", ks0108_port);
126 goto none;
127 }
128
129 ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME,
130 NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
131 if (ks0108_pardevice == NULL) {
132 printk(KERN_ERR KS0108_NAME ": ERROR: "
133 "parport didn't register new device\n");
134 goto none;
135 }
136
137 result = parport_claim(ks0108_pardevice);
138 if (result != 0) {
139 printk(KERN_ERR KS0108_NAME ": ERROR: "
140 "can't claim %i parport, maybe in use\n", ks0108_port);
141 ret = result;
142 goto registered;
143 }
144
145 return 0;
146
147registered:
148 parport_unregister_device(ks0108_pardevice);
149
150none:
151 return ret;
152}
153
154static void __exit ks0108_exit(void)
155{
156 parport_release(ks0108_pardevice);
157 parport_unregister_device(ks0108_pardevice);
158}
159
160module_init(ks0108_init);
161module_exit(ks0108_exit);
162
163MODULE_LICENSE("GPL v2");
164MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
165MODULE_DESCRIPTION("ks0108 LCD Controller driver");
166
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 001e6f6b9c1b..475e33f76e0d 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -40,13 +40,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
40 int n; 40 int n;
41 int nid = dev->id; 41 int nid = dev->id;
42 struct sysinfo i; 42 struct sysinfo i;
43 unsigned long inactive;
44 unsigned long active;
45 unsigned long free;
46 43
47 si_meminfo_node(&i, nid); 44 si_meminfo_node(&i, nid);
48 __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
49
50 45
51 n = sprintf(buf, "\n" 46 n = sprintf(buf, "\n"
52 "Node %d MemTotal: %8lu kB\n" 47 "Node %d MemTotal: %8lu kB\n"
@@ -74,8 +69,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
74 nid, K(i.totalram), 69 nid, K(i.totalram),
75 nid, K(i.freeram), 70 nid, K(i.freeram),
76 nid, K(i.totalram - i.freeram), 71 nid, K(i.totalram - i.freeram),
77 nid, K(active), 72 nid, node_page_state(nid, NR_ACTIVE),
78 nid, K(inactive), 73 nid, node_page_state(nid, NR_INACTIVE),
79#ifdef CONFIG_HIGHMEM 74#ifdef CONFIG_HIGHMEM
80 nid, K(i.totalhigh), 75 nid, K(i.totalhigh),
81 nid, K(i.freehigh), 76 nid, K(i.freehigh),
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 8d81a3a64c07..6ad28dfb1469 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -177,7 +177,7 @@ static void DAC960_AnnounceDriver(DAC960_Controller_T *Controller)
177 DAC960_Failure prints a standardized error message, and then returns false. 177 DAC960_Failure prints a standardized error message, and then returns false.
178*/ 178*/
179 179
180static boolean DAC960_Failure(DAC960_Controller_T *Controller, 180static bool DAC960_Failure(DAC960_Controller_T *Controller,
181 unsigned char *ErrorMessage) 181 unsigned char *ErrorMessage)
182{ 182{
183 DAC960_Error("While configuring DAC960 PCI RAID Controller at\n", 183 DAC960_Error("While configuring DAC960 PCI RAID Controller at\n",
@@ -206,7 +206,7 @@ static boolean DAC960_Failure(DAC960_Controller_T *Controller,
206 that are passed in. 206 that are passed in.
207 */ 207 */
208 208
209static boolean init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf, 209static bool init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
210 size_t len) 210 size_t len)
211{ 211{
212 void *cpu_addr; 212 void *cpu_addr;
@@ -250,7 +250,7 @@ static void free_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf_handle)
250 failure. 250 failure.
251*/ 251*/
252 252
253static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller) 253static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
254{ 254{
255 int CommandAllocationLength, CommandAllocationGroupSize; 255 int CommandAllocationLength, CommandAllocationGroupSize;
256 int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount; 256 int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount;
@@ -790,7 +790,7 @@ static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
790 on failure. 790 on failure.
791*/ 791*/
792 792
793static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller, 793static bool DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
794 DAC960_V1_CommandOpcode_T CommandOpcode, 794 DAC960_V1_CommandOpcode_T CommandOpcode,
795 dma_addr_t DataDMA) 795 dma_addr_t DataDMA)
796{ 796{
@@ -814,7 +814,7 @@ static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
814 on failure. 814 on failure.
815*/ 815*/
816 816
817static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller, 817static bool DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
818 DAC960_V1_CommandOpcode_T CommandOpcode, 818 DAC960_V1_CommandOpcode_T CommandOpcode,
819 unsigned char CommandOpcode2, 819 unsigned char CommandOpcode2,
820 dma_addr_t DataDMA) 820 dma_addr_t DataDMA)
@@ -840,7 +840,7 @@ static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
840 on failure. 840 on failure.
841*/ 841*/
842 842
843static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller, 843static bool DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
844 DAC960_V1_CommandOpcode_T CommandOpcode, 844 DAC960_V1_CommandOpcode_T CommandOpcode,
845 unsigned char Channel, 845 unsigned char Channel,
846 unsigned char TargetID, 846 unsigned char TargetID,
@@ -870,7 +870,7 @@ static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
870 Return data in The controller's HealthStatusBuffer, which is dma-able memory 870 Return data in The controller's HealthStatusBuffer, which is dma-able memory
871*/ 871*/
872 872
873static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller) 873static bool DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
874{ 874{
875 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller); 875 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
876 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox; 876 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
@@ -908,7 +908,7 @@ static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
908 memory buffer. 908 memory buffer.
909*/ 909*/
910 910
911static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller) 911static bool DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
912{ 912{
913 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller); 913 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
914 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox; 914 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
@@ -946,7 +946,7 @@ static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
946 Data is returned in the controller's V2.NewLogicalDeviceInformation 946 Data is returned in the controller's V2.NewLogicalDeviceInformation
947*/ 947*/
948 948
949static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller, 949static bool DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
950 unsigned short LogicalDeviceNumber) 950 unsigned short LogicalDeviceNumber)
951{ 951{
952 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller); 952 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
@@ -997,7 +997,7 @@ static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
997 997
998*/ 998*/
999 999
1000static boolean DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller, 1000static bool DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
1001 unsigned char Channel, 1001 unsigned char Channel,
1002 unsigned char TargetID, 1002 unsigned char TargetID,
1003 unsigned char LogicalUnit) 1003 unsigned char LogicalUnit)
@@ -1082,7 +1082,7 @@ static void DAC960_V2_ConstructNewUnitSerialNumber(
1082 memory buffer. 1082 memory buffer.
1083*/ 1083*/
1084 1084
1085static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller, 1085static bool DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
1086 int Channel, int TargetID, int LogicalUnit) 1086 int Channel, int TargetID, int LogicalUnit)
1087{ 1087{
1088 DAC960_Command_T *Command; 1088 DAC960_Command_T *Command;
@@ -1110,7 +1110,7 @@ static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Control
1110 success and false on failure. 1110 success and false on failure.
1111*/ 1111*/
1112 1112
1113static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller, 1113static bool DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1114 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode, 1114 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
1115 DAC960_V2_OperationDevice_T 1115 DAC960_V2_OperationDevice_T
1116 OperationDevice) 1116 OperationDevice)
@@ -1142,7 +1142,7 @@ static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1142 other dma mapped memory. 1142 other dma mapped memory.
1143*/ 1143*/
1144 1144
1145static boolean DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T 1145static bool DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1146 *Controller) 1146 *Controller)
1147{ 1147{
1148 void __iomem *ControllerBaseAddress = Controller->BaseAddress; 1148 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
@@ -1348,7 +1348,7 @@ skip_mailboxes:
1348 the structures that are contained in that region. 1348 the structures that are contained in that region.
1349*/ 1349*/
1350 1350
1351static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T 1351static bool DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1352 *Controller) 1352 *Controller)
1353{ 1353{
1354 void __iomem *ControllerBaseAddress = Controller->BaseAddress; 1354 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
@@ -1526,7 +1526,7 @@ static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1526 from DAC960 V1 Firmware Controllers and initializes the Controller structure. 1526 from DAC960 V1 Firmware Controllers and initializes the Controller structure.
1527*/ 1527*/
1528 1528
1529static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T 1529static bool DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1530 *Controller) 1530 *Controller)
1531{ 1531{
1532 DAC960_V1_Enquiry2_T *Enquiry2; 1532 DAC960_V1_Enquiry2_T *Enquiry2;
@@ -1767,7 +1767,7 @@ static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1767 from DAC960 V2 Firmware Controllers and initializes the Controller structure. 1767 from DAC960 V2 Firmware Controllers and initializes the Controller structure.
1768*/ 1768*/
1769 1769
1770static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T 1770static bool DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1771 *Controller) 1771 *Controller)
1772{ 1772{
1773 DAC960_V2_ControllerInfo_T *ControllerInfo = 1773 DAC960_V2_ControllerInfo_T *ControllerInfo =
@@ -1898,7 +1898,7 @@ static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1898 for Controller. 1898 for Controller.
1899*/ 1899*/
1900 1900
1901static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T 1901static bool DAC960_ReportControllerConfiguration(DAC960_Controller_T
1902 *Controller) 1902 *Controller)
1903{ 1903{
1904 DAC960_Info("Configuring Mylex %s PCI RAID Controller\n", 1904 DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",
@@ -1947,7 +1947,7 @@ static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
1947 Controller. 1947 Controller.
1948*/ 1948*/
1949 1949
1950static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T 1950static bool DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
1951 *Controller) 1951 *Controller)
1952{ 1952{
1953 struct dma_loaf local_dma; 1953 struct dma_loaf local_dma;
@@ -2095,7 +2095,7 @@ static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
2095 device connected to Controller. 2095 device connected to Controller.
2096*/ 2096*/
2097 2097
2098static boolean DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T 2098static bool DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
2099 *Controller) 2099 *Controller)
2100{ 2100{
2101 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0; 2101 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
@@ -2219,7 +2219,7 @@ static void DAC960_SanitizeInquiryData(DAC960_SCSI_Inquiry_T
2219 Information for DAC960 V1 Firmware Controllers. 2219 Information for DAC960 V1 Firmware Controllers.
2220*/ 2220*/
2221 2221
2222static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T 2222static bool DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2223 *Controller) 2223 *Controller)
2224{ 2224{
2225 int LogicalDriveNumber, Channel, TargetID; 2225 int LogicalDriveNumber, Channel, TargetID;
@@ -2316,7 +2316,7 @@ static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2316 Information for DAC960 V2 Firmware Controllers. 2316 Information for DAC960 V2 Firmware Controllers.
2317*/ 2317*/
2318 2318
2319static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T 2319static bool DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2320 *Controller) 2320 *Controller)
2321{ 2321{
2322 int PhysicalDeviceIndex, LogicalDriveNumber; 2322 int PhysicalDeviceIndex, LogicalDriveNumber;
@@ -2501,7 +2501,7 @@ static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2501 associated with Controller. 2501 associated with Controller.
2502*/ 2502*/
2503 2503
2504static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) 2504static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2505{ 2505{
2506 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber; 2506 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2507 int n; 2507 int n;
@@ -2582,7 +2582,7 @@ static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
2582 It returns true for fatal errors and false otherwise. 2582 It returns true for fatal errors and false otherwise.
2583*/ 2583*/
2584 2584
2585static boolean DAC960_ReportErrorStatus(DAC960_Controller_T *Controller, 2585static bool DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
2586 unsigned char ErrorStatus, 2586 unsigned char ErrorStatus,
2587 unsigned char Parameter0, 2587 unsigned char Parameter0,
2588 unsigned char Parameter1) 2588 unsigned char Parameter1)
@@ -3048,7 +3048,7 @@ Failure:
3048 DAC960_InitializeController initializes Controller. 3048 DAC960_InitializeController initializes Controller.
3049*/ 3049*/
3050 3050
3051static boolean 3051static bool
3052DAC960_InitializeController(DAC960_Controller_T *Controller) 3052DAC960_InitializeController(DAC960_Controller_T *Controller)
3053{ 3053{
3054 if (DAC960_ReadControllerConfiguration(Controller) && 3054 if (DAC960_ReadControllerConfiguration(Controller) &&
@@ -3445,8 +3445,8 @@ static void DAC960_RequestFunction(struct request_queue *RequestQueue)
3445 individual Buffer. 3445 individual Buffer.
3446*/ 3446*/
3447 3447
3448static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, 3448static inline bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3449 boolean SuccessfulIO) 3449 bool SuccessfulIO)
3450{ 3450{
3451 struct request *Request = Command->Request; 3451 struct request *Request = Command->Request;
3452 int UpToDate; 3452 int UpToDate;
@@ -3572,7 +3572,7 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
3572 else if (CommandType == DAC960_ReadRetryCommand || 3572 else if (CommandType == DAC960_ReadRetryCommand ||
3573 CommandType == DAC960_WriteRetryCommand) 3573 CommandType == DAC960_WriteRetryCommand)
3574 { 3574 {
3575 boolean normal_completion; 3575 bool normal_completion;
3576#ifdef FORCE_RETRY_FAILURE_DEBUG 3576#ifdef FORCE_RETRY_FAILURE_DEBUG
3577 static int retry_count = 1; 3577 static int retry_count = 1;
3578#endif 3578#endif
@@ -4659,7 +4659,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4659 else if (CommandType == DAC960_ReadRetryCommand || 4659 else if (CommandType == DAC960_ReadRetryCommand ||
4660 CommandType == DAC960_WriteRetryCommand) 4660 CommandType == DAC960_WriteRetryCommand)
4661 { 4661 {
4662 boolean normal_completion; 4662 bool normal_completion;
4663 4663
4664#ifdef FORCE_RETRY_FAILURE_DEBUG 4664#ifdef FORCE_RETRY_FAILURE_DEBUG
4665 static int retry_count = 1; 4665 static int retry_count = 1;
@@ -5632,7 +5632,7 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
5632 &Controller->V2.ControllerInformation; 5632 &Controller->V2.ControllerInformation;
5633 unsigned int StatusChangeCounter = 5633 unsigned int StatusChangeCounter =
5634 Controller->V2.HealthStatusBuffer->StatusChangeCounter; 5634 Controller->V2.HealthStatusBuffer->StatusChangeCounter;
5635 boolean ForceMonitoringCommand = false; 5635 bool ForceMonitoringCommand = false;
5636 if (time_after(jiffies, Controller->SecondaryMonitoringTime 5636 if (time_after(jiffies, Controller->SecondaryMonitoringTime
5637 + DAC960_SecondaryMonitoringInterval)) 5637 + DAC960_SecondaryMonitoringInterval))
5638 { 5638 {
@@ -5696,7 +5696,7 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
5696 necessary. It returns true if there is enough room and false otherwise. 5696 necessary. It returns true if there is enough room and false otherwise.
5697*/ 5697*/
5698 5698
5699static boolean DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller, 5699static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
5700 unsigned int ByteCount) 5700 unsigned int ByteCount)
5701{ 5701{
5702 unsigned char *NewStatusBuffer; 5702 unsigned char *NewStatusBuffer;
@@ -5744,7 +5744,7 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
5744 ...) 5744 ...)
5745{ 5745{
5746 static unsigned char Buffer[DAC960_LineBufferSize]; 5746 static unsigned char Buffer[DAC960_LineBufferSize];
5747 static boolean BeginningOfLine = true; 5747 static bool BeginningOfLine = true;
5748 va_list Arguments; 5748 va_list Arguments;
5749 int Length = 0; 5749 int Length = 0;
5750 va_start(Arguments, Controller); 5750 va_start(Arguments, Controller);
@@ -5837,7 +5837,7 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
5837 Channel and TargetID and returns true on success and false on failure. 5837 Channel and TargetID and returns true on success and false on failure.
5838*/ 5838*/
5839 5839
5840static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller, 5840static bool DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
5841 char *UserCommandString, 5841 char *UserCommandString,
5842 unsigned char *Channel, 5842 unsigned char *Channel,
5843 unsigned char *TargetID) 5843 unsigned char *TargetID)
@@ -5870,7 +5870,7 @@ static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
5870 returns true on success and false on failure. 5870 returns true on success and false on failure.
5871*/ 5871*/
5872 5872
5873static boolean DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller, 5873static bool DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
5874 char *UserCommandString, 5874 char *UserCommandString,
5875 unsigned char *LogicalDriveNumber) 5875 unsigned char *LogicalDriveNumber)
5876{ 5876{
@@ -5951,7 +5951,7 @@ static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
5951 Controllers. 5951 Controllers.
5952*/ 5952*/
5953 5953
5954static boolean DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller, 5954static bool DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
5955 unsigned char *UserCommand) 5955 unsigned char *UserCommand)
5956{ 5956{
5957 DAC960_Command_T *Command; 5957 DAC960_Command_T *Command;
@@ -6166,7 +6166,7 @@ failure:
6166 on failure. 6166 on failure.
6167*/ 6167*/
6168 6168
6169static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command, 6169static bool DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6170 unsigned char Channel, 6170 unsigned char Channel,
6171 unsigned char TargetID, 6171 unsigned char TargetID,
6172 unsigned short 6172 unsigned short
@@ -6213,7 +6213,7 @@ static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6213 Controllers. 6213 Controllers.
6214*/ 6214*/
6215 6215
6216static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller, 6216static bool DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
6217 unsigned char *UserCommand) 6217 unsigned char *UserCommand)
6218{ 6218{
6219 DAC960_Command_T *Command; 6219 DAC960_Command_T *Command;
diff --git a/drivers/block/DAC960.h b/drivers/block/DAC960.h
index 6148073532b2..f5e2436c39aa 100644
--- a/drivers/block/DAC960.h
+++ b/drivers/block/DAC960.h
@@ -68,13 +68,6 @@
68#define DAC690_V2_PciDmaMask 0xffffffffffffffffULL 68#define DAC690_V2_PciDmaMask 0xffffffffffffffffULL
69 69
70/* 70/*
71 Define a Boolean data type.
72*/
73
74typedef bool boolean;
75
76
77/*
78 Define a 32/64 bit I/O Address data type. 71 Define a 32/64 bit I/O Address data type.
79*/ 72*/
80 73
@@ -139,25 +132,25 @@ typedef struct DAC960_SCSI_Inquiry
139 unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ 132 unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */
140 unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ 133 unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */
141 unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ 134 unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */
142 boolean RMB:1; /* Byte 1 Bit 7 */ 135 bool RMB:1; /* Byte 1 Bit 7 */
143 unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ 136 unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */
144 unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */ 137 unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */
145 unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */ 138 unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */
146 unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */ 139 unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */
147 unsigned char :2; /* Byte 3 Bits 4-5 */ 140 unsigned char :2; /* Byte 3 Bits 4-5 */
148 boolean TrmIOP:1; /* Byte 3 Bit 6 */ 141 bool TrmIOP:1; /* Byte 3 Bit 6 */
149 boolean AENC:1; /* Byte 3 Bit 7 */ 142 bool AENC:1; /* Byte 3 Bit 7 */
150 unsigned char AdditionalLength; /* Byte 4 */ 143 unsigned char AdditionalLength; /* Byte 4 */
151 unsigned char :8; /* Byte 5 */ 144 unsigned char :8; /* Byte 5 */
152 unsigned char :8; /* Byte 6 */ 145 unsigned char :8; /* Byte 6 */
153 boolean SftRe:1; /* Byte 7 Bit 0 */ 146 bool SftRe:1; /* Byte 7 Bit 0 */
154 boolean CmdQue:1; /* Byte 7 Bit 1 */ 147 bool CmdQue:1; /* Byte 7 Bit 1 */
155 boolean :1; /* Byte 7 Bit 2 */ 148 bool :1; /* Byte 7 Bit 2 */
156 boolean Linked:1; /* Byte 7 Bit 3 */ 149 bool Linked:1; /* Byte 7 Bit 3 */
157 boolean Sync:1; /* Byte 7 Bit 4 */ 150 bool Sync:1; /* Byte 7 Bit 4 */
158 boolean WBus16:1; /* Byte 7 Bit 5 */ 151 bool WBus16:1; /* Byte 7 Bit 5 */
159 boolean WBus32:1; /* Byte 7 Bit 6 */ 152 bool WBus32:1; /* Byte 7 Bit 6 */
160 boolean RelAdr:1; /* Byte 7 Bit 7 */ 153 bool RelAdr:1; /* Byte 7 Bit 7 */
161 unsigned char VendorIdentification[8]; /* Bytes 8-15 */ 154 unsigned char VendorIdentification[8]; /* Bytes 8-15 */
162 unsigned char ProductIdentification[16]; /* Bytes 16-31 */ 155 unsigned char ProductIdentification[16]; /* Bytes 16-31 */
163 unsigned char ProductRevisionLevel[4]; /* Bytes 32-35 */ 156 unsigned char ProductRevisionLevel[4]; /* Bytes 32-35 */
@@ -215,13 +208,13 @@ DAC960_SCSI_RequestSenseKey_T;
215typedef struct DAC960_SCSI_RequestSense 208typedef struct DAC960_SCSI_RequestSense
216{ 209{
217 unsigned char ErrorCode:7; /* Byte 0 Bits 0-6 */ 210 unsigned char ErrorCode:7; /* Byte 0 Bits 0-6 */
218 boolean Valid:1; /* Byte 0 Bit 7 */ 211 bool Valid:1; /* Byte 0 Bit 7 */
219 unsigned char SegmentNumber; /* Byte 1 */ 212 unsigned char SegmentNumber; /* Byte 1 */
220 DAC960_SCSI_RequestSenseKey_T SenseKey:4; /* Byte 2 Bits 0-3 */ 213 DAC960_SCSI_RequestSenseKey_T SenseKey:4; /* Byte 2 Bits 0-3 */
221 unsigned char :1; /* Byte 2 Bit 4 */ 214 unsigned char :1; /* Byte 2 Bit 4 */
222 boolean ILI:1; /* Byte 2 Bit 5 */ 215 bool ILI:1; /* Byte 2 Bit 5 */
223 boolean EOM:1; /* Byte 2 Bit 6 */ 216 bool EOM:1; /* Byte 2 Bit 6 */
224 boolean Filemark:1; /* Byte 2 Bit 7 */ 217 bool Filemark:1; /* Byte 2 Bit 7 */
225 unsigned char Information[4]; /* Bytes 3-6 */ 218 unsigned char Information[4]; /* Bytes 3-6 */
226 unsigned char AdditionalSenseLength; /* Byte 7 */ 219 unsigned char AdditionalSenseLength; /* Byte 7 */
227 unsigned char CommandSpecificInformation[4]; /* Bytes 8-11 */ 220 unsigned char CommandSpecificInformation[4]; /* Bytes 8-11 */
@@ -381,8 +374,8 @@ typedef struct DAC960_V1_Enquiry
381 unsigned int LogicalDriveSizes[32]; /* Bytes 4-131 */ 374 unsigned int LogicalDriveSizes[32]; /* Bytes 4-131 */
382 unsigned short FlashAge; /* Bytes 132-133 */ 375 unsigned short FlashAge; /* Bytes 132-133 */
383 struct { 376 struct {
384 boolean DeferredWriteError:1; /* Byte 134 Bit 0 */ 377 bool DeferredWriteError:1; /* Byte 134 Bit 0 */
385 boolean BatteryLow:1; /* Byte 134 Bit 1 */ 378 bool BatteryLow:1; /* Byte 134 Bit 1 */
386 unsigned char :6; /* Byte 134 Bits 2-7 */ 379 unsigned char :6; /* Byte 134 Bits 2-7 */
387 } StatusFlags; 380 } StatusFlags;
388 unsigned char :8; /* Byte 135 */ 381 unsigned char :8; /* Byte 135 */
@@ -410,7 +403,7 @@ typedef struct DAC960_V1_Enquiry
410 unsigned char RebuildCount; /* Byte 150 */ 403 unsigned char RebuildCount; /* Byte 150 */
411 struct { 404 struct {
412 unsigned char :3; /* Byte 151 Bits 0-2 */ 405 unsigned char :3; /* Byte 151 Bits 0-2 */
413 boolean BatteryBackupUnitPresent:1; /* Byte 151 Bit 3 */ 406 bool BatteryBackupUnitPresent:1; /* Byte 151 Bit 3 */
414 unsigned char :3; /* Byte 151 Bits 4-6 */ 407 unsigned char :3; /* Byte 151 Bits 4-6 */
415 unsigned char :1; /* Byte 151 Bit 7 */ 408 unsigned char :1; /* Byte 151 Bit 7 */
416 } MiscFlags; 409 } MiscFlags;
@@ -492,8 +485,8 @@ typedef struct DAC960_V1_Enquiry2
492 DAC960_V1_ErrorCorrection_ECC = 0x2, 485 DAC960_V1_ErrorCorrection_ECC = 0x2,
493 DAC960_V1_ErrorCorrection_Last = 0x7 486 DAC960_V1_ErrorCorrection_Last = 0x7
494 } __attribute__ ((packed)) ErrorCorrection:3; /* Byte 40 Bits 3-5 */ 487 } __attribute__ ((packed)) ErrorCorrection:3; /* Byte 40 Bits 3-5 */
495 boolean FastPageMode:1; /* Byte 40 Bit 6 */ 488 bool FastPageMode:1; /* Byte 40 Bit 6 */
496 boolean LowPowerMemory:1; /* Byte 40 Bit 7 */ 489 bool LowPowerMemory:1; /* Byte 40 Bit 7 */
497 unsigned char :8; /* Bytes 41 */ 490 unsigned char :8; /* Bytes 41 */
498 } MemoryType; 491 } MemoryType;
499 unsigned short ClockSpeed; /* Bytes 42-43 */ 492 unsigned short ClockSpeed; /* Bytes 42-43 */
@@ -538,7 +531,7 @@ typedef struct DAC960_V1_Enquiry2
538 DAC960_V1_Ultra = 0x1, 531 DAC960_V1_Ultra = 0x1,
539 DAC960_V1_Ultra2 = 0x2 532 DAC960_V1_Ultra2 = 0x2
540 } __attribute__ ((packed)) BusSpeed:2; /* Byte 106 Bits 2-3 */ 533 } __attribute__ ((packed)) BusSpeed:2; /* Byte 106 Bits 2-3 */
541 boolean Differential:1; /* Byte 106 Bit 4 */ 534 bool Differential:1; /* Byte 106 Bit 4 */
542 unsigned char :3; /* Byte 106 Bits 5-7 */ 535 unsigned char :3; /* Byte 106 Bits 5-7 */
543 } SCSICapability; 536 } SCSICapability;
544 unsigned char :8; /* Byte 107 */ 537 unsigned char :8; /* Byte 107 */
@@ -554,10 +547,10 @@ typedef struct DAC960_V1_Enquiry2
554 } __attribute__ ((packed)) FaultManagementType; /* Byte 114 */ 547 } __attribute__ ((packed)) FaultManagementType; /* Byte 114 */
555 unsigned char :8; /* Byte 115 */ 548 unsigned char :8; /* Byte 115 */
556 struct { 549 struct {
557 boolean Clustering:1; /* Byte 116 Bit 0 */ 550 bool Clustering:1; /* Byte 116 Bit 0 */
558 boolean MylexOnlineRAIDExpansion:1; /* Byte 116 Bit 1 */ 551 bool MylexOnlineRAIDExpansion:1; /* Byte 116 Bit 1 */
559 boolean ReadAhead:1; /* Byte 116 Bit 2 */ 552 bool ReadAhead:1; /* Byte 116 Bit 2 */
560 boolean BackgroundInitialization:1; /* Byte 116 Bit 3 */ 553 bool BackgroundInitialization:1; /* Byte 116 Bit 3 */
561 unsigned int :28; /* Bytes 116-119 */ 554 unsigned int :28; /* Bytes 116-119 */
562 } FirmwareFeatures; 555 } FirmwareFeatures;
563 unsigned int :32; /* Bytes 120-123 */ 556 unsigned int :32; /* Bytes 120-123 */
@@ -589,7 +582,7 @@ typedef struct DAC960_V1_LogicalDriveInformation
589 unsigned int LogicalDriveSize; /* Bytes 0-3 */ 582 unsigned int LogicalDriveSize; /* Bytes 0-3 */
590 DAC960_V1_LogicalDriveState_T LogicalDriveState; /* Byte 4 */ 583 DAC960_V1_LogicalDriveState_T LogicalDriveState; /* Byte 4 */
591 unsigned char RAIDLevel:7; /* Byte 5 Bits 0-6 */ 584 unsigned char RAIDLevel:7; /* Byte 5 Bits 0-6 */
592 boolean WriteBack:1; /* Byte 5 Bit 7 */ 585 bool WriteBack:1; /* Byte 5 Bit 7 */
593 unsigned short :16; /* Bytes 6-7 */ 586 unsigned short :16; /* Bytes 6-7 */
594} 587}
595DAC960_V1_LogicalDriveInformation_T; 588DAC960_V1_LogicalDriveInformation_T;
@@ -630,13 +623,13 @@ typedef struct DAC960_V1_EventLogEntry
630 unsigned char :2; /* Byte 3 Bits 6-7 */ 623 unsigned char :2; /* Byte 3 Bits 6-7 */
631 unsigned short SequenceNumber; /* Bytes 4-5 */ 624 unsigned short SequenceNumber; /* Bytes 4-5 */
632 unsigned char ErrorCode:7; /* Byte 6 Bits 0-6 */ 625 unsigned char ErrorCode:7; /* Byte 6 Bits 0-6 */
633 boolean Valid:1; /* Byte 6 Bit 7 */ 626 bool Valid:1; /* Byte 6 Bit 7 */
634 unsigned char SegmentNumber; /* Byte 7 */ 627 unsigned char SegmentNumber; /* Byte 7 */
635 DAC960_SCSI_RequestSenseKey_T SenseKey:4; /* Byte 8 Bits 0-3 */ 628 DAC960_SCSI_RequestSenseKey_T SenseKey:4; /* Byte 8 Bits 0-3 */
636 unsigned char :1; /* Byte 8 Bit 4 */ 629 unsigned char :1; /* Byte 8 Bit 4 */
637 boolean ILI:1; /* Byte 8 Bit 5 */ 630 bool ILI:1; /* Byte 8 Bit 5 */
638 boolean EOM:1; /* Byte 8 Bit 6 */ 631 bool EOM:1; /* Byte 8 Bit 6 */
639 boolean Filemark:1; /* Byte 8 Bit 7 */ 632 bool Filemark:1; /* Byte 8 Bit 7 */
640 unsigned char Information[4]; /* Bytes 9-12 */ 633 unsigned char Information[4]; /* Bytes 9-12 */
641 unsigned char AdditionalSenseLength; /* Byte 13 */ 634 unsigned char AdditionalSenseLength; /* Byte 13 */
642 unsigned char CommandSpecificInformation[4]; /* Bytes 14-17 */ 635 unsigned char CommandSpecificInformation[4]; /* Bytes 14-17 */
@@ -670,7 +663,7 @@ DAC960_V1_PhysicalDeviceState_T;
670 663
671typedef struct DAC960_V1_DeviceState 664typedef struct DAC960_V1_DeviceState
672{ 665{
673 boolean Present:1; /* Byte 0 Bit 0 */ 666 bool Present:1; /* Byte 0 Bit 0 */
674 unsigned char :7; /* Byte 0 Bits 1-7 */ 667 unsigned char :7; /* Byte 0 Bits 1-7 */
675 enum { 668 enum {
676 DAC960_V1_OtherType = 0x0, 669 DAC960_V1_OtherType = 0x0,
@@ -678,12 +671,12 @@ typedef struct DAC960_V1_DeviceState
678 DAC960_V1_SequentialType = 0x2, 671 DAC960_V1_SequentialType = 0x2,
679 DAC960_V1_CDROM_or_WORM_Type = 0x3 672 DAC960_V1_CDROM_or_WORM_Type = 0x3
680 } __attribute__ ((packed)) DeviceType:2; /* Byte 1 Bits 0-1 */ 673 } __attribute__ ((packed)) DeviceType:2; /* Byte 1 Bits 0-1 */
681 boolean :1; /* Byte 1 Bit 2 */ 674 bool :1; /* Byte 1 Bit 2 */
682 boolean Fast20:1; /* Byte 1 Bit 3 */ 675 bool Fast20:1; /* Byte 1 Bit 3 */
683 boolean Sync:1; /* Byte 1 Bit 4 */ 676 bool Sync:1; /* Byte 1 Bit 4 */
684 boolean Fast:1; /* Byte 1 Bit 5 */ 677 bool Fast:1; /* Byte 1 Bit 5 */
685 boolean Wide:1; /* Byte 1 Bit 6 */ 678 bool Wide:1; /* Byte 1 Bit 6 */
686 boolean TaggedQueuingSupported:1; /* Byte 1 Bit 7 */ 679 bool TaggedQueuingSupported:1; /* Byte 1 Bit 7 */
687 DAC960_V1_PhysicalDeviceState_T DeviceState; /* Byte 2 */ 680 DAC960_V1_PhysicalDeviceState_T DeviceState; /* Byte 2 */
688 unsigned char :8; /* Byte 3 */ 681 unsigned char :8; /* Byte 3 */
689 unsigned char SynchronousMultiplier; /* Byte 4 */ 682 unsigned char SynchronousMultiplier; /* Byte 4 */
@@ -765,15 +758,15 @@ DAC960_V1_ErrorTable_T;
765typedef struct DAC960_V1_Config2 758typedef struct DAC960_V1_Config2
766{ 759{
767 unsigned char :1; /* Byte 0 Bit 0 */ 760 unsigned char :1; /* Byte 0 Bit 0 */
768 boolean ActiveNegationEnabled:1; /* Byte 0 Bit 1 */ 761 bool ActiveNegationEnabled:1; /* Byte 0 Bit 1 */
769 unsigned char :5; /* Byte 0 Bits 2-6 */ 762 unsigned char :5; /* Byte 0 Bits 2-6 */
770 boolean NoRescanIfResetReceivedDuringScan:1; /* Byte 0 Bit 7 */ 763 bool NoRescanIfResetReceivedDuringScan:1; /* Byte 0 Bit 7 */
771 boolean StorageWorksSupportEnabled:1; /* Byte 1 Bit 0 */ 764 bool StorageWorksSupportEnabled:1; /* Byte 1 Bit 0 */
772 boolean HewlettPackardSupportEnabled:1; /* Byte 1 Bit 1 */ 765 bool HewlettPackardSupportEnabled:1; /* Byte 1 Bit 1 */
773 boolean NoDisconnectOnFirstCommand:1; /* Byte 1 Bit 2 */ 766 bool NoDisconnectOnFirstCommand:1; /* Byte 1 Bit 2 */
774 unsigned char :2; /* Byte 1 Bits 3-4 */ 767 unsigned char :2; /* Byte 1 Bits 3-4 */
775 boolean AEMI_ARM:1; /* Byte 1 Bit 5 */ 768 bool AEMI_ARM:1; /* Byte 1 Bit 5 */
776 boolean AEMI_OFM:1; /* Byte 1 Bit 6 */ 769 bool AEMI_OFM:1; /* Byte 1 Bit 6 */
777 unsigned char :1; /* Byte 1 Bit 7 */ 770 unsigned char :1; /* Byte 1 Bit 7 */
778 enum { 771 enum {
779 DAC960_V1_OEMID_Mylex = 0x00, 772 DAC960_V1_OEMID_Mylex = 0x00,
@@ -787,13 +780,13 @@ typedef struct DAC960_V1_Config2
787 unsigned char PhysicalSector; /* Byte 4 */ 780 unsigned char PhysicalSector; /* Byte 4 */
788 unsigned char LogicalSector; /* Byte 5 */ 781 unsigned char LogicalSector; /* Byte 5 */
789 unsigned char BlockFactor; /* Byte 6 */ 782 unsigned char BlockFactor; /* Byte 6 */
790 boolean ReadAheadEnabled:1; /* Byte 7 Bit 0 */ 783 bool ReadAheadEnabled:1; /* Byte 7 Bit 0 */
791 boolean LowBIOSDelay:1; /* Byte 7 Bit 1 */ 784 bool LowBIOSDelay:1; /* Byte 7 Bit 1 */
792 unsigned char :2; /* Byte 7 Bits 2-3 */ 785 unsigned char :2; /* Byte 7 Bits 2-3 */
793 boolean ReassignRestrictedToOneSector:1; /* Byte 7 Bit 4 */ 786 bool ReassignRestrictedToOneSector:1; /* Byte 7 Bit 4 */
794 unsigned char :1; /* Byte 7 Bit 5 */ 787 unsigned char :1; /* Byte 7 Bit 5 */
795 boolean ForceUnitAccessDuringWriteRecovery:1; /* Byte 7 Bit 6 */ 788 bool ForceUnitAccessDuringWriteRecovery:1; /* Byte 7 Bit 6 */
796 boolean EnableLeftSymmetricRAID5Algorithm:1; /* Byte 7 Bit 7 */ 789 bool EnableLeftSymmetricRAID5Algorithm:1; /* Byte 7 Bit 7 */
797 unsigned char DefaultRebuildRate; /* Byte 8 */ 790 unsigned char DefaultRebuildRate; /* Byte 8 */
798 unsigned char :8; /* Byte 9 */ 791 unsigned char :8; /* Byte 9 */
799 unsigned char BlocksPerCacheLine; /* Byte 10 */ 792 unsigned char BlocksPerCacheLine; /* Byte 10 */
@@ -805,10 +798,10 @@ typedef struct DAC960_V1_Config2
805 DAC960_V1_Sync_5MHz = 0x2, 798 DAC960_V1_Sync_5MHz = 0x2,
806 DAC960_V1_Sync_10or20MHz = 0x3 /* Byte 11 Bits 0-1 */ 799 DAC960_V1_Sync_10or20MHz = 0x3 /* Byte 11 Bits 0-1 */
807 } __attribute__ ((packed)) Speed:2; 800 } __attribute__ ((packed)) Speed:2;
808 boolean Force8Bit:1; /* Byte 11 Bit 2 */ 801 bool Force8Bit:1; /* Byte 11 Bit 2 */
809 boolean DisableFast20:1; /* Byte 11 Bit 3 */ 802 bool DisableFast20:1; /* Byte 11 Bit 3 */
810 unsigned char :3; /* Byte 11 Bits 4-6 */ 803 unsigned char :3; /* Byte 11 Bits 4-6 */
811 boolean EnableTaggedQueuing:1; /* Byte 11 Bit 7 */ 804 bool EnableTaggedQueuing:1; /* Byte 11 Bit 7 */
812 } __attribute__ ((packed)) ChannelParameters[6]; /* Bytes 12-17 */ 805 } __attribute__ ((packed)) ChannelParameters[6]; /* Bytes 12-17 */
813 unsigned char SCSIInitiatorID; /* Byte 18 */ 806 unsigned char SCSIInitiatorID; /* Byte 18 */
814 unsigned char :8; /* Byte 19 */ 807 unsigned char :8; /* Byte 19 */
@@ -819,8 +812,8 @@ typedef struct DAC960_V1_Config2
819 unsigned char SimultaneousDeviceSpinUpCount; /* Byte 21 */ 812 unsigned char SimultaneousDeviceSpinUpCount; /* Byte 21 */
820 unsigned char SecondsDelayBetweenSpinUps; /* Byte 22 */ 813 unsigned char SecondsDelayBetweenSpinUps; /* Byte 22 */
821 unsigned char Reserved1[29]; /* Bytes 23-51 */ 814 unsigned char Reserved1[29]; /* Bytes 23-51 */
822 boolean BIOSDisabled:1; /* Byte 52 Bit 0 */ 815 bool BIOSDisabled:1; /* Byte 52 Bit 0 */
823 boolean CDROMBootEnabled:1; /* Byte 52 Bit 1 */ 816 bool CDROMBootEnabled:1; /* Byte 52 Bit 1 */
824 unsigned char :3; /* Byte 52 Bits 2-4 */ 817 unsigned char :3; /* Byte 52 Bits 2-4 */
825 enum { 818 enum {
826 DAC960_V1_Geometry_128_32 = 0x0, 819 DAC960_V1_Geometry_128_32 = 0x0,
@@ -849,7 +842,7 @@ typedef struct DAC960_V1_DCDB
849 DAC960_V1_DCDB_DataTransferSystemToDevice = 2, 842 DAC960_V1_DCDB_DataTransferSystemToDevice = 2,
850 DAC960_V1_DCDB_IllegalDataTransfer = 3 843 DAC960_V1_DCDB_IllegalDataTransfer = 3
851 } __attribute__ ((packed)) Direction:2; /* Byte 1 Bits 0-1 */ 844 } __attribute__ ((packed)) Direction:2; /* Byte 1 Bits 0-1 */
852 boolean EarlyStatus:1; /* Byte 1 Bit 2 */ 845 bool EarlyStatus:1; /* Byte 1 Bit 2 */
853 unsigned char :1; /* Byte 1 Bit 3 */ 846 unsigned char :1; /* Byte 1 Bit 3 */
854 enum { 847 enum {
855 DAC960_V1_DCDB_Timeout_24_hours = 0, 848 DAC960_V1_DCDB_Timeout_24_hours = 0,
@@ -857,8 +850,8 @@ typedef struct DAC960_V1_DCDB
857 DAC960_V1_DCDB_Timeout_60_seconds = 2, 850 DAC960_V1_DCDB_Timeout_60_seconds = 2,
858 DAC960_V1_DCDB_Timeout_10_minutes = 3 851 DAC960_V1_DCDB_Timeout_10_minutes = 3
859 } __attribute__ ((packed)) Timeout:2; /* Byte 1 Bits 4-5 */ 852 } __attribute__ ((packed)) Timeout:2; /* Byte 1 Bits 4-5 */
860 boolean NoAutomaticRequestSense:1; /* Byte 1 Bit 6 */ 853 bool NoAutomaticRequestSense:1; /* Byte 1 Bit 6 */
861 boolean DisconnectPermitted:1; /* Byte 1 Bit 7 */ 854 bool DisconnectPermitted:1; /* Byte 1 Bit 7 */
862 unsigned short TransferLength; /* Bytes 2-3 */ 855 unsigned short TransferLength; /* Bytes 2-3 */
863 DAC960_BusAddress32_T BusAddress; /* Bytes 4-7 */ 856 DAC960_BusAddress32_T BusAddress; /* Bytes 4-7 */
864 unsigned char CDBLength:4; /* Byte 8 Bits 0-3 */ 857 unsigned char CDBLength:4; /* Byte 8 Bits 0-3 */
@@ -920,7 +913,7 @@ typedef union DAC960_V1_CommandMailbox
920 DAC960_V1_CommandIdentifier_T CommandIdentifier; /* Byte 1 */ 913 DAC960_V1_CommandIdentifier_T CommandIdentifier; /* Byte 1 */
921 unsigned char Dummy1[5]; /* Bytes 2-6 */ 914 unsigned char Dummy1[5]; /* Bytes 2-6 */
922 unsigned char LogicalDriveNumber:6; /* Byte 7 Bits 0-6 */ 915 unsigned char LogicalDriveNumber:6; /* Byte 7 Bits 0-6 */
923 boolean AutoRestore:1; /* Byte 7 Bit 7 */ 916 bool AutoRestore:1; /* Byte 7 Bit 7 */
924 unsigned char Dummy2[8]; /* Bytes 8-15 */ 917 unsigned char Dummy2[8]; /* Bytes 8-15 */
925 } __attribute__ ((packed)) Type3C; 918 } __attribute__ ((packed)) Type3C;
926 struct { 919 struct {
@@ -1070,9 +1063,9 @@ typedef struct DAC960_V2_MemoryType
1070 DAC960_V2_MemoryType_SDRAM = 0x04, 1063 DAC960_V2_MemoryType_SDRAM = 0x04,
1071 DAC960_V2_MemoryType_Last = 0x1F 1064 DAC960_V2_MemoryType_Last = 0x1F
1072 } __attribute__ ((packed)) MemoryType:5; /* Byte 0 Bits 0-4 */ 1065 } __attribute__ ((packed)) MemoryType:5; /* Byte 0 Bits 0-4 */
1073 boolean :1; /* Byte 0 Bit 5 */ 1066 bool :1; /* Byte 0 Bit 5 */
1074 boolean MemoryParity:1; /* Byte 0 Bit 6 */ 1067 bool MemoryParity:1; /* Byte 0 Bit 6 */
1075 boolean MemoryECC:1; /* Byte 0 Bit 7 */ 1068 bool MemoryECC:1; /* Byte 0 Bit 7 */
1076} 1069}
1077DAC960_V2_MemoryType_T; 1070DAC960_V2_MemoryType_T;
1078 1071
@@ -1187,13 +1180,13 @@ typedef struct DAC960_V2_ControllerInfo
1187 unsigned char OEM_Code; /* Byte 131 */ 1180 unsigned char OEM_Code; /* Byte 131 */
1188 unsigned char VendorName[16]; /* Bytes 132-147 */ 1181 unsigned char VendorName[16]; /* Bytes 132-147 */
1189 /* Other Physical/Controller/Operation Information */ 1182 /* Other Physical/Controller/Operation Information */
1190 boolean BBU_Present:1; /* Byte 148 Bit 0 */ 1183 bool BBU_Present:1; /* Byte 148 Bit 0 */
1191 boolean ActiveActiveClusteringMode:1; /* Byte 148 Bit 1 */ 1184 bool ActiveActiveClusteringMode:1; /* Byte 148 Bit 1 */
1192 unsigned char :6; /* Byte 148 Bits 2-7 */ 1185 unsigned char :6; /* Byte 148 Bits 2-7 */
1193 unsigned char :8; /* Byte 149 */ 1186 unsigned char :8; /* Byte 149 */
1194 unsigned short :16; /* Bytes 150-151 */ 1187 unsigned short :16; /* Bytes 150-151 */
1195 /* Physical Device Scan Information */ 1188 /* Physical Device Scan Information */
1196 boolean PhysicalScanActive:1; /* Byte 152 Bit 0 */ 1189 bool PhysicalScanActive:1; /* Byte 152 Bit 0 */
1197 unsigned char :7; /* Byte 152 Bits 1-7 */ 1190 unsigned char :7; /* Byte 152 Bits 1-7 */
1198 unsigned char PhysicalDeviceChannelNumber; /* Byte 153 */ 1191 unsigned char PhysicalDeviceChannelNumber; /* Byte 153 */
1199 unsigned char PhysicalDeviceTargetID; /* Byte 154 */ 1192 unsigned char PhysicalDeviceTargetID; /* Byte 154 */
@@ -1305,8 +1298,8 @@ typedef struct DAC960_V2_ControllerInfo
1305 unsigned int FreeIOP; /* Bytes 468-471 */ 1298 unsigned int FreeIOP; /* Bytes 468-471 */
1306 unsigned short MaximumCombLengthInBlocks; /* Bytes 472-473 */ 1299 unsigned short MaximumCombLengthInBlocks; /* Bytes 472-473 */
1307 unsigned short NumberOfConfigurationGroups; /* Bytes 474-475 */ 1300 unsigned short NumberOfConfigurationGroups; /* Bytes 474-475 */
1308 boolean InstallationAbortStatus:1; /* Byte 476 Bit 0 */ 1301 bool InstallationAbortStatus:1; /* Byte 476 Bit 0 */
1309 boolean MaintenanceModeStatus:1; /* Byte 476 Bit 1 */ 1302 bool MaintenanceModeStatus:1; /* Byte 476 Bit 1 */
1310 unsigned int :24; /* Bytes 476-479 */ 1303 unsigned int :24; /* Bytes 476-479 */
1311 unsigned char Reserved10[32]; /* Bytes 480-511 */ 1304 unsigned char Reserved10[32]; /* Bytes 480-511 */
1312 unsigned char Reserved11[512]; /* Bytes 512-1023 */ 1305 unsigned char Reserved11[512]; /* Bytes 512-1023 */
@@ -1357,33 +1350,33 @@ typedef struct DAC960_V2_LogicalDeviceInfo
1357 DAC960_V2_IntelligentWriteCacheEnabled = 0x3, 1350 DAC960_V2_IntelligentWriteCacheEnabled = 0x3,
1358 DAC960_V2_WriteCache_Last = 0x7 1351 DAC960_V2_WriteCache_Last = 0x7
1359 } __attribute__ ((packed)) WriteCache:3; /* Byte 8 Bits 3-5 */ 1352 } __attribute__ ((packed)) WriteCache:3; /* Byte 8 Bits 3-5 */
1360 boolean :1; /* Byte 8 Bit 6 */ 1353 bool :1; /* Byte 8 Bit 6 */
1361 boolean LogicalDeviceInitialized:1; /* Byte 8 Bit 7 */ 1354 bool LogicalDeviceInitialized:1; /* Byte 8 Bit 7 */
1362 } LogicalDeviceControl; /* Byte 8 */ 1355 } LogicalDeviceControl; /* Byte 8 */
1363 /* Logical Device Operations Status */ 1356 /* Logical Device Operations Status */
1364 boolean ConsistencyCheckInProgress:1; /* Byte 9 Bit 0 */ 1357 bool ConsistencyCheckInProgress:1; /* Byte 9 Bit 0 */
1365 boolean RebuildInProgress:1; /* Byte 9 Bit 1 */ 1358 bool RebuildInProgress:1; /* Byte 9 Bit 1 */
1366 boolean BackgroundInitializationInProgress:1; /* Byte 9 Bit 2 */ 1359 bool BackgroundInitializationInProgress:1; /* Byte 9 Bit 2 */
1367 boolean ForegroundInitializationInProgress:1; /* Byte 9 Bit 3 */ 1360 bool ForegroundInitializationInProgress:1; /* Byte 9 Bit 3 */
1368 boolean DataMigrationInProgress:1; /* Byte 9 Bit 4 */ 1361 bool DataMigrationInProgress:1; /* Byte 9 Bit 4 */
1369 boolean PatrolOperationInProgress:1; /* Byte 9 Bit 5 */ 1362 bool PatrolOperationInProgress:1; /* Byte 9 Bit 5 */
1370 unsigned char :2; /* Byte 9 Bits 6-7 */ 1363 unsigned char :2; /* Byte 9 Bits 6-7 */
1371 unsigned char RAID5WriteUpdate; /* Byte 10 */ 1364 unsigned char RAID5WriteUpdate; /* Byte 10 */
1372 unsigned char RAID5Algorithm; /* Byte 11 */ 1365 unsigned char RAID5Algorithm; /* Byte 11 */
1373 unsigned short LogicalDeviceNumber; /* Bytes 12-13 */ 1366 unsigned short LogicalDeviceNumber; /* Bytes 12-13 */
1374 /* BIOS Info */ 1367 /* BIOS Info */
1375 boolean BIOSDisabled:1; /* Byte 14 Bit 0 */ 1368 bool BIOSDisabled:1; /* Byte 14 Bit 0 */
1376 boolean CDROMBootEnabled:1; /* Byte 14 Bit 1 */ 1369 bool CDROMBootEnabled:1; /* Byte 14 Bit 1 */
1377 boolean DriveCoercionEnabled:1; /* Byte 14 Bit 2 */ 1370 bool DriveCoercionEnabled:1; /* Byte 14 Bit 2 */
1378 boolean WriteSameDisabled:1; /* Byte 14 Bit 3 */ 1371 bool WriteSameDisabled:1; /* Byte 14 Bit 3 */
1379 boolean HBA_ModeEnabled:1; /* Byte 14 Bit 4 */ 1372 bool HBA_ModeEnabled:1; /* Byte 14 Bit 4 */
1380 enum { 1373 enum {
1381 DAC960_V2_Geometry_128_32 = 0x0, 1374 DAC960_V2_Geometry_128_32 = 0x0,
1382 DAC960_V2_Geometry_255_63 = 0x1, 1375 DAC960_V2_Geometry_255_63 = 0x1,
1383 DAC960_V2_Geometry_Reserved1 = 0x2, 1376 DAC960_V2_Geometry_Reserved1 = 0x2,
1384 DAC960_V2_Geometry_Reserved2 = 0x3 1377 DAC960_V2_Geometry_Reserved2 = 0x3
1385 } __attribute__ ((packed)) DriveGeometry:2; /* Byte 14 Bits 5-6 */ 1378 } __attribute__ ((packed)) DriveGeometry:2; /* Byte 14 Bits 5-6 */
1386 boolean SuperReadAheadEnabled:1; /* Byte 14 Bit 7 */ 1379 bool SuperReadAheadEnabled:1; /* Byte 14 Bit 7 */
1387 unsigned char :8; /* Byte 15 */ 1380 unsigned char :8; /* Byte 15 */
1388 /* Error Counters */ 1381 /* Error Counters */
1389 unsigned short SoftErrors; /* Bytes 16-17 */ 1382 unsigned short SoftErrors; /* Bytes 16-17 */
@@ -1446,13 +1439,13 @@ typedef struct DAC960_V2_PhysicalDeviceInfo
1446 unsigned char TargetID; /* Byte 2 */ 1439 unsigned char TargetID; /* Byte 2 */
1447 unsigned char LogicalUnit; /* Byte 3 */ 1440 unsigned char LogicalUnit; /* Byte 3 */
1448 /* Configuration Status Bits */ 1441 /* Configuration Status Bits */
1449 boolean PhysicalDeviceFaultTolerant:1; /* Byte 4 Bit 0 */ 1442 bool PhysicalDeviceFaultTolerant:1; /* Byte 4 Bit 0 */
1450 boolean PhysicalDeviceConnected:1; /* Byte 4 Bit 1 */ 1443 bool PhysicalDeviceConnected:1; /* Byte 4 Bit 1 */
1451 boolean PhysicalDeviceLocalToController:1; /* Byte 4 Bit 2 */ 1444 bool PhysicalDeviceLocalToController:1; /* Byte 4 Bit 2 */
1452 unsigned char :5; /* Byte 4 Bits 3-7 */ 1445 unsigned char :5; /* Byte 4 Bits 3-7 */
1453 /* Multiple Host/Controller Status Bits */ 1446 /* Multiple Host/Controller Status Bits */
1454 boolean RemoteHostSystemDead:1; /* Byte 5 Bit 0 */ 1447 bool RemoteHostSystemDead:1; /* Byte 5 Bit 0 */
1455 boolean RemoteControllerDead:1; /* Byte 5 Bit 1 */ 1448 bool RemoteControllerDead:1; /* Byte 5 Bit 1 */
1456 unsigned char :6; /* Byte 5 Bits 2-7 */ 1449 unsigned char :6; /* Byte 5 Bits 2-7 */
1457 DAC960_V2_PhysicalDeviceState_T PhysicalDeviceState; /* Byte 6 */ 1450 DAC960_V2_PhysicalDeviceState_T PhysicalDeviceState; /* Byte 6 */
1458 unsigned char NegotiatedDataWidthBits; /* Byte 7 */ 1451 unsigned char NegotiatedDataWidthBits; /* Byte 7 */
@@ -1464,12 +1457,12 @@ typedef struct DAC960_V2_PhysicalDeviceInfo
1464 unsigned char NetworkAddress[16]; /* Bytes 16-31 */ 1457 unsigned char NetworkAddress[16]; /* Bytes 16-31 */
1465 unsigned short MaximumTags; /* Bytes 32-33 */ 1458 unsigned short MaximumTags; /* Bytes 32-33 */
1466 /* Physical Device Operations Status */ 1459 /* Physical Device Operations Status */
1467 boolean ConsistencyCheckInProgress:1; /* Byte 34 Bit 0 */ 1460 bool ConsistencyCheckInProgress:1; /* Byte 34 Bit 0 */
1468 boolean RebuildInProgress:1; /* Byte 34 Bit 1 */ 1461 bool RebuildInProgress:1; /* Byte 34 Bit 1 */
1469 boolean MakingDataConsistentInProgress:1; /* Byte 34 Bit 2 */ 1462 bool MakingDataConsistentInProgress:1; /* Byte 34 Bit 2 */
1470 boolean PhysicalDeviceInitializationInProgress:1; /* Byte 34 Bit 3 */ 1463 bool PhysicalDeviceInitializationInProgress:1; /* Byte 34 Bit 3 */
1471 boolean DataMigrationInProgress:1; /* Byte 34 Bit 4 */ 1464 bool DataMigrationInProgress:1; /* Byte 34 Bit 4 */
1472 boolean PatrolOperationInProgress:1; /* Byte 34 Bit 5 */ 1465 bool PatrolOperationInProgress:1; /* Byte 34 Bit 5 */
1473 unsigned char :2; /* Byte 34 Bits 6-7 */ 1466 unsigned char :2; /* Byte 34 Bits 6-7 */
1474 unsigned char LongOperationStatus; /* Byte 35 */ 1467 unsigned char LongOperationStatus; /* Byte 35 */
1475 unsigned char ParityErrors; /* Byte 36 */ 1468 unsigned char ParityErrors; /* Byte 36 */
@@ -1555,14 +1548,14 @@ DAC960_V2_Event_T;
1555 1548
1556typedef struct DAC960_V2_CommandControlBits 1549typedef struct DAC960_V2_CommandControlBits
1557{ 1550{
1558 boolean ForceUnitAccess:1; /* Byte 0 Bit 0 */ 1551 bool ForceUnitAccess:1; /* Byte 0 Bit 0 */
1559 boolean DisablePageOut:1; /* Byte 0 Bit 1 */ 1552 bool DisablePageOut:1; /* Byte 0 Bit 1 */
1560 boolean :1; /* Byte 0 Bit 2 */ 1553 bool :1; /* Byte 0 Bit 2 */
1561 boolean AdditionalScatterGatherListMemory:1; /* Byte 0 Bit 3 */ 1554 bool AdditionalScatterGatherListMemory:1; /* Byte 0 Bit 3 */
1562 boolean DataTransferControllerToHost:1; /* Byte 0 Bit 4 */ 1555 bool DataTransferControllerToHost:1; /* Byte 0 Bit 4 */
1563 boolean :1; /* Byte 0 Bit 5 */ 1556 bool :1; /* Byte 0 Bit 5 */
1564 boolean NoAutoRequestSense:1; /* Byte 0 Bit 6 */ 1557 bool NoAutoRequestSense:1; /* Byte 0 Bit 6 */
1565 boolean DisconnectProhibited:1; /* Byte 0 Bit 7 */ 1558 bool DisconnectProhibited:1; /* Byte 0 Bit 7 */
1566} 1559}
1567DAC960_V2_CommandControlBits_T; 1560DAC960_V2_CommandControlBits_T;
1568 1561
@@ -1825,8 +1818,8 @@ typedef union DAC960_V2_CommandMailbox
1825 DAC960_V2_CommandTimeout_T CommandTimeout; /* Byte 19 */ 1818 DAC960_V2_CommandTimeout_T CommandTimeout; /* Byte 19 */
1826 unsigned char RequestSenseSize; /* Byte 20 */ 1819 unsigned char RequestSenseSize; /* Byte 20 */
1827 unsigned char IOCTL_Opcode; /* Byte 21 */ 1820 unsigned char IOCTL_Opcode; /* Byte 21 */
1828 boolean RestoreConsistency:1; /* Byte 22 Bit 0 */ 1821 bool RestoreConsistency:1; /* Byte 22 Bit 0 */
1829 boolean InitializedAreaOnly:1; /* Byte 22 Bit 1 */ 1822 bool InitializedAreaOnly:1; /* Byte 22 Bit 1 */
1830 unsigned char :6; /* Byte 22 Bits 2-7 */ 1823 unsigned char :6; /* Byte 22 Bits 2-7 */
1831 unsigned char Reserved[9]; /* Bytes 23-31 */ 1824 unsigned char Reserved[9]; /* Bytes 23-31 */
1832 DAC960_V2_DataTransferMemoryAddress_T 1825 DAC960_V2_DataTransferMemoryAddress_T
@@ -2190,7 +2183,7 @@ typedef union DAC960_V1_StatusMailbox
2190 struct { 2183 struct {
2191 DAC960_V1_CommandIdentifier_T CommandIdentifier; /* Byte 0 */ 2184 DAC960_V1_CommandIdentifier_T CommandIdentifier; /* Byte 0 */
2192 unsigned char :7; /* Byte 1 Bits 0-6 */ 2185 unsigned char :7; /* Byte 1 Bits 0-6 */
2193 boolean Valid:1; /* Byte 1 Bit 7 */ 2186 bool Valid:1; /* Byte 1 Bit 7 */
2194 DAC960_V1_CommandStatus_T CommandStatus; /* Bytes 2-3 */ 2187 DAC960_V1_CommandStatus_T CommandStatus; /* Bytes 2-3 */
2195 } Fields; 2188 } Fields;
2196} 2189}
@@ -2322,12 +2315,12 @@ typedef struct DAC960_Controller
2322 unsigned long ShutdownMonitoringTimer; 2315 unsigned long ShutdownMonitoringTimer;
2323 unsigned long LastProgressReportTime; 2316 unsigned long LastProgressReportTime;
2324 unsigned long LastCurrentStatusTime; 2317 unsigned long LastCurrentStatusTime;
2325 boolean ControllerInitialized; 2318 bool ControllerInitialized;
2326 boolean MonitoringCommandDeferred; 2319 bool MonitoringCommandDeferred;
2327 boolean EphemeralProgressMessage; 2320 bool EphemeralProgressMessage;
2328 boolean DriveSpinUpMessageDisplayed; 2321 bool DriveSpinUpMessageDisplayed;
2329 boolean MonitoringAlertMode; 2322 bool MonitoringAlertMode;
2330 boolean SuppressEnclosureMessages; 2323 bool SuppressEnclosureMessages;
2331 struct timer_list MonitoringTimer; 2324 struct timer_list MonitoringTimer;
2332 struct gendisk *disks[DAC960_MaxLogicalDrives]; 2325 struct gendisk *disks[DAC960_MaxLogicalDrives];
2333 struct pci_pool *ScatterGatherPool; 2326 struct pci_pool *ScatterGatherPool;
@@ -2342,11 +2335,11 @@ typedef struct DAC960_Controller
2342 DAC960_Command_T InitialCommand; 2335 DAC960_Command_T InitialCommand;
2343 DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth]; 2336 DAC960_Command_T *Commands[DAC960_MaxDriverQueueDepth];
2344 struct proc_dir_entry *ControllerProcEntry; 2337 struct proc_dir_entry *ControllerProcEntry;
2345 boolean LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives]; 2338 bool LogicalDriveInitiallyAccessible[DAC960_MaxLogicalDrives];
2346 void (*QueueCommand)(DAC960_Command_T *Command); 2339 void (*QueueCommand)(DAC960_Command_T *Command);
2347 boolean (*ReadControllerConfiguration)(struct DAC960_Controller *); 2340 bool (*ReadControllerConfiguration)(struct DAC960_Controller *);
2348 boolean (*ReadDeviceConfiguration)(struct DAC960_Controller *); 2341 bool (*ReadDeviceConfiguration)(struct DAC960_Controller *);
2349 boolean (*ReportDeviceConfiguration)(struct DAC960_Controller *); 2342 bool (*ReportDeviceConfiguration)(struct DAC960_Controller *);
2350 void (*QueueReadWriteCommand)(DAC960_Command_T *Command); 2343 void (*QueueReadWriteCommand)(DAC960_Command_T *Command);
2351 union { 2344 union {
2352 struct { 2345 struct {
@@ -2359,21 +2352,21 @@ typedef struct DAC960_Controller
2359 unsigned short OldEventLogSequenceNumber; 2352 unsigned short OldEventLogSequenceNumber;
2360 unsigned short DeviceStateChannel; 2353 unsigned short DeviceStateChannel;
2361 unsigned short DeviceStateTargetID; 2354 unsigned short DeviceStateTargetID;
2362 boolean DualModeMemoryMailboxInterface; 2355 bool DualModeMemoryMailboxInterface;
2363 boolean BackgroundInitializationStatusSupported; 2356 bool BackgroundInitializationStatusSupported;
2364 boolean SAFTE_EnclosureManagementEnabled; 2357 bool SAFTE_EnclosureManagementEnabled;
2365 boolean NeedLogicalDriveInformation; 2358 bool NeedLogicalDriveInformation;
2366 boolean NeedErrorTableInformation; 2359 bool NeedErrorTableInformation;
2367 boolean NeedDeviceStateInformation; 2360 bool NeedDeviceStateInformation;
2368 boolean NeedDeviceInquiryInformation; 2361 bool NeedDeviceInquiryInformation;
2369 boolean NeedDeviceSerialNumberInformation; 2362 bool NeedDeviceSerialNumberInformation;
2370 boolean NeedRebuildProgress; 2363 bool NeedRebuildProgress;
2371 boolean NeedConsistencyCheckProgress; 2364 bool NeedConsistencyCheckProgress;
2372 boolean NeedBackgroundInitializationStatus; 2365 bool NeedBackgroundInitializationStatus;
2373 boolean StartDeviceStateScan; 2366 bool StartDeviceStateScan;
2374 boolean RebuildProgressFirst; 2367 bool RebuildProgressFirst;
2375 boolean RebuildFlagPending; 2368 bool RebuildFlagPending;
2376 boolean RebuildStatusPending; 2369 bool RebuildStatusPending;
2377 2370
2378 dma_addr_t FirstCommandMailboxDMA; 2371 dma_addr_t FirstCommandMailboxDMA;
2379 DAC960_V1_CommandMailbox_T *FirstCommandMailbox; 2372 DAC960_V1_CommandMailbox_T *FirstCommandMailbox;
@@ -2432,17 +2425,17 @@ typedef struct DAC960_Controller
2432 dma_addr_t NewInquiryUnitSerialNumberDMA; 2425 dma_addr_t NewInquiryUnitSerialNumberDMA;
2433 2426
2434 int DeviceResetCount[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets]; 2427 int DeviceResetCount[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
2435 boolean DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets]; 2428 bool DirectCommandActive[DAC960_V1_MaxChannels][DAC960_V1_MaxTargets];
2436 } V1; 2429 } V1;
2437 struct { 2430 struct {
2438 unsigned int StatusChangeCounter; 2431 unsigned int StatusChangeCounter;
2439 unsigned int NextEventSequenceNumber; 2432 unsigned int NextEventSequenceNumber;
2440 unsigned int PhysicalDeviceIndex; 2433 unsigned int PhysicalDeviceIndex;
2441 boolean NeedLogicalDeviceInformation; 2434 bool NeedLogicalDeviceInformation;
2442 boolean NeedPhysicalDeviceInformation; 2435 bool NeedPhysicalDeviceInformation;
2443 boolean NeedDeviceSerialNumberInformation; 2436 bool NeedDeviceSerialNumberInformation;
2444 boolean StartLogicalDeviceInformationScan; 2437 bool StartLogicalDeviceInformationScan;
2445 boolean StartPhysicalDeviceInformationScan; 2438 bool StartPhysicalDeviceInformationScan;
2446 struct pci_pool *RequestSensePool; 2439 struct pci_pool *RequestSensePool;
2447 2440
2448 dma_addr_t FirstCommandMailboxDMA; 2441 dma_addr_t FirstCommandMailboxDMA;
@@ -2487,7 +2480,7 @@ typedef struct DAC960_Controller
2487 2480
2488 DAC960_V2_PhysicalDevice_T 2481 DAC960_V2_PhysicalDevice_T
2489 LogicalDriveToVirtualDevice[DAC960_MaxLogicalDrives]; 2482 LogicalDriveToVirtualDevice[DAC960_MaxLogicalDrives];
2490 boolean LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives]; 2483 bool LogicalDriveFoundDuringScan[DAC960_MaxLogicalDrives];
2491 } V2; 2484 } V2;
2492 } FW; 2485 } FW;
2493 unsigned char ProgressBuffer[DAC960_ProgressBufferSize]; 2486 unsigned char ProgressBuffer[DAC960_ProgressBufferSize];
@@ -2572,17 +2565,17 @@ typedef union DAC960_GEM_InboundDoorBellRegister
2572 unsigned int All; 2565 unsigned int All;
2573 struct { 2566 struct {
2574 unsigned int :24; 2567 unsigned int :24;
2575 boolean HardwareMailboxNewCommand:1; 2568 bool HardwareMailboxNewCommand:1;
2576 boolean AcknowledgeHardwareMailboxStatus:1; 2569 bool AcknowledgeHardwareMailboxStatus:1;
2577 boolean GenerateInterrupt:1; 2570 bool GenerateInterrupt:1;
2578 boolean ControllerReset:1; 2571 bool ControllerReset:1;
2579 boolean MemoryMailboxNewCommand:1; 2572 bool MemoryMailboxNewCommand:1;
2580 unsigned int :3; 2573 unsigned int :3;
2581 } Write; 2574 } Write;
2582 struct { 2575 struct {
2583 unsigned int :24; 2576 unsigned int :24;
2584 boolean HardwareMailboxFull:1; 2577 bool HardwareMailboxFull:1;
2585 boolean InitializationInProgress:1; 2578 bool InitializationInProgress:1;
2586 unsigned int :6; 2579 unsigned int :6;
2587 } Read; 2580 } Read;
2588} 2581}
@@ -2596,14 +2589,14 @@ typedef union DAC960_GEM_OutboundDoorBellRegister
2596 unsigned int All; 2589 unsigned int All;
2597 struct { 2590 struct {
2598 unsigned int :24; 2591 unsigned int :24;
2599 boolean AcknowledgeHardwareMailboxInterrupt:1; 2592 bool AcknowledgeHardwareMailboxInterrupt:1;
2600 boolean AcknowledgeMemoryMailboxInterrupt:1; 2593 bool AcknowledgeMemoryMailboxInterrupt:1;
2601 unsigned int :6; 2594 unsigned int :6;
2602 } Write; 2595 } Write;
2603 struct { 2596 struct {
2604 unsigned int :24; 2597 unsigned int :24;
2605 boolean HardwareMailboxStatusAvailable:1; 2598 bool HardwareMailboxStatusAvailable:1;
2606 boolean MemoryMailboxStatusAvailable:1; 2599 bool MemoryMailboxStatusAvailable:1;
2607 unsigned int :6; 2600 unsigned int :6;
2608 } Read; 2601 } Read;
2609} 2602}
@@ -2635,7 +2628,7 @@ typedef union DAC960_GEM_ErrorStatusRegister
2635 struct { 2628 struct {
2636 unsigned int :24; 2629 unsigned int :24;
2637 unsigned int :5; 2630 unsigned int :5;
2638 boolean ErrorStatusPending:1; 2631 bool ErrorStatusPending:1;
2639 unsigned int :2; 2632 unsigned int :2;
2640 } Bits; 2633 } Bits;
2641} 2634}
@@ -2697,7 +2690,7 @@ void DAC960_GEM_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
2697} 2690}
2698 2691
2699static inline 2692static inline
2700boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress) 2693bool DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
2701{ 2694{
2702 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister; 2695 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2703 InboundDoorBellRegister.All = 2696 InboundDoorBellRegister.All =
@@ -2707,7 +2700,7 @@ boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
2707} 2700}
2708 2701
2709static inline 2702static inline
2710boolean DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress) 2703bool DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
2711{ 2704{
2712 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister; 2705 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2713 InboundDoorBellRegister.All = 2706 InboundDoorBellRegister.All =
@@ -2748,7 +2741,7 @@ void DAC960_GEM_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
2748} 2741}
2749 2742
2750static inline 2743static inline
2751boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 2744bool DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2752{ 2745{
2753 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister; 2746 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2754 OutboundDoorBellRegister.All = 2747 OutboundDoorBellRegister.All =
@@ -2758,7 +2751,7 @@ boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseA
2758} 2751}
2759 2752
2760static inline 2753static inline
2761boolean DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 2754bool DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2762{ 2755{
2763 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister; 2756 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2764 OutboundDoorBellRegister.All = 2757 OutboundDoorBellRegister.All =
@@ -2790,7 +2783,7 @@ void DAC960_GEM_DisableInterrupts(void __iomem *ControllerBaseAddress)
2790} 2783}
2791 2784
2792static inline 2785static inline
2793boolean DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 2786bool DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
2794{ 2787{
2795 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister; 2788 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2796 InterruptMaskRegister.All = 2789 InterruptMaskRegister.All =
@@ -2834,7 +2827,7 @@ DAC960_GEM_ReadCommandStatus(void __iomem *ControllerBaseAddress)
2834 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2); 2827 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2);
2835} 2828}
2836 2829
2837static inline boolean 2830static inline bool
2838DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress, 2831DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress,
2839 unsigned char *ErrorStatus, 2832 unsigned char *ErrorStatus,
2840 unsigned char *Parameter0, 2833 unsigned char *Parameter0,
@@ -2882,16 +2875,16 @@ typedef union DAC960_BA_InboundDoorBellRegister
2882{ 2875{
2883 unsigned char All; 2876 unsigned char All;
2884 struct { 2877 struct {
2885 boolean HardwareMailboxNewCommand:1; /* Bit 0 */ 2878 bool HardwareMailboxNewCommand:1; /* Bit 0 */
2886 boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */ 2879 bool AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
2887 boolean GenerateInterrupt:1; /* Bit 2 */ 2880 bool GenerateInterrupt:1; /* Bit 2 */
2888 boolean ControllerReset:1; /* Bit 3 */ 2881 bool ControllerReset:1; /* Bit 3 */
2889 boolean MemoryMailboxNewCommand:1; /* Bit 4 */ 2882 bool MemoryMailboxNewCommand:1; /* Bit 4 */
2890 unsigned char :3; /* Bits 5-7 */ 2883 unsigned char :3; /* Bits 5-7 */
2891 } Write; 2884 } Write;
2892 struct { 2885 struct {
2893 boolean HardwareMailboxEmpty:1; /* Bit 0 */ 2886 bool HardwareMailboxEmpty:1; /* Bit 0 */
2894 boolean InitializationNotInProgress:1; /* Bit 1 */ 2887 bool InitializationNotInProgress:1; /* Bit 1 */
2895 unsigned char :6; /* Bits 2-7 */ 2888 unsigned char :6; /* Bits 2-7 */
2896 } Read; 2889 } Read;
2897} 2890}
@@ -2906,13 +2899,13 @@ typedef union DAC960_BA_OutboundDoorBellRegister
2906{ 2899{
2907 unsigned char All; 2900 unsigned char All;
2908 struct { 2901 struct {
2909 boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */ 2902 bool AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
2910 boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */ 2903 bool AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
2911 unsigned char :6; /* Bits 2-7 */ 2904 unsigned char :6; /* Bits 2-7 */
2912 } Write; 2905 } Write;
2913 struct { 2906 struct {
2914 boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */ 2907 bool HardwareMailboxStatusAvailable:1; /* Bit 0 */
2915 boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */ 2908 bool MemoryMailboxStatusAvailable:1; /* Bit 1 */
2916 unsigned char :6; /* Bits 2-7 */ 2909 unsigned char :6; /* Bits 2-7 */
2917 } Read; 2910 } Read;
2918} 2911}
@@ -2928,8 +2921,8 @@ typedef union DAC960_BA_InterruptMaskRegister
2928 unsigned char All; 2921 unsigned char All;
2929 struct { 2922 struct {
2930 unsigned int :2; /* Bits 0-1 */ 2923 unsigned int :2; /* Bits 0-1 */
2931 boolean DisableInterrupts:1; /* Bit 2 */ 2924 bool DisableInterrupts:1; /* Bit 2 */
2932 boolean DisableInterruptsI2O:1; /* Bit 3 */ 2925 bool DisableInterruptsI2O:1; /* Bit 3 */
2933 unsigned int :4; /* Bits 4-7 */ 2926 unsigned int :4; /* Bits 4-7 */
2934 } Bits; 2927 } Bits;
2935} 2928}
@@ -2945,7 +2938,7 @@ typedef union DAC960_BA_ErrorStatusRegister
2945 unsigned char All; 2938 unsigned char All;
2946 struct { 2939 struct {
2947 unsigned int :2; /* Bits 0-1 */ 2940 unsigned int :2; /* Bits 0-1 */
2948 boolean ErrorStatusPending:1; /* Bit 2 */ 2941 bool ErrorStatusPending:1; /* Bit 2 */
2949 unsigned int :5; /* Bits 3-7 */ 2942 unsigned int :5; /* Bits 3-7 */
2950 } Bits; 2943 } Bits;
2951} 2944}
@@ -3008,7 +3001,7 @@ void DAC960_BA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
3008} 3001}
3009 3002
3010static inline 3003static inline
3011boolean DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress) 3004bool DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3012{ 3005{
3013 DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister; 3006 DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
3014 InboundDoorBellRegister.All = 3007 InboundDoorBellRegister.All =
@@ -3017,7 +3010,7 @@ boolean DAC960_BA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3017} 3010}
3018 3011
3019static inline 3012static inline
3020boolean DAC960_BA_InitializationInProgressP(void __iomem *ControllerBaseAddress) 3013bool DAC960_BA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
3021{ 3014{
3022 DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister; 3015 DAC960_BA_InboundDoorBellRegister_T InboundDoorBellRegister;
3023 InboundDoorBellRegister.All = 3016 InboundDoorBellRegister.All =
@@ -3057,7 +3050,7 @@ void DAC960_BA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
3057} 3050}
3058 3051
3059static inline 3052static inline
3060boolean DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3053bool DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3061{ 3054{
3062 DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3055 DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3063 OutboundDoorBellRegister.All = 3056 OutboundDoorBellRegister.All =
@@ -3066,7 +3059,7 @@ boolean DAC960_BA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
3066} 3059}
3067 3060
3068static inline 3061static inline
3069boolean DAC960_BA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3062bool DAC960_BA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3070{ 3063{
3071 DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3064 DAC960_BA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3072 OutboundDoorBellRegister.All = 3065 OutboundDoorBellRegister.All =
@@ -3097,7 +3090,7 @@ void DAC960_BA_DisableInterrupts(void __iomem *ControllerBaseAddress)
3097} 3090}
3098 3091
3099static inline 3092static inline
3100boolean DAC960_BA_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 3093bool DAC960_BA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
3101{ 3094{
3102 DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister; 3095 DAC960_BA_InterruptMaskRegister_T InterruptMaskRegister;
3103 InterruptMaskRegister.All = 3096 InterruptMaskRegister.All =
@@ -3140,7 +3133,7 @@ DAC960_BA_ReadCommandStatus(void __iomem *ControllerBaseAddress)
3140 return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset + 2); 3133 return readw(ControllerBaseAddress + DAC960_BA_CommandStatusOffset + 2);
3141} 3134}
3142 3135
3143static inline boolean 3136static inline bool
3144DAC960_BA_ReadErrorStatus(void __iomem *ControllerBaseAddress, 3137DAC960_BA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
3145 unsigned char *ErrorStatus, 3138 unsigned char *ErrorStatus,
3146 unsigned char *Parameter0, 3139 unsigned char *Parameter0,
@@ -3188,16 +3181,16 @@ typedef union DAC960_LP_InboundDoorBellRegister
3188{ 3181{
3189 unsigned char All; 3182 unsigned char All;
3190 struct { 3183 struct {
3191 boolean HardwareMailboxNewCommand:1; /* Bit 0 */ 3184 bool HardwareMailboxNewCommand:1; /* Bit 0 */
3192 boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */ 3185 bool AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
3193 boolean GenerateInterrupt:1; /* Bit 2 */ 3186 bool GenerateInterrupt:1; /* Bit 2 */
3194 boolean ControllerReset:1; /* Bit 3 */ 3187 bool ControllerReset:1; /* Bit 3 */
3195 boolean MemoryMailboxNewCommand:1; /* Bit 4 */ 3188 bool MemoryMailboxNewCommand:1; /* Bit 4 */
3196 unsigned char :3; /* Bits 5-7 */ 3189 unsigned char :3; /* Bits 5-7 */
3197 } Write; 3190 } Write;
3198 struct { 3191 struct {
3199 boolean HardwareMailboxFull:1; /* Bit 0 */ 3192 bool HardwareMailboxFull:1; /* Bit 0 */
3200 boolean InitializationInProgress:1; /* Bit 1 */ 3193 bool InitializationInProgress:1; /* Bit 1 */
3201 unsigned char :6; /* Bits 2-7 */ 3194 unsigned char :6; /* Bits 2-7 */
3202 } Read; 3195 } Read;
3203} 3196}
@@ -3212,13 +3205,13 @@ typedef union DAC960_LP_OutboundDoorBellRegister
3212{ 3205{
3213 unsigned char All; 3206 unsigned char All;
3214 struct { 3207 struct {
3215 boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */ 3208 bool AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
3216 boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */ 3209 bool AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
3217 unsigned char :6; /* Bits 2-7 */ 3210 unsigned char :6; /* Bits 2-7 */
3218 } Write; 3211 } Write;
3219 struct { 3212 struct {
3220 boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */ 3213 bool HardwareMailboxStatusAvailable:1; /* Bit 0 */
3221 boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */ 3214 bool MemoryMailboxStatusAvailable:1; /* Bit 1 */
3222 unsigned char :6; /* Bits 2-7 */ 3215 unsigned char :6; /* Bits 2-7 */
3223 } Read; 3216 } Read;
3224} 3217}
@@ -3234,7 +3227,7 @@ typedef union DAC960_LP_InterruptMaskRegister
3234 unsigned char All; 3227 unsigned char All;
3235 struct { 3228 struct {
3236 unsigned int :2; /* Bits 0-1 */ 3229 unsigned int :2; /* Bits 0-1 */
3237 boolean DisableInterrupts:1; /* Bit 2 */ 3230 bool DisableInterrupts:1; /* Bit 2 */
3238 unsigned int :5; /* Bits 3-7 */ 3231 unsigned int :5; /* Bits 3-7 */
3239 } Bits; 3232 } Bits;
3240} 3233}
@@ -3250,7 +3243,7 @@ typedef union DAC960_LP_ErrorStatusRegister
3250 unsigned char All; 3243 unsigned char All;
3251 struct { 3244 struct {
3252 unsigned int :2; /* Bits 0-1 */ 3245 unsigned int :2; /* Bits 0-1 */
3253 boolean ErrorStatusPending:1; /* Bit 2 */ 3246 bool ErrorStatusPending:1; /* Bit 2 */
3254 unsigned int :5; /* Bits 3-7 */ 3247 unsigned int :5; /* Bits 3-7 */
3255 } Bits; 3248 } Bits;
3256} 3249}
@@ -3313,7 +3306,7 @@ void DAC960_LP_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
3313} 3306}
3314 3307
3315static inline 3308static inline
3316boolean DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress) 3309bool DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3317{ 3310{
3318 DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister; 3311 DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
3319 InboundDoorBellRegister.All = 3312 InboundDoorBellRegister.All =
@@ -3322,7 +3315,7 @@ boolean DAC960_LP_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3322} 3315}
3323 3316
3324static inline 3317static inline
3325boolean DAC960_LP_InitializationInProgressP(void __iomem *ControllerBaseAddress) 3318bool DAC960_LP_InitializationInProgressP(void __iomem *ControllerBaseAddress)
3326{ 3319{
3327 DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister; 3320 DAC960_LP_InboundDoorBellRegister_T InboundDoorBellRegister;
3328 InboundDoorBellRegister.All = 3321 InboundDoorBellRegister.All =
@@ -3362,7 +3355,7 @@ void DAC960_LP_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
3362} 3355}
3363 3356
3364static inline 3357static inline
3365boolean DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3358bool DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3366{ 3359{
3367 DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3360 DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3368 OutboundDoorBellRegister.All = 3361 OutboundDoorBellRegister.All =
@@ -3371,7 +3364,7 @@ boolean DAC960_LP_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
3371} 3364}
3372 3365
3373static inline 3366static inline
3374boolean DAC960_LP_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3367bool DAC960_LP_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3375{ 3368{
3376 DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3369 DAC960_LP_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3377 OutboundDoorBellRegister.All = 3370 OutboundDoorBellRegister.All =
@@ -3400,7 +3393,7 @@ void DAC960_LP_DisableInterrupts(void __iomem *ControllerBaseAddress)
3400} 3393}
3401 3394
3402static inline 3395static inline
3403boolean DAC960_LP_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 3396bool DAC960_LP_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
3404{ 3397{
3405 DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister; 3398 DAC960_LP_InterruptMaskRegister_T InterruptMaskRegister;
3406 InterruptMaskRegister.All = 3399 InterruptMaskRegister.All =
@@ -3442,7 +3435,7 @@ DAC960_LP_ReadCommandStatus(void __iomem *ControllerBaseAddress)
3442 return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset + 2); 3435 return readw(ControllerBaseAddress + DAC960_LP_CommandStatusOffset + 2);
3443} 3436}
3444 3437
3445static inline boolean 3438static inline bool
3446DAC960_LP_ReadErrorStatus(void __iomem *ControllerBaseAddress, 3439DAC960_LP_ReadErrorStatus(void __iomem *ControllerBaseAddress,
3447 unsigned char *ErrorStatus, 3440 unsigned char *ErrorStatus,
3448 unsigned char *Parameter0, 3441 unsigned char *Parameter0,
@@ -3502,16 +3495,16 @@ typedef union DAC960_LA_InboundDoorBellRegister
3502{ 3495{
3503 unsigned char All; 3496 unsigned char All;
3504 struct { 3497 struct {
3505 boolean HardwareMailboxNewCommand:1; /* Bit 0 */ 3498 bool HardwareMailboxNewCommand:1; /* Bit 0 */
3506 boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */ 3499 bool AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
3507 boolean GenerateInterrupt:1; /* Bit 2 */ 3500 bool GenerateInterrupt:1; /* Bit 2 */
3508 boolean ControllerReset:1; /* Bit 3 */ 3501 bool ControllerReset:1; /* Bit 3 */
3509 boolean MemoryMailboxNewCommand:1; /* Bit 4 */ 3502 bool MemoryMailboxNewCommand:1; /* Bit 4 */
3510 unsigned char :3; /* Bits 5-7 */ 3503 unsigned char :3; /* Bits 5-7 */
3511 } Write; 3504 } Write;
3512 struct { 3505 struct {
3513 boolean HardwareMailboxEmpty:1; /* Bit 0 */ 3506 bool HardwareMailboxEmpty:1; /* Bit 0 */
3514 boolean InitializationNotInProgress:1; /* Bit 1 */ 3507 bool InitializationNotInProgress:1; /* Bit 1 */
3515 unsigned char :6; /* Bits 2-7 */ 3508 unsigned char :6; /* Bits 2-7 */
3516 } Read; 3509 } Read;
3517} 3510}
@@ -3526,13 +3519,13 @@ typedef union DAC960_LA_OutboundDoorBellRegister
3526{ 3519{
3527 unsigned char All; 3520 unsigned char All;
3528 struct { 3521 struct {
3529 boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */ 3522 bool AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
3530 boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */ 3523 bool AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
3531 unsigned char :6; /* Bits 2-7 */ 3524 unsigned char :6; /* Bits 2-7 */
3532 } Write; 3525 } Write;
3533 struct { 3526 struct {
3534 boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */ 3527 bool HardwareMailboxStatusAvailable:1; /* Bit 0 */
3535 boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */ 3528 bool MemoryMailboxStatusAvailable:1; /* Bit 1 */
3536 unsigned char :6; /* Bits 2-7 */ 3529 unsigned char :6; /* Bits 2-7 */
3537 } Read; 3530 } Read;
3538} 3531}
@@ -3548,7 +3541,7 @@ typedef union DAC960_LA_InterruptMaskRegister
3548 unsigned char All; 3541 unsigned char All;
3549 struct { 3542 struct {
3550 unsigned char :2; /* Bits 0-1 */ 3543 unsigned char :2; /* Bits 0-1 */
3551 boolean DisableInterrupts:1; /* Bit 2 */ 3544 bool DisableInterrupts:1; /* Bit 2 */
3552 unsigned char :5; /* Bits 3-7 */ 3545 unsigned char :5; /* Bits 3-7 */
3553 } Bits; 3546 } Bits;
3554} 3547}
@@ -3564,7 +3557,7 @@ typedef union DAC960_LA_ErrorStatusRegister
3564 unsigned char All; 3557 unsigned char All;
3565 struct { 3558 struct {
3566 unsigned int :2; /* Bits 0-1 */ 3559 unsigned int :2; /* Bits 0-1 */
3567 boolean ErrorStatusPending:1; /* Bit 2 */ 3560 bool ErrorStatusPending:1; /* Bit 2 */
3568 unsigned int :5; /* Bits 3-7 */ 3561 unsigned int :5; /* Bits 3-7 */
3569 } Bits; 3562 } Bits;
3570} 3563}
@@ -3627,7 +3620,7 @@ void DAC960_LA_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
3627} 3620}
3628 3621
3629static inline 3622static inline
3630boolean DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress) 3623bool DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3631{ 3624{
3632 DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister; 3625 DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
3633 InboundDoorBellRegister.All = 3626 InboundDoorBellRegister.All =
@@ -3636,7 +3629,7 @@ boolean DAC960_LA_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3636} 3629}
3637 3630
3638static inline 3631static inline
3639boolean DAC960_LA_InitializationInProgressP(void __iomem *ControllerBaseAddress) 3632bool DAC960_LA_InitializationInProgressP(void __iomem *ControllerBaseAddress)
3640{ 3633{
3641 DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister; 3634 DAC960_LA_InboundDoorBellRegister_T InboundDoorBellRegister;
3642 InboundDoorBellRegister.All = 3635 InboundDoorBellRegister.All =
@@ -3676,7 +3669,7 @@ void DAC960_LA_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
3676} 3669}
3677 3670
3678static inline 3671static inline
3679boolean DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3672bool DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3680{ 3673{
3681 DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3674 DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3682 OutboundDoorBellRegister.All = 3675 OutboundDoorBellRegister.All =
@@ -3685,7 +3678,7 @@ boolean DAC960_LA_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
3685} 3678}
3686 3679
3687static inline 3680static inline
3688boolean DAC960_LA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3681bool DAC960_LA_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
3689{ 3682{
3690 DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3683 DAC960_LA_OutboundDoorBellRegister_T OutboundDoorBellRegister;
3691 OutboundDoorBellRegister.All = 3684 OutboundDoorBellRegister.All =
@@ -3714,7 +3707,7 @@ void DAC960_LA_DisableInterrupts(void __iomem *ControllerBaseAddress)
3714} 3707}
3715 3708
3716static inline 3709static inline
3717boolean DAC960_LA_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 3710bool DAC960_LA_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
3718{ 3711{
3719 DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister; 3712 DAC960_LA_InterruptMaskRegister_T InterruptMaskRegister;
3720 InterruptMaskRegister.All = 3713 InterruptMaskRegister.All =
@@ -3763,7 +3756,7 @@ DAC960_LA_ReadStatusRegister(void __iomem *ControllerBaseAddress)
3763 return readw(ControllerBaseAddress + DAC960_LA_StatusRegisterOffset); 3756 return readw(ControllerBaseAddress + DAC960_LA_StatusRegisterOffset);
3764} 3757}
3765 3758
3766static inline boolean 3759static inline bool
3767DAC960_LA_ReadErrorStatus(void __iomem *ControllerBaseAddress, 3760DAC960_LA_ReadErrorStatus(void __iomem *ControllerBaseAddress,
3768 unsigned char *ErrorStatus, 3761 unsigned char *ErrorStatus,
3769 unsigned char *Parameter0, 3762 unsigned char *Parameter0,
@@ -3822,16 +3815,16 @@ typedef union DAC960_PG_InboundDoorBellRegister
3822{ 3815{
3823 unsigned int All; 3816 unsigned int All;
3824 struct { 3817 struct {
3825 boolean HardwareMailboxNewCommand:1; /* Bit 0 */ 3818 bool HardwareMailboxNewCommand:1; /* Bit 0 */
3826 boolean AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */ 3819 bool AcknowledgeHardwareMailboxStatus:1; /* Bit 1 */
3827 boolean GenerateInterrupt:1; /* Bit 2 */ 3820 bool GenerateInterrupt:1; /* Bit 2 */
3828 boolean ControllerReset:1; /* Bit 3 */ 3821 bool ControllerReset:1; /* Bit 3 */
3829 boolean MemoryMailboxNewCommand:1; /* Bit 4 */ 3822 bool MemoryMailboxNewCommand:1; /* Bit 4 */
3830 unsigned int :27; /* Bits 5-31 */ 3823 unsigned int :27; /* Bits 5-31 */
3831 } Write; 3824 } Write;
3832 struct { 3825 struct {
3833 boolean HardwareMailboxFull:1; /* Bit 0 */ 3826 bool HardwareMailboxFull:1; /* Bit 0 */
3834 boolean InitializationInProgress:1; /* Bit 1 */ 3827 bool InitializationInProgress:1; /* Bit 1 */
3835 unsigned int :30; /* Bits 2-31 */ 3828 unsigned int :30; /* Bits 2-31 */
3836 } Read; 3829 } Read;
3837} 3830}
@@ -3846,13 +3839,13 @@ typedef union DAC960_PG_OutboundDoorBellRegister
3846{ 3839{
3847 unsigned int All; 3840 unsigned int All;
3848 struct { 3841 struct {
3849 boolean AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */ 3842 bool AcknowledgeHardwareMailboxInterrupt:1; /* Bit 0 */
3850 boolean AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */ 3843 bool AcknowledgeMemoryMailboxInterrupt:1; /* Bit 1 */
3851 unsigned int :30; /* Bits 2-31 */ 3844 unsigned int :30; /* Bits 2-31 */
3852 } Write; 3845 } Write;
3853 struct { 3846 struct {
3854 boolean HardwareMailboxStatusAvailable:1; /* Bit 0 */ 3847 bool HardwareMailboxStatusAvailable:1; /* Bit 0 */
3855 boolean MemoryMailboxStatusAvailable:1; /* Bit 1 */ 3848 bool MemoryMailboxStatusAvailable:1; /* Bit 1 */
3856 unsigned int :30; /* Bits 2-31 */ 3849 unsigned int :30; /* Bits 2-31 */
3857 } Read; 3850 } Read;
3858} 3851}
@@ -3868,7 +3861,7 @@ typedef union DAC960_PG_InterruptMaskRegister
3868 unsigned int All; 3861 unsigned int All;
3869 struct { 3862 struct {
3870 unsigned int MessageUnitInterruptMask1:2; /* Bits 0-1 */ 3863 unsigned int MessageUnitInterruptMask1:2; /* Bits 0-1 */
3871 boolean DisableInterrupts:1; /* Bit 2 */ 3864 bool DisableInterrupts:1; /* Bit 2 */
3872 unsigned int MessageUnitInterruptMask2:5; /* Bits 3-7 */ 3865 unsigned int MessageUnitInterruptMask2:5; /* Bits 3-7 */
3873 unsigned int Reserved0:24; /* Bits 8-31 */ 3866 unsigned int Reserved0:24; /* Bits 8-31 */
3874 } Bits; 3867 } Bits;
@@ -3885,7 +3878,7 @@ typedef union DAC960_PG_ErrorStatusRegister
3885 unsigned char All; 3878 unsigned char All;
3886 struct { 3879 struct {
3887 unsigned int :2; /* Bits 0-1 */ 3880 unsigned int :2; /* Bits 0-1 */
3888 boolean ErrorStatusPending:1; /* Bit 2 */ 3881 bool ErrorStatusPending:1; /* Bit 2 */
3889 unsigned int :5; /* Bits 3-7 */ 3882 unsigned int :5; /* Bits 3-7 */
3890 } Bits; 3883 } Bits;
3891} 3884}
@@ -3948,7 +3941,7 @@ void DAC960_PG_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
3948} 3941}
3949 3942
3950static inline 3943static inline
3951boolean DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress) 3944bool DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3952{ 3945{
3953 DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister; 3946 DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
3954 InboundDoorBellRegister.All = 3947 InboundDoorBellRegister.All =
@@ -3957,7 +3950,7 @@ boolean DAC960_PG_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
3957} 3950}
3958 3951
3959static inline 3952static inline
3960boolean DAC960_PG_InitializationInProgressP(void __iomem *ControllerBaseAddress) 3953bool DAC960_PG_InitializationInProgressP(void __iomem *ControllerBaseAddress)
3961{ 3954{
3962 DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister; 3955 DAC960_PG_InboundDoorBellRegister_T InboundDoorBellRegister;
3963 InboundDoorBellRegister.All = 3956 InboundDoorBellRegister.All =
@@ -3997,7 +3990,7 @@ void DAC960_PG_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
3997} 3990}
3998 3991
3999static inline 3992static inline
4000boolean DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 3993bool DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
4001{ 3994{
4002 DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister; 3995 DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
4003 OutboundDoorBellRegister.All = 3996 OutboundDoorBellRegister.All =
@@ -4006,7 +3999,7 @@ boolean DAC960_PG_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAd
4006} 3999}
4007 4000
4008static inline 4001static inline
4009boolean DAC960_PG_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress) 4002bool DAC960_PG_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
4010{ 4003{
4011 DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister; 4004 DAC960_PG_OutboundDoorBellRegister_T OutboundDoorBellRegister;
4012 OutboundDoorBellRegister.All = 4005 OutboundDoorBellRegister.All =
@@ -4039,7 +4032,7 @@ void DAC960_PG_DisableInterrupts(void __iomem *ControllerBaseAddress)
4039} 4032}
4040 4033
4041static inline 4034static inline
4042boolean DAC960_PG_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 4035bool DAC960_PG_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
4043{ 4036{
4044 DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister; 4037 DAC960_PG_InterruptMaskRegister_T InterruptMaskRegister;
4045 InterruptMaskRegister.All = 4038 InterruptMaskRegister.All =
@@ -4088,7 +4081,7 @@ DAC960_PG_ReadStatusRegister(void __iomem *ControllerBaseAddress)
4088 return readw(ControllerBaseAddress + DAC960_PG_StatusRegisterOffset); 4081 return readw(ControllerBaseAddress + DAC960_PG_StatusRegisterOffset);
4089} 4082}
4090 4083
4091static inline boolean 4084static inline bool
4092DAC960_PG_ReadErrorStatus(void __iomem *ControllerBaseAddress, 4085DAC960_PG_ReadErrorStatus(void __iomem *ControllerBaseAddress,
4093 unsigned char *ErrorStatus, 4086 unsigned char *ErrorStatus,
4094 unsigned char *Parameter0, 4087 unsigned char *Parameter0,
@@ -4147,15 +4140,15 @@ typedef union DAC960_PD_InboundDoorBellRegister
4147{ 4140{
4148 unsigned char All; 4141 unsigned char All;
4149 struct { 4142 struct {
4150 boolean NewCommand:1; /* Bit 0 */ 4143 bool NewCommand:1; /* Bit 0 */
4151 boolean AcknowledgeStatus:1; /* Bit 1 */ 4144 bool AcknowledgeStatus:1; /* Bit 1 */
4152 boolean GenerateInterrupt:1; /* Bit 2 */ 4145 bool GenerateInterrupt:1; /* Bit 2 */
4153 boolean ControllerReset:1; /* Bit 3 */ 4146 bool ControllerReset:1; /* Bit 3 */
4154 unsigned char :4; /* Bits 4-7 */ 4147 unsigned char :4; /* Bits 4-7 */
4155 } Write; 4148 } Write;
4156 struct { 4149 struct {
4157 boolean MailboxFull:1; /* Bit 0 */ 4150 bool MailboxFull:1; /* Bit 0 */
4158 boolean InitializationInProgress:1; /* Bit 1 */ 4151 bool InitializationInProgress:1; /* Bit 1 */
4159 unsigned char :6; /* Bits 2-7 */ 4152 unsigned char :6; /* Bits 2-7 */
4160 } Read; 4153 } Read;
4161} 4154}
@@ -4170,11 +4163,11 @@ typedef union DAC960_PD_OutboundDoorBellRegister
4170{ 4163{
4171 unsigned char All; 4164 unsigned char All;
4172 struct { 4165 struct {
4173 boolean AcknowledgeInterrupt:1; /* Bit 0 */ 4166 bool AcknowledgeInterrupt:1; /* Bit 0 */
4174 unsigned char :7; /* Bits 1-7 */ 4167 unsigned char :7; /* Bits 1-7 */
4175 } Write; 4168 } Write;
4176 struct { 4169 struct {
4177 boolean StatusAvailable:1; /* Bit 0 */ 4170 bool StatusAvailable:1; /* Bit 0 */
4178 unsigned char :7; /* Bits 1-7 */ 4171 unsigned char :7; /* Bits 1-7 */
4179 } Read; 4172 } Read;
4180} 4173}
@@ -4189,7 +4182,7 @@ typedef union DAC960_PD_InterruptEnableRegister
4189{ 4182{
4190 unsigned char All; 4183 unsigned char All;
4191 struct { 4184 struct {
4192 boolean EnableInterrupts:1; /* Bit 0 */ 4185 bool EnableInterrupts:1; /* Bit 0 */
4193 unsigned char :7; /* Bits 1-7 */ 4186 unsigned char :7; /* Bits 1-7 */
4194 } Bits; 4187 } Bits;
4195} 4188}
@@ -4205,7 +4198,7 @@ typedef union DAC960_PD_ErrorStatusRegister
4205 unsigned char All; 4198 unsigned char All;
4206 struct { 4199 struct {
4207 unsigned int :2; /* Bits 0-1 */ 4200 unsigned int :2; /* Bits 0-1 */
4208 boolean ErrorStatusPending:1; /* Bit 2 */ 4201 bool ErrorStatusPending:1; /* Bit 2 */
4209 unsigned int :5; /* Bits 3-7 */ 4202 unsigned int :5; /* Bits 3-7 */
4210 } Bits; 4203 } Bits;
4211} 4204}
@@ -4258,7 +4251,7 @@ void DAC960_PD_ControllerReset(void __iomem *ControllerBaseAddress)
4258} 4251}
4259 4252
4260static inline 4253static inline
4261boolean DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress) 4254bool DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
4262{ 4255{
4263 DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister; 4256 DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
4264 InboundDoorBellRegister.All = 4257 InboundDoorBellRegister.All =
@@ -4267,7 +4260,7 @@ boolean DAC960_PD_MailboxFullP(void __iomem *ControllerBaseAddress)
4267} 4260}
4268 4261
4269static inline 4262static inline
4270boolean DAC960_PD_InitializationInProgressP(void __iomem *ControllerBaseAddress) 4263bool DAC960_PD_InitializationInProgressP(void __iomem *ControllerBaseAddress)
4271{ 4264{
4272 DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister; 4265 DAC960_PD_InboundDoorBellRegister_T InboundDoorBellRegister;
4273 InboundDoorBellRegister.All = 4266 InboundDoorBellRegister.All =
@@ -4286,7 +4279,7 @@ void DAC960_PD_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
4286} 4279}
4287 4280
4288static inline 4281static inline
4289boolean DAC960_PD_StatusAvailableP(void __iomem *ControllerBaseAddress) 4282bool DAC960_PD_StatusAvailableP(void __iomem *ControllerBaseAddress)
4290{ 4283{
4291 DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister; 4284 DAC960_PD_OutboundDoorBellRegister_T OutboundDoorBellRegister;
4292 OutboundDoorBellRegister.All = 4285 OutboundDoorBellRegister.All =
@@ -4315,7 +4308,7 @@ void DAC960_PD_DisableInterrupts(void __iomem *ControllerBaseAddress)
4315} 4308}
4316 4309
4317static inline 4310static inline
4318boolean DAC960_PD_InterruptsEnabledP(void __iomem *ControllerBaseAddress) 4311bool DAC960_PD_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
4319{ 4312{
4320 DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister; 4313 DAC960_PD_InterruptEnableRegister_T InterruptEnableRegister;
4321 InterruptEnableRegister.All = 4314 InterruptEnableRegister.All =
@@ -4350,7 +4343,7 @@ DAC960_PD_ReadStatusRegister(void __iomem *ControllerBaseAddress)
4350 return readw(ControllerBaseAddress + DAC960_PD_StatusRegisterOffset); 4343 return readw(ControllerBaseAddress + DAC960_PD_StatusRegisterOffset);
4351} 4344}
4352 4345
4353static inline boolean 4346static inline bool
4354DAC960_PD_ReadErrorStatus(void __iomem *ControllerBaseAddress, 4347DAC960_PD_ReadErrorStatus(void __iomem *ControllerBaseAddress,
4355 unsigned char *ErrorStatus, 4348 unsigned char *ErrorStatus,
4356 unsigned char *Parameter0, 4349 unsigned char *Parameter0,
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 58c1debf86f1..cacb1c816e35 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -417,8 +417,10 @@ config BLK_DEV_INITRD
417 etc. See <file:Documentation/initrd.txt> for details. 417 etc. See <file:Documentation/initrd.txt> for details.
418 418
419 If RAM disk support (BLK_DEV_RAM) is also included, this 419 If RAM disk support (BLK_DEV_RAM) is also included, this
420 also enables initial RAM disk (initrd) support. 420 also enables initial RAM disk (initrd) support and adds
421 15 Kbytes (more on some other architectures) to the kernel size.
421 422
423 If unsure say Y.
422 424
423config CDROM_PKTCDVD 425config CDROM_PKTCDVD
424 tristate "Packet writing on CD/DVD media" 426 tristate "Packet writing on CD/DVD media"
diff --git a/drivers/block/paride/Kconfig b/drivers/block/paride/Kconfig
index c0d2854dd097..28cf3082d442 100644
--- a/drivers/block/paride/Kconfig
+++ b/drivers/block/paride/Kconfig
@@ -2,14 +2,8 @@
2# PARIDE configuration 2# PARIDE configuration
3# 3#
4# PARIDE doesn't need PARPORT, but if PARPORT is configured as a module, 4# PARIDE doesn't need PARPORT, but if PARPORT is configured as a module,
5# PARIDE must also be a module. The bogus CONFIG_PARIDE_PARPORT option 5# PARIDE must also be a module.
6# controls the choices given to the user ...
7# PARIDE only supports PC style parports. Tough for USB or other parports... 6# PARIDE only supports PC style parports. Tough for USB or other parports...
8config PARIDE_PARPORT
9 tristate
10 depends on PARIDE!=n
11 default m if PARPORT_PC=m
12 default y if PARPORT_PC!=m
13 7
14comment "Parallel IDE high-level drivers" 8comment "Parallel IDE high-level drivers"
15 depends on PARIDE 9 depends on PARIDE
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 62462190e07e..c0e89490e3d5 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -190,15 +190,6 @@ static struct attribute *kobj_pkt_attrs_wqueue[] = {
190 NULL 190 NULL
191}; 191};
192 192
193/* declares a char buffer[64] _dbuf, copies data from
194 * _b with length _l into it and ensures that _dbuf ends
195 * with a \0 character.
196 */
197#define DECLARE_BUF_AS_STRING(_dbuf, _b, _l) \
198 char _dbuf[64]; int dlen = (_l) < 0 ? 0 : (_l); \
199 if (dlen >= sizeof(_dbuf)) dlen = sizeof(_dbuf)-1; \
200 memcpy(_dbuf, _b, dlen); _dbuf[dlen] = 0
201
202static ssize_t kobj_pkt_show(struct kobject *kobj, 193static ssize_t kobj_pkt_show(struct kobject *kobj,
203 struct attribute *attr, char *data) 194 struct attribute *attr, char *data)
204{ 195{
@@ -264,9 +255,8 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
264{ 255{
265 struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd; 256 struct pktcdvd_device *pd = to_pktcdvdkobj(kobj)->pd;
266 int val; 257 int val;
267 DECLARE_BUF_AS_STRING(dbuf, data, len); /* ensure sscanf scans a string */
268 258
269 if (strcmp(attr->name, "reset") == 0 && dlen > 0) { 259 if (strcmp(attr->name, "reset") == 0 && len > 0) {
270 pd->stats.pkt_started = 0; 260 pd->stats.pkt_started = 0;
271 pd->stats.pkt_ended = 0; 261 pd->stats.pkt_ended = 0;
272 pd->stats.secs_w = 0; 262 pd->stats.secs_w = 0;
@@ -274,7 +264,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
274 pd->stats.secs_r = 0; 264 pd->stats.secs_r = 0;
275 265
276 } else if (strcmp(attr->name, "congestion_off") == 0 266 } else if (strcmp(attr->name, "congestion_off") == 0
277 && sscanf(dbuf, "%d", &val) == 1) { 267 && sscanf(data, "%d", &val) == 1) {
278 spin_lock(&pd->lock); 268 spin_lock(&pd->lock);
279 pd->write_congestion_off = val; 269 pd->write_congestion_off = val;
280 init_write_congestion_marks(&pd->write_congestion_off, 270 init_write_congestion_marks(&pd->write_congestion_off,
@@ -282,7 +272,7 @@ static ssize_t kobj_pkt_store(struct kobject *kobj,
282 spin_unlock(&pd->lock); 272 spin_unlock(&pd->lock);
283 273
284 } else if (strcmp(attr->name, "congestion_on") == 0 274 } else if (strcmp(attr->name, "congestion_on") == 0
285 && sscanf(dbuf, "%d", &val) == 1) { 275 && sscanf(data, "%d", &val) == 1) {
286 spin_lock(&pd->lock); 276 spin_lock(&pd->lock);
287 pd->write_congestion_on = val; 277 pd->write_congestion_on = val;
288 init_write_congestion_marks(&pd->write_congestion_off, 278 init_write_congestion_marks(&pd->write_congestion_off,
@@ -369,8 +359,7 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
369 size_t count) 359 size_t count)
370{ 360{
371 unsigned int major, minor; 361 unsigned int major, minor;
372 DECLARE_BUF_AS_STRING(dbuf, buf, count); 362 if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
373 if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
374 pkt_setup_dev(MKDEV(major, minor), NULL); 363 pkt_setup_dev(MKDEV(major, minor), NULL);
375 return count; 364 return count;
376 } 365 }
@@ -381,8 +370,7 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, const char *buf,
381 size_t count) 370 size_t count)
382{ 371{
383 unsigned int major, minor; 372 unsigned int major, minor;
384 DECLARE_BUF_AS_STRING(dbuf, buf, count); 373 if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
385 if (sscanf(dbuf, "%u:%u", &major, &minor) == 2) {
386 pkt_remove_dev(MKDEV(major, minor)); 374 pkt_remove_dev(MKDEV(major, minor));
387 return count; 375 return count;
388 } 376 }
@@ -1377,7 +1365,7 @@ try_next_bio:
1377 && pd->bio_queue_size <= pd->write_congestion_off); 1365 && pd->bio_queue_size <= pd->write_congestion_off);
1378 spin_unlock(&pd->lock); 1366 spin_unlock(&pd->lock);
1379 if (wakeup) 1367 if (wakeup)
1380 blk_clear_queue_congested(pd->disk->queue, WRITE); 1368 clear_bdi_congested(&pd->disk->queue->backing_dev_info, WRITE);
1381 1369
1382 pkt->sleep_time = max(PACKET_WAIT_TIME, 1); 1370 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
1383 pkt_set_state(pkt, PACKET_WAITING_STATE); 1371 pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2598,7 +2586,7 @@ static int pkt_make_request(request_queue_t *q, struct bio *bio)
2598 spin_lock(&pd->lock); 2586 spin_lock(&pd->lock);
2599 if (pd->write_congestion_on > 0 2587 if (pd->write_congestion_on > 0
2600 && pd->bio_queue_size >= pd->write_congestion_on) { 2588 && pd->bio_queue_size >= pd->write_congestion_on) {
2601 blk_set_queue_congested(q, WRITE); 2589 set_bdi_congested(&q->backing_dev_info, WRITE);
2602 do { 2590 do {
2603 spin_unlock(&pd->lock); 2591 spin_unlock(&pd->lock);
2604 congestion_wait(WRITE, HZ); 2592 congestion_wait(WRITE, HZ);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index d08bb4ee1307..d0a6dc53213c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -191,7 +191,7 @@ config MOXA_INTELLIO
191 module will be called moxa. 191 module will be called moxa.
192 192
193config MOXA_SMARTIO 193config MOXA_SMARTIO
194 tristate "Moxa SmartIO support" 194 tristate "Moxa SmartIO support (OBSOLETE)"
195 depends on SERIAL_NONSTANDARD 195 depends on SERIAL_NONSTANDARD
196 help 196 help
197 Say Y here if you have a Moxa SmartIO multiport serial card. 197 Say Y here if you have a Moxa SmartIO multiport serial card.
@@ -202,7 +202,7 @@ config MOXA_SMARTIO
202 here. 202 here.
203 203
204config MOXA_SMARTIO_NEW 204config MOXA_SMARTIO_NEW
205 tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)" 205 tristate "Moxa SmartIO support v. 2.0"
206 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) 206 depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
207 help 207 help
208 Say Y here if you have a Moxa SmartIO multiport serial card and/or 208 Say Y here if you have a Moxa SmartIO multiport serial card and/or
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index feb4ac802a0d..0e2b72f2b887 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -527,10 +527,8 @@ static void do_softint(unsigned long private_)
527 if (!tty) 527 if (!tty)
528 return; 528 return;
529 529
530 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { 530 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
531 tty_wakeup(tty); 531 tty_wakeup(tty);
532 wake_up_interruptible(&tty->write_wait);
533 }
534} 532}
535 533
536/* 534/*
@@ -904,8 +902,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
904 if (!info->xmit.buf) 902 if (!info->xmit.buf)
905 return 0; 903 return 0;
906 904
907 local_save_flags(flags); 905 local_irq_save(flags);
908 local_irq_disable();
909 while (1) { 906 while (1) {
910 c = CIRC_SPACE_TO_END(info->xmit.head, 907 c = CIRC_SPACE_TO_END(info->xmit.head,
911 info->xmit.tail, 908 info->xmit.tail,
@@ -968,7 +965,6 @@ static void rs_flush_buffer(struct tty_struct *tty)
968 local_irq_save(flags); 965 local_irq_save(flags);
969 info->xmit.head = info->xmit.tail = 0; 966 info->xmit.head = info->xmit.tail = 0;
970 local_irq_restore(flags); 967 local_irq_restore(flags);
971 wake_up_interruptible(&tty->write_wait);
972 tty_wakeup(tty); 968 tty_wakeup(tty);
973} 969}
974 970
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 3ffa0807754c..363beb165729 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -4488,7 +4488,6 @@ static void cy_flush_buffer(struct tty_struct *tty)
4488 CY_UNLOCK(info, flags); 4488 CY_UNLOCK(info, flags);
4489 } 4489 }
4490 tty_wakeup(tty); 4490 tty_wakeup(tty);
4491 wake_up_interruptible(&tty->write_wait);
4492} /* cy_flush_buffer */ 4491} /* cy_flush_buffer */
4493 4492
4494/* 4493/*
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index a0f822c9d74d..88fc24fc4392 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -844,7 +844,6 @@ static void pc_flush_buffer(struct tty_struct *tty)
844 fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); 844 fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
845 memoff(ch); 845 memoff(ch);
846 spin_unlock_irqrestore(&epca_lock, flags); 846 spin_unlock_irqrestore(&epca_lock, flags);
847 wake_up_interruptible(&tty->write_wait);
848 tty_wakeup(tty); 847 tty_wakeup(tty);
849} /* End pc_flush_buffer */ 848} /* End pc_flush_buffer */
850 849
@@ -1795,7 +1794,6 @@ static void doevent(int crd)
1795 { /* Begin if LOWWAIT */ 1794 { /* Begin if LOWWAIT */
1796 ch->statusflags &= ~LOWWAIT; 1795 ch->statusflags &= ~LOWWAIT;
1797 tty_wakeup(tty); 1796 tty_wakeup(tty);
1798 wake_up_interruptible(&tty->write_wait);
1799 } /* End if LOWWAIT */ 1797 } /* End if LOWWAIT */
1800 } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */ 1798 } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */
1801 /* This event is generated by setup_empty_event */ 1799 /* This event is generated by setup_empty_event */
@@ -1803,7 +1801,6 @@ static void doevent(int crd)
1803 if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ 1801 if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */
1804 ch->statusflags &= ~EMPTYWAIT; 1802 ch->statusflags &= ~EMPTYWAIT;
1805 tty_wakeup(tty); 1803 tty_wakeup(tty);
1806 wake_up_interruptible(&tty->write_wait);
1807 } /* End if EMPTYWAIT */ 1804 } /* End if EMPTYWAIT */
1808 } /* End EMPTYTX_IND */ 1805 } /* End EMPTYTX_IND */
1809 } /* End if valid tty */ 1806 } /* End if valid tty */
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index e769811e7417..337bbcdcf13d 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -382,7 +382,6 @@ void gs_flush_buffer(struct tty_struct *tty)
382 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 382 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
383 spin_unlock_irqrestore (&port->driver_lock, flags); 383 spin_unlock_irqrestore (&port->driver_lock, flags);
384 384
385 wake_up_interruptible(&tty->write_wait);
386 tty_wakeup(tty); 385 tty_wakeup(tty);
387 func_exit (); 386 func_exit ();
388} 387}
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 78045767ec33..88b9d338da53 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -1373,15 +1373,7 @@ ip2_owake( PTTY tp)
1373 ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags, 1373 ip2trace (CHANN, ITRC_SICMD, 10, 2, tp->flags,
1374 (1 << TTY_DO_WRITE_WAKEUP) ); 1374 (1 << TTY_DO_WRITE_WAKEUP) );
1375 1375
1376 wake_up_interruptible ( &tp->write_wait ); 1376 tty_wakeup(tp);
1377 if ( ( tp->flags & (1 << TTY_DO_WRITE_WAKEUP) )
1378 && tp->ldisc.write_wakeup )
1379 {
1380 (tp->ldisc.write_wakeup) ( tp );
1381
1382 ip2trace (CHANN, ITRC_SICMD, 11, 0 );
1383
1384 }
1385} 1377}
1386 1378
1387static inline void 1379static inline void
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 53582b53da95..3aff5e99b674 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -406,13 +406,14 @@ static void clean_up_interface_data(ipmi_smi_t intf)
406 free_smi_msg_list(&intf->waiting_msgs); 406 free_smi_msg_list(&intf->waiting_msgs);
407 free_recv_msg_list(&intf->waiting_events); 407 free_recv_msg_list(&intf->waiting_events);
408 408
409 /* Wholesale remove all the entries from the list in the 409 /*
410 * interface and wait for RCU to know that none are in use. */ 410 * Wholesale remove all the entries from the list in the
411 * interface and wait for RCU to know that none are in use.
412 */
411 mutex_lock(&intf->cmd_rcvrs_mutex); 413 mutex_lock(&intf->cmd_rcvrs_mutex);
412 list_add_rcu(&list, &intf->cmd_rcvrs); 414 INIT_LIST_HEAD(&list);
413 list_del_rcu(&intf->cmd_rcvrs); 415 list_splice_init_rcu(&intf->cmd_rcvrs, &list, synchronize_rcu);
414 mutex_unlock(&intf->cmd_rcvrs_mutex); 416 mutex_unlock(&intf->cmd_rcvrs_mutex);
415 synchronize_rcu();
416 417
417 list_for_each_entry_safe(rcvr, rcvr2, &list, link) 418 list_for_each_entry_safe(rcvr, rcvr2, &list, link)
418 kfree(rcvr); 419 kfree(rcvr);
@@ -451,7 +452,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
451 mutex_lock(&ipmi_interfaces_mutex); 452 mutex_lock(&ipmi_interfaces_mutex);
452 453
453 /* Build a list of things to deliver. */ 454 /* Build a list of things to deliver. */
454 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 455 list_for_each_entry(intf, &ipmi_interfaces, link) {
455 if (intf->intf_num == -1) 456 if (intf->intf_num == -1)
456 continue; 457 continue;
457 e = kmalloc(sizeof(*e), GFP_KERNEL); 458 e = kmalloc(sizeof(*e), GFP_KERNEL);
@@ -1886,7 +1887,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1886 kfree(entry); 1887 kfree(entry);
1887 rv = -ENOMEM; 1888 rv = -ENOMEM;
1888 } else { 1889 } else {
1889 file->nlink = 1;
1890 file->data = data; 1890 file->data = data;
1891 file->read_proc = read_proc; 1891 file->read_proc = read_proc;
1892 file->write_proc = write_proc; 1892 file->write_proc = write_proc;
@@ -2760,9 +2760,15 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2760 synchronize_rcu(); 2760 synchronize_rcu();
2761 kref_put(&intf->refcount, intf_free); 2761 kref_put(&intf->refcount, intf_free);
2762 } else { 2762 } else {
2763 /* After this point the interface is legal to use. */ 2763 /*
2764 * Keep memory order straight for RCU readers. Make
2765 * sure everything else is committed to memory before
2766 * setting intf_num to mark the interface valid.
2767 */
2768 smp_wmb();
2764 intf->intf_num = i; 2769 intf->intf_num = i;
2765 mutex_unlock(&ipmi_interfaces_mutex); 2770 mutex_unlock(&ipmi_interfaces_mutex);
2771 /* After this point the interface is legal to use. */
2766 call_smi_watchers(i, intf->si_dev); 2772 call_smi_watchers(i, intf->si_dev);
2767 mutex_unlock(&smi_watchers_mutex); 2773 mutex_unlock(&smi_watchers_mutex);
2768 } 2774 }
@@ -3923,6 +3929,14 @@ static void send_panic_events(char *str)
3923 /* Interface was not ready yet. */ 3929 /* Interface was not ready yet. */
3924 continue; 3930 continue;
3925 3931
3932 /*
3933 * intf_num is used as an marker to tell if the
3934 * interface is valid. Thus we need a read barrier to
3935 * make sure data fetched before checking intf_num
3936 * won't be used.
3937 */
3938 smp_rmb();
3939
3926 /* First job here is to figure out where to send the 3940 /* First job here is to figure out where to send the
3927 OEM events. There's no way in IPMI to send OEM 3941 OEM events. There's no way in IPMI to send OEM
3928 events using an event send command, so we have to 3942 events using an event send command, so we have to
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 01084abffddf..43ab9edc76f5 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -183,7 +183,7 @@ static DEFINE_TIMER(tx, isicom_tx, 0, 0);
183/* baud index mappings from linux defns to isi */ 183/* baud index mappings from linux defns to isi */
184 184
185static signed char linuxb_to_isib[] = { 185static signed char linuxb_to_isib[] = {
186 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19 186 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 20, 21
187}; 187};
188 188
189struct isi_board { 189struct isi_board {
@@ -213,8 +213,6 @@ struct isi_port {
213 struct tty_struct * tty; 213 struct tty_struct * tty;
214 wait_queue_head_t close_wait; 214 wait_queue_head_t close_wait;
215 wait_queue_head_t open_wait; 215 wait_queue_head_t open_wait;
216 struct work_struct hangup_tq;
217 struct work_struct bh_tqueue;
218 unsigned char * xmit_buf; 216 unsigned char * xmit_buf;
219 int xmit_head; 217 int xmit_head;
220 int xmit_tail; 218 int xmit_tail;
@@ -510,7 +508,7 @@ static void isicom_tx(unsigned long _data)
510 if (port->xmit_cnt <= 0) 508 if (port->xmit_cnt <= 0)
511 port->status &= ~ISI_TXOK; 509 port->status &= ~ISI_TXOK;
512 if (port->xmit_cnt <= WAKEUP_CHARS) 510 if (port->xmit_cnt <= WAKEUP_CHARS)
513 schedule_work(&port->bh_tqueue); 511 tty_wakeup(tty);
514 unlock_card(&isi_card[card]); 512 unlock_card(&isi_card[card]);
515 } 513 }
516 514
@@ -524,21 +522,6 @@ sched_again:
524 mod_timer(&tx, jiffies + msecs_to_jiffies(10)); 522 mod_timer(&tx, jiffies + msecs_to_jiffies(10));
525} 523}
526 524
527/* Interrupt handlers */
528
529
530static void isicom_bottomhalf(struct work_struct *work)
531{
532 struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
533 struct tty_struct *tty = port->tty;
534
535 if (!tty)
536 return;
537
538 tty_wakeup(tty);
539 wake_up_interruptible(&tty->write_wait);
540}
541
542/* 525/*
543 * Main interrupt handler routine 526 * Main interrupt handler routine
544 */ 527 */
@@ -557,6 +540,11 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
557 return IRQ_NONE; 540 return IRQ_NONE;
558 541
559 base = card->base; 542 base = card->base;
543
544 /* did the card interrupt us? */
545 if (!(inw(base + 0x0e) & 0x02))
546 return IRQ_NONE;
547
560 spin_lock(&card->card_lock); 548 spin_lock(&card->card_lock);
561 549
562 /* 550 /*
@@ -581,6 +569,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
581 port = card->ports + channel; 569 port = card->ports + channel;
582 if (!(port->flags & ASYNC_INITIALIZED)) { 570 if (!(port->flags & ASYNC_INITIALIZED)) {
583 outw(0x0000, base+0x04); /* enable interrupts */ 571 outw(0x0000, base+0x04); /* enable interrupts */
572 spin_unlock(&card->card_lock);
584 return IRQ_HANDLED; 573 return IRQ_HANDLED;
585 } 574 }
586 575
@@ -609,7 +598,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
609 pr_dbg("interrupt: DCD->low.\n" 598 pr_dbg("interrupt: DCD->low.\n"
610 ); 599 );
611 port->status &= ~ISI_DCD; 600 port->status &= ~ISI_DCD;
612 schedule_work(&port->hangup_tq); 601 tty_hangup(tty);
613 } 602 }
614 } else if (header & ISI_DCD) { 603 } else if (header & ISI_DCD) {
615 /* Carrier has been detected */ 604 /* Carrier has been detected */
@@ -631,7 +620,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
631 /* start tx ing */ 620 /* start tx ing */
632 port->status |= (ISI_TXOK 621 port->status |= (ISI_TXOK
633 | ISI_CTS); 622 | ISI_CTS);
634 schedule_work(&port->bh_tqueue); 623 tty_wakeup(tty);
635 } 624 }
636 } else if (!(header & ISI_CTS)) { 625 } else if (!(header & ISI_CTS)) {
637 port->tty->hw_stopped = 1; 626 port->tty->hw_stopped = 1;
@@ -695,6 +684,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
695 tty_flip_buffer_push(tty); 684 tty_flip_buffer_push(tty);
696 } 685 }
697 outw(0x0000, base+0x04); /* enable interrupts */ 686 outw(0x0000, base+0x04); /* enable interrupts */
687 spin_unlock(&card->card_lock);
698 688
699 return IRQ_HANDLED; 689 return IRQ_HANDLED;
700} 690}
@@ -720,7 +710,8 @@ static void isicom_config_port(struct isi_port *port)
720 * respectively. 710 * respectively.
721 */ 711 */
722 712
723 if (baud < 1 || baud > 2) 713 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */
714 if (baud < 1 || baud > 4)
724 port->tty->termios->c_cflag &= ~CBAUDEX; 715 port->tty->termios->c_cflag &= ~CBAUDEX;
725 else 716 else
726 baud += 15; 717 baud += 15;
@@ -736,6 +727,10 @@ static void isicom_config_port(struct isi_port *port)
736 baud++; /* 57.6 Kbps */ 727 baud++; /* 57.6 Kbps */
737 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 728 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
738 baud +=2; /* 115 Kbps */ 729 baud +=2; /* 115 Kbps */
730 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
731 baud += 3; /* 230 kbps*/
732 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
733 baud += 4; /* 460 kbps*/
739 } 734 }
740 if (linuxb_to_isib[baud] == -1) { 735 if (linuxb_to_isib[baud] == -1) {
741 /* hang up */ 736 /* hang up */
@@ -1460,17 +1455,6 @@ static void isicom_start(struct tty_struct *tty)
1460 port->status |= ISI_TXOK; 1455 port->status |= ISI_TXOK;
1461} 1456}
1462 1457
1463/* hangup et all */
1464static void do_isicom_hangup(struct work_struct *work)
1465{
1466 struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
1467 struct tty_struct *tty;
1468
1469 tty = port->tty;
1470 if (tty)
1471 tty_hangup(tty);
1472}
1473
1474static void isicom_hangup(struct tty_struct *tty) 1458static void isicom_hangup(struct tty_struct *tty)
1475{ 1459{
1476 struct isi_port *port = tty->driver_data; 1460 struct isi_port *port = tty->driver_data;
@@ -1503,7 +1487,6 @@ static void isicom_flush_buffer(struct tty_struct *tty)
1503 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1487 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1504 spin_unlock_irqrestore(&card->card_lock, flags); 1488 spin_unlock_irqrestore(&card->card_lock, flags);
1505 1489
1506 wake_up_interruptible(&tty->write_wait);
1507 tty_wakeup(tty); 1490 tty_wakeup(tty);
1508} 1491}
1509 1492
@@ -1536,7 +1519,7 @@ static int __devinit reset_card(struct pci_dev *pdev,
1536{ 1519{
1537 struct isi_board *board = pci_get_drvdata(pdev); 1520 struct isi_board *board = pci_get_drvdata(pdev);
1538 unsigned long base = board->base; 1521 unsigned long base = board->base;
1539 unsigned int portcount = 0; 1522 unsigned int sig, portcount = 0;
1540 int retval = 0; 1523 int retval = 0;
1541 1524
1542 dev_dbg(&pdev->dev, "ISILoad:Resetting Card%d at 0x%lx\n", card + 1, 1525 dev_dbg(&pdev->dev, "ISILoad:Resetting Card%d at 0x%lx\n", card + 1,
@@ -1544,27 +1527,35 @@ static int __devinit reset_card(struct pci_dev *pdev,
1544 1527
1545 inw(base + 0x8); 1528 inw(base + 0x8);
1546 1529
1547 mdelay(10); 1530 msleep(10);
1548 1531
1549 outw(0, base + 0x8); /* Reset */ 1532 outw(0, base + 0x8); /* Reset */
1550 1533
1551 msleep(3000); 1534 msleep(1000);
1552 1535
1553 *signature = inw(base + 0x4) & 0xff; 1536 sig = inw(base + 0x4) & 0xff;
1537
1538 if (sig != 0xa5 && sig != 0xbb && sig != 0xcc && sig != 0xdd &&
1539 sig != 0xee) {
1540 dev_warn(&pdev->dev, "ISILoad:Card%u reset failure (Possible "
1541 "bad I/O Port Address 0x%lx).\n", card + 1, base);
1542 dev_dbg(&pdev->dev, "Sig=0x%x\n", sig);
1543 retval = -EIO;
1544 goto end;
1545 }
1546
1547 msleep(10);
1554 1548
1555 portcount = inw(base + 0x2); 1549 portcount = inw(base + 0x2);
1556 if (!(inw(base + 0xe) & 0x1) || ((portcount != 0) && 1550 if (!inw(base + 0xe) & 0x1 || (portcount != 0 && portcount != 4 &&
1557 (portcount != 4) && (portcount != 8))) { 1551 portcount != 8 && portcount != 16)) {
1558 dev_dbg(&pdev->dev, "base+0x2=0x%lx, base+0xe=0x%lx\n", 1552 dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure.",
1559 inw(base + 0x2), inw(base + 0xe)); 1553 card + 1);
1560 dev_err(&pdev->dev, "ISILoad:PCI Card%d reset failure "
1561 "(Possible bad I/O Port Address 0x%lx).\n",
1562 card + 1, base);
1563 retval = -EIO; 1554 retval = -EIO;
1564 goto end; 1555 goto end;
1565 } 1556 }
1566 1557
1567 switch (*signature) { 1558 switch (sig) {
1568 case 0xa5: 1559 case 0xa5:
1569 case 0xbb: 1560 case 0xbb:
1570 case 0xdd: 1561 case 0xdd:
@@ -1572,16 +1563,13 @@ static int __devinit reset_card(struct pci_dev *pdev,
1572 board->shift_count = 12; 1563 board->shift_count = 12;
1573 break; 1564 break;
1574 case 0xcc: 1565 case 0xcc:
1566 case 0xee:
1575 board->port_count = 16; 1567 board->port_count = 16;
1576 board->shift_count = 11; 1568 board->shift_count = 11;
1577 break; 1569 break;
1578 default:
1579 dev_warn(&pdev->dev, "ISILoad:Card%d reset failure (Possible "
1580 "bad I/O Port Address 0x%lx).\n", card + 1, base);
1581 dev_dbg(&pdev->dev, "Sig=0x%lx\n", signature);
1582 retval = -EIO;
1583 } 1570 }
1584 dev_info(&pdev->dev, "-Done\n"); 1571 dev_info(&pdev->dev, "-Done\n");
1572 *signature = sig;
1585 1573
1586end: 1574end:
1587 return retval; 1575 return retval;
@@ -1757,7 +1745,7 @@ end:
1757/* 1745/*
1758 * Insmod can set static symbols so keep these static 1746 * Insmod can set static symbols so keep these static
1759 */ 1747 */
1760static int card; 1748static unsigned int card_count;
1761 1749
1762static int __devinit isicom_probe(struct pci_dev *pdev, 1750static int __devinit isicom_probe(struct pci_dev *pdev,
1763 const struct pci_device_id *ent) 1751 const struct pci_device_id *ent)
@@ -1767,7 +1755,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1767 u8 pciirq; 1755 u8 pciirq;
1768 struct isi_board *board = NULL; 1756 struct isi_board *board = NULL;
1769 1757
1770 if (card >= BOARD_COUNT) 1758 if (card_count >= BOARD_COUNT)
1771 goto err; 1759 goto err;
1772 1760
1773 ioaddr = pci_resource_start(pdev, 3); 1761 ioaddr = pci_resource_start(pdev, 3);
@@ -1785,7 +1773,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1785 board->index = index; 1773 board->index = index;
1786 board->base = ioaddr; 1774 board->base = ioaddr;
1787 board->irq = pciirq; 1775 board->irq = pciirq;
1788 card++; 1776 card_count++;
1789 1777
1790 pci_set_drvdata(pdev, board); 1778 pci_set_drvdata(pdev, board);
1791 1779
@@ -1795,7 +1783,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1795 "will be disabled.\n", board->base, board->base + 15, 1783 "will be disabled.\n", board->base, board->base + 15,
1796 index + 1); 1784 index + 1);
1797 retval = -EBUSY; 1785 retval = -EBUSY;
1798 goto err; 1786 goto errdec;
1799 } 1787 }
1800 1788
1801 retval = request_irq(board->irq, isicom_interrupt, 1789 retval = request_irq(board->irq, isicom_interrupt,
@@ -1824,8 +1812,10 @@ errunri:
1824 free_irq(board->irq, board); 1812 free_irq(board->irq, board);
1825errunrr: 1813errunrr:
1826 pci_release_region(pdev, 3); 1814 pci_release_region(pdev, 3);
1827err: 1815errdec:
1828 board->base = 0; 1816 board->base = 0;
1817 card_count--;
1818err:
1829 return retval; 1819 return retval;
1830} 1820}
1831 1821
@@ -1839,6 +1829,8 @@ static void __devexit isicom_remove(struct pci_dev *pdev)
1839 1829
1840 free_irq(board->irq, board); 1830 free_irq(board->irq, board);
1841 pci_release_region(pdev, 3); 1831 pci_release_region(pdev, 3);
1832 board->base = 0;
1833 card_count--;
1842} 1834}
1843 1835
1844static int __init isicom_init(void) 1836static int __init isicom_init(void)
@@ -1846,8 +1838,6 @@ static int __init isicom_init(void)
1846 int retval, idx, channel; 1838 int retval, idx, channel;
1847 struct isi_port *port; 1839 struct isi_port *port;
1848 1840
1849 card = 0;
1850
1851 for(idx = 0; idx < BOARD_COUNT; idx++) { 1841 for(idx = 0; idx < BOARD_COUNT; idx++) {
1852 port = &isi_ports[idx * 16]; 1842 port = &isi_ports[idx * 16];
1853 isi_card[idx].ports = port; 1843 isi_card[idx].ports = port;
@@ -1858,8 +1848,6 @@ static int __init isicom_init(void)
1858 port->channel = channel; 1848 port->channel = channel;
1859 port->close_delay = 50 * HZ/100; 1849 port->close_delay = 50 * HZ/100;
1860 port->closing_wait = 3000 * HZ/100; 1850 port->closing_wait = 3000 * HZ/100;
1861 INIT_WORK(&port->hangup_tq, do_isicom_hangup);
1862 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
1863 port->status = 0; 1851 port->status = 0;
1864 init_waitqueue_head(&port->open_wait); 1852 init_waitqueue_head(&port->open_wait);
1865 init_waitqueue_head(&port->close_wait); 1853 init_waitqueue_head(&port->close_wait);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 68645d351873..7b279d1de4a2 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -2424,7 +2424,6 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
2424 if (tty != NULL) { 2424 if (tty != NULL) {
2425 tty_wakeup(tty); 2425 tty_wakeup(tty);
2426 EBRDENABLE(brdp); 2426 EBRDENABLE(brdp);
2427 wake_up_interruptible(&tty->write_wait);
2428 } 2427 }
2429 } 2428 }
2430 2429
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 7a6c1c0b7a95..c654a3e0c697 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -595,15 +595,9 @@ static void fn_spawn_con(struct vc_data *vc)
595 595
596static void fn_SAK(struct vc_data *vc) 596static void fn_SAK(struct vc_data *vc)
597{ 597{
598 struct tty_struct *tty = vc->vc_tty; 598 struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;
599 599 PREPARE_WORK(SAK_work, vc_SAK);
600 /* 600 schedule_work(SAK_work);
601 * SAK should also work in all raw modes and reset
602 * them properly.
603 */
604 if (tty)
605 do_SAK(tty);
606 reset_vc(vc);
607} 601}
608 602
609static void fn_null(struct vc_data *vc) 603static void fn_null(struct vc_data *vc)
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index f391a24a1b44..7dbaee8d9402 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -11,15 +11,6 @@
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 14 */
24 15
25/* 16/*
@@ -55,36 +46,20 @@
55#include <asm/io.h> 46#include <asm/io.h>
56#include <asm/uaccess.h> 47#include <asm/uaccess.h>
57 48
58#define MOXA_VERSION "5.1k" 49#define MOXA_VERSION "5.1k"
59 50
60#define MOXAMAJOR 172 51#define MOXAMAJOR 172
61#define MOXACUMAJOR 173 52#define MOXACUMAJOR 173
62 53
63#define put_to_user(arg1, arg2) put_user(arg1, (unsigned long *)arg2) 54#define MAX_BOARDS 4 /* Don't change this value */
64#define get_from_user(arg1, arg2) get_user(arg1, (unsigned int *)arg2)
65
66#define MAX_BOARDS 4 /* Don't change this value */
67#define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ 55#define MAX_PORTS_PER_BOARD 32 /* Don't change this value */
68#define MAX_PORTS 128 /* Don't change this value */ 56#define MAX_PORTS (MAX_BOARDS * MAX_PORTS_PER_BOARD)
69 57
70/* 58/*
71 * Define the Moxa PCI vendor and device IDs. 59 * Define the Moxa PCI vendor and device IDs.
72 */ 60 */
73#define MOXA_BUS_TYPE_ISA 0 61#define MOXA_BUS_TYPE_ISA 0
74#define MOXA_BUS_TYPE_PCI 1 62#define MOXA_BUS_TYPE_PCI 1
75
76#ifndef PCI_VENDOR_ID_MOXA
77#define PCI_VENDOR_ID_MOXA 0x1393
78#endif
79#ifndef PCI_DEVICE_ID_CP204J
80#define PCI_DEVICE_ID_CP204J 0x2040
81#endif
82#ifndef PCI_DEVICE_ID_C218
83#define PCI_DEVICE_ID_C218 0x2180
84#endif
85#ifndef PCI_DEVICE_ID_C320
86#define PCI_DEVICE_ID_C320 0x3200
87#endif
88 63
89enum { 64enum {
90 MOXA_BOARD_C218_PCI = 1, 65 MOXA_BOARD_C218_PCI = 1,
@@ -105,47 +80,56 @@ static char *moxa_brdname[] =
105 80
106#ifdef CONFIG_PCI 81#ifdef CONFIG_PCI
107static struct pci_device_id moxa_pcibrds[] = { 82static struct pci_device_id moxa_pcibrds[] = {
108 { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C218, PCI_ANY_ID, PCI_ANY_ID, 83 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218),
109 0, 0, MOXA_BOARD_C218_PCI }, 84 .driver_data = MOXA_BOARD_C218_PCI },
110 { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C320, PCI_ANY_ID, PCI_ANY_ID, 85 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320),
111 0, 0, MOXA_BOARD_C320_PCI }, 86 .driver_data = MOXA_BOARD_C320_PCI },
112 { PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP204J, PCI_ANY_ID, PCI_ANY_ID, 87 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP204J),
113 0, 0, MOXA_BOARD_CP204J }, 88 .driver_data = MOXA_BOARD_CP204J },
114 { 0 } 89 { 0 }
115}; 90};
116MODULE_DEVICE_TABLE(pci, moxa_pcibrds); 91MODULE_DEVICE_TABLE(pci, moxa_pcibrds);
117#endif /* CONFIG_PCI */ 92#endif /* CONFIG_PCI */
118 93
119typedef struct _moxa_isa_board_conf { 94struct moxa_isa_board_conf {
120 int boardType; 95 int boardType;
121 int numPorts; 96 int numPorts;
122 unsigned long baseAddr; 97 unsigned long baseAddr;
123} moxa_isa_board_conf; 98};
124 99
125static moxa_isa_board_conf moxa_isa_boards[] = 100static struct moxa_isa_board_conf moxa_isa_boards[] =
126{ 101{
127/* {MOXA_BOARD_C218_ISA,8,0xDC000}, */ 102/* {MOXA_BOARD_C218_ISA,8,0xDC000}, */
128}; 103};
129 104
130typedef struct _moxa_pci_devinfo { 105static struct moxa_board_conf {
131 ushort busNum;
132 ushort devNum;
133 struct pci_dev *pdev;
134} moxa_pci_devinfo;
135
136typedef struct _moxa_board_conf {
137 int boardType; 106 int boardType;
138 int numPorts; 107 int numPorts;
139 unsigned long baseAddr; 108 unsigned long baseAddr;
140 int busType; 109 int busType;
141 moxa_pci_devinfo pciInfo;
142} moxa_board_conf;
143 110
144static moxa_board_conf moxa_boards[MAX_BOARDS]; 111 int loadstat;
145static void __iomem *moxaBaseAddr[MAX_BOARDS]; 112
146static int loadstat[MAX_BOARDS]; 113 void __iomem *basemem;
114 void __iomem *intNdx;
115 void __iomem *intPend;
116 void __iomem *intTable;
117} moxa_boards[MAX_BOARDS];
118
119struct mxser_mstatus {
120 tcflag_t cflag;
121 int cts;
122 int dsr;
123 int ri;
124 int dcd;
125};
126
127struct moxaq_str {
128 int inq;
129 int outq;
130};
147 131
148struct moxa_str { 132struct moxa_port {
149 int type; 133 int type;
150 int port; 134 int port;
151 int close_delay; 135 int close_delay;
@@ -159,18 +143,18 @@ struct moxa_str {
159 int cflag; 143 int cflag;
160 wait_queue_head_t open_wait; 144 wait_queue_head_t open_wait;
161 wait_queue_head_t close_wait; 145 wait_queue_head_t close_wait;
162 struct work_struct tqueue;
163};
164 146
165struct mxser_mstatus { 147 struct timer_list emptyTimer;
166 tcflag_t cflag;
167 int cts;
168 int dsr;
169 int ri;
170 int dcd;
171};
172 148
173static struct mxser_mstatus GMStatus[MAX_PORTS]; 149 char chkPort;
150 char lineCtrl;
151 void __iomem *tableAddr;
152 long curBaud;
153 char DCDState;
154 char lowChkFlag;
155
156 ushort breakCnt;
157};
174 158
175/* statusflags */ 159/* statusflags */
176#define TXSTOPPED 0x1 160#define TXSTOPPED 0x1
@@ -178,25 +162,17 @@ static struct mxser_mstatus GMStatus[MAX_PORTS];
178#define EMPTYWAIT 0x4 162#define EMPTYWAIT 0x4
179#define THROTTLE 0x8 163#define THROTTLE 0x8
180 164
181/* event */
182#define MOXA_EVENT_HANGUP 1
183
184#define SERIAL_DO_RESTART 165#define SERIAL_DO_RESTART
185 166
186
187#define SERIAL_TYPE_NORMAL 1
188
189#define WAKEUP_CHARS 256 167#define WAKEUP_CHARS 256
190 168
191#define PORTNO(x) ((x)->index)
192
193static int verbose = 0; 169static int verbose = 0;
194static int ttymajor = MOXAMAJOR; 170static int ttymajor = MOXAMAJOR;
195/* Variables for insmod */ 171/* Variables for insmod */
196#ifdef MODULE 172#ifdef MODULE
197static int baseaddr[] = {0, 0, 0, 0}; 173static int baseaddr[4];
198static int type[] = {0, 0, 0, 0}; 174static int type[4];
199static int numports[] = {0, 0, 0, 0}; 175static int numports[4];
200#endif 176#endif
201 177
202MODULE_AUTHOR("William Chen"); 178MODULE_AUTHOR("William Chen");
@@ -210,19 +186,9 @@ module_param_array(numports, int, NULL, 0);
210module_param(ttymajor, int, 0); 186module_param(ttymajor, int, 0);
211module_param(verbose, bool, 0644); 187module_param(verbose, bool, 0644);
212 188
213static struct tty_driver *moxaDriver;
214static struct moxa_str moxaChannels[MAX_PORTS];
215static unsigned char *moxaXmitBuff;
216static int moxaTimer_on;
217static struct timer_list moxaTimer;
218static int moxaEmptyTimer_on[MAX_PORTS];
219static struct timer_list moxaEmptyTimer[MAX_PORTS];
220static struct semaphore moxaBuffSem;
221
222/* 189/*
223 * static functions: 190 * static functions:
224 */ 191 */
225static void do_moxa_softint(struct work_struct *);
226static int moxa_open(struct tty_struct *, struct file *); 192static int moxa_open(struct tty_struct *, struct file *);
227static void moxa_close(struct tty_struct *, struct file *); 193static void moxa_close(struct tty_struct *, struct file *);
228static int moxa_write(struct tty_struct *, const unsigned char *, int); 194static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -244,11 +210,11 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
244static void moxa_poll(unsigned long); 210static void moxa_poll(unsigned long);
245static void set_tty_param(struct tty_struct *); 211static void set_tty_param(struct tty_struct *);
246static int block_till_ready(struct tty_struct *, struct file *, 212static int block_till_ready(struct tty_struct *, struct file *,
247 struct moxa_str *); 213 struct moxa_port *);
248static void setup_empty_event(struct tty_struct *); 214static void setup_empty_event(struct tty_struct *);
249static void check_xmit_empty(unsigned long); 215static void check_xmit_empty(unsigned long);
250static void shut_down(struct moxa_str *); 216static void shut_down(struct moxa_port *);
251static void receive_data(struct moxa_str *); 217static void receive_data(struct moxa_port *);
252/* 218/*
253 * moxa board interface functions: 219 * moxa board interface functions:
254 */ 220 */
@@ -278,8 +244,8 @@ static void MoxaPortTxDisable(int);
278static void MoxaPortTxEnable(int); 244static void MoxaPortTxEnable(int);
279static int MoxaPortResetBrkCnt(int); 245static int MoxaPortResetBrkCnt(int);
280static void MoxaPortSendBreak(int, int); 246static void MoxaPortSendBreak(int, int);
281static int moxa_get_serial_info(struct moxa_str *, struct serial_struct __user *); 247static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *);
282static int moxa_set_serial_info(struct moxa_str *, struct serial_struct __user *); 248static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *);
283static void MoxaSetFifo(int port, int enable); 249static void MoxaSetFifo(int port, int enable);
284 250
285static const struct tty_operations moxa_ops = { 251static const struct tty_operations moxa_ops = {
@@ -302,12 +268,41 @@ static const struct tty_operations moxa_ops = {
302 .tiocmset = moxa_tiocmset, 268 .tiocmset = moxa_tiocmset,
303}; 269};
304 270
271static struct tty_driver *moxaDriver;
272static struct moxa_port moxa_ports[MAX_PORTS];
273static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
305static DEFINE_SPINLOCK(moxa_lock); 274static DEFINE_SPINLOCK(moxa_lock);
306 275
307#ifdef CONFIG_PCI 276#ifdef CONFIG_PCI
308static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) 277static int __devinit moxa_pci_probe(struct pci_dev *pdev,
278 const struct pci_device_id *ent)
309{ 279{
310 board->baseAddr = pci_resource_start (p, 2); 280 struct moxa_board_conf *board;
281 unsigned int i;
282 int board_type = ent->driver_data;
283 int retval;
284
285 retval = pci_enable_device(pdev);
286 if (retval)
287 goto err;
288
289 for (i = 0; i < MAX_BOARDS; i++)
290 if (moxa_boards[i].basemem == NULL)
291 break;
292
293 retval = -ENODEV;
294 if (i >= MAX_BOARDS) {
295 if (verbose)
296 printk("More than %d MOXA Intellio family boards "
297 "found. Board is ignored.\n", MAX_BOARDS);
298 goto err;
299 }
300
301 board = &moxa_boards[i];
302 board->basemem = pci_iomap(pdev, 2, 0x4000);
303 if (board->basemem == NULL)
304 goto err;
305
311 board->boardType = board_type; 306 board->boardType = board_type;
312 switch (board_type) { 307 switch (board_type) {
313 case MOXA_BOARD_C218_ISA: 308 case MOXA_BOARD_C218_ISA:
@@ -323,27 +318,40 @@ static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf
323 break; 318 break;
324 } 319 }
325 board->busType = MOXA_BUS_TYPE_PCI; 320 board->busType = MOXA_BUS_TYPE_PCI;
326 board->pciInfo.busNum = p->bus->number; 321
327 board->pciInfo.devNum = p->devfn >> 3; 322 pci_set_drvdata(pdev, board);
328 board->pciInfo.pdev = p;
329 /* don't lose the reference in the next pci_get_device iteration */
330 pci_dev_get(p);
331 323
332 return (0); 324 return (0);
325err:
326 return retval;
333} 327}
328
329static void __devexit moxa_pci_remove(struct pci_dev *pdev)
330{
331 struct moxa_board_conf *brd = pci_get_drvdata(pdev);
332
333 pci_iounmap(pdev, brd->basemem);
334 brd->basemem = NULL;
335}
336
337static struct pci_driver moxa_pci_driver = {
338 .name = "moxa",
339 .id_table = moxa_pcibrds,
340 .probe = moxa_pci_probe,
341 .remove = __devexit_p(moxa_pci_remove)
342};
334#endif /* CONFIG_PCI */ 343#endif /* CONFIG_PCI */
335 344
336static int __init moxa_init(void) 345static int __init moxa_init(void)
337{ 346{
338 int i, numBoards; 347 int i, numBoards, retval = 0;
339 struct moxa_str *ch; 348 struct moxa_port *ch;
340 349
341 printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION); 350 printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION);
342 moxaDriver = alloc_tty_driver(MAX_PORTS + 1); 351 moxaDriver = alloc_tty_driver(MAX_PORTS + 1);
343 if (!moxaDriver) 352 if (!moxaDriver)
344 return -ENOMEM; 353 return -ENOMEM;
345 354
346 init_MUTEX(&moxaBuffSem);
347 moxaDriver->owner = THIS_MODULE; 355 moxaDriver->owner = THIS_MODULE;
348 moxaDriver->name = "ttyMX"; 356 moxaDriver->name = "ttyMX";
349 moxaDriver->major = ttymajor; 357 moxaDriver->major = ttymajor;
@@ -351,40 +359,25 @@ static int __init moxa_init(void)
351 moxaDriver->type = TTY_DRIVER_TYPE_SERIAL; 359 moxaDriver->type = TTY_DRIVER_TYPE_SERIAL;
352 moxaDriver->subtype = SERIAL_TYPE_NORMAL; 360 moxaDriver->subtype = SERIAL_TYPE_NORMAL;
353 moxaDriver->init_termios = tty_std_termios; 361 moxaDriver->init_termios = tty_std_termios;
354 moxaDriver->init_termios.c_iflag = 0;
355 moxaDriver->init_termios.c_oflag = 0;
356 moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; 362 moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
357 moxaDriver->init_termios.c_lflag = 0;
358 moxaDriver->init_termios.c_ispeed = 9600; 363 moxaDriver->init_termios.c_ispeed = 9600;
359 moxaDriver->init_termios.c_ospeed = 9600; 364 moxaDriver->init_termios.c_ospeed = 9600;
360 moxaDriver->flags = TTY_DRIVER_REAL_RAW; 365 moxaDriver->flags = TTY_DRIVER_REAL_RAW;
361 tty_set_operations(moxaDriver, &moxa_ops); 366 tty_set_operations(moxaDriver, &moxa_ops);
362 367
363 moxaXmitBuff = NULL; 368 for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
364
365 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
366 ch->type = PORT_16550A; 369 ch->type = PORT_16550A;
367 ch->port = i; 370 ch->port = i;
368 INIT_WORK(&ch->tqueue, do_moxa_softint);
369 ch->tty = NULL;
370 ch->close_delay = 5 * HZ / 10; 371 ch->close_delay = 5 * HZ / 10;
371 ch->closing_wait = 30 * HZ; 372 ch->closing_wait = 30 * HZ;
372 ch->count = 0;
373 ch->blocked_open = 0;
374 ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; 373 ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
375 init_waitqueue_head(&ch->open_wait); 374 init_waitqueue_head(&ch->open_wait);
376 init_waitqueue_head(&ch->close_wait); 375 init_waitqueue_head(&ch->close_wait);
377 }
378 376
379 for (i = 0; i < MAX_BOARDS; i++) { 377 setup_timer(&ch->emptyTimer, check_xmit_empty,
380 moxa_boards[i].boardType = 0; 378 (unsigned long)ch);
381 moxa_boards[i].numPorts = 0;
382 moxa_boards[i].baseAddr = 0;
383 moxa_boards[i].busType = 0;
384 moxa_boards[i].pciInfo.busNum = 0;
385 moxa_boards[i].pciInfo.devNum = 0;
386 } 379 }
387 MoxaDriverInit(); 380
388 printk("Tty devices major number = %d\n", ttymajor); 381 printk("Tty devices major number = %d\n", ttymajor);
389 382
390 if (tty_register_driver(moxaDriver)) { 383 if (tty_register_driver(moxaDriver)) {
@@ -392,18 +385,8 @@ static int __init moxa_init(void)
392 put_tty_driver(moxaDriver); 385 put_tty_driver(moxaDriver);
393 return -1; 386 return -1;
394 } 387 }
395 for (i = 0; i < MAX_PORTS; i++) {
396 init_timer(&moxaEmptyTimer[i]);
397 moxaEmptyTimer[i].function = check_xmit_empty;
398 moxaEmptyTimer[i].data = (unsigned long) & moxaChannels[i];
399 moxaEmptyTimer_on[i] = 0;
400 }
401 388
402 init_timer(&moxaTimer); 389 mod_timer(&moxaTimer, jiffies + HZ / 50);
403 moxaTimer.function = moxa_poll;
404 moxaTimer.expires = jiffies + (HZ / 50);
405 moxaTimer_on = 1;
406 add_timer(&moxaTimer);
407 390
408 /* Find the boards defined in source code */ 391 /* Find the boards defined in source code */
409 numBoards = 0; 392 numBoards = 0;
@@ -451,35 +434,22 @@ static int __init moxa_init(void)
451 } 434 }
452 } 435 }
453#endif 436#endif
454 /* Find PCI boards here */ 437
455#ifdef CONFIG_PCI 438#ifdef CONFIG_PCI
456 { 439 retval = pci_register_driver(&moxa_pci_driver);
457 struct pci_dev *p = NULL; 440 if (retval) {
458 int n = ARRAY_SIZE(moxa_pcibrds) - 1; 441 printk(KERN_ERR "Can't register moxa pci driver!\n");
459 i = 0; 442 if (numBoards)
460 while (i < n) { 443 retval = 0;
461 while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
462 {
463 if (pci_enable_device(p))
464 continue;
465 if (numBoards >= MAX_BOARDS) {
466 if (verbose)
467 printk("More than %d MOXA Intellio family boards found. Board is ignored.", MAX_BOARDS);
468 } else {
469 moxa_get_PCI_conf(p, moxa_pcibrds[i].driver_data,
470 &moxa_boards[numBoards]);
471 numBoards++;
472 }
473 }
474 i++;
475 }
476 } 444 }
477#endif 445#endif
446
478 for (i = 0; i < numBoards; i++) { 447 for (i = 0; i < numBoards; i++) {
479 moxaBaseAddr[i] = ioremap((unsigned long) moxa_boards[i].baseAddr, 0x4000); 448 moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
449 0x4000);
480 } 450 }
481 451
482 return (0); 452 return retval;
483} 453}
484 454
485static void __exit moxa_exit(void) 455static void __exit moxa_exit(void)
@@ -489,23 +459,22 @@ static void __exit moxa_exit(void)
489 if (verbose) 459 if (verbose)
490 printk("Unloading module moxa ...\n"); 460 printk("Unloading module moxa ...\n");
491 461
492 if (moxaTimer_on) 462 del_timer_sync(&moxaTimer);
493 del_timer(&moxaTimer);
494 463
495 for (i = 0; i < MAX_PORTS; i++) 464 for (i = 0; i < MAX_PORTS; i++)
496 if (moxaEmptyTimer_on[i]) 465 del_timer_sync(&moxa_ports[i].emptyTimer);
497 del_timer(&moxaEmptyTimer[i]);
498 466
499 if (tty_unregister_driver(moxaDriver)) 467 if (tty_unregister_driver(moxaDriver))
500 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 468 printk("Couldn't unregister MOXA Intellio family serial driver\n");
501 put_tty_driver(moxaDriver); 469 put_tty_driver(moxaDriver);
502 470
503 for (i = 0; i < MAX_BOARDS; i++) { 471#ifdef CONFIG_PCI
504 if (moxaBaseAddr[i]) 472 pci_unregister_driver(&moxa_pci_driver);
505 iounmap(moxaBaseAddr[i]); 473#endif
506 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) 474
507 pci_dev_put(moxa_boards[i].pciInfo.pdev); 475 for (i = 0; i < MAX_BOARDS; i++)
508 } 476 if (moxa_boards[i].basemem)
477 iounmap(moxa_boards[i].basemem);
509 478
510 if (verbose) 479 if (verbose)
511 printk("Done\n"); 480 printk("Done\n");
@@ -514,28 +483,13 @@ static void __exit moxa_exit(void)
514module_init(moxa_init); 483module_init(moxa_init);
515module_exit(moxa_exit); 484module_exit(moxa_exit);
516 485
517static void do_moxa_softint(struct work_struct *work)
518{
519 struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
520 struct tty_struct *tty;
521
522 if (ch && (tty = ch->tty)) {
523 if (test_and_clear_bit(MOXA_EVENT_HANGUP, &ch->event)) {
524 tty_hangup(tty); /* FIXME: module removal race here - AKPM */
525 wake_up_interruptible(&ch->open_wait);
526 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
527 }
528 }
529}
530
531static int moxa_open(struct tty_struct *tty, struct file *filp) 486static int moxa_open(struct tty_struct *tty, struct file *filp)
532{ 487{
533 struct moxa_str *ch; 488 struct moxa_port *ch;
534 int port; 489 int port;
535 int retval; 490 int retval;
536 unsigned long page;
537 491
538 port = PORTNO(tty); 492 port = tty->index;
539 if (port == MAX_PORTS) { 493 if (port == MAX_PORTS) {
540 return (0); 494 return (0);
541 } 495 }
@@ -543,23 +497,8 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
543 tty->driver_data = NULL; 497 tty->driver_data = NULL;
544 return (-ENODEV); 498 return (-ENODEV);
545 } 499 }
546 down(&moxaBuffSem);
547 if (!moxaXmitBuff) {
548 page = get_zeroed_page(GFP_KERNEL);
549 if (!page) {
550 up(&moxaBuffSem);
551 return (-ENOMEM);
552 }
553 /* This test is guarded by the BuffSem so no longer needed
554 delete me in 2.5 */
555 if (moxaXmitBuff)
556 free_page(page);
557 else
558 moxaXmitBuff = (unsigned char *) page;
559 }
560 up(&moxaBuffSem);
561 500
562 ch = &moxaChannels[port]; 501 ch = &moxa_ports[port];
563 ch->count++; 502 ch->count++;
564 tty->driver_data = ch; 503 tty->driver_data = ch;
565 ch->tty = tty; 504 ch->tty = tty;
@@ -585,10 +524,10 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
585 524
586static void moxa_close(struct tty_struct *tty, struct file *filp) 525static void moxa_close(struct tty_struct *tty, struct file *filp)
587{ 526{
588 struct moxa_str *ch; 527 struct moxa_port *ch;
589 int port; 528 int port;
590 529
591 port = PORTNO(tty); 530 port = tty->index;
592 if (port == MAX_PORTS) { 531 if (port == MAX_PORTS) {
593 return; 532 return;
594 } 533 }
@@ -605,7 +544,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
605 if (tty_hung_up_p(filp)) { 544 if (tty_hung_up_p(filp)) {
606 return; 545 return;
607 } 546 }
608 ch = (struct moxa_str *) tty->driver_data; 547 ch = (struct moxa_port *) tty->driver_data;
609 548
610 if ((tty->count == 1) && (ch->count != 1)) { 549 if ((tty->count == 1) && (ch->count != 1)) {
611 printk("moxa_close: bad serial port count; tty->count is 1, " 550 printk("moxa_close: bad serial port count; tty->count is 1, "
@@ -626,8 +565,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
626 if (ch->asyncflags & ASYNC_INITIALIZED) { 565 if (ch->asyncflags & ASYNC_INITIALIZED) {
627 setup_empty_event(tty); 566 setup_empty_event(tty);
628 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ 567 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */
629 moxaEmptyTimer_on[ch->port] = 0; 568 del_timer_sync(&moxa_ports[ch->port].emptyTimer);
630 del_timer(&moxaEmptyTimer[ch->port]);
631 } 569 }
632 shut_down(ch); 570 shut_down(ch);
633 MoxaPortFlushData(port, 2); 571 MoxaPortFlushData(port, 2);
@@ -652,11 +590,11 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
652static int moxa_write(struct tty_struct *tty, 590static int moxa_write(struct tty_struct *tty,
653 const unsigned char *buf, int count) 591 const unsigned char *buf, int count)
654{ 592{
655 struct moxa_str *ch; 593 struct moxa_port *ch;
656 int len, port; 594 int len, port;
657 unsigned long flags; 595 unsigned long flags;
658 596
659 ch = (struct moxa_str *) tty->driver_data; 597 ch = (struct moxa_port *) tty->driver_data;
660 if (ch == NULL) 598 if (ch == NULL)
661 return (0); 599 return (0);
662 port = ch->port; 600 port = ch->port;
@@ -675,11 +613,11 @@ static int moxa_write(struct tty_struct *tty,
675 613
676static int moxa_write_room(struct tty_struct *tty) 614static int moxa_write_room(struct tty_struct *tty)
677{ 615{
678 struct moxa_str *ch; 616 struct moxa_port *ch;
679 617
680 if (tty->stopped) 618 if (tty->stopped)
681 return (0); 619 return (0);
682 ch = (struct moxa_str *) tty->driver_data; 620 ch = (struct moxa_port *) tty->driver_data;
683 if (ch == NULL) 621 if (ch == NULL)
684 return (0); 622 return (0);
685 return (MoxaPortTxFree(ch->port)); 623 return (MoxaPortTxFree(ch->port));
@@ -687,7 +625,7 @@ static int moxa_write_room(struct tty_struct *tty)
687 625
688static void moxa_flush_buffer(struct tty_struct *tty) 626static void moxa_flush_buffer(struct tty_struct *tty)
689{ 627{
690 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 628 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
691 629
692 if (ch == NULL) 630 if (ch == NULL)
693 return; 631 return;
@@ -698,7 +636,7 @@ static void moxa_flush_buffer(struct tty_struct *tty)
698static int moxa_chars_in_buffer(struct tty_struct *tty) 636static int moxa_chars_in_buffer(struct tty_struct *tty)
699{ 637{
700 int chars; 638 int chars;
701 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 639 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
702 640
703 /* 641 /*
704 * Sigh...I have to check if driver_data is NULL here, because 642 * Sigh...I have to check if driver_data is NULL here, because
@@ -730,17 +668,16 @@ static void moxa_flush_chars(struct tty_struct *tty)
730 668
731static void moxa_put_char(struct tty_struct *tty, unsigned char c) 669static void moxa_put_char(struct tty_struct *tty, unsigned char c)
732{ 670{
733 struct moxa_str *ch; 671 struct moxa_port *ch;
734 int port; 672 int port;
735 unsigned long flags; 673 unsigned long flags;
736 674
737 ch = (struct moxa_str *) tty->driver_data; 675 ch = (struct moxa_port *) tty->driver_data;
738 if (ch == NULL) 676 if (ch == NULL)
739 return; 677 return;
740 port = ch->port; 678 port = ch->port;
741 spin_lock_irqsave(&moxa_lock, flags); 679 spin_lock_irqsave(&moxa_lock, flags);
742 moxaXmitBuff[0] = c; 680 MoxaPortWriteData(port, &c, 1);
743 MoxaPortWriteData(port, moxaXmitBuff, 1);
744 spin_unlock_irqrestore(&moxa_lock, flags); 681 spin_unlock_irqrestore(&moxa_lock, flags);
745 /************************************************ 682 /************************************************
746 if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) ) 683 if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
@@ -750,11 +687,11 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c)
750 687
751static int moxa_tiocmget(struct tty_struct *tty, struct file *file) 688static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
752{ 689{
753 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 690 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
754 int port; 691 int port;
755 int flag = 0, dtr, rts; 692 int flag = 0, dtr, rts;
756 693
757 port = PORTNO(tty); 694 port = tty->index;
758 if ((port != MAX_PORTS) && (!ch)) 695 if ((port != MAX_PORTS) && (!ch))
759 return (-EINVAL); 696 return (-EINVAL);
760 697
@@ -776,11 +713,11 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
776static int moxa_tiocmset(struct tty_struct *tty, struct file *file, 713static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
777 unsigned int set, unsigned int clear) 714 unsigned int set, unsigned int clear)
778{ 715{
779 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 716 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
780 int port; 717 int port;
781 int dtr, rts; 718 int dtr, rts;
782 719
783 port = PORTNO(tty); 720 port = tty->index;
784 if ((port != MAX_PORTS) && (!ch)) 721 if ((port != MAX_PORTS) && (!ch))
785 return (-EINVAL); 722 return (-EINVAL);
786 723
@@ -800,12 +737,12 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
800static int moxa_ioctl(struct tty_struct *tty, struct file *file, 737static int moxa_ioctl(struct tty_struct *tty, struct file *file,
801 unsigned int cmd, unsigned long arg) 738 unsigned int cmd, unsigned long arg)
802{ 739{
803 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 740 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
804 register int port; 741 register int port;
805 void __user *argp = (void __user *)arg; 742 void __user *argp = (void __user *)arg;
806 int retval; 743 int retval;
807 744
808 port = PORTNO(tty); 745 port = tty->index;
809 if ((port != MAX_PORTS) && (!ch)) 746 if ((port != MAX_PORTS) && (!ch))
810 return (-EINVAL); 747 return (-EINVAL);
811 748
@@ -853,14 +790,14 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
853 790
854static void moxa_throttle(struct tty_struct *tty) 791static void moxa_throttle(struct tty_struct *tty)
855{ 792{
856 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 793 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
857 794
858 ch->statusflags |= THROTTLE; 795 ch->statusflags |= THROTTLE;
859} 796}
860 797
861static void moxa_unthrottle(struct tty_struct *tty) 798static void moxa_unthrottle(struct tty_struct *tty)
862{ 799{
863 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 800 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
864 801
865 ch->statusflags &= ~THROTTLE; 802 ch->statusflags &= ~THROTTLE;
866} 803}
@@ -868,7 +805,7 @@ static void moxa_unthrottle(struct tty_struct *tty)
868static void moxa_set_termios(struct tty_struct *tty, 805static void moxa_set_termios(struct tty_struct *tty,
869 struct ktermios *old_termios) 806 struct ktermios *old_termios)
870{ 807{
871 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 808 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
872 809
873 if (ch == NULL) 810 if (ch == NULL)
874 return; 811 return;
@@ -880,7 +817,7 @@ static void moxa_set_termios(struct tty_struct *tty,
880 817
881static void moxa_stop(struct tty_struct *tty) 818static void moxa_stop(struct tty_struct *tty)
882{ 819{
883 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 820 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
884 821
885 if (ch == NULL) 822 if (ch == NULL)
886 return; 823 return;
@@ -891,7 +828,7 @@ static void moxa_stop(struct tty_struct *tty)
891 828
892static void moxa_start(struct tty_struct *tty) 829static void moxa_start(struct tty_struct *tty)
893{ 830{
894 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 831 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
895 832
896 if (ch == NULL) 833 if (ch == NULL)
897 return; 834 return;
@@ -905,7 +842,7 @@ static void moxa_start(struct tty_struct *tty)
905 842
906static void moxa_hangup(struct tty_struct *tty) 843static void moxa_hangup(struct tty_struct *tty)
907{ 844{
908 struct moxa_str *ch = (struct moxa_str *) tty->driver_data; 845 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
909 846
910 moxa_flush_buffer(tty); 847 moxa_flush_buffer(tty);
911 shut_down(ch); 848 shut_down(ch);
@@ -919,24 +856,20 @@ static void moxa_hangup(struct tty_struct *tty)
919static void moxa_poll(unsigned long ignored) 856static void moxa_poll(unsigned long ignored)
920{ 857{
921 register int card; 858 register int card;
922 struct moxa_str *ch; 859 struct moxa_port *ch;
923 struct tty_struct *tp; 860 struct tty_struct *tp;
924 int i, ports; 861 int i, ports;
925 862
926 moxaTimer_on = 0;
927 del_timer(&moxaTimer); 863 del_timer(&moxaTimer);
928 864
929 if (MoxaDriverPoll() < 0) { 865 if (MoxaDriverPoll() < 0) {
930 moxaTimer.function = moxa_poll; 866 mod_timer(&moxaTimer, jiffies + HZ / 50);
931 moxaTimer.expires = jiffies + (HZ / 50);
932 moxaTimer_on = 1;
933 add_timer(&moxaTimer);
934 return; 867 return;
935 } 868 }
936 for (card = 0; card < MAX_BOARDS; card++) { 869 for (card = 0; card < MAX_BOARDS; card++) {
937 if ((ports = MoxaPortsOfCard(card)) <= 0) 870 if ((ports = MoxaPortsOfCard(card)) <= 0)
938 continue; 871 continue;
939 ch = &moxaChannels[card * MAX_PORTS_PER_BOARD]; 872 ch = &moxa_ports[card * MAX_PORTS_PER_BOARD];
940 for (i = 0; i < ports; i++, ch++) { 873 for (i = 0; i < ports; i++, ch++) {
941 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) 874 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
942 continue; 875 continue;
@@ -962,18 +895,16 @@ static void moxa_poll(unsigned long ignored)
962 if (MoxaPortDCDON(ch->port)) 895 if (MoxaPortDCDON(ch->port))
963 wake_up_interruptible(&ch->open_wait); 896 wake_up_interruptible(&ch->open_wait);
964 else { 897 else {
965 set_bit(MOXA_EVENT_HANGUP, &ch->event); 898 tty_hangup(tp);
966 schedule_work(&ch->tqueue); 899 wake_up_interruptible(&ch->open_wait);
900 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
967 } 901 }
968 } 902 }
969 } 903 }
970 } 904 }
971 } 905 }
972 906
973 moxaTimer.function = moxa_poll; 907 mod_timer(&moxaTimer, jiffies + HZ / 50);
974 moxaTimer.expires = jiffies + (HZ / 50);
975 moxaTimer_on = 1;
976 add_timer(&moxaTimer);
977} 908}
978 909
979/******************************************************************************/ 910/******************************************************************************/
@@ -981,10 +912,10 @@ static void moxa_poll(unsigned long ignored)
981static void set_tty_param(struct tty_struct *tty) 912static void set_tty_param(struct tty_struct *tty)
982{ 913{
983 register struct ktermios *ts; 914 register struct ktermios *ts;
984 struct moxa_str *ch; 915 struct moxa_port *ch;
985 int rts, cts, txflow, rxflow, xany; 916 int rts, cts, txflow, rxflow, xany;
986 917
987 ch = (struct moxa_str *) tty->driver_data; 918 ch = (struct moxa_port *) tty->driver_data;
988 ts = tty->termios; 919 ts = tty->termios;
989 if (ts->c_cflag & CLOCAL) 920 if (ts->c_cflag & CLOCAL)
990 ch->asyncflags &= ~ASYNC_CHECK_CD; 921 ch->asyncflags &= ~ASYNC_CHECK_CD;
@@ -1004,7 +935,7 @@ static void set_tty_param(struct tty_struct *tty)
1004} 935}
1005 936
1006static int block_till_ready(struct tty_struct *tty, struct file *filp, 937static int block_till_ready(struct tty_struct *tty, struct file *filp,
1007 struct moxa_str *ch) 938 struct moxa_port *ch)
1008{ 939{
1009 DECLARE_WAITQUEUE(wait,current); 940 DECLARE_WAITQUEUE(wait,current);
1010 unsigned long flags; 941 unsigned long flags;
@@ -1095,40 +1026,33 @@ static int block_till_ready(struct tty_struct *tty, struct file *filp,
1095 1026
1096static void setup_empty_event(struct tty_struct *tty) 1027static void setup_empty_event(struct tty_struct *tty)
1097{ 1028{
1098 struct moxa_str *ch = tty->driver_data; 1029 struct moxa_port *ch = tty->driver_data;
1099 unsigned long flags; 1030 unsigned long flags;
1100 1031
1101 spin_lock_irqsave(&moxa_lock, flags); 1032 spin_lock_irqsave(&moxa_lock, flags);
1102 ch->statusflags |= EMPTYWAIT; 1033 ch->statusflags |= EMPTYWAIT;
1103 moxaEmptyTimer_on[ch->port] = 0; 1034 mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
1104 del_timer(&moxaEmptyTimer[ch->port]);
1105 moxaEmptyTimer[ch->port].expires = jiffies + HZ;
1106 moxaEmptyTimer_on[ch->port] = 1;
1107 add_timer(&moxaEmptyTimer[ch->port]);
1108 spin_unlock_irqrestore(&moxa_lock, flags); 1035 spin_unlock_irqrestore(&moxa_lock, flags);
1109} 1036}
1110 1037
1111static void check_xmit_empty(unsigned long data) 1038static void check_xmit_empty(unsigned long data)
1112{ 1039{
1113 struct moxa_str *ch; 1040 struct moxa_port *ch;
1114 1041
1115 ch = (struct moxa_str *) data; 1042 ch = (struct moxa_port *) data;
1116 moxaEmptyTimer_on[ch->port] = 0; 1043 del_timer_sync(&moxa_ports[ch->port].emptyTimer);
1117 del_timer(&moxaEmptyTimer[ch->port]);
1118 if (ch->tty && (ch->statusflags & EMPTYWAIT)) { 1044 if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
1119 if (MoxaPortTxQueue(ch->port) == 0) { 1045 if (MoxaPortTxQueue(ch->port) == 0) {
1120 ch->statusflags &= ~EMPTYWAIT; 1046 ch->statusflags &= ~EMPTYWAIT;
1121 tty_wakeup(ch->tty); 1047 tty_wakeup(ch->tty);
1122 return; 1048 return;
1123 } 1049 }
1124 moxaEmptyTimer[ch->port].expires = jiffies + HZ; 1050 mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ);
1125 moxaEmptyTimer_on[ch->port] = 1;
1126 add_timer(&moxaEmptyTimer[ch->port]);
1127 } else 1051 } else
1128 ch->statusflags &= ~EMPTYWAIT; 1052 ch->statusflags &= ~EMPTYWAIT;
1129} 1053}
1130 1054
1131static void shut_down(struct moxa_str *ch) 1055static void shut_down(struct moxa_port *ch)
1132{ 1056{
1133 struct tty_struct *tp; 1057 struct tty_struct *tp;
1134 1058
@@ -1148,7 +1072,7 @@ static void shut_down(struct moxa_str *ch)
1148 ch->asyncflags &= ~ASYNC_INITIALIZED; 1072 ch->asyncflags &= ~ASYNC_INITIALIZED;
1149} 1073}
1150 1074
1151static void receive_data(struct moxa_str *ch) 1075static void receive_data(struct moxa_port *ch)
1152{ 1076{
1153 struct tty_struct *tp; 1077 struct tty_struct *tp;
1154 struct ktermios *ts; 1078 struct ktermios *ts;
@@ -1465,35 +1389,21 @@ static void receive_data(struct moxa_str *ch)
1465/* 1389/*
1466 * Query 1390 * Query
1467 */ 1391 */
1468#define QueryPort MAX_PORTS
1469
1470
1471 1392
1472struct mon_str { 1393struct mon_str {
1473 int tick; 1394 int tick;
1474 int rxcnt[MAX_PORTS]; 1395 int rxcnt[MAX_PORTS];
1475 int txcnt[MAX_PORTS]; 1396 int txcnt[MAX_PORTS];
1476}; 1397};
1477typedef struct mon_str mon_st;
1478 1398
1479#define DCD_changed 0x01 1399#define DCD_changed 0x01
1480#define DCD_oldstate 0x80 1400#define DCD_oldstate 0x80
1481 1401
1482static unsigned char moxaBuff[10240]; 1402static unsigned char moxaBuff[10240];
1483static void __iomem *moxaIntNdx[MAX_BOARDS];
1484static void __iomem *moxaIntPend[MAX_BOARDS];
1485static void __iomem *moxaIntTable[MAX_BOARDS];
1486static char moxaChkPort[MAX_PORTS];
1487static char moxaLineCtrl[MAX_PORTS];
1488static void __iomem *moxaTableAddr[MAX_PORTS];
1489static long moxaCurBaud[MAX_PORTS];
1490static char moxaDCDState[MAX_PORTS];
1491static char moxaLowChkFlag[MAX_PORTS];
1492static int moxaLowWaterChk; 1403static int moxaLowWaterChk;
1493static int moxaCard; 1404static int moxaCard;
1494static mon_st moxaLog; 1405static struct mon_str moxaLog;
1495static int moxaFuncTout; 1406static int moxaFuncTout = HZ / 2;
1496static ushort moxaBreakCnt[MAX_PORTS];
1497 1407
1498static void moxadelay(int); 1408static void moxadelay(int);
1499static void moxafunc(void __iomem *, int, ushort); 1409static void moxafunc(void __iomem *, int, ushort);
@@ -1514,16 +1424,18 @@ static int moxaloadc320(int, void __iomem *, int, int *);
1514 *****************************************************************************/ 1424 *****************************************************************************/
1515void MoxaDriverInit(void) 1425void MoxaDriverInit(void)
1516{ 1426{
1517 int i; 1427 struct moxa_port *p;
1428 unsigned int i;
1518 1429
1519 moxaFuncTout = HZ / 2; /* 500 mini-seconds */ 1430 moxaFuncTout = HZ / 2; /* 500 mini-seconds */
1520 moxaCard = 0; 1431 moxaCard = 0;
1521 moxaLog.tick = 0; 1432 moxaLog.tick = 0;
1522 moxaLowWaterChk = 0; 1433 moxaLowWaterChk = 0;
1523 for (i = 0; i < MAX_PORTS; i++) { 1434 for (i = 0; i < MAX_PORTS; i++) {
1524 moxaChkPort[i] = 0; 1435 p = &moxa_ports[i];
1525 moxaLowChkFlag[i] = 0; 1436 p->chkPort = 0;
1526 moxaLineCtrl[i] = 0; 1437 p->lowChkFlag = 0;
1438 p->lineCtrl = 0;
1527 moxaLog.rxcnt[i] = 0; 1439 moxaLog.rxcnt[i] = 0;
1528 moxaLog.txcnt[i] = 0; 1440 moxaLog.txcnt[i] = 0;
1529 } 1441 }
@@ -1545,19 +1457,12 @@ void MoxaDriverInit(void)
1545#define MOXA_GET_CUMAJOR (MOXA + 64) 1457#define MOXA_GET_CUMAJOR (MOXA + 64)
1546#define MOXA_GETMSTATUS (MOXA + 65) 1458#define MOXA_GETMSTATUS (MOXA + 65)
1547 1459
1548
1549struct moxaq_str {
1550 int inq;
1551 int outq;
1552};
1553
1554struct dl_str { 1460struct dl_str {
1555 char __user *buf; 1461 char __user *buf;
1556 int len; 1462 int len;
1557 int cardno; 1463 int cardno;
1558}; 1464};
1559 1465
1560static struct moxaq_str temp_queue[MAX_PORTS];
1561static struct dl_str dltmp; 1466static struct dl_str dltmp;
1562 1467
1563void MoxaPortFlushData(int port, int mode) 1468void MoxaPortFlushData(int port, int mode)
@@ -1565,10 +1470,10 @@ void MoxaPortFlushData(int port, int mode)
1565 void __iomem *ofsAddr; 1470 void __iomem *ofsAddr;
1566 if ((mode < 0) || (mode > 2)) 1471 if ((mode < 0) || (mode > 2))
1567 return; 1472 return;
1568 ofsAddr = moxaTableAddr[port]; 1473 ofsAddr = moxa_ports[port].tableAddr;
1569 moxafunc(ofsAddr, FC_FlushQueue, mode); 1474 moxafunc(ofsAddr, FC_FlushQueue, mode);
1570 if (mode != 1) { 1475 if (mode != 1) {
1571 moxaLowChkFlag[port] = 0; 1476 moxa_ports[port].lowChkFlag = 0;
1572 low_water_check(ofsAddr); 1477 low_water_check(ofsAddr);
1573 } 1478 }
1574} 1479}
@@ -1580,7 +1485,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1580 int MoxaPortTxQueue(int), MoxaPortRxQueue(int); 1485 int MoxaPortTxQueue(int), MoxaPortRxQueue(int);
1581 void __user *argp = (void __user *)arg; 1486 void __user *argp = (void __user *)arg;
1582 1487
1583 if (port == QueryPort) { 1488 if (port == MAX_PORTS) {
1584 if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_INIT_DRIVER) && 1489 if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_INIT_DRIVER) &&
1585 (cmd != MOXA_LOAD_BIOS) && (cmd != MOXA_FIND_BOARD) && (cmd != MOXA_LOAD_C320B) && 1490 (cmd != MOXA_LOAD_BIOS) && (cmd != MOXA_FIND_BOARD) && (cmd != MOXA_LOAD_C320B) &&
1586 (cmd != MOXA_LOAD_CODE) && (cmd != MOXA_GETDATACOUNT) && 1491 (cmd != MOXA_LOAD_CODE) && (cmd != MOXA_GETDATACOUNT) &&
@@ -1590,7 +1495,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1590 } 1495 }
1591 switch (cmd) { 1496 switch (cmd) {
1592 case MOXA_GET_CONF: 1497 case MOXA_GET_CONF:
1593 if(copy_to_user(argp, &moxa_boards, MAX_BOARDS * sizeof(moxa_board_conf))) 1498 if(copy_to_user(argp, &moxa_boards, MAX_BOARDS *
1499 sizeof(struct moxa_board_conf)))
1594 return -EFAULT; 1500 return -EFAULT;
1595 return (0); 1501 return (0);
1596 case MOXA_INIT_DRIVER: 1502 case MOXA_INIT_DRIVER:
@@ -1599,23 +1505,27 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1599 return (0); 1505 return (0);
1600 case MOXA_GETDATACOUNT: 1506 case MOXA_GETDATACOUNT:
1601 moxaLog.tick = jiffies; 1507 moxaLog.tick = jiffies;
1602 if(copy_to_user(argp, &moxaLog, sizeof(mon_st))) 1508 if(copy_to_user(argp, &moxaLog, sizeof(struct mon_str)))
1603 return -EFAULT; 1509 return -EFAULT;
1604 return (0); 1510 return (0);
1605 case MOXA_FLUSH_QUEUE: 1511 case MOXA_FLUSH_QUEUE:
1606 MoxaPortFlushData(port, arg); 1512 MoxaPortFlushData(port, arg);
1607 return (0); 1513 return (0);
1608 case MOXA_GET_IOQUEUE: 1514 case MOXA_GET_IOQUEUE: {
1609 for (i = 0; i < MAX_PORTS; i++) { 1515 struct moxaq_str __user *argm = argp;
1610 if (moxaChkPort[i]) { 1516 struct moxaq_str tmp;
1611 temp_queue[i].inq = MoxaPortRxQueue(i); 1517
1612 temp_queue[i].outq = MoxaPortTxQueue(i); 1518 for (i = 0; i < MAX_PORTS; i++, argm++) {
1519 memset(&tmp, 0, sizeof(tmp));
1520 if (moxa_ports[i].chkPort) {
1521 tmp.inq = MoxaPortRxQueue(i);
1522 tmp.outq = MoxaPortTxQueue(i);
1613 } 1523 }
1524 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1525 return -EFAULT;
1614 } 1526 }
1615 if(copy_to_user(argp, temp_queue, sizeof(struct moxaq_str) * MAX_PORTS))
1616 return -EFAULT;
1617 return (0); 1527 return (0);
1618 case MOXA_GET_OQUEUE: 1528 } case MOXA_GET_OQUEUE:
1619 i = MoxaPortTxQueue(port); 1529 i = MoxaPortTxQueue(port);
1620 return put_user(i, (unsigned long __user *)argp); 1530 return put_user(i, (unsigned long __user *)argp);
1621 case MOXA_GET_IQUEUE: 1531 case MOXA_GET_IQUEUE:
@@ -1630,33 +1540,36 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1630 if(copy_to_user(argp, &i, sizeof(int))) 1540 if(copy_to_user(argp, &i, sizeof(int)))
1631 return -EFAULT; 1541 return -EFAULT;
1632 return 0; 1542 return 0;
1633 case MOXA_GETMSTATUS: 1543 case MOXA_GETMSTATUS: {
1634 for (i = 0; i < MAX_PORTS; i++) { 1544 struct mxser_mstatus __user *argm = argp;
1635 GMStatus[i].ri = 0; 1545 struct mxser_mstatus tmp;
1636 GMStatus[i].dcd = 0; 1546 struct moxa_port *p;
1637 GMStatus[i].dsr = 0; 1547
1638 GMStatus[i].cts = 0; 1548 for (i = 0; i < MAX_PORTS; i++, argm++) {
1639 if (!moxaChkPort[i]) { 1549 p = &moxa_ports[i];
1640 continue; 1550 memset(&tmp, 0, sizeof(tmp));
1551 if (!p->chkPort) {
1552 goto copy;
1641 } else { 1553 } else {
1642 status = MoxaPortLineStatus(moxaChannels[i].port); 1554 status = MoxaPortLineStatus(p->port);
1643 if (status & 1) 1555 if (status & 1)
1644 GMStatus[i].cts = 1; 1556 tmp.cts = 1;
1645 if (status & 2) 1557 if (status & 2)
1646 GMStatus[i].dsr = 1; 1558 tmp.dsr = 1;
1647 if (status & 4) 1559 if (status & 4)
1648 GMStatus[i].dcd = 1; 1560 tmp.dcd = 1;
1649 } 1561 }
1650 1562
1651 if (!moxaChannels[i].tty || !moxaChannels[i].tty->termios) 1563 if (!p->tty || !p->tty->termios)
1652 GMStatus[i].cflag = moxaChannels[i].cflag; 1564 tmp.cflag = p->cflag;
1653 else 1565 else
1654 GMStatus[i].cflag = moxaChannels[i].tty->termios->c_cflag; 1566 tmp.cflag = p->tty->termios->c_cflag;
1567copy:
1568 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1569 return -EFAULT;
1655 } 1570 }
1656 if(copy_to_user(argp, GMStatus, sizeof(struct mxser_mstatus) * MAX_PORTS))
1657 return -EFAULT;
1658 return 0; 1571 return 0;
1659 default: 1572 } default:
1660 return (-ENOIOCTLCMD); 1573 return (-ENOIOCTLCMD);
1661 case MOXA_LOAD_BIOS: 1574 case MOXA_LOAD_BIOS:
1662 case MOXA_FIND_BOARD: 1575 case MOXA_FIND_BOARD:
@@ -1694,6 +1607,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1694 1607
1695int MoxaDriverPoll(void) 1608int MoxaDriverPoll(void)
1696{ 1609{
1610 struct moxa_board_conf *brd;
1697 register ushort temp; 1611 register ushort temp;
1698 register int card; 1612 register int card;
1699 void __iomem *ofsAddr; 1613 void __iomem *ofsAddr;
@@ -1703,43 +1617,44 @@ int MoxaDriverPoll(void)
1703 if (moxaCard == 0) 1617 if (moxaCard == 0)
1704 return (-1); 1618 return (-1);
1705 for (card = 0; card < MAX_BOARDS; card++) { 1619 for (card = 0; card < MAX_BOARDS; card++) {
1706 if (loadstat[card] == 0) 1620 brd = &moxa_boards[card];
1621 if (brd->loadstat == 0)
1707 continue; 1622 continue;
1708 if ((ports = moxa_boards[card].numPorts) == 0) 1623 if ((ports = brd->numPorts) == 0)
1709 continue; 1624 continue;
1710 if (readb(moxaIntPend[card]) == 0xff) { 1625 if (readb(brd->intPend) == 0xff) {
1711 ip = moxaIntTable[card] + readb(moxaIntNdx[card]); 1626 ip = brd->intTable + readb(brd->intNdx);
1712 p = card * MAX_PORTS_PER_BOARD; 1627 p = card * MAX_PORTS_PER_BOARD;
1713 ports <<= 1; 1628 ports <<= 1;
1714 for (port = 0; port < ports; port += 2, p++) { 1629 for (port = 0; port < ports; port += 2, p++) {
1715 if ((temp = readw(ip + port)) != 0) { 1630 if ((temp = readw(ip + port)) != 0) {
1716 writew(0, ip + port); 1631 writew(0, ip + port);
1717 ofsAddr = moxaTableAddr[p]; 1632 ofsAddr = moxa_ports[p].tableAddr;
1718 if (temp & IntrTx) 1633 if (temp & IntrTx)
1719 writew(readw(ofsAddr + HostStat) & ~WakeupTx, ofsAddr + HostStat); 1634 writew(readw(ofsAddr + HostStat) & ~WakeupTx, ofsAddr + HostStat);
1720 if (temp & IntrBreak) { 1635 if (temp & IntrBreak) {
1721 moxaBreakCnt[p]++; 1636 moxa_ports[p].breakCnt++;
1722 } 1637 }
1723 if (temp & IntrLine) { 1638 if (temp & IntrLine) {
1724 if (readb(ofsAddr + FlagStat) & DCD_state) { 1639 if (readb(ofsAddr + FlagStat) & DCD_state) {
1725 if ((moxaDCDState[p] & DCD_oldstate) == 0) 1640 if ((moxa_ports[p].DCDState & DCD_oldstate) == 0)
1726 moxaDCDState[p] = (DCD_oldstate | 1641 moxa_ports[p].DCDState = (DCD_oldstate |
1727 DCD_changed); 1642 DCD_changed);
1728 } else { 1643 } else {
1729 if (moxaDCDState[p] & DCD_oldstate) 1644 if (moxa_ports[p].DCDState & DCD_oldstate)
1730 moxaDCDState[p] = DCD_changed; 1645 moxa_ports[p].DCDState = DCD_changed;
1731 } 1646 }
1732 } 1647 }
1733 } 1648 }
1734 } 1649 }
1735 writeb(0, moxaIntPend[card]); 1650 writeb(0, brd->intPend);
1736 } 1651 }
1737 if (moxaLowWaterChk) { 1652 if (moxaLowWaterChk) {
1738 p = card * MAX_PORTS_PER_BOARD; 1653 p = card * MAX_PORTS_PER_BOARD;
1739 for (port = 0; port < ports; port++, p++) { 1654 for (port = 0; port < ports; port++, p++) {
1740 if (moxaLowChkFlag[p]) { 1655 if (moxa_ports[p].lowChkFlag) {
1741 moxaLowChkFlag[p] = 0; 1656 moxa_ports[p].lowChkFlag = 0;
1742 ofsAddr = moxaTableAddr[p]; 1657 ofsAddr = moxa_ports[p].tableAddr;
1743 low_water_check(ofsAddr); 1658 low_water_check(ofsAddr);
1744 } 1659 }
1745 } 1660 }
@@ -1767,9 +1682,7 @@ int MoxaPortsOfCard(int cardno)
1767 * 2. MoxaPortEnable(int port); * 1682 * 2. MoxaPortEnable(int port); *
1768 * 3. MoxaPortDisable(int port); * 1683 * 3. MoxaPortDisable(int port); *
1769 * 4. MoxaPortGetMaxBaud(int port); * 1684 * 4. MoxaPortGetMaxBaud(int port); *
1770 * 5. MoxaPortGetCurBaud(int port); *
1771 * 6. MoxaPortSetBaud(int port, long baud); * 1685 * 6. MoxaPortSetBaud(int port, long baud); *
1772 * 7. MoxaPortSetMode(int port, int databit, int stopbit, int parity); *
1773 * 8. MoxaPortSetTermio(int port, unsigned char *termio); * 1686 * 8. MoxaPortSetTermio(int port, unsigned char *termio); *
1774 * 9. MoxaPortGetLineOut(int port, int *dtrState, int *rtsState); * 1687 * 9. MoxaPortGetLineOut(int port, int *dtrState, int *rtsState); *
1775 * 10. MoxaPortLineCtrl(int port, int dtrState, int rtsState); * 1688 * 10. MoxaPortLineCtrl(int port, int dtrState, int rtsState); *
@@ -1780,18 +1693,12 @@ int MoxaPortsOfCard(int cardno)
1780 * 15. MoxaPortFlushData(int port, int mode); * 1693 * 15. MoxaPortFlushData(int port, int mode); *
1781 * 16. MoxaPortWriteData(int port, unsigned char * buffer, int length); * 1694 * 16. MoxaPortWriteData(int port, unsigned char * buffer, int length); *
1782 * 17. MoxaPortReadData(int port, struct tty_struct *tty); * 1695 * 17. MoxaPortReadData(int port, struct tty_struct *tty); *
1783 * 18. MoxaPortTxBufSize(int port); *
1784 * 19. MoxaPortRxBufSize(int port); *
1785 * 20. MoxaPortTxQueue(int port); * 1696 * 20. MoxaPortTxQueue(int port); *
1786 * 21. MoxaPortTxFree(int port); * 1697 * 21. MoxaPortTxFree(int port); *
1787 * 22. MoxaPortRxQueue(int port); * 1698 * 22. MoxaPortRxQueue(int port); *
1788 * 23. MoxaPortRxFree(int port); *
1789 * 24. MoxaPortTxDisable(int port); * 1699 * 24. MoxaPortTxDisable(int port); *
1790 * 25. MoxaPortTxEnable(int port); * 1700 * 25. MoxaPortTxEnable(int port); *
1791 * 26. MoxaPortGetBrkCnt(int port); *
1792 * 27. MoxaPortResetBrkCnt(int port); * 1701 * 27. MoxaPortResetBrkCnt(int port); *
1793 * 28. MoxaPortSetXonXoff(int port, int xonValue, int xoffValue); *
1794 * 29. MoxaPortIsTxHold(int port); *
1795 * 30. MoxaPortSendBreak(int port, int ticks); * 1702 * 30. MoxaPortSendBreak(int port, int ticks); *
1796 *****************************************************************************/ 1703 *****************************************************************************/
1797/* 1704/*
@@ -1878,15 +1785,6 @@ int MoxaPortsOfCard(int cardno)
1878 * 38400/57600/115200 bps 1785 * 38400/57600/115200 bps
1879 * 1786 *
1880 * 1787 *
1881 * Function 9: Get the current baud rate of this port.
1882 * Syntax:
1883 * long MoxaPortGetCurBaud(int port);
1884 * int port : port number (0 - 127)
1885 *
1886 * return: 0 : this port is invalid
1887 * 50 - 115200 bps
1888 *
1889 *
1890 * Function 10: Setting baud rate of this port. 1788 * Function 10: Setting baud rate of this port.
1891 * Syntax: 1789 * Syntax:
1892 * long MoxaPortSetBaud(int port, long baud); 1790 * long MoxaPortSetBaud(int port, long baud);
@@ -1900,18 +1798,6 @@ int MoxaPortsOfCard(int cardno)
1900 * baud rate will be the maximun baud rate. 1798 * baud rate will be the maximun baud rate.
1901 * 1799 *
1902 * 1800 *
1903 * Function 11: Setting the data-bits/stop-bits/parity of this port
1904 * Syntax:
1905 * int MoxaPortSetMode(int port, int databits, int stopbits, int parity);
1906 * int port : port number (0 - 127)
1907 * int databits : data bits (8/7/6/5)
1908 * int stopbits : stop bits (2/1/0, 0 show 1.5 stop bits)
1909 int parity : parity (0:None,1:Odd,2:Even,3:Mark,4:Space)
1910 *
1911 * return: -1 : invalid parameter
1912 * 0 : setting O.K.
1913 *
1914 *
1915 * Function 12: Configure the port. 1801 * Function 12: Configure the port.
1916 * Syntax: 1802 * Syntax:
1917 * int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud); 1803 * int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud);
@@ -2016,22 +1902,6 @@ int MoxaPortsOfCard(int cardno)
2016 * return: 0 - length : real read data length 1902 * return: 0 - length : real read data length
2017 * 1903 *
2018 * 1904 *
2019 * Function 22: Get the Tx buffer size of this port
2020 * Syntax:
2021 * int MoxaPortTxBufSize(int port);
2022 * int port : port number (0 - 127)
2023 *
2024 * return: .. : Tx buffer size
2025 *
2026 *
2027 * Function 23: Get the Rx buffer size of this port
2028 * Syntax:
2029 * int MoxaPortRxBufSize(int port);
2030 * int port : port number (0 - 127)
2031 *
2032 * return: .. : Rx buffer size
2033 *
2034 *
2035 * Function 24: Get the Tx buffer current queued data bytes 1905 * Function 24: Get the Tx buffer current queued data bytes
2036 * Syntax: 1906 * Syntax:
2037 * int MoxaPortTxQueue(int port); 1907 * int MoxaPortTxQueue(int port);
@@ -2056,14 +1926,6 @@ int MoxaPortsOfCard(int cardno)
2056 * return: .. : Rx buffer current queued data bytes 1926 * return: .. : Rx buffer current queued data bytes
2057 * 1927 *
2058 * 1928 *
2059 * Function 27: Get the Rx buffer current free space
2060 * Syntax:
2061 * int MoxaPortRxFree(int port);
2062 * int port : port number (0 - 127)
2063 *
2064 * return: .. : Rx buffer current free space
2065 *
2066 *
2067 * Function 28: Disable port data transmission. 1929 * Function 28: Disable port data transmission.
2068 * Syntax: 1930 * Syntax:
2069 * void MoxaPortTxDisable(int port); 1931 * void MoxaPortTxDisable(int port);
@@ -2076,14 +1938,6 @@ int MoxaPortsOfCard(int cardno)
2076 * int port : port number (0 - 127) 1938 * int port : port number (0 - 127)
2077 * 1939 *
2078 * 1940 *
2079 * Function 30: Get the received BREAK signal count.
2080 * Syntax:
2081 * int MoxaPortGetBrkCnt(int port);
2082 * int port : port number (0 - 127)
2083 *
2084 * return: 0 - .. : BREAK signal count
2085 *
2086 *
2087 * Function 31: Get the received BREAK signal count and reset it. 1941 * Function 31: Get the received BREAK signal count and reset it.
2088 * Syntax: 1942 * Syntax:
2089 * int MoxaPortResetBrkCnt(int port); 1943 * int MoxaPortResetBrkCnt(int port);
@@ -2092,25 +1946,6 @@ int MoxaPortsOfCard(int cardno)
2092 * return: 0 - .. : BREAK signal count 1946 * return: 0 - .. : BREAK signal count
2093 * 1947 *
2094 * 1948 *
2095 * Function 32: Set the S/W flow control new XON/XOFF value, default
2096 * XON is 0x11 & XOFF is 0x13.
2097 * Syntax:
2098 * void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue);
2099 * int port : port number (0 - 127)
2100 * int xonValue : new XON value (0 - 255)
2101 * int xoffValue : new XOFF value (0 - 255)
2102 *
2103 *
2104 * Function 33: Check this port's transmission is hold by remote site
2105 * because the flow control.
2106 * Syntax:
2107 * int MoxaPortIsTxHold(int port);
2108 * int port : port number (0 - 127)
2109 *
2110 * return: 0 : normal
2111 * 1 : hold by remote site
2112 *
2113 *
2114 * Function 34: Send out a BREAK signal. 1949 * Function 34: Send out a BREAK signal.
2115 * Syntax: 1950 * Syntax:
2116 * void MoxaPortSendBreak(int port, int ms100); 1951 * void MoxaPortSendBreak(int port, int ms100);
@@ -2125,7 +1960,7 @@ int MoxaPortIsValid(int port)
2125 1960
2126 if (moxaCard == 0) 1961 if (moxaCard == 0)
2127 return (0); 1962 return (0);
2128 if (moxaChkPort[port] == 0) 1963 if (moxa_ports[port].chkPort == 0)
2129 return (0); 1964 return (0);
2130 return (1); 1965 return (1);
2131} 1966}
@@ -2136,9 +1971,9 @@ void MoxaPortEnable(int port)
2136 int MoxaPortLineStatus(int); 1971 int MoxaPortLineStatus(int);
2137 short lowwater = 512; 1972 short lowwater = 512;
2138 1973
2139 ofsAddr = moxaTableAddr[port]; 1974 ofsAddr = moxa_ports[port].tableAddr;
2140 writew(lowwater, ofsAddr + Low_water); 1975 writew(lowwater, ofsAddr + Low_water);
2141 moxaBreakCnt[port] = 0; 1976 moxa_ports[port].breakCnt = 0;
2142 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || 1977 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
2143 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { 1978 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
2144 moxafunc(ofsAddr, FC_SetBreakIrq, 0); 1979 moxafunc(ofsAddr, FC_SetBreakIrq, 0);
@@ -2155,7 +1990,7 @@ void MoxaPortEnable(int port)
2155 1990
2156void MoxaPortDisable(int port) 1991void MoxaPortDisable(int port)
2157{ 1992{
2158 void __iomem *ofsAddr = moxaTableAddr[port]; 1993 void __iomem *ofsAddr = moxa_ports[port].tableAddr;
2159 1994
2160 moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */ 1995 moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */
2161 moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code); 1996 moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
@@ -2181,7 +2016,7 @@ long MoxaPortSetBaud(int port, long baud)
2181 2016
2182 if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) 2017 if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0))
2183 return (0); 2018 return (0);
2184 ofsAddr = moxaTableAddr[port]; 2019 ofsAddr = moxa_ports[port].tableAddr;
2185 if (baud > max) 2020 if (baud > max)
2186 baud = max; 2021 baud = max;
2187 if (max == 38400L) 2022 if (max == 38400L)
@@ -2193,7 +2028,7 @@ long MoxaPortSetBaud(int port, long baud)
2193 val = clock / baud; 2028 val = clock / baud;
2194 moxafunc(ofsAddr, FC_SetBaud, val); 2029 moxafunc(ofsAddr, FC_SetBaud, val);
2195 baud = clock / val; 2030 baud = clock / val;
2196 moxaCurBaud[port] = baud; 2031 moxa_ports[port].curBaud = baud;
2197 return (baud); 2032 return (baud);
2198} 2033}
2199 2034
@@ -2203,9 +2038,9 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
2203 tcflag_t cflag; 2038 tcflag_t cflag;
2204 tcflag_t mode = 0; 2039 tcflag_t mode = 0;
2205 2040
2206 if (moxaChkPort[port] == 0 || termio == 0) 2041 if (moxa_ports[port].chkPort == 0 || termio == 0)
2207 return (-1); 2042 return (-1);
2208 ofsAddr = moxaTableAddr[port]; 2043 ofsAddr = moxa_ports[port].tableAddr;
2209 cflag = termio->c_cflag; /* termio->c_cflag */ 2044 cflag = termio->c_cflag; /* termio->c_cflag */
2210 2045
2211 mode = termio->c_cflag & CSIZE; 2046 mode = termio->c_cflag & CSIZE;
@@ -2259,13 +2094,13 @@ int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState)
2259 if (!MoxaPortIsValid(port)) 2094 if (!MoxaPortIsValid(port))
2260 return (-1); 2095 return (-1);
2261 if (dtrState) { 2096 if (dtrState) {
2262 if (moxaLineCtrl[port] & DTR_ON) 2097 if (moxa_ports[port].lineCtrl & DTR_ON)
2263 *dtrState = 1; 2098 *dtrState = 1;
2264 else 2099 else
2265 *dtrState = 0; 2100 *dtrState = 0;
2266 } 2101 }
2267 if (rtsState) { 2102 if (rtsState) {
2268 if (moxaLineCtrl[port] & RTS_ON) 2103 if (moxa_ports[port].lineCtrl & RTS_ON)
2269 *rtsState = 1; 2104 *rtsState = 1;
2270 else 2105 else
2271 *rtsState = 0; 2106 *rtsState = 0;
@@ -2278,13 +2113,13 @@ void MoxaPortLineCtrl(int port, int dtr, int rts)
2278 void __iomem *ofsAddr; 2113 void __iomem *ofsAddr;
2279 int mode; 2114 int mode;
2280 2115
2281 ofsAddr = moxaTableAddr[port]; 2116 ofsAddr = moxa_ports[port].tableAddr;
2282 mode = 0; 2117 mode = 0;
2283 if (dtr) 2118 if (dtr)
2284 mode |= DTR_ON; 2119 mode |= DTR_ON;
2285 if (rts) 2120 if (rts)
2286 mode |= RTS_ON; 2121 mode |= RTS_ON;
2287 moxaLineCtrl[port] = mode; 2122 moxa_ports[port].lineCtrl = mode;
2288 moxafunc(ofsAddr, FC_LineControl, mode); 2123 moxafunc(ofsAddr, FC_LineControl, mode);
2289} 2124}
2290 2125
@@ -2293,7 +2128,7 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx
2293 void __iomem *ofsAddr; 2128 void __iomem *ofsAddr;
2294 int mode; 2129 int mode;
2295 2130
2296 ofsAddr = moxaTableAddr[port]; 2131 ofsAddr = moxa_ports[port].tableAddr;
2297 mode = 0; 2132 mode = 0;
2298 if (rts) 2133 if (rts)
2299 mode |= RTS_FlowCtl; 2134 mode |= RTS_FlowCtl;
@@ -2313,7 +2148,7 @@ int MoxaPortLineStatus(int port)
2313 void __iomem *ofsAddr; 2148 void __iomem *ofsAddr;
2314 int val; 2149 int val;
2315 2150
2316 ofsAddr = moxaTableAddr[port]; 2151 ofsAddr = moxa_ports[port].tableAddr;
2317 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || 2152 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
2318 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { 2153 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
2319 moxafunc(ofsAddr, FC_LineStatus, 0); 2154 moxafunc(ofsAddr, FC_LineStatus, 0);
@@ -2324,11 +2159,11 @@ int MoxaPortLineStatus(int port)
2324 val &= 0x0B; 2159 val &= 0x0B;
2325 if (val & 8) { 2160 if (val & 8) {
2326 val |= 4; 2161 val |= 4;
2327 if ((moxaDCDState[port] & DCD_oldstate) == 0) 2162 if ((moxa_ports[port].DCDState & DCD_oldstate) == 0)
2328 moxaDCDState[port] = (DCD_oldstate | DCD_changed); 2163 moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed);
2329 } else { 2164 } else {
2330 if (moxaDCDState[port] & DCD_oldstate) 2165 if (moxa_ports[port].DCDState & DCD_oldstate)
2331 moxaDCDState[port] = DCD_changed; 2166 moxa_ports[port].DCDState = DCD_changed;
2332 } 2167 }
2333 val &= 7; 2168 val &= 7;
2334 return (val); 2169 return (val);
@@ -2338,10 +2173,10 @@ int MoxaPortDCDChange(int port)
2338{ 2173{
2339 int n; 2174 int n;
2340 2175
2341 if (moxaChkPort[port] == 0) 2176 if (moxa_ports[port].chkPort == 0)
2342 return (0); 2177 return (0);
2343 n = moxaDCDState[port]; 2178 n = moxa_ports[port].DCDState;
2344 moxaDCDState[port] &= ~DCD_changed; 2179 moxa_ports[port].DCDState &= ~DCD_changed;
2345 n &= DCD_changed; 2180 n &= DCD_changed;
2346 return (n); 2181 return (n);
2347} 2182}
@@ -2350,32 +2185,15 @@ int MoxaPortDCDON(int port)
2350{ 2185{
2351 int n; 2186 int n;
2352 2187
2353 if (moxaChkPort[port] == 0) 2188 if (moxa_ports[port].chkPort == 0)
2354 return (0); 2189 return (0);
2355 if (moxaDCDState[port] & DCD_oldstate) 2190 if (moxa_ports[port].DCDState & DCD_oldstate)
2356 n = 1; 2191 n = 1;
2357 else 2192 else
2358 n = 0; 2193 n = 0;
2359 return (n); 2194 return (n);
2360} 2195}
2361 2196
2362
2363/*
2364 int MoxaDumpMem(int port, unsigned char * buffer, int len)
2365 {
2366 int i;
2367 unsigned long baseAddr,ofsAddr,ofs;
2368
2369 baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
2370 ofs = baseAddr + DynPage_addr + pageofs;
2371 if (len > 0x2000L)
2372 len = 0x2000L;
2373 for (i = 0; i < len; i++)
2374 buffer[i] = readb(ofs+i);
2375 }
2376 */
2377
2378
2379int MoxaPortWriteData(int port, unsigned char * buffer, int len) 2197int MoxaPortWriteData(int port, unsigned char * buffer, int len)
2380{ 2198{
2381 int c, total, i; 2199 int c, total, i;
@@ -2385,8 +2203,8 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
2385 ushort pageno, pageofs, bufhead; 2203 ushort pageno, pageofs, bufhead;
2386 void __iomem *baseAddr, *ofsAddr, *ofs; 2204 void __iomem *baseAddr, *ofsAddr, *ofs;
2387 2205
2388 ofsAddr = moxaTableAddr[port]; 2206 ofsAddr = moxa_ports[port].tableAddr;
2389 baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD]; 2207 baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
2390 tx_mask = readw(ofsAddr + TX_mask); 2208 tx_mask = readw(ofsAddr + TX_mask);
2391 spage = readw(ofsAddr + Page_txb); 2209 spage = readw(ofsAddr + Page_txb);
2392 epage = readw(ofsAddr + EndPage_txb); 2210 epage = readw(ofsAddr + EndPage_txb);
@@ -2448,8 +2266,8 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
2448 ushort pageno, bufhead; 2266 ushort pageno, bufhead;
2449 void __iomem *baseAddr, *ofsAddr, *ofs; 2267 void __iomem *baseAddr, *ofsAddr, *ofs;
2450 2268
2451 ofsAddr = moxaTableAddr[port]; 2269 ofsAddr = moxa_ports[port].tableAddr;
2452 baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD]; 2270 baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem;
2453 head = readw(ofsAddr + RXrptr); 2271 head = readw(ofsAddr + RXrptr);
2454 tail = readw(ofsAddr + RXwptr); 2272 tail = readw(ofsAddr + RXwptr);
2455 rx_mask = readw(ofsAddr + RX_mask); 2273 rx_mask = readw(ofsAddr + RX_mask);
@@ -2504,7 +2322,7 @@ int MoxaPortReadData(int port, struct tty_struct *tty)
2504 } 2322 }
2505 if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) { 2323 if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) {
2506 moxaLowWaterChk = 1; 2324 moxaLowWaterChk = 1;
2507 moxaLowChkFlag[port] = 1; 2325 moxa_ports[port].lowChkFlag = 1;
2508 } 2326 }
2509 return (total); 2327 return (total);
2510} 2328}
@@ -2516,7 +2334,7 @@ int MoxaPortTxQueue(int port)
2516 ushort rptr, wptr, mask; 2334 ushort rptr, wptr, mask;
2517 int len; 2335 int len;
2518 2336
2519 ofsAddr = moxaTableAddr[port]; 2337 ofsAddr = moxa_ports[port].tableAddr;
2520 rptr = readw(ofsAddr + TXrptr); 2338 rptr = readw(ofsAddr + TXrptr);
2521 wptr = readw(ofsAddr + TXwptr); 2339 wptr = readw(ofsAddr + TXwptr);
2522 mask = readw(ofsAddr + TX_mask); 2340 mask = readw(ofsAddr + TX_mask);
@@ -2530,7 +2348,7 @@ int MoxaPortTxFree(int port)
2530 ushort rptr, wptr, mask; 2348 ushort rptr, wptr, mask;
2531 int len; 2349 int len;
2532 2350
2533 ofsAddr = moxaTableAddr[port]; 2351 ofsAddr = moxa_ports[port].tableAddr;
2534 rptr = readw(ofsAddr + TXrptr); 2352 rptr = readw(ofsAddr + TXrptr);
2535 wptr = readw(ofsAddr + TXwptr); 2353 wptr = readw(ofsAddr + TXwptr);
2536 mask = readw(ofsAddr + TX_mask); 2354 mask = readw(ofsAddr + TX_mask);
@@ -2544,7 +2362,7 @@ int MoxaPortRxQueue(int port)
2544 ushort rptr, wptr, mask; 2362 ushort rptr, wptr, mask;
2545 int len; 2363 int len;
2546 2364
2547 ofsAddr = moxaTableAddr[port]; 2365 ofsAddr = moxa_ports[port].tableAddr;
2548 rptr = readw(ofsAddr + RXrptr); 2366 rptr = readw(ofsAddr + RXrptr);
2549 wptr = readw(ofsAddr + RXwptr); 2367 wptr = readw(ofsAddr + RXwptr);
2550 mask = readw(ofsAddr + RX_mask); 2368 mask = readw(ofsAddr + RX_mask);
@@ -2557,7 +2375,7 @@ void MoxaPortTxDisable(int port)
2557{ 2375{
2558 void __iomem *ofsAddr; 2376 void __iomem *ofsAddr;
2559 2377
2560 ofsAddr = moxaTableAddr[port]; 2378 ofsAddr = moxa_ports[port].tableAddr;
2561 moxafunc(ofsAddr, FC_SetXoffState, Magic_code); 2379 moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
2562} 2380}
2563 2381
@@ -2565,7 +2383,7 @@ void MoxaPortTxEnable(int port)
2565{ 2383{
2566 void __iomem *ofsAddr; 2384 void __iomem *ofsAddr;
2567 2385
2568 ofsAddr = moxaTableAddr[port]; 2386 ofsAddr = moxa_ports[port].tableAddr;
2569 moxafunc(ofsAddr, FC_SetXonState, Magic_code); 2387 moxafunc(ofsAddr, FC_SetXonState, Magic_code);
2570} 2388}
2571 2389
@@ -2573,8 +2391,8 @@ void MoxaPortTxEnable(int port)
2573int MoxaPortResetBrkCnt(int port) 2391int MoxaPortResetBrkCnt(int port)
2574{ 2392{
2575 ushort cnt; 2393 ushort cnt;
2576 cnt = moxaBreakCnt[port]; 2394 cnt = moxa_ports[port].breakCnt;
2577 moxaBreakCnt[port] = 0; 2395 moxa_ports[port].breakCnt = 0;
2578 return (cnt); 2396 return (cnt);
2579} 2397}
2580 2398
@@ -2583,7 +2401,7 @@ void MoxaPortSendBreak(int port, int ms100)
2583{ 2401{
2584 void __iomem *ofsAddr; 2402 void __iomem *ofsAddr;
2585 2403
2586 ofsAddr = moxaTableAddr[port]; 2404 ofsAddr = moxa_ports[port].tableAddr;
2587 if (ms100) { 2405 if (ms100) {
2588 moxafunc(ofsAddr, FC_SendBreak, Magic_code); 2406 moxafunc(ofsAddr, FC_SendBreak, Magic_code);
2589 moxadelay(ms100 * (HZ / 10)); 2407 moxadelay(ms100 * (HZ / 10));
@@ -2594,7 +2412,7 @@ void MoxaPortSendBreak(int port, int ms100)
2594 moxafunc(ofsAddr, FC_StopBreak, Magic_code); 2412 moxafunc(ofsAddr, FC_StopBreak, Magic_code);
2595} 2413}
2596 2414
2597static int moxa_get_serial_info(struct moxa_str *info, 2415static int moxa_get_serial_info(struct moxa_port *info,
2598 struct serial_struct __user *retinfo) 2416 struct serial_struct __user *retinfo)
2599{ 2417{
2600 struct serial_struct tmp; 2418 struct serial_struct tmp;
@@ -2616,7 +2434,7 @@ static int moxa_get_serial_info(struct moxa_str *info,
2616} 2434}
2617 2435
2618 2436
2619static int moxa_set_serial_info(struct moxa_str *info, 2437static int moxa_set_serial_info(struct moxa_port *info,
2620 struct serial_struct __user *new_info) 2438 struct serial_struct __user *new_info)
2621{ 2439{
2622 struct serial_struct new_serial; 2440 struct serial_struct new_serial;
@@ -2713,7 +2531,7 @@ static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
2713 2531
2714 if(copy_from_user(moxaBuff, tmp, len)) 2532 if(copy_from_user(moxaBuff, tmp, len))
2715 return -EFAULT; 2533 return -EFAULT;
2716 baseAddr = moxaBaseAddr[cardno]; 2534 baseAddr = moxa_boards[cardno].basemem;
2717 writeb(HW_reset, baseAddr + Control_reg); /* reset */ 2535 writeb(HW_reset, baseAddr + Control_reg); /* reset */
2718 moxadelay(1); /* delay 10 ms */ 2536 moxadelay(1); /* delay 10 ms */
2719 for (i = 0; i < 4096; i++) 2537 for (i = 0; i < 4096; i++)
@@ -2729,7 +2547,7 @@ static int moxafindcard(int cardno)
2729 void __iomem *baseAddr; 2547 void __iomem *baseAddr;
2730 ushort tmp; 2548 ushort tmp;
2731 2549
2732 baseAddr = moxaBaseAddr[cardno]; 2550 baseAddr = moxa_boards[cardno].basemem;
2733 switch (moxa_boards[cardno].boardType) { 2551 switch (moxa_boards[cardno].boardType) {
2734 case MOXA_BOARD_C218_ISA: 2552 case MOXA_BOARD_C218_ISA:
2735 case MOXA_BOARD_C218_PCI: 2553 case MOXA_BOARD_C218_PCI:
@@ -2762,7 +2580,7 @@ static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
2762 return -EINVAL; 2580 return -EINVAL;
2763 if(copy_from_user(moxaBuff, tmp, len)) 2581 if(copy_from_user(moxaBuff, tmp, len))
2764 return -EFAULT; 2582 return -EFAULT;
2765 baseAddr = moxaBaseAddr[cardno]; 2583 baseAddr = moxa_boards[cardno].basemem;
2766 writew(len - 7168 - 2, baseAddr + C320bapi_len); 2584 writew(len - 7168 - 2, baseAddr + C320bapi_len);
2767 writeb(1, baseAddr + Control_reg); /* Select Page 1 */ 2585 writeb(1, baseAddr + Control_reg); /* Select Page 1 */
2768 for (i = 0; i < 7168; i++) 2586 for (i = 0; i < 7168; i++)
@@ -2780,7 +2598,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
2780 2598
2781 if(copy_from_user(moxaBuff, tmp, len)) 2599 if(copy_from_user(moxaBuff, tmp, len))
2782 return -EFAULT; 2600 return -EFAULT;
2783 baseAddr = moxaBaseAddr[cardno]; 2601 baseAddr = moxa_boards[cardno].basemem;
2784 switch (moxa_boards[cardno].boardType) { 2602 switch (moxa_boards[cardno].boardType) {
2785 case MOXA_BOARD_C218_ISA: 2603 case MOXA_BOARD_C218_ISA:
2786 case MOXA_BOARD_C218_PCI: 2604 case MOXA_BOARD_C218_PCI:
@@ -2790,11 +2608,13 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
2790 return (retval); 2608 return (retval);
2791 port = cardno * MAX_PORTS_PER_BOARD; 2609 port = cardno * MAX_PORTS_PER_BOARD;
2792 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) { 2610 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
2793 moxaChkPort[port] = 1; 2611 struct moxa_port *p = &moxa_ports[port];
2794 moxaCurBaud[port] = 9600L; 2612
2795 moxaDCDState[port] = 0; 2613 p->chkPort = 1;
2796 moxaTableAddr[port] = baseAddr + Extern_table + Extern_size * i; 2614 p->curBaud = 9600L;
2797 ofsAddr = moxaTableAddr[port]; 2615 p->DCDState = 0;
2616 p->tableAddr = baseAddr + Extern_table + Extern_size * i;
2617 ofsAddr = p->tableAddr;
2798 writew(C218rx_mask, ofsAddr + RX_mask); 2618 writew(C218rx_mask, ofsAddr + RX_mask);
2799 writew(C218tx_mask, ofsAddr + TX_mask); 2619 writew(C218tx_mask, ofsAddr + TX_mask);
2800 writew(C218rx_spage + i * C218buf_pageno, ofsAddr + Page_rxb); 2620 writew(C218rx_spage + i * C218buf_pageno, ofsAddr + Page_rxb);
@@ -2812,11 +2632,13 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
2812 return (retval); 2632 return (retval);
2813 port = cardno * MAX_PORTS_PER_BOARD; 2633 port = cardno * MAX_PORTS_PER_BOARD;
2814 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) { 2634 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
2815 moxaChkPort[port] = 1; 2635 struct moxa_port *p = &moxa_ports[port];
2816 moxaCurBaud[port] = 9600L; 2636
2817 moxaDCDState[port] = 0; 2637 p->chkPort = 1;
2818 moxaTableAddr[port] = baseAddr + Extern_table + Extern_size * i; 2638 p->curBaud = 9600L;
2819 ofsAddr = moxaTableAddr[port]; 2639 p->DCDState = 0;
2640 p->tableAddr = baseAddr + Extern_table + Extern_size * i;
2641 ofsAddr = p->tableAddr;
2820 if (moxa_boards[cardno].numPorts == 8) { 2642 if (moxa_boards[cardno].numPorts == 8) {
2821 writew(C320p8rx_mask, ofsAddr + RX_mask); 2643 writew(C320p8rx_mask, ofsAddr + RX_mask);
2822 writew(C320p8tx_mask, ofsAddr + TX_mask); 2644 writew(C320p8tx_mask, ofsAddr + TX_mask);
@@ -2852,7 +2674,7 @@ static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
2852 } 2674 }
2853 break; 2675 break;
2854 } 2676 }
2855 loadstat[cardno] = 1; 2677 moxa_boards[cardno].loadstat = 1;
2856 return (0); 2678 return (0);
2857} 2679}
2858 2680
@@ -2926,9 +2748,9 @@ static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2926 return (-1); 2748 return (-1);
2927 } 2749 }
2928 moxaCard = 1; 2750 moxaCard = 1;
2929 moxaIntNdx[cardno] = baseAddr + IRQindex; 2751 moxa_boards[cardno].intNdx = baseAddr + IRQindex;
2930 moxaIntPend[cardno] = baseAddr + IRQpending; 2752 moxa_boards[cardno].intPend = baseAddr + IRQpending;
2931 moxaIntTable[cardno] = baseAddr + IRQtable; 2753 moxa_boards[cardno].intTable = baseAddr + IRQtable;
2932 return (0); 2754 return (0);
2933} 2755}
2934 2756
@@ -3021,25 +2843,15 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
3021 if (readw(baseAddr + Magic_no) != Magic_code) 2843 if (readw(baseAddr + Magic_no) != Magic_code)
3022 return (-102); 2844 return (-102);
3023 moxaCard = 1; 2845 moxaCard = 1;
3024 moxaIntNdx[cardno] = baseAddr + IRQindex; 2846 moxa_boards[cardno].intNdx = baseAddr + IRQindex;
3025 moxaIntPend[cardno] = baseAddr + IRQpending; 2847 moxa_boards[cardno].intPend = baseAddr + IRQpending;
3026 moxaIntTable[cardno] = baseAddr + IRQtable; 2848 moxa_boards[cardno].intTable = baseAddr + IRQtable;
3027 return (0); 2849 return (0);
3028} 2850}
3029 2851
3030#if 0
3031long MoxaPortGetCurBaud(int port)
3032{
3033
3034 if (moxaChkPort[port] == 0)
3035 return (0);
3036 return (moxaCurBaud[port]);
3037}
3038#endif /* 0 */
3039
3040static void MoxaSetFifo(int port, int enable) 2852static void MoxaSetFifo(int port, int enable)
3041{ 2853{
3042 void __iomem *ofsAddr = moxaTableAddr[port]; 2854 void __iomem *ofsAddr = moxa_ports[port].tableAddr;
3043 2855
3044 if (!enable) { 2856 if (!enable) {
3045 moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0); 2857 moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
@@ -3049,132 +2861,3 @@ static void MoxaSetFifo(int port, int enable)
3049 moxafunc(ofsAddr, FC_SetTxFIFOCnt, 16); 2861 moxafunc(ofsAddr, FC_SetTxFIFOCnt, 16);
3050 } 2862 }
3051} 2863}
3052
3053#if 0
3054int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
3055{
3056 void __iomem *ofsAddr;
3057 int val;
3058
3059 val = 0;
3060 switch (databits) {
3061 case 5:
3062 val |= 0;
3063 break;
3064 case 6:
3065 val |= 1;
3066 break;
3067 case 7:
3068 val |= 2;
3069 break;
3070 case 8:
3071 val |= 3;
3072 break;
3073 default:
3074 return (-1);
3075 }
3076 switch (stopbits) {
3077 case 0:
3078 val |= 0;
3079 break; /* stop bits 1.5 */
3080 case 1:
3081 val |= 0;
3082 break;
3083 case 2:
3084 val |= 4;
3085 break;
3086 default:
3087 return (-1);
3088 }
3089 switch (parity) {
3090 case 0:
3091 val |= 0x00;
3092 break; /* None */
3093 case 1:
3094 val |= 0x08;
3095 break; /* Odd */
3096 case 2:
3097 val |= 0x18;
3098 break; /* Even */
3099 case 3:
3100 val |= 0x28;
3101 break; /* Mark */
3102 case 4:
3103 val |= 0x38;
3104 break; /* Space */
3105 default:
3106 return (-1);
3107 }
3108 ofsAddr = moxaTableAddr[port];
3109 moxafunc(ofsAddr, FC_SetMode, val);
3110 return (0);
3111}
3112
3113int MoxaPortTxBufSize(int port)
3114{
3115 void __iomem *ofsAddr;
3116 int size;
3117
3118 ofsAddr = moxaTableAddr[port];
3119 size = readw(ofsAddr + TX_mask);
3120 return (size);
3121}
3122
3123int MoxaPortRxBufSize(int port)
3124{
3125 void __iomem *ofsAddr;
3126 int size;
3127
3128 ofsAddr = moxaTableAddr[port];
3129 size = readw(ofsAddr + RX_mask);
3130 return (size);
3131}
3132
3133int MoxaPortRxFree(int port)
3134{
3135 void __iomem *ofsAddr;
3136 ushort rptr, wptr, mask;
3137 int len;
3138
3139 ofsAddr = moxaTableAddr[port];
3140 rptr = readw(ofsAddr + RXrptr);
3141 wptr = readw(ofsAddr + RXwptr);
3142 mask = readw(ofsAddr + RX_mask);
3143 len = mask - ((wptr - rptr) & mask);
3144 return (len);
3145}
3146int MoxaPortGetBrkCnt(int port)
3147{
3148 return (moxaBreakCnt[port]);
3149}
3150
3151void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
3152{
3153 void __iomem *ofsAddr;
3154
3155 ofsAddr = moxaTableAddr[port];
3156 writew(xonValue, ofsAddr + FuncArg);
3157 writew(xoffValue, ofsAddr + FuncArg1);
3158 writew(FC_SetXonXoff, ofsAddr + FuncCode);
3159 wait_finish(ofsAddr);
3160}
3161
3162int MoxaPortIsTxHold(int port)
3163{
3164 void __iomem *ofsAddr;
3165 int val;
3166
3167 ofsAddr = moxaTableAddr[port];
3168 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
3169 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
3170 moxafunc(ofsAddr, FC_GetCCSR, 0);
3171 val = readw(ofsAddr + FuncArg);
3172 if (val & 0x04)
3173 return (1);
3174 } else {
3175 if (readw(ofsAddr + FlagStat) & Tx_flowOff)
3176 return (1);
3177 }
3178 return (0);
3179}
3180#endif
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 83f604b19290..a61fb6da5d03 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -321,8 +321,6 @@ struct mxser_struct {
321 unsigned long event; 321 unsigned long event;
322 int count; /* # of fd on device */ 322 int count; /* # of fd on device */
323 int blocked_open; /* # of blocked opens */ 323 int blocked_open; /* # of blocked opens */
324 long session; /* Session of opening process */
325 long pgrp; /* pgrp of opening process */
326 unsigned char *xmit_buf; 324 unsigned char *xmit_buf;
327 int xmit_head; 325 int xmit_head;
328 int xmit_tail; 326 int xmit_tail;
@@ -1001,15 +999,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
1001 mxser_change_speed(info, NULL); 999 mxser_change_speed(info, NULL);
1002 } 1000 }
1003 1001
1004 info->session = process_session(current);
1005 info->pgrp = process_group(current);
1006
1007 /* 1002 /*
1008 status = mxser_get_msr(info->base, 0, info->port); 1003 status = mxser_get_msr(info->base, 0, info->port);
1009 mxser_check_modem_status(info, status); 1004 mxser_check_modem_status(info, status);
1010 */ 1005 */
1011 1006
1012/* unmark here for very high baud rate (ex. 921600 bps) used */ 1007 /* unmark here for very high baud rate (ex. 921600 bps) used */
1013 tty->low_latency = 1; 1008 tty->low_latency = 1;
1014 return 0; 1009 return 0;
1015} 1010}
@@ -1254,9 +1249,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1254 spin_unlock_irqrestore(&info->slock, flags); 1249 spin_unlock_irqrestore(&info->slock, flags);
1255 /* above added by shinhay */ 1250 /* above added by shinhay */
1256 1251
1257 wake_up_interruptible(&tty->write_wait); 1252 tty_wakeup(tty);
1258 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
1259 (tty->ldisc.write_wakeup) (tty);
1260} 1253}
1261 1254
1262static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1255static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
diff --git a/drivers/char/mxser.h b/drivers/char/mxser.h
index 7e188a4d602a..9fe28497eae9 100644
--- a/drivers/char/mxser.h
+++ b/drivers/char/mxser.h
@@ -439,12 +439,4 @@
439 439
440#define READ_MOXA_MUST_GDL(baseio) inb((baseio)+MOXA_MUST_GDL_REGISTER) 440#define READ_MOXA_MUST_GDL(baseio) inb((baseio)+MOXA_MUST_GDL_REGISTER)
441 441
442
443#ifndef INIT_WORK
444#define INIT_WORK(_work, _func, _data){ \
445 _data->tqueue.routine = _func;\
446 _data->tqueue.data = _data;\
447 }
448#endif
449
450#endif 442#endif
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c
index 1bb030b3a51a..9af07e4999d5 100644
--- a/drivers/char/mxser_new.c
+++ b/drivers/char/mxser_new.c
@@ -49,22 +49,25 @@
49 49
50#include "mxser_new.h" 50#include "mxser_new.h"
51 51
52#define MXSER_VERSION "2.0" 52#define MXSER_VERSION "2.0.1" /* 1.9.15 */
53#define MXSERMAJOR 174 53#define MXSERMAJOR 174
54#define MXSERCUMAJOR 175 54#define MXSERCUMAJOR 175
55 55
56#define MXSER_EVENT_TXLOW 1
57
58#define MXSER_BOARDS 4 /* Max. boards */ 56#define MXSER_BOARDS 4 /* Max. boards */
59#define MXSER_PORTS_PER_BOARD 8 /* Max. ports per board */ 57#define MXSER_PORTS_PER_BOARD 8 /* Max. ports per board */
60#define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD) 58#define MXSER_PORTS (MXSER_BOARDS * MXSER_PORTS_PER_BOARD)
61#define MXSER_ISR_PASS_LIMIT 99999L 59#define MXSER_ISR_PASS_LIMIT 100
62 60
63#define MXSER_ERR_IOADDR -1 61#define MXSER_ERR_IOADDR -1
64#define MXSER_ERR_IRQ -2 62#define MXSER_ERR_IRQ -2
65#define MXSER_ERR_IRQ_CONFLIT -3 63#define MXSER_ERR_IRQ_CONFLIT -3
66#define MXSER_ERR_VECTOR -4 64#define MXSER_ERR_VECTOR -4
67 65
66/*CheckIsMoxaMust return value*/
67#define MOXA_OTHER_UART 0x00
68#define MOXA_MUST_MU150_HWID 0x01
69#define MOXA_MUST_MU860_HWID 0x02
70
68#define WAKEUP_CHARS 256 71#define WAKEUP_CHARS 256
69 72
70#define UART_MCR_AFE 0x20 73#define UART_MCR_AFE 0x20
@@ -176,6 +179,18 @@ static struct pci_device_id mxser_pcibrds[] = {
176}; 179};
177MODULE_DEVICE_TABLE(pci, mxser_pcibrds); 180MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
178 181
182static int mxvar_baud_table[] = {
183 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
184 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
185};
186static unsigned int mxvar_baud_table1[] = {
187 0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
188 B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800, B921600
189};
190#define BAUD_TABLE_NO ARRAY_SIZE(mxvar_baud_table)
191
192#define B_SPEC B2000000
193
179static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; 194static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
180static int ttymajor = MXSERMAJOR; 195static int ttymajor = MXSERMAJOR;
181static int calloutmajor = MXSERCUMAJOR; 196static int calloutmajor = MXSERCUMAJOR;
@@ -237,8 +252,7 @@ struct mxser_port {
237 long realbaud; 252 long realbaud;
238 int type; /* UART type */ 253 int type; /* UART type */
239 int flags; /* defined in tty.h */ 254 int flags; /* defined in tty.h */
240 long session; /* Session of opening process */ 255 int speed;
241 long pgrp; /* pgrp of opening process */
242 256
243 int x_char; /* xon/xoff character */ 257 int x_char; /* xon/xoff character */
244 int IER; /* Interrupt Enable Register */ 258 int IER; /* Interrupt Enable Register */
@@ -267,14 +281,11 @@ struct mxser_port {
267 int xmit_cnt; 281 int xmit_cnt;
268 282
269 struct ktermios normal_termios; 283 struct ktermios normal_termios;
270 struct ktermios callout_termios;
271 284
272 struct mxser_mon mon_data; 285 struct mxser_mon mon_data;
273 286
274 spinlock_t slock; 287 spinlock_t slock;
275 struct work_struct tqueue;
276 wait_queue_head_t open_wait; 288 wait_queue_head_t open_wait;
277 wait_queue_head_t close_wait;
278 wait_queue_head_t delta_msr_wait; 289 wait_queue_head_t delta_msr_wait;
279}; 290};
280 291
@@ -313,10 +324,9 @@ static int mxvar_diagflag;
313static unsigned char mxser_msr[MXSER_PORTS + 1]; 324static unsigned char mxser_msr[MXSER_PORTS + 1];
314static struct mxser_mon_ext mon_data_ext; 325static struct mxser_mon_ext mon_data_ext;
315static int mxser_set_baud_method[MXSER_PORTS + 1]; 326static int mxser_set_baud_method[MXSER_PORTS + 1];
316static spinlock_t gm_lock;
317 327
318#ifdef CONFIG_PCI 328#ifdef CONFIG_PCI
319static int CheckIsMoxaMust(int io) 329static int __devinit CheckIsMoxaMust(int io)
320{ 330{
321 u8 oldmcr, hwid; 331 u8 oldmcr, hwid;
322 int i; 332 int i;
@@ -360,15 +370,6 @@ static void process_txrx_fifo(struct mxser_port *info)
360 } 370 }
361} 371}
362 372
363static void mxser_do_softint(struct work_struct *work)
364{
365 struct mxser_port *info = container_of(work, struct mxser_port, tqueue);
366 struct tty_struct *tty = info->tty;
367
368 if (test_and_clear_bit(MXSER_EVENT_TXLOW, &info->event))
369 tty_wakeup(tty);
370}
371
372static unsigned char mxser_get_msr(int baseaddr, int mode, int port) 373static unsigned char mxser_get_msr(int baseaddr, int mode, int port)
373{ 374{
374 unsigned char status = 0; 375 unsigned char status = 0;
@@ -456,10 +457,10 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
456 457
457static int mxser_set_baud(struct mxser_port *info, long newspd) 458static int mxser_set_baud(struct mxser_port *info, long newspd)
458{ 459{
460 unsigned int i;
459 int quot = 0; 461 int quot = 0;
460 unsigned char cval; 462 unsigned char cval;
461 int ret = 0; 463 int ret = 0;
462 unsigned long flags;
463 464
464 if (!info->tty || !info->tty->termios) 465 if (!info->tty || !info->tty->termios)
465 return ret; 466 return ret;
@@ -471,29 +472,34 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
471 return 0; 472 return 0;
472 473
473 info->realbaud = newspd; 474 info->realbaud = newspd;
474 if (newspd == 134) { 475 for (i = 0; i < BAUD_TABLE_NO; i++)
475 quot = (2 * info->baud_base / 269); 476 if (newspd == mxvar_baud_table[i])
476 } else if (newspd) { 477 break;
477 quot = info->baud_base / newspd; 478 if (i == BAUD_TABLE_NO) {
478 if (quot == 0) 479 quot = info->baud_base / info->speed;
479 quot = 1; 480 if (info->speed <= 0 || info->speed > info->max_baud)
481 quot = 0;
480 } else { 482 } else {
481 quot = 0; 483 if (newspd == 134) {
484 quot = (2 * info->baud_base / 269);
485 } else if (newspd) {
486 quot = info->baud_base / newspd;
487 if (quot == 0)
488 quot = 1;
489 } else {
490 quot = 0;
491 }
482 } 492 }
483 493
484 info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base); 494 info->timeout = ((info->xmit_fifo_size * HZ * 10 * quot) / info->baud_base);
485 info->timeout += HZ / 50; /* Add .02 seconds of slop */ 495 info->timeout += HZ / 50; /* Add .02 seconds of slop */
486 496
487 if (quot) { 497 if (quot) {
488 spin_lock_irqsave(&info->slock, flags);
489 info->MCR |= UART_MCR_DTR; 498 info->MCR |= UART_MCR_DTR;
490 outb(info->MCR, info->ioaddr + UART_MCR); 499 outb(info->MCR, info->ioaddr + UART_MCR);
491 spin_unlock_irqrestore(&info->slock, flags);
492 } else { 500 } else {
493 spin_lock_irqsave(&info->slock, flags);
494 info->MCR &= ~UART_MCR_DTR; 501 info->MCR &= ~UART_MCR_DTR;
495 outb(info->MCR, info->ioaddr + UART_MCR); 502 outb(info->MCR, info->ioaddr + UART_MCR);
496 spin_unlock_irqrestore(&info->slock, flags);
497 return ret; 503 return ret;
498 } 504 }
499 505
@@ -505,6 +511,18 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
505 outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */ 511 outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */
506 outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */ 512 outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */
507 513
514 if (i == BAUD_TABLE_NO) {
515 quot = info->baud_base % info->speed;
516 quot *= 8;
517 if ((quot % info->speed) > (info->speed / 2)) {
518 quot /= info->speed;
519 quot++;
520 } else {
521 quot /= info->speed;
522 }
523 SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot);
524 } else
525 SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0);
508 526
509 return ret; 527 return ret;
510} 528}
@@ -520,7 +538,6 @@ static int mxser_change_speed(struct mxser_port *info,
520 int ret = 0; 538 int ret = 0;
521 unsigned char status; 539 unsigned char status;
522 long baud; 540 long baud;
523 unsigned long flags;
524 541
525 if (!info->tty || !info->tty->termios) 542 if (!info->tty || !info->tty->termios)
526 return ret; 543 return ret;
@@ -529,7 +546,10 @@ static int mxser_change_speed(struct mxser_port *info,
529 return ret; 546 return ret;
530 547
531 if (mxser_set_baud_method[info->tty->index] == 0) { 548 if (mxser_set_baud_method[info->tty->index] == 0) {
532 baud = tty_get_baud_rate(info->tty); 549 if ((cflag & CBAUD) == B_SPEC)
550 baud = info->speed;
551 else
552 baud = tty_get_baud_rate(info->tty);
533 mxser_set_baud(info, baud); 553 mxser_set_baud(info, baud);
534 } 554 }
535 555
@@ -612,8 +632,8 @@ static int mxser_change_speed(struct mxser_port *info,
612 outb(info->IER, info->ioaddr + 632 outb(info->IER, info->ioaddr +
613 UART_IER); 633 UART_IER);
614 } 634 }
615 set_bit(MXSER_EVENT_TXLOW, &info->event); 635 tty_wakeup(info->tty);
616 schedule_work(&info->tqueue); } 636 }
617 } else { 637 } else {
618 if (!(status & UART_MSR_CTS)) { 638 if (!(status & UART_MSR_CTS)) {
619 info->tty->hw_stopped = 1; 639 info->tty->hw_stopped = 1;
@@ -668,7 +688,6 @@ static int mxser_change_speed(struct mxser_port *info,
668 } 688 }
669 } 689 }
670 if (info->board->chip_flag) { 690 if (info->board->chip_flag) {
671 spin_lock_irqsave(&info->slock, flags);
672 SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty)); 691 SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty));
673 SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty)); 692 SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty));
674 if (I_IXON(info->tty)) { 693 if (I_IXON(info->tty)) {
@@ -681,7 +700,6 @@ static int mxser_change_speed(struct mxser_port *info,
681 } else { 700 } else {
682 DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 701 DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr);
683 } 702 }
684 spin_unlock_irqrestore(&info->slock, flags);
685 } 703 }
686 704
687 705
@@ -708,7 +726,6 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
708 if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 726 if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
709 if (status & UART_MSR_DCD) 727 if (status & UART_MSR_DCD)
710 wake_up_interruptible(&port->open_wait); 728 wake_up_interruptible(&port->open_wait);
711 schedule_work(&port->tqueue);
712 } 729 }
713 730
714 if (port->flags & ASYNC_CTS_FLOW) { 731 if (port->flags & ASYNC_CTS_FLOW) {
@@ -724,8 +741,7 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
724 outb(port->IER, port->ioaddr + 741 outb(port->IER, port->ioaddr +
725 UART_IER); 742 UART_IER);
726 } 743 }
727 set_bit(MXSER_EVENT_TXLOW, &port->event); 744 tty_wakeup(port->tty);
728 schedule_work(&port->tqueue);
729 } 745 }
730 } else { 746 } else {
731 if (!(status & UART_MSR_CTS)) { 747 if (!(status & UART_MSR_CTS)) {
@@ -836,10 +852,10 @@ static int mxser_startup(struct mxser_port *info)
836 /* 852 /*
837 * and set the speed of the serial port 853 * and set the speed of the serial port
838 */ 854 */
839 spin_unlock_irqrestore(&info->slock, flags);
840 mxser_change_speed(info, NULL); 855 mxser_change_speed(info, NULL);
841
842 info->flags |= ASYNC_INITIALIZED; 856 info->flags |= ASYNC_INITIALIZED;
857 spin_unlock_irqrestore(&info->slock, flags);
858
843 return 0; 859 return 0;
844} 860}
845 861
@@ -909,11 +925,9 @@ static void mxser_shutdown(struct mxser_port *info)
909static int mxser_open(struct tty_struct *tty, struct file *filp) 925static int mxser_open(struct tty_struct *tty, struct file *filp)
910{ 926{
911 struct mxser_port *info; 927 struct mxser_port *info;
928 unsigned long flags;
912 int retval, line; 929 int retval, line;
913 930
914 /* initialize driver_data in case something fails */
915 tty->driver_data = NULL;
916
917 line = tty->index; 931 line = tty->index;
918 if (line == MXSER_PORTS) 932 if (line == MXSER_PORTS)
919 return 0; 933 return 0;
@@ -928,7 +942,9 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
928 /* 942 /*
929 * Start up serial port 943 * Start up serial port
930 */ 944 */
945 spin_lock_irqsave(&info->slock, flags);
931 info->count++; 946 info->count++;
947 spin_unlock_irqrestore(&info->slock, flags);
932 retval = mxser_startup(info); 948 retval = mxser_startup(info);
933 if (retval) 949 if (retval)
934 return retval; 950 return retval;
@@ -937,17 +953,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
937 if (retval) 953 if (retval)
938 return retval; 954 return retval;
939 955
940 if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
941 if (tty->driver->subtype == SERIAL_TYPE_NORMAL)
942 *tty->termios = info->normal_termios;
943 else
944 *tty->termios = info->callout_termios;
945 mxser_change_speed(info, NULL);
946 }
947
948 info->session = process_session(current);
949 info->pgrp = process_group(current);
950
951 /* unmark here for very high baud rate (ex. 921600 bps) used */ 956 /* unmark here for very high baud rate (ex. 921600 bps) used */
952 tty->low_latency = 1; 957 tty->low_latency = 1;
953 return 0; 958 return 0;
@@ -1054,8 +1059,6 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1054 } 1059 }
1055 1060
1056 info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1061 info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
1057 wake_up_interruptible(&info->close_wait);
1058
1059} 1062}
1060 1063
1061static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) 1064static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -1222,6 +1225,7 @@ static int mxser_set_serial_info(struct mxser_port *info,
1222 struct serial_struct __user *new_info) 1225 struct serial_struct __user *new_info)
1223{ 1226{
1224 struct serial_struct new_serial; 1227 struct serial_struct new_serial;
1228 unsigned long sl_flags;
1225 unsigned int flags; 1229 unsigned int flags;
1226 int retval = 0; 1230 int retval = 0;
1227 1231
@@ -1264,8 +1268,11 @@ static int mxser_set_serial_info(struct mxser_port *info,
1264 process_txrx_fifo(info); 1268 process_txrx_fifo(info);
1265 1269
1266 if (info->flags & ASYNC_INITIALIZED) { 1270 if (info->flags & ASYNC_INITIALIZED) {
1267 if (flags != (info->flags & ASYNC_SPD_MASK)) 1271 if (flags != (info->flags & ASYNC_SPD_MASK)) {
1272 spin_lock_irqsave(&info->slock, sl_flags);
1268 mxser_change_speed(info, NULL); 1273 mxser_change_speed(info, NULL);
1274 spin_unlock_irqrestore(&info->slock, sl_flags);
1275 }
1269 } else 1276 } else
1270 retval = mxser_startup(info); 1277 retval = mxser_startup(info);
1271 1278
@@ -1373,11 +1380,10 @@ static int mxser_tiocmset(struct tty_struct *tty, struct file *file,
1373 return 0; 1380 return 0;
1374} 1381}
1375 1382
1376static int mxser_program_mode(int port) 1383static int __init mxser_program_mode(int port)
1377{ 1384{
1378 int id, i, j, n; 1385 int id, i, j, n;
1379 1386
1380 spin_lock(&gm_lock);
1381 outb(0, port); 1387 outb(0, port);
1382 outb(0, port); 1388 outb(0, port);
1383 outb(0, port); 1389 outb(0, port);
@@ -1385,7 +1391,6 @@ static int mxser_program_mode(int port)
1385 (void)inb(port); 1391 (void)inb(port);
1386 outb(0, port); 1392 outb(0, port);
1387 (void)inb(port); 1393 (void)inb(port);
1388 spin_unlock(&gm_lock);
1389 1394
1390 id = inb(port + 1) & 0x1F; 1395 id = inb(port + 1) & 0x1F;
1391 if ((id != C168_ASIC_ID) && 1396 if ((id != C168_ASIC_ID) &&
@@ -1410,7 +1415,7 @@ static int mxser_program_mode(int port)
1410 return id; 1415 return id;
1411} 1416}
1412 1417
1413static void mxser_normal_mode(int port) 1418static void __init mxser_normal_mode(int port)
1414{ 1419{
1415 int i, n; 1420 int i, n;
1416 1421
@@ -1443,7 +1448,7 @@ static void mxser_normal_mode(int port)
1443#define EN0_PORT 0x010 /* Rcv missed frame error counter RD */ 1448#define EN0_PORT 0x010 /* Rcv missed frame error counter RD */
1444#define ENC_PAGE0 0x000 /* Select page 0 of chip registers */ 1449#define ENC_PAGE0 0x000 /* Select page 0 of chip registers */
1445#define ENC_PAGE3 0x0C0 /* Select page 3 of chip registers */ 1450#define ENC_PAGE3 0x0C0 /* Select page 3 of chip registers */
1446static int mxser_read_register(int port, unsigned short *regs) 1451static int __init mxser_read_register(int port, unsigned short *regs)
1447{ 1452{
1448 int i, k, value, id; 1453 int i, k, value, id;
1449 unsigned int j; 1454 unsigned int j;
@@ -1644,6 +1649,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1644 struct serial_icounter_struct __user *p_cuser; 1649 struct serial_icounter_struct __user *p_cuser;
1645 unsigned long templ; 1650 unsigned long templ;
1646 unsigned long flags; 1651 unsigned long flags;
1652 unsigned int i;
1647 void __user *argp = (void __user *)arg; 1653 void __user *argp = (void __user *)arg;
1648 int retval; 1654 int retval;
1649 1655
@@ -1682,6 +1688,36 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1682 return 0; 1688 return 0;
1683 } 1689 }
1684 1690
1691 if (cmd == MOXA_SET_SPECIAL_BAUD_RATE) {
1692 int speed;
1693
1694 if (get_user(speed, (int __user *)argp))
1695 return -EFAULT;
1696 if (speed <= 0 || speed > info->max_baud)
1697 return -EFAULT;
1698 if (!info->tty || !info->tty->termios || !info->ioaddr)
1699 return 0;
1700 info->tty->termios->c_cflag &= ~(CBAUD | CBAUDEX);
1701 for (i = 0; i < BAUD_TABLE_NO; i++)
1702 if (speed == mxvar_baud_table[i])
1703 break;
1704 if (i == BAUD_TABLE_NO) {
1705 info->tty->termios->c_cflag |= B_SPEC;
1706 } else if (speed != 0)
1707 info->tty->termios->c_cflag |= mxvar_baud_table1[i];
1708
1709 info->speed = speed;
1710 spin_lock_irqsave(&info->slock, flags);
1711 mxser_change_speed(info, NULL);
1712 spin_unlock_irqrestore(&info->slock, flags);
1713
1714 return 0;
1715 } else if (cmd == MOXA_GET_SPECIAL_BAUD_RATE) {
1716 if (copy_to_user(argp, &info->speed, sizeof(int)))
1717 return -EFAULT;
1718 return 0;
1719 }
1720
1685 if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT && 1721 if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT &&
1686 test_bit(TTY_IO_ERROR, &tty->flags)) 1722 test_bit(TTY_IO_ERROR, &tty->flags))
1687 return -EIO; 1723 return -EIO;
@@ -1799,7 +1835,9 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1799 long baud; 1835 long baud;
1800 if (get_user(baud, (long __user *)argp)) 1836 if (get_user(baud, (long __user *)argp))
1801 return -EFAULT; 1837 return -EFAULT;
1838 spin_lock_irqsave(&info->slock, flags);
1802 mxser_set_baud(info, baud); 1839 mxser_set_baud(info, baud);
1840 spin_unlock_irqrestore(&info->slock, flags);
1803 return 0; 1841 return 0;
1804 } 1842 }
1805 case MOXA_ASPP_GETBAUD: 1843 case MOXA_ASPP_GETBAUD:
@@ -1976,7 +2014,9 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
1976 if ((tty->termios->c_cflag != old_termios->c_cflag) || 2014 if ((tty->termios->c_cflag != old_termios->c_cflag) ||
1977 (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { 2015 (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
1978 2016
2017 spin_lock_irqsave(&info->slock, flags);
1979 mxser_change_speed(info, old_termios); 2018 mxser_change_speed(info, old_termios);
2019 spin_unlock_irqrestore(&info->slock, flags);
1980 2020
1981 if ((old_termios->c_cflag & CRTSCTS) && 2021 if ((old_termios->c_cflag & CRTSCTS) &&
1982 !(tty->termios->c_cflag & CRTSCTS)) { 2022 !(tty->termios->c_cflag & CRTSCTS)) {
@@ -2066,7 +2106,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
2066/* 2106/*
2067 * This routine is called by tty_hangup() when a hangup is signaled. 2107 * This routine is called by tty_hangup() when a hangup is signaled.
2068 */ 2108 */
2069void mxser_hangup(struct tty_struct *tty) 2109static void mxser_hangup(struct tty_struct *tty)
2070{ 2110{
2071 struct mxser_port *info = tty->driver_data; 2111 struct mxser_port *info = tty->driver_data;
2072 2112
@@ -2105,9 +2145,6 @@ static void mxser_receive_chars(struct mxser_port *port, int *status)
2105 int cnt = 0; 2145 int cnt = 0;
2106 int recv_room; 2146 int recv_room;
2107 int max = 256; 2147 int max = 256;
2108 unsigned long flags;
2109
2110 spin_lock_irqsave(&port->slock, flags);
2111 2148
2112 recv_room = tty->receive_room; 2149 recv_room = tty->receive_room;
2113 if ((recv_room == 0) && (!port->ldisc_stop_rx)) 2150 if ((recv_room == 0) && (!port->ldisc_stop_rx))
@@ -2169,7 +2206,8 @@ intr_old:
2169 } else if (*status & UART_LSR_OE) { 2206 } else if (*status & UART_LSR_OE) {
2170 flag = TTY_OVERRUN; 2207 flag = TTY_OVERRUN;
2171 port->icount.overrun++; 2208 port->icount.overrun++;
2172 } 2209 } else
2210 flag = TTY_BREAK;
2173 } 2211 }
2174 tty_insert_flip_char(tty, ch, flag); 2212 tty_insert_flip_char(tty, ch, flag);
2175 cnt++; 2213 cnt++;
@@ -2191,7 +2229,6 @@ end_intr:
2191 mxvar_log.rxcnt[port->tty->index] += cnt; 2229 mxvar_log.rxcnt[port->tty->index] += cnt;
2192 port->mon_data.rxcnt += cnt; 2230 port->mon_data.rxcnt += cnt;
2193 port->mon_data.up_rxcnt += cnt; 2231 port->mon_data.up_rxcnt += cnt;
2194 spin_unlock_irqrestore(&port->slock, flags);
2195 2232
2196 tty_flip_buffer_push(tty); 2233 tty_flip_buffer_push(tty);
2197} 2234}
@@ -2199,9 +2236,6 @@ end_intr:
2199static void mxser_transmit_chars(struct mxser_port *port) 2236static void mxser_transmit_chars(struct mxser_port *port)
2200{ 2237{
2201 int count, cnt; 2238 int count, cnt;
2202 unsigned long flags;
2203
2204 spin_lock_irqsave(&port->slock, flags);
2205 2239
2206 if (port->x_char) { 2240 if (port->x_char) {
2207 outb(port->x_char, port->ioaddr + UART_TX); 2241 outb(port->x_char, port->ioaddr + UART_TX);
@@ -2210,11 +2244,11 @@ static void mxser_transmit_chars(struct mxser_port *port)
2210 port->mon_data.txcnt++; 2244 port->mon_data.txcnt++;
2211 port->mon_data.up_txcnt++; 2245 port->mon_data.up_txcnt++;
2212 port->icount.tx++; 2246 port->icount.tx++;
2213 goto unlock; 2247 return;
2214 } 2248 }
2215 2249
2216 if (port->xmit_buf == 0) 2250 if (port->xmit_buf == 0)
2217 goto unlock; 2251 return;
2218 2252
2219 if ((port->xmit_cnt <= 0) || port->tty->stopped || 2253 if ((port->xmit_cnt <= 0) || port->tty->stopped ||
2220 (port->tty->hw_stopped && 2254 (port->tty->hw_stopped &&
@@ -2222,7 +2256,7 @@ static void mxser_transmit_chars(struct mxser_port *port)
2222 (!port->board->chip_flag))) { 2256 (!port->board->chip_flag))) {
2223 port->IER &= ~UART_IER_THRI; 2257 port->IER &= ~UART_IER_THRI;
2224 outb(port->IER, port->ioaddr + UART_IER); 2258 outb(port->IER, port->ioaddr + UART_IER);
2225 goto unlock; 2259 return;
2226 } 2260 }
2227 2261
2228 cnt = port->xmit_cnt; 2262 cnt = port->xmit_cnt;
@@ -2240,16 +2274,13 @@ static void mxser_transmit_chars(struct mxser_port *port)
2240 port->mon_data.up_txcnt += (cnt - port->xmit_cnt); 2274 port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
2241 port->icount.tx += (cnt - port->xmit_cnt); 2275 port->icount.tx += (cnt - port->xmit_cnt);
2242 2276
2243 if (port->xmit_cnt < WAKEUP_CHARS) { 2277 if (port->xmit_cnt < WAKEUP_CHARS)
2244 set_bit(MXSER_EVENT_TXLOW, &port->event); 2278 tty_wakeup(port->tty);
2245 schedule_work(&port->tqueue); 2279
2246 }
2247 if (port->xmit_cnt <= 0) { 2280 if (port->xmit_cnt <= 0) {
2248 port->IER &= ~UART_IER_THRI; 2281 port->IER &= ~UART_IER_THRI;
2249 outb(port->IER, port->ioaddr + UART_IER); 2282 outb(port->IER, port->ioaddr + UART_IER);
2250 } 2283 }
2251unlock:
2252 spin_unlock_irqrestore(&port->slock, flags);
2253} 2284}
2254 2285
2255/* 2286/*
@@ -2261,8 +2292,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
2261 struct mxser_board *brd = NULL; 2292 struct mxser_board *brd = NULL;
2262 struct mxser_port *port; 2293 struct mxser_port *port;
2263 int max, irqbits, bits, msr; 2294 int max, irqbits, bits, msr;
2264 int pass_counter = 0; 2295 unsigned int int_cnt, pass_counter = 0;
2265 unsigned int int_cnt;
2266 int handled = IRQ_NONE; 2296 int handled = IRQ_NONE;
2267 2297
2268 for (i = 0; i < MXSER_BOARDS; i++) 2298 for (i = 0; i < MXSER_BOARDS; i++)
@@ -2276,7 +2306,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
2276 if (brd == NULL) 2306 if (brd == NULL)
2277 goto irq_stop; 2307 goto irq_stop;
2278 max = brd->info->nports; 2308 max = brd->info->nports;
2279 while (1) { 2309 while (pass_counter++ < MXSER_ISR_PASS_LIMIT) {
2280 irqbits = inb(brd->vector) & brd->vector_mask; 2310 irqbits = inb(brd->vector) & brd->vector_mask;
2281 if (irqbits == brd->vector_mask) 2311 if (irqbits == brd->vector_mask)
2282 break; 2312 break;
@@ -2290,12 +2320,16 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
2290 port = &brd->ports[i]; 2320 port = &brd->ports[i];
2291 2321
2292 int_cnt = 0; 2322 int_cnt = 0;
2323 spin_lock(&port->slock);
2293 do { 2324 do {
2294 iir = inb(port->ioaddr + UART_IIR); 2325 iir = inb(port->ioaddr + UART_IIR);
2295 if (iir & UART_IIR_NO_INT) 2326 if (iir & UART_IIR_NO_INT)
2296 break; 2327 break;
2297 iir &= MOXA_MUST_IIR_MASK; 2328 iir &= MOXA_MUST_IIR_MASK;
2298 if (!port->tty) { 2329 if (!port->tty ||
2330 (port->flags & ASYNC_CLOSING) ||
2331 !(port->flags &
2332 ASYNC_INITIALIZED)) {
2299 status = inb(port->ioaddr + UART_LSR); 2333 status = inb(port->ioaddr + UART_LSR);
2300 outb(0x27, port->ioaddr + UART_FCR); 2334 outb(0x27, port->ioaddr + UART_FCR);
2301 inb(port->ioaddr + UART_MSR); 2335 inb(port->ioaddr + UART_MSR);
@@ -2341,9 +2375,8 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
2341 mxser_transmit_chars(port); 2375 mxser_transmit_chars(port);
2342 } 2376 }
2343 } while (int_cnt++ < MXSER_ISR_PASS_LIMIT); 2377 } while (int_cnt++ < MXSER_ISR_PASS_LIMIT);
2378 spin_unlock(&port->slock);
2344 } 2379 }
2345 if (pass_counter++ > MXSER_ISR_PASS_LIMIT)
2346 break; /* Prevent infinite loops */
2347 } 2380 }
2348 2381
2349irq_stop: 2382irq_stop:
@@ -2385,7 +2418,6 @@ static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev,
2385#ifdef CONFIG_PCI 2418#ifdef CONFIG_PCI
2386 pci_release_region(pdev, 2); 2419 pci_release_region(pdev, 2);
2387 pci_release_region(pdev, 3); 2420 pci_release_region(pdev, 3);
2388 pci_dev_put(pdev);
2389#endif 2421#endif
2390 } else { 2422 } else {
2391 release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 2423 release_region(brd->ports[0].ioaddr, 8 * brd->info->nports);
@@ -2420,11 +2452,10 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
2420 info->custom_divisor = info->baud_base * 16; 2452 info->custom_divisor = info->baud_base * 16;
2421 info->close_delay = 5 * HZ / 10; 2453 info->close_delay = 5 * HZ / 10;
2422 info->closing_wait = 30 * HZ; 2454 info->closing_wait = 30 * HZ;
2423 INIT_WORK(&info->tqueue, mxser_do_softint);
2424 info->normal_termios = mxvar_sdriver->init_termios; 2455 info->normal_termios = mxvar_sdriver->init_termios;
2425 init_waitqueue_head(&info->open_wait); 2456 init_waitqueue_head(&info->open_wait);
2426 init_waitqueue_head(&info->close_wait);
2427 init_waitqueue_head(&info->delta_msr_wait); 2457 init_waitqueue_head(&info->delta_msr_wait);
2458 info->speed = 9600;
2428 memset(&info->mon_data, 0, sizeof(struct mxser_mon)); 2459 memset(&info->mon_data, 0, sizeof(struct mxser_mon));
2429 info->err_shadow = 0; 2460 info->err_shadow = 0;
2430 spin_lock_init(&info->slock); 2461 spin_lock_init(&info->slock);
@@ -2433,22 +2464,17 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
2433 outb(inb(info->ioaddr + UART_IER) & 0xf0, 2464 outb(inb(info->ioaddr + UART_IER) & 0xf0,
2434 info->ioaddr + UART_IER); 2465 info->ioaddr + UART_IER);
2435 } 2466 }
2436 /*
2437 * Allocate the IRQ if necessary
2438 */
2439 2467
2440 retval = request_irq(brd->irq, mxser_interrupt, 2468 retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser",
2441 (brd->ports[0].flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : 2469 brd);
2442 IRQF_DISABLED, "mxser", brd);
2443 if (retval) { 2470 if (retval) {
2444 printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " 2471 printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may "
2445 "conflict with another device.\n", 2472 "conflict with another device.\n",
2446 brd->info->name, brd->irq); 2473 brd->info->name, brd->irq);
2447 /* We hold resources, we need to release them. */ 2474 /* We hold resources, we need to release them. */
2448 mxser_release_res(brd, pdev, 0); 2475 mxser_release_res(brd, pdev, 0);
2449 return retval;
2450 } 2476 }
2451 return 0; 2477 return retval;
2452} 2478}
2453 2479
2454static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) 2480static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
@@ -2633,8 +2659,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
2633 } 2659 }
2634 2660
2635 /* mxser_initbrd will hook ISR. */ 2661 /* mxser_initbrd will hook ISR. */
2636 if (mxser_initbrd(brd, pdev) < 0) 2662 retval = mxser_initbrd(brd, pdev);
2637 goto err_relvec; 2663 if (retval)
2664 goto err_null;
2638 2665
2639 for (i = 0; i < brd->info->nports; i++) 2666 for (i = 0; i < brd->info->nports; i++)
2640 tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev); 2667 tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev);
@@ -2642,10 +2669,9 @@ static int __devinit mxser_probe(struct pci_dev *pdev,
2642 pci_set_drvdata(pdev, brd); 2669 pci_set_drvdata(pdev, brd);
2643 2670
2644 return 0; 2671 return 0;
2645err_relvec:
2646 pci_release_region(pdev, 3);
2647err_relio: 2672err_relio:
2648 pci_release_region(pdev, 2); 2673 pci_release_region(pdev, 2);
2674err_null:
2649 brd->info = NULL; 2675 brd->info = NULL;
2650err: 2676err:
2651 return retval; 2677 return retval;
@@ -2663,6 +2689,7 @@ static void __devexit mxser_remove(struct pci_dev *pdev)
2663 tty_unregister_device(mxvar_sdriver, brd->idx + i); 2689 tty_unregister_device(mxvar_sdriver, brd->idx + i);
2664 2690
2665 mxser_release_res(brd, pdev, 1); 2691 mxser_release_res(brd, pdev, 1);
2692 brd->info = NULL;
2666} 2693}
2667 2694
2668static struct pci_driver mxser_driver = { 2695static struct pci_driver mxser_driver = {
@@ -2684,7 +2711,6 @@ static int __init mxser_module_init(void)
2684 mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1); 2711 mxvar_sdriver = alloc_tty_driver(MXSER_PORTS + 1);
2685 if (!mxvar_sdriver) 2712 if (!mxvar_sdriver)
2686 return -ENOMEM; 2713 return -ENOMEM;
2687 spin_lock_init(&gm_lock);
2688 2714
2689 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", 2715 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
2690 MXSER_VERSION); 2716 MXSER_VERSION);
diff --git a/drivers/char/mxser_new.h b/drivers/char/mxser_new.h
index a08f0ecb09ba..d42f7766c652 100644
--- a/drivers/char/mxser_new.h
+++ b/drivers/char/mxser_new.h
@@ -26,18 +26,8 @@
26#define RS422_MODE 2 26#define RS422_MODE 2
27#define RS485_4WIRE_MODE 3 27#define RS485_4WIRE_MODE 3
28#define OP_MODE_MASK 3 28#define OP_MODE_MASK 3
29// above add by Victor Yu. 01-05-2004
30
31#define TTY_THRESHOLD_THROTTLE 128
32
33#define LO_WATER (TTY_FLIPBUF_SIZE)
34#define HI_WATER (TTY_FLIPBUF_SIZE*2*3/4)
35
36// added by James. 03-11-2004.
37#define MOXA_SDS_GETICOUNTER (MOXA + 68)
38#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
39// (above) added by James.
40 29
30#define MOXA_SDS_RSTICOUNTER (MOXA + 69)
41#define MOXA_ASPP_OQUEUE (MOXA + 70) 31#define MOXA_ASPP_OQUEUE (MOXA + 70)
42#define MOXA_ASPP_SETBAUD (MOXA + 71) 32#define MOXA_ASPP_SETBAUD (MOXA + 71)
43#define MOXA_ASPP_GETBAUD (MOXA + 72) 33#define MOXA_ASPP_GETBAUD (MOXA + 72)
@@ -45,7 +35,8 @@
45#define MOXA_ASPP_LSTATUS (MOXA + 74) 35#define MOXA_ASPP_LSTATUS (MOXA + 74)
46#define MOXA_ASPP_MON_EXT (MOXA + 75) 36#define MOXA_ASPP_MON_EXT (MOXA + 75)
47#define MOXA_SET_BAUD_METHOD (MOXA + 76) 37#define MOXA_SET_BAUD_METHOD (MOXA + 76)
48 38#define MOXA_SET_SPECIAL_BAUD_RATE (MOXA + 77)
39#define MOXA_GET_SPECIAL_BAUD_RATE (MOXA + 78)
49 40
50/* --------------------------------------------------- */ 41/* --------------------------------------------------- */
51 42
@@ -55,51 +46,46 @@
55#define NPPI_NOTIFY_SW_OVERRUN 0x08 46#define NPPI_NOTIFY_SW_OVERRUN 0x08
56#define NPPI_NOTIFY_BREAK 0x10 47#define NPPI_NOTIFY_BREAK 0x10
57 48
58#define NPPI_NOTIFY_CTSHOLD 0x01 // Tx hold by CTS low 49#define NPPI_NOTIFY_CTSHOLD 0x01 /* Tx hold by CTS low */
59#define NPPI_NOTIFY_DSRHOLD 0x02 // Tx hold by DSR low 50#define NPPI_NOTIFY_DSRHOLD 0x02 /* Tx hold by DSR low */
60#define NPPI_NOTIFY_XOFFHOLD 0x08 // Tx hold by Xoff received 51#define NPPI_NOTIFY_XOFFHOLD 0x08 /* Tx hold by Xoff received */
61#define NPPI_NOTIFY_XOFFXENT 0x10 // Xoff Sent 52#define NPPI_NOTIFY_XOFFXENT 0x10 /* Xoff Sent */
62 53
63//CheckIsMoxaMust return value 54/* follow just for Moxa Must chip define. */
64#define MOXA_OTHER_UART 0x00 55/* */
65#define MOXA_MUST_MU150_HWID 0x01 56/* when LCR register (offset 0x03) write following value, */
66#define MOXA_MUST_MU860_HWID 0x02 57/* the Must chip will enter enchance mode. And write value */
67 58/* on EFR (offset 0x02) bit 6,7 to change bank. */
68// follow just for Moxa Must chip define.
69//
70// when LCR register (offset 0x03) write following value,
71// the Must chip will enter enchance mode. And write value
72// on EFR (offset 0x02) bit 6,7 to change bank.
73#define MOXA_MUST_ENTER_ENCHANCE 0xBF 59#define MOXA_MUST_ENTER_ENCHANCE 0xBF
74 60
75// when enhance mode enable, access on general bank register 61/* when enhance mode enable, access on general bank register */
76#define MOXA_MUST_GDL_REGISTER 0x07 62#define MOXA_MUST_GDL_REGISTER 0x07
77#define MOXA_MUST_GDL_MASK 0x7F 63#define MOXA_MUST_GDL_MASK 0x7F
78#define MOXA_MUST_GDL_HAS_BAD_DATA 0x80 64#define MOXA_MUST_GDL_HAS_BAD_DATA 0x80
79 65
80#define MOXA_MUST_LSR_RERR 0x80 // error in receive FIFO 66#define MOXA_MUST_LSR_RERR 0x80 /* error in receive FIFO */
81// enchance register bank select and enchance mode setting register 67/* enchance register bank select and enchance mode setting register */
82// when LCR register equal to 0xBF 68/* when LCR register equal to 0xBF */
83#define MOXA_MUST_EFR_REGISTER 0x02 69#define MOXA_MUST_EFR_REGISTER 0x02
84// enchance mode enable 70/* enchance mode enable */
85#define MOXA_MUST_EFR_EFRB_ENABLE 0x10 71#define MOXA_MUST_EFR_EFRB_ENABLE 0x10
86// enchance reister bank set 0, 1, 2 72/* enchance reister bank set 0, 1, 2 */
87#define MOXA_MUST_EFR_BANK0 0x00 73#define MOXA_MUST_EFR_BANK0 0x00
88#define MOXA_MUST_EFR_BANK1 0x40 74#define MOXA_MUST_EFR_BANK1 0x40
89#define MOXA_MUST_EFR_BANK2 0x80 75#define MOXA_MUST_EFR_BANK2 0x80
90#define MOXA_MUST_EFR_BANK3 0xC0 76#define MOXA_MUST_EFR_BANK3 0xC0
91#define MOXA_MUST_EFR_BANK_MASK 0xC0 77#define MOXA_MUST_EFR_BANK_MASK 0xC0
92 78
93// set XON1 value register, when LCR=0xBF and change to bank0 79/* set XON1 value register, when LCR=0xBF and change to bank0 */
94#define MOXA_MUST_XON1_REGISTER 0x04 80#define MOXA_MUST_XON1_REGISTER 0x04
95 81
96// set XON2 value register, when LCR=0xBF and change to bank0 82/* set XON2 value register, when LCR=0xBF and change to bank0 */
97#define MOXA_MUST_XON2_REGISTER 0x05 83#define MOXA_MUST_XON2_REGISTER 0x05
98 84
99// set XOFF1 value register, when LCR=0xBF and change to bank0 85/* set XOFF1 value register, when LCR=0xBF and change to bank0 */
100#define MOXA_MUST_XOFF1_REGISTER 0x06 86#define MOXA_MUST_XOFF1_REGISTER 0x06
101 87
102// set XOFF2 value register, when LCR=0xBF and change to bank0 88/* set XOFF2 value register, when LCR=0xBF and change to bank0 */
103#define MOXA_MUST_XOFF2_REGISTER 0x07 89#define MOXA_MUST_XOFF2_REGISTER 0x07
104 90
105#define MOXA_MUST_RBRTL_REGISTER 0x04 91#define MOXA_MUST_RBRTL_REGISTER 0x04
@@ -111,32 +97,32 @@
111#define MOXA_MUST_ECR_REGISTER 0x06 97#define MOXA_MUST_ECR_REGISTER 0x06
112#define MOXA_MUST_CSR_REGISTER 0x07 98#define MOXA_MUST_CSR_REGISTER 0x07
113 99
114// good data mode enable 100/* good data mode enable */
115#define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20 101#define MOXA_MUST_FCR_GDA_MODE_ENABLE 0x20
116// only good data put into RxFIFO 102/* only good data put into RxFIFO */
117#define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10 103#define MOXA_MUST_FCR_GDA_ONLY_ENABLE 0x10
118 104
119// enable CTS interrupt 105/* enable CTS interrupt */
120#define MOXA_MUST_IER_ECTSI 0x80 106#define MOXA_MUST_IER_ECTSI 0x80
121// enable RTS interrupt 107/* enable RTS interrupt */
122#define MOXA_MUST_IER_ERTSI 0x40 108#define MOXA_MUST_IER_ERTSI 0x40
123// enable Xon/Xoff interrupt 109/* enable Xon/Xoff interrupt */
124#define MOXA_MUST_IER_XINT 0x20 110#define MOXA_MUST_IER_XINT 0x20
125// enable GDA interrupt 111/* enable GDA interrupt */
126#define MOXA_MUST_IER_EGDAI 0x10 112#define MOXA_MUST_IER_EGDAI 0x10
127 113
128#define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI) 114#define MOXA_MUST_RECV_ISR (UART_IER_RDI | MOXA_MUST_IER_EGDAI)
129 115
130// GDA interrupt pending 116/* GDA interrupt pending */
131#define MOXA_MUST_IIR_GDA 0x1C 117#define MOXA_MUST_IIR_GDA 0x1C
132#define MOXA_MUST_IIR_RDA 0x04 118#define MOXA_MUST_IIR_RDA 0x04
133#define MOXA_MUST_IIR_RTO 0x0C 119#define MOXA_MUST_IIR_RTO 0x0C
134#define MOXA_MUST_IIR_LSR 0x06 120#define MOXA_MUST_IIR_LSR 0x06
135 121
136// recieved Xon/Xoff or specical interrupt pending 122/* recieved Xon/Xoff or specical interrupt pending */
137#define MOXA_MUST_IIR_XSC 0x10 123#define MOXA_MUST_IIR_XSC 0x10
138 124
139// RTS/CTS change state interrupt pending 125/* RTS/CTS change state interrupt pending */
140#define MOXA_MUST_IIR_RTSCTS 0x20 126#define MOXA_MUST_IIR_RTSCTS 0x20
141#define MOXA_MUST_IIR_MASK 0x3E 127#define MOXA_MUST_IIR_MASK 0x3E
142 128
@@ -144,307 +130,164 @@
144#define MOXA_MUST_MCR_XON_ANY 0x80 130#define MOXA_MUST_MCR_XON_ANY 0x80
145#define MOXA_MUST_MCR_TX_XON 0x08 131#define MOXA_MUST_MCR_TX_XON 0x08
146 132
147 133/* software flow control on chip mask value */
148// software flow control on chip mask value
149#define MOXA_MUST_EFR_SF_MASK 0x0F 134#define MOXA_MUST_EFR_SF_MASK 0x0F
150// send Xon1/Xoff1 135/* send Xon1/Xoff1 */
151#define MOXA_MUST_EFR_SF_TX1 0x08 136#define MOXA_MUST_EFR_SF_TX1 0x08
152// send Xon2/Xoff2 137/* send Xon2/Xoff2 */
153#define MOXA_MUST_EFR_SF_TX2 0x04 138#define MOXA_MUST_EFR_SF_TX2 0x04
154// send Xon1,Xon2/Xoff1,Xoff2 139/* send Xon1,Xon2/Xoff1,Xoff2 */
155#define MOXA_MUST_EFR_SF_TX12 0x0C 140#define MOXA_MUST_EFR_SF_TX12 0x0C
156// don't send Xon/Xoff 141/* don't send Xon/Xoff */
157#define MOXA_MUST_EFR_SF_TX_NO 0x00 142#define MOXA_MUST_EFR_SF_TX_NO 0x00
158// Tx software flow control mask 143/* Tx software flow control mask */
159#define MOXA_MUST_EFR_SF_TX_MASK 0x0C 144#define MOXA_MUST_EFR_SF_TX_MASK 0x0C
160// don't receive Xon/Xoff 145/* don't receive Xon/Xoff */
161#define MOXA_MUST_EFR_SF_RX_NO 0x00 146#define MOXA_MUST_EFR_SF_RX_NO 0x00
162// receive Xon1/Xoff1 147/* receive Xon1/Xoff1 */
163#define MOXA_MUST_EFR_SF_RX1 0x02 148#define MOXA_MUST_EFR_SF_RX1 0x02
164// receive Xon2/Xoff2 149/* receive Xon2/Xoff2 */
165#define MOXA_MUST_EFR_SF_RX2 0x01 150#define MOXA_MUST_EFR_SF_RX2 0x01
166// receive Xon1,Xon2/Xoff1,Xoff2 151/* receive Xon1,Xon2/Xoff1,Xoff2 */
167#define MOXA_MUST_EFR_SF_RX12 0x03 152#define MOXA_MUST_EFR_SF_RX12 0x03
168// Rx software flow control mask 153/* Rx software flow control mask */
169#define MOXA_MUST_EFR_SF_RX_MASK 0x03 154#define MOXA_MUST_EFR_SF_RX_MASK 0x03
170 155
171//#define MOXA_MUST_MIN_XOFFLIMIT 66 156#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
172//#define MOXA_MUST_MIN_XONLIMIT 20 157 u8 __oldlcr, __efr; \
173//#define ID1_RX_TRIG 120 158 __oldlcr = inb((baseio)+UART_LCR); \
174
175
176#define CHECK_MOXA_MUST_XOFFLIMIT(info) { \
177 if ( (info)->IsMoxaMustChipFlag && \
178 (info)->HandFlow.XoffLimit < MOXA_MUST_MIN_XOFFLIMIT ) { \
179 (info)->HandFlow.XoffLimit = MOXA_MUST_MIN_XOFFLIMIT; \
180 (info)->HandFlow.XonLimit = MOXA_MUST_MIN_XONLIMIT; \
181 } \
182}
183
184#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) { \
185 u8 __oldlcr, __efr; \
186 __oldlcr = inb((baseio)+UART_LCR); \
187 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 159 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
188 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 160 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
189 __efr |= MOXA_MUST_EFR_EFRB_ENABLE; \ 161 __efr |= MOXA_MUST_EFR_EFRB_ENABLE; \
190 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 162 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
191 outb(__oldlcr, (baseio)+UART_LCR); \ 163 outb(__oldlcr, (baseio)+UART_LCR); \
192} 164} while (0)
193 165
194#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) { \ 166#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
195 u8 __oldlcr, __efr; \ 167 u8 __oldlcr, __efr; \
196 __oldlcr = inb((baseio)+UART_LCR); \ 168 __oldlcr = inb((baseio)+UART_LCR); \
197 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 169 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
198 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 170 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
199 __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE; \ 171 __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE; \
200 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 172 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
201 outb(__oldlcr, (baseio)+UART_LCR); \ 173 outb(__oldlcr, (baseio)+UART_LCR); \
202} 174} while (0)
203 175
204#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) { \ 176#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) do { \
205 u8 __oldlcr, __efr; \ 177 u8 __oldlcr, __efr; \
206 __oldlcr = inb((baseio)+UART_LCR); \ 178 __oldlcr = inb((baseio)+UART_LCR); \
207 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 179 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
208 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 180 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
209 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \ 181 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
210 __efr |= MOXA_MUST_EFR_BANK0; \ 182 __efr |= MOXA_MUST_EFR_BANK0; \
211 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 183 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
212 outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER); \ 184 outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER); \
213 outb(__oldlcr, (baseio)+UART_LCR); \ 185 outb(__oldlcr, (baseio)+UART_LCR); \
214} 186} while (0)
215 187
216#define SET_MOXA_MUST_XON2_VALUE(baseio, Value) { \ 188#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) do { \
217 u8 __oldlcr, __efr; \ 189 u8 __oldlcr, __efr; \
218 __oldlcr = inb((baseio)+UART_LCR); \ 190 __oldlcr = inb((baseio)+UART_LCR); \
219 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 191 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
220 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 192 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
221 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \ 193 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
222 __efr |= MOXA_MUST_EFR_BANK0; \ 194 __efr |= MOXA_MUST_EFR_BANK0; \
223 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 195 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
224 outb((u8)(Value), (baseio)+MOXA_MUST_XON2_REGISTER); \
225 outb(__oldlcr, (baseio)+UART_LCR); \
226}
227
228#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) { \
229 u8 __oldlcr, __efr; \
230 __oldlcr = inb((baseio)+UART_LCR); \
231 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
232 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
233 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
234 __efr |= MOXA_MUST_EFR_BANK0; \
235 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
236 outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER); \ 196 outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER); \
237 outb(__oldlcr, (baseio)+UART_LCR); \ 197 outb(__oldlcr, (baseio)+UART_LCR); \
238} 198} while (0)
239 199
240#define SET_MOXA_MUST_XOFF2_VALUE(baseio, Value) { \ 200#define SET_MOXA_MUST_FIFO_VALUE(info) do { \
241 u8 __oldlcr, __efr; \ 201 u8 __oldlcr, __efr; \
242 __oldlcr = inb((baseio)+UART_LCR); \ 202 __oldlcr = inb((info)->ioaddr+UART_LCR); \
243 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 203 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);\
244 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
245 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
246 __efr |= MOXA_MUST_EFR_BANK0; \
247 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
248 outb((u8)(Value), (baseio)+MOXA_MUST_XOFF2_REGISTER); \
249 outb(__oldlcr, (baseio)+UART_LCR); \
250}
251
252#define SET_MOXA_MUST_RBRTL_VALUE(baseio, Value) { \
253 u8 __oldlcr, __efr; \
254 __oldlcr = inb((baseio)+UART_LCR); \
255 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
256 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
257 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
258 __efr |= MOXA_MUST_EFR_BANK1; \
259 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
260 outb((u8)(Value), (baseio)+MOXA_MUST_RBRTL_REGISTER); \
261 outb(__oldlcr, (baseio)+UART_LCR); \
262}
263
264#define SET_MOXA_MUST_RBRTH_VALUE(baseio, Value) { \
265 u8 __oldlcr, __efr; \
266 __oldlcr = inb((baseio)+UART_LCR); \
267 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
268 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
269 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
270 __efr |= MOXA_MUST_EFR_BANK1; \
271 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
272 outb((u8)(Value), (baseio)+MOXA_MUST_RBRTH_REGISTER); \
273 outb(__oldlcr, (baseio)+UART_LCR); \
274}
275
276#define SET_MOXA_MUST_RBRTI_VALUE(baseio, Value) { \
277 u8 __oldlcr, __efr; \
278 __oldlcr = inb((baseio)+UART_LCR); \
279 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
280 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
281 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
282 __efr |= MOXA_MUST_EFR_BANK1; \
283 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
284 outb((u8)(Value), (baseio)+MOXA_MUST_RBRTI_REGISTER); \
285 outb(__oldlcr, (baseio)+UART_LCR); \
286}
287
288#define SET_MOXA_MUST_THRTL_VALUE(baseio, Value) { \
289 u8 __oldlcr, __efr; \
290 __oldlcr = inb((baseio)+UART_LCR); \
291 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
292 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
293 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
294 __efr |= MOXA_MUST_EFR_BANK1; \
295 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
296 outb((u8)(Value), (baseio)+MOXA_MUST_THRTL_REGISTER); \
297 outb(__oldlcr, (baseio)+UART_LCR); \
298}
299
300//#define MOXA_MUST_RBRL_VALUE 4
301#define SET_MOXA_MUST_FIFO_VALUE(info) { \
302 u8 __oldlcr, __efr; \
303 __oldlcr = inb((info)->ioaddr+UART_LCR); \
304 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR); \
305 __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \ 204 __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
306 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \ 205 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
307 __efr |= MOXA_MUST_EFR_BANK1; \ 206 __efr |= MOXA_MUST_EFR_BANK1; \
308 outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \ 207 outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
309 outb((u8)((info)->rx_high_water), (info)->ioaddr+MOXA_MUST_RBRTH_REGISTER); \ 208 outb((u8)((info)->rx_high_water), (info)->ioaddr+ \
310 outb((u8)((info)->rx_trigger), (info)->ioaddr+MOXA_MUST_RBRTI_REGISTER); \ 209 MOXA_MUST_RBRTH_REGISTER); \
311 outb((u8)((info)->rx_low_water), (info)->ioaddr+MOXA_MUST_RBRTL_REGISTER); \ 210 outb((u8)((info)->rx_trigger), (info)->ioaddr+ \
312 outb(__oldlcr, (info)->ioaddr+UART_LCR); \ 211 MOXA_MUST_RBRTI_REGISTER); \
313} 212 outb((u8)((info)->rx_low_water), (info)->ioaddr+ \
314 213 MOXA_MUST_RBRTL_REGISTER); \
315 214 outb(__oldlcr, (info)->ioaddr+UART_LCR); \
316 215} while (0)
317#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) { \ 216
318 u8 __oldlcr, __efr; \ 217#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) do { \
319 __oldlcr = inb((baseio)+UART_LCR); \ 218 u8 __oldlcr, __efr; \
219 __oldlcr = inb((baseio)+UART_LCR); \
320 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 220 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
321 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 221 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
322 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \ 222 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
323 __efr |= MOXA_MUST_EFR_BANK2; \ 223 __efr |= MOXA_MUST_EFR_BANK2; \
324 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 224 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
325 outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER); \ 225 outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER); \
326 outb(__oldlcr, (baseio)+UART_LCR); \ 226 outb(__oldlcr, (baseio)+UART_LCR); \
327} 227} while (0)
328 228
329#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) { \ 229#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) do { \
330 u8 __oldlcr, __efr; \ 230 u8 __oldlcr, __efr; \
331 __oldlcr = inb((baseio)+UART_LCR); \ 231 __oldlcr = inb((baseio)+UART_LCR); \
332 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
333 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
334 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
335 __efr |= MOXA_MUST_EFR_BANK2; \
336 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
337 *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER); \
338 outb(__oldlcr, (baseio)+UART_LCR); \
339}
340
341#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) { \
342 u8 __oldlcr, __efr; \
343 __oldlcr = inb((baseio)+UART_LCR); \
344 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
345 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
346 __efr &= ~MOXA_MUST_EFR_SF_MASK; \
347 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
348 outb(__oldlcr, (baseio)+UART_LCR); \
349}
350
351#define SET_MOXA_MUST_JUST_TX_SOFTWARE_FLOW_CONTROL(baseio) { \
352 u8 __oldlcr, __efr; \
353 __oldlcr = inb((baseio)+UART_LCR); \
354 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 232 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
355 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 233 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
356 __efr &= ~MOXA_MUST_EFR_SF_MASK; \ 234 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
357 __efr |= MOXA_MUST_EFR_SF_TX1; \ 235 __efr |= MOXA_MUST_EFR_BANK2; \
358 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 236 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
359 outb(__oldlcr, (baseio)+UART_LCR); \ 237 *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER); \
360} 238 outb(__oldlcr, (baseio)+UART_LCR); \
361 239} while (0)
362#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) { \ 240
363 u8 __oldlcr, __efr; \ 241#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) do { \
364 __oldlcr = inb((baseio)+UART_LCR); \ 242 u8 __oldlcr, __efr; \
243 __oldlcr = inb((baseio)+UART_LCR); \
365 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 244 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
366 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 245 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
367 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \ 246 __efr &= ~MOXA_MUST_EFR_SF_MASK; \
368 __efr |= MOXA_MUST_EFR_SF_TX1; \ 247 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
369 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 248 outb(__oldlcr, (baseio)+UART_LCR); \
370 outb(__oldlcr, (baseio)+UART_LCR); \ 249} while (0)
371} 250
372 251#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
373#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) { \ 252 u8 __oldlcr, __efr; \
374 u8 __oldlcr, __efr; \ 253 __oldlcr = inb((baseio)+UART_LCR); \
375 __oldlcr = inb((baseio)+UART_LCR); \
376 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 254 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
377 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 255 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
378 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \ 256 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
379 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 257 __efr |= MOXA_MUST_EFR_SF_TX1; \
380 outb(__oldlcr, (baseio)+UART_LCR); \ 258 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
381} 259 outb(__oldlcr, (baseio)+UART_LCR); \
382 260} while (0)
383#define SET_MOXA_MUST_JUST_RX_SOFTWARE_FLOW_CONTROL(baseio) { \ 261
384 u8 __oldlcr, __efr; \ 262#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
385 __oldlcr = inb((baseio)+UART_LCR); \ 263 u8 __oldlcr, __efr; \
264 __oldlcr = inb((baseio)+UART_LCR); \
386 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 265 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
387 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 266 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
388 __efr &= ~MOXA_MUST_EFR_SF_MASK; \ 267 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
389 __efr |= MOXA_MUST_EFR_SF_RX1; \ 268 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
390 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 269 outb(__oldlcr, (baseio)+UART_LCR); \
391 outb(__oldlcr, (baseio)+UART_LCR); \ 270} while (0)
392} 271
393 272#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
394#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) { \ 273 u8 __oldlcr, __efr; \
395 u8 __oldlcr, __efr; \ 274 __oldlcr = inb((baseio)+UART_LCR); \
396 __oldlcr = inb((baseio)+UART_LCR); \
397 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 275 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
398 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 276 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
399 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \ 277 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
400 __efr |= MOXA_MUST_EFR_SF_RX1; \ 278 __efr |= MOXA_MUST_EFR_SF_RX1; \
401 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 279 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
402 outb(__oldlcr, (baseio)+UART_LCR); \ 280 outb(__oldlcr, (baseio)+UART_LCR); \
403} 281} while (0)
404 282
405#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) { \ 283#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
406 u8 __oldlcr, __efr; \ 284 u8 __oldlcr, __efr; \
407 __oldlcr = inb((baseio)+UART_LCR); \ 285 __oldlcr = inb((baseio)+UART_LCR); \
408 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \ 286 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
409 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \ 287 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
410 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \ 288 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
411 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \ 289 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
412 outb(__oldlcr, (baseio)+UART_LCR); \ 290 outb(__oldlcr, (baseio)+UART_LCR); \
413} 291} while (0)
414
415#define ENABLE_MOXA_MUST_TX_RX_SOFTWARE_FLOW_CONTROL(baseio) { \
416 u8 __oldlcr, __efr; \
417 __oldlcr = inb((baseio)+UART_LCR); \
418 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
419 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
420 __efr &= ~MOXA_MUST_EFR_SF_MASK; \
421 __efr |= (MOXA_MUST_EFR_SF_RX1|MOXA_MUST_EFR_SF_TX1); \
422 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
423 outb(__oldlcr, (baseio)+UART_LCR); \
424}
425
426#define ENABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) { \
427 u8 __oldmcr; \
428 __oldmcr = inb((baseio)+UART_MCR); \
429 __oldmcr |= MOXA_MUST_MCR_XON_ANY; \
430 outb(__oldmcr, (baseio)+UART_MCR); \
431}
432
433#define DISABLE_MOXA_MUST_XON_ANY_FLOW_CONTROL(baseio) { \
434 u8 __oldmcr; \
435 __oldmcr = inb((baseio)+UART_MCR); \
436 __oldmcr &= ~MOXA_MUST_MCR_XON_ANY; \
437 outb(__oldmcr, (baseio)+UART_MCR); \
438}
439
440#define READ_MOXA_MUST_GDL(baseio) inb((baseio)+MOXA_MUST_GDL_REGISTER)
441
442
443#ifndef INIT_WORK
444#define INIT_WORK(_work, _func, _data){ \
445 _data->tqueue.routine = _func;\
446 _data->tqueue.data = _data;\
447 }
448#endif
449 292
450#endif 293#endif
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index dc6d41841457..fab1b7d42858 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -60,62 +60,56 @@
60#include <linux/slab.h> 60#include <linux/slab.h>
61#include <linux/tty.h> 61#include <linux/tty.h>
62#include <linux/errno.h> 62#include <linux/errno.h>
63#include <linux/string.h> /* used in new tty drivers */ 63#include <linux/string.h> /* used in new tty drivers */
64#include <linux/signal.h> /* used in new tty drivers */ 64#include <linux/signal.h> /* used in new tty drivers */
65#include <linux/ioctl.h> 65#include <linux/ioctl.h>
66#include <linux/n_r3964.h> 66#include <linux/n_r3964.h>
67#include <linux/poll.h> 67#include <linux/poll.h>
68#include <linux/init.h> 68#include <linux/init.h>
69#include <asm/uaccess.h> 69#include <asm/uaccess.h>
70 70
71 71/*#define DEBUG_QUEUE*/
72//#define DEBUG_QUEUE
73 72
74/* Log successful handshake and protocol operations */ 73/* Log successful handshake and protocol operations */
75//#define DEBUG_PROTO_S 74/*#define DEBUG_PROTO_S*/
76 75
77/* Log handshake and protocol errors: */ 76/* Log handshake and protocol errors: */
78//#define DEBUG_PROTO_E 77/*#define DEBUG_PROTO_E*/
79 78
80/* Log Linediscipline operations (open, close, read, write...): */ 79/* Log Linediscipline operations (open, close, read, write...): */
81//#define DEBUG_LDISC 80/*#define DEBUG_LDISC*/
82 81
83/* Log module and memory operations (init, cleanup; kmalloc, kfree): */ 82/* Log module and memory operations (init, cleanup; kmalloc, kfree): */
84//#define DEBUG_MODUL 83/*#define DEBUG_MODUL*/
85 84
86/* Macro helpers for debug output: */ 85/* Macro helpers for debug output: */
87#define TRACE(format, args...) printk("r3964: " format "\n" , ## args); 86#define TRACE(format, args...) printk("r3964: " format "\n" , ## args)
88 87
89#ifdef DEBUG_MODUL 88#ifdef DEBUG_MODUL
90#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args); 89#define TRACE_M(format, args...) printk("r3964: " format "\n" , ## args)
91#else 90#else
92#define TRACE_M(fmt, arg...) /**/ 91#define TRACE_M(fmt, arg...) do {} while (0)
93#endif 92#endif
94
95#ifdef DEBUG_PROTO_S 93#ifdef DEBUG_PROTO_S
96#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args); 94#define TRACE_PS(format, args...) printk("r3964: " format "\n" , ## args)
97#else 95#else
98#define TRACE_PS(fmt, arg...) /**/ 96#define TRACE_PS(fmt, arg...) do {} while (0)
99#endif 97#endif
100
101#ifdef DEBUG_PROTO_E 98#ifdef DEBUG_PROTO_E
102#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args); 99#define TRACE_PE(format, args...) printk("r3964: " format "\n" , ## args)
103#else 100#else
104#define TRACE_PE(fmt, arg...) /**/ 101#define TRACE_PE(fmt, arg...) do {} while (0)
105#endif 102#endif
106
107#ifdef DEBUG_LDISC 103#ifdef DEBUG_LDISC
108#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args); 104#define TRACE_L(format, args...) printk("r3964: " format "\n" , ## args)
109#else 105#else
110#define TRACE_L(fmt, arg...) /**/ 106#define TRACE_L(fmt, arg...) do {} while (0)
111#endif 107#endif
112
113#ifdef DEBUG_QUEUE 108#ifdef DEBUG_QUEUE
114#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args); 109#define TRACE_Q(format, args...) printk("r3964: " format "\n" , ## args)
115#else 110#else
116#define TRACE_Q(fmt, arg...) /**/ 111#define TRACE_Q(fmt, arg...) do {} while (0)
117#endif 112#endif
118
119static void add_tx_queue(struct r3964_info *, struct r3964_block_header *); 113static void add_tx_queue(struct r3964_info *, struct r3964_block_header *);
120static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code); 114static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code);
121static void put_char(struct r3964_info *pInfo, unsigned char ch); 115static void put_char(struct r3964_info *pInfo, unsigned char ch);
@@ -126,937 +120,830 @@ static void receive_char(struct r3964_info *pInfo, const unsigned char c);
126static void receive_error(struct r3964_info *pInfo, const char flag); 120static void receive_error(struct r3964_info *pInfo, const char flag);
127static void on_timeout(unsigned long priv); 121static void on_timeout(unsigned long priv);
128static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg); 122static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg);
129static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf); 123static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
124 unsigned char __user * buf);
130static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, 125static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
131 int error_code, struct r3964_block_header *pBlock); 126 int error_code, struct r3964_block_header *pBlock);
132static struct r3964_message* remove_msg(struct r3964_info *pInfo, 127static struct r3964_message *remove_msg(struct r3964_info *pInfo,
133 struct r3964_client_info *pClient); 128 struct r3964_client_info *pClient);
134static void remove_client_block(struct r3964_info *pInfo, 129static void remove_client_block(struct r3964_info *pInfo,
135 struct r3964_client_info *pClient); 130 struct r3964_client_info *pClient);
136 131
137static int r3964_open(struct tty_struct *tty); 132static int r3964_open(struct tty_struct *tty);
138static void r3964_close(struct tty_struct *tty); 133static void r3964_close(struct tty_struct *tty);
139static ssize_t r3964_read(struct tty_struct *tty, struct file *file, 134static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
140 unsigned char __user *buf, size_t nr); 135 unsigned char __user * buf, size_t nr);
141static ssize_t r3964_write(struct tty_struct * tty, struct file * file, 136static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
142 const unsigned char * buf, size_t nr); 137 const unsigned char *buf, size_t nr);
143static int r3964_ioctl(struct tty_struct * tty, struct file * file, 138static int r3964_ioctl(struct tty_struct *tty, struct file *file,
144 unsigned int cmd, unsigned long arg); 139 unsigned int cmd, unsigned long arg);
145static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old); 140static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
146static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, 141static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
147 struct poll_table_struct *wait); 142 struct poll_table_struct *wait);
148static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 143static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
149 char *fp, int count); 144 char *fp, int count);
150 145
151static struct tty_ldisc tty_ldisc_N_R3964 = { 146static struct tty_ldisc tty_ldisc_N_R3964 = {
152 .owner = THIS_MODULE, 147 .owner = THIS_MODULE,
153 .magic = TTY_LDISC_MAGIC, 148 .magic = TTY_LDISC_MAGIC,
154 .name = "R3964", 149 .name = "R3964",
155 .open = r3964_open, 150 .open = r3964_open,
156 .close = r3964_close, 151 .close = r3964_close,
157 .read = r3964_read, 152 .read = r3964_read,
158 .write = r3964_write, 153 .write = r3964_write,
159 .ioctl = r3964_ioctl, 154 .ioctl = r3964_ioctl,
160 .set_termios = r3964_set_termios, 155 .set_termios = r3964_set_termios,
161 .poll = r3964_poll, 156 .poll = r3964_poll,
162 .receive_buf = r3964_receive_buf, 157 .receive_buf = r3964_receive_buf,
163}; 158};
164 159
165
166
167static void dump_block(const unsigned char *block, unsigned int length) 160static void dump_block(const unsigned char *block, unsigned int length)
168{ 161{
169 unsigned int i,j; 162 unsigned int i, j;
170 char linebuf[16*3+1]; 163 char linebuf[16 * 3 + 1];
171 164
172 for(i=0;i<length;i+=16) 165 for (i = 0; i < length; i += 16) {
173 { 166 for (j = 0; (j < 16) && (j + i < length); j++) {
174 for(j=0;(j<16) && (j+i<length);j++) 167 sprintf(linebuf + 3 * j, "%02x ", block[i + j]);
175 { 168 }
176 sprintf(linebuf+3*j,"%02x ",block[i+j]); 169 linebuf[3 * j] = '\0';
177 } 170 TRACE_PS("%s", linebuf);
178 linebuf[3*j]='\0'; 171 }
179 TRACE_PS("%s",linebuf);
180 }
181} 172}
182 173
183
184
185
186/************************************************************* 174/*************************************************************
187 * Driver initialisation 175 * Driver initialisation
188 *************************************************************/ 176 *************************************************************/
189 177
190
191/************************************************************* 178/*************************************************************
192 * Module support routines 179 * Module support routines
193 *************************************************************/ 180 *************************************************************/
194 181
195static void __exit r3964_exit(void) 182static void __exit r3964_exit(void)
196{ 183{
197 int status; 184 int status;
198 185
199 TRACE_M ("cleanup_module()"); 186 TRACE_M("cleanup_module()");
200 187
201 status=tty_unregister_ldisc(N_R3964); 188 status = tty_unregister_ldisc(N_R3964);
202 189
203 if(status!=0) 190 if (status != 0) {
204 { 191 printk(KERN_ERR "r3964: error unregistering linediscipline: "
205 printk(KERN_ERR "r3964: error unregistering linediscipline: %d\n", status); 192 "%d\n", status);
206 } 193 } else {
207 else 194 TRACE_L("linediscipline successfully unregistered");
208 { 195 }
209 TRACE_L("linediscipline successfully unregistered");
210 }
211
212} 196}
213 197
214static int __init r3964_init(void) 198static int __init r3964_init(void)
215{ 199{
216 int status; 200 int status;
217 201
218 printk ("r3964: Philips r3964 Driver $Revision: 1.10 $\n"); 202 printk("r3964: Philips r3964 Driver $Revision: 1.10 $\n");
219 203
220 /* 204 /*
221 * Register the tty line discipline 205 * Register the tty line discipline
222 */ 206 */
223 207
224 status = tty_register_ldisc (N_R3964, &tty_ldisc_N_R3964); 208 status = tty_register_ldisc(N_R3964, &tty_ldisc_N_R3964);
225 if (status == 0) 209 if (status == 0) {
226 { 210 TRACE_L("line discipline %d registered", N_R3964);
227 TRACE_L("line discipline %d registered", N_R3964); 211 TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags,
228 TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, 212 tty_ldisc_N_R3964.num);
229 tty_ldisc_N_R3964.num); 213 TRACE_L("open=%p", tty_ldisc_N_R3964.open);
230 TRACE_L("open=%p", tty_ldisc_N_R3964.open); 214 TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964);
231 TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964); 215 } else {
232 } 216 printk(KERN_ERR "r3964: error registering line discipline: "
233 else 217 "%d\n", status);
234 { 218 }
235 printk (KERN_ERR "r3964: error registering line discipline: %d\n", status); 219 return status;
236 }
237 return status;
238} 220}
239 221
240module_init(r3964_init); 222module_init(r3964_init);
241module_exit(r3964_exit); 223module_exit(r3964_exit);
242 224
243
244/************************************************************* 225/*************************************************************
245 * Protocol implementation routines 226 * Protocol implementation routines
246 *************************************************************/ 227 *************************************************************/
247 228
248static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) 229static void add_tx_queue(struct r3964_info *pInfo,
230 struct r3964_block_header *pHeader)
249{ 231{
250 unsigned long flags; 232 unsigned long flags;
251 233
252 spin_lock_irqsave(&pInfo->lock, flags); 234 spin_lock_irqsave(&pInfo->lock, flags);
253 235
254 pHeader->next = NULL; 236 pHeader->next = NULL;
255 237
256 if(pInfo->tx_last == NULL) 238 if (pInfo->tx_last == NULL) {
257 { 239 pInfo->tx_first = pInfo->tx_last = pHeader;
258 pInfo->tx_first = pInfo->tx_last = pHeader; 240 } else {
259 } 241 pInfo->tx_last->next = pHeader;
260 else 242 pInfo->tx_last = pHeader;
261 { 243 }
262 pInfo->tx_last->next = pHeader; 244
263 pInfo->tx_last = pHeader; 245 spin_unlock_irqrestore(&pInfo->lock, flags);
264 } 246
265 247 TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
266 spin_unlock_irqrestore(&pInfo->lock, flags); 248 pHeader, pHeader->length, pInfo->tx_first);
267
268 TRACE_Q("add_tx_queue %p, length %d, tx_first = %p",
269 pHeader, pHeader->length, pInfo->tx_first );
270} 249}
271 250
272static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) 251static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code)
273{ 252{
274 struct r3964_block_header *pHeader; 253 struct r3964_block_header *pHeader;
275 unsigned long flags; 254 unsigned long flags;
276#ifdef DEBUG_QUEUE 255#ifdef DEBUG_QUEUE
277 struct r3964_block_header *pDump; 256 struct r3964_block_header *pDump;
278#endif 257#endif
279
280 pHeader = pInfo->tx_first;
281 258
282 if(pHeader==NULL) 259 pHeader = pInfo->tx_first;
283 return; 260
261 if (pHeader == NULL)
262 return;
284 263
285#ifdef DEBUG_QUEUE 264#ifdef DEBUG_QUEUE
286 printk("r3964: remove_from_tx_queue: %p, length %u - ", 265 printk("r3964: remove_from_tx_queue: %p, length %u - ",
287 pHeader, pHeader->length ); 266 pHeader, pHeader->length);
288 for(pDump=pHeader;pDump;pDump=pDump->next) 267 for (pDump = pHeader; pDump; pDump = pDump->next)
289 printk("%p ", pDump); 268 printk("%p ", pDump);
290 printk("\n"); 269 printk("\n");
291#endif 270#endif
292 271
272 if (pHeader->owner) {
273 if (error_code) {
274 add_msg(pHeader->owner, R3964_MSG_ACK, 0,
275 error_code, NULL);
276 } else {
277 add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
278 error_code, NULL);
279 }
280 wake_up_interruptible(&pInfo->read_wait);
281 }
282
283 spin_lock_irqsave(&pInfo->lock, flags);
284
285 pInfo->tx_first = pHeader->next;
286 if (pInfo->tx_first == NULL) {
287 pInfo->tx_last = NULL;
288 }
289
290 spin_unlock_irqrestore(&pInfo->lock, flags);
291
292 kfree(pHeader);
293 TRACE_M("remove_from_tx_queue - kfree %p", pHeader);
293 294
294 if(pHeader->owner) 295 TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
295 { 296 pInfo->tx_first, pInfo->tx_last);
296 if(error_code)
297 {
298 add_msg(pHeader->owner, R3964_MSG_ACK, 0,
299 error_code, NULL);
300 }
301 else
302 {
303 add_msg(pHeader->owner, R3964_MSG_ACK, pHeader->length,
304 error_code, NULL);
305 }
306 wake_up_interruptible (&pInfo->read_wait);
307 }
308
309 spin_lock_irqsave(&pInfo->lock, flags);
310
311 pInfo->tx_first = pHeader->next;
312 if(pInfo->tx_first==NULL)
313 {
314 pInfo->tx_last = NULL;
315 }
316
317 spin_unlock_irqrestore(&pInfo->lock, flags);
318
319 kfree(pHeader);
320 TRACE_M("remove_from_tx_queue - kfree %p",pHeader);
321
322 TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p",
323 pInfo->tx_first, pInfo->tx_last );
324} 297}
325 298
326static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) 299static void add_rx_queue(struct r3964_info *pInfo,
300 struct r3964_block_header *pHeader)
327{ 301{
328 unsigned long flags; 302 unsigned long flags;
329 303
330 spin_lock_irqsave(&pInfo->lock, flags); 304 spin_lock_irqsave(&pInfo->lock, flags);
331 305
332 pHeader->next = NULL; 306 pHeader->next = NULL;
333 307
334 if(pInfo->rx_last == NULL) 308 if (pInfo->rx_last == NULL) {
335 { 309 pInfo->rx_first = pInfo->rx_last = pHeader;
336 pInfo->rx_first = pInfo->rx_last = pHeader; 310 } else {
337 } 311 pInfo->rx_last->next = pHeader;
338 else 312 pInfo->rx_last = pHeader;
339 { 313 }
340 pInfo->rx_last->next = pHeader; 314 pInfo->blocks_in_rx_queue++;
341 pInfo->rx_last = pHeader; 315
342 } 316 spin_unlock_irqrestore(&pInfo->lock, flags);
343 pInfo->blocks_in_rx_queue++; 317
344 318 TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
345 spin_unlock_irqrestore(&pInfo->lock, flags); 319 pHeader, pHeader->length,
346 320 pInfo->rx_first, pInfo->blocks_in_rx_queue);
347 TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d",
348 pHeader, pHeader->length,
349 pInfo->rx_first, pInfo->blocks_in_rx_queue);
350} 321}
351 322
352static void remove_from_rx_queue(struct r3964_info *pInfo, 323static void remove_from_rx_queue(struct r3964_info *pInfo,
353 struct r3964_block_header *pHeader) 324 struct r3964_block_header *pHeader)
354{ 325{
355 unsigned long flags; 326 unsigned long flags;
356 struct r3964_block_header *pFind; 327 struct r3964_block_header *pFind;
357 328
358 if(pHeader==NULL) 329 if (pHeader == NULL)
359 return; 330 return;
360 331
361 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", 332 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
362 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue ); 333 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
363 TRACE_Q("remove_from_rx_queue: %p, length %u", 334 TRACE_Q("remove_from_rx_queue: %p, length %u",
364 pHeader, pHeader->length ); 335 pHeader, pHeader->length);
365 336
366 spin_lock_irqsave(&pInfo->lock, flags); 337 spin_lock_irqsave(&pInfo->lock, flags);
367 338
368 if(pInfo->rx_first == pHeader) 339 if (pInfo->rx_first == pHeader) {
369 { 340 /* Remove the first block in the linked list: */
370 /* Remove the first block in the linked list: */ 341 pInfo->rx_first = pHeader->next;
371 pInfo->rx_first = pHeader->next; 342
372 343 if (pInfo->rx_first == NULL) {
373 if(pInfo->rx_first==NULL) 344 pInfo->rx_last = NULL;
374 { 345 }
375 pInfo->rx_last = NULL; 346 pInfo->blocks_in_rx_queue--;
376 } 347 } else {
377 pInfo->blocks_in_rx_queue--; 348 /* Find block to remove: */
378 } 349 for (pFind = pInfo->rx_first; pFind; pFind = pFind->next) {
379 else 350 if (pFind->next == pHeader) {
380 { 351 /* Got it. */
381 /* Find block to remove: */ 352 pFind->next = pHeader->next;
382 for(pFind=pInfo->rx_first; pFind; pFind=pFind->next) 353 pInfo->blocks_in_rx_queue--;
383 { 354 if (pFind->next == NULL) {
384 if(pFind->next == pHeader) 355 /* Oh, removed the last one! */
385 { 356 pInfo->rx_last = pFind;
386 /* Got it. */ 357 }
387 pFind->next = pHeader->next; 358 break;
388 pInfo->blocks_in_rx_queue--; 359 }
389 if(pFind->next==NULL) 360 }
390 { 361 }
391 /* Oh, removed the last one! */ 362
392 pInfo->rx_last = pFind; 363 spin_unlock_irqrestore(&pInfo->lock, flags);
393 } 364
394 break; 365 kfree(pHeader);
395 } 366 TRACE_M("remove_from_rx_queue - kfree %p", pHeader);
396 } 367
397 } 368 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
398 369 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue);
399 spin_unlock_irqrestore(&pInfo->lock, flags);
400
401 kfree(pHeader);
402 TRACE_M("remove_from_rx_queue - kfree %p",pHeader);
403
404 TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d",
405 pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue );
406} 370}
407 371
408static void put_char(struct r3964_info *pInfo, unsigned char ch) 372static void put_char(struct r3964_info *pInfo, unsigned char ch)
409{ 373{
410 struct tty_struct *tty = pInfo->tty; 374 struct tty_struct *tty = pInfo->tty;
411 375
412 if(tty==NULL) 376 if (tty == NULL)
413 return; 377 return;
414 378
415 if(tty->driver->put_char) 379 if (tty->driver->put_char) {
416 { 380 tty->driver->put_char(tty, ch);
417 tty->driver->put_char(tty, ch); 381 }
418 } 382 pInfo->bcc ^= ch;
419 pInfo->bcc ^= ch;
420} 383}
421 384
422static void flush(struct r3964_info *pInfo) 385static void flush(struct r3964_info *pInfo)
423{ 386{
424 struct tty_struct *tty = pInfo->tty; 387 struct tty_struct *tty = pInfo->tty;
425 388
426 if(tty==NULL) 389 if (tty == NULL)
427 return; 390 return;
428 391
429 if(tty->driver->flush_chars) 392 if (tty->driver->flush_chars) {
430 { 393 tty->driver->flush_chars(tty);
431 tty->driver->flush_chars(tty); 394 }
432 }
433} 395}
434 396
435static void trigger_transmit(struct r3964_info *pInfo) 397static void trigger_transmit(struct r3964_info *pInfo)
436{ 398{
437 unsigned long flags; 399 unsigned long flags;
438
439 400
440 spin_lock_irqsave(&pInfo->lock, flags); 401 spin_lock_irqsave(&pInfo->lock, flags);
441 402
442 if((pInfo->state == R3964_IDLE) && (pInfo->tx_first!=NULL)) 403 if ((pInfo->state == R3964_IDLE) && (pInfo->tx_first != NULL)) {
443 { 404 pInfo->state = R3964_TX_REQUEST;
444 pInfo->state = R3964_TX_REQUEST; 405 pInfo->nRetry = 0;
445 pInfo->nRetry=0; 406 pInfo->flags &= ~R3964_ERROR;
446 pInfo->flags &= ~R3964_ERROR; 407 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
447 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
448 408
449 spin_unlock_irqrestore(&pInfo->lock, flags); 409 spin_unlock_irqrestore(&pInfo->lock, flags);
450 410
451 TRACE_PS("trigger_transmit - sent STX"); 411 TRACE_PS("trigger_transmit - sent STX");
452 412
453 put_char(pInfo, STX); 413 put_char(pInfo, STX);
454 flush(pInfo); 414 flush(pInfo);
455 415
456 pInfo->bcc = 0; 416 pInfo->bcc = 0;
457 } 417 } else {
458 else 418 spin_unlock_irqrestore(&pInfo->lock, flags);
459 { 419 }
460 spin_unlock_irqrestore(&pInfo->lock, flags);
461 }
462} 420}
463 421
464static void retry_transmit(struct r3964_info *pInfo) 422static void retry_transmit(struct r3964_info *pInfo)
465{ 423{
466 if(pInfo->nRetry<R3964_MAX_RETRIES) 424 if (pInfo->nRetry < R3964_MAX_RETRIES) {
467 { 425 TRACE_PE("transmission failed. Retry #%d", pInfo->nRetry);
468 TRACE_PE("transmission failed. Retry #%d", 426 pInfo->bcc = 0;
469 pInfo->nRetry); 427 put_char(pInfo, STX);
470 pInfo->bcc = 0; 428 flush(pInfo);
471 put_char(pInfo, STX); 429 pInfo->state = R3964_TX_REQUEST;
472 flush(pInfo); 430 pInfo->nRetry++;
473 pInfo->state = R3964_TX_REQUEST; 431 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
474 pInfo->nRetry++; 432 } else {
475 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ); 433 TRACE_PE("transmission failed after %d retries",
476 } 434 R3964_MAX_RETRIES);
477 else 435
478 { 436 remove_from_tx_queue(pInfo, R3964_TX_FAIL);
479 TRACE_PE("transmission failed after %d retries", 437
480 R3964_MAX_RETRIES); 438 put_char(pInfo, NAK);
481 439 flush(pInfo);
482 remove_from_tx_queue(pInfo, R3964_TX_FAIL); 440 pInfo->state = R3964_IDLE;
483 441
484 put_char(pInfo, NAK); 442 trigger_transmit(pInfo);
485 flush(pInfo); 443 }
486 pInfo->state = R3964_IDLE;
487
488 trigger_transmit(pInfo);
489 }
490} 444}
491 445
492
493static void transmit_block(struct r3964_info *pInfo) 446static void transmit_block(struct r3964_info *pInfo)
494{ 447{
495 struct tty_struct *tty = pInfo->tty; 448 struct tty_struct *tty = pInfo->tty;
496 struct r3964_block_header *pBlock = pInfo->tx_first; 449 struct r3964_block_header *pBlock = pInfo->tx_first;
497 int room=0; 450 int room = 0;
498 451
499 if((tty==NULL) || (pBlock==NULL)) 452 if ((tty == NULL) || (pBlock == NULL)) {
500 { 453 return;
501 return; 454 }
502 } 455
503 456 if (tty->driver->write_room)
504 if(tty->driver->write_room) 457 room = tty->driver->write_room(tty);
505 room=tty->driver->write_room(tty); 458
506 459 TRACE_PS("transmit_block %p, room %d, length %d",
507 TRACE_PS("transmit_block %p, room %d, length %d", 460 pBlock, room, pBlock->length);
508 pBlock, room, pBlock->length); 461
509 462 while (pInfo->tx_position < pBlock->length) {
510 while(pInfo->tx_position < pBlock->length) 463 if (room < 2)
511 { 464 break;
512 if(room<2) 465
513 break; 466 if (pBlock->data[pInfo->tx_position] == DLE) {
514 467 /* send additional DLE char: */
515 if(pBlock->data[pInfo->tx_position]==DLE) 468 put_char(pInfo, DLE);
516 { 469 }
517 /* send additional DLE char: */ 470 put_char(pInfo, pBlock->data[pInfo->tx_position++]);
518 put_char(pInfo, DLE); 471
519 } 472 room--;
520 put_char(pInfo, pBlock->data[pInfo->tx_position++]); 473 }
521 474
522 room--; 475 if ((pInfo->tx_position == pBlock->length) && (room >= 3)) {
523 } 476 put_char(pInfo, DLE);
524 477 put_char(pInfo, ETX);
525 if((pInfo->tx_position == pBlock->length) && (room>=3)) 478 if (pInfo->flags & R3964_BCC) {
526 { 479 put_char(pInfo, pInfo->bcc);
527 put_char(pInfo, DLE); 480 }
528 put_char(pInfo, ETX); 481 pInfo->state = R3964_WAIT_FOR_TX_ACK;
529 if(pInfo->flags & R3964_BCC) 482 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
530 { 483 }
531 put_char(pInfo, pInfo->bcc); 484 flush(pInfo);
532 }
533 pInfo->state = R3964_WAIT_FOR_TX_ACK;
534 mod_timer(&pInfo->tmr, jiffies + R3964_TO_QVZ);
535 }
536 flush(pInfo);
537} 485}
538 486
539static void on_receive_block(struct r3964_info *pInfo) 487static void on_receive_block(struct r3964_info *pInfo)
540{ 488{
541 unsigned int length; 489 unsigned int length;
542 struct r3964_client_info *pClient; 490 struct r3964_client_info *pClient;
543 struct r3964_block_header *pBlock; 491 struct r3964_block_header *pBlock;
544 492
545 length=pInfo->rx_position; 493 length = pInfo->rx_position;
546 494
547 /* compare byte checksum characters: */ 495 /* compare byte checksum characters: */
548 if(pInfo->flags & R3964_BCC) 496 if (pInfo->flags & R3964_BCC) {
549 { 497 if (pInfo->bcc != pInfo->last_rx) {
550 if(pInfo->bcc!=pInfo->last_rx) 498 TRACE_PE("checksum error - got %x but expected %x",
551 { 499 pInfo->last_rx, pInfo->bcc);
552 TRACE_PE("checksum error - got %x but expected %x", 500 pInfo->flags |= R3964_CHECKSUM;
553 pInfo->last_rx, pInfo->bcc); 501 }
554 pInfo->flags |= R3964_CHECKSUM; 502 }
555 } 503
556 } 504 /* check for errors (parity, overrun,...): */
557 505 if (pInfo->flags & R3964_ERROR) {
558 /* check for errors (parity, overrun,...): */ 506 TRACE_PE("on_receive_block - transmission failed error %x",
559 if(pInfo->flags & R3964_ERROR) 507 pInfo->flags & R3964_ERROR);
560 { 508
561 TRACE_PE("on_receive_block - transmission failed error %x", 509 put_char(pInfo, NAK);
562 pInfo->flags & R3964_ERROR); 510 flush(pInfo);
563 511 if (pInfo->nRetry < R3964_MAX_RETRIES) {
564 put_char(pInfo, NAK); 512 pInfo->state = R3964_WAIT_FOR_RX_REPEAT;
565 flush(pInfo); 513 pInfo->nRetry++;
566 if(pInfo->nRetry<R3964_MAX_RETRIES) 514 mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
567 { 515 } else {
568 pInfo->state=R3964_WAIT_FOR_RX_REPEAT; 516 TRACE_PE("on_receive_block - failed after max retries");
569 pInfo->nRetry++; 517 pInfo->state = R3964_IDLE;
570 mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC); 518 }
571 } 519 return;
572 else 520 }
573 { 521
574 TRACE_PE("on_receive_block - failed after max retries"); 522 /* received block; submit DLE: */
575 pInfo->state=R3964_IDLE; 523 put_char(pInfo, DLE);
576 } 524 flush(pInfo);
577 return; 525 del_timer_sync(&pInfo->tmr);
578 } 526 TRACE_PS(" rx success: got %d chars", length);
579 527
580 528 /* prepare struct r3964_block_header: */
581 /* received block; submit DLE: */ 529 pBlock = kmalloc(length + sizeof(struct r3964_block_header),
582 put_char(pInfo, DLE); 530 GFP_KERNEL);
583 flush(pInfo); 531 TRACE_M("on_receive_block - kmalloc %p", pBlock);
584 del_timer_sync(&pInfo->tmr); 532
585 TRACE_PS(" rx success: got %d chars", length); 533 if (pBlock == NULL)
586 534 return;
587 /* prepare struct r3964_block_header: */ 535
588 pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL); 536 pBlock->length = length;
589 TRACE_M("on_receive_block - kmalloc %p",pBlock); 537 pBlock->data = ((unsigned char *)pBlock) +
590 538 sizeof(struct r3964_block_header);
591 if(pBlock==NULL) 539 pBlock->locks = 0;
592 return; 540 pBlock->next = NULL;
593 541 pBlock->owner = NULL;
594 pBlock->length = length; 542
595 pBlock->data = ((unsigned char*)pBlock)+sizeof(struct r3964_block_header); 543 memcpy(pBlock->data, pInfo->rx_buf, length);
596 pBlock->locks = 0; 544
597 pBlock->next = NULL; 545 /* queue block into rx_queue: */
598 pBlock->owner = NULL; 546 add_rx_queue(pInfo, pBlock);
599 547
600 memcpy(pBlock->data, pInfo->rx_buf, length); 548 /* notify attached client processes: */
601 549 for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
602 /* queue block into rx_queue: */ 550 if (pClient->sig_flags & R3964_SIG_DATA) {
603 add_rx_queue(pInfo, pBlock); 551 add_msg(pClient, R3964_MSG_DATA, length, R3964_OK,
604 552 pBlock);
605 /* notify attached client processes: */ 553 }
606 for(pClient=pInfo->firstClient; pClient; pClient=pClient->next) 554 }
607 { 555 wake_up_interruptible(&pInfo->read_wait);
608 if(pClient->sig_flags & R3964_SIG_DATA)
609 {
610 add_msg(pClient, R3964_MSG_DATA, length, R3964_OK, pBlock);
611 }
612 }
613 wake_up_interruptible (&pInfo->read_wait);
614
615 pInfo->state = R3964_IDLE;
616
617 trigger_transmit(pInfo);
618}
619 556
557 pInfo->state = R3964_IDLE;
558
559 trigger_transmit(pInfo);
560}
620 561
621static void receive_char(struct r3964_info *pInfo, const unsigned char c) 562static void receive_char(struct r3964_info *pInfo, const unsigned char c)
622{ 563{
623 switch(pInfo->state) 564 switch (pInfo->state) {
624 { 565 case R3964_TX_REQUEST:
625 case R3964_TX_REQUEST: 566 if (c == DLE) {
626 if(c==DLE) 567 TRACE_PS("TX_REQUEST - got DLE");
627 { 568
628 TRACE_PS("TX_REQUEST - got DLE"); 569 pInfo->state = R3964_TRANSMITTING;
629 570 pInfo->tx_position = 0;
630 pInfo->state = R3964_TRANSMITTING; 571
631 pInfo->tx_position = 0; 572 transmit_block(pInfo);
632 573 } else if (c == STX) {
633 transmit_block(pInfo); 574 if (pInfo->nRetry == 0) {
634 } 575 TRACE_PE("TX_REQUEST - init conflict");
635 else if(c==STX) 576 if (pInfo->priority == R3964_SLAVE) {
636 { 577 goto start_receiving;
637 if(pInfo->nRetry==0) 578 }
638 { 579 } else {
639 TRACE_PE("TX_REQUEST - init conflict"); 580 TRACE_PE("TX_REQUEST - secondary init "
640 if(pInfo->priority == R3964_SLAVE) 581 "conflict!? Switching to SLAVE mode "
641 { 582 "for next rx.");
642 goto start_receiving; 583 goto start_receiving;
643 } 584 }
644 } 585 } else {
645 else 586 TRACE_PE("TX_REQUEST - char != DLE: %x", c);
646 { 587 retry_transmit(pInfo);
647 TRACE_PE("TX_REQUEST - secondary init conflict!?" 588 }
648 " Switching to SLAVE mode for next rx."); 589 break;
649 goto start_receiving; 590 case R3964_TRANSMITTING:
650 } 591 if (c == NAK) {
651 } 592 TRACE_PE("TRANSMITTING - got NAK");
652 else 593 retry_transmit(pInfo);
653 { 594 } else {
654 TRACE_PE("TX_REQUEST - char != DLE: %x", c); 595 TRACE_PE("TRANSMITTING - got invalid char");
655 retry_transmit(pInfo); 596
656 } 597 pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY;
657 break; 598 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
658 case R3964_TRANSMITTING: 599 }
659 if(c==NAK) 600 break;
660 { 601 case R3964_WAIT_FOR_TX_ACK:
661 TRACE_PE("TRANSMITTING - got NAK"); 602 if (c == DLE) {
662 retry_transmit(pInfo); 603 TRACE_PS("WAIT_FOR_TX_ACK - got DLE");
663 } 604 remove_from_tx_queue(pInfo, R3964_OK);
664 else 605
665 { 606 pInfo->state = R3964_IDLE;
666 TRACE_PE("TRANSMITTING - got invalid char"); 607 trigger_transmit(pInfo);
667 608 } else {
668 pInfo->state = R3964_WAIT_ZVZ_BEFORE_TX_RETRY; 609 retry_transmit(pInfo);
669 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 610 }
670 } 611 break;
671 break; 612 case R3964_WAIT_FOR_RX_REPEAT:
672 case R3964_WAIT_FOR_TX_ACK: 613 /* FALLTROUGH */
673 if(c==DLE) 614 case R3964_IDLE:
674 { 615 if (c == STX) {
675 TRACE_PS("WAIT_FOR_TX_ACK - got DLE"); 616 /* Prevent rx_queue from overflow: */
676 remove_from_tx_queue(pInfo, R3964_OK); 617 if (pInfo->blocks_in_rx_queue >=
677 618 R3964_MAX_BLOCKS_IN_RX_QUEUE) {
678 pInfo->state = R3964_IDLE; 619 TRACE_PE("IDLE - got STX but no space in "
679 trigger_transmit(pInfo); 620 "rx_queue!");
680 } 621 pInfo->state = R3964_WAIT_FOR_RX_BUF;
681 else 622 mod_timer(&pInfo->tmr,
682 { 623 jiffies + R3964_TO_NO_BUF);
683 retry_transmit(pInfo); 624 break;
684 } 625 }
685 break;
686 case R3964_WAIT_FOR_RX_REPEAT:
687 /* FALLTROUGH */
688 case R3964_IDLE:
689 if(c==STX)
690 {
691 /* Prevent rx_queue from overflow: */
692 if(pInfo->blocks_in_rx_queue >= R3964_MAX_BLOCKS_IN_RX_QUEUE)
693 {
694 TRACE_PE("IDLE - got STX but no space in rx_queue!");
695 pInfo->state=R3964_WAIT_FOR_RX_BUF;
696 mod_timer(&pInfo->tmr, jiffies + R3964_TO_NO_BUF);
697 break;
698 }
699start_receiving: 626start_receiving:
700 /* Ok, start receiving: */ 627 /* Ok, start receiving: */
701 TRACE_PS("IDLE - got STX"); 628 TRACE_PS("IDLE - got STX");
702 pInfo->rx_position = 0; 629 pInfo->rx_position = 0;
703 pInfo->last_rx = 0; 630 pInfo->last_rx = 0;
704 pInfo->flags &= ~R3964_ERROR; 631 pInfo->flags &= ~R3964_ERROR;
705 pInfo->state=R3964_RECEIVING; 632 pInfo->state = R3964_RECEIVING;
706 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 633 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
707 pInfo->nRetry = 0; 634 pInfo->nRetry = 0;
708 put_char(pInfo, DLE); 635 put_char(pInfo, DLE);
709 flush(pInfo); 636 flush(pInfo);
710 pInfo->bcc = 0; 637 pInfo->bcc = 0;
711 } 638 }
712 break; 639 break;
713 case R3964_RECEIVING: 640 case R3964_RECEIVING:
714 if(pInfo->rx_position < RX_BUF_SIZE) 641 if (pInfo->rx_position < RX_BUF_SIZE) {
715 { 642 pInfo->bcc ^= c;
716 pInfo->bcc ^= c; 643
717 644 if (c == DLE) {
718 if(c==DLE) 645 if (pInfo->last_rx == DLE) {
719 { 646 pInfo->last_rx = 0;
720 if(pInfo->last_rx==DLE) 647 goto char_to_buf;
721 { 648 }
722 pInfo->last_rx = 0; 649 pInfo->last_rx = DLE;
723 goto char_to_buf; 650 break;
724 } 651 } else if ((c == ETX) && (pInfo->last_rx == DLE)) {
725 pInfo->last_rx = DLE; 652 if (pInfo->flags & R3964_BCC) {
726 break; 653 pInfo->state = R3964_WAIT_FOR_BCC;
727 } 654 mod_timer(&pInfo->tmr,
728 else if((c==ETX) && (pInfo->last_rx==DLE)) 655 jiffies + R3964_TO_ZVZ);
729 { 656 } else {
730 if(pInfo->flags & R3964_BCC) 657 on_receive_block(pInfo);
731 { 658 }
732 pInfo->state = R3964_WAIT_FOR_BCC; 659 } else {
733 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 660 pInfo->last_rx = c;
734 }
735 else
736 {
737 on_receive_block(pInfo);
738 }
739 }
740 else
741 {
742 pInfo->last_rx = c;
743char_to_buf: 661char_to_buf:
744 pInfo->rx_buf[pInfo->rx_position++] = c; 662 pInfo->rx_buf[pInfo->rx_position++] = c;
745 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ); 663 mod_timer(&pInfo->tmr, jiffies + R3964_TO_ZVZ);
746 } 664 }
747 } 665 }
748 /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */ 666 /* else: overflow-msg? BUF_SIZE>MTU; should not happen? */
749 break; 667 break;
750 case R3964_WAIT_FOR_BCC: 668 case R3964_WAIT_FOR_BCC:
751 pInfo->last_rx = c; 669 pInfo->last_rx = c;
752 on_receive_block(pInfo); 670 on_receive_block(pInfo);
753 break; 671 break;
754 } 672 }
755} 673}
756 674
757static void receive_error(struct r3964_info *pInfo, const char flag) 675static void receive_error(struct r3964_info *pInfo, const char flag)
758{ 676{
759 switch (flag) 677 switch (flag) {
760 { 678 case TTY_NORMAL:
761 case TTY_NORMAL: 679 break;
762 break; 680 case TTY_BREAK:
763 case TTY_BREAK: 681 TRACE_PE("received break");
764 TRACE_PE("received break") 682 pInfo->flags |= R3964_BREAK;
765 pInfo->flags |= R3964_BREAK; 683 break;
766 break; 684 case TTY_PARITY:
767 case TTY_PARITY: 685 TRACE_PE("parity error");
768 TRACE_PE("parity error") 686 pInfo->flags |= R3964_PARITY;
769 pInfo->flags |= R3964_PARITY; 687 break;
770 break; 688 case TTY_FRAME:
771 case TTY_FRAME: 689 TRACE_PE("frame error");
772 TRACE_PE("frame error") 690 pInfo->flags |= R3964_FRAME;
773 pInfo->flags |= R3964_FRAME; 691 break;
774 break; 692 case TTY_OVERRUN:
775 case TTY_OVERRUN: 693 TRACE_PE("frame overrun");
776 TRACE_PE("frame overrun") 694 pInfo->flags |= R3964_OVERRUN;
777 pInfo->flags |= R3964_OVERRUN; 695 break;
778 break; 696 default:
779 default: 697 TRACE_PE("receive_error - unknown flag %d", flag);
780 TRACE_PE("receive_error - unknown flag %d", flag); 698 pInfo->flags |= R3964_UNKNOWN;
781 pInfo->flags |= R3964_UNKNOWN; 699 break;
782 break; 700 }
783 }
784} 701}
785 702
786static void on_timeout(unsigned long priv) 703static void on_timeout(unsigned long priv)
787{ 704{
788 struct r3964_info *pInfo = (void *)priv; 705 struct r3964_info *pInfo = (void *)priv;
789 706
790 switch(pInfo->state) 707 switch (pInfo->state) {
791 { 708 case R3964_TX_REQUEST:
792 case R3964_TX_REQUEST: 709 TRACE_PE("TX_REQUEST - timeout");
793 TRACE_PE("TX_REQUEST - timeout"); 710 retry_transmit(pInfo);
794 retry_transmit(pInfo); 711 break;
795 break; 712 case R3964_WAIT_ZVZ_BEFORE_TX_RETRY:
796 case R3964_WAIT_ZVZ_BEFORE_TX_RETRY: 713 put_char(pInfo, NAK);
797 put_char(pInfo, NAK); 714 flush(pInfo);
798 flush(pInfo); 715 retry_transmit(pInfo);
799 retry_transmit(pInfo); 716 break;
800 break; 717 case R3964_WAIT_FOR_TX_ACK:
801 case R3964_WAIT_FOR_TX_ACK: 718 TRACE_PE("WAIT_FOR_TX_ACK - timeout");
802 TRACE_PE("WAIT_FOR_TX_ACK - timeout"); 719 retry_transmit(pInfo);
803 retry_transmit(pInfo); 720 break;
804 break; 721 case R3964_WAIT_FOR_RX_BUF:
805 case R3964_WAIT_FOR_RX_BUF: 722 TRACE_PE("WAIT_FOR_RX_BUF - timeout");
806 TRACE_PE("WAIT_FOR_RX_BUF - timeout"); 723 put_char(pInfo, NAK);
807 put_char(pInfo, NAK); 724 flush(pInfo);
808 flush(pInfo); 725 pInfo->state = R3964_IDLE;
809 pInfo->state=R3964_IDLE; 726 break;
810 break; 727 case R3964_RECEIVING:
811 case R3964_RECEIVING: 728 TRACE_PE("RECEIVING - timeout after %d chars",
812 TRACE_PE("RECEIVING - timeout after %d chars", 729 pInfo->rx_position);
813 pInfo->rx_position); 730 put_char(pInfo, NAK);
814 put_char(pInfo, NAK); 731 flush(pInfo);
815 flush(pInfo); 732 pInfo->state = R3964_IDLE;
816 pInfo->state=R3964_IDLE; 733 break;
817 break; 734 case R3964_WAIT_FOR_RX_REPEAT:
818 case R3964_WAIT_FOR_RX_REPEAT: 735 TRACE_PE("WAIT_FOR_RX_REPEAT - timeout");
819 TRACE_PE("WAIT_FOR_RX_REPEAT - timeout"); 736 pInfo->state = R3964_IDLE;
820 pInfo->state=R3964_IDLE; 737 break;
821 break; 738 case R3964_WAIT_FOR_BCC:
822 case R3964_WAIT_FOR_BCC: 739 TRACE_PE("WAIT_FOR_BCC - timeout");
823 TRACE_PE("WAIT_FOR_BCC - timeout"); 740 put_char(pInfo, NAK);
824 put_char(pInfo, NAK); 741 flush(pInfo);
825 flush(pInfo); 742 pInfo->state = R3964_IDLE;
826 pInfo->state=R3964_IDLE; 743 break;
827 break; 744 }
828 }
829} 745}
830 746
831static struct r3964_client_info *findClient( 747static struct r3964_client_info *findClient(struct r3964_info *pInfo,
832 struct r3964_info *pInfo, struct pid *pid) 748 struct pid *pid)
833{ 749{
834 struct r3964_client_info *pClient; 750 struct r3964_client_info *pClient;
835 751
836 for(pClient=pInfo->firstClient; pClient; pClient=pClient->next) 752 for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
837 { 753 if (pClient->pid == pid) {
838 if(pClient->pid == pid) 754 return pClient;
839 { 755 }
840 return pClient; 756 }
841 } 757 return NULL;
842 }
843 return NULL;
844} 758}
845 759
846static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) 760static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
847{ 761{
848 struct r3964_client_info *pClient; 762 struct r3964_client_info *pClient;
849 struct r3964_client_info **ppClient; 763 struct r3964_client_info **ppClient;
850 struct r3964_message *pMsg; 764 struct r3964_message *pMsg;
851 765
852 if((arg & R3964_SIG_ALL)==0) 766 if ((arg & R3964_SIG_ALL) == 0) {
853 { 767 /* Remove client from client list */
854 /* Remove client from client list */ 768 for (ppClient = &pInfo->firstClient; *ppClient;
855 for(ppClient=&pInfo->firstClient; *ppClient; ppClient=&(*ppClient)->next) 769 ppClient = &(*ppClient)->next) {
856 { 770 pClient = *ppClient;
857 pClient = *ppClient; 771
858 772 if (pClient->pid == pid) {
859 if(pClient->pid == pid) 773 TRACE_PS("removing client %d from client list",
860 { 774 pid_nr(pid));
861 TRACE_PS("removing client %d from client list", pid_nr(pid)); 775 *ppClient = pClient->next;
862 *ppClient = pClient->next; 776 while (pClient->msg_count) {
863 while(pClient->msg_count) 777 pMsg = remove_msg(pInfo, pClient);
864 { 778 if (pMsg) {
865 pMsg=remove_msg(pInfo, pClient); 779 kfree(pMsg);
866 if(pMsg) 780 TRACE_M("enable_signals - msg "
867 { 781 "kfree %p", pMsg);
868 kfree(pMsg); 782 }
869 TRACE_M("enable_signals - msg kfree %p",pMsg); 783 }
870 } 784 put_pid(pClient->pid);
871 } 785 kfree(pClient);
872 put_pid(pClient->pid); 786 TRACE_M("enable_signals - kfree %p", pClient);
873 kfree(pClient); 787 return 0;
874 TRACE_M("enable_signals - kfree %p",pClient); 788 }
875 return 0; 789 }
876 } 790 return -EINVAL;
877 } 791 } else {
878 return -EINVAL; 792 pClient = findClient(pInfo, pid);
879 } 793 if (pClient) {
880 else 794 /* update signal options */
881 { 795 pClient->sig_flags = arg;
882 pClient=findClient(pInfo, pid); 796 } else {
883 if(pClient) 797 /* add client to client list */
884 { 798 pClient = kmalloc(sizeof(struct r3964_client_info),
885 /* update signal options */ 799 GFP_KERNEL);
886 pClient->sig_flags=arg; 800 TRACE_M("enable_signals - kmalloc %p", pClient);
887 } 801 if (pClient == NULL)
888 else 802 return -ENOMEM;
889 { 803
890 /* add client to client list */ 804 TRACE_PS("add client %d to client list", pid_nr(pid));
891 pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL); 805 spin_lock_init(&pClient->lock);
892 TRACE_M("enable_signals - kmalloc %p",pClient); 806 pClient->sig_flags = arg;
893 if(pClient==NULL) 807 pClient->pid = get_pid(pid);
894 return -ENOMEM; 808 pClient->next = pInfo->firstClient;
895 809 pClient->first_msg = NULL;
896 TRACE_PS("add client %d to client list", pid_nr(pid)); 810 pClient->last_msg = NULL;
897 spin_lock_init(&pClient->lock); 811 pClient->next_block_to_read = NULL;
898 pClient->sig_flags=arg; 812 pClient->msg_count = 0;
899 pClient->pid = get_pid(pid); 813 pInfo->firstClient = pClient;
900 pClient->next=pInfo->firstClient; 814 }
901 pClient->first_msg = NULL; 815 }
902 pClient->last_msg = NULL; 816
903 pClient->next_block_to_read = NULL; 817 return 0;
904 pClient->msg_count = 0;
905 pInfo->firstClient=pClient;
906 }
907 }
908
909 return 0;
910} 818}
911 819
912static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf) 820static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
821 unsigned char __user * buf)
913{ 822{
914 struct r3964_client_info *pClient; 823 struct r3964_client_info *pClient;
915 struct r3964_block_header *block; 824 struct r3964_block_header *block;
916 825
917 if(!buf) 826 if (!buf) {
918 { 827 return -EINVAL;
919 return -EINVAL; 828 }
920 } 829
921 830 pClient = findClient(pInfo, pid);
922 pClient=findClient(pInfo,pid); 831 if (pClient == NULL) {
923 if(pClient==NULL) 832 return -EINVAL;
924 { 833 }
925 return -EINVAL; 834
926 } 835 block = pClient->next_block_to_read;
927 836 if (!block) {
928 block=pClient->next_block_to_read; 837 return 0;
929 if(!block) 838 } else {
930 { 839 if (copy_to_user(buf, block->data, block->length))
931 return 0; 840 return -EFAULT;
932 } 841
933 else 842 remove_client_block(pInfo, pClient);
934 { 843 return block->length;
935 if (copy_to_user (buf, block->data, block->length)) 844 }
936 return -EFAULT; 845
937 846 return -EINVAL;
938 remove_client_block(pInfo, pClient);
939 return block->length;
940 }
941
942 return -EINVAL;
943} 847}
944 848
945static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, 849static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
946 int error_code, struct r3964_block_header *pBlock) 850 int error_code, struct r3964_block_header *pBlock)
947{ 851{
948 struct r3964_message *pMsg; 852 struct r3964_message *pMsg;
949 unsigned long flags; 853 unsigned long flags;
950 854
951 if(pClient->msg_count<R3964_MAX_MSG_COUNT-1) 855 if (pClient->msg_count < R3964_MAX_MSG_COUNT - 1) {
952 {
953queue_the_message: 856queue_the_message:
954 857
955 pMsg = kmalloc(sizeof(struct r3964_message), 858 pMsg = kmalloc(sizeof(struct r3964_message),
956 error_code?GFP_ATOMIC:GFP_KERNEL); 859 error_code ? GFP_ATOMIC : GFP_KERNEL);
957 TRACE_M("add_msg - kmalloc %p",pMsg); 860 TRACE_M("add_msg - kmalloc %p", pMsg);
958 if(pMsg==NULL) { 861 if (pMsg == NULL) {
959 return; 862 return;
960 } 863 }
961 864
962 spin_lock_irqsave(&pClient->lock, flags); 865 spin_lock_irqsave(&pClient->lock, flags);
963 866
964 pMsg->msg_id = msg_id; 867 pMsg->msg_id = msg_id;
965 pMsg->arg = arg; 868 pMsg->arg = arg;
966 pMsg->error_code = error_code; 869 pMsg->error_code = error_code;
967 pMsg->block = pBlock; 870 pMsg->block = pBlock;
968 pMsg->next = NULL; 871 pMsg->next = NULL;
969 872
970 if(pClient->last_msg==NULL) 873 if (pClient->last_msg == NULL) {
971 { 874 pClient->first_msg = pClient->last_msg = pMsg;
972 pClient->first_msg=pClient->last_msg=pMsg; 875 } else {
973 } 876 pClient->last_msg->next = pMsg;
974 else 877 pClient->last_msg = pMsg;
975 { 878 }
976 pClient->last_msg->next = pMsg; 879
977 pClient->last_msg=pMsg; 880 pClient->msg_count++;
978 } 881
979 882 if (pBlock != NULL) {
980 pClient->msg_count++; 883 pBlock->locks++;
981 884 }
982 if(pBlock!=NULL) 885 spin_unlock_irqrestore(&pClient->lock, flags);
983 { 886 } else {
984 pBlock->locks++; 887 if ((pClient->last_msg->msg_id == R3964_MSG_ACK)
985 } 888 && (pClient->last_msg->error_code == R3964_OVERFLOW)) {
986 spin_unlock_irqrestore(&pClient->lock, flags); 889 pClient->last_msg->arg++;
987 } 890 TRACE_PE("add_msg - inc prev OVERFLOW-msg");
988 else 891 } else {
989 { 892 msg_id = R3964_MSG_ACK;
990 if((pClient->last_msg->msg_id == R3964_MSG_ACK) 893 arg = 0;
991 && (pClient->last_msg->error_code==R3964_OVERFLOW)) 894 error_code = R3964_OVERFLOW;
992 { 895 pBlock = NULL;
993 pClient->last_msg->arg++; 896 TRACE_PE("add_msg - queue OVERFLOW-msg");
994 TRACE_PE("add_msg - inc prev OVERFLOW-msg"); 897 goto queue_the_message;
995 } 898 }
996 else 899 }
997 { 900 /* Send SIGIO signal to client process: */
998 msg_id = R3964_MSG_ACK; 901 if (pClient->sig_flags & R3964_USE_SIGIO) {
999 arg = 0; 902 kill_pid(pClient->pid, SIGIO, 1);
1000 error_code = R3964_OVERFLOW; 903 }
1001 pBlock = NULL;
1002 TRACE_PE("add_msg - queue OVERFLOW-msg");
1003 goto queue_the_message;
1004 }
1005 }
1006 /* Send SIGIO signal to client process: */
1007 if(pClient->sig_flags & R3964_USE_SIGIO)
1008 {
1009 kill_pid(pClient->pid, SIGIO, 1);
1010 }
1011} 904}
1012 905
1013static struct r3964_message *remove_msg(struct r3964_info *pInfo, 906static struct r3964_message *remove_msg(struct r3964_info *pInfo,
1014 struct r3964_client_info *pClient) 907 struct r3964_client_info *pClient)
1015{ 908{
1016 struct r3964_message *pMsg=NULL; 909 struct r3964_message *pMsg = NULL;
1017 unsigned long flags; 910 unsigned long flags;
1018 911
1019 if(pClient->first_msg) 912 if (pClient->first_msg) {
1020 { 913 spin_lock_irqsave(&pClient->lock, flags);
1021 spin_lock_irqsave(&pClient->lock, flags); 914
1022 915 pMsg = pClient->first_msg;
1023 pMsg = pClient->first_msg; 916 pClient->first_msg = pMsg->next;
1024 pClient->first_msg = pMsg->next; 917 if (pClient->first_msg == NULL) {
1025 if(pClient->first_msg==NULL) 918 pClient->last_msg = NULL;
1026 { 919 }
1027 pClient->last_msg = NULL; 920
1028 } 921 pClient->msg_count--;
1029 922 if (pMsg->block) {
1030 pClient->msg_count--; 923 remove_client_block(pInfo, pClient);
1031 if(pMsg->block) 924 pClient->next_block_to_read = pMsg->block;
1032 { 925 }
1033 remove_client_block(pInfo, pClient); 926 spin_unlock_irqrestore(&pClient->lock, flags);
1034 pClient->next_block_to_read = pMsg->block; 927 }
1035 } 928 return pMsg;
1036 spin_unlock_irqrestore(&pClient->lock, flags);
1037 }
1038 return pMsg;
1039} 929}
1040 930
1041static void remove_client_block(struct r3964_info *pInfo, 931static void remove_client_block(struct r3964_info *pInfo,
1042 struct r3964_client_info *pClient) 932 struct r3964_client_info *pClient)
1043{ 933{
1044 struct r3964_block_header *block; 934 struct r3964_block_header *block;
1045 935
1046 TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid)); 936 TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
1047
1048 block=pClient->next_block_to_read;
1049 if(block)
1050 {
1051 block->locks--;
1052 if(block->locks==0)
1053 {
1054 remove_from_rx_queue(pInfo, block);
1055 }
1056 }
1057 pClient->next_block_to_read = NULL;
1058}
1059 937
938 block = pClient->next_block_to_read;
939 if (block) {
940 block->locks--;
941 if (block->locks == 0) {
942 remove_from_rx_queue(pInfo, block);
943 }
944 }
945 pClient->next_block_to_read = NULL;
946}
1060 947
1061/************************************************************* 948/*************************************************************
1062 * Line discipline routines 949 * Line discipline routines
@@ -1064,342 +951,320 @@ static void remove_client_block(struct r3964_info *pInfo,
1064 951
1065static int r3964_open(struct tty_struct *tty) 952static int r3964_open(struct tty_struct *tty)
1066{ 953{
1067 struct r3964_info *pInfo; 954 struct r3964_info *pInfo;
1068 955
1069 TRACE_L("open"); 956 TRACE_L("open");
1070 TRACE_L("tty=%p, PID=%d, disc_data=%p", 957 TRACE_L("tty=%p, PID=%d, disc_data=%p",
1071 tty, current->pid, tty->disc_data); 958 tty, current->pid, tty->disc_data);
1072 959
1073 pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); 960 pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
1074 TRACE_M("r3964_open - info kmalloc %p",pInfo); 961 TRACE_M("r3964_open - info kmalloc %p", pInfo);
1075 962
1076 if(!pInfo) 963 if (!pInfo) {
1077 { 964 printk(KERN_ERR "r3964: failed to alloc info structure\n");
1078 printk(KERN_ERR "r3964: failed to alloc info structure\n"); 965 return -ENOMEM;
1079 return -ENOMEM; 966 }
1080 } 967
1081 968 pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
1082 pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); 969 TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf);
1083 TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf); 970
1084 971 if (!pInfo->rx_buf) {
1085 if(!pInfo->rx_buf) 972 printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
1086 { 973 kfree(pInfo);
1087 printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); 974 TRACE_M("r3964_open - info kfree %p", pInfo);
1088 kfree(pInfo); 975 return -ENOMEM;
1089 TRACE_M("r3964_open - info kfree %p",pInfo); 976 }
1090 return -ENOMEM; 977
1091 } 978 pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
1092 979 TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf);
1093 pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); 980
1094 TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf); 981 if (!pInfo->tx_buf) {
1095 982 printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
1096 if(!pInfo->tx_buf) 983 kfree(pInfo->rx_buf);
1097 { 984 TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf);
1098 printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); 985 kfree(pInfo);
1099 kfree(pInfo->rx_buf); 986 TRACE_M("r3964_open - info kfree %p", pInfo);
1100 TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf); 987 return -ENOMEM;
1101 kfree(pInfo); 988 }
1102 TRACE_M("r3964_open - info kfree %p",pInfo); 989
1103 return -ENOMEM; 990 spin_lock_init(&pInfo->lock);
1104 } 991 pInfo->tty = tty;
1105 992 init_waitqueue_head(&pInfo->read_wait);
1106 spin_lock_init(&pInfo->lock); 993 pInfo->priority = R3964_MASTER;
1107 pInfo->tty = tty; 994 pInfo->rx_first = pInfo->rx_last = NULL;
1108 init_waitqueue_head (&pInfo->read_wait); 995 pInfo->tx_first = pInfo->tx_last = NULL;
1109 pInfo->priority = R3964_MASTER; 996 pInfo->rx_position = 0;
1110 pInfo->rx_first = pInfo->rx_last = NULL; 997 pInfo->tx_position = 0;
1111 pInfo->tx_first = pInfo->tx_last = NULL; 998 pInfo->last_rx = 0;
1112 pInfo->rx_position = 0; 999 pInfo->blocks_in_rx_queue = 0;
1113 pInfo->tx_position = 0; 1000 pInfo->firstClient = NULL;
1114 pInfo->last_rx = 0; 1001 pInfo->state = R3964_IDLE;
1115 pInfo->blocks_in_rx_queue = 0; 1002 pInfo->flags = R3964_DEBUG;
1116 pInfo->firstClient=NULL; 1003 pInfo->nRetry = 0;
1117 pInfo->state=R3964_IDLE; 1004
1118 pInfo->flags = R3964_DEBUG; 1005 tty->disc_data = pInfo;
1119 pInfo->nRetry = 0; 1006 tty->receive_room = 65536;
1120 1007
1121 tty->disc_data = pInfo; 1008 init_timer(&pInfo->tmr);
1122 tty->receive_room = 65536; 1009 pInfo->tmr.data = (unsigned long)pInfo;
1123 1010 pInfo->tmr.function = on_timeout;
1124 init_timer(&pInfo->tmr); 1011
1125 pInfo->tmr.data = (unsigned long)pInfo; 1012 return 0;
1126 pInfo->tmr.function = on_timeout;
1127
1128 return 0;
1129} 1013}
1130 1014
1131static void r3964_close(struct tty_struct *tty) 1015static void r3964_close(struct tty_struct *tty)
1132{ 1016{
1133 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1017 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1134 struct r3964_client_info *pClient, *pNext; 1018 struct r3964_client_info *pClient, *pNext;
1135 struct r3964_message *pMsg; 1019 struct r3964_message *pMsg;
1136 struct r3964_block_header *pHeader, *pNextHeader; 1020 struct r3964_block_header *pHeader, *pNextHeader;
1137 unsigned long flags; 1021 unsigned long flags;
1138 1022
1139 TRACE_L("close"); 1023 TRACE_L("close");
1140 1024
1141 /* 1025 /*
1142 * Make sure that our task queue isn't activated. If it 1026 * Make sure that our task queue isn't activated. If it
1143 * is, take it out of the linked list. 1027 * is, take it out of the linked list.
1144 */ 1028 */
1145 del_timer_sync(&pInfo->tmr); 1029 del_timer_sync(&pInfo->tmr);
1146 1030
1147 /* Remove client-structs and message queues: */ 1031 /* Remove client-structs and message queues: */
1148 pClient=pInfo->firstClient; 1032 pClient = pInfo->firstClient;
1149 while(pClient) 1033 while (pClient) {
1150 { 1034 pNext = pClient->next;
1151 pNext=pClient->next; 1035 while (pClient->msg_count) {
1152 while(pClient->msg_count) 1036 pMsg = remove_msg(pInfo, pClient);
1153 { 1037 if (pMsg) {
1154 pMsg=remove_msg(pInfo, pClient); 1038 kfree(pMsg);
1155 if(pMsg) 1039 TRACE_M("r3964_close - msg kfree %p", pMsg);
1156 { 1040 }
1157 kfree(pMsg); 1041 }
1158 TRACE_M("r3964_close - msg kfree %p",pMsg); 1042 put_pid(pClient->pid);
1159 } 1043 kfree(pClient);
1160 } 1044 TRACE_M("r3964_close - client kfree %p", pClient);
1161 put_pid(pClient->pid); 1045 pClient = pNext;
1162 kfree(pClient); 1046 }
1163 TRACE_M("r3964_close - client kfree %p",pClient); 1047 /* Remove jobs from tx_queue: */
1164 pClient=pNext; 1048 spin_lock_irqsave(&pInfo->lock, flags);
1165 } 1049 pHeader = pInfo->tx_first;
1166 /* Remove jobs from tx_queue: */ 1050 pInfo->tx_first = pInfo->tx_last = NULL;
1167 spin_lock_irqsave(&pInfo->lock, flags);
1168 pHeader=pInfo->tx_first;
1169 pInfo->tx_first=pInfo->tx_last=NULL;
1170 spin_unlock_irqrestore(&pInfo->lock, flags); 1051 spin_unlock_irqrestore(&pInfo->lock, flags);
1171 1052
1172 while(pHeader) 1053 while (pHeader) {
1173 { 1054 pNextHeader = pHeader->next;
1174 pNextHeader=pHeader->next; 1055 kfree(pHeader);
1175 kfree(pHeader); 1056 pHeader = pNextHeader;
1176 pHeader=pNextHeader;
1177 } 1057 }
1178 1058
1179 /* Free buffers: */ 1059 /* Free buffers: */
1180 wake_up_interruptible(&pInfo->read_wait); 1060 wake_up_interruptible(&pInfo->read_wait);
1181 kfree(pInfo->rx_buf); 1061 kfree(pInfo->rx_buf);
1182 TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf); 1062 TRACE_M("r3964_close - rx_buf kfree %p", pInfo->rx_buf);
1183 kfree(pInfo->tx_buf); 1063 kfree(pInfo->tx_buf);
1184 TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf); 1064 TRACE_M("r3964_close - tx_buf kfree %p", pInfo->tx_buf);
1185 kfree(pInfo); 1065 kfree(pInfo);
1186 TRACE_M("r3964_close - info kfree %p",pInfo); 1066 TRACE_M("r3964_close - info kfree %p", pInfo);
1187} 1067}
1188 1068
1189static ssize_t r3964_read(struct tty_struct *tty, struct file *file, 1069static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1190 unsigned char __user *buf, size_t nr) 1070 unsigned char __user * buf, size_t nr)
1191{ 1071{
1192 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1072 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1193 struct r3964_client_info *pClient; 1073 struct r3964_client_info *pClient;
1194 struct r3964_message *pMsg; 1074 struct r3964_message *pMsg;
1195 struct r3964_client_message theMsg; 1075 struct r3964_client_message theMsg;
1196 DECLARE_WAITQUEUE (wait, current); 1076 DECLARE_WAITQUEUE(wait, current);
1197 1077
1198 int count; 1078 int count;
1199 1079
1200 TRACE_L("read()"); 1080 TRACE_L("read()");
1201 1081
1202 pClient=findClient(pInfo, task_pid(current)); 1082 pClient = findClient(pInfo, task_pid(current));
1203 if(pClient) 1083 if (pClient) {
1204 { 1084 pMsg = remove_msg(pInfo, pClient);
1205 pMsg = remove_msg(pInfo, pClient); 1085 if (pMsg == NULL) {
1206 if(pMsg==NULL) 1086 /* no messages available. */
1207 { 1087 if (file->f_flags & O_NONBLOCK) {
1208 /* no messages available. */ 1088 return -EAGAIN;
1209 if (file->f_flags & O_NONBLOCK) 1089 }
1210 { 1090 /* block until there is a message: */
1211 return -EAGAIN; 1091 add_wait_queue(&pInfo->read_wait, &wait);
1212 }
1213 /* block until there is a message: */
1214 add_wait_queue(&pInfo->read_wait, &wait);
1215repeat: 1092repeat:
1216 current->state = TASK_INTERRUPTIBLE; 1093 current->state = TASK_INTERRUPTIBLE;
1217 pMsg = remove_msg(pInfo, pClient); 1094 pMsg = remove_msg(pInfo, pClient);
1218 if (!pMsg && !signal_pending(current)) 1095 if (!pMsg && !signal_pending(current)) {
1219 { 1096 schedule();
1220 schedule(); 1097 goto repeat;
1221 goto repeat; 1098 }
1222 } 1099 current->state = TASK_RUNNING;
1223 current->state = TASK_RUNNING; 1100 remove_wait_queue(&pInfo->read_wait, &wait);
1224 remove_wait_queue(&pInfo->read_wait, &wait); 1101 }
1225 } 1102
1226 1103 /* If we still haven't got a message, we must have been signalled */
1227 /* If we still haven't got a message, we must have been signalled */ 1104
1228 1105 if (!pMsg)
1229 if (!pMsg) return -EINTR; 1106 return -EINTR;
1230 1107
1231 /* deliver msg to client process: */ 1108 /* deliver msg to client process: */
1232 theMsg.msg_id = pMsg->msg_id; 1109 theMsg.msg_id = pMsg->msg_id;
1233 theMsg.arg = pMsg->arg; 1110 theMsg.arg = pMsg->arg;
1234 theMsg.error_code = pMsg->error_code; 1111 theMsg.error_code = pMsg->error_code;
1235 count = sizeof(struct r3964_client_message); 1112 count = sizeof(struct r3964_client_message);
1236 1113
1237 kfree(pMsg); 1114 kfree(pMsg);
1238 TRACE_M("r3964_read - msg kfree %p",pMsg); 1115 TRACE_M("r3964_read - msg kfree %p", pMsg);
1239 1116
1240 if (copy_to_user(buf,&theMsg, count)) 1117 if (copy_to_user(buf, &theMsg, count))
1241 return -EFAULT; 1118 return -EFAULT;
1242 1119
1243 TRACE_PS("read - return %d", count); 1120 TRACE_PS("read - return %d", count);
1244 return count; 1121 return count;
1245 } 1122 }
1246 return -EPERM; 1123 return -EPERM;
1247} 1124}
1248 1125
1249static ssize_t r3964_write(struct tty_struct * tty, struct file * file, 1126static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
1250 const unsigned char *data, size_t count) 1127 const unsigned char *data, size_t count)
1251{ 1128{
1252 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1129 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1253 struct r3964_block_header *pHeader; 1130 struct r3964_block_header *pHeader;
1254 struct r3964_client_info *pClient; 1131 struct r3964_client_info *pClient;
1255 unsigned char *new_data; 1132 unsigned char *new_data;
1256 1133
1257 TRACE_L("write request, %d characters", count); 1134 TRACE_L("write request, %d characters", count);
1258/* 1135/*
1259 * Verify the pointers 1136 * Verify the pointers
1260 */ 1137 */
1261 1138
1262 if(!pInfo) 1139 if (!pInfo)
1263 return -EIO; 1140 return -EIO;
1264 1141
1265/* 1142/*
1266 * Ensure that the caller does not wish to send too much. 1143 * Ensure that the caller does not wish to send too much.
1267 */ 1144 */
1268 if (count > R3964_MTU) 1145 if (count > R3964_MTU) {
1269 { 1146 if (pInfo->flags & R3964_DEBUG) {
1270 if (pInfo->flags & R3964_DEBUG) 1147 TRACE_L(KERN_WARNING "r3964_write: truncating user "
1271 { 1148 "packet from %u to mtu %d", count, R3964_MTU);
1272 TRACE_L (KERN_WARNING 1149 }
1273 "r3964_write: truncating user packet " 1150 count = R3964_MTU;
1274 "from %u to mtu %d", count, R3964_MTU); 1151 }
1275 }
1276 count = R3964_MTU;
1277 }
1278/* 1152/*
1279 * Allocate a buffer for the data and copy it from the buffer with header prepended 1153 * Allocate a buffer for the data and copy it from the buffer with header prepended
1280 */ 1154 */
1281 new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL); 1155 new_data = kmalloc(count + sizeof(struct r3964_block_header),
1282 TRACE_M("r3964_write - kmalloc %p",new_data); 1156 GFP_KERNEL);
1283 if (new_data == NULL) { 1157 TRACE_M("r3964_write - kmalloc %p", new_data);
1284 if (pInfo->flags & R3964_DEBUG) 1158 if (new_data == NULL) {
1285 { 1159 if (pInfo->flags & R3964_DEBUG) {
1286 printk (KERN_ERR 1160 printk(KERN_ERR "r3964_write: no memory\n");
1287 "r3964_write: no memory\n"); 1161 }
1288 } 1162 return -ENOSPC;
1289 return -ENOSPC; 1163 }
1290 } 1164
1291 1165 pHeader = (struct r3964_block_header *)new_data;
1292 pHeader = (struct r3964_block_header *)new_data; 1166 pHeader->data = new_data + sizeof(struct r3964_block_header);
1293 pHeader->data = new_data + sizeof(struct r3964_block_header); 1167 pHeader->length = count;
1294 pHeader->length = count; 1168 pHeader->locks = 0;
1295 pHeader->locks = 0; 1169 pHeader->owner = NULL;
1296 pHeader->owner = NULL; 1170
1297 1171 pClient = findClient(pInfo, task_pid(current));
1298 pClient=findClient(pInfo, task_pid(current)); 1172 if (pClient) {
1299 if(pClient) 1173 pHeader->owner = pClient;
1300 { 1174 }
1301 pHeader->owner = pClient; 1175
1302 } 1176 memcpy(pHeader->data, data, count); /* We already verified this */
1303 1177
1304 memcpy(pHeader->data, data, count); /* We already verified this */ 1178 if (pInfo->flags & R3964_DEBUG) {
1305 1179 dump_block(pHeader->data, count);
1306 if(pInfo->flags & R3964_DEBUG) 1180 }
1307 {
1308 dump_block(pHeader->data, count);
1309 }
1310 1181
1311/* 1182/*
1312 * Add buffer to transmit-queue: 1183 * Add buffer to transmit-queue:
1313 */ 1184 */
1314 add_tx_queue(pInfo, pHeader); 1185 add_tx_queue(pInfo, pHeader);
1315 trigger_transmit(pInfo); 1186 trigger_transmit(pInfo);
1316 1187
1317 return 0; 1188 return 0;
1318} 1189}
1319 1190
1320static int r3964_ioctl(struct tty_struct * tty, struct file * file, 1191static int r3964_ioctl(struct tty_struct *tty, struct file *file,
1321 unsigned int cmd, unsigned long arg) 1192 unsigned int cmd, unsigned long arg)
1322{ 1193{
1323 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1194 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1324 if(pInfo==NULL) 1195 if (pInfo == NULL)
1325 return -EINVAL; 1196 return -EINVAL;
1326 switch(cmd) 1197 switch (cmd) {
1327 { 1198 case R3964_ENABLE_SIGNALS:
1328 case R3964_ENABLE_SIGNALS: 1199 return enable_signals(pInfo, task_pid(current), arg);
1329 return enable_signals(pInfo, task_pid(current), arg); 1200 case R3964_SETPRIORITY:
1330 case R3964_SETPRIORITY: 1201 if (arg < R3964_MASTER || arg > R3964_SLAVE)
1331 if(arg<R3964_MASTER || arg>R3964_SLAVE) 1202 return -EINVAL;
1332 return -EINVAL; 1203 pInfo->priority = arg & 0xff;
1333 pInfo->priority = arg & 0xff; 1204 return 0;
1334 return 0; 1205 case R3964_USE_BCC:
1335 case R3964_USE_BCC: 1206 if (arg)
1336 if(arg) 1207 pInfo->flags |= R3964_BCC;
1337 pInfo->flags |= R3964_BCC; 1208 else
1338 else 1209 pInfo->flags &= ~R3964_BCC;
1339 pInfo->flags &= ~R3964_BCC; 1210 return 0;
1340 return 0; 1211 case R3964_READ_TELEGRAM:
1341 case R3964_READ_TELEGRAM: 1212 return read_telegram(pInfo, task_pid(current),
1342 return read_telegram(pInfo, task_pid(current), (unsigned char __user *)arg); 1213 (unsigned char __user *)arg);
1343 default: 1214 default:
1344 return -ENOIOCTLCMD; 1215 return -ENOIOCTLCMD;
1345 } 1216 }
1346} 1217}
1347 1218
1348static void r3964_set_termios(struct tty_struct *tty, struct ktermios * old) 1219static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old)
1349{ 1220{
1350 TRACE_L("set_termios"); 1221 TRACE_L("set_termios");
1351} 1222}
1352 1223
1353/* Called without the kernel lock held - fine */ 1224/* Called without the kernel lock held - fine */
1354static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, 1225static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
1355 struct poll_table_struct *wait) 1226 struct poll_table_struct *wait)
1356{ 1227{
1357 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1228 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1358 struct r3964_client_info *pClient; 1229 struct r3964_client_info *pClient;
1359 struct r3964_message *pMsg=NULL; 1230 struct r3964_message *pMsg = NULL;
1360 unsigned long flags; 1231 unsigned long flags;
1361 int result = POLLOUT; 1232 int result = POLLOUT;
1362 1233
1363 TRACE_L("POLL"); 1234 TRACE_L("POLL");
1364 1235
1365 pClient=findClient(pInfo, task_pid(current)); 1236 pClient = findClient(pInfo, task_pid(current));
1366 if(pClient) 1237 if (pClient) {
1367 { 1238 poll_wait(file, &pInfo->read_wait, wait);
1368 poll_wait(file, &pInfo->read_wait, wait); 1239 spin_lock_irqsave(&pInfo->lock, flags);
1369 spin_lock_irqsave(&pInfo->lock, flags); 1240 pMsg = pClient->first_msg;
1370 pMsg=pClient->first_msg; 1241 spin_unlock_irqrestore(&pInfo->lock, flags);
1371 spin_unlock_irqrestore(&pInfo->lock, flags); 1242 if (pMsg)
1372 if(pMsg) 1243 result |= POLLIN | POLLRDNORM;
1373 result |= POLLIN | POLLRDNORM; 1244 } else {
1374 } 1245 result = -EINVAL;
1375 else 1246 }
1376 { 1247 return result;
1377 result = -EINVAL;
1378 }
1379 return result;
1380} 1248}
1381 1249
1382static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1250static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1383 char *fp, int count) 1251 char *fp, int count)
1384{ 1252{
1385 struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; 1253 struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data;
1386 const unsigned char *p; 1254 const unsigned char *p;
1387 char *f, flags = 0; 1255 char *f, flags = 0;
1388 int i; 1256 int i;
1389 1257
1390 for (i=count, p = cp, f = fp; i; i--, p++) { 1258 for (i = count, p = cp, f = fp; i; i--, p++) {
1391 if (f) 1259 if (f)
1392 flags = *f++; 1260 flags = *f++;
1393 if(flags==TTY_NORMAL) 1261 if (flags == TTY_NORMAL) {
1394 { 1262 receive_char(pInfo, *p);
1395 receive_char(pInfo, *p); 1263 } else {
1396 } 1264 receive_error(pInfo, flags);
1397 else 1265 }
1398 { 1266
1399 receive_error(pInfo, flags); 1267 }
1400 }
1401
1402 }
1403} 1268}
1404 1269
1405MODULE_LICENSE("GPL"); 1270MODULE_LICENSE("GPL");
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index f108c136800a..4ab2c98f978c 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -887,10 +887,8 @@ static void bh_transmit(MGSLPC_INFO *info)
887 if (debug_level >= DEBUG_LEVEL_BH) 887 if (debug_level >= DEBUG_LEVEL_BH)
888 printk("bh_transmit() entry on %s\n", info->device_name); 888 printk("bh_transmit() entry on %s\n", info->device_name);
889 889
890 if (tty) { 890 if (tty)
891 tty_wakeup(tty); 891 tty_wakeup(tty);
892 wake_up_interruptible(&tty->write_wait);
893 }
894} 892}
895 893
896static void bh_status(MGSLPC_INFO *info) 894static void bh_status(MGSLPC_INFO *info)
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 645e20a06ece..1f0d7c60c944 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -154,7 +154,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
154 goto out; 154 goto out;
155 } 155 }
156 156
157 if (rq.raw_minor < 0 || rq.raw_minor >= MAX_RAW_MINORS) { 157 if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) {
158 err = -EINVAL; 158 err = -EINVAL;
159 goto out; 159 goto out;
160 } 160 }
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index eeda40c5e189..ebc76342712c 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -162,13 +162,8 @@ void RIOTxEnable(char *en)
162 162
163 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 163 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
164 164
165 if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN)) { 165 if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN))
166 rio_dprintk(RIO_DEBUG_INTR, "Waking up.... ldisc:%d (%d/%d)....", (int) (PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)), PortP->gs.wakeup_chars, PortP->gs.xmit_cnt); 166 tty_wakeup(PortP->gs.tty);
167 if ((PortP->gs.tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && PortP->gs.tty->ldisc.write_wakeup)
168 (PortP->gs.tty->ldisc.write_wakeup) (PortP->gs.tty);
169 rio_dprintk(RIO_DEBUG_INTR, "(%d/%d)\n", PortP->gs.wakeup_chars, PortP->gs.xmit_cnt);
170 wake_up_interruptible(&PortP->gs.tty->write_wait);
171 }
172 167
173} 168}
174 169
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index e2a94bfb2a43..70145254fb9d 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1229,7 +1229,6 @@ static void rc_flush_buffer(struct tty_struct *tty)
1229 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 1229 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1230 restore_flags(flags); 1230 restore_flags(flags);
1231 1231
1232 wake_up_interruptible(&tty->write_wait);
1233 tty_wakeup(tty); 1232 tty_wakeup(tty);
1234} 1233}
1235 1234
@@ -1570,10 +1569,8 @@ static void do_softint(struct work_struct *ugly_api)
1570 if(!(tty = port->tty)) 1569 if(!(tty = port->tty))
1571 return; 1570 return;
1572 1571
1573 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) { 1572 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
1574 tty_wakeup(tty); 1573 tty_wakeup(tty);
1575 wake_up_interruptible(&tty->write_wait);
1576 }
1577} 1574}
1578 1575
1579static const struct tty_operations riscom_ops = { 1576static const struct tty_operations riscom_ops = {
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index e94a62e30fc4..106f225e745f 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -474,7 +474,6 @@ static void rp_do_transmit(struct r_port *info)
474 474
475 if (info->xmit_cnt < WAKEUP_CHARS) { 475 if (info->xmit_cnt < WAKEUP_CHARS) {
476 tty_wakeup(tty); 476 tty_wakeup(tty);
477 wake_up_interruptible(&tty->write_wait);
478#ifdef ROCKETPORT_HAVE_POLL_WAIT 477#ifdef ROCKETPORT_HAVE_POLL_WAIT
479 wake_up_interruptible(&tty->poll_wait); 478 wake_up_interruptible(&tty->poll_wait);
480#endif 479#endif
@@ -1772,7 +1771,6 @@ static int rp_write(struct tty_struct *tty,
1772end: 1771end:
1773 if (info->xmit_cnt < WAKEUP_CHARS) { 1772 if (info->xmit_cnt < WAKEUP_CHARS) {
1774 tty_wakeup(tty); 1773 tty_wakeup(tty);
1775 wake_up_interruptible(&tty->write_wait);
1776#ifdef ROCKETPORT_HAVE_POLL_WAIT 1774#ifdef ROCKETPORT_HAVE_POLL_WAIT
1777 wake_up_interruptible(&tty->poll_wait); 1775 wake_up_interruptible(&tty->poll_wait);
1778#endif 1776#endif
@@ -1841,7 +1839,6 @@ static void rp_flush_buffer(struct tty_struct *tty)
1841 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1839 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1842 spin_unlock_irqrestore(&info->slock, flags); 1840 spin_unlock_irqrestore(&info->slock, flags);
1843 1841
1844 wake_up_interruptible(&tty->write_wait);
1845#ifdef ROCKETPORT_HAVE_POLL_WAIT 1842#ifdef ROCKETPORT_HAVE_POLL_WAIT
1846 wake_up_interruptible(&tty->poll_wait); 1843 wake_up_interruptible(&tty->poll_wait);
1847#endif 1844#endif
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index af50d32ae2c7..5fd314adc1f2 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -111,12 +111,13 @@ u_char initial_console_speed;
111 111
112/* This is the per-port data structure */ 112/* This is the per-port data structure */
113struct cyclades_port cy_port[] = { 113struct cyclades_port cy_port[] = {
114 /* CARD# */ 114 /* CARD# */
115 {-1 }, /* ttyS0 */ 115 {-1}, /* ttyS0 */
116 {-1 }, /* ttyS1 */ 116 {-1}, /* ttyS1 */
117 {-1 }, /* ttyS2 */ 117 {-1}, /* ttyS2 */
118 {-1 }, /* ttyS3 */ 118 {-1}, /* ttyS3 */
119}; 119};
120
120#define NR_PORTS ARRAY_SIZE(cy_port) 121#define NR_PORTS ARRAY_SIZE(cy_port)
121 122
122/* 123/*
@@ -128,42 +129,46 @@ struct cyclades_port cy_port[] = {
128 * HI VHI 129 * HI VHI
129 */ 130 */
130static int baud_table[] = { 131static int baud_table[] = {
131 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 132 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
132 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000, 133 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,
133 0}; 134 0
135};
134 136
135#if 0 137#if 0
136static char baud_co[] = { /* 25 MHz clock option table */ 138static char baud_co[] = { /* 25 MHz clock option table */
137 /* value => 00 01 02 03 04 */ 139 /* value => 00 01 02 03 04 */
138 /* divide by 8 32 128 512 2048 */ 140 /* divide by 8 32 128 512 2048 */
139 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 141 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
140 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 142 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
143};
141 144
142static char baud_bpr[] = { /* 25 MHz baud rate period table */ 145static char baud_bpr[] = { /* 25 MHz baud rate period table */
143 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, 146 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
144 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15}; 147 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15
148};
145#endif 149#endif
146 150
147/* I think 166 brd clocks 2401 at 20MHz.... */ 151/* I think 166 brd clocks 2401 at 20MHz.... */
148 152
149/* These values are written directly to tcor, and >> 5 for writing to rcor */ 153/* These values are written directly to tcor, and >> 5 for writing to rcor */
150static u_char baud_co[] = { /* 20 MHz clock option table */ 154static u_char baud_co[] = { /* 20 MHz clock option table */
151 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40, 155 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x40,
152 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 156 0x40, 0x40, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
157};
153 158
154/* These values written directly to tbpr/rbpr */ 159/* These values written directly to tbpr/rbpr */
155static u_char baud_bpr[] = { /* 20 MHz baud rate period table */ 160static u_char baud_bpr[] = { /* 20 MHz baud rate period table */
156 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81, 161 0x00, 0xc0, 0x80, 0x58, 0x6c, 0x40, 0xc0, 0x81, 0x40, 0x81,
157 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10}; 162 0x57, 0x40, 0x81, 0x40, 0x81, 0x40, 0x2b, 0x20, 0x15, 0x10
158 163};
159static u_char baud_cor4[] = { /* receive threshold */
160 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
161 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07};
162
163 164
165static u_char baud_cor4[] = { /* receive threshold */
166 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
167 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07
168};
164 169
165static void shutdown(struct cyclades_port *); 170static void shutdown(struct cyclades_port *);
166static int startup (struct cyclades_port *); 171static int startup(struct cyclades_port *);
167static void cy_throttle(struct tty_struct *); 172static void cy_throttle(struct tty_struct *);
168static void cy_unthrottle(struct tty_struct *); 173static void cy_unthrottle(struct tty_struct *);
169static void config_setup(struct cyclades_port *); 174static void config_setup(struct cyclades_port *);
@@ -174,16 +179,16 @@ static void show_status(int);
174 179
175#ifdef CONFIG_REMOTE_DEBUG 180#ifdef CONFIG_REMOTE_DEBUG
176static void debug_setup(void); 181static void debug_setup(void);
177void queueDebugChar (int c); 182void queueDebugChar(int c);
178int getDebugChar(void); 183int getDebugChar(void);
179 184
180#define DEBUG_PORT 1 185#define DEBUG_PORT 1
181#define DEBUG_LEN 256 186#define DEBUG_LEN 256
182 187
183typedef struct { 188typedef struct {
184 int in; 189 int in;
185 int out; 190 int out;
186 unsigned char buf[DEBUG_LEN]; 191 unsigned char buf[DEBUG_LEN];
187} debugq; 192} debugq;
188 193
189debugq debugiq; 194debugq debugiq;
@@ -196,7 +201,7 @@ debugq debugiq;
196 * delay, but this wild guess will do for now. 201 * delay, but this wild guess will do for now.
197 */ 202 */
198 203
199void my_udelay (long us) 204void my_udelay(long us)
200{ 205{
201 u_char x; 206 u_char x;
202 volatile u_char *p = &x; 207 volatile u_char *p = &x;
@@ -207,62 +212,73 @@ void my_udelay (long us)
207 x |= *p; 212 x |= *p;
208} 213}
209 214
210static inline int 215static inline int serial_paranoia_check(struct cyclades_port *info, char *name,
211serial_paranoia_check(struct cyclades_port *info, char *name, 216 const char *routine)
212 const char *routine)
213{ 217{
214#ifdef SERIAL_PARANOIA_CHECK 218#ifdef SERIAL_PARANOIA_CHECK
215 static const char *badmagic = 219 if (!info) {
216 "Warning: bad magic number for serial struct (%s) in %s\n"; 220 printk("Warning: null cyclades_port for (%s) in %s\n", name,
217 static const char *badinfo = 221 routine);
218 "Warning: null cyclades_port for (%s) in %s\n"; 222 return 1;
219 static const char *badrange = 223 }
220 "Warning: cyclades_port out of range for (%s) in %s\n"; 224
221 225 if ((long)info < (long)(&cy_port[0])
222 if (!info) { 226 || (long)(&cy_port[NR_PORTS]) < (long)info) {
223 printk(badinfo, name, routine); 227 printk("Warning: cyclades_port out of range for (%s) in %s\n",
224 return 1; 228 name, routine);
225 } 229 return 1;
226 230 }
227 if( (long)info < (long)(&cy_port[0]) 231
228 || (long)(&cy_port[NR_PORTS]) < (long)info ){ 232 if (info->magic != CYCLADES_MAGIC) {
229 printk(badrange, name, routine); 233 printk("Warning: bad magic number for serial struct (%s) in "
230 return 1; 234 "%s\n", name, routine);
231 } 235 return 1;
232 236 }
233 if (info->magic != CYCLADES_MAGIC) {
234 printk(badmagic, name, routine);
235 return 1;
236 }
237#endif 237#endif
238 return 0; 238 return 0;
239} /* serial_paranoia_check */ 239} /* serial_paranoia_check */
240 240
241#if 0 241#if 0
242/* The following diagnostic routines allow the driver to spew 242/* The following diagnostic routines allow the driver to spew
243 information on the screen, even (especially!) during interrupts. 243 information on the screen, even (especially!) during interrupts.
244 */ 244 */
245void 245void SP(char *data)
246SP(char *data){ 246{
247 unsigned long flags; 247 unsigned long flags;
248 local_irq_save(flags); 248 local_irq_save(flags);
249 console_print(data); 249 console_print(data);
250 local_irq_restore(flags); 250 local_irq_restore(flags);
251} 251}
252
252char scrn[2]; 253char scrn[2];
253void 254void CP(char data)
254CP(char data){ 255{
255 unsigned long flags; 256 unsigned long flags;
256 local_irq_save(flags); 257 local_irq_save(flags);
257 scrn[0] = data; 258 scrn[0] = data;
258 console_print(scrn); 259 console_print(scrn);
259 local_irq_restore(flags); 260 local_irq_restore(flags);
260}/* CP */ 261} /* CP */
261 262
262void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }/* CP1 */ 263void CP1(int data)
263void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */ 264{
264void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */ 265 (data < 10) ? CP(data + '0') : CP(data + 'A' - 10);
265void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */ 266} /* CP1 */
267void CP2(int data)
268{
269 CP1((data >> 4) & 0x0f);
270 CP1(data & 0x0f);
271} /* CP2 */
272void CP4(int data)
273{
274 CP2((data >> 8) & 0xff);
275 CP2(data & 0xff);
276} /* CP4 */
277void CP8(long data)
278{
279 CP4((data >> 16) & 0xffff);
280 CP4(data & 0xffff);
281} /* CP8 */
266#endif 282#endif
267 283
268/* This routine waits up to 1000 micro-seconds for the previous 284/* This routine waits up to 1000 micro-seconds for the previous
@@ -270,87 +286,78 @@ void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
270 new command. An error is returned if the previous command 286 new command. An error is returned if the previous command
271 didn't finish within the time limit. 287 didn't finish within the time limit.
272 */ 288 */
273u_short 289u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd)
274write_cy_cmd(volatile u_char *base_addr, u_char cmd)
275{ 290{
276 unsigned long flags; 291 unsigned long flags;
277 volatile int i; 292 volatile int i;
278 293
279 local_irq_save(flags); 294 local_irq_save(flags);
280 /* Check to see that the previous command has completed */ 295 /* Check to see that the previous command has completed */
281 for(i = 0 ; i < 100 ; i++){ 296 for (i = 0; i < 100; i++) {
282 if (base_addr[CyCCR] == 0){ 297 if (base_addr[CyCCR] == 0) {
283 break; 298 break;
284 } 299 }
285 my_udelay(10L); 300 my_udelay(10L);
286 } 301 }
287 /* if the CCR never cleared, the previous command 302 /* if the CCR never cleared, the previous command
288 didn't finish within the "reasonable time" */ 303 didn't finish within the "reasonable time" */
289 if ( i == 10 ) { 304 if (i == 10) {
290 local_irq_restore(flags); 305 local_irq_restore(flags);
291 return (-1); 306 return (-1);
292 } 307 }
293 308
294 /* Issue the new command */ 309 /* Issue the new command */
295 base_addr[CyCCR] = cmd; 310 base_addr[CyCCR] = cmd;
296 local_irq_restore(flags); 311 local_irq_restore(flags);
297 return(0); 312 return (0);
298} /* write_cy_cmd */ 313} /* write_cy_cmd */
299
300 314
301/* cy_start and cy_stop provide software output flow control as a 315/* cy_start and cy_stop provide software output flow control as a
302 function of XON/XOFF, software CTS, and other such stuff. */ 316 function of XON/XOFF, software CTS, and other such stuff. */
303 317
304static void 318static void cy_stop(struct tty_struct *tty)
305cy_stop(struct tty_struct *tty)
306{ 319{
307 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 320 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
308 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 321 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
309 int channel; 322 int channel;
310 unsigned long flags; 323 unsigned long flags;
311 324
312#ifdef SERIAL_DEBUG_OTHER 325#ifdef SERIAL_DEBUG_OTHER
313 printk("cy_stop %s\n", tty->name); /* */ 326 printk("cy_stop %s\n", tty->name); /* */
314#endif 327#endif
315 328
316 if (serial_paranoia_check(info, tty->name, "cy_stop")) 329 if (serial_paranoia_check(info, tty->name, "cy_stop"))
317 return; 330 return;
318
319 channel = info->line;
320 331
321 local_irq_save(flags); 332 channel = info->line;
322 base_addr[CyCAR] = (u_char)(channel); /* index channel */
323 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
324 local_irq_restore(flags);
325 333
326 return; 334 local_irq_save(flags);
327} /* cy_stop */ 335 base_addr[CyCAR] = (u_char) (channel); /* index channel */
336 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
337 local_irq_restore(flags);
338} /* cy_stop */
328 339
329static void 340static void cy_start(struct tty_struct *tty)
330cy_start(struct tty_struct *tty)
331{ 341{
332 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 342 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
333 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 343 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
334 int channel; 344 int channel;
335 unsigned long flags; 345 unsigned long flags;
336 346
337#ifdef SERIAL_DEBUG_OTHER 347#ifdef SERIAL_DEBUG_OTHER
338 printk("cy_start %s\n", tty->name); /* */ 348 printk("cy_start %s\n", tty->name); /* */
339#endif 349#endif
340 350
341 if (serial_paranoia_check(info, tty->name, "cy_start")) 351 if (serial_paranoia_check(info, tty->name, "cy_start"))
342 return; 352 return;
343
344 channel = info->line;
345 353
346 local_irq_save(flags); 354 channel = info->line;
347 base_addr[CyCAR] = (u_char)(channel);
348 base_addr[CyIER] |= CyTxMpty;
349 local_irq_restore(flags);
350
351 return;
352} /* cy_start */
353 355
356 local_irq_save(flags);
357 base_addr[CyCAR] = (u_char) (channel);
358 base_addr[CyIER] |= CyTxMpty;
359 local_irq_restore(flags);
360} /* cy_start */
354 361
355/* 362/*
356 * This routine is used by the interrupt handler to schedule 363 * This routine is used by the interrupt handler to schedule
@@ -358,332 +365,332 @@ cy_start(struct tty_struct *tty)
358 * (also known as the "bottom half"). This can be called any 365 * (also known as the "bottom half"). This can be called any
359 * number of times for any channel without harm. 366 * number of times for any channel without harm.
360 */ 367 */
361static inline void 368static inline void cy_sched_event(struct cyclades_port *info, int event)
362cy_sched_event(struct cyclades_port *info, int event)
363{ 369{
364 info->event |= 1 << event; /* remember what kind of event and who */ 370 info->event |= 1 << event; /* remember what kind of event and who */
365 schedule_work(&info->tqueue); 371 schedule_work(&info->tqueue);
366} /* cy_sched_event */ 372} /* cy_sched_event */
367
368 373
369/* The real interrupt service routines are called 374/* The real interrupt service routines are called
370 whenever the card wants its hand held--chars 375 whenever the card wants its hand held--chars
371 received, out buffer empty, modem change, etc. 376 received, out buffer empty, modem change, etc.
372 */ 377 */
373static irqreturn_t 378static irqreturn_t cd2401_rxerr_interrupt(int irq, void *dev_id)
374cd2401_rxerr_interrupt(int irq, void *dev_id)
375{ 379{
376 struct tty_struct *tty; 380 struct tty_struct *tty;
377 struct cyclades_port *info; 381 struct cyclades_port *info;
378 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 382 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
379 unsigned char err, rfoc; 383 unsigned char err, rfoc;
380 int channel; 384 int channel;
381 char data; 385 char data;
382 386
383 /* determine the channel and change to that context */ 387 /* determine the channel and change to that context */
384 channel = (u_short ) (base_addr[CyLICR] >> 2); 388 channel = (u_short) (base_addr[CyLICR] >> 2);
385 info = &cy_port[channel]; 389 info = &cy_port[channel];
386 info->last_active = jiffies; 390 info->last_active = jiffies;
387 391
388 if ((err = base_addr[CyRISR]) & CyTIMEOUT) { 392 if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
389 /* This is a receive timeout interrupt, ignore it */ 393 /* This is a receive timeout interrupt, ignore it */
390 base_addr[CyREOIR] = CyNOTRANS; 394 base_addr[CyREOIR] = CyNOTRANS;
391 return IRQ_HANDLED; 395 return IRQ_HANDLED;
392 } 396 }
393
394 /* Read a byte of data if there is any - assume the error
395 * is associated with this character */
396 397
397 if ((rfoc = base_addr[CyRFOC]) != 0) 398 /* Read a byte of data if there is any - assume the error
398 data = base_addr[CyRDR]; 399 * is associated with this character */
399 else
400 data = 0;
401 400
402 /* if there is nowhere to put the data, discard it */ 401 if ((rfoc = base_addr[CyRFOC]) != 0)
403 if(info->tty == 0) { 402 data = base_addr[CyRDR];
403 else
404 data = 0;
405
406 /* if there is nowhere to put the data, discard it */
407 if (info->tty == 0) {
408 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
409 return IRQ_HANDLED;
410 } else { /* there is an open port for this data */
411 tty = info->tty;
412 if (err & info->ignore_status_mask) {
413 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
414 return IRQ_HANDLED;
415 }
416 if (tty_buffer_request_room(tty, 1) != 0) {
417 if (err & info->read_status_mask) {
418 if (err & CyBREAK) {
419 tty_insert_flip_char(tty, data,
420 TTY_BREAK);
421 if (info->flags & ASYNC_SAK) {
422 do_SAK(tty);
423 }
424 } else if (err & CyFRAME) {
425 tty_insert_flip_char(tty, data,
426 TTY_FRAME);
427 } else if (err & CyPARITY) {
428 tty_insert_flip_char(tty, data,
429 TTY_PARITY);
430 } else if (err & CyOVERRUN) {
431 tty_insert_flip_char(tty, 0,
432 TTY_OVERRUN);
433 /*
434 If the flip buffer itself is
435 overflowing, we still loose
436 the next incoming character.
437 */
438 if (tty_buffer_request_room(tty, 1) !=
439 0) {
440 tty_insert_flip_char(tty, data,
441 TTY_FRAME);
442 }
443 /* These two conditions may imply */
444 /* a normal read should be done. */
445 /* else if(data & CyTIMEOUT) */
446 /* else if(data & CySPECHAR) */
447 } else {
448 tty_insert_flip_char(tty, 0,
449 TTY_NORMAL);
450 }
451 } else {
452 tty_insert_flip_char(tty, data, TTY_NORMAL);
453 }
454 } else {
455 /* there was a software buffer overrun
456 and nothing could be done about it!!! */
457 }
458 }
459 tty_schedule_flip(tty);
460 /* end of service */
404 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS; 461 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
405 return IRQ_HANDLED; 462 return IRQ_HANDLED;
406 } 463} /* cy_rxerr_interrupt */
407 else { /* there is an open port for this data */ 464
408 tty = info->tty; 465static irqreturn_t cd2401_modem_interrupt(int irq, void *dev_id)
409 if(err & info->ignore_status_mask){
410 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
411 return IRQ_HANDLED;
412 }
413 if (tty_buffer_request_room(tty, 1) != 0){
414 if (err & info->read_status_mask){
415 if(err & CyBREAK){
416 tty_insert_flip_char(tty, data, TTY_BREAK);
417 if (info->flags & ASYNC_SAK){
418 do_SAK(tty);
419 }
420 }else if(err & CyFRAME){
421 tty_insert_flip_char(tty, data, TTY_FRAME);
422 }else if(err & CyPARITY){
423 tty_insert_flip_char(tty, data, TTY_PARITY);
424 }else if(err & CyOVERRUN){
425 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
426 /*
427 If the flip buffer itself is
428 overflowing, we still loose
429 the next incoming character.
430 */
431 if (tty_buffer_request_room(tty, 1) != 0){
432 tty_insert_flip_char(tty, data, TTY_FRAME);
433 }
434 /* These two conditions may imply */
435 /* a normal read should be done. */
436 /* else if(data & CyTIMEOUT) */
437 /* else if(data & CySPECHAR) */
438 }else{
439 tty_insert_flip_char(tty, 0, TTY_NORMAL);
440 }
441 }else{
442 tty_insert_flip_char(tty, data, TTY_NORMAL);
443 }
444 }else{
445 /* there was a software buffer overrun
446 and nothing could be done about it!!! */
447 }
448 }
449 tty_schedule_flip(tty);
450 /* end of service */
451 base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
452 return IRQ_HANDLED;
453} /* cy_rxerr_interrupt */
454
455static irqreturn_t
456cd2401_modem_interrupt(int irq, void *dev_id)
457{ 466{
458 struct cyclades_port *info; 467 struct cyclades_port *info;
459 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 468 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
460 int channel; 469 int channel;
461 int mdm_change; 470 int mdm_change;
462 int mdm_status; 471 int mdm_status;
463 472
464 473 /* determine the channel and change to that context */
465 /* determine the channel and change to that context */ 474 channel = (u_short) (base_addr[CyLICR] >> 2);
466 channel = (u_short ) (base_addr[CyLICR] >> 2); 475 info = &cy_port[channel];
467 info = &cy_port[channel]; 476 info->last_active = jiffies;
468 info->last_active = jiffies; 477
469 478 mdm_change = base_addr[CyMISR];
470 mdm_change = base_addr[CyMISR]; 479 mdm_status = base_addr[CyMSVR1];
471 mdm_status = base_addr[CyMSVR1]; 480
472 481 if (info->tty == 0) { /* nowhere to put the data, ignore it */
473 if(info->tty == 0){ /* nowhere to put the data, ignore it */ 482 ;
474 ; 483 } else {
475 }else{ 484 if ((mdm_change & CyDCD)
476 if((mdm_change & CyDCD) 485 && (info->flags & ASYNC_CHECK_CD)) {
477 && (info->flags & ASYNC_CHECK_CD)){ 486 if (mdm_status & CyDCD) {
478 if(mdm_status & CyDCD){
479/* CP('!'); */ 487/* CP('!'); */
480 cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); 488 cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
481 } else { 489 } else {
482/* CP('@'); */ 490/* CP('@'); */
483 cy_sched_event(info, Cy_EVENT_HANGUP); 491 cy_sched_event(info, Cy_EVENT_HANGUP);
484 } 492 }
485 }
486 if((mdm_change & CyCTS)
487 && (info->flags & ASYNC_CTS_FLOW)){
488 if(info->tty->stopped){
489 if(mdm_status & CyCTS){
490 /* !!! cy_start isn't used because... */
491 info->tty->stopped = 0;
492 base_addr[CyIER] |= CyTxMpty;
493 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
494 } 493 }
495 }else{ 494 if ((mdm_change & CyCTS)
496 if(!(mdm_status & CyCTS)){ 495 && (info->flags & ASYNC_CTS_FLOW)) {
497 /* !!! cy_stop isn't used because... */ 496 if (info->tty->stopped) {
498 info->tty->stopped = 1; 497 if (mdm_status & CyCTS) {
499 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 498 /* !!! cy_start isn't used because... */
499 info->tty->stopped = 0;
500 base_addr[CyIER] |= CyTxMpty;
501 cy_sched_event(info,
502 Cy_EVENT_WRITE_WAKEUP);
503 }
504 } else {
505 if (!(mdm_status & CyCTS)) {
506 /* !!! cy_stop isn't used because... */
507 info->tty->stopped = 1;
508 base_addr[CyIER] &=
509 ~(CyTxMpty | CyTxRdy);
510 }
511 }
512 }
513 if (mdm_status & CyDSR) {
500 } 514 }
501 }
502 }
503 if(mdm_status & CyDSR){
504 } 515 }
505 } 516 base_addr[CyMEOIR] = 0;
506 base_addr[CyMEOIR] = 0; 517 return IRQ_HANDLED;
507 return IRQ_HANDLED; 518} /* cy_modem_interrupt */
508} /* cy_modem_interrupt */
509 519
510static irqreturn_t 520static irqreturn_t cd2401_tx_interrupt(int irq, void *dev_id)
511cd2401_tx_interrupt(int irq, void *dev_id)
512{ 521{
513 struct cyclades_port *info; 522 struct cyclades_port *info;
514 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 523 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
515 int channel; 524 int channel;
516 int char_count, saved_cnt; 525 int char_count, saved_cnt;
517 int outch; 526 int outch;
518 527
519 /* determine the channel and change to that context */ 528 /* determine the channel and change to that context */
520 channel = (u_short ) (base_addr[CyLICR] >> 2); 529 channel = (u_short) (base_addr[CyLICR] >> 2);
521 530
522#ifdef CONFIG_REMOTE_DEBUG 531#ifdef CONFIG_REMOTE_DEBUG
523 if (channel == DEBUG_PORT) { 532 if (channel == DEBUG_PORT) {
524 panic ("TxInt on debug port!!!"); 533 panic("TxInt on debug port!!!");
525 } 534 }
526#endif 535#endif
527 536
528 info = &cy_port[channel]; 537 info = &cy_port[channel];
529 538
530 /* validate the port number (as configured and open) */ 539 /* validate the port number (as configured and open) */
531 if( (channel < 0) || (NR_PORTS <= channel) ){ 540 if ((channel < 0) || (NR_PORTS <= channel)) {
532 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 541 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
533 base_addr[CyTEOIR] = CyNOTRANS; 542 base_addr[CyTEOIR] = CyNOTRANS;
534 return IRQ_HANDLED; 543 return IRQ_HANDLED;
535 } 544 }
536 info->last_active = jiffies; 545 info->last_active = jiffies;
537 if(info->tty == 0){ 546 if (info->tty == 0) {
538 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy); 547 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
539 if (info->xmit_cnt < WAKEUP_CHARS) { 548 if (info->xmit_cnt < WAKEUP_CHARS) {
540 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 549 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
541 } 550 }
542 base_addr[CyTEOIR] = CyNOTRANS; 551 base_addr[CyTEOIR] = CyNOTRANS;
543 return IRQ_HANDLED; 552 return IRQ_HANDLED;
544 } 553 }
545 554
546 /* load the on-chip space available for outbound data */ 555 /* load the on-chip space available for outbound data */
547 saved_cnt = char_count = base_addr[CyTFTC]; 556 saved_cnt = char_count = base_addr[CyTFTC];
548 557
549 if(info->x_char) { /* send special char */ 558 if (info->x_char) { /* send special char */
550 outch = info->x_char; 559 outch = info->x_char;
551 base_addr[CyTDR] = outch;
552 char_count--;
553 info->x_char = 0;
554 }
555
556 if (info->x_break){
557 /* The Cirrus chip requires the "Embedded Transmit
558 Commands" of start break, delay, and end break
559 sequences to be sent. The duration of the
560 break is given in TICs, which runs at HZ
561 (typically 100) and the PPR runs at 200 Hz,
562 so the delay is duration * 200/HZ, and thus a
563 break can run from 1/100 sec to about 5/4 sec.
564 Need to check these values - RGH 141095.
565 */
566 base_addr[CyTDR] = 0; /* start break */
567 base_addr[CyTDR] = 0x81;
568 base_addr[CyTDR] = 0; /* delay a bit */
569 base_addr[CyTDR] = 0x82;
570 base_addr[CyTDR] = info->x_break*200/HZ;
571 base_addr[CyTDR] = 0; /* terminate break */
572 base_addr[CyTDR] = 0x83;
573 char_count -= 7;
574 info->x_break = 0;
575 }
576
577 while (char_count > 0){
578 if (!info->xmit_cnt){
579 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
580 break;
581 }
582 if (info->xmit_buf == 0){
583 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
584 break;
585 }
586 if (info->tty->stopped || info->tty->hw_stopped){
587 base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
588 break;
589 }
590 /* Because the Embedded Transmit Commands have been
591 enabled, we must check to see if the escape
592 character, NULL, is being sent. If it is, we
593 must ensure that there is room for it to be
594 doubled in the output stream. Therefore we
595 no longer advance the pointer when the character
596 is fetched, but rather wait until after the check
597 for a NULL output character. (This is necessary
598 because there may not be room for the two chars
599 needed to send a NULL.
600 */
601 outch = info->xmit_buf[info->xmit_tail];
602 if( outch ){
603 info->xmit_cnt--;
604 info->xmit_tail = (info->xmit_tail + 1)
605 & (PAGE_SIZE - 1);
606 base_addr[CyTDR] = outch;
607 char_count--;
608 }else{
609 if(char_count > 1){
610 info->xmit_cnt--;
611 info->xmit_tail = (info->xmit_tail + 1)
612 & (PAGE_SIZE - 1);
613 base_addr[CyTDR] = outch; 560 base_addr[CyTDR] = outch;
614 base_addr[CyTDR] = 0;
615 char_count--; 561 char_count--;
616 char_count--; 562 info->x_char = 0;
617 }else{
618 break;
619 }
620 } 563 }
621 }
622 564
623 if (info->xmit_cnt < WAKEUP_CHARS) { 565 if (info->x_break) {
624 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); 566 /* The Cirrus chip requires the "Embedded Transmit
625 } 567 Commands" of start break, delay, and end break
626 base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS; 568 sequences to be sent. The duration of the
627 return IRQ_HANDLED; 569 break is given in TICs, which runs at HZ
628} /* cy_tx_interrupt */ 570 (typically 100) and the PPR runs at 200 Hz,
571 so the delay is duration * 200/HZ, and thus a
572 break can run from 1/100 sec to about 5/4 sec.
573 Need to check these values - RGH 141095.
574 */
575 base_addr[CyTDR] = 0; /* start break */
576 base_addr[CyTDR] = 0x81;
577 base_addr[CyTDR] = 0; /* delay a bit */
578 base_addr[CyTDR] = 0x82;
579 base_addr[CyTDR] = info->x_break * 200 / HZ;
580 base_addr[CyTDR] = 0; /* terminate break */
581 base_addr[CyTDR] = 0x83;
582 char_count -= 7;
583 info->x_break = 0;
584 }
585
586 while (char_count > 0) {
587 if (!info->xmit_cnt) {
588 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
589 break;
590 }
591 if (info->xmit_buf == 0) {
592 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
593 break;
594 }
595 if (info->tty->stopped || info->tty->hw_stopped) {
596 base_addr[CyIER] &= ~(CyTxMpty | CyTxRdy);
597 break;
598 }
599 /* Because the Embedded Transmit Commands have been
600 enabled, we must check to see if the escape
601 character, NULL, is being sent. If it is, we
602 must ensure that there is room for it to be
603 doubled in the output stream. Therefore we
604 no longer advance the pointer when the character
605 is fetched, but rather wait until after the check
606 for a NULL output character. (This is necessary
607 because there may not be room for the two chars
608 needed to send a NULL.
609 */
610 outch = info->xmit_buf[info->xmit_tail];
611 if (outch) {
612 info->xmit_cnt--;
613 info->xmit_tail = (info->xmit_tail + 1)
614 & (PAGE_SIZE - 1);
615 base_addr[CyTDR] = outch;
616 char_count--;
617 } else {
618 if (char_count > 1) {
619 info->xmit_cnt--;
620 info->xmit_tail = (info->xmit_tail + 1)
621 & (PAGE_SIZE - 1);
622 base_addr[CyTDR] = outch;
623 base_addr[CyTDR] = 0;
624 char_count--;
625 char_count--;
626 } else {
627 break;
628 }
629 }
630 }
631
632 if (info->xmit_cnt < WAKEUP_CHARS) {
633 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
634 }
635 base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
636 return IRQ_HANDLED;
637} /* cy_tx_interrupt */
629 638
630static irqreturn_t 639static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id)
631cd2401_rx_interrupt(int irq, void *dev_id)
632{ 640{
633 struct tty_struct *tty; 641 struct tty_struct *tty;
634 struct cyclades_port *info; 642 struct cyclades_port *info;
635 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 643 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
636 int channel; 644 int channel;
637 char data; 645 char data;
638 int char_count; 646 int char_count;
639 int save_cnt; 647 int save_cnt;
640 int len; 648 int len;
641 649
642 /* determine the channel and change to that context */ 650 /* determine the channel and change to that context */
643 channel = (u_short ) (base_addr[CyLICR] >> 2); 651 channel = (u_short) (base_addr[CyLICR] >> 2);
644 info = &cy_port[channel]; 652 info = &cy_port[channel];
645 info->last_active = jiffies; 653 info->last_active = jiffies;
646 save_cnt = char_count = base_addr[CyRFOC]; 654 save_cnt = char_count = base_addr[CyRFOC];
647 655
648#ifdef CONFIG_REMOTE_DEBUG 656#ifdef CONFIG_REMOTE_DEBUG
649 if (channel == DEBUG_PORT) { 657 if (channel == DEBUG_PORT) {
650 while (char_count--) { 658 while (char_count--) {
651 data = base_addr[CyRDR]; 659 data = base_addr[CyRDR];
652 queueDebugChar(data); 660 queueDebugChar(data);
653 } 661 }
654 } 662 } else
655 else
656#endif 663#endif
657 /* if there is nowhere to put the data, discard it */ 664 /* if there is nowhere to put the data, discard it */
658 if(info->tty == 0){ 665 if (info->tty == 0) {
659 while(char_count--){ 666 while (char_count--) {
660 data = base_addr[CyRDR]; 667 data = base_addr[CyRDR];
661 } 668 }
662 }else{ /* there is an open port for this data */ 669 } else { /* there is an open port for this data */
663 tty = info->tty; 670 tty = info->tty;
664 /* load # characters available from the chip */ 671 /* load # characters available from the chip */
665 672
666#ifdef CYCLOM_ENABLE_MONITORING 673#ifdef CYCLOM_ENABLE_MONITORING
667 ++info->mon.int_count; 674 ++info->mon.int_count;
668 info->mon.char_count += char_count; 675 info->mon.char_count += char_count;
669 if (char_count > info->mon.char_max) 676 if (char_count > info->mon.char_max)
670 info->mon.char_max = char_count; 677 info->mon.char_max = char_count;
671 info->mon.char_last = char_count; 678 info->mon.char_last = char_count;
672#endif 679#endif
673 len = tty_buffer_request_room(tty, char_count); 680 len = tty_buffer_request_room(tty, char_count);
674 while(len--){ 681 while (len--) {
675 data = base_addr[CyRDR]; 682 data = base_addr[CyRDR];
676 tty_insert_flip_char(tty, data, TTY_NORMAL); 683 tty_insert_flip_char(tty, data, TTY_NORMAL);
677#ifdef CYCLOM_16Y_HACK 684#ifdef CYCLOM_16Y_HACK
678 udelay(10L); 685 udelay(10L);
679#endif 686#endif
680 } 687 }
681 tty_schedule_flip(tty); 688 tty_schedule_flip(tty);
682 } 689 }
683 /* end of service */ 690 /* end of service */
684 base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS; 691 base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
685 return IRQ_HANDLED; 692 return IRQ_HANDLED;
686} /* cy_rx_interrupt */ 693} /* cy_rx_interrupt */
687 694
688/* 695/*
689 * This routine is used to handle the "bottom half" processing for the 696 * This routine is used to handle the "bottom half" processing for the
@@ -705,192 +712,188 @@ cd2401_rx_interrupt(int irq, void *dev_id)
705 * structure) to the bottom half of the driver. Previous kernels 712 * structure) to the bottom half of the driver. Previous kernels
706 * had to poll every port to see if that port needed servicing. 713 * had to poll every port to see if that port needed servicing.
707 */ 714 */
708static void 715static void do_softint(struct work_struct *ugly_api)
709do_softint(struct work_struct *ugly_api)
710{ 716{
711 struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue); 717 struct cyclades_port *info =
712 struct tty_struct *tty; 718 container_of(ugly_api, struct cyclades_port, tqueue);
713 719 struct tty_struct *tty;
714 tty = info->tty;
715 if (!tty)
716 return;
717 720
718 if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) { 721 tty = info->tty;
719 tty_hangup(info->tty); 722 if (!tty)
720 wake_up_interruptible(&info->open_wait); 723 return;
721 info->flags &= ~ASYNC_NORMAL_ACTIVE;
722 }
723 if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
724 wake_up_interruptible(&info->open_wait);
725 }
726 if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
727 tty_wakeup(tty);
728 }
729} /* do_softint */
730 724
725 if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
726 tty_hangup(info->tty);
727 wake_up_interruptible(&info->open_wait);
728 info->flags &= ~ASYNC_NORMAL_ACTIVE;
729 }
730 if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
731 wake_up_interruptible(&info->open_wait);
732 }
733 if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
734 tty_wakeup(tty);
735 }
736} /* do_softint */
731 737
732/* This is called whenever a port becomes active; 738/* This is called whenever a port becomes active;
733 interrupts are enabled and DTR & RTS are turned on. 739 interrupts are enabled and DTR & RTS are turned on.
734 */ 740 */
735static int 741static int startup(struct cyclades_port *info)
736startup(struct cyclades_port * info)
737{ 742{
738 unsigned long flags; 743 unsigned long flags;
739 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; 744 volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
740 int channel; 745 int channel;
741 746
742 if (info->flags & ASYNC_INITIALIZED){ 747 if (info->flags & ASYNC_INITIALIZED) {
743 return 0; 748 return 0;
744 } 749 }
745 750
746 if (!info->type){ 751 if (!info->type) {
747 if (info->tty){ 752 if (info->tty) {
748 set_bit(TTY_IO_ERROR, &info->tty->flags); 753 set_bit(TTY_IO_ERROR, &info->tty->flags);
754 }
755 return 0;
749 } 756 }
750 return 0; 757 if (!info->xmit_buf) {
751 } 758 info->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
752 if (!info->xmit_buf){ 759 if (!info->xmit_buf) {
753 info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL); 760 return -ENOMEM;
754 if (!info->xmit_buf){ 761 }
755 return -ENOMEM;
756 } 762 }
757 }
758 763
759 config_setup(info); 764 config_setup(info);
760 765
761 channel = info->line; 766 channel = info->line;
762 767
763#ifdef SERIAL_DEBUG_OPEN 768#ifdef SERIAL_DEBUG_OPEN
764 printk("startup channel %d\n", channel); 769 printk("startup channel %d\n", channel);
765#endif 770#endif
766 771
767 local_irq_save(flags); 772 local_irq_save(flags);
768 base_addr[CyCAR] = (u_char)channel; 773 base_addr[CyCAR] = (u_char) channel;
769 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); 774 write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
770 775
771 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ 776 base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
772 base_addr[CyMSVR1] = CyRTS; 777 base_addr[CyMSVR1] = CyRTS;
773/* CP('S');CP('1'); */ 778/* CP('S');CP('1'); */
774 base_addr[CyMSVR2] = CyDTR; 779 base_addr[CyMSVR2] = CyDTR;
775 780
776#ifdef SERIAL_DEBUG_DTR 781#ifdef SERIAL_DEBUG_DTR
777 printk("cyc: %d: raising DTR\n", __LINE__); 782 printk("cyc: %d: raising DTR\n", __LINE__);
778 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 783 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
784 base_addr[CyMSVR2]);
779#endif 785#endif
780 786
781 base_addr[CyIER] |= CyRxData; 787 base_addr[CyIER] |= CyRxData;
782 info->flags |= ASYNC_INITIALIZED; 788 info->flags |= ASYNC_INITIALIZED;
783 789
784 if (info->tty){ 790 if (info->tty) {
785 clear_bit(TTY_IO_ERROR, &info->tty->flags); 791 clear_bit(TTY_IO_ERROR, &info->tty->flags);
786 } 792 }
787 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 793 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
788 794
789 local_irq_restore(flags); 795 local_irq_restore(flags);
790 796
791#ifdef SERIAL_DEBUG_OPEN 797#ifdef SERIAL_DEBUG_OPEN
792 printk(" done\n"); 798 printk(" done\n");
793#endif 799#endif
794 return 0; 800 return 0;
795} /* startup */ 801} /* startup */
796 802
797void 803void start_xmit(struct cyclades_port *info)
798start_xmit( struct cyclades_port *info )
799{ 804{
800 unsigned long flags; 805 unsigned long flags;
801 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 806 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
802 int channel; 807 int channel;
803 808
804 channel = info->line; 809 channel = info->line;
805 local_irq_save(flags); 810 local_irq_save(flags);
806 base_addr[CyCAR] = channel; 811 base_addr[CyCAR] = channel;
807 base_addr[CyIER] |= CyTxMpty; 812 base_addr[CyIER] |= CyTxMpty;
808 local_irq_restore(flags); 813 local_irq_restore(flags);
809} /* start_xmit */ 814} /* start_xmit */
810 815
811/* 816/*
812 * This routine shuts down a serial port; interrupts are disabled, 817 * This routine shuts down a serial port; interrupts are disabled,
813 * and DTR is dropped if the hangup on close termio flag is on. 818 * and DTR is dropped if the hangup on close termio flag is on.
814 */ 819 */
815static void 820static void shutdown(struct cyclades_port *info)
816shutdown(struct cyclades_port * info)
817{ 821{
818 unsigned long flags; 822 unsigned long flags;
819 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 823 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
820 int channel; 824 int channel;
821 825
822 if (!(info->flags & ASYNC_INITIALIZED)){ 826 if (!(info->flags & ASYNC_INITIALIZED)) {
823/* CP('$'); */ 827/* CP('$'); */
824 return; 828 return;
825 } 829 }
826 830
827 channel = info->line; 831 channel = info->line;
828 832
829#ifdef SERIAL_DEBUG_OPEN 833#ifdef SERIAL_DEBUG_OPEN
830 printk("shutdown channel %d\n", channel); 834 printk("shutdown channel %d\n", channel);
831#endif 835#endif
832 836
833 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE 837 /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
834 SENT BEFORE DROPPING THE LINE !!! (Perhaps 838 SENT BEFORE DROPPING THE LINE !!! (Perhaps
835 set some flag that is read when XMTY happens.) 839 set some flag that is read when XMTY happens.)
836 Other choices are to delay some fixed interval 840 Other choices are to delay some fixed interval
837 or schedule some later processing. 841 or schedule some later processing.
838 */ 842 */
839 local_irq_save(flags); 843 local_irq_save(flags);
840 if (info->xmit_buf){ 844 if (info->xmit_buf) {
841 free_page((unsigned long) info->xmit_buf); 845 free_page((unsigned long)info->xmit_buf);
842 info->xmit_buf = NULL; 846 info->xmit_buf = NULL;
843 } 847 }
844 848
845 base_addr[CyCAR] = (u_char)channel; 849 base_addr[CyCAR] = (u_char) channel;
846 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { 850 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
847 base_addr[CyMSVR1] = 0; 851 base_addr[CyMSVR1] = 0;
848/* CP('C');CP('1'); */ 852/* CP('C');CP('1'); */
849 base_addr[CyMSVR2] = 0; 853 base_addr[CyMSVR2] = 0;
850#ifdef SERIAL_DEBUG_DTR 854#ifdef SERIAL_DEBUG_DTR
851 printk("cyc: %d: dropping DTR\n", __LINE__); 855 printk("cyc: %d: dropping DTR\n", __LINE__);
852 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 856 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
857 base_addr[CyMSVR2]);
853#endif 858#endif
854 } 859 }
855 write_cy_cmd(base_addr,CyDIS_RCVR); 860 write_cy_cmd(base_addr, CyDIS_RCVR);
856 /* it may be appropriate to clear _XMIT at 861 /* it may be appropriate to clear _XMIT at
857 some later date (after testing)!!! */ 862 some later date (after testing)!!! */
858 863
859 if (info->tty){ 864 if (info->tty) {
860 set_bit(TTY_IO_ERROR, &info->tty->flags); 865 set_bit(TTY_IO_ERROR, &info->tty->flags);
861 } 866 }
862 info->flags &= ~ASYNC_INITIALIZED; 867 info->flags &= ~ASYNC_INITIALIZED;
863 local_irq_restore(flags); 868 local_irq_restore(flags);
864 869
865#ifdef SERIAL_DEBUG_OPEN 870#ifdef SERIAL_DEBUG_OPEN
866 printk(" done\n"); 871 printk(" done\n");
867#endif 872#endif
868 return; 873} /* shutdown */
869} /* shutdown */
870 874
871/* 875/*
872 * This routine finds or computes the various line characteristics. 876 * This routine finds or computes the various line characteristics.
873 */ 877 */
874static void 878static void config_setup(struct cyclades_port *info)
875config_setup(struct cyclades_port * info)
876{ 879{
877 unsigned long flags; 880 unsigned long flags;
878 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 881 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
879 int channel; 882 int channel;
880 unsigned cflag; 883 unsigned cflag;
881 int i; 884 int i;
882 unsigned char ti, need_init_chan = 0; 885 unsigned char ti, need_init_chan = 0;
883 886
884 if (!info->tty || !info->tty->termios){ 887 if (!info->tty || !info->tty->termios) {
885 return; 888 return;
886 } 889 }
887 if (info->line == -1){ 890 if (info->line == -1) {
888 return; 891 return;
889 } 892 }
890 cflag = info->tty->termios->c_cflag; 893 cflag = info->tty->termios->c_cflag;
891 894
892 /* baud rate */ 895 /* baud rate */
893 i = cflag & CBAUD; 896 i = cflag & CBAUD;
894#ifdef CBAUDEX 897#ifdef CBAUDEX
895/* Starting with kernel 1.1.65, there is direct support for 898/* Starting with kernel 1.1.65, there is direct support for
896 higher baud rates. The following code supports those 899 higher baud rates. The following code supports those
@@ -900,120 +903,123 @@ config_setup(struct cyclades_port * info)
900 is still the possibility of supporting 75 kbit/sec with 903 is still the possibility of supporting 75 kbit/sec with
901 the Cyclades board.) 904 the Cyclades board.)
902 */ 905 */
903 if (i & CBAUDEX) { 906 if (i & CBAUDEX) {
904 if (i == B57600) 907 if (i == B57600)
905 i = 16; 908 i = 16;
906 else if(i == B115200) 909 else if (i == B115200)
907 i = 18; 910 i = 18;
908#ifdef B78600 911#ifdef B78600
909 else if(i == B78600) 912 else if (i == B78600)
910 i = 17; 913 i = 17;
911#endif 914#endif
912 else 915 else
913 info->tty->termios->c_cflag &= ~CBAUDEX; 916 info->tty->termios->c_cflag &= ~CBAUDEX;
914 } 917 }
915#endif 918#endif
916 if (i == 15) { 919 if (i == 15) {
917 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 920 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
918 i += 1; 921 i += 1;
919 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 922 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
920 i += 3; 923 i += 3;
921 } 924 }
922 /* Don't ever change the speed of the console port. It will 925 /* Don't ever change the speed of the console port. It will
923 * run at the speed specified in bootinfo, or at 19.2K */ 926 * run at the speed specified in bootinfo, or at 19.2K */
924 /* Actually, it should run at whatever speed 166Bug was using */ 927 /* Actually, it should run at whatever speed 166Bug was using */
925 /* Note info->timeout isn't used at present */ 928 /* Note info->timeout isn't used at present */
926 if (info != serial_console_info) { 929 if (info != serial_console_info) {
927 info->tbpr = baud_bpr[i]; /* Tx BPR */ 930 info->tbpr = baud_bpr[i]; /* Tx BPR */
928 info->tco = baud_co[i]; /* Tx CO */ 931 info->tco = baud_co[i]; /* Tx CO */
929 info->rbpr = baud_bpr[i]; /* Rx BPR */ 932 info->rbpr = baud_bpr[i]; /* Rx BPR */
930 info->rco = baud_co[i] >> 5; /* Rx CO */ 933 info->rco = baud_co[i] >> 5; /* Rx CO */
931 if (baud_table[i] == 134) { 934 if (baud_table[i] == 134) {
932 info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; 935 info->timeout =
933 /* get it right for 134.5 baud */ 936 (info->xmit_fifo_size * HZ * 30 / 269) + 2;
934 } else if (baud_table[i]) { 937 /* get it right for 134.5 baud */
935 info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2; 938 } else if (baud_table[i]) {
936 /* this needs to be propagated into the card info */ 939 info->timeout =
940 (info->xmit_fifo_size * HZ * 15 / baud_table[i]) +
941 2;
942 /* this needs to be propagated into the card info */
943 } else {
944 info->timeout = 0;
945 }
946 }
947 /* By tradition (is it a standard?) a baud rate of zero
948 implies the line should be/has been closed. A bit
949 later in this routine such a test is performed. */
950
951 /* byte size and parity */
952 info->cor7 = 0;
953 info->cor6 = 0;
954 info->cor5 = 0;
955 info->cor4 = (info->default_threshold ? info->default_threshold : baud_cor4[i]); /* receive threshold */
956 /* Following two lines added 101295, RGH. */
957 /* It is obviously wrong to access CyCORx, and not info->corx here,
958 * try and remember to fix it later! */
959 channel = info->line;
960 base_addr[CyCAR] = (u_char) channel;
961 if (C_CLOCAL(info->tty)) {
962 if (base_addr[CyIER] & CyMdmCh)
963 base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
964 /* ignore 1->0 modem transitions */
965 if (base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD))
966 base_addr[CyCOR4] &= ~(CyDSR | CyCTS | CyDCD);
967 /* ignore 0->1 modem transitions */
968 if (base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD))
969 base_addr[CyCOR5] &= ~(CyDSR | CyCTS | CyDCD);
937 } else { 970 } else {
938 info->timeout = 0; 971 if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
939 } 972 base_addr[CyIER] |= CyMdmCh; /* with modem intr */
940 } 973 /* act on 1->0 modem transitions */
941 /* By tradition (is it a standard?) a baud rate of zero 974 if ((base_addr[CyCOR4] & (CyDSR | CyCTS | CyDCD)) !=
942 implies the line should be/has been closed. A bit 975 (CyDSR | CyCTS | CyDCD))
943 later in this routine such a test is performed. */ 976 base_addr[CyCOR4] |= CyDSR | CyCTS | CyDCD;
944 977 /* act on 0->1 modem transitions */
945 /* byte size and parity */ 978 if ((base_addr[CyCOR5] & (CyDSR | CyCTS | CyDCD)) !=
946 info->cor7 = 0; 979 (CyDSR | CyCTS | CyDCD))
947 info->cor6 = 0; 980 base_addr[CyCOR5] |= CyDSR | CyCTS | CyDCD;
948 info->cor5 = 0; 981 }
949 info->cor4 = (info->default_threshold 982 info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
950 ? info->default_threshold 983 info->cor2 = CyETC;
951 : baud_cor4[i]); /* receive threshold */ 984 switch (cflag & CSIZE) {
952 /* Following two lines added 101295, RGH. */ 985 case CS5:
953 /* It is obviously wrong to access CyCORx, and not info->corx here, 986 info->cor1 = Cy_5_BITS;
954 * try and remember to fix it later! */ 987 break;
955 channel = info->line; 988 case CS6:
956 base_addr[CyCAR] = (u_char)channel; 989 info->cor1 = Cy_6_BITS;
957 if (C_CLOCAL(info->tty)) { 990 break;
958 if (base_addr[CyIER] & CyMdmCh) 991 case CS7:
959 base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */ 992 info->cor1 = Cy_7_BITS;
960 /* ignore 1->0 modem transitions */ 993 break;
961 if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) 994 case CS8:
962 base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD); 995 info->cor1 = Cy_8_BITS;
963 /* ignore 0->1 modem transitions */ 996 break;
964 if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) 997 }
965 base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD); 998 if (cflag & PARENB) {
966 } else { 999 if (cflag & PARODD) {
967 if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh) 1000 info->cor1 |= CyPARITY_O;
968 base_addr[CyIER] |= CyMdmCh; /* with modem intr */ 1001 } else {
969 /* act on 1->0 modem transitions */ 1002 info->cor1 |= CyPARITY_E;
970 if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) 1003 }
971 base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD; 1004 } else {
972 /* act on 0->1 modem transitions */ 1005 info->cor1 |= CyPARITY_NONE;
973 if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD)) 1006 }
974 base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD; 1007
975 } 1008 /* CTS flow control flag */
976 info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
977 info->cor2 = CyETC;
978 switch(cflag & CSIZE){
979 case CS5:
980 info->cor1 = Cy_5_BITS;
981 break;
982 case CS6:
983 info->cor1 = Cy_6_BITS;
984 break;
985 case CS7:
986 info->cor1 = Cy_7_BITS;
987 break;
988 case CS8:
989 info->cor1 = Cy_8_BITS;
990 break;
991 }
992 if (cflag & PARENB){
993 if (cflag & PARODD){
994 info->cor1 |= CyPARITY_O;
995 }else{
996 info->cor1 |= CyPARITY_E;
997 }
998 }else{
999 info->cor1 |= CyPARITY_NONE;
1000 }
1001
1002 /* CTS flow control flag */
1003#if 0 1009#if 0
1004 /* Don't complcate matters for now! RGH 141095 */ 1010 /* Don't complcate matters for now! RGH 141095 */
1005 if (cflag & CRTSCTS){ 1011 if (cflag & CRTSCTS) {
1006 info->flags |= ASYNC_CTS_FLOW; 1012 info->flags |= ASYNC_CTS_FLOW;
1007 info->cor2 |= CyCtsAE; 1013 info->cor2 |= CyCtsAE;
1008 }else{ 1014 } else {
1009 info->flags &= ~ASYNC_CTS_FLOW; 1015 info->flags &= ~ASYNC_CTS_FLOW;
1010 info->cor2 &= ~CyCtsAE; 1016 info->cor2 &= ~CyCtsAE;
1011 } 1017 }
1012#endif 1018#endif
1013 if (cflag & CLOCAL) 1019 if (cflag & CLOCAL)
1014 info->flags &= ~ASYNC_CHECK_CD; 1020 info->flags &= ~ASYNC_CHECK_CD;
1015 else 1021 else
1016 info->flags |= ASYNC_CHECK_CD; 1022 info->flags |= ASYNC_CHECK_CD;
1017 1023
1018 /*********************************************** 1024 /***********************************************
1019 The hardware option, CyRtsAO, presents RTS when 1025 The hardware option, CyRtsAO, presents RTS when
@@ -1025,149 +1031,146 @@ config_setup(struct cyclades_port * info)
1025 cable. Contact Marcio Saito for details. 1031 cable. Contact Marcio Saito for details.
1026 ***********************************************/ 1032 ***********************************************/
1027 1033
1028 channel = info->line; 1034 channel = info->line;
1029 1035
1030 local_irq_save(flags); 1036 local_irq_save(flags);
1031 base_addr[CyCAR] = (u_char)channel; 1037 base_addr[CyCAR] = (u_char) channel;
1032 1038
1033 /* CyCMR set once only in mvme167_init_serial() */ 1039 /* CyCMR set once only in mvme167_init_serial() */
1034 if (base_addr[CyLICR] != channel << 2) 1040 if (base_addr[CyLICR] != channel << 2)
1035 base_addr[CyLICR] = channel << 2; 1041 base_addr[CyLICR] = channel << 2;
1036 if (base_addr[CyLIVR] != 0x5c) 1042 if (base_addr[CyLIVR] != 0x5c)
1037 base_addr[CyLIVR] = 0x5c; 1043 base_addr[CyLIVR] = 0x5c;
1038 1044
1039 /* tx and rx baud rate */ 1045 /* tx and rx baud rate */
1040 1046
1041 if (base_addr[CyCOR1] != info->cor1) 1047 if (base_addr[CyCOR1] != info->cor1)
1042 need_init_chan = 1; 1048 need_init_chan = 1;
1043 if (base_addr[CyTCOR] != info->tco) 1049 if (base_addr[CyTCOR] != info->tco)
1044 base_addr[CyTCOR] = info->tco; 1050 base_addr[CyTCOR] = info->tco;
1045 if (base_addr[CyTBPR] != info->tbpr) 1051 if (base_addr[CyTBPR] != info->tbpr)
1046 base_addr[CyTBPR] = info->tbpr; 1052 base_addr[CyTBPR] = info->tbpr;
1047 if (base_addr[CyRCOR] != info->rco) 1053 if (base_addr[CyRCOR] != info->rco)
1048 base_addr[CyRCOR] = info->rco; 1054 base_addr[CyRCOR] = info->rco;
1049 if (base_addr[CyRBPR] != info->rbpr) 1055 if (base_addr[CyRBPR] != info->rbpr)
1050 base_addr[CyRBPR] = info->rbpr; 1056 base_addr[CyRBPR] = info->rbpr;
1051 1057
1052 /* set line characteristics according configuration */ 1058 /* set line characteristics according configuration */
1053 1059
1054 if (base_addr[CySCHR1] != START_CHAR(info->tty)) 1060 if (base_addr[CySCHR1] != START_CHAR(info->tty))
1055 base_addr[CySCHR1] = START_CHAR(info->tty); 1061 base_addr[CySCHR1] = START_CHAR(info->tty);
1056 if (base_addr[CySCHR2] != STOP_CHAR(info->tty)) 1062 if (base_addr[CySCHR2] != STOP_CHAR(info->tty))
1057 base_addr[CySCHR2] = STOP_CHAR(info->tty); 1063 base_addr[CySCHR2] = STOP_CHAR(info->tty);
1058 if (base_addr[CySCRL] != START_CHAR(info->tty)) 1064 if (base_addr[CySCRL] != START_CHAR(info->tty))
1059 base_addr[CySCRL] = START_CHAR(info->tty); 1065 base_addr[CySCRL] = START_CHAR(info->tty);
1060 if (base_addr[CySCRH] != START_CHAR(info->tty)) 1066 if (base_addr[CySCRH] != START_CHAR(info->tty))
1061 base_addr[CySCRH] = START_CHAR(info->tty); 1067 base_addr[CySCRH] = START_CHAR(info->tty);
1062 if (base_addr[CyCOR1] != info->cor1) 1068 if (base_addr[CyCOR1] != info->cor1)
1063 base_addr[CyCOR1] = info->cor1; 1069 base_addr[CyCOR1] = info->cor1;
1064 if (base_addr[CyCOR2] != info->cor2) 1070 if (base_addr[CyCOR2] != info->cor2)
1065 base_addr[CyCOR2] = info->cor2; 1071 base_addr[CyCOR2] = info->cor2;
1066 if (base_addr[CyCOR3] != info->cor3) 1072 if (base_addr[CyCOR3] != info->cor3)
1067 base_addr[CyCOR3] = info->cor3; 1073 base_addr[CyCOR3] = info->cor3;
1068 if (base_addr[CyCOR4] != info->cor4) 1074 if (base_addr[CyCOR4] != info->cor4)
1069 base_addr[CyCOR4] = info->cor4; 1075 base_addr[CyCOR4] = info->cor4;
1070 if (base_addr[CyCOR5] != info->cor5) 1076 if (base_addr[CyCOR5] != info->cor5)
1071 base_addr[CyCOR5] = info->cor5; 1077 base_addr[CyCOR5] = info->cor5;
1072 if (base_addr[CyCOR6] != info->cor6) 1078 if (base_addr[CyCOR6] != info->cor6)
1073 base_addr[CyCOR6] = info->cor6; 1079 base_addr[CyCOR6] = info->cor6;
1074 if (base_addr[CyCOR7] != info->cor7) 1080 if (base_addr[CyCOR7] != info->cor7)
1075 base_addr[CyCOR7] = info->cor7; 1081 base_addr[CyCOR7] = info->cor7;
1076 1082
1077 if (need_init_chan) 1083 if (need_init_chan)
1078 write_cy_cmd(base_addr,CyINIT_CHAN); 1084 write_cy_cmd(base_addr, CyINIT_CHAN);
1079 1085
1080 base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */ 1086 base_addr[CyCAR] = (u_char) channel; /* !!! Is this needed? */
1081 1087
1082 /* 2ms default rx timeout */ 1088 /* 2ms default rx timeout */
1083 ti = info->default_timeout ? info->default_timeout : 0x02; 1089 ti = info->default_timeout ? info->default_timeout : 0x02;
1084 if (base_addr[CyRTPRL] != ti) 1090 if (base_addr[CyRTPRL] != ti)
1085 base_addr[CyRTPRL] = ti; 1091 base_addr[CyRTPRL] = ti;
1086 if (base_addr[CyRTPRH] != 0) 1092 if (base_addr[CyRTPRH] != 0)
1087 base_addr[CyRTPRH] = 0; 1093 base_addr[CyRTPRH] = 0;
1088 1094
1089 /* Set up RTS here also ????? RGH 141095 */ 1095 /* Set up RTS here also ????? RGH 141095 */
1090 if(i == 0){ /* baud rate is zero, turn off line */ 1096 if (i == 0) { /* baud rate is zero, turn off line */
1091 if ((base_addr[CyMSVR2] & CyDTR) == CyDTR) 1097 if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
1092 base_addr[CyMSVR2] = 0; 1098 base_addr[CyMSVR2] = 0;
1093#ifdef SERIAL_DEBUG_DTR 1099#ifdef SERIAL_DEBUG_DTR
1094 printk("cyc: %d: dropping DTR\n", __LINE__); 1100 printk("cyc: %d: dropping DTR\n", __LINE__);
1095 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1101 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
1102 base_addr[CyMSVR2]);
1096#endif 1103#endif
1097 }else{ 1104 } else {
1098 if ((base_addr[CyMSVR2] & CyDTR) != CyDTR) 1105 if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
1099 base_addr[CyMSVR2] = CyDTR; 1106 base_addr[CyMSVR2] = CyDTR;
1100#ifdef SERIAL_DEBUG_DTR 1107#ifdef SERIAL_DEBUG_DTR
1101 printk("cyc: %d: raising DTR\n", __LINE__); 1108 printk("cyc: %d: raising DTR\n", __LINE__);
1102 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1109 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
1110 base_addr[CyMSVR2]);
1103#endif 1111#endif
1104 } 1112 }
1105 1113
1106 if (info->tty){ 1114 if (info->tty) {
1107 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1115 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1108 } 1116 }
1109 1117
1110 local_irq_restore(flags); 1118 local_irq_restore(flags);
1111
1112} /* config_setup */
1113 1119
1120} /* config_setup */
1114 1121
1115static void 1122static void cy_put_char(struct tty_struct *tty, unsigned char ch)
1116cy_put_char(struct tty_struct *tty, unsigned char ch)
1117{ 1123{
1118 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1124 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1119 unsigned long flags; 1125 unsigned long flags;
1120 1126
1121#ifdef SERIAL_DEBUG_IO 1127#ifdef SERIAL_DEBUG_IO
1122 printk("cy_put_char %s(0x%02x)\n", tty->name, ch); 1128 printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
1123#endif 1129#endif
1124 1130
1125 if (serial_paranoia_check(info, tty->name, "cy_put_char")) 1131 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
1126 return; 1132 return;
1127 1133
1128 if (!info->xmit_buf) 1134 if (!info->xmit_buf)
1129 return; 1135 return;
1130 1136
1131 local_irq_save(flags); 1137 local_irq_save(flags);
1132 if (info->xmit_cnt >= PAGE_SIZE - 1) { 1138 if (info->xmit_cnt >= PAGE_SIZE - 1) {
1133 local_irq_restore(flags); 1139 local_irq_restore(flags);
1134 return; 1140 return;
1135 } 1141 }
1136 1142
1137 info->xmit_buf[info->xmit_head++] = ch; 1143 info->xmit_buf[info->xmit_head++] = ch;
1138 info->xmit_head &= PAGE_SIZE - 1; 1144 info->xmit_head &= PAGE_SIZE - 1;
1139 info->xmit_cnt++; 1145 info->xmit_cnt++;
1140 local_irq_restore(flags); 1146 local_irq_restore(flags);
1141} /* cy_put_char */ 1147} /* cy_put_char */
1142
1143 1148
1144static void 1149static void cy_flush_chars(struct tty_struct *tty)
1145cy_flush_chars(struct tty_struct *tty)
1146{ 1150{
1147 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1151 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1148 unsigned long flags; 1152 unsigned long flags;
1149 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1153 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1150 int channel; 1154 int channel;
1151 1155
1152#ifdef SERIAL_DEBUG_IO 1156#ifdef SERIAL_DEBUG_IO
1153 printk("cy_flush_chars %s\n", tty->name); /* */ 1157 printk("cy_flush_chars %s\n", tty->name); /* */
1154#endif 1158#endif
1155 1159
1156 if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) 1160 if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
1157 return; 1161 return;
1158 1162
1159 if (info->xmit_cnt <= 0 || tty->stopped 1163 if (info->xmit_cnt <= 0 || tty->stopped
1160 || tty->hw_stopped || !info->xmit_buf) 1164 || tty->hw_stopped || !info->xmit_buf)
1161 return; 1165 return;
1162 1166
1163 channel = info->line; 1167 channel = info->line;
1164 1168
1165 local_irq_save(flags); 1169 local_irq_save(flags);
1166 base_addr[CyCAR] = channel; 1170 base_addr[CyCAR] = channel;
1167 base_addr[CyIER] |= CyTxMpty; 1171 base_addr[CyIER] |= CyTxMpty;
1168 local_irq_restore(flags); 1172 local_irq_restore(flags);
1169} /* cy_flush_chars */ 1173} /* cy_flush_chars */
1170
1171 1174
1172/* This routine gets called when tty_write has put something into 1175/* This routine gets called when tty_write has put something into
1173 the write_queue. If the port is not already transmitting stuff, 1176 the write_queue. If the port is not already transmitting stuff,
@@ -1175,650 +1178,616 @@ cy_flush_chars(struct tty_struct *tty)
1175 routine will then ensure that the characters are sent. If the 1178 routine will then ensure that the characters are sent. If the
1176 port is already active, there is no need to kick it. 1179 port is already active, there is no need to kick it.
1177 */ 1180 */
1178static int 1181static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
1179cy_write(struct tty_struct * tty,
1180 const unsigned char *buf, int count)
1181{ 1182{
1182 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1183 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1183 unsigned long flags; 1184 unsigned long flags;
1184 int c, total = 0; 1185 int c, total = 0;
1185 1186
1186#ifdef SERIAL_DEBUG_IO 1187#ifdef SERIAL_DEBUG_IO
1187 printk("cy_write %s\n", tty->name); /* */ 1188 printk("cy_write %s\n", tty->name); /* */
1188#endif 1189#endif
1189 1190
1190 if (serial_paranoia_check(info, tty->name, "cy_write")){ 1191 if (serial_paranoia_check(info, tty->name, "cy_write")) {
1191 return 0; 1192 return 0;
1192 } 1193 }
1193
1194 if (!info->xmit_buf){
1195 return 0;
1196 }
1197
1198 while (1) {
1199 local_irq_save(flags);
1200 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1201 SERIAL_XMIT_SIZE - info->xmit_head));
1202 if (c <= 0) {
1203 local_irq_restore(flags);
1204 break;
1205 }
1206
1207 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1208 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1209 info->xmit_cnt += c;
1210 local_irq_restore(flags);
1211
1212 buf += c;
1213 count -= c;
1214 total += c;
1215 }
1216
1217 if (info->xmit_cnt
1218 && !tty->stopped
1219 && !tty->hw_stopped ) {
1220 start_xmit(info);
1221 }
1222 return total;
1223} /* cy_write */
1224 1194
1195 if (!info->xmit_buf) {
1196 return 0;
1197 }
1225 1198
1226static int 1199 while (1) {
1227cy_write_room(struct tty_struct *tty) 1200 local_irq_save(flags);
1201 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1202 SERIAL_XMIT_SIZE - info->xmit_head));
1203 if (c <= 0) {
1204 local_irq_restore(flags);
1205 break;
1206 }
1207
1208 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1209 info->xmit_head =
1210 (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1);
1211 info->xmit_cnt += c;
1212 local_irq_restore(flags);
1213
1214 buf += c;
1215 count -= c;
1216 total += c;
1217 }
1218
1219 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
1220 start_xmit(info);
1221 }
1222 return total;
1223} /* cy_write */
1224
1225static int cy_write_room(struct tty_struct *tty)
1228{ 1226{
1229 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1227 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1230 int ret; 1228 int ret;
1231 1229
1232#ifdef SERIAL_DEBUG_IO 1230#ifdef SERIAL_DEBUG_IO
1233 printk("cy_write_room %s\n", tty->name); /* */ 1231 printk("cy_write_room %s\n", tty->name); /* */
1234#endif 1232#endif
1235 1233
1236 if (serial_paranoia_check(info, tty->name, "cy_write_room")) 1234 if (serial_paranoia_check(info, tty->name, "cy_write_room"))
1237 return 0; 1235 return 0;
1238 ret = PAGE_SIZE - info->xmit_cnt - 1; 1236 ret = PAGE_SIZE - info->xmit_cnt - 1;
1239 if (ret < 0) 1237 if (ret < 0)
1240 ret = 0; 1238 ret = 0;
1241 return ret; 1239 return ret;
1242} /* cy_write_room */ 1240} /* cy_write_room */
1243
1244 1241
1245static int 1242static int cy_chars_in_buffer(struct tty_struct *tty)
1246cy_chars_in_buffer(struct tty_struct *tty)
1247{ 1243{
1248 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1244 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1249 1245
1250#ifdef SERIAL_DEBUG_IO 1246#ifdef SERIAL_DEBUG_IO
1251 printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */ 1247 printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
1252#endif 1248#endif
1253 1249
1254 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) 1250 if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
1255 return 0; 1251 return 0;
1256
1257 return info->xmit_cnt;
1258} /* cy_chars_in_buffer */
1259 1252
1253 return info->xmit_cnt;
1254} /* cy_chars_in_buffer */
1260 1255
1261static void 1256static void cy_flush_buffer(struct tty_struct *tty)
1262cy_flush_buffer(struct tty_struct *tty)
1263{ 1257{
1264 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1258 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1265 unsigned long flags; 1259 unsigned long flags;
1266 1260
1267#ifdef SERIAL_DEBUG_IO 1261#ifdef SERIAL_DEBUG_IO
1268 printk("cy_flush_buffer %s\n", tty->name); /* */ 1262 printk("cy_flush_buffer %s\n", tty->name); /* */
1269#endif 1263#endif
1270 1264
1271 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) 1265 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
1272 return; 1266 return;
1273 local_irq_save(flags); 1267 local_irq_save(flags);
1274 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1268 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1275 local_irq_restore(flags); 1269 local_irq_restore(flags);
1276 tty_wakeup(tty); 1270 tty_wakeup(tty);
1277} /* cy_flush_buffer */ 1271} /* cy_flush_buffer */
1278
1279 1272
1280/* This routine is called by the upper-layer tty layer to signal 1273/* This routine is called by the upper-layer tty layer to signal
1281 that incoming characters should be throttled or that the 1274 that incoming characters should be throttled or that the
1282 throttle should be released. 1275 throttle should be released.
1283 */ 1276 */
1284static void 1277static void cy_throttle(struct tty_struct *tty)
1285cy_throttle(struct tty_struct * tty)
1286{ 1278{
1287 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1279 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1288 unsigned long flags; 1280 unsigned long flags;
1289 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1281 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1290 int channel; 1282 int channel;
1291 1283
1292#ifdef SERIAL_DEBUG_THROTTLE 1284#ifdef SERIAL_DEBUG_THROTTLE
1293 char buf[64]; 1285 char buf[64];
1294 1286
1295 printk("throttle %s: %d....\n", tty_name(tty, buf), 1287 printk("throttle %s: %d....\n", tty_name(tty, buf),
1296 tty->ldisc.chars_in_buffer(tty)); 1288 tty->ldisc.chars_in_buffer(tty));
1297 printk("cy_throttle %s\n", tty->name); 1289 printk("cy_throttle %s\n", tty->name);
1298#endif 1290#endif
1299 1291
1300 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ 1292 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
1301 return; 1293 return;
1302 } 1294 }
1303 1295
1304 if (I_IXOFF(tty)) { 1296 if (I_IXOFF(tty)) {
1305 info->x_char = STOP_CHAR(tty); 1297 info->x_char = STOP_CHAR(tty);
1306 /* Should use the "Send Special Character" feature!!! */ 1298 /* Should use the "Send Special Character" feature!!! */
1307 } 1299 }
1308 1300
1309 channel = info->line; 1301 channel = info->line;
1310 1302
1311 local_irq_save(flags); 1303 local_irq_save(flags);
1312 base_addr[CyCAR] = (u_char)channel; 1304 base_addr[CyCAR] = (u_char) channel;
1313 base_addr[CyMSVR1] = 0; 1305 base_addr[CyMSVR1] = 0;
1314 local_irq_restore(flags); 1306 local_irq_restore(flags);
1315 1307} /* cy_throttle */
1316 return;
1317} /* cy_throttle */
1318
1319 1308
1320static void 1309static void cy_unthrottle(struct tty_struct *tty)
1321cy_unthrottle(struct tty_struct * tty)
1322{ 1310{
1323 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1311 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1324 unsigned long flags; 1312 unsigned long flags;
1325 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1313 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1326 int channel; 1314 int channel;
1327 1315
1328#ifdef SERIAL_DEBUG_THROTTLE 1316#ifdef SERIAL_DEBUG_THROTTLE
1329 char buf[64]; 1317 char buf[64];
1330 1318
1331 printk("throttle %s: %d....\n", tty_name(tty, buf), 1319 printk("throttle %s: %d....\n", tty_name(tty, buf),
1332 tty->ldisc.chars_in_buffer(tty)); 1320 tty->ldisc.chars_in_buffer(tty));
1333 printk("cy_unthrottle %s\n", tty->name); 1321 printk("cy_unthrottle %s\n", tty->name);
1334#endif 1322#endif
1335 1323
1336 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){ 1324 if (serial_paranoia_check(info, tty->name, "cy_nthrottle")) {
1337 return; 1325 return;
1338 } 1326 }
1339 1327
1340 if (I_IXOFF(tty)) { 1328 if (I_IXOFF(tty)) {
1341 info->x_char = START_CHAR(tty); 1329 info->x_char = START_CHAR(tty);
1342 /* Should use the "Send Special Character" feature!!! */ 1330 /* Should use the "Send Special Character" feature!!! */
1343 } 1331 }
1344 1332
1345 channel = info->line; 1333 channel = info->line;
1346 1334
1347 local_irq_save(flags); 1335 local_irq_save(flags);
1348 base_addr[CyCAR] = (u_char)channel; 1336 base_addr[CyCAR] = (u_char) channel;
1349 base_addr[CyMSVR1] = CyRTS; 1337 base_addr[CyMSVR1] = CyRTS;
1350 local_irq_restore(flags); 1338 local_irq_restore(flags);
1351 1339} /* cy_unthrottle */
1352 return;
1353} /* cy_unthrottle */
1354 1340
1355static int 1341static int
1356get_serial_info(struct cyclades_port * info, 1342get_serial_info(struct cyclades_port *info,
1357 struct serial_struct __user * retinfo) 1343 struct serial_struct __user * retinfo)
1358{ 1344{
1359 struct serial_struct tmp; 1345 struct serial_struct tmp;
1360 1346
1361/* CP('g'); */ 1347/* CP('g'); */
1362 if (!retinfo) 1348 if (!retinfo)
1363 return -EFAULT; 1349 return -EFAULT;
1364 memset(&tmp, 0, sizeof(tmp)); 1350 memset(&tmp, 0, sizeof(tmp));
1365 tmp.type = info->type; 1351 tmp.type = info->type;
1366 tmp.line = info->line; 1352 tmp.line = info->line;
1367 tmp.port = info->line; 1353 tmp.port = info->line;
1368 tmp.irq = 0; 1354 tmp.irq = 0;
1369 tmp.flags = info->flags; 1355 tmp.flags = info->flags;
1370 tmp.baud_base = 0; /*!!!*/ 1356 tmp.baud_base = 0; /*!!! */
1371 tmp.close_delay = info->close_delay; 1357 tmp.close_delay = info->close_delay;
1372 tmp.custom_divisor = 0; /*!!!*/ 1358 tmp.custom_divisor = 0; /*!!! */
1373 tmp.hub6 = 0; /*!!!*/ 1359 tmp.hub6 = 0; /*!!! */
1374 return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0; 1360 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
1375} /* get_serial_info */ 1361} /* get_serial_info */
1376 1362
1377static int 1363static int
1378set_serial_info(struct cyclades_port * info, 1364set_serial_info(struct cyclades_port *info,
1379 struct serial_struct __user * new_info) 1365 struct serial_struct __user * new_info)
1380{ 1366{
1381 struct serial_struct new_serial; 1367 struct serial_struct new_serial;
1382 struct cyclades_port old_info; 1368 struct cyclades_port old_info;
1383 1369
1384/* CP('s'); */ 1370/* CP('s'); */
1385 if (!new_info) 1371 if (!new_info)
1386 return -EFAULT; 1372 return -EFAULT;
1387 if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1373 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
1388 return -EFAULT; 1374 return -EFAULT;
1389 old_info = *info; 1375 old_info = *info;
1376
1377 if (!capable(CAP_SYS_ADMIN)) {
1378 if ((new_serial.close_delay != info->close_delay) ||
1379 ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
1380 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
1381 return -EPERM;
1382 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
1383 (new_serial.flags & ASYNC_USR_MASK));
1384 goto check_and_exit;
1385 }
1390 1386
1391 if (!capable(CAP_SYS_ADMIN)) { 1387 /*
1392 if ((new_serial.close_delay != info->close_delay) || 1388 * OK, past this point, all the error checking has been done.
1393 ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) != 1389 * At this point, we start making changes.....
1394 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))) 1390 */
1395 return -EPERM;
1396 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
1397 (new_serial.flags & ASYNC_USR_MASK));
1398 goto check_and_exit;
1399 }
1400 1391
1392 info->flags = ((info->flags & ~ASYNC_FLAGS) |
1393 (new_serial.flags & ASYNC_FLAGS));
1394 info->close_delay = new_serial.close_delay;
1401 1395
1402 /* 1396check_and_exit:
1403 * OK, past this point, all the error checking has been done. 1397 if (info->flags & ASYNC_INITIALIZED) {
1404 * At this point, we start making changes..... 1398 config_setup(info);
1405 */ 1399 return 0;
1400 }
1401 return startup(info);
1402} /* set_serial_info */
1406 1403
1407 info->flags = ((info->flags & ~ASYNC_FLAGS) | 1404static int cy_tiocmget(struct tty_struct *tty, struct file *file)
1408 (new_serial.flags & ASYNC_FLAGS)); 1405{
1409 info->close_delay = new_serial.close_delay; 1406 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1407 int channel;
1408 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1409 unsigned long flags;
1410 unsigned char status;
1410 1411
1412 channel = info->line;
1411 1413
1412check_and_exit: 1414 local_irq_save(flags);
1413 if (info->flags & ASYNC_INITIALIZED){ 1415 base_addr[CyCAR] = (u_char) channel;
1414 config_setup(info); 1416 status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
1415 return 0; 1417 local_irq_restore(flags);
1416 }else{
1417 return startup(info);
1418 }
1419} /* set_serial_info */
1420 1418
1421static int 1419 return ((status & CyRTS) ? TIOCM_RTS : 0)
1422cy_tiocmget(struct tty_struct *tty, struct file *file) 1420 | ((status & CyDTR) ? TIOCM_DTR : 0)
1423{ 1421 | ((status & CyDCD) ? TIOCM_CAR : 0)
1424 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1422 | ((status & CyDSR) ? TIOCM_DSR : 0)
1425 int channel; 1423 | ((status & CyCTS) ? TIOCM_CTS : 0);
1426 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1424} /* cy_tiocmget */
1427 unsigned long flags;
1428 unsigned char status;
1429
1430 channel = info->line;
1431
1432 local_irq_save(flags);
1433 base_addr[CyCAR] = (u_char)channel;
1434 status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
1435 local_irq_restore(flags);
1436
1437 return ((status & CyRTS) ? TIOCM_RTS : 0)
1438 | ((status & CyDTR) ? TIOCM_DTR : 0)
1439 | ((status & CyDCD) ? TIOCM_CAR : 0)
1440 | ((status & CyDSR) ? TIOCM_DSR : 0)
1441 | ((status & CyCTS) ? TIOCM_CTS : 0);
1442} /* cy_tiocmget */
1443 1425
1444static int 1426static int
1445cy_tiocmset(struct tty_struct *tty, struct file *file, 1427cy_tiocmset(struct tty_struct *tty, struct file *file,
1446 unsigned int set, unsigned int clear) 1428 unsigned int set, unsigned int clear)
1447{ 1429{
1448 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1430 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1449 int channel; 1431 int channel;
1450 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1432 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1451 unsigned long flags; 1433 unsigned long flags;
1452 1434
1453 channel = info->line; 1435 channel = info->line;
1454 1436
1455 if (set & TIOCM_RTS){ 1437 if (set & TIOCM_RTS) {
1456 local_irq_save(flags); 1438 local_irq_save(flags);
1457 base_addr[CyCAR] = (u_char)channel; 1439 base_addr[CyCAR] = (u_char) channel;
1458 base_addr[CyMSVR1] = CyRTS; 1440 base_addr[CyMSVR1] = CyRTS;
1459 local_irq_restore(flags); 1441 local_irq_restore(flags);
1460 } 1442 }
1461 if (set & TIOCM_DTR){ 1443 if (set & TIOCM_DTR) {
1462 local_irq_save(flags); 1444 local_irq_save(flags);
1463 base_addr[CyCAR] = (u_char)channel; 1445 base_addr[CyCAR] = (u_char) channel;
1464/* CP('S');CP('2'); */ 1446/* CP('S');CP('2'); */
1465 base_addr[CyMSVR2] = CyDTR; 1447 base_addr[CyMSVR2] = CyDTR;
1466#ifdef SERIAL_DEBUG_DTR 1448#ifdef SERIAL_DEBUG_DTR
1467 printk("cyc: %d: raising DTR\n", __LINE__); 1449 printk("cyc: %d: raising DTR\n", __LINE__);
1468 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1450 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
1451 base_addr[CyMSVR2]);
1469#endif 1452#endif
1470 local_irq_restore(flags); 1453 local_irq_restore(flags);
1471 } 1454 }
1472 1455
1473 if (clear & TIOCM_RTS){ 1456 if (clear & TIOCM_RTS) {
1474 local_irq_save(flags); 1457 local_irq_save(flags);
1475 base_addr[CyCAR] = (u_char)channel; 1458 base_addr[CyCAR] = (u_char) channel;
1476 base_addr[CyMSVR1] = 0; 1459 base_addr[CyMSVR1] = 0;
1477 local_irq_restore(flags); 1460 local_irq_restore(flags);
1478 } 1461 }
1479 if (clear & TIOCM_DTR){ 1462 if (clear & TIOCM_DTR) {
1480 local_irq_save(flags); 1463 local_irq_save(flags);
1481 base_addr[CyCAR] = (u_char)channel; 1464 base_addr[CyCAR] = (u_char) channel;
1482/* CP('C');CP('2'); */ 1465/* CP('C');CP('2'); */
1483 base_addr[CyMSVR2] = 0; 1466 base_addr[CyMSVR2] = 0;
1484#ifdef SERIAL_DEBUG_DTR 1467#ifdef SERIAL_DEBUG_DTR
1485 printk("cyc: %d: dropping DTR\n", __LINE__); 1468 printk("cyc: %d: dropping DTR\n", __LINE__);
1486 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1469 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
1470 base_addr[CyMSVR2]);
1487#endif 1471#endif
1488 local_irq_restore(flags); 1472 local_irq_restore(flags);
1489 } 1473 }
1490 1474
1491 return 0; 1475 return 0;
1492} /* set_modem_info */ 1476} /* set_modem_info */
1493 1477
1494static void 1478static void send_break(struct cyclades_port *info, int duration)
1495send_break( struct cyclades_port * info, int duration) 1479{ /* Let the transmit ISR take care of this (since it
1496{ /* Let the transmit ISR take care of this (since it 1480 requires stuffing characters into the output stream).
1497 requires stuffing characters into the output stream). 1481 */
1498 */ 1482 info->x_break = duration;
1499 info->x_break = duration; 1483 if (!info->xmit_cnt) {
1500 if (!info->xmit_cnt ) { 1484 start_xmit(info);
1501 start_xmit(info); 1485 }
1502 } 1486} /* send_break */
1503} /* send_break */
1504 1487
1505static int 1488static int
1506get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) 1489get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon)
1507{ 1490{
1508 1491
1509 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 1492 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
1510 return -EFAULT; 1493 return -EFAULT;
1511 info->mon.int_count = 0; 1494 info->mon.int_count = 0;
1512 info->mon.char_count = 0; 1495 info->mon.char_count = 0;
1513 info->mon.char_max = 0; 1496 info->mon.char_max = 0;
1514 info->mon.char_last = 0; 1497 info->mon.char_last = 0;
1515 return 0; 1498 return 0;
1516} 1499}
1517 1500
1518static int 1501static int set_threshold(struct cyclades_port *info, unsigned long __user * arg)
1519set_threshold(struct cyclades_port * info, unsigned long __user *arg)
1520{ 1502{
1521 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1503 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1522 unsigned long value; 1504 unsigned long value;
1523 int channel; 1505 int channel;
1524 1506
1525 if (get_user(value, arg)) 1507 if (get_user(value, arg))
1526 return -EFAULT; 1508 return -EFAULT;
1527 1509
1528 channel = info->line; 1510 channel = info->line;
1529 info->cor4 &= ~CyREC_FIFO; 1511 info->cor4 &= ~CyREC_FIFO;
1530 info->cor4 |= value & CyREC_FIFO; 1512 info->cor4 |= value & CyREC_FIFO;
1531 base_addr[CyCOR4] = info->cor4; 1513 base_addr[CyCOR4] = info->cor4;
1532 return 0; 1514 return 0;
1533} 1515}
1534 1516
1535static int 1517static int
1536get_threshold(struct cyclades_port * info, unsigned long __user *value) 1518get_threshold(struct cyclades_port *info, unsigned long __user * value)
1537{ 1519{
1538 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1520 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1539 int channel; 1521 int channel;
1540 unsigned long tmp; 1522 unsigned long tmp;
1541 1523
1542 channel = info->line; 1524 channel = info->line;
1543 1525
1544 tmp = base_addr[CyCOR4] & CyREC_FIFO; 1526 tmp = base_addr[CyCOR4] & CyREC_FIFO;
1545 return put_user(tmp,value); 1527 return put_user(tmp, value);
1546} 1528}
1547 1529
1548static int 1530static int
1549set_default_threshold(struct cyclades_port * info, unsigned long __user *arg) 1531set_default_threshold(struct cyclades_port *info, unsigned long __user * arg)
1550{ 1532{
1551 unsigned long value; 1533 unsigned long value;
1552 1534
1553 if (get_user(value, arg)) 1535 if (get_user(value, arg))
1554 return -EFAULT; 1536 return -EFAULT;
1555 1537
1556 info->default_threshold = value & 0x0f; 1538 info->default_threshold = value & 0x0f;
1557 return 0; 1539 return 0;
1558} 1540}
1559 1541
1560static int 1542static int
1561get_default_threshold(struct cyclades_port * info, unsigned long __user *value) 1543get_default_threshold(struct cyclades_port *info, unsigned long __user * value)
1562{ 1544{
1563 return put_user(info->default_threshold,value); 1545 return put_user(info->default_threshold, value);
1564} 1546}
1565 1547
1566static int 1548static int set_timeout(struct cyclades_port *info, unsigned long __user * arg)
1567set_timeout(struct cyclades_port * info, unsigned long __user *arg)
1568{ 1549{
1569 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1550 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1570 int channel; 1551 int channel;
1571 unsigned long value; 1552 unsigned long value;
1572 1553
1573 if (get_user(value, arg)) 1554 if (get_user(value, arg))
1574 return -EFAULT; 1555 return -EFAULT;
1575 1556
1576 channel = info->line; 1557 channel = info->line;
1577 1558
1578 base_addr[CyRTPRL] = value & 0xff; 1559 base_addr[CyRTPRL] = value & 0xff;
1579 base_addr[CyRTPRH] = (value >> 8) & 0xff; 1560 base_addr[CyRTPRH] = (value >> 8) & 0xff;
1580 return 0; 1561 return 0;
1581} 1562}
1582 1563
1583static int 1564static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
1584get_timeout(struct cyclades_port * info, unsigned long __user *value)
1585{ 1565{
1586 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1566 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
1587 int channel; 1567 int channel;
1588 unsigned long tmp; 1568 unsigned long tmp;
1589 1569
1590 channel = info->line; 1570 channel = info->line;
1591 1571
1592 tmp = base_addr[CyRTPRL]; 1572 tmp = base_addr[CyRTPRL];
1593 return put_user(tmp,value); 1573 return put_user(tmp, value);
1594} 1574}
1595 1575
1596static int 1576static int set_default_timeout(struct cyclades_port *info, unsigned long value)
1597set_default_timeout(struct cyclades_port * info, unsigned long value)
1598{ 1577{
1599 info->default_timeout = value & 0xff; 1578 info->default_timeout = value & 0xff;
1600 return 0; 1579 return 0;
1601} 1580}
1602 1581
1603static int 1582static int
1604get_default_timeout(struct cyclades_port * info, unsigned long __user *value) 1583get_default_timeout(struct cyclades_port *info, unsigned long __user * value)
1605{ 1584{
1606 return put_user(info->default_timeout,value); 1585 return put_user(info->default_timeout, value);
1607} 1586}
1608 1587
1609static int 1588static int
1610cy_ioctl(struct tty_struct *tty, struct file * file, 1589cy_ioctl(struct tty_struct *tty, struct file *file,
1611 unsigned int cmd, unsigned long arg) 1590 unsigned int cmd, unsigned long arg)
1612{ 1591{
1613 unsigned long val; 1592 unsigned long val;
1614 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1593 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1615 int ret_val = 0; 1594 int ret_val = 0;
1616 void __user *argp = (void __user *)arg; 1595 void __user *argp = (void __user *)arg;
1617 1596
1618#ifdef SERIAL_DEBUG_OTHER 1597#ifdef SERIAL_DEBUG_OTHER
1619 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1598 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
1620#endif 1599#endif
1621 1600
1622 switch (cmd) { 1601 switch (cmd) {
1623 case CYGETMON: 1602 case CYGETMON:
1624 ret_val = get_mon_info(info, argp); 1603 ret_val = get_mon_info(info, argp);
1625 break; 1604 break;
1626 case CYGETTHRESH: 1605 case CYGETTHRESH:
1627 ret_val = get_threshold(info, argp); 1606 ret_val = get_threshold(info, argp);
1628 break; 1607 break;
1629 case CYSETTHRESH: 1608 case CYSETTHRESH:
1630 ret_val = set_threshold(info, argp); 1609 ret_val = set_threshold(info, argp);
1631 break; 1610 break;
1632 case CYGETDEFTHRESH: 1611 case CYGETDEFTHRESH:
1633 ret_val = get_default_threshold(info, argp); 1612 ret_val = get_default_threshold(info, argp);
1634 break; 1613 break;
1635 case CYSETDEFTHRESH: 1614 case CYSETDEFTHRESH:
1636 ret_val = set_default_threshold(info, argp); 1615 ret_val = set_default_threshold(info, argp);
1637 break; 1616 break;
1638 case CYGETTIMEOUT: 1617 case CYGETTIMEOUT:
1639 ret_val = get_timeout(info, argp); 1618 ret_val = get_timeout(info, argp);
1640 break; 1619 break;
1641 case CYSETTIMEOUT: 1620 case CYSETTIMEOUT:
1642 ret_val = set_timeout(info, argp); 1621 ret_val = set_timeout(info, argp);
1643 break; 1622 break;
1644 case CYGETDEFTIMEOUT: 1623 case CYGETDEFTIMEOUT:
1645 ret_val = get_default_timeout(info, argp); 1624 ret_val = get_default_timeout(info, argp);
1646 break; 1625 break;
1647 case CYSETDEFTIMEOUT: 1626 case CYSETDEFTIMEOUT:
1648 ret_val = set_default_timeout(info, (unsigned long)arg); 1627 ret_val = set_default_timeout(info, (unsigned long)arg);
1649 break; 1628 break;
1650 case TCSBRK: /* SVID version: non-zero arg --> no break */ 1629 case TCSBRK: /* SVID version: non-zero arg --> no break */
1651 ret_val = tty_check_change(tty); 1630 ret_val = tty_check_change(tty);
1652 if (ret_val) 1631 if (ret_val)
1653 break; 1632 break;
1654 tty_wait_until_sent(tty,0); 1633 tty_wait_until_sent(tty, 0);
1655 if (!arg) 1634 if (!arg)
1656 send_break(info, HZ/4); /* 1/4 second */ 1635 send_break(info, HZ / 4); /* 1/4 second */
1657 break; 1636 break;
1658 case TCSBRKP: /* support for POSIX tcsendbreak() */ 1637 case TCSBRKP: /* support for POSIX tcsendbreak() */
1659 ret_val = tty_check_change(tty); 1638 ret_val = tty_check_change(tty);
1660 if (ret_val) 1639 if (ret_val)
1640 break;
1641 tty_wait_until_sent(tty, 0);
1642 send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
1661 break; 1643 break;
1662 tty_wait_until_sent(tty,0);
1663 send_break(info, arg ? arg*(HZ/10) : HZ/4);
1664 break;
1665 1644
1666/* The following commands are incompletely implemented!!! */ 1645/* The following commands are incompletely implemented!!! */
1667 case TIOCGSOFTCAR: 1646 case TIOCGSOFTCAR:
1668 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); 1647 ret_val =
1669 break; 1648 put_user(C_CLOCAL(tty) ? 1 : 0,
1670 case TIOCSSOFTCAR: 1649 (unsigned long __user *)argp);
1671 ret_val = get_user(val, (unsigned long __user *) argp); 1650 break;
1672 if (ret_val) 1651 case TIOCSSOFTCAR:
1673 break; 1652 ret_val = get_user(val, (unsigned long __user *)argp);
1674 tty->termios->c_cflag = 1653 if (ret_val)
1675 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0)); 1654 break;
1676 break; 1655 tty->termios->c_cflag =
1677 case TIOCGSERIAL: 1656 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1678 ret_val = get_serial_info(info, argp); 1657 break;
1679 break; 1658 case TIOCGSERIAL:
1680 case TIOCSSERIAL: 1659 ret_val = get_serial_info(info, argp);
1681 ret_val = set_serial_info(info, argp); 1660 break;
1682 break; 1661 case TIOCSSERIAL:
1683 default: 1662 ret_val = set_serial_info(info, argp);
1684 ret_val = -ENOIOCTLCMD; 1663 break;
1685 } 1664 default:
1665 ret_val = -ENOIOCTLCMD;
1666 }
1686 1667
1687#ifdef SERIAL_DEBUG_OTHER 1668#ifdef SERIAL_DEBUG_OTHER
1688 printk("cy_ioctl done\n"); 1669 printk("cy_ioctl done\n");
1689#endif 1670#endif
1690 1671
1691 return ret_val; 1672 return ret_val;
1692} /* cy_ioctl */ 1673} /* cy_ioctl */
1693
1694 1674
1695 1675static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1696
1697static void
1698cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
1699{ 1676{
1700 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1677 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1701 1678
1702#ifdef SERIAL_DEBUG_OTHER 1679#ifdef SERIAL_DEBUG_OTHER
1703 printk("cy_set_termios %s\n", tty->name); 1680 printk("cy_set_termios %s\n", tty->name);
1704#endif 1681#endif
1705 1682
1706 if (tty->termios->c_cflag == old_termios->c_cflag) 1683 if (tty->termios->c_cflag == old_termios->c_cflag)
1707 return; 1684 return;
1708 config_setup(info); 1685 config_setup(info);
1709 1686
1710 if ((old_termios->c_cflag & CRTSCTS) && 1687 if ((old_termios->c_cflag & CRTSCTS) &&
1711 !(tty->termios->c_cflag & CRTSCTS)) { 1688 !(tty->termios->c_cflag & CRTSCTS)) {
1712 tty->stopped = 0; 1689 tty->stopped = 0;
1713 cy_start(tty); 1690 cy_start(tty);
1714 } 1691 }
1715#ifdef tytso_patch_94Nov25_1726 1692#ifdef tytso_patch_94Nov25_1726
1716 if (!(old_termios->c_cflag & CLOCAL) && 1693 if (!(old_termios->c_cflag & CLOCAL) &&
1717 (tty->termios->c_cflag & CLOCAL)) 1694 (tty->termios->c_cflag & CLOCAL))
1718 wake_up_interruptible(&info->open_wait); 1695 wake_up_interruptible(&info->open_wait);
1719#endif 1696#endif
1697} /* cy_set_termios */
1720 1698
1721 return; 1699static void cy_close(struct tty_struct *tty, struct file *filp)
1722} /* cy_set_termios */
1723
1724
1725static void
1726cy_close(struct tty_struct * tty, struct file * filp)
1727{ 1700{
1728 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1701 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1729 1702
1730/* CP('C'); */ 1703/* CP('C'); */
1731#ifdef SERIAL_DEBUG_OTHER 1704#ifdef SERIAL_DEBUG_OTHER
1732 printk("cy_close %s\n", tty->name); 1705 printk("cy_close %s\n", tty->name);
1733#endif 1706#endif
1734 1707
1735 if (!info 1708 if (!info || serial_paranoia_check(info, tty->name, "cy_close")) {
1736 || serial_paranoia_check(info, tty->name, "cy_close")){ 1709 return;
1737 return; 1710 }
1738 }
1739#ifdef SERIAL_DEBUG_OPEN 1711#ifdef SERIAL_DEBUG_OPEN
1740 printk("cy_close %s, count = %d\n", tty->name, info->count); 1712 printk("cy_close %s, count = %d\n", tty->name, info->count);
1741#endif 1713#endif
1742 1714
1743 if ((tty->count == 1) && (info->count != 1)) { 1715 if ((tty->count == 1) && (info->count != 1)) {
1744 /* 1716 /*
1745 * Uh, oh. tty->count is 1, which means that the tty 1717 * Uh, oh. tty->count is 1, which means that the tty
1746 * structure will be freed. Info->count should always 1718 * structure will be freed. Info->count should always
1747 * be one in these conditions. If it's greater than 1719 * be one in these conditions. If it's greater than
1748 * one, we've got real problems, since it means the 1720 * one, we've got real problems, since it means the
1749 * serial port won't be shutdown. 1721 * serial port won't be shutdown.
1750 */ 1722 */
1751 printk("cy_close: bad serial port count; tty->count is 1, " 1723 printk("cy_close: bad serial port count; tty->count is 1, "
1752 "info->count is %d\n", info->count); 1724 "info->count is %d\n", info->count);
1753 info->count = 1; 1725 info->count = 1;
1754 } 1726 }
1755#ifdef SERIAL_DEBUG_COUNT 1727#ifdef SERIAL_DEBUG_COUNT
1756 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1); 1728 printk("cyc: %d: decrementing count to %d\n", __LINE__,
1729 info->count - 1);
1757#endif 1730#endif
1758 if (--info->count < 0) { 1731 if (--info->count < 0) {
1759 printk("cy_close: bad serial port count for ttys%d: %d\n", 1732 printk("cy_close: bad serial port count for ttys%d: %d\n",
1760 info->line, info->count); 1733 info->line, info->count);
1761#ifdef SERIAL_DEBUG_COUNT 1734#ifdef SERIAL_DEBUG_COUNT
1762 printk("cyc: %d: setting count to 0\n", __LINE__); 1735 printk("cyc: %d: setting count to 0\n", __LINE__);
1763#endif 1736#endif
1764 info->count = 0; 1737 info->count = 0;
1765 }
1766 if (info->count)
1767 return;
1768 info->flags |= ASYNC_CLOSING;
1769 if (info->flags & ASYNC_INITIALIZED)
1770 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1771 shutdown(info);
1772 if (tty->driver->flush_buffer)
1773 tty->driver->flush_buffer(tty);
1774 tty_ldisc_flush(tty);
1775 info->event = 0;
1776 info->tty = NULL;
1777 if (info->blocked_open) {
1778 if (info->close_delay) {
1779 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1780 } 1738 }
1781 wake_up_interruptible(&info->open_wait); 1739 if (info->count)
1782 } 1740 return;
1783 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1741 info->flags |= ASYNC_CLOSING;
1784 wake_up_interruptible(&info->close_wait); 1742 if (info->flags & ASYNC_INITIALIZED)
1743 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1744 shutdown(info);
1745 if (tty->driver->flush_buffer)
1746 tty->driver->flush_buffer(tty);
1747 tty_ldisc_flush(tty);
1748 info->event = 0;
1749 info->tty = NULL;
1750 if (info->blocked_open) {
1751 if (info->close_delay) {
1752 msleep_interruptible(jiffies_to_msecs
1753 (info->close_delay));
1754 }
1755 wake_up_interruptible(&info->open_wait);
1756 }
1757 info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
1758 wake_up_interruptible(&info->close_wait);
1785 1759
1786#ifdef SERIAL_DEBUG_OTHER 1760#ifdef SERIAL_DEBUG_OTHER
1787 printk("cy_close done\n"); 1761 printk("cy_close done\n");
1788#endif 1762#endif
1789 1763} /* cy_close */
1790 return;
1791} /* cy_close */
1792 1764
1793/* 1765/*
1794 * cy_hangup() --- called by tty_hangup() when a hangup is signaled. 1766 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
1795 */ 1767 */
1796void 1768void cy_hangup(struct tty_struct *tty)
1797cy_hangup(struct tty_struct *tty)
1798{ 1769{
1799 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1770 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1800 1771
1801#ifdef SERIAL_DEBUG_OTHER 1772#ifdef SERIAL_DEBUG_OTHER
1802 printk("cy_hangup %s\n", tty->name); /* */ 1773 printk("cy_hangup %s\n", tty->name); /* */
1803#endif 1774#endif
1804 1775
1805 if (serial_paranoia_check(info, tty->name, "cy_hangup")) 1776 if (serial_paranoia_check(info, tty->name, "cy_hangup"))
1806 return; 1777 return;
1807 1778
1808 shutdown(info); 1779 shutdown(info);
1809#if 0 1780#if 0
1810 info->event = 0; 1781 info->event = 0;
1811 info->count = 0; 1782 info->count = 0;
1812#ifdef SERIAL_DEBUG_COUNT 1783#ifdef SERIAL_DEBUG_COUNT
1813 printk("cyc: %d: setting count to 0\n", __LINE__); 1784 printk("cyc: %d: setting count to 0\n", __LINE__);
1814#endif 1785#endif
1815 info->tty = 0; 1786 info->tty = 0;
1816#endif 1787#endif
1817 info->flags &= ~ASYNC_NORMAL_ACTIVE; 1788 info->flags &= ~ASYNC_NORMAL_ACTIVE;
1818 wake_up_interruptible(&info->open_wait); 1789 wake_up_interruptible(&info->open_wait);
1819} /* cy_hangup */ 1790} /* cy_hangup */
1820
1821
1822 1791
1823/* 1792/*
1824 * ------------------------------------------------------------ 1793 * ------------------------------------------------------------
@@ -1827,177 +1796,180 @@ cy_hangup(struct tty_struct *tty)
1827 */ 1796 */
1828 1797
1829static int 1798static int
1830block_til_ready(struct tty_struct *tty, struct file * filp, 1799block_til_ready(struct tty_struct *tty, struct file *filp,
1831 struct cyclades_port *info) 1800 struct cyclades_port *info)
1832{ 1801{
1833 DECLARE_WAITQUEUE(wait, current); 1802 DECLARE_WAITQUEUE(wait, current);
1834 unsigned long flags; 1803 unsigned long flags;
1835 int channel; 1804 int channel;
1836 int retval; 1805 int retval;
1837 volatile u_char *base_addr = (u_char *)BASE_ADDR; 1806 volatile u_char *base_addr = (u_char *) BASE_ADDR;
1838 1807
1839 /* 1808 /*
1840 * If the device is in the middle of being closed, then block 1809 * If the device is in the middle of being closed, then block
1841 * until it's done, and then try again. 1810 * until it's done, and then try again.
1842 */ 1811 */
1843 if (info->flags & ASYNC_CLOSING) { 1812 if (info->flags & ASYNC_CLOSING) {
1844 interruptible_sleep_on(&info->close_wait); 1813 interruptible_sleep_on(&info->close_wait);
1845 if (info->flags & ASYNC_HUP_NOTIFY){ 1814 if (info->flags & ASYNC_HUP_NOTIFY) {
1846 return -EAGAIN; 1815 return -EAGAIN;
1847 }else{ 1816 } else {
1848 return -ERESTARTSYS; 1817 return -ERESTARTSYS;
1849 } 1818 }
1850 } 1819 }
1851 1820
1852 /* 1821 /*
1853 * If non-blocking mode is set, then make the check up front 1822 * If non-blocking mode is set, then make the check up front
1854 * and then exit. 1823 * and then exit.
1855 */ 1824 */
1856 if (filp->f_flags & O_NONBLOCK) { 1825 if (filp->f_flags & O_NONBLOCK) {
1857 info->flags |= ASYNC_NORMAL_ACTIVE; 1826 info->flags |= ASYNC_NORMAL_ACTIVE;
1858 return 0; 1827 return 0;
1859 } 1828 }
1860 1829
1861 /* 1830 /*
1862 * Block waiting for the carrier detect and the line to become 1831 * Block waiting for the carrier detect and the line to become
1863 * free (i.e., not in use by the callout). While we are in 1832 * free (i.e., not in use by the callout). While we are in
1864 * this loop, info->count is dropped by one, so that 1833 * this loop, info->count is dropped by one, so that
1865 * cy_close() knows when to free things. We restore it upon 1834 * cy_close() knows when to free things. We restore it upon
1866 * exit, either normal or abnormal. 1835 * exit, either normal or abnormal.
1867 */ 1836 */
1868 retval = 0; 1837 retval = 0;
1869 add_wait_queue(&info->open_wait, &wait); 1838 add_wait_queue(&info->open_wait, &wait);
1870#ifdef SERIAL_DEBUG_OPEN 1839#ifdef SERIAL_DEBUG_OPEN
1871 printk("block_til_ready before block: %s, count = %d\n", 1840 printk("block_til_ready before block: %s, count = %d\n",
1872 tty->name, info->count);/**/ 1841 tty->name, info->count);
1842 /**/
1873#endif 1843#endif
1874 info->count--; 1844 info->count--;
1875#ifdef SERIAL_DEBUG_COUNT 1845#ifdef SERIAL_DEBUG_COUNT
1876 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count); 1846 printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
1877#endif 1847#endif
1878 info->blocked_open++; 1848 info->blocked_open++;
1879 1849
1880 channel = info->line; 1850 channel = info->line;
1881 1851
1882 while (1) { 1852 while (1) {
1883 local_irq_save(flags); 1853 local_irq_save(flags);
1884 base_addr[CyCAR] = (u_char)channel; 1854 base_addr[CyCAR] = (u_char) channel;
1885 base_addr[CyMSVR1] = CyRTS; 1855 base_addr[CyMSVR1] = CyRTS;
1886/* CP('S');CP('4'); */ 1856/* CP('S');CP('4'); */
1887 base_addr[CyMSVR2] = CyDTR; 1857 base_addr[CyMSVR2] = CyDTR;
1888#ifdef SERIAL_DEBUG_DTR 1858#ifdef SERIAL_DEBUG_DTR
1889 printk("cyc: %d: raising DTR\n", __LINE__); 1859 printk("cyc: %d: raising DTR\n", __LINE__);
1890 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]); 1860 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1],
1891#endif 1861 base_addr[CyMSVR2]);
1892 local_irq_restore(flags); 1862#endif
1893 set_current_state(TASK_INTERRUPTIBLE); 1863 local_irq_restore(flags);
1894 if (tty_hung_up_p(filp) 1864 set_current_state(TASK_INTERRUPTIBLE);
1895 || !(info->flags & ASYNC_INITIALIZED) ){ 1865 if (tty_hung_up_p(filp)
1896 if (info->flags & ASYNC_HUP_NOTIFY) { 1866 || !(info->flags & ASYNC_INITIALIZED)) {
1897 retval = -EAGAIN; 1867 if (info->flags & ASYNC_HUP_NOTIFY) {
1898 }else{ 1868 retval = -EAGAIN;
1899 retval = -ERESTARTSYS; 1869 } else {
1900 } 1870 retval = -ERESTARTSYS;
1901 break; 1871 }
1902 } 1872 break;
1903 local_irq_save(flags); 1873 }
1904 base_addr[CyCAR] = (u_char)channel; 1874 local_irq_save(flags);
1875 base_addr[CyCAR] = (u_char) channel;
1905/* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */ 1876/* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
1906 if (!(info->flags & ASYNC_CLOSING) 1877 if (!(info->flags & ASYNC_CLOSING)
1907 && (C_CLOCAL(tty) 1878 && (C_CLOCAL(tty)
1908 || (base_addr[CyMSVR1] & CyDCD))) { 1879 || (base_addr[CyMSVR1] & CyDCD))) {
1909 local_irq_restore(flags); 1880 local_irq_restore(flags);
1910 break; 1881 break;
1911 } 1882 }
1912 local_irq_restore(flags); 1883 local_irq_restore(flags);
1913 if (signal_pending(current)) { 1884 if (signal_pending(current)) {
1914 retval = -ERESTARTSYS; 1885 retval = -ERESTARTSYS;
1915 break; 1886 break;
1916 } 1887 }
1917#ifdef SERIAL_DEBUG_OPEN 1888#ifdef SERIAL_DEBUG_OPEN
1918 printk("block_til_ready blocking: %s, count = %d\n", 1889 printk("block_til_ready blocking: %s, count = %d\n",
1919 tty->name, info->count);/**/ 1890 tty->name, info->count);
1920#endif 1891 /**/
1921 schedule(); 1892#endif
1922 } 1893 schedule();
1923 current->state = TASK_RUNNING; 1894 }
1924 remove_wait_queue(&info->open_wait, &wait); 1895 current->state = TASK_RUNNING;
1925 if (!tty_hung_up_p(filp)){ 1896 remove_wait_queue(&info->open_wait, &wait);
1926 info->count++; 1897 if (!tty_hung_up_p(filp)) {
1898 info->count++;
1927#ifdef SERIAL_DEBUG_COUNT 1899#ifdef SERIAL_DEBUG_COUNT
1928 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); 1900 printk("cyc: %d: incrementing count to %d\n", __LINE__,
1901 info->count);
1929#endif 1902#endif
1930 } 1903 }
1931 info->blocked_open--; 1904 info->blocked_open--;
1932#ifdef SERIAL_DEBUG_OPEN 1905#ifdef SERIAL_DEBUG_OPEN
1933 printk("block_til_ready after blocking: %s, count = %d\n", 1906 printk("block_til_ready after blocking: %s, count = %d\n",
1934 tty->name, info->count);/**/ 1907 tty->name, info->count);
1908 /**/
1935#endif 1909#endif
1936 if (retval) 1910 if (retval)
1937 return retval; 1911 return retval;
1938 info->flags |= ASYNC_NORMAL_ACTIVE; 1912 info->flags |= ASYNC_NORMAL_ACTIVE;
1939 return 0; 1913 return 0;
1940} /* block_til_ready */ 1914} /* block_til_ready */
1941 1915
1942/* 1916/*
1943 * This routine is called whenever a serial port is opened. It 1917 * This routine is called whenever a serial port is opened. It
1944 * performs the serial-specific initialization for the tty structure. 1918 * performs the serial-specific initialization for the tty structure.
1945 */ 1919 */
1946int 1920int cy_open(struct tty_struct *tty, struct file *filp)
1947cy_open(struct tty_struct *tty, struct file * filp)
1948{ 1921{
1949 struct cyclades_port *info; 1922 struct cyclades_port *info;
1950 int retval, line; 1923 int retval, line;
1951 1924
1952/* CP('O'); */ 1925/* CP('O'); */
1953 line = tty->index; 1926 line = tty->index;
1954 if ((line < 0) || (NR_PORTS <= line)){ 1927 if ((line < 0) || (NR_PORTS <= line)) {
1955 return -ENODEV; 1928 return -ENODEV;
1956 } 1929 }
1957 info = &cy_port[line]; 1930 info = &cy_port[line];
1958 if (info->line < 0){ 1931 if (info->line < 0) {
1959 return -ENODEV; 1932 return -ENODEV;
1960 } 1933 }
1961#ifdef SERIAL_DEBUG_OTHER 1934#ifdef SERIAL_DEBUG_OTHER
1962 printk("cy_open %s\n", tty->name); /* */ 1935 printk("cy_open %s\n", tty->name); /* */
1963#endif 1936#endif
1964 if (serial_paranoia_check(info, tty->name, "cy_open")){ 1937 if (serial_paranoia_check(info, tty->name, "cy_open")) {
1965 return -ENODEV; 1938 return -ENODEV;
1966 } 1939 }
1967#ifdef SERIAL_DEBUG_OPEN 1940#ifdef SERIAL_DEBUG_OPEN
1968 printk("cy_open %s, count = %d\n", tty->name, info->count);/**/ 1941 printk("cy_open %s, count = %d\n", tty->name, info->count);
1942 /**/
1969#endif 1943#endif
1970 info->count++; 1944 info->count++;
1971#ifdef SERIAL_DEBUG_COUNT 1945#ifdef SERIAL_DEBUG_COUNT
1972 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count); 1946 printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
1973#endif 1947#endif
1974 tty->driver_data = info; 1948 tty->driver_data = info;
1975 info->tty = tty; 1949 info->tty = tty;
1976 1950
1977 /* 1951 /*
1978 * Start up serial port 1952 * Start up serial port
1979 */ 1953 */
1980 retval = startup(info); 1954 retval = startup(info);
1981 if (retval){ 1955 if (retval) {
1982 return retval; 1956 return retval;
1983 } 1957 }
1984 1958
1985 retval = block_til_ready(tty, filp, info); 1959 retval = block_til_ready(tty, filp, info);
1986 if (retval) { 1960 if (retval) {
1987#ifdef SERIAL_DEBUG_OPEN 1961#ifdef SERIAL_DEBUG_OPEN
1988 printk("cy_open returning after block_til_ready with %d\n", 1962 printk("cy_open returning after block_til_ready with %d\n",
1989 retval); 1963 retval);
1990#endif 1964#endif
1991 return retval; 1965 return retval;
1992 } 1966 }
1993
1994#ifdef SERIAL_DEBUG_OPEN 1967#ifdef SERIAL_DEBUG_OPEN
1995 printk("cy_open done\n");/**/ 1968 printk("cy_open done\n");
1969 /**/
1996#endif 1970#endif
1997 return 0; 1971 return 0;
1998} /* cy_open */ 1972} /* cy_open */
1999
2000
2001 1973
2002/* 1974/*
2003 * --------------------------------------------------------------------- 1975 * ---------------------------------------------------------------------
@@ -2012,11 +1984,10 @@ cy_open(struct tty_struct *tty, struct file * filp)
2012 * number, and identifies which options were configured into this 1984 * number, and identifies which options were configured into this
2013 * driver. 1985 * driver.
2014 */ 1986 */
2015static void 1987static void show_version(void)
2016show_version(void)
2017{ 1988{
2018 printk("MVME166/167 cd2401 driver\n"); 1989 printk("MVME166/167 cd2401 driver\n");
2019} /* show_version */ 1990} /* show_version */
2020 1991
2021/* initialize chips on card -- return number of valid 1992/* initialize chips on card -- return number of valid
2022 chips (which is number of ports/4) */ 1993 chips (which is number of ports/4) */
@@ -2030,10 +2001,9 @@ show_version(void)
2030 * ... I wonder what I should do if this fails ... 2001 * ... I wonder what I should do if this fails ...
2031 */ 2002 */
2032 2003
2033void 2004void mvme167_serial_console_setup(int cflag)
2034mvme167_serial_console_setup(int cflag)
2035{ 2005{
2036 volatile unsigned char* base_addr = (u_char *)BASE_ADDR; 2006 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2037 int ch; 2007 int ch;
2038 u_char spd; 2008 u_char spd;
2039 u_char rcor, rbpr, badspeed = 0; 2009 u_char rcor, rbpr, badspeed = 0;
@@ -2062,21 +2032,21 @@ mvme167_serial_console_setup(int cflag)
2062 2032
2063 /* OK, we have chosen a speed, now reset and reinitialise */ 2033 /* OK, we have chosen a speed, now reset and reinitialise */
2064 2034
2065 my_udelay(20000L); /* Allow time for any active o/p to complete */ 2035 my_udelay(20000L); /* Allow time for any active o/p to complete */
2066 if(base_addr[CyCCR] != 0x00){ 2036 if (base_addr[CyCCR] != 0x00) {
2067 local_irq_restore(flags); 2037 local_irq_restore(flags);
2068 /* printk(" chip is never idle (CCR != 0)\n"); */ 2038 /* printk(" chip is never idle (CCR != 0)\n"); */
2069 return; 2039 return;
2070 } 2040 }
2071 2041
2072 base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */ 2042 base_addr[CyCCR] = CyCHIP_RESET; /* Reset the chip */
2073 my_udelay(1000L); 2043 my_udelay(1000L);
2074 2044
2075 if(base_addr[CyGFRCR] == 0x00){ 2045 if (base_addr[CyGFRCR] == 0x00) {
2076 local_irq_restore(flags); 2046 local_irq_restore(flags);
2077 /* printk(" chip is not responding (GFRCR stayed 0)\n"); */ 2047 /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
2078 return; 2048 return;
2079 } 2049 }
2080 2050
2081 /* 2051 /*
2082 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms 2052 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
@@ -2085,9 +2055,9 @@ mvme167_serial_console_setup(int cflag)
2085 2055
2086 base_addr[CyTPR] = 10; 2056 base_addr[CyTPR] = 10;
2087 2057
2088 base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */ 2058 base_addr[CyPILR1] = 0x01; /* Interrupt level for modem change */
2089 base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */ 2059 base_addr[CyPILR2] = 0x02; /* Interrupt level for tx ints */
2090 base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */ 2060 base_addr[CyPILR3] = 0x03; /* Interrupt level for rx ints */
2091 2061
2092 /* 2062 /*
2093 * Attempt to set up all channels to something reasonable, and 2063 * Attempt to set up all channels to something reasonable, and
@@ -2095,11 +2065,11 @@ mvme167_serial_console_setup(int cflag)
2095 * the ammount of fiddling we have to do in normal running. 2065 * the ammount of fiddling we have to do in normal running.
2096 */ 2066 */
2097 2067
2098 for (ch = 3; ch >= 0 ; ch--) { 2068 for (ch = 3; ch >= 0; ch--) {
2099 base_addr[CyCAR] = (u_char)ch; 2069 base_addr[CyCAR] = (u_char) ch;
2100 base_addr[CyIER] = 0; 2070 base_addr[CyIER] = 0;
2101 base_addr[CyCMR] = CyASYNC; 2071 base_addr[CyCMR] = CyASYNC;
2102 base_addr[CyLICR] = (u_char)ch << 2; 2072 base_addr[CyLICR] = (u_char) ch << 2;
2103 base_addr[CyLIVR] = 0x5c; 2073 base_addr[CyLIVR] = 0x5c;
2104 base_addr[CyTCOR] = baud_co[spd]; 2074 base_addr[CyTCOR] = baud_co[spd];
2105 base_addr[CyTBPR] = baud_bpr[spd]; 2075 base_addr[CyTBPR] = baud_bpr[spd];
@@ -2118,29 +2088,30 @@ mvme167_serial_console_setup(int cflag)
2118 base_addr[CyCOR7] = 0; 2088 base_addr[CyCOR7] = 0;
2119 base_addr[CyRTPRL] = 2; 2089 base_addr[CyRTPRL] = 2;
2120 base_addr[CyRTPRH] = 0; 2090 base_addr[CyRTPRH] = 0;
2121 base_addr[CyMSVR1] = 0; 2091 base_addr[CyMSVR1] = 0;
2122 base_addr[CyMSVR2] = 0; 2092 base_addr[CyMSVR2] = 0;
2123 write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR); 2093 write_cy_cmd(base_addr, CyINIT_CHAN | CyDIS_RCVR | CyDIS_XMTR);
2124 } 2094 }
2125 2095
2126 /* 2096 /*
2127 * Now do specials for channel zero.... 2097 * Now do specials for channel zero....
2128 */ 2098 */
2129 2099
2130 base_addr[CyMSVR1] = CyRTS; 2100 base_addr[CyMSVR1] = CyRTS;
2131 base_addr[CyMSVR2] = CyDTR; 2101 base_addr[CyMSVR2] = CyDTR;
2132 base_addr[CyIER] = CyRxData; 2102 base_addr[CyIER] = CyRxData;
2133 write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR); 2103 write_cy_cmd(base_addr, CyENB_RCVR | CyENB_XMTR);
2134 2104
2135 local_irq_restore(flags); 2105 local_irq_restore(flags);
2136 2106
2137 my_udelay(20000L); /* Let it all settle down */ 2107 my_udelay(20000L); /* Let it all settle down */
2138 2108
2139 printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]); 2109 printk("CD2401 initialised, chip is rev 0x%02x\n", base_addr[CyGFRCR]);
2140 if (badspeed) 2110 if (badspeed)
2141 printk(" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n", 2111 printk
2142 rcor >> 5, rbpr); 2112 (" WARNING: Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
2143} /* serial_console_init */ 2113 rcor >> 5, rbpr);
2114} /* serial_console_init */
2144 2115
2145static const struct tty_operations cy_ops = { 2116static const struct tty_operations cy_ops = {
2146 .open = cy_open, 2117 .open = cy_open,
@@ -2161,6 +2132,7 @@ static const struct tty_operations cy_ops = {
2161 .tiocmget = cy_tiocmget, 2132 .tiocmget = cy_tiocmget,
2162 .tiocmset = cy_tiocmset, 2133 .tiocmset = cy_tiocmset,
2163}; 2134};
2135
2164/* The serial driver boot-time initialization code! 2136/* The serial driver boot-time initialization code!
2165 Hardware I/O ports are mapped to character special devices on a 2137 Hardware I/O ports are mapped to character special devices on a
2166 first found, first allocated manner. That is, this code searches 2138 first found, first allocated manner. That is, this code searches
@@ -2177,214 +2149,214 @@ static const struct tty_operations cy_ops = {
2177 If there are more cards with more ports than have been statically 2149 If there are more cards with more ports than have been statically
2178 allocated above, a warning is printed and the extra ports are ignored. 2150 allocated above, a warning is printed and the extra ports are ignored.
2179 */ 2151 */
2180static int __init 2152static int __init serial167_init(void)
2181serial167_init(void)
2182{ 2153{
2183 struct cyclades_port *info; 2154 struct cyclades_port *info;
2184 int ret = 0; 2155 int ret = 0;
2185 int good_ports = 0; 2156 int good_ports = 0;
2186 int port_num = 0; 2157 int port_num = 0;
2187 int index; 2158 int index;
2188 int DefSpeed; 2159 int DefSpeed;
2189#ifdef notyet 2160#ifdef notyet
2190 struct sigaction sa; 2161 struct sigaction sa;
2191#endif 2162#endif
2192 2163
2193 if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401)) 2164 if (!(mvme16x_config & MVME16x_CONFIG_GOT_CD2401))
2194 return 0; 2165 return 0;
2195 2166
2196 cy_serial_driver = alloc_tty_driver(NR_PORTS); 2167 cy_serial_driver = alloc_tty_driver(NR_PORTS);
2197 if (!cy_serial_driver) 2168 if (!cy_serial_driver)
2198 return -ENOMEM; 2169 return -ENOMEM;
2199 2170
2200#if 0 2171#if 0
2201scrn[1] = '\0'; 2172 scrn[1] = '\0';
2202#endif 2173#endif
2203 2174
2204 show_version(); 2175 show_version();
2205 2176
2206 /* Has "console=0,9600n8" been used in bootinfo to change speed? */ 2177 /* Has "console=0,9600n8" been used in bootinfo to change speed? */
2207 if (serial_console_cflag) 2178 if (serial_console_cflag)
2208 DefSpeed = serial_console_cflag & 0017; 2179 DefSpeed = serial_console_cflag & 0017;
2209 else { 2180 else {
2210 DefSpeed = initial_console_speed; 2181 DefSpeed = initial_console_speed;
2211 serial_console_info = &cy_port[0]; 2182 serial_console_info = &cy_port[0];
2212 serial_console_cflag = DefSpeed | CS8; 2183 serial_console_cflag = DefSpeed | CS8;
2213#if 0 2184#if 0
2214 serial_console = 64; /*callout_driver.minor_start*/ 2185 serial_console = 64; /*callout_driver.minor_start */
2215#endif 2186#endif
2216 } 2187 }
2217
2218 /* Initialize the tty_driver structure */
2219
2220 cy_serial_driver->owner = THIS_MODULE;
2221 cy_serial_driver->name = "ttyS";
2222 cy_serial_driver->major = TTY_MAJOR;
2223 cy_serial_driver->minor_start = 64;
2224 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
2225 cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
2226 cy_serial_driver->init_termios = tty_std_termios;
2227 cy_serial_driver->init_termios.c_cflag =
2228 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2229 cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
2230 tty_set_operations(cy_serial_driver, &cy_ops);
2231 2188
2232 ret = tty_register_driver(cy_serial_driver); 2189 /* Initialize the tty_driver structure */
2233 if (ret) {
2234 printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
2235 put_tty_driver(cy_serial_driver);
2236 return ret;
2237 }
2238 2190
2239 port_num = 0; 2191 cy_serial_driver->owner = THIS_MODULE;
2240 info = cy_port; 2192 cy_serial_driver->name = "ttyS";
2241 for (index = 0; index < 1; index++) { 2193 cy_serial_driver->major = TTY_MAJOR;
2194 cy_serial_driver->minor_start = 64;
2195 cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
2196 cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
2197 cy_serial_driver->init_termios = tty_std_termios;
2198 cy_serial_driver->init_termios.c_cflag =
2199 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2200 cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
2201 tty_set_operations(cy_serial_driver, &cy_ops);
2202
2203 ret = tty_register_driver(cy_serial_driver);
2204 if (ret) {
2205 printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
2206 put_tty_driver(cy_serial_driver);
2207 return ret;
2208 }
2242 2209
2243 good_ports = 4; 2210 port_num = 0;
2211 info = cy_port;
2212 for (index = 0; index < 1; index++) {
2244 2213
2245 if(port_num < NR_PORTS){ 2214 good_ports = 4;
2246 while( good_ports-- && port_num < NR_PORTS){ 2215
2216 if (port_num < NR_PORTS) {
2217 while (good_ports-- && port_num < NR_PORTS) {
2247 /*** initialize port ***/ 2218 /*** initialize port ***/
2248 info->magic = CYCLADES_MAGIC; 2219 info->magic = CYCLADES_MAGIC;
2249 info->type = PORT_CIRRUS; 2220 info->type = PORT_CIRRUS;
2250 info->card = index; 2221 info->card = index;
2251 info->line = port_num; 2222 info->line = port_num;
2252 info->flags = STD_COM_FLAGS; 2223 info->flags = STD_COM_FLAGS;
2253 info->tty = NULL; 2224 info->tty = NULL;
2254 info->xmit_fifo_size = 12; 2225 info->xmit_fifo_size = 12;
2255 info->cor1 = CyPARITY_NONE|Cy_8_BITS; 2226 info->cor1 = CyPARITY_NONE | Cy_8_BITS;
2256 info->cor2 = CyETC; 2227 info->cor2 = CyETC;
2257 info->cor3 = Cy_1_STOP; 2228 info->cor3 = Cy_1_STOP;
2258 info->cor4 = 0x08; /* _very_ small receive threshold */ 2229 info->cor4 = 0x08; /* _very_ small receive threshold */
2259 info->cor5 = 0; 2230 info->cor5 = 0;
2260 info->cor6 = 0; 2231 info->cor6 = 0;
2261 info->cor7 = 0; 2232 info->cor7 = 0;
2262 info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */ 2233 info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */
2263 info->tco = baud_co[DefSpeed]; /* Tx CO */ 2234 info->tco = baud_co[DefSpeed]; /* Tx CO */
2264 info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */ 2235 info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */
2265 info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */ 2236 info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */
2266 info->close_delay = 0; 2237 info->close_delay = 0;
2267 info->x_char = 0; 2238 info->x_char = 0;
2268 info->event = 0; 2239 info->event = 0;
2269 info->count = 0; 2240 info->count = 0;
2270#ifdef SERIAL_DEBUG_COUNT 2241#ifdef SERIAL_DEBUG_COUNT
2271 printk("cyc: %d: setting count to 0\n", __LINE__); 2242 printk("cyc: %d: setting count to 0\n",
2272#endif 2243 __LINE__);
2273 info->blocked_open = 0; 2244#endif
2274 info->default_threshold = 0; 2245 info->blocked_open = 0;
2275 info->default_timeout = 0; 2246 info->default_threshold = 0;
2276 INIT_WORK(&info->tqueue, do_softint); 2247 info->default_timeout = 0;
2277 init_waitqueue_head(&info->open_wait); 2248 INIT_WORK(&info->tqueue, do_softint);
2278 init_waitqueue_head(&info->close_wait); 2249 init_waitqueue_head(&info->open_wait);
2279 /* info->session */ 2250 init_waitqueue_head(&info->close_wait);
2280 /* info->pgrp */ 2251 /* info->session */
2252 /* info->pgrp */
2281/*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/ 2253/*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
2282 info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK 2254 info->read_status_mask =
2283 | CyPARITY| CyFRAME| CyOVERRUN; 2255 CyTIMEOUT | CySPECHAR | CyBREAK | CyPARITY |
2284 /* info->timeout */ 2256 CyFRAME | CyOVERRUN;
2285 2257 /* info->timeout */
2286 printk("ttyS%d ", info->line); 2258
2287 port_num++;info++; 2259 printk("ttyS%d ", info->line);
2288 if(!(port_num & 7)){ 2260 port_num++;
2289 printk("\n "); 2261 info++;
2262 if (!(port_num & 7)) {
2263 printk("\n ");
2264 }
2265 }
2290 } 2266 }
2291 } 2267 printk("\n");
2292 } 2268 }
2293 printk("\n"); 2269 while (port_num < NR_PORTS) {
2294 } 2270 info->line = -1;
2295 while( port_num < NR_PORTS){ 2271 port_num++;
2296 info->line = -1; 2272 info++;
2297 port_num++;info++; 2273 }
2298 }
2299#ifdef CONFIG_REMOTE_DEBUG 2274#ifdef CONFIG_REMOTE_DEBUG
2300 debug_setup(); 2275 debug_setup();
2301#endif 2276#endif
2302 ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0, 2277 ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
2303 "cd2401_errors", cd2401_rxerr_interrupt); 2278 "cd2401_errors", cd2401_rxerr_interrupt);
2304 if (ret) { 2279 if (ret) {
2305 printk(KERN_ERR "Could't get cd2401_errors IRQ"); 2280 printk(KERN_ERR "Could't get cd2401_errors IRQ");
2306 goto cleanup_serial_driver; 2281 goto cleanup_serial_driver;
2307 } 2282 }
2308 2283
2309 ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0, 2284 ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
2310 "cd2401_modem", cd2401_modem_interrupt); 2285 "cd2401_modem", cd2401_modem_interrupt);
2311 if (ret) { 2286 if (ret) {
2312 printk(KERN_ERR "Could't get cd2401_modem IRQ"); 2287 printk(KERN_ERR "Could't get cd2401_modem IRQ");
2313 goto cleanup_irq_cd2401_errors; 2288 goto cleanup_irq_cd2401_errors;
2314 } 2289 }
2315 2290
2316 ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0, 2291 ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
2317 "cd2401_txints", cd2401_tx_interrupt); 2292 "cd2401_txints", cd2401_tx_interrupt);
2318 if (ret) { 2293 if (ret) {
2319 printk(KERN_ERR "Could't get cd2401_txints IRQ"); 2294 printk(KERN_ERR "Could't get cd2401_txints IRQ");
2320 goto cleanup_irq_cd2401_modem; 2295 goto cleanup_irq_cd2401_modem;
2321 } 2296 }
2322 2297
2323 ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0, 2298 ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
2324 "cd2401_rxints", cd2401_rx_interrupt); 2299 "cd2401_rxints", cd2401_rx_interrupt);
2325 if (ret) { 2300 if (ret) {
2326 printk(KERN_ERR "Could't get cd2401_rxints IRQ"); 2301 printk(KERN_ERR "Could't get cd2401_rxints IRQ");
2327 goto cleanup_irq_cd2401_txints; 2302 goto cleanup_irq_cd2401_txints;
2328 } 2303 }
2329 2304
2330 /* Now we have registered the interrupt handlers, allow the interrupts */ 2305 /* Now we have registered the interrupt handlers, allow the interrupts */
2331 2306
2332 pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */ 2307 pcc2chip[PccSCCMICR] = 0x15; /* Serial ints are level 5 */
2333 pcc2chip[PccSCCTICR] = 0x15; 2308 pcc2chip[PccSCCTICR] = 0x15;
2334 pcc2chip[PccSCCRICR] = 0x15; 2309 pcc2chip[PccSCCRICR] = 0x15;
2335 2310
2336 pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */ 2311 pcc2chip[PccIMLR] = 3; /* Allow PCC2 ints above 3!? */
2337 2312
2338 return 0; 2313 return 0;
2339cleanup_irq_cd2401_txints: 2314cleanup_irq_cd2401_txints:
2340 free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt); 2315 free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
2341cleanup_irq_cd2401_modem: 2316cleanup_irq_cd2401_modem:
2342 free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt); 2317 free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
2343cleanup_irq_cd2401_errors: 2318cleanup_irq_cd2401_errors:
2344 free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt); 2319 free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
2345cleanup_serial_driver: 2320cleanup_serial_driver:
2346 if (tty_unregister_driver(cy_serial_driver)) 2321 if (tty_unregister_driver(cy_serial_driver))
2347 printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n"); 2322 printk(KERN_ERR
2348 put_tty_driver(cy_serial_driver); 2323 "Couldn't unregister MVME166/7 serial driver\n");
2349 return ret; 2324 put_tty_driver(cy_serial_driver);
2350} /* serial167_init */ 2325 return ret;
2326} /* serial167_init */
2351 2327
2352module_init(serial167_init); 2328module_init(serial167_init);
2353 2329
2354
2355#ifdef CYCLOM_SHOW_STATUS 2330#ifdef CYCLOM_SHOW_STATUS
2356static void 2331static void show_status(int line_num)
2357show_status(int line_num)
2358{ 2332{
2359 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2333 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2360 int channel; 2334 int channel;
2361 struct cyclades_port * info; 2335 struct cyclades_port *info;
2362 unsigned long flags; 2336 unsigned long flags;
2363 2337
2364 info = &cy_port[line_num]; 2338 info = &cy_port[line_num];
2365 channel = info->line; 2339 channel = info->line;
2366 printk(" channel %d\n", channel);/**/ 2340 printk(" channel %d\n", channel);
2367 2341 /**/ printk(" cy_port\n");
2368 printk(" cy_port\n"); 2342 printk(" card line flags = %d %d %x\n",
2369 printk(" card line flags = %d %d %x\n", 2343 info->card, info->line, info->flags);
2370 info->card, info->line, info->flags); 2344 printk
2371 printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n", 2345 (" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
2372 (long)info->tty, info->read_status_mask, 2346 (long)info->tty, info->read_status_mask, info->timeout,
2373 info->timeout, info->xmit_fifo_size); 2347 info->xmit_fifo_size);
2374 printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n", 2348 printk(" cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
2375 info->cor1, info->cor2, info->cor3, info->cor4, info->cor5, 2349 info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
2376 info->cor6, info->cor7); 2350 info->cor6, info->cor7);
2377 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", 2351 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n", info->tbpr, info->tco,
2378 info->tbpr, info->tco, info->rbpr, info->rco); 2352 info->rbpr, info->rco);
2379 printk(" close_delay event count = %d %d %d\n", 2353 printk(" close_delay event count = %d %d %d\n", info->close_delay,
2380 info->close_delay, info->event, info->count); 2354 info->event, info->count);
2381 printk(" x_char blocked_open = %x %x\n", 2355 printk(" x_char blocked_open = %x %x\n", info->x_char,
2382 info->x_char, info->blocked_open); 2356 info->blocked_open);
2383 printk(" open_wait = %lx %lx %lx\n", 2357 printk(" open_wait = %lx %lx %lx\n", (long)info->open_wait);
2384 (long)info->open_wait); 2358
2385 2359 local_irq_save(flags);
2386
2387 local_irq_save(flags);
2388 2360
2389/* Global Registers */ 2361/* Global Registers */
2390 2362
@@ -2398,7 +2370,7 @@ show_status(int line_num)
2398 printk(" CyMIR %x\n", base_addr[CyMIR]); 2370 printk(" CyMIR %x\n", base_addr[CyMIR]);
2399 printk(" CyTPR %x\n", base_addr[CyTPR]); 2371 printk(" CyTPR %x\n", base_addr[CyTPR]);
2400 2372
2401 base_addr[CyCAR] = (u_char)channel; 2373 base_addr[CyCAR] = (u_char) channel;
2402 2374
2403/* Virtual Registers */ 2375/* Virtual Registers */
2404 2376
@@ -2442,11 +2414,10 @@ show_status(int line_num)
2442 printk(" CyTBPR %x\n", base_addr[CyTBPR]); 2414 printk(" CyTBPR %x\n", base_addr[CyTBPR]);
2443 printk(" CyTCOR %x\n", base_addr[CyTCOR]); 2415 printk(" CyTCOR %x\n", base_addr[CyTCOR]);
2444 2416
2445 local_irq_restore(flags); 2417 local_irq_restore(flags);
2446} /* show_status */ 2418} /* show_status */
2447#endif 2419#endif
2448 2420
2449
2450#if 0 2421#if 0
2451/* Dummy routine in mvme16x/config.c for now */ 2422/* Dummy routine in mvme16x/config.c for now */
2452 2423
@@ -2459,61 +2430,67 @@ void console_setup(char *str, int *ints)
2459 int cflag = 0; 2430 int cflag = 0;
2460 2431
2461 /* Sanity check. */ 2432 /* Sanity check. */
2462 if (ints[0] > 3 || ints[1] > 3) return; 2433 if (ints[0] > 3 || ints[1] > 3)
2434 return;
2463 2435
2464 /* Get baud, bits and parity */ 2436 /* Get baud, bits and parity */
2465 baud = 2400; 2437 baud = 2400;
2466 bits = 8; 2438 bits = 8;
2467 parity = 'n'; 2439 parity = 'n';
2468 if (ints[2]) baud = ints[2]; 2440 if (ints[2])
2441 baud = ints[2];
2469 if ((s = strchr(str, ','))) { 2442 if ((s = strchr(str, ','))) {
2470 do { 2443 do {
2471 s++; 2444 s++;
2472 } while(*s >= '0' && *s <= '9'); 2445 } while (*s >= '0' && *s <= '9');
2473 if (*s) parity = *s++; 2446 if (*s)
2474 if (*s) bits = *s - '0'; 2447 parity = *s++;
2448 if (*s)
2449 bits = *s - '0';
2475 } 2450 }
2476 2451
2477 /* Now construct a cflag setting. */ 2452 /* Now construct a cflag setting. */
2478 switch(baud) { 2453 switch (baud) {
2479 case 1200: 2454 case 1200:
2480 cflag |= B1200; 2455 cflag |= B1200;
2481 break; 2456 break;
2482 case 9600: 2457 case 9600:
2483 cflag |= B9600; 2458 cflag |= B9600;
2484 break; 2459 break;
2485 case 19200: 2460 case 19200:
2486 cflag |= B19200; 2461 cflag |= B19200;
2487 break; 2462 break;
2488 case 38400: 2463 case 38400:
2489 cflag |= B38400; 2464 cflag |= B38400;
2490 break; 2465 break;
2491 case 2400: 2466 case 2400:
2492 default: 2467 default:
2493 cflag |= B2400; 2468 cflag |= B2400;
2494 break; 2469 break;
2495 } 2470 }
2496 switch(bits) { 2471 switch (bits) {
2497 case 7: 2472 case 7:
2498 cflag |= CS7; 2473 cflag |= CS7;
2499 break; 2474 break;
2500 default: 2475 default:
2501 case 8: 2476 case 8:
2502 cflag |= CS8; 2477 cflag |= CS8;
2503 break; 2478 break;
2504 } 2479 }
2505 switch(parity) { 2480 switch (parity) {
2506 case 'o': case 'O': 2481 case 'o':
2507 cflag |= PARODD; 2482 case 'O':
2508 break; 2483 cflag |= PARODD;
2509 case 'e': case 'E': 2484 break;
2510 cflag |= PARENB; 2485 case 'e':
2511 break; 2486 case 'E':
2487 cflag |= PARENB;
2488 break;
2512 } 2489 }
2513 2490
2514 serial_console_info = &cy_port[ints[1]]; 2491 serial_console_info = &cy_port[ints[1]];
2515 serial_console_cflag = cflag; 2492 serial_console_cflag = cflag;
2516 serial_console = ints[1] + 64; /*callout_driver.minor_start*/ 2493 serial_console = ints[1] + 64; /*callout_driver.minor_start */
2517} 2494}
2518#endif 2495#endif
2519 2496
@@ -2532,9 +2509,10 @@ void console_setup(char *str, int *ints)
2532 * The console must be locked when we get here. 2509 * The console must be locked when we get here.
2533 */ 2510 */
2534 2511
2535void serial167_console_write(struct console *co, const char *str, unsigned count) 2512void serial167_console_write(struct console *co, const char *str,
2513 unsigned count)
2536{ 2514{
2537 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2515 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2538 unsigned long flags; 2516 unsigned long flags;
2539 volatile u_char sink; 2517 volatile u_char sink;
2540 u_char ier; 2518 u_char ier;
@@ -2547,7 +2525,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
2547 /* Ensure transmitter is enabled! */ 2525 /* Ensure transmitter is enabled! */
2548 2526
2549 port = 0; 2527 port = 0;
2550 base_addr[CyCAR] = (u_char)port; 2528 base_addr[CyCAR] = (u_char) port;
2551 while (base_addr[CyCCR]) 2529 while (base_addr[CyCCR])
2552 ; 2530 ;
2553 base_addr[CyCCR] = CyENB_XMTR; 2531 base_addr[CyCCR] = CyENB_XMTR;
@@ -2556,8 +2534,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
2556 base_addr[CyIER] = CyTxMpty; 2534 base_addr[CyIER] = CyTxMpty;
2557 2535
2558 while (1) { 2536 while (1) {
2559 if (pcc2chip[PccSCCTICR] & 0x20) 2537 if (pcc2chip[PccSCCTICR] & 0x20) {
2560 {
2561 /* We have a Tx int. Acknowledge it */ 2538 /* We have a Tx int. Acknowledge it */
2562 sink = pcc2chip[PccTPIACKR]; 2539 sink = pcc2chip[PccTPIACKR];
2563 if ((base_addr[CyLICR] >> 2) == port) { 2540 if ((base_addr[CyLICR] >> 2) == port) {
@@ -2571,18 +2548,15 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
2571 str++; 2548 str++;
2572 i++; 2549 i++;
2573 do_lf = 0; 2550 do_lf = 0;
2574 } 2551 } else if (*str == '\n') {
2575 else if (*str == '\n') {
2576 base_addr[CyTDR] = '\r'; 2552 base_addr[CyTDR] = '\r';
2577 do_lf = 1; 2553 do_lf = 1;
2578 } 2554 } else {
2579 else {
2580 base_addr[CyTDR] = *str++; 2555 base_addr[CyTDR] = *str++;
2581 i++; 2556 i++;
2582 } 2557 }
2583 base_addr[CyTEOIR] = 0; 2558 base_addr[CyTEOIR] = 0;
2584 } 2559 } else
2585 else
2586 base_addr[CyTEOIR] = CyNOTRANS; 2560 base_addr[CyTEOIR] = CyNOTRANS;
2587 } 2561 }
2588 } 2562 }
@@ -2592,45 +2566,44 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
2592 local_irq_restore(flags); 2566 local_irq_restore(flags);
2593} 2567}
2594 2568
2595static struct tty_driver *serial167_console_device(struct console *c, int *index) 2569static struct tty_driver *serial167_console_device(struct console *c,
2570 int *index)
2596{ 2571{
2597 *index = c->index; 2572 *index = c->index;
2598 return cy_serial_driver; 2573 return cy_serial_driver;
2599} 2574}
2600 2575
2601
2602static int __init serial167_console_setup(struct console *co, char *options) 2576static int __init serial167_console_setup(struct console *co, char *options)
2603{ 2577{
2604 return 0; 2578 return 0;
2605} 2579}
2606 2580
2607
2608static struct console sercons = { 2581static struct console sercons = {
2609 .name = "ttyS", 2582 .name = "ttyS",
2610 .write = serial167_console_write, 2583 .write = serial167_console_write,
2611 .device = serial167_console_device, 2584 .device = serial167_console_device,
2612 .setup = serial167_console_setup, 2585 .setup = serial167_console_setup,
2613 .flags = CON_PRINTBUFFER, 2586 .flags = CON_PRINTBUFFER,
2614 .index = -1, 2587 .index = -1,
2615}; 2588};
2616 2589
2617
2618static int __init serial167_console_init(void) 2590static int __init serial167_console_init(void)
2619{ 2591{
2620 if (vme_brdtype == VME_TYPE_MVME166 || 2592 if (vme_brdtype == VME_TYPE_MVME166 ||
2621 vme_brdtype == VME_TYPE_MVME167 || 2593 vme_brdtype == VME_TYPE_MVME167 ||
2622 vme_brdtype == VME_TYPE_MVME177) { 2594 vme_brdtype == VME_TYPE_MVME177) {
2623 mvme167_serial_console_setup(0); 2595 mvme167_serial_console_setup(0);
2624 register_console(&sercons); 2596 register_console(&sercons);
2625 } 2597 }
2626 return 0; 2598 return 0;
2627} 2599}
2600
2628console_initcall(serial167_console_init); 2601console_initcall(serial167_console_init);
2629 2602
2630#ifdef CONFIG_REMOTE_DEBUG 2603#ifdef CONFIG_REMOTE_DEBUG
2631void putDebugChar (int c) 2604void putDebugChar(int c)
2632{ 2605{
2633 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2606 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2634 unsigned long flags; 2607 unsigned long flags;
2635 volatile u_char sink; 2608 volatile u_char sink;
2636 u_char ier; 2609 u_char ier;
@@ -2641,7 +2614,7 @@ void putDebugChar (int c)
2641 /* Ensure transmitter is enabled! */ 2614 /* Ensure transmitter is enabled! */
2642 2615
2643 port = DEBUG_PORT; 2616 port = DEBUG_PORT;
2644 base_addr[CyCAR] = (u_char)port; 2617 base_addr[CyCAR] = (u_char) port;
2645 while (base_addr[CyCCR]) 2618 while (base_addr[CyCCR])
2646 ; 2619 ;
2647 base_addr[CyCCR] = CyENB_XMTR; 2620 base_addr[CyCCR] = CyENB_XMTR;
@@ -2650,16 +2623,14 @@ void putDebugChar (int c)
2650 base_addr[CyIER] = CyTxMpty; 2623 base_addr[CyIER] = CyTxMpty;
2651 2624
2652 while (1) { 2625 while (1) {
2653 if (pcc2chip[PccSCCTICR] & 0x20) 2626 if (pcc2chip[PccSCCTICR] & 0x20) {
2654 {
2655 /* We have a Tx int. Acknowledge it */ 2627 /* We have a Tx int. Acknowledge it */
2656 sink = pcc2chip[PccTPIACKR]; 2628 sink = pcc2chip[PccTPIACKR];
2657 if ((base_addr[CyLICR] >> 2) == port) { 2629 if ((base_addr[CyLICR] >> 2) == port) {
2658 base_addr[CyTDR] = c; 2630 base_addr[CyTDR] = c;
2659 base_addr[CyTEOIR] = 0; 2631 base_addr[CyTEOIR] = 0;
2660 break; 2632 break;
2661 } 2633 } else
2662 else
2663 base_addr[CyTEOIR] = CyNOTRANS; 2634 base_addr[CyTEOIR] = CyNOTRANS;
2664 } 2635 }
2665 } 2636 }
@@ -2671,7 +2642,7 @@ void putDebugChar (int c)
2671 2642
2672int getDebugChar() 2643int getDebugChar()
2673{ 2644{
2674 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2645 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2675 unsigned long flags; 2646 unsigned long flags;
2676 volatile u_char sink; 2647 volatile u_char sink;
2677 u_char ier; 2648 u_char ier;
@@ -2693,7 +2664,7 @@ int getDebugChar()
2693 /* Ensure receiver is enabled! */ 2664 /* Ensure receiver is enabled! */
2694 2665
2695 port = DEBUG_PORT; 2666 port = DEBUG_PORT;
2696 base_addr[CyCAR] = (u_char)port; 2667 base_addr[CyCAR] = (u_char) port;
2697#if 0 2668#if 0
2698 while (base_addr[CyCCR]) 2669 while (base_addr[CyCCR])
2699 ; 2670 ;
@@ -2703,31 +2674,30 @@ int getDebugChar()
2703 base_addr[CyIER] = CyRxData; 2674 base_addr[CyIER] = CyRxData;
2704 2675
2705 while (1) { 2676 while (1) {
2706 if (pcc2chip[PccSCCRICR] & 0x20) 2677 if (pcc2chip[PccSCCRICR] & 0x20) {
2707 {
2708 /* We have a Rx int. Acknowledge it */ 2678 /* We have a Rx int. Acknowledge it */
2709 sink = pcc2chip[PccRPIACKR]; 2679 sink = pcc2chip[PccRPIACKR];
2710 if ((base_addr[CyLICR] >> 2) == port) { 2680 if ((base_addr[CyLICR] >> 2) == port) {
2711 int cnt = base_addr[CyRFOC]; 2681 int cnt = base_addr[CyRFOC];
2712 while (cnt-- > 0) 2682 while (cnt-- > 0) {
2713 {
2714 c = base_addr[CyRDR]; 2683 c = base_addr[CyRDR];
2715 if (c == 0) 2684 if (c == 0)
2716 printk ("!! debug char is null (cnt=%d) !!", cnt); 2685 printk
2686 ("!! debug char is null (cnt=%d) !!",
2687 cnt);
2717 else 2688 else
2718 queueDebugChar (c); 2689 queueDebugChar(c);
2719 } 2690 }
2720 base_addr[CyREOIR] = 0; 2691 base_addr[CyREOIR] = 0;
2721 i = debugiq.out; 2692 i = debugiq.out;
2722 if (i == debugiq.in) 2693 if (i == debugiq.in)
2723 panic ("Debug input queue empty!"); 2694 panic("Debug input queue empty!");
2724 c = debugiq.buf[i]; 2695 c = debugiq.buf[i];
2725 if (++i == DEBUG_LEN) 2696 if (++i == DEBUG_LEN)
2726 i = 0; 2697 i = 0;
2727 debugiq.out = i; 2698 debugiq.out = i;
2728 break; 2699 break;
2729 } 2700 } else
2730 else
2731 base_addr[CyREOIR] = CyNOTRANS; 2701 base_addr[CyREOIR] = CyNOTRANS;
2732 } 2702 }
2733 } 2703 }
@@ -2739,7 +2709,7 @@ int getDebugChar()
2739 return (c); 2709 return (c);
2740} 2710}
2741 2711
2742void queueDebugChar (int c) 2712void queueDebugChar(int c)
2743{ 2713{
2744 int i; 2714 int i;
2745 2715
@@ -2751,73 +2721,71 @@ void queueDebugChar (int c)
2751 debugiq.in = i; 2721 debugiq.in = i;
2752} 2722}
2753 2723
2754static void 2724static void debug_setup()
2755debug_setup()
2756{ 2725{
2757 unsigned long flags; 2726 unsigned long flags;
2758 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 2727 volatile unsigned char *base_addr = (u_char *) BASE_ADDR;
2759 int i, cflag; 2728 int i, cflag;
2760 2729
2761 cflag = B19200; 2730 cflag = B19200;
2762 2731
2763 local_irq_save(flags); 2732 local_irq_save(flags);
2764 2733
2765 for (i = 0; i < 4; i++) 2734 for (i = 0; i < 4; i++) {
2766 { 2735 base_addr[CyCAR] = i;
2767 base_addr[CyCAR] = i; 2736 base_addr[CyLICR] = i << 2;
2768 base_addr[CyLICR] = i << 2; 2737 }
2769 }
2770 2738
2771 debugiq.in = debugiq.out = 0; 2739 debugiq.in = debugiq.out = 0;
2772 2740
2773 base_addr[CyCAR] = DEBUG_PORT; 2741 base_addr[CyCAR] = DEBUG_PORT;
2774 2742
2775 /* baud rate */ 2743 /* baud rate */
2776 i = cflag & CBAUD; 2744 i = cflag & CBAUD;
2777 2745
2778 base_addr[CyIER] = 0; 2746 base_addr[CyIER] = 0;
2779 2747
2780 base_addr[CyCMR] = CyASYNC; 2748 base_addr[CyCMR] = CyASYNC;
2781 base_addr[CyLICR] = DEBUG_PORT << 2; 2749 base_addr[CyLICR] = DEBUG_PORT << 2;
2782 base_addr[CyLIVR] = 0x5c; 2750 base_addr[CyLIVR] = 0x5c;
2783 2751
2784 /* tx and rx baud rate */ 2752 /* tx and rx baud rate */
2785 2753
2786 base_addr[CyTCOR] = baud_co[i]; 2754 base_addr[CyTCOR] = baud_co[i];
2787 base_addr[CyTBPR] = baud_bpr[i]; 2755 base_addr[CyTBPR] = baud_bpr[i];
2788 base_addr[CyRCOR] = baud_co[i] >> 5; 2756 base_addr[CyRCOR] = baud_co[i] >> 5;
2789 base_addr[CyRBPR] = baud_bpr[i]; 2757 base_addr[CyRBPR] = baud_bpr[i];
2790 2758
2791 /* set line characteristics according configuration */ 2759 /* set line characteristics according configuration */
2792 2760
2793 base_addr[CySCHR1] = 0; 2761 base_addr[CySCHR1] = 0;
2794 base_addr[CySCHR2] = 0; 2762 base_addr[CySCHR2] = 0;
2795 base_addr[CySCRL] = 0; 2763 base_addr[CySCRL] = 0;
2796 base_addr[CySCRH] = 0; 2764 base_addr[CySCRH] = 0;
2797 base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE; 2765 base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
2798 base_addr[CyCOR2] = 0; 2766 base_addr[CyCOR2] = 0;
2799 base_addr[CyCOR3] = Cy_1_STOP; 2767 base_addr[CyCOR3] = Cy_1_STOP;
2800 base_addr[CyCOR4] = baud_cor4[i]; 2768 base_addr[CyCOR4] = baud_cor4[i];
2801 base_addr[CyCOR5] = 0; 2769 base_addr[CyCOR5] = 0;
2802 base_addr[CyCOR6] = 0; 2770 base_addr[CyCOR6] = 0;
2803 base_addr[CyCOR7] = 0; 2771 base_addr[CyCOR7] = 0;
2804 2772
2805 write_cy_cmd(base_addr,CyINIT_CHAN); 2773 write_cy_cmd(base_addr, CyINIT_CHAN);
2806 write_cy_cmd(base_addr,CyENB_RCVR); 2774 write_cy_cmd(base_addr, CyENB_RCVR);
2807 2775
2808 base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */ 2776 base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */
2809 2777
2810 base_addr[CyRTPRL] = 2; 2778 base_addr[CyRTPRL] = 2;
2811 base_addr[CyRTPRH] = 0; 2779 base_addr[CyRTPRH] = 0;
2812 2780
2813 base_addr[CyMSVR1] = CyRTS; 2781 base_addr[CyMSVR1] = CyRTS;
2814 base_addr[CyMSVR2] = CyDTR; 2782 base_addr[CyMSVR2] = CyDTR;
2815 2783
2816 base_addr[CyIER] = CyRxData; 2784 base_addr[CyIER] = CyRxData;
2817 2785
2818 local_irq_restore(flags); 2786 local_irq_restore(flags);
2819 2787
2820} /* debug_setup */ 2788} /* debug_setup */
2821 2789
2822#endif 2790#endif
2823 2791
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 20946f5127e0..92043c8f2355 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2350,10 +2350,8 @@ static void do_softint(struct work_struct *work)
2350 return; 2350 return;
2351 } 2351 }
2352 2352
2353 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event)) { 2353 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &port->event))
2354 tty_wakeup(tty); 2354 tty_wakeup(tty);
2355 //wake_up_interruptible(&tty->write_wait);
2356 }
2357 2355
2358 func_exit(); 2356 func_exit();
2359} 2357}
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 3fa625db9e4b..bf76db1342c5 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -1148,10 +1148,8 @@ static void mgsl_bh_transmit(struct mgsl_struct *info)
1148 printk( "%s(%d):mgsl_bh_transmit() entry on %s\n", 1148 printk( "%s(%d):mgsl_bh_transmit() entry on %s\n",
1149 __FILE__,__LINE__,info->device_name); 1149 __FILE__,__LINE__,info->device_name);
1150 1150
1151 if (tty) { 1151 if (tty)
1152 tty_wakeup(tty); 1152 tty_wakeup(tty);
1153 wake_up_interruptible(&tty->write_wait);
1154 }
1155 1153
1156 /* if transmitter idle and loopmode_send_done_requested 1154 /* if transmitter idle and loopmode_send_done_requested
1157 * then start echoing RxD to TxD 1155 * then start echoing RxD to TxD
@@ -2340,7 +2338,6 @@ static void mgsl_flush_buffer(struct tty_struct *tty)
2340 del_timer(&info->tx_timer); 2338 del_timer(&info->tx_timer);
2341 spin_unlock_irqrestore(&info->irq_spinlock,flags); 2339 spin_unlock_irqrestore(&info->irq_spinlock,flags);
2342 2340
2343 wake_up_interruptible(&tty->write_wait);
2344 tty_wakeup(tty); 2341 tty_wakeup(tty);
2345} 2342}
2346 2343
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 792c79c315e0..54af763518fe 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1045,7 +1045,6 @@ static void flush_buffer(struct tty_struct *tty)
1045 info->tx_count = 0; 1045 info->tx_count = 0;
1046 spin_unlock_irqrestore(&info->lock,flags); 1046 spin_unlock_irqrestore(&info->lock,flags);
1047 1047
1048 wake_up_interruptible(&tty->write_wait);
1049 tty_wakeup(tty); 1048 tty_wakeup(tty);
1050} 1049}
1051 1050
@@ -1933,10 +1932,8 @@ static void bh_transmit(struct slgt_info *info)
1933 struct tty_struct *tty = info->tty; 1932 struct tty_struct *tty = info->tty;
1934 1933
1935 DBGBH(("%s bh_transmit\n", info->device_name)); 1934 DBGBH(("%s bh_transmit\n", info->device_name));
1936 if (tty) { 1935 if (tty)
1937 tty_wakeup(tty); 1936 tty_wakeup(tty);
1938 wake_up_interruptible(&tty->write_wait);
1939 }
1940} 1937}
1941 1938
1942static void dsr_change(struct slgt_info *info) 1939static void dsr_change(struct slgt_info *info)
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 8f4d67afe5bf..ebde4e552335 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -1258,7 +1258,6 @@ static void flush_buffer(struct tty_struct *tty)
1258 del_timer(&info->tx_timer); 1258 del_timer(&info->tx_timer);
1259 spin_unlock_irqrestore(&info->lock,flags); 1259 spin_unlock_irqrestore(&info->lock,flags);
1260 1260
1261 wake_up_interruptible(&tty->write_wait);
1262 tty_wakeup(tty); 1261 tty_wakeup(tty);
1263} 1262}
1264 1263
@@ -2127,10 +2126,8 @@ void bh_transmit(SLMP_INFO *info)
2127 printk( "%s(%d):%s bh_transmit() entry\n", 2126 printk( "%s(%d):%s bh_transmit() entry\n",
2128 __FILE__,__LINE__,info->device_name); 2127 __FILE__,__LINE__,info->device_name);
2129 2128
2130 if (tty) { 2129 if (tty)
2131 tty_wakeup(tty); 2130 tty_wakeup(tty);
2132 wake_up_interruptible(&tty->write_wait);
2133 }
2134} 2131}
2135 2132
2136void bh_status(SLMP_INFO *info) 2133void bh_status(SLMP_INFO *info)
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 7fd3cd5ddf21..3757610b7835 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -88,9 +88,9 @@ static struct sysrq_key_op sysrq_loglevel_op = {
88#ifdef CONFIG_VT 88#ifdef CONFIG_VT
89static void sysrq_handle_SAK(int key, struct tty_struct *tty) 89static void sysrq_handle_SAK(int key, struct tty_struct *tty)
90{ 90{
91 if (tty) 91 struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work;
92 do_SAK(tty); 92 PREPARE_WORK(SAK_work, vc_SAK);
93 reset_vc(vc_cons[fg_console].d); 93 schedule_work(SAK_work);
94} 94}
95static struct sysrq_key_op sysrq_SAK_op = { 95static struct sysrq_key_op sysrq_SAK_op = {
96 .handler = sysrq_handle_SAK, 96 .handler = sysrq_handle_SAK,
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index 07067c31c4ec..c346ec5a3dc9 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -68,6 +68,7 @@
68#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/stat.h> 69#include <linux/stat.h>
70#include <linux/proc_fs.h> 70#include <linux/proc_fs.h>
71#include <linux/seq_file.h>
71 72
72#include <linux/toshiba.h> 73#include <linux/toshiba.h>
73 74
@@ -298,12 +299,10 @@ static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
298 * Print the information for /proc/toshiba 299 * Print the information for /proc/toshiba
299 */ 300 */
300#ifdef CONFIG_PROC_FS 301#ifdef CONFIG_PROC_FS
301static int tosh_get_info(char *buffer, char **start, off_t fpos, int length) 302static int proc_toshiba_show(struct seq_file *m, void *v)
302{ 303{
303 char *temp;
304 int key; 304 int key;
305 305
306 temp = buffer;
307 key = tosh_fn_status(); 306 key = tosh_fn_status();
308 307
309 /* Arguments 308 /* Arguments
@@ -314,8 +313,7 @@ static int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
314 4) BIOS date (in SCI date format) 313 4) BIOS date (in SCI date format)
315 5) Fn Key status 314 5) Fn Key status
316 */ 315 */
317 316 seq_printf(m, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
318 temp += sprintf(temp, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
319 tosh_id, 317 tosh_id,
320 (tosh_sci & 0xff00)>>8, 318 (tosh_sci & 0xff00)>>8,
321 tosh_sci & 0xff, 319 tosh_sci & 0xff,
@@ -323,9 +321,21 @@ static int tosh_get_info(char *buffer, char **start, off_t fpos, int length)
323 tosh_bios & 0xff, 321 tosh_bios & 0xff,
324 tosh_date, 322 tosh_date,
325 key); 323 key);
324 return 0;
325}
326 326
327 return temp-buffer; 327static int proc_toshiba_open(struct inode *inode, struct file *file)
328{
329 return single_open(file, proc_toshiba_show, NULL);
328} 330}
331
332static const struct file_operations proc_toshiba_fops = {
333 .owner = THIS_MODULE,
334 .open = proc_toshiba_open,
335 .read = seq_read,
336 .llseek = seq_lseek,
337 .release = single_release,
338};
329#endif 339#endif
330 340
331 341
@@ -508,10 +518,15 @@ static int __init toshiba_init(void)
508 return retval; 518 return retval;
509 519
510#ifdef CONFIG_PROC_FS 520#ifdef CONFIG_PROC_FS
511 /* register the proc entry */ 521 {
512 if (create_proc_info_entry("toshiba", 0, NULL, tosh_get_info) == NULL) { 522 struct proc_dir_entry *pde;
513 misc_deregister(&tosh_device); 523
514 return -ENOMEM; 524 pde = create_proc_entry("toshiba", 0, NULL);
525 if (!pde) {
526 misc_deregister(&tosh_device);
527 return -ENOMEM;
528 }
529 pde->proc_fops = &proc_toshiba_fops;
515 } 530 }
516#endif 531#endif
517 532
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 47a6eacb10bc..558ca927e32b 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -154,7 +154,7 @@ static int tty_release(struct inode *, struct file *);
154int tty_ioctl(struct inode * inode, struct file * file, 154int tty_ioctl(struct inode * inode, struct file * file,
155 unsigned int cmd, unsigned long arg); 155 unsigned int cmd, unsigned long arg);
156static int tty_fasync(int fd, struct file * filp, int on); 156static int tty_fasync(int fd, struct file * filp, int on);
157static void release_mem(struct tty_struct *tty, int idx); 157static void release_tty(struct tty_struct *tty, int idx);
158 158
159/** 159/**
160 * alloc_tty_struct - allocate a tty object 160 * alloc_tty_struct - allocate a tty object
@@ -1612,7 +1612,6 @@ void start_tty(struct tty_struct *tty)
1612 1612
1613 /* If we have a running line discipline it may need kicking */ 1613 /* If we have a running line discipline it may need kicking */
1614 tty_wakeup(tty); 1614 tty_wakeup(tty);
1615 wake_up_interruptible(&tty->write_wait);
1616} 1615}
1617 1616
1618EXPORT_SYMBOL(start_tty); 1617EXPORT_SYMBOL(start_tty);
@@ -2003,7 +2002,7 @@ static int init_dev(struct tty_driver *driver, int idx,
2003 2002
2004 /* 2003 /*
2005 * All structures have been allocated, so now we install them. 2004 * All structures have been allocated, so now we install them.
2006 * Failures after this point use release_mem to clean up, so 2005 * Failures after this point use release_tty to clean up, so
2007 * there's no need to null out the local pointers. 2006 * there's no need to null out the local pointers.
2008 */ 2007 */
2009 if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) { 2008 if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) {
@@ -2024,8 +2023,8 @@ static int init_dev(struct tty_driver *driver, int idx,
2024 2023
2025 /* 2024 /*
2026 * Structures all installed ... call the ldisc open routines. 2025 * Structures all installed ... call the ldisc open routines.
2027 * If we fail here just call release_mem to clean up. No need 2026 * If we fail here just call release_tty to clean up. No need
2028 * to decrement the use counts, as release_mem doesn't care. 2027 * to decrement the use counts, as release_tty doesn't care.
2029 */ 2028 */
2030 2029
2031 if (tty->ldisc.open) { 2030 if (tty->ldisc.open) {
@@ -2095,17 +2094,17 @@ fail_no_mem:
2095 retval = -ENOMEM; 2094 retval = -ENOMEM;
2096 goto end_init; 2095 goto end_init;
2097 2096
2098 /* call the tty release_mem routine to clean out this slot */ 2097 /* call the tty release_tty routine to clean out this slot */
2099release_mem_out: 2098release_mem_out:
2100 if (printk_ratelimit()) 2099 if (printk_ratelimit())
2101 printk(KERN_INFO "init_dev: ldisc open failed, " 2100 printk(KERN_INFO "init_dev: ldisc open failed, "
2102 "clearing slot %d\n", idx); 2101 "clearing slot %d\n", idx);
2103 release_mem(tty, idx); 2102 release_tty(tty, idx);
2104 goto end_init; 2103 goto end_init;
2105} 2104}
2106 2105
2107/** 2106/**
2108 * release_mem - release tty structure memory 2107 * release_one_tty - release tty structure memory
2109 * 2108 *
2110 * Releases memory associated with a tty structure, and clears out the 2109 * Releases memory associated with a tty structure, and clears out the
2111 * driver table slots. This function is called when a device is no longer 2110 * driver table slots. This function is called when a device is no longer
@@ -2117,37 +2116,14 @@ release_mem_out:
2117 * of ttys that the driver keeps. 2116 * of ttys that the driver keeps.
2118 * FIXME: should we require tty_mutex is held here ?? 2117 * FIXME: should we require tty_mutex is held here ??
2119 */ 2118 */
2120 2119static void release_one_tty(struct tty_struct *tty, int idx)
2121static void release_mem(struct tty_struct *tty, int idx)
2122{ 2120{
2123 struct tty_struct *o_tty;
2124 struct ktermios *tp;
2125 int devpts = tty->driver->flags & TTY_DRIVER_DEVPTS_MEM; 2121 int devpts = tty->driver->flags & TTY_DRIVER_DEVPTS_MEM;
2126 2122 struct ktermios *tp;
2127 if ((o_tty = tty->link) != NULL) {
2128 if (!devpts)
2129 o_tty->driver->ttys[idx] = NULL;
2130 if (o_tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
2131 tp = o_tty->termios;
2132 if (!devpts)
2133 o_tty->driver->termios[idx] = NULL;
2134 kfree(tp);
2135
2136 tp = o_tty->termios_locked;
2137 if (!devpts)
2138 o_tty->driver->termios_locked[idx] = NULL;
2139 kfree(tp);
2140 }
2141 o_tty->magic = 0;
2142 o_tty->driver->refcount--;
2143 file_list_lock();
2144 list_del_init(&o_tty->tty_files);
2145 file_list_unlock();
2146 free_tty_struct(o_tty);
2147 }
2148 2123
2149 if (!devpts) 2124 if (!devpts)
2150 tty->driver->ttys[idx] = NULL; 2125 tty->driver->ttys[idx] = NULL;
2126
2151 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) { 2127 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
2152 tp = tty->termios; 2128 tp = tty->termios;
2153 if (!devpts) 2129 if (!devpts)
@@ -2160,15 +2136,39 @@ static void release_mem(struct tty_struct *tty, int idx)
2160 kfree(tp); 2136 kfree(tp);
2161 } 2137 }
2162 2138
2139
2163 tty->magic = 0; 2140 tty->magic = 0;
2164 tty->driver->refcount--; 2141 tty->driver->refcount--;
2142
2165 file_list_lock(); 2143 file_list_lock();
2166 list_del_init(&tty->tty_files); 2144 list_del_init(&tty->tty_files);
2167 file_list_unlock(); 2145 file_list_unlock();
2168 module_put(tty->driver->owner); 2146
2169 free_tty_struct(tty); 2147 free_tty_struct(tty);
2170} 2148}
2171 2149
2150/**
2151 * release_tty - release tty structure memory
2152 *
2153 * Release both @tty and a possible linked partner (think pty pair),
2154 * and decrement the refcount of the backing module.
2155 *
2156 * Locking:
2157 * tty_mutex - sometimes only
2158 * takes the file list lock internally when working on the list
2159 * of ttys that the driver keeps.
2160 * FIXME: should we require tty_mutex is held here ??
2161 */
2162static void release_tty(struct tty_struct *tty, int idx)
2163{
2164 struct tty_driver *driver = tty->driver;
2165
2166 if (tty->link)
2167 release_one_tty(tty->link, idx);
2168 release_one_tty(tty, idx);
2169 module_put(driver->owner);
2170}
2171
2172/* 2172/*
2173 * Even releasing the tty structures is a tricky business.. We have 2173 * Even releasing the tty structures is a tricky business.. We have
2174 * to be very careful that the structures are all released at the 2174 * to be very careful that the structures are all released at the
@@ -2436,10 +2436,10 @@ static void release_dev(struct file * filp)
2436 tty_set_termios_ldisc(o_tty,N_TTY); 2436 tty_set_termios_ldisc(o_tty,N_TTY);
2437 } 2437 }
2438 /* 2438 /*
2439 * The release_mem function takes care of the details of clearing 2439 * The release_tty function takes care of the details of clearing
2440 * the slots and preserving the termios structure. 2440 * the slots and preserving the termios structure.
2441 */ 2441 */
2442 release_mem(tty, idx); 2442 release_tty(tty, idx);
2443 2443
2444#ifdef CONFIG_UNIX98_PTYS 2444#ifdef CONFIG_UNIX98_PTYS
2445 /* Make this pty number available for reallocation */ 2445 /* Make this pty number available for reallocation */
@@ -3324,10 +3324,8 @@ int tty_ioctl(struct inode * inode, struct file * file,
3324 * Nasty bug: do_SAK is being called in interrupt context. This can 3324 * Nasty bug: do_SAK is being called in interrupt context. This can
3325 * deadlock. We punt it up to process context. AKPM - 16Mar2001 3325 * deadlock. We punt it up to process context. AKPM - 16Mar2001
3326 */ 3326 */
3327static void __do_SAK(struct work_struct *work) 3327void __do_SAK(struct tty_struct *tty)
3328{ 3328{
3329 struct tty_struct *tty =
3330 container_of(work, struct tty_struct, SAK_work);
3331#ifdef TTY_SOFT_SAK 3329#ifdef TTY_SOFT_SAK
3332 tty_hangup(tty); 3330 tty_hangup(tty);
3333#else 3331#else
@@ -3394,6 +3392,13 @@ static void __do_SAK(struct work_struct *work)
3394#endif 3392#endif
3395} 3393}
3396 3394
3395static void do_SAK_work(struct work_struct *work)
3396{
3397 struct tty_struct *tty =
3398 container_of(work, struct tty_struct, SAK_work);
3399 __do_SAK(tty);
3400}
3401
3397/* 3402/*
3398 * The tq handling here is a little racy - tty->SAK_work may already be queued. 3403 * The tq handling here is a little racy - tty->SAK_work may already be queued.
3399 * Fortunately we don't need to worry, because if ->SAK_work is already queued, 3404 * Fortunately we don't need to worry, because if ->SAK_work is already queued,
@@ -3404,7 +3409,7 @@ void do_SAK(struct tty_struct *tty)
3404{ 3409{
3405 if (!tty) 3410 if (!tty)
3406 return; 3411 return;
3407 PREPARE_WORK(&tty->SAK_work, __do_SAK); 3412 PREPARE_WORK(&tty->SAK_work, do_SAK_work);
3408 schedule_work(&tty->SAK_work); 3413 schedule_work(&tty->SAK_work);
3409} 3414}
3410 3415
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index dee47f40c6a3..fd471cb3338f 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -225,7 +225,7 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
225 225
226/** 226/**
227 * tty_termios_encode_baud_rate 227 * tty_termios_encode_baud_rate
228 * @termios: termios structure 228 * @termios: ktermios structure holding user requested state
229 * @ispeed: input speed 229 * @ispeed: input speed
230 * @ospeed: output speed 230 * @ospeed: output speed
231 * 231 *
@@ -233,7 +233,10 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
233 * used as a library helper for drivers os that they can report back 233 * used as a library helper for drivers os that they can report back
234 * the actual speed selected when it differs from the speed requested 234 * the actual speed selected when it differs from the speed requested
235 * 235 *
236 * For now input and output speed must agree. 236 * For maximal back compatibility with legacy SYS5/POSIX *nix behaviour
237 * we need to carefully set the bits when the user does not get the
238 * desired speed. We allow small margins and preserve as much of possible
239 * of the input intent to keep compatiblity.
237 * 240 *
238 * Locking: Caller should hold termios lock. This is already held 241 * Locking: Caller should hold termios lock. This is already held
239 * when calling this function from the driver termios handler. 242 * when calling this function from the driver termios handler.
@@ -242,32 +245,44 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
242void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud) 245void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud)
243{ 246{
244 int i = 0; 247 int i = 0;
245 int ifound = 0, ofound = 0; 248 int ifound = -1, ofound = -1;
249 int iclose = ibaud/50, oclose = obaud/50;
250 int ibinput = 0;
246 251
247 termios->c_ispeed = ibaud; 252 termios->c_ispeed = ibaud;
248 termios->c_ospeed = obaud; 253 termios->c_ospeed = obaud;
249 254
255 /* If the user asked for a precise weird speed give a precise weird
256 answer. If they asked for a Bfoo speed they many have problems
257 digesting non-exact replies so fuzz a bit */
258
259 if ((termios->c_cflag & CBAUD) == BOTHER)
260 oclose = 0;
261 if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
262 iclose = 0;
263 if ((termios->c_cflag >> IBSHIFT) & CBAUD)
264 ibinput = 1; /* An input speed was specified */
265
250 termios->c_cflag &= ~CBAUD; 266 termios->c_cflag &= ~CBAUD;
251 /* Identical speed means no input encoding (ie B0 << IBSHIFT)*/
252 if (termios->c_ispeed == termios->c_ospeed)
253 ifound = 1;
254 267
255 do { 268 do {
256 if (obaud == baud_table[i]) { 269 if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
257 termios->c_cflag |= baud_bits[i]; 270 termios->c_cflag |= baud_bits[i];
258 ofound = 1; 271 ofound = i;
259 /* So that if ibaud == obaud we don't set it */
260 continue;
261 } 272 }
262 if (ibaud == baud_table[i]) { 273 if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
263 termios->c_cflag |= (baud_bits[i] << IBSHIFT); 274 /* For the case input == output don't set IBAUD bits if the user didn't do so */
264 ifound = 1; 275 if (ofound != i || ibinput)
276 termios->c_cflag |= (baud_bits[i] << IBSHIFT);
277 ifound = i;
265 } 278 }
266 } 279 }
267 while(++i < n_baud_table); 280 while(++i < n_baud_table);
268 if (!ofound) 281 if (ofound == -1)
269 termios->c_cflag |= BOTHER; 282 termios->c_cflag |= BOTHER;
270 if (!ifound) 283 /* Set exact input bits only if the input and output differ or the
284 user already did */
285 if (ifound == -1 && (ibaud != obaud || ibinput))
271 termios->c_cflag |= (BOTHER << IBSHIFT); 286 termios->c_cflag |= (BOTHER << IBSHIFT);
272} 287}
273 288
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 06c32a3e3ca4..13299b8fdbd6 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -136,9 +136,6 @@ const struct consw *conswitchp;
136#define DEFAULT_BELL_PITCH 750 136#define DEFAULT_BELL_PITCH 750
137#define DEFAULT_BELL_DURATION (HZ/8) 137#define DEFAULT_BELL_DURATION (HZ/8)
138 138
139extern void vcs_make_sysfs(struct tty_struct *tty);
140extern void vcs_remove_sysfs(struct tty_struct *tty);
141
142struct vc vc_cons [MAX_NR_CONSOLES]; 139struct vc vc_cons [MAX_NR_CONSOLES];
143 140
144#ifndef VT_SINGLE_DRIVER 141#ifndef VT_SINGLE_DRIVER
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index dc8368ebb1ac..3a5d301e783b 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -672,7 +672,8 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
672 vc->vt_mode = tmp; 672 vc->vt_mode = tmp;
673 /* the frsig is ignored, so we set it to 0 */ 673 /* the frsig is ignored, so we set it to 0 */
674 vc->vt_mode.frsig = 0; 674 vc->vt_mode.frsig = 0;
675 put_pid(xchg(&vc->vt_pid, get_pid(task_pid(current)))); 675 put_pid(vc->vt_pid);
676 vc->vt_pid = get_pid(task_pid(current));
676 /* no switch is required -- saw@shade.msu.ru */ 677 /* no switch is required -- saw@shade.msu.ru */
677 vc->vt_newvt = -1; 678 vc->vt_newvt = -1;
678 release_console_sem(); 679 release_console_sem();
@@ -1063,12 +1064,35 @@ void reset_vc(struct vc_data *vc)
1063 vc->vt_mode.relsig = 0; 1064 vc->vt_mode.relsig = 0;
1064 vc->vt_mode.acqsig = 0; 1065 vc->vt_mode.acqsig = 0;
1065 vc->vt_mode.frsig = 0; 1066 vc->vt_mode.frsig = 0;
1066 put_pid(xchg(&vc->vt_pid, NULL)); 1067 put_pid(vc->vt_pid);
1068 vc->vt_pid = NULL;
1067 vc->vt_newvt = -1; 1069 vc->vt_newvt = -1;
1068 if (!in_interrupt()) /* Via keyboard.c:SAK() - akpm */ 1070 if (!in_interrupt()) /* Via keyboard.c:SAK() - akpm */
1069 reset_palette(vc); 1071 reset_palette(vc);
1070} 1072}
1071 1073
1074void vc_SAK(struct work_struct *work)
1075{
1076 struct vc *vc_con =
1077 container_of(work, struct vc, SAK_work);
1078 struct vc_data *vc;
1079 struct tty_struct *tty;
1080
1081 acquire_console_sem();
1082 vc = vc_con->d;
1083 if (vc) {
1084 tty = vc->vc_tty;
1085 /*
1086 * SAK should also work in all raw modes and reset
1087 * them properly.
1088 */
1089 if (tty)
1090 __do_SAK(tty);
1091 reset_vc(vc);
1092 }
1093 release_console_sem();
1094}
1095
1072/* 1096/*
1073 * Performs the back end of a vt switch 1097 * Performs the back end of a vt switch
1074 */ 1098 */
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 5c261e1f92b2..d8806e4f1829 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -233,6 +233,8 @@ edd_show_interface(struct edd_device *edev, char *buf)
233 233
234/** 234/**
235 * edd_show_raw_data() - copies raw data to buffer for userspace to parse 235 * edd_show_raw_data() - copies raw data to buffer for userspace to parse
236 * @edev: target edd_device
237 * @buf: output buffer
236 * 238 *
237 * Returns: number of bytes written, or -EINVAL on failure 239 * Returns: number of bytes written, or -EINVAL on failure
238 */ 240 */
@@ -634,8 +636,8 @@ static decl_subsys(edd,&ktype_edd,NULL);
634 636
635/** 637/**
636 * edd_dev_is_type() - is this EDD device a 'type' device? 638 * edd_dev_is_type() - is this EDD device a 'type' device?
637 * @edev 639 * @edev: target edd_device
638 * @type - a host bus or interface identifier string per the EDD spec 640 * @type: a host bus or interface identifier string per the EDD spec
639 * 641 *
640 * Returns 1 (TRUE) if it is a 'type' device, 0 otherwise. 642 * Returns 1 (TRUE) if it is a 'type' device, 0 otherwise.
641 */ 643 */
@@ -657,7 +659,7 @@ edd_dev_is_type(struct edd_device *edev, const char *type)
657 659
658/** 660/**
659 * edd_get_pci_dev() - finds pci_dev that matches edev 661 * edd_get_pci_dev() - finds pci_dev that matches edev
660 * @edev - edd_device 662 * @edev: edd_device
661 * 663 *
662 * Returns pci_dev if found, or NULL 664 * Returns pci_dev if found, or NULL
663 */ 665 */
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index aa049dab3d95..ad49bd823ebd 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -413,7 +413,6 @@ void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void
413 while (p->name != NULL) { 413 while (p->name != NULL) {
414 ent = create_proc_entry(p->name, p->mode, dir); 414 ent = create_proc_entry(p->name, p->mode, dir);
415 if (!ent) return; 415 if (!ent) return;
416 ent->nlink = 1;
417 ent->data = data; 416 ent->data = data;
418 ent->read_proc = p->read_proc; 417 ent->read_proc = p->read_proc;
419 ent->write_proc = p->write_proc; 418 ent->write_proc = p->write_proc;
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 9291a86ca053..6ebfa27e4e16 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -134,14 +134,13 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
135 return ERR_PTR(-EINVAL); 135 return ERR_PTR(-EINVAL);
136 136
137 my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL); 137 my_cq = kmem_cache_zalloc(cq_cache, GFP_KERNEL);
138 if (!my_cq) { 138 if (!my_cq) {
139 ehca_err(device, "Out of memory for ehca_cq struct device=%p", 139 ehca_err(device, "Out of memory for ehca_cq struct device=%p",
140 device); 140 device);
141 return ERR_PTR(-ENOMEM); 141 return ERR_PTR(-ENOMEM);
142 } 142 }
143 143
144 memset(my_cq, 0, sizeof(struct ehca_cq));
145 memset(&param, 0, sizeof(struct ehca_alloc_cq_parms)); 144 memset(&param, 0, sizeof(struct ehca_alloc_cq_parms));
146 145
147 spin_lock_init(&my_cq->spinlock); 146 spin_lock_init(&my_cq->spinlock);
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index cfb362a1029c..d22ab563633f 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -53,9 +53,8 @@ static struct ehca_mr *ehca_mr_new(void)
53{ 53{
54 struct ehca_mr *me; 54 struct ehca_mr *me;
55 55
56 me = kmem_cache_alloc(mr_cache, GFP_KERNEL); 56 me = kmem_cache_zalloc(mr_cache, GFP_KERNEL);
57 if (me) { 57 if (me) {
58 memset(me, 0, sizeof(struct ehca_mr));
59 spin_lock_init(&me->mrlock); 58 spin_lock_init(&me->mrlock);
60 } else 59 } else
61 ehca_gen_err("alloc failed"); 60 ehca_gen_err("alloc failed");
@@ -72,9 +71,8 @@ static struct ehca_mw *ehca_mw_new(void)
72{ 71{
73 struct ehca_mw *me; 72 struct ehca_mw *me;
74 73
75 me = kmem_cache_alloc(mw_cache, GFP_KERNEL); 74 me = kmem_cache_zalloc(mw_cache, GFP_KERNEL);
76 if (me) { 75 if (me) {
77 memset(me, 0, sizeof(struct ehca_mw));
78 spin_lock_init(&me->mwlock); 76 spin_lock_init(&me->mwlock);
79 } else 77 } else
80 ehca_gen_err("alloc failed"); 78 ehca_gen_err("alloc failed");
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index d5345e5b3cd6..79d0591a8043 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -50,14 +50,13 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
50{ 50{
51 struct ehca_pd *pd; 51 struct ehca_pd *pd;
52 52
53 pd = kmem_cache_alloc(pd_cache, GFP_KERNEL); 53 pd = kmem_cache_zalloc(pd_cache, GFP_KERNEL);
54 if (!pd) { 54 if (!pd) {
55 ehca_err(device, "device=%p context=%p out of memory", 55 ehca_err(device, "device=%p context=%p out of memory",
56 device, context); 56 device, context);
57 return ERR_PTR(-ENOMEM); 57 return ERR_PTR(-ENOMEM);
58 } 58 }
59 59
60 memset(pd, 0, sizeof(struct ehca_pd));
61 pd->ownpid = current->tgid; 60 pd->ownpid = current->tgid;
62 61
63 /* 62 /*
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 95efef921f1d..df0516f24379 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -450,13 +450,12 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
450 if (pd->uobject && udata) 450 if (pd->uobject && udata)
451 context = pd->uobject->context; 451 context = pd->uobject->context;
452 452
453 my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL); 453 my_qp = kmem_cache_zalloc(qp_cache, GFP_KERNEL);
454 if (!my_qp) { 454 if (!my_qp) {
455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd); 455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
456 return ERR_PTR(-ENOMEM); 456 return ERR_PTR(-ENOMEM);
457 } 457 }
458 458
459 memset(my_qp, 0, sizeof(struct ehca_qp));
460 memset (&parms, 0, sizeof(struct ehca_alloc_qp_parms)); 459 memset (&parms, 0, sizeof(struct ehca_alloc_qp_parms));
461 spin_lock_init(&my_qp->spinlock_s); 460 spin_lock_init(&my_qp->spinlock_s);
462 spin_lock_init(&my_qp->spinlock_r); 461 spin_lock_init(&my_qp->spinlock_r);
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
index f68dbe6f7f04..7b7a546323cf 100644
--- a/drivers/input/gameport/ns558.c
+++ b/drivers/input/gameport/ns558.c
@@ -151,7 +151,6 @@ static int ns558_isa_probe(int io)
151 return -ENOMEM; 151 return -ENOMEM;
152 } 152 }
153 153
154 memset(ns558, 0, sizeof(struct ns558));
155 ns558->io = io; 154 ns558->io = io;
156 ns558->size = 1 << i; 155 ns558->size = 1 << i;
157 ns558->gameport = port; 156 ns558->gameport = port;
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index b5e7f9c7d74e..63e51dd6debe 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -257,10 +257,10 @@ static inline void dump_urb(enum debuglevel level, const char *tag,
257 urb->transfer_flags); 257 urb->transfer_flags);
258 gig_dbg(level, 258 gig_dbg(level,
259 " transfer_buffer=0x%08lx[%d], actual_length=%d, " 259 " transfer_buffer=0x%08lx[%d], actual_length=%d, "
260 "bandwidth=%d, setup_packet=0x%08lx,", 260 "setup_packet=0x%08lx,",
261 (unsigned long) urb->transfer_buffer, 261 (unsigned long) urb->transfer_buffer,
262 urb->transfer_buffer_length, urb->actual_length, 262 urb->transfer_buffer_length, urb->actual_length,
263 urb->bandwidth, (unsigned long) urb->setup_packet); 263 (unsigned long) urb->setup_packet);
264 gig_dbg(level, 264 gig_dbg(level,
265 " start_frame=%d, number_of_packets=%d, interval=%d, " 265 " start_frame=%d, number_of_packets=%d, interval=%d, "
266 "error_count=%d,", 266 "error_count=%d,",
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 458b6462f937..f13de20947e0 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -599,19 +599,9 @@ out:
599static void if_wake(unsigned long data) 599static void if_wake(unsigned long data)
600{ 600{
601 struct cardstate *cs = (struct cardstate *) data; 601 struct cardstate *cs = (struct cardstate *) data;
602 struct tty_struct *tty;
603
604 tty = cs->tty;
605 if (!tty)
606 return;
607
608 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
609 tty->ldisc.write_wakeup) {
610 gig_dbg(DEBUG_IF, "write wakeup call");
611 tty->ldisc.write_wakeup(tty);
612 }
613 602
614 wake_up_interruptible(&tty->write_wait); 603 if (cs->tty)
604 tty_wakeup(cs->tty);
615} 605}
616 606
617/*** interface to common ***/ 607/*** interface to common ***/
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index fc80afe555b9..ea5f30d4a5a2 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1261,7 +1261,6 @@ isdn_tty_flush_buffer(struct tty_struct *tty)
1261 } 1261 }
1262 isdn_tty_cleanup_xmit(info); 1262 isdn_tty_cleanup_xmit(info);
1263 info->xmit_count = 0; 1263 info->xmit_count = 0;
1264 wake_up_interruptible(&tty->write_wait);
1265 tty_wakeup(tty); 1264 tty_wakeup(tty);
1266} 1265}
1267 1266
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 8ca75e52f637..eb6653f69ce4 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -516,7 +516,6 @@ static int __init via_pmu_dev_init(void)
516 proc_get_irqstats, NULL); 516 proc_get_irqstats, NULL);
517 proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root); 517 proc_pmu_options = create_proc_entry("options", 0600, proc_pmu_root);
518 if (proc_pmu_options) { 518 if (proc_pmu_options) {
519 proc_pmu_options->nlink = 1;
520 proc_pmu_options->read_proc = proc_read_options; 519 proc_pmu_options->read_proc = proc_read_options;
521 proc_pmu_options->write_proc = proc_write_options; 520 proc_pmu_options->write_proc = proc_write_options;
522 } 521 }
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 059704fbb753..5554adaa58f9 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -666,7 +666,7 @@ static void bitmap_file_put(struct bitmap *bitmap)
666 666
667 if (file) { 667 if (file) {
668 struct inode *inode = file->f_path.dentry->d_inode; 668 struct inode *inode = file->f_path.dentry->d_inode;
669 invalidate_inode_pages(inode->i_mapping); 669 invalidate_mapping_pages(inode->i_mapping, 0, -1);
670 fput(file); 670 fput(file);
671 } 671 }
672} 672}
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 862a984c2155..e10a9ee25fc5 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -562,7 +562,6 @@ jpg_fbuffer_alloc (struct file *file)
562 jpg_fbuffer_free(file); 562 jpg_fbuffer_free(file);
563 return -ENOBUFS; 563 return -ENOBUFS;
564 } 564 }
565 memset((void *) mem, 0, PAGE_SIZE);
566 fh->jpg_buffers.buffer[i].frag_tab = (u32 *) mem; 565 fh->jpg_buffers.buffer[i].frag_tab = (u32 *) mem;
567 fh->jpg_buffers.buffer[i].frag_tab_bus = 566 fh->jpg_buffers.buffer[i].frag_tab_bus =
568 virt_to_bus((void *) mem); 567 virt_to_bus((void *) mem);
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index ea9d5f233c83..6a51e99a8079 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -72,11 +72,9 @@ static int hdpu_nexus_probe(struct platform_device *pdev)
72 printk("Could not map slot id\n"); 72 printk("Could not map slot id\n");
73 hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, &proc_root); 73 hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, &proc_root);
74 hdpu_slot_id->read_proc = hdpu_slot_id_read; 74 hdpu_slot_id->read_proc = hdpu_slot_id_read;
75 hdpu_slot_id->nlink = 1;
76 75
77 hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root); 76 hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root);
78 hdpu_chassis_id->read_proc = hdpu_chassis_id_read; 77 hdpu_chassis_id->read_proc = hdpu_chassis_id_read;
79 hdpu_chassis_id->nlink = 1;
80 return 0; 78 return 0;
81} 79}
82 80
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index b995a15b7526..6a5a05d1f392 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -309,7 +309,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
309 ret = -ENODEV; 309 ret = -ENODEV;
310 goto out_pci; 310 goto out_pci;
311 } 311 }
312 if (!request_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs), 312 if (!request_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
313 "ioc4_misc")) { 313 "ioc4_misc")) {
314 printk(KERN_WARNING 314 printk(KERN_WARNING
315 "%s: Unable to request IOC4 misc region " 315 "%s: Unable to request IOC4 misc region "
@@ -379,7 +379,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
379 return 0; 379 return 0;
380 380
381out_misc_region: 381out_misc_region:
382 release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); 382 release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
383out_pci: 383out_pci:
384 kfree(idd); 384 kfree(idd);
385out_idd: 385out_idd:
@@ -418,7 +418,7 @@ ioc4_remove(struct pci_dev *pdev)
418 "Device removal may be incomplete.\n", 418 "Device removal may be incomplete.\n",
419 __FUNCTION__, pci_name(idd->idd_pdev)); 419 __FUNCTION__, pci_name(idd->idd_pdev));
420 } 420 }
421 release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); 421 release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
422 422
423 /* Disable IOC4 and relinquish */ 423 /* Disable IOC4 and relinquish */
424 pci_disable_device(pdev); 424 pci_disable_device(pdev);
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 6d917a4daa9d..f9f2ce7806b0 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -278,7 +278,8 @@ static void block2mtd_free_device(struct block2mtd_dev *dev)
278 kfree(dev->mtd.name); 278 kfree(dev->mtd.name);
279 279
280 if (dev->blkdev) { 280 if (dev->blkdev) {
281 invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping); 281 invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
282 0, -1);
282 close_bdev_excl(dev->blkdev); 283 close_bdev_excl(dev->blkdev);
283 } 284 }
284 285
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index c6de566188e4..0986f6c843e6 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -83,7 +83,7 @@ struct ppp_file {
83 int dead; /* unit/channel has been shut down */ 83 int dead; /* unit/channel has been shut down */
84}; 84};
85 85
86#define PF_TO_X(pf, X) ((X *)((char *)(pf) - offsetof(X, file))) 86#define PF_TO_X(pf, X) container_of(pf, X, file)
87 87
88#define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp) 88#define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
89#define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel) 89#define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel)
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 8dac2ba82bb9..9a731c101d10 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -252,7 +252,6 @@ static int __init led_create_procfs(void)
252 proc_pdc_root->owner = THIS_MODULE; 252 proc_pdc_root->owner = THIS_MODULE;
253 ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); 253 ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
254 if (!ent) return -1; 254 if (!ent) return -1;
255 ent->nlink = 1;
256 ent->data = (void *)LED_NOLCD; /* LED */ 255 ent->data = (void *)LED_NOLCD; /* LED */
257 ent->read_proc = led_proc_read; 256 ent->read_proc = led_proc_read;
258 ent->write_proc = led_proc_write; 257 ent->write_proc = led_proc_write;
@@ -262,7 +261,6 @@ static int __init led_create_procfs(void)
262 { 261 {
263 ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); 262 ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
264 if (!ent) return -1; 263 if (!ent) return -1;
265 ent->nlink = 1;
266 ent->data = (void *)LED_HASLCD; /* LCD */ 264 ent->data = (void *)LED_HASLCD; /* LCD */
267 ent->read_proc = led_proc_read; 265 ent->read_proc = led_proc_read;
268 ent->write_proc = led_proc_write; 266 ent->write_proc = led_proc_write;
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 6b8c4cfd02a6..31a633f65547 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -1,4 +1,3 @@
1extern struct bus_type pnp_bus_type;
2extern spinlock_t pnp_lock; 1extern spinlock_t pnp_lock;
3void *pnp_alloc(long size); 2void *pnp_alloc(long size);
4int pnp_interface_attach_device(struct pnp_dev *dev); 3int pnp_interface_attach_device(struct pnp_dev *dev);
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 95b79685a9d1..3c2ab8394e3f 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -530,7 +530,6 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); 530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL);
531 if (!dev_id) 531 if (!dev_id)
532 return NULL; 532 return NULL;
533 memset(dev_id, 0, sizeof(struct pnp_id));
534 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id); 533 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id);
535 memcpy(&dev_id->id, id, 7); 534 memcpy(&dev_id->id, id, 7);
536 pnp_add_id(dev_id, dev); 535 pnp_add_id(dev_id, dev);
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 7bf7b2c88245..f935c1f71a58 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -326,14 +326,17 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
326 rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR, 326 rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR,
327 &rdev->dst_ops); 327 &rdev->dst_ops);
328 328
329 if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops) 329 if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) {
330 && do_enum) { 330 if (do_enum) {
331 rio_set_device_id(port, destid, hopcount, next_destid); 331 rio_set_device_id(port, destid, hopcount, next_destid);
332 rdev->destid = next_destid++; 332 rdev->destid = next_destid++;
333 if (next_destid == port->host_deviceid) 333 if (next_destid == port->host_deviceid)
334 next_destid++; 334 next_destid++;
335 } else
336 rdev->destid = rio_get_device_id(port, destid, hopcount);
335 } else 337 } else
336 rdev->destid = rio_get_device_id(port, destid, hopcount); 338 /* Switch device has an associated destID */
339 rdev->destid = RIO_INVALID_DESTID;
337 340
338 /* If a PE has both switch and other functions, show it as a switch */ 341 /* If a PE has both switch and other functions, show it as a switch */
339 if (rio_is_switch(rdev)) { 342 if (rio_is_switch(rdev)) {
@@ -347,7 +350,7 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
347 } 350 }
348 rswitch->switchid = next_switchid; 351 rswitch->switchid = next_switchid;
349 rswitch->hopcount = hopcount; 352 rswitch->hopcount = hopcount;
350 rswitch->destid = 0xffff; 353 rswitch->destid = destid;
351 /* Initialize switch route table */ 354 /* Initialize switch route table */
352 for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++) 355 for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++)
353 rswitch->route_table[rdid] = RIO_INVALID_ROUTE; 356 rswitch->route_table[rdid] = RIO_INVALID_ROUTE;
@@ -422,7 +425,7 @@ rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
422/** 425/**
423 * rio_route_add_entry- Add a route entry to a switch routing table 426 * rio_route_add_entry- Add a route entry to a switch routing table
424 * @mport: Master port to send transaction 427 * @mport: Master port to send transaction
425 * @rdev: Switch device 428 * @rswitch: Switch device
426 * @table: Routing table ID 429 * @table: Routing table ID
427 * @route_destid: Destination ID to be routed 430 * @route_destid: Destination ID to be routed
428 * @route_port: Port number to be routed 431 * @route_port: Port number to be routed
@@ -434,18 +437,18 @@ rio_sport_is_active(struct rio_mport *port, u16 destid, u8 hopcount, int sport)
434 * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL 437 * %RIO_GLOBAL_TABLE in @table. Returns %0 on success or %-EINVAL
435 * on failure. 438 * on failure.
436 */ 439 */
437static int rio_route_add_entry(struct rio_mport *mport, struct rio_dev *rdev, 440static int rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch,
438 u16 table, u16 route_destid, u8 route_port) 441 u16 table, u16 route_destid, u8 route_port)
439{ 442{
440 return rdev->rswitch->add_entry(mport, rdev->rswitch->destid, 443 return rswitch->add_entry(mport, rswitch->destid,
441 rdev->rswitch->hopcount, table, 444 rswitch->hopcount, table,
442 route_destid, route_port); 445 route_destid, route_port);
443} 446}
444 447
445/** 448/**
446 * rio_route_get_entry- Read a route entry in a switch routing table 449 * rio_route_get_entry- Read a route entry in a switch routing table
447 * @mport: Master port to send transaction 450 * @mport: Master port to send transaction
448 * @rdev: Switch device 451 * @rswitch: Switch device
449 * @table: Routing table ID 452 * @table: Routing table ID
450 * @route_destid: Destination ID to be routed 453 * @route_destid: Destination ID to be routed
451 * @route_port: Pointer to read port number into 454 * @route_port: Pointer to read port number into
@@ -458,11 +461,11 @@ static int rio_route_add_entry(struct rio_mport *mport, struct rio_dev *rdev,
458 * on failure. 461 * on failure.
459 */ 462 */
460static int 463static int
461rio_route_get_entry(struct rio_mport *mport, struct rio_dev *rdev, u16 table, 464rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table,
462 u16 route_destid, u8 * route_port) 465 u16 route_destid, u8 * route_port)
463{ 466{
464 return rdev->rswitch->get_entry(mport, rdev->rswitch->destid, 467 return rswitch->get_entry(mport, rswitch->destid,
465 rdev->rswitch->hopcount, table, 468 rswitch->hopcount, table,
466 route_destid, route_port); 469 route_destid, route_port);
467} 470}
468 471
@@ -552,6 +555,8 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
552 int port_num; 555 int port_num;
553 int num_ports; 556 int num_ports;
554 int cur_destid; 557 int cur_destid;
558 int sw_destid;
559 int sw_inport;
555 struct rio_dev *rdev; 560 struct rio_dev *rdev;
556 u16 destid; 561 u16 destid;
557 int tmp; 562 int tmp;
@@ -594,15 +599,17 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
594 599
595 if (rio_is_switch(rdev)) { 600 if (rio_is_switch(rdev)) {
596 next_switchid++; 601 next_switchid++;
602 sw_inport = rio_get_swpinfo_inport(port, RIO_ANY_DESTID, hopcount);
603 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
604 port->host_deviceid, sw_inport);
605 rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
597 606
598 for (destid = 0; destid < next_destid; destid++) { 607 for (destid = 0; destid < next_destid; destid++) {
599 rio_route_add_entry(port, rdev, RIO_GLOBAL_TABLE, 608 if (destid == port->host_deviceid)
600 destid, rio_get_swpinfo_inport(port, 609 continue;
601 RIO_ANY_DESTID, 610 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE,
602 hopcount)); 611 destid, sw_inport);
603 rdev->rswitch->route_table[destid] = 612 rdev->rswitch->route_table[destid] = sw_inport;
604 rio_get_swpinfo_inport(port, RIO_ANY_DESTID,
605 hopcount);
606 } 613 }
607 614
608 num_ports = 615 num_ports =
@@ -610,9 +617,9 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
610 pr_debug( 617 pr_debug(
611 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", 618 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
612 rio_name(rdev), rdev->vid, rdev->did, num_ports); 619 rio_name(rdev), rdev->vid, rdev->did, num_ports);
620 sw_destid = next_destid;
613 for (port_num = 0; port_num < num_ports; port_num++) { 621 for (port_num = 0; port_num < num_ports; port_num++) {
614 if (rio_get_swpinfo_inport 622 if (sw_inport == port_num)
615 (port, RIO_ANY_DESTID, hopcount) == port_num)
616 continue; 623 continue;
617 624
618 cur_destid = next_destid; 625 cur_destid = next_destid;
@@ -622,7 +629,7 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
622 pr_debug( 629 pr_debug(
623 "RIO: scanning device on port %d\n", 630 "RIO: scanning device on port %d\n",
624 port_num); 631 port_num);
625 rio_route_add_entry(port, rdev, 632 rio_route_add_entry(port, rdev->rswitch,
626 RIO_GLOBAL_TABLE, 633 RIO_GLOBAL_TABLE,
627 RIO_ANY_DESTID, port_num); 634 RIO_ANY_DESTID, port_num);
628 635
@@ -633,7 +640,9 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
633 if (next_destid > cur_destid) { 640 if (next_destid > cur_destid) {
634 for (destid = cur_destid; 641 for (destid = cur_destid;
635 destid < next_destid; destid++) { 642 destid < next_destid; destid++) {
636 rio_route_add_entry(port, rdev, 643 if (destid == port->host_deviceid)
644 continue;
645 rio_route_add_entry(port, rdev->rswitch,
637 RIO_GLOBAL_TABLE, 646 RIO_GLOBAL_TABLE,
638 destid, 647 destid,
639 port_num); 648 port_num);
@@ -641,10 +650,18 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port,
641 route_table[destid] = 650 route_table[destid] =
642 port_num; 651 port_num;
643 } 652 }
644 rdev->rswitch->destid = cur_destid;
645 } 653 }
646 } 654 }
647 } 655 }
656
657 /* Check for empty switch */
658 if (next_destid == sw_destid) {
659 next_destid++;
660 if (next_destid == port->host_deviceid)
661 next_destid++;
662 }
663
664 rdev->rswitch->destid = sw_destid;
648 } else 665 } else
649 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n", 666 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
650 rio_name(rdev), rdev->vid, rdev->did); 667 rio_name(rdev), rdev->vid, rdev->did);
@@ -721,7 +738,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
721 port_num); 738 port_num);
722 for (ndestid = 0; ndestid < RIO_ANY_DESTID; 739 for (ndestid = 0; ndestid < RIO_ANY_DESTID;
723 ndestid++) { 740 ndestid++) {
724 rio_route_get_entry(port, rdev, 741 rio_route_get_entry(port, rdev->rswitch,
725 RIO_GLOBAL_TABLE, 742 RIO_GLOBAL_TABLE,
726 ndestid, 743 ndestid,
727 &route_port); 744 &route_port);
@@ -798,6 +815,44 @@ static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port)
798} 815}
799 816
800/** 817/**
818 * rio_update_route_tables- Updates route tables in switches
819 * @port: Master port associated with the RIO network
820 *
821 * For each enumerated device, ensure that each switch in a system
822 * has correct routing entries. Add routes for devices that where
823 * unknown dirung the first enumeration pass through the switch.
824 */
825static void rio_update_route_tables(struct rio_mport *port)
826{
827 struct rio_dev *rdev;
828 struct rio_switch *rswitch;
829 u8 sport;
830 u16 destid;
831
832 list_for_each_entry(rdev, &rio_devices, global_list) {
833
834 destid = (rio_is_switch(rdev))?rdev->rswitch->destid:rdev->destid;
835
836 list_for_each_entry(rswitch, &rio_switches, node) {
837
838 if (rio_is_switch(rdev) && (rdev->rswitch == rswitch))
839 continue;
840
841 if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) {
842
843 sport = rio_get_swpinfo_inport(port,
844 rswitch->destid, rswitch->hopcount);
845
846 if (rswitch->add_entry) {
847 rio_route_add_entry(port, rswitch, RIO_GLOBAL_TABLE, destid, sport);
848 rswitch->route_table[destid] = sport;
849 }
850 }
851 }
852 }
853}
854
855/**
801 * rio_enum_mport- Start enumeration through a master port 856 * rio_enum_mport- Start enumeration through a master port
802 * @mport: Master port to send transactions 857 * @mport: Master port to send transactions
803 * 858 *
@@ -838,6 +893,7 @@ int rio_enum_mport(struct rio_mport *mport)
838 rc = -EBUSY; 893 rc = -EBUSY;
839 goto out; 894 goto out;
840 } 895 }
896 rio_update_route_tables(mport);
841 rio_clear_locks(mport); 897 rio_clear_locks(mport);
842 } else { 898 } else {
843 printk(KERN_INFO "RIO: master port %d link inactive\n", 899 printk(KERN_INFO "RIO: master port %d link inactive\n",
@@ -865,8 +921,8 @@ static void rio_build_route_tables(void)
865 if (rio_is_switch(rdev)) 921 if (rio_is_switch(rdev))
866 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) { 922 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) {
867 if (rio_route_get_entry 923 if (rio_route_get_entry
868 (rdev->net->hport, rdev, RIO_GLOBAL_TABLE, i, 924 (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE,
869 &sport) < 0) 925 i, &sport) < 0)
870 continue; 926 continue;
871 rdev->rswitch->route_table[i] = sport; 927 rdev->rswitch->route_table[i] = sport;
872 } 928 }
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 09660e2ab051..4bbca500d3d2 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1,4 +1,4 @@
1\# 1#
2# RTC class/drivers configuration 2# RTC class/drivers configuration
3# 3#
4 4
@@ -95,6 +95,29 @@ config RTC_INTF_DEV_UIE_EMUL
95comment "RTC drivers" 95comment "RTC drivers"
96 depends on RTC_CLASS 96 depends on RTC_CLASS
97 97
98# this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h>
99# requires <asm/mc146818rtc.h> defining CMOS_READ/CMOS_WRITE, and a
100# global rtc_lock ... it's not yet just another platform_device.
101
102config RTC_DRV_CMOS
103 tristate "PC-style 'CMOS' real time clock"
104 depends on RTC_CLASS && (X86_PC || ALPHA || ARM26 || ARM \
105 || M32R || ATARI || POWERPC)
106 help
107 Say "yes" here to get direct support for the real time clock
108 found in every PC or ACPI-based system, and some other boards.
109 Specifically the original MC146818, compatibles like those in
110 PC south bridges, the DS12887 or M48T86, some multifunction
111 or LPC bus chips, and so on.
112
113 Your system will need to define the platform device used by
114 this driver, otherwise it won't be accessible. This means
115 you can safely enable this driver if you don't know whether
116 or not your board has this kind of hardware.
117
118 This driver can also be built as a module. If so, the module
119 will be called rtc-cmos.
120
98config RTC_DRV_X1205 121config RTC_DRV_X1205
99 tristate "Xicor/Intersil X1205" 122 tristate "Xicor/Intersil X1205"
100 depends on RTC_CLASS && I2C 123 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index e6beedacc966..92bfe1b3a5fa 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
15obj-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o 15obj-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o
16obj-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o 16obj-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o
17 17
18obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
18obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 19obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
19obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o 20obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
20obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o 21obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
new file mode 100644
index 000000000000..85bf795abdcc
--- /dev/null
+++ b/drivers/rtc/rtc-cmos.c
@@ -0,0 +1,725 @@
1/*
2 * RTC class driver for "CMOS RTC": PCs, ACPI, etc
3 *
4 * Copyright (C) 1996 Paul Gortmaker (drivers/char/rtc.c)
5 * Copyright (C) 2006 David Brownell (convert to new framework)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13/*
14 * The original "cmos clock" chip was an MC146818 chip, now obsolete.
15 * That defined the register interface now provided by all PCs, some
16 * non-PC systems, and incorporated into ACPI. Modern PC chipsets
17 * integrate an MC146818 clone in their southbridge, and boards use
18 * that instead of discrete clones like the DS12887 or M48T86. There
19 * are also clones that connect using the LPC bus.
20 *
21 * That register API is also used directly by various other drivers
22 * (notably for integrated NVRAM), infrastructure (x86 has code to
23 * bypass the RTC framework, directly reading the RTC during boot
24 * and updating minutes/seconds for systems using NTP synch) and
25 * utilities (like userspace 'hwclock', if no /dev node exists).
26 *
27 * So **ALL** calls to CMOS_READ and CMOS_WRITE must be done with
28 * interrupts disabled, holding the global rtc_lock, to exclude those
29 * other drivers and utilities on correctly configured systems.
30 */
31#include <linux/kernel.h>
32#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/interrupt.h>
35#include <linux/spinlock.h>
36#include <linux/platform_device.h>
37#include <linux/mod_devicetable.h>
38
39/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
40#include <asm-generic/rtc.h>
41
42
43struct cmos_rtc {
44 struct rtc_device *rtc;
45 struct device *dev;
46 int irq;
47 struct resource *iomem;
48
49 u8 suspend_ctrl;
50
51 /* newer hardware extends the original register set */
52 u8 day_alrm;
53 u8 mon_alrm;
54 u8 century;
55};
56
57/* both platform and pnp busses use negative numbers for invalid irqs */
58#define is_valid_irq(n) ((n) >= 0)
59
60static const char driver_name[] = "rtc_cmos";
61
62/*----------------------------------------------------------------*/
63
64static int cmos_read_time(struct device *dev, struct rtc_time *t)
65{
66 /* REVISIT: if the clock has a "century" register, use
67 * that instead of the heuristic in get_rtc_time().
68 * That'll make Y3K compatility (year > 2070) easy!
69 */
70 get_rtc_time(t);
71 return 0;
72}
73
74static int cmos_set_time(struct device *dev, struct rtc_time *t)
75{
76 /* REVISIT: set the "century" register if available
77 *
78 * NOTE: this ignores the issue whereby updating the seconds
79 * takes effect exactly 500ms after we write the register.
80 * (Also queueing and other delays before we get this far.)
81 */
82 return set_rtc_time(t);
83}
84
85static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
86{
87 struct cmos_rtc *cmos = dev_get_drvdata(dev);
88 unsigned char rtc_control;
89
90 if (!is_valid_irq(cmos->irq))
91 return -EIO;
92
93 /* Basic alarms only support hour, minute, and seconds fields.
94 * Some also support day and month, for alarms up to a year in
95 * the future.
96 */
97 t->time.tm_mday = -1;
98 t->time.tm_mon = -1;
99
100 spin_lock_irq(&rtc_lock);
101 t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);
102 t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);
103 t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);
104
105 if (cmos->day_alrm) {
106 t->time.tm_mday = CMOS_READ(cmos->day_alrm);
107 if (!t->time.tm_mday)
108 t->time.tm_mday = -1;
109
110 if (cmos->mon_alrm) {
111 t->time.tm_mon = CMOS_READ(cmos->mon_alrm);
112 if (!t->time.tm_mon)
113 t->time.tm_mon = -1;
114 }
115 }
116
117 rtc_control = CMOS_READ(RTC_CONTROL);
118 spin_unlock_irq(&rtc_lock);
119
120 /* REVISIT this assumes PC style usage: always BCD */
121
122 if (((unsigned)t->time.tm_sec) < 0x60)
123 t->time.tm_sec = BCD2BIN(t->time.tm_sec);
124 else
125 t->time.tm_sec = -1;
126 if (((unsigned)t->time.tm_min) < 0x60)
127 t->time.tm_min = BCD2BIN(t->time.tm_min);
128 else
129 t->time.tm_min = -1;
130 if (((unsigned)t->time.tm_hour) < 0x24)
131 t->time.tm_hour = BCD2BIN(t->time.tm_hour);
132 else
133 t->time.tm_hour = -1;
134
135 if (cmos->day_alrm) {
136 if (((unsigned)t->time.tm_mday) <= 0x31)
137 t->time.tm_mday = BCD2BIN(t->time.tm_mday);
138 else
139 t->time.tm_mday = -1;
140 if (cmos->mon_alrm) {
141 if (((unsigned)t->time.tm_mon) <= 0x12)
142 t->time.tm_mon = BCD2BIN(t->time.tm_mon) - 1;
143 else
144 t->time.tm_mon = -1;
145 }
146 }
147 t->time.tm_year = -1;
148
149 t->enabled = !!(rtc_control & RTC_AIE);
150 t->pending = 0;
151
152 return 0;
153}
154
155static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
156{
157 struct cmos_rtc *cmos = dev_get_drvdata(dev);
158 unsigned char mon, mday, hrs, min, sec;
159 unsigned char rtc_control, rtc_intr;
160
161 if (!is_valid_irq(cmos->irq))
162 return -EIO;
163
164 /* REVISIT this assumes PC style usage: always BCD */
165
166 /* Writing 0xff means "don't care" or "match all". */
167
168 mon = t->time.tm_mon;
169 mon = (mon < 12) ? BIN2BCD(mon) : 0xff;
170 mon++;
171
172 mday = t->time.tm_mday;
173 mday = (mday >= 1 && mday <= 31) ? BIN2BCD(mday) : 0xff;
174
175 hrs = t->time.tm_hour;
176 hrs = (hrs < 24) ? BIN2BCD(hrs) : 0xff;
177
178 min = t->time.tm_min;
179 min = (min < 60) ? BIN2BCD(min) : 0xff;
180
181 sec = t->time.tm_sec;
182 sec = (sec < 60) ? BIN2BCD(sec) : 0xff;
183
184 spin_lock_irq(&rtc_lock);
185
186 /* next rtc irq must not be from previous alarm setting */
187 rtc_control = CMOS_READ(RTC_CONTROL);
188 rtc_control &= ~RTC_AIE;
189 CMOS_WRITE(rtc_control, RTC_CONTROL);
190 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
191 if (rtc_intr)
192 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
193
194 /* update alarm */
195 CMOS_WRITE(hrs, RTC_HOURS_ALARM);
196 CMOS_WRITE(min, RTC_MINUTES_ALARM);
197 CMOS_WRITE(sec, RTC_SECONDS_ALARM);
198
199 /* the system may support an "enhanced" alarm */
200 if (cmos->day_alrm) {
201 CMOS_WRITE(mday, cmos->day_alrm);
202 if (cmos->mon_alrm)
203 CMOS_WRITE(mon, cmos->mon_alrm);
204 }
205
206 if (t->enabled) {
207 rtc_control |= RTC_AIE;
208 CMOS_WRITE(rtc_control, RTC_CONTROL);
209 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
210 if (rtc_intr)
211 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
212 }
213
214 spin_unlock_irq(&rtc_lock);
215
216 return 0;
217}
218
219static int cmos_set_freq(struct device *dev, int freq)
220{
221 struct cmos_rtc *cmos = dev_get_drvdata(dev);
222 int f;
223 unsigned long flags;
224
225 if (!is_valid_irq(cmos->irq))
226 return -ENXIO;
227
228 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
229 f = ffs(freq);
230 if (f != 0) {
231 if (f-- > 16 || freq != (1 << f))
232 return -EINVAL;
233 f = 16 - f;
234 }
235
236 spin_lock_irqsave(&rtc_lock, flags);
237 CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT);
238 spin_unlock_irqrestore(&rtc_lock, flags);
239
240 return 0;
241}
242
243#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
244
245static int
246cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
247{
248 struct cmos_rtc *cmos = dev_get_drvdata(dev);
249 unsigned char rtc_control, rtc_intr;
250 unsigned long flags;
251
252 switch (cmd) {
253 case RTC_AIE_OFF:
254 case RTC_AIE_ON:
255 case RTC_UIE_OFF:
256 case RTC_UIE_ON:
257 case RTC_PIE_OFF:
258 case RTC_PIE_ON:
259 if (!is_valid_irq(cmos->irq))
260 return -EINVAL;
261 break;
262 default:
263 return -ENOIOCTLCMD;
264 }
265
266 spin_lock_irqsave(&rtc_lock, flags);
267 rtc_control = CMOS_READ(RTC_CONTROL);
268 switch (cmd) {
269 case RTC_AIE_OFF: /* alarm off */
270 rtc_control &= ~RTC_AIE;
271 break;
272 case RTC_AIE_ON: /* alarm on */
273 rtc_control |= RTC_AIE;
274 break;
275 case RTC_UIE_OFF: /* update off */
276 rtc_control &= ~RTC_UIE;
277 break;
278 case RTC_UIE_ON: /* update on */
279 rtc_control |= RTC_UIE;
280 break;
281 case RTC_PIE_OFF: /* periodic off */
282 rtc_control &= ~RTC_PIE;
283 break;
284 case RTC_PIE_ON: /* periodic on */
285 rtc_control |= RTC_PIE;
286 break;
287 }
288 CMOS_WRITE(rtc_control, RTC_CONTROL);
289 rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
290 if (rtc_intr)
291 rtc_update_irq(&cmos->rtc->class_dev, 1, rtc_intr);
292 spin_unlock_irqrestore(&rtc_lock, flags);
293 return 0;
294}
295
296#else
297#define cmos_rtc_ioctl NULL
298#endif
299
300#if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE)
301
302static int cmos_procfs(struct device *dev, struct seq_file *seq)
303{
304 struct cmos_rtc *cmos = dev_get_drvdata(dev);
305 unsigned char rtc_control, valid;
306
307 spin_lock_irq(&rtc_lock);
308 rtc_control = CMOS_READ(RTC_CONTROL);
309 valid = CMOS_READ(RTC_VALID);
310 spin_unlock_irq(&rtc_lock);
311
312 /* NOTE: at least ICH6 reports battery status using a different
313 * (non-RTC) bit; and SQWE is ignored on many current systems.
314 */
315 return seq_printf(seq,
316 "periodic_IRQ\t: %s\n"
317 "update_IRQ\t: %s\n"
318 // "square_wave\t: %s\n"
319 // "BCD\t\t: %s\n"
320 "DST_enable\t: %s\n"
321 "periodic_freq\t: %d\n"
322 "batt_status\t: %s\n",
323 (rtc_control & RTC_PIE) ? "yes" : "no",
324 (rtc_control & RTC_UIE) ? "yes" : "no",
325 // (rtc_control & RTC_SQWE) ? "yes" : "no",
326 // (rtc_control & RTC_DM_BINARY) ? "no" : "yes",
327 (rtc_control & RTC_DST_EN) ? "yes" : "no",
328 cmos->rtc->irq_freq,
329 (valid & RTC_VRT) ? "okay" : "dead");
330}
331
332#else
333#define cmos_procfs NULL
334#endif
335
336static const struct rtc_class_ops cmos_rtc_ops = {
337 .ioctl = cmos_rtc_ioctl,
338 .read_time = cmos_read_time,
339 .set_time = cmos_set_time,
340 .read_alarm = cmos_read_alarm,
341 .set_alarm = cmos_set_alarm,
342 .proc = cmos_procfs,
343 .irq_set_freq = cmos_set_freq,
344};
345
346/*----------------------------------------------------------------*/
347
348static struct cmos_rtc cmos_rtc;
349
350static irqreturn_t cmos_interrupt(int irq, void *p)
351{
352 u8 irqstat;
353
354 spin_lock(&rtc_lock);
355 irqstat = CMOS_READ(RTC_INTR_FLAGS);
356 spin_unlock(&rtc_lock);
357
358 if (irqstat) {
359 /* NOTE: irqstat may have e.g. RTC_PF set
360 * even when RTC_PIE is clear...
361 */
362 rtc_update_irq(p, 1, irqstat);
363 return IRQ_HANDLED;
364 } else
365 return IRQ_NONE;
366}
367
368#ifdef CONFIG_PNPACPI
369#define is_pnpacpi() 1
370#define INITSECTION
371
372#else
373#define is_pnpacpi() 0
374#define INITSECTION __init
375#endif
376
377static int INITSECTION
378cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
379{
380 struct cmos_rtc_board_info *info = dev->platform_data;
381 int retval = 0;
382 unsigned char rtc_control;
383
384 /* there can be only one ... */
385 if (cmos_rtc.dev)
386 return -EBUSY;
387
388 if (!ports)
389 return -ENODEV;
390
391 cmos_rtc.irq = rtc_irq;
392 cmos_rtc.iomem = ports;
393
394 /* For ACPI systems the info comes from the FADT. On others,
395 * board specific setup provides it as appropriate.
396 */
397 if (info) {
398 cmos_rtc.day_alrm = info->rtc_day_alarm;
399 cmos_rtc.mon_alrm = info->rtc_mon_alarm;
400 cmos_rtc.century = info->rtc_century;
401 }
402
403 cmos_rtc.rtc = rtc_device_register(driver_name, dev,
404 &cmos_rtc_ops, THIS_MODULE);
405 if (IS_ERR(cmos_rtc.rtc))
406 return PTR_ERR(cmos_rtc.rtc);
407
408 cmos_rtc.dev = dev;
409 dev_set_drvdata(dev, &cmos_rtc);
410
411 /* platform and pnp busses handle resources incompatibly.
412 *
413 * REVISIT for non-x86 systems we may need to handle io memory
414 * resources: ioremap them, and request_mem_region().
415 */
416 if (is_pnpacpi()) {
417 retval = request_resource(&ioport_resource, ports);
418 if (retval < 0) {
419 dev_dbg(dev, "i/o registers already in use\n");
420 goto cleanup0;
421 }
422 }
423 rename_region(ports, cmos_rtc.rtc->class_dev.class_id);
424
425 spin_lock_irq(&rtc_lock);
426
427 /* force periodic irq to CMOS reset default of 1024Hz;
428 *
429 * REVISIT it's been reported that at least one x86_64 ALI mobo
430 * doesn't use 32KHz here ... for portability we might need to
431 * do something about other clock frequencies.
432 */
433 CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);
434 cmos_rtc.rtc->irq_freq = 1024;
435
436 /* disable irqs.
437 *
438 * NOTE after changing RTC_xIE bits we always read INTR_FLAGS;
439 * allegedly some older rtcs need that to handle irqs properly
440 */
441 rtc_control = CMOS_READ(RTC_CONTROL);
442 rtc_control &= ~(RTC_PIE | RTC_AIE | RTC_UIE);
443 CMOS_WRITE(rtc_control, RTC_CONTROL);
444 CMOS_READ(RTC_INTR_FLAGS);
445
446 spin_unlock_irq(&rtc_lock);
447
448 /* FIXME teach the alarm code how to handle binary mode;
449 * <asm-generic/rtc.h> doesn't know 12-hour mode either.
450 */
451 if (!(rtc_control & RTC_24H) || (rtc_control & (RTC_DM_BINARY))) {
452 dev_dbg(dev, "only 24-hr BCD mode supported\n");
453 retval = -ENXIO;
454 goto cleanup1;
455 }
456
457 if (is_valid_irq(rtc_irq))
458 retval = request_irq(rtc_irq, cmos_interrupt, IRQF_DISABLED,
459 cmos_rtc.rtc->class_dev.class_id,
460 &cmos_rtc.rtc->class_dev);
461 if (retval < 0) {
462 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
463 goto cleanup1;
464 }
465
466 /* REVISIT optionally make 50 or 114 bytes NVRAM available,
467 * like rtc-ds1553, rtc-ds1742 ... this will often include
468 * registers for century, and day/month alarm.
469 */
470
471 pr_info("%s: alarms up to one %s%s\n",
472 cmos_rtc.rtc->class_dev.class_id,
473 is_valid_irq(rtc_irq)
474 ? (cmos_rtc.mon_alrm
475 ? "year"
476 : (cmos_rtc.day_alrm
477 ? "month" : "day"))
478 : "no",
479 cmos_rtc.century ? ", y3k" : ""
480 );
481
482 return 0;
483
484cleanup1:
485 rename_region(ports, NULL);
486cleanup0:
487 rtc_device_unregister(cmos_rtc.rtc);
488 return retval;
489}
490
491static void cmos_do_shutdown(void)
492{
493 unsigned char rtc_control;
494
495 spin_lock_irq(&rtc_lock);
496 rtc_control = CMOS_READ(RTC_CONTROL);
497 rtc_control &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
498 CMOS_WRITE(rtc_control, RTC_CONTROL);
499 CMOS_READ(RTC_INTR_FLAGS);
500 spin_unlock_irq(&rtc_lock);
501}
502
503static void __exit cmos_do_remove(struct device *dev)
504{
505 struct cmos_rtc *cmos = dev_get_drvdata(dev);
506
507 cmos_do_shutdown();
508
509 if (is_pnpacpi())
510 release_resource(cmos->iomem);
511 rename_region(cmos->iomem, NULL);
512
513 if (is_valid_irq(cmos->irq))
514 free_irq(cmos->irq, &cmos_rtc.rtc->class_dev);
515
516 rtc_device_unregister(cmos_rtc.rtc);
517
518 cmos_rtc.dev = NULL;
519 dev_set_drvdata(dev, NULL);
520}
521
522#ifdef CONFIG_PM
523
524static int cmos_suspend(struct device *dev, pm_message_t mesg)
525{
526 struct cmos_rtc *cmos = dev_get_drvdata(dev);
527 int do_wake = device_may_wakeup(dev);
528 unsigned char tmp, irqstat;
529
530 /* only the alarm might be a wakeup event source */
531 spin_lock_irq(&rtc_lock);
532 cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL);
533 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
534 if (do_wake)
535 tmp &= ~(RTC_PIE|RTC_UIE);
536 else
537 tmp &= ~(RTC_PIE|RTC_AIE|RTC_UIE);
538 CMOS_WRITE(tmp, RTC_CONTROL);
539 irqstat = CMOS_READ(RTC_INTR_FLAGS);
540 } else
541 irqstat = 0;
542 spin_unlock_irq(&rtc_lock);
543
544 if (irqstat)
545 rtc_update_irq(&cmos->rtc->class_dev, 1, irqstat);
546
547 /* ACPI HOOK: enable ACPI_EVENT_RTC when (tmp & RTC_AIE)
548 * ... it'd be best if we could do that under rtc_lock.
549 */
550
551 pr_debug("%s: suspend%s, ctrl %02x\n",
552 cmos_rtc.rtc->class_dev.class_id,
553 (tmp & RTC_AIE) ? ", alarm may wake" : "",
554 tmp);
555
556 return 0;
557}
558
559static int cmos_resume(struct device *dev)
560{
561 struct cmos_rtc *cmos = dev_get_drvdata(dev);
562 unsigned char tmp = cmos->suspend_ctrl;
563
564 /* REVISIT: a mechanism to resync the system clock (jiffies)
565 * on resume should be portable between platforms ...
566 */
567
568 /* re-enable any irqs previously active */
569 if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
570
571 /* ACPI HOOK: disable ACPI_EVENT_RTC when (tmp & RTC_AIE) */
572
573 spin_lock_irq(&rtc_lock);
574 CMOS_WRITE(tmp, RTC_CONTROL);
575 tmp = CMOS_READ(RTC_INTR_FLAGS);
576 spin_unlock_irq(&rtc_lock);
577 if (tmp)
578 rtc_update_irq(&cmos->rtc->class_dev, 1, tmp);
579 }
580
581 pr_debug("%s: resume, ctrl %02x\n",
582 cmos_rtc.rtc->class_dev.class_id,
583 cmos->suspend_ctrl);
584
585
586 return 0;
587}
588
589#else
590#define cmos_suspend NULL
591#define cmos_resume NULL
592#endif
593
594/*----------------------------------------------------------------*/
595
596/* The "CMOS" RTC normally lives on the platform_bus. On ACPI systems,
597 * the device node may alternatively be created as a PNP device.
598 */
599
600#ifdef CONFIG_PNPACPI
601
602#include <linux/pnp.h>
603
604static int __devinit
605cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
606{
607 /* REVISIT paranoia argues for a shutdown notifier, since PNP
608 * drivers can't provide shutdown() methods to disable IRQs.
609 * Or better yet, fix PNP to allow those methods...
610 */
611 return cmos_do_probe(&pnp->dev,
612 &pnp->res.port_resource[0],
613 pnp->res.irq_resource[0].start);
614}
615
616static void __exit cmos_pnp_remove(struct pnp_dev *pnp)
617{
618 cmos_do_remove(&pnp->dev);
619}
620
621#ifdef CONFIG_PM
622
623static int cmos_pnp_suspend(struct pnp_dev *pnp, pm_message_t mesg)
624{
625 return cmos_suspend(&pnp->dev, mesg);
626}
627
628static int cmos_pnp_resume(struct pnp_dev *pnp)
629{
630 return cmos_resume(&pnp->dev);
631}
632
633#else
634#define cmos_pnp_suspend NULL
635#define cmos_pnp_resume NULL
636#endif
637
638
639static const struct pnp_device_id rtc_ids[] = {
640 { .id = "PNP0b00", },
641 { .id = "PNP0b01", },
642 { .id = "PNP0b02", },
643 { },
644};
645MODULE_DEVICE_TABLE(pnp, rtc_ids);
646
647static struct pnp_driver cmos_pnp_driver = {
648 .name = (char *) driver_name,
649 .id_table = rtc_ids,
650 .probe = cmos_pnp_probe,
651 .remove = __exit_p(cmos_pnp_remove),
652
653 /* flag ensures resume() gets called, and stops syslog spam */
654 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
655 .suspend = cmos_pnp_suspend,
656 .resume = cmos_pnp_resume,
657};
658
659static int __init cmos_init(void)
660{
661 return pnp_register_driver(&cmos_pnp_driver);
662}
663module_init(cmos_init);
664
665static void __exit cmos_exit(void)
666{
667 pnp_unregister_driver(&cmos_pnp_driver);
668}
669module_exit(cmos_exit);
670
671#else /* no PNPACPI */
672
673/*----------------------------------------------------------------*/
674
675/* Platform setup should have set up an RTC device, when PNPACPI is
676 * unavailable ... this is the normal case, common even on PCs.
677 */
678
679static int __init cmos_platform_probe(struct platform_device *pdev)
680{
681 return cmos_do_probe(&pdev->dev,
682 platform_get_resource(pdev, IORESOURCE_IO, 0),
683 platform_get_irq(pdev, 0));
684}
685
686static int __exit cmos_platform_remove(struct platform_device *pdev)
687{
688 cmos_do_remove(&pdev->dev);
689 return 0;
690}
691
692static void cmos_platform_shutdown(struct platform_device *pdev)
693{
694 cmos_do_shutdown();
695}
696
697static struct platform_driver cmos_platform_driver = {
698 .remove = __exit_p(cmos_platform_remove),
699 .shutdown = cmos_platform_shutdown,
700 .driver = {
701 .name = (char *) driver_name,
702 .suspend = cmos_suspend,
703 .resume = cmos_resume,
704 }
705};
706
707static int __init cmos_init(void)
708{
709 return platform_driver_probe(&cmos_platform_driver,
710 cmos_platform_probe);
711}
712module_init(cmos_init);
713
714static void __exit cmos_exit(void)
715{
716 platform_driver_unregister(&cmos_platform_driver);
717}
718module_exit(cmos_exit);
719
720
721#endif /* !PNPACPI */
722
723MODULE_AUTHOR("David Brownell");
724MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
725MODULE_LICENSE("GPL");
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index b9e59bc9435a..2c785148d21e 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -1063,7 +1063,6 @@ int __init zcrypt_api_init(void)
1063 rc = -ENOMEM; 1063 rc = -ENOMEM;
1064 goto out_misc; 1064 goto out_misc;
1065 } 1065 }
1066 zcrypt_entry->nlink = 1;
1067 zcrypt_entry->data = NULL; 1066 zcrypt_entry->data = NULL;
1068 zcrypt_entry->read_proc = zcrypt_status_read; 1067 zcrypt_entry->read_proc = zcrypt_status_read;
1069 zcrypt_entry->write_proc = zcrypt_status_write; 1068 zcrypt_entry->write_proc = zcrypt_status_write;
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index b97dd15bdb9a..ecca1046714e 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1511,8 +1511,7 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1511 LCS_DBF_TEXT(5, trace, "txbuffcb"); 1511 LCS_DBF_TEXT(5, trace, "txbuffcb");
1512 /* Put buffer back to pool. */ 1512 /* Put buffer back to pool. */
1513 lcs_release_buffer(channel, buffer); 1513 lcs_release_buffer(channel, buffer);
1514 card = (struct lcs_card *) 1514 card = container_of(channel, struct lcs_card, write);
1515 ((char *) channel - offsetof(struct lcs_card, write));
1516 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev)) 1515 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev))
1517 netif_wake_queue(card->dev); 1516 netif_wake_queue(card->dev);
1518 spin_lock(&card->lock); 1517 spin_lock(&card->lock);
@@ -1810,8 +1809,7 @@ lcs_get_frames_cb(struct lcs_channel *channel, struct lcs_buffer *buffer)
1810 LCS_DBF_TEXT(4, trace, "-eiogpkt"); 1809 LCS_DBF_TEXT(4, trace, "-eiogpkt");
1811 return; 1810 return;
1812 } 1811 }
1813 card = (struct lcs_card *) 1812 card = container_of(channel, struct lcs_card, read);
1814 ((char *) channel - offsetof(struct lcs_card, read));
1815 offset = 0; 1813 offset = 0;
1816 while (lcs_hdr->offset != 0) { 1814 while (lcs_hdr->offset != 0) {
1817 if (lcs_hdr->offset <= 0 || 1815 if (lcs_hdr->offset <= 0 ||
diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
index 640536ef77dc..9c3794310879 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -3099,7 +3099,6 @@ allocate_cmd (Scsi_Cmnd *cmd) {
3099 real = get_zeroed_page(GFP_ATOMIC); 3099 real = get_zeroed_page(GFP_ATOMIC);
3100 if (real == 0) 3100 if (real == 0)
3101 return NULL; 3101 return NULL;
3102 memset((void *)real, 0, 4096);
3103 cache_push(virt_to_phys((void *)real), 4096); 3102 cache_push(virt_to_phys((void *)real), 4096);
3104 cache_clear(virt_to_phys((void *)real), 4096); 3103 cache_clear(virt_to_phys((void *)real), 4096);
3105 kernel_set_cachemode((void *)real, 4096, IOMAP_NOCACHE_SER); 3104 kernel_set_cachemode((void *)real, 4096, IOMAP_NOCACHE_SER);
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index da94e126ca83..0cd7eed9196c 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -1052,10 +1052,9 @@ static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
1052 struct asd_ascb *ascb; 1052 struct asd_ascb *ascb;
1053 unsigned long flags; 1053 unsigned long flags;
1054 1054
1055 ascb = kmem_cache_alloc(asd_ascb_cache, gfp_flags); 1055 ascb = kmem_cache_zalloc(asd_ascb_cache, gfp_flags);
1056 1056
1057 if (ascb) { 1057 if (ascb) {
1058 memset(ascb, 0, sizeof(*ascb));
1059 ascb->dma_scb.size = sizeof(struct scb); 1058 ascb->dma_scb.size = sizeof(struct scb);
1060 ascb->dma_scb.vaddr = dma_pool_alloc(asd_ha->scb_pool, 1059 ascb->dma_scb.vaddr = dma_pool_alloc(asd_ha->scb_pool,
1061 gfp_flags, 1060 gfp_flags,
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f02f48a882a9..a1cd6e6a292a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -388,10 +388,9 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
388 int err = 0; 388 int err = 0;
389 int write = (data_direction == DMA_TO_DEVICE); 389 int write = (data_direction == DMA_TO_DEVICE);
390 390
391 sioc = kmem_cache_alloc(scsi_io_context_cache, gfp); 391 sioc = kmem_cache_zalloc(scsi_io_context_cache, gfp);
392 if (!sioc) 392 if (!sioc)
393 return DRIVER_ERROR << 24; 393 return DRIVER_ERROR << 24;
394 memset(sioc, 0, sizeof(*sioc));
395 394
396 req = blk_get_request(sdev->request_queue, write, gfp); 395 req = blk_get_request(sdev->request_queue, write, gfp);
397 if (!req) 396 if (!req)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 5261f0af8b10..2964ca9df5a0 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -920,12 +920,16 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
920#ifdef __i386__ 920#ifdef __i386__
921 outb(0xff, 0x080); 921 outb(0xff, 0x080);
922#endif 922#endif
923 scratch2 = serial_inp(up, UART_IER); 923 /*
924 * Mask out IER[7:4] bits for test as some UARTs (e.g. TL
925 * 16C754B) allow only to modify them if an EFR bit is set.
926 */
927 scratch2 = serial_inp(up, UART_IER) & 0x0f;
924 serial_outp(up, UART_IER, 0x0F); 928 serial_outp(up, UART_IER, 0x0F);
925#ifdef __i386__ 929#ifdef __i386__
926 outb(0, 0x080); 930 outb(0, 0x080);
927#endif 931#endif
928 scratch3 = serial_inp(up, UART_IER); 932 scratch3 = serial_inp(up, UART_IER) & 0x0f;
929 serial_outp(up, UART_IER, scratch); 933 serial_outp(up, UART_IER, scratch);
930 if (scratch2 != 0 || scratch3 != 0x0F) { 934 if (scratch2 != 0 || scratch3 != 0x0F) {
931 /* 935 /*
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 52e2e64c6649..a2dac378bda9 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -679,6 +679,13 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
679 */ 679 */
680 { 680 {
681 .vendor = PCI_VENDOR_ID_PLX, 681 .vendor = PCI_VENDOR_ID_PLX,
682 .device = PCI_DEVICE_ID_PLX_9030,
683 .subvendor = PCI_SUBVENDOR_ID_PERLE,
684 .subdevice = PCI_ANY_ID,
685 .setup = pci_default_setup,
686 },
687 {
688 .vendor = PCI_VENDOR_ID_PLX,
682 .device = PCI_DEVICE_ID_PLX_9050, 689 .device = PCI_DEVICE_ID_PLX_9050,
683 .subvendor = PCI_SUBVENDOR_ID_EXSYS, 690 .subvendor = PCI_SUBVENDOR_ID_EXSYS,
684 .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055, 691 .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055,
@@ -936,6 +943,7 @@ enum pci_board_num_t {
936 943
937 pbn_b2_1_115200, 944 pbn_b2_1_115200,
938 pbn_b2_2_115200, 945 pbn_b2_2_115200,
946 pbn_b2_4_115200,
939 pbn_b2_8_115200, 947 pbn_b2_8_115200,
940 948
941 pbn_b2_1_460800, 949 pbn_b2_1_460800,
@@ -1249,6 +1257,12 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1249 .base_baud = 115200, 1257 .base_baud = 115200,
1250 .uart_offset = 8, 1258 .uart_offset = 8,
1251 }, 1259 },
1260 [pbn_b2_4_115200] = {
1261 .flags = FL_BASE2,
1262 .num_ports = 4,
1263 .base_baud = 115200,
1264 .uart_offset = 8,
1265 },
1252 [pbn_b2_8_115200] = { 1266 [pbn_b2_8_115200] = {
1253 .flags = FL_BASE2, 1267 .flags = FL_BASE2,
1254 .num_ports = 8, 1268 .num_ports = 8,
@@ -1990,6 +2004,10 @@ static struct pci_device_id serial_pci_tbl[] = {
1990 { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM, 2004 { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM,
1991 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2005 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1992 pbn_panacom2 }, 2006 pbn_panacom2 },
2007 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
2008 PCI_VENDOR_ID_ESDGMBH,
2009 PCI_DEVICE_ID_ESDGMBH_CPCIASIO4, 0, 0,
2010 pbn_b2_4_115200 },
1993 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, 2011 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
1994 PCI_SUBVENDOR_ID_CHASE_PCIFAST, 2012 PCI_SUBVENDOR_ID_CHASE_PCIFAST,
1995 PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0, 2013 PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0,
@@ -2379,6 +2397,15 @@ static struct pci_device_id serial_pci_tbl[] = {
2379 pbn_b2_2_115200 }, 2397 pbn_b2_2_115200 },
2380 2398
2381 /* 2399 /*
2400 * Perle PCI-RAS cards
2401 */
2402 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
2403 PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS4,
2404 0, 0, pbn_b2_4_921600 },
2405 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030,
2406 PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS8,
2407 0, 0, pbn_b2_8_921600 },
2408 /*
2382 * These entries match devices with class COMMUNICATION_SERIAL, 2409 * These entries match devices with class COMMUNICATION_SERIAL,
2383 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 2410 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
2384 */ 2411 */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 2978c09860ee..5cc6b91f8408 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -916,6 +916,11 @@ config SERIAL_TXX9
916config HAS_TXX9_SERIAL 916config HAS_TXX9_SERIAL
917 bool 917 bool
918 918
919config SERIAL_TXX9_NR_UARTS
920 int "Maximum number of TMPTX39XX/49XX SIO ports"
921 depends on SERIAL_TXX9
922 default "6"
923
919config SERIAL_TXX9_CONSOLE 924config SERIAL_TXX9_CONSOLE
920 bool "TMPTX39XX/49XX SIO Console support" 925 bool "TMPTX39XX/49XX SIO Console support"
921 depends on SERIAL_TXX9=y 926 depends on SERIAL_TXX9=y
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 42b050c46abe..312bef6bd583 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -3173,12 +3173,8 @@ do_softint(void *private_)
3173 if (!tty) 3173 if (!tty)
3174 return; 3174 return;
3175 3175
3176 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { 3176 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
3177 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 3177 tty_wakeup(tty);
3178 tty->ldisc.write_wakeup)
3179 (tty->ldisc.write_wakeup)(tty);
3180 wake_up_interruptible(&tty->write_wait);
3181 }
3182} 3178}
3183 3179
3184static int 3180static int
@@ -3798,11 +3794,7 @@ rs_flush_buffer(struct tty_struct *tty)
3798 info->xmit.head = info->xmit.tail = 0; 3794 info->xmit.head = info->xmit.tail = 0;
3799 restore_flags(flags); 3795 restore_flags(flags);
3800 3796
3801 wake_up_interruptible(&tty->write_wait); 3797 tty_wakeup(tty);
3802
3803 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
3804 tty->ldisc.write_wakeup)
3805 (tty->ldisc.write_wakeup)(tty);
3806} 3798}
3807 3799
3808/* 3800/*
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index c862f67c985a..f540212e7409 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -2685,7 +2685,7 @@ static int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
2685 free_irq(control->ic_irq, soft); 2685 free_irq(control->ic_irq, soft);
2686 if (soft->is_ioc4_serial_addr) { 2686 if (soft->is_ioc4_serial_addr) {
2687 iounmap(soft->is_ioc4_serial_addr); 2687 iounmap(soft->is_ioc4_serial_addr);
2688 release_region((unsigned long) 2688 release_mem_region((unsigned long)
2689 soft->is_ioc4_serial_addr, 2689 soft->is_ioc4_serial_addr,
2690 sizeof(struct ioc4_serial)); 2690 sizeof(struct ioc4_serial));
2691 } 2691 }
@@ -2790,7 +2790,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2790 /* request serial registers */ 2790 /* request serial registers */
2791 tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET; 2791 tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET;
2792 2792
2793 if (!request_region(tmp_addr1, sizeof(struct ioc4_serial), 2793 if (!request_mem_region(tmp_addr1, sizeof(struct ioc4_serial),
2794 "sioc4_uart")) { 2794 "sioc4_uart")) {
2795 printk(KERN_WARNING 2795 printk(KERN_WARNING
2796 "ioc4 (%p): unable to get request region for " 2796 "ioc4 (%p): unable to get request region for "
@@ -2889,7 +2889,7 @@ out3:
2889out2: 2889out2:
2890 if (serial) 2890 if (serial)
2891 iounmap(serial); 2891 iounmap(serial);
2892 release_region(tmp_addr1, sizeof(struct ioc4_serial)); 2892 release_mem_region(tmp_addr1, sizeof(struct ioc4_serial));
2893out1: 2893out1:
2894 2894
2895 return ret; 2895 return ret;
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 7186a82c4759..f4440d329310 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -37,6 +37,7 @@
37 * 1.06 Do not insert a char caused previous overrun. 37 * 1.06 Do not insert a char caused previous overrun.
38 * Fix some spin_locks. 38 * Fix some spin_locks.
39 * Do not call uart_add_one_port for absent ports. 39 * Do not call uart_add_one_port for absent ports.
40 * 1.07 Use CONFIG_SERIAL_TXX9_NR_UARTS. Cleanup.
40 */ 41 */
41 42
42#if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 43#if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -58,9 +59,8 @@
58#include <linux/mutex.h> 59#include <linux/mutex.h>
59 60
60#include <asm/io.h> 61#include <asm/io.h>
61#include <asm/irq.h>
62 62
63static char *serial_version = "1.06"; 63static char *serial_version = "1.07";
64static char *serial_name = "TX39/49 Serial driver"; 64static char *serial_name = "TX39/49 Serial driver";
65 65
66#define PASS_LIMIT 256 66#define PASS_LIMIT 256
@@ -88,12 +88,7 @@ static char *serial_name = "TX39/49 Serial driver";
88/* 88/*
89 * Number of serial ports 89 * Number of serial ports
90 */ 90 */
91#ifdef ENABLE_SERIAL_TXX9_PCI 91#define UART_NR CONFIG_SERIAL_TXX9_NR_UARTS
92#define NR_PCI_BOARDS 4
93#define UART_NR (4 + NR_PCI_BOARDS)
94#else
95#define UART_NR 4
96#endif
97 92
98#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) 93#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
99 94
@@ -987,6 +982,7 @@ int __init early_serial_txx9_setup(struct uart_port *port)
987} 982}
988 983
989#ifdef ENABLE_SERIAL_TXX9_PCI 984#ifdef ENABLE_SERIAL_TXX9_PCI
985#ifdef CONFIG_PM
990/** 986/**
991 * serial_txx9_suspend_port - suspend one serial port 987 * serial_txx9_suspend_port - suspend one serial port
992 * @line: serial line number 988 * @line: serial line number
@@ -1008,6 +1004,7 @@ static void serial_txx9_resume_port(int line)
1008{ 1004{
1009 uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port); 1005 uart_resume_port(&serial_txx9_reg, &serial_txx9_ports[line].port);
1010} 1006}
1007#endif
1011 1008
1012static DEFINE_MUTEX(serial_txx9_mutex); 1009static DEFINE_MUTEX(serial_txx9_mutex);
1013 1010
@@ -1118,6 +1115,7 @@ static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev)
1118 } 1115 }
1119} 1116}
1120 1117
1118#ifdef CONFIG_PM
1121static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state) 1119static int pciserial_txx9_suspend_one(struct pci_dev *dev, pm_message_t state)
1122{ 1120{
1123 int line = (int)(long)pci_get_drvdata(dev); 1121 int line = (int)(long)pci_get_drvdata(dev);
@@ -1142,11 +1140,10 @@ static int pciserial_txx9_resume_one(struct pci_dev *dev)
1142 } 1140 }
1143 return 0; 1141 return 0;
1144} 1142}
1143#endif
1145 1144
1146static struct pci_device_id serial_txx9_pci_tbl[] = { 1145static const struct pci_device_id serial_txx9_pci_tbl[] = {
1147 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC, 1146 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC) },
1148 PCI_ANY_ID, PCI_ANY_ID,
1149 0, 0, 0 },
1150 { 0, } 1147 { 0, }
1151}; 1148};
1152 1149
@@ -1154,8 +1151,10 @@ static struct pci_driver serial_txx9_pci_driver = {
1154 .name = "serial_txx9", 1151 .name = "serial_txx9",
1155 .probe = pciserial_txx9_init_one, 1152 .probe = pciserial_txx9_init_one,
1156 .remove = __devexit_p(pciserial_txx9_remove_one), 1153 .remove = __devexit_p(pciserial_txx9_remove_one),
1154#ifdef CONFIG_PM
1157 .suspend = pciserial_txx9_suspend_one, 1155 .suspend = pciserial_txx9_suspend_one,
1158 .resume = pciserial_txx9_resume_one, 1156 .resume = pciserial_txx9_resume_one,
1157#endif
1159 .id_table = serial_txx9_pci_tbl, 1158 .id_table = serial_txx9_pci_tbl,
1160}; 1159};
1161 1160
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index cd6b65333b71..2dd6eed50aa0 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -654,7 +654,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
654 ret = -ENODEV; 654 ret = -ENODEV;
655 goto out_pci; 655 goto out_pci;
656 } 656 }
657 if (!request_region(idd->pma, IOC3_PCI_SIZE, "ioc3")) { 657 if (!request_mem_region(idd->pma, IOC3_PCI_SIZE, "ioc3")) {
658 printk(KERN_WARNING 658 printk(KERN_WARNING
659 "%s: Unable to request IOC3 region " 659 "%s: Unable to request IOC3 region "
660 "for pci_dev %s.\n", 660 "for pci_dev %s.\n",
@@ -744,7 +744,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
744 return 0; 744 return 0;
745 745
746out_misc_region: 746out_misc_region:
747 release_region(idd->pma, IOC3_PCI_SIZE); 747 release_mem_region(idd->pma, IOC3_PCI_SIZE);
748out_pci: 748out_pci:
749 kfree(idd); 749 kfree(idd);
750out_idd: 750out_idd:
@@ -785,7 +785,7 @@ static void ioc3_remove(struct pci_dev *pdev)
785 if(idd->dual_irq) 785 if(idd->dual_irq)
786 free_irq(idd->irq_eth, (void *)idd); 786 free_irq(idd->irq_eth, (void *)idd);
787 iounmap(idd->vma); 787 iounmap(idd->vma);
788 release_region(idd->pma, IOC3_PCI_SIZE); 788 release_mem_region(idd->pma, IOC3_PCI_SIZE);
789 789
790 /* Disable IOC3 and relinquish */ 790 /* Disable IOC3 and relinquish */
791 pci_disable_device(pdev); 791 pci_disable_device(pdev);
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index fc3197273663..3d72aa5cfc71 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -626,10 +626,8 @@ static void do_softint(unsigned long private_)
626 if (!tty) 626 if (!tty)
627 return; 627 return;
628 628
629 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { 629 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
630 tty_wakeup(tty); 630 tty_wakeup(tty);
631 wake_up_interruptible(&tty->write_wait);
632 }
633} 631}
634 632
635static int zs_startup(struct dec_serial * info) 633static int zs_startup(struct dec_serial * info)
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index f04a29a46646..c6b6479fa4dd 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1953,7 +1953,7 @@ static void invalidate_sub(struct lun *curlun)
1953 struct inode *inode = filp->f_path.dentry->d_inode; 1953 struct inode *inode = filp->f_path.dentry->d_inode;
1954 unsigned long rc; 1954 unsigned long rc;
1955 1955
1956 rc = invalidate_inode_pages(inode->i_mapping); 1956 rc = invalidate_mapping_pages(inode->i_mapping, 0, -1);
1957 VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc); 1957 VLDBG(curlun, "invalidate_inode_pages -> %ld\n", rc);
1958} 1958}
1959 1959
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 408c3380d602..6ec8cf1a3ccb 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1419,7 +1419,6 @@ int __devinit rndis_init (void)
1419 return -EIO; 1419 return -EIO;
1420 } 1420 }
1421 1421
1422 rndis_connect_state [i]->nlink = 1;
1423 rndis_connect_state [i]->write_proc = rndis_proc_write; 1422 rndis_connect_state [i]->write_proc = rndis_proc_write;
1424 rndis_connect_state [i]->read_proc = rndis_proc_read; 1423 rndis_connect_state [i]->read_proc = rndis_proc_read;
1425 rndis_connect_state [i]->data = (void *) 1424 rndis_connect_state [i]->data = (void *)
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 282d82efc0b0..f0ffb8907f29 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -2163,9 +2163,8 @@ static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid)
2163 2163
2164 maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); 2164 maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
2165 2165
2166 sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_FLAG); 2166 sb_desc = kmem_cache_zalloc(usb_desc_cache, SLAB_FLAG);
2167 assert(sb_desc != NULL); 2167 assert(sb_desc != NULL);
2168 memset(sb_desc, 0, sizeof(USB_SB_Desc_t));
2169 2168
2170 2169
2171 if (usb_pipeout(urb->pipe)) { 2170 if (usb_pipeout(urb->pipe)) {
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 2cbb239e63f8..68e66b33e726 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -624,12 +624,10 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
624{ 624{
625 struct urb_priv *urbp; 625 struct urb_priv *urbp;
626 626
627 urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC); 627 urbp = kmem_cache_zalloc(uhci_up_cachep, GFP_ATOMIC);
628 if (!urbp) 628 if (!urbp)
629 return NULL; 629 return NULL;
630 630
631 memset((void *)urbp, 0, sizeof(*urbp));
632
633 urbp->urb = urb; 631 urbp->urb = urb;
634 urb->hcpriv = urbp; 632 urb->hcpriv = urbp;
635 633
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 0b0fb51bad3e..d78692c01cfa 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -616,15 +616,7 @@ static void digi_wakeup_write_lock(struct work_struct *work)
616 616
617static void digi_wakeup_write( struct usb_serial_port *port ) 617static void digi_wakeup_write( struct usb_serial_port *port )
618{ 618{
619 619 tty_wakeup(port->tty);
620 struct tty_struct *tty = port->tty;
621
622
623 /* wake up port processes */
624 wake_up_interruptible( &port->write_wait );
625
626 /* wake up line discipline */
627 tty_wakeup(tty);
628} 620}
629 621
630 622
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index da514cb785b3..dd0b66a6ed5d 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -182,13 +182,8 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
182 struct keyspan_pda_private *priv = 182 struct keyspan_pda_private *priv =
183 container_of(work, struct keyspan_pda_private, wakeup_work); 183 container_of(work, struct keyspan_pda_private, wakeup_work);
184 struct usb_serial_port *port = priv->port; 184 struct usb_serial_port *port = priv->port;
185 struct tty_struct *tty = port->tty;
186 185
187 /* wake up port processes */ 186 tty_wakeup(port->tty);
188 wake_up_interruptible( &port->write_wait );
189
190 /* wake up line discipline */
191 tty_wakeup(tty);
192} 187}
193 188
194static void keyspan_pda_request_unthrottle(struct work_struct *work) 189static void keyspan_pda_request_unthrottle(struct work_struct *work)
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 6109c6704a73..2d588fb82573 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -269,18 +269,8 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
269 269
270 tty = mos7720_port->port->tty; 270 tty = mos7720_port->port->tty;
271 271
272 if (tty && mos7720_port->open) { 272 if (tty && mos7720_port->open)
273 /* let the tty driver wakeup if it has a special * 273 tty_wakeup(tty);
274 * write_wakeup function */
275 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
276 tty->ldisc.write_wakeup)
277 (tty->ldisc.write_wakeup)(tty);
278
279 /* tell the tty driver that something has changed */
280 wake_up_interruptible(&tty->write_wait);
281 }
282
283 /* schedule_work(&mos7720_port->port->work); */
284} 274}
285 275
286/* 276/*
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index b2264a87617b..c6cca859af45 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -755,18 +755,8 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
755 755
756 tty = mos7840_port->port->tty; 756 tty = mos7840_port->port->tty;
757 757
758 if (tty && mos7840_port->open) { 758 if (tty && mos7840_port->open)
759 /* let the tty driver wakeup if it has a special * 759 tty_wakeup(tty);
760 * write_wakeup function */
761
762 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
763 && tty->ldisc.write_wakeup) {
764 (tty->ldisc.write_wakeup) (tty);
765 }
766
767 /* tell the tty driver that something has changed */
768 wake_up_interruptible(&tty->write_wait);
769 }
770 760
771} 761}
772 762
diff --git a/drivers/video/sa1100fb.h b/drivers/video/sa1100fb.h
index 0b07f6ae3367..48066ef3af05 100644
--- a/drivers/video/sa1100fb.h
+++ b/drivers/video/sa1100fb.h
@@ -110,9 +110,7 @@ struct sa1100fb_info {
110#endif 110#endif
111}; 111};
112 112
113#define __type_entry(ptr,type,member) ((type *)((char *)(ptr)-offsetof(type,member))) 113#define TO_INF(ptr,member) container_of(ptr,struct sa1100fb_info,member)
114
115#define TO_INF(ptr,member) __type_entry(ptr,struct sa1100fb_info,member)
116 114
117#define SA1100_PALETTE_MODE_VAL(bpp) (((bpp) & 0x018) << 9) 115#define SA1100_PALETTE_MODE_VAL(bpp) (((bpp) & 0x018) << 9)
118 116