aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig57
-rw-r--r--drivers/char/Makefile4
-rw-r--r--drivers/char/agp/Kconfig7
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c81
-rw-r--r--drivers/char/agp/ati-agp.c2
-rw-r--r--drivers/char/agp/efficeon-agp.c2
-rw-r--r--drivers/char/agp/hp-agp.c2
-rw-r--r--drivers/char/agp/sgi-agp.c5
-rw-r--r--drivers/char/applicom.c49
-rw-r--r--drivers/char/cyclades.c7
-rw-r--r--drivers/char/drm/drm_memory_debug.h2
-rw-r--r--drivers/char/drm/i915_dma.c4
-rw-r--r--drivers/char/drm/i915_drm.h13
-rw-r--r--drivers/char/drm/i915_drv.h6
-rw-r--r--drivers/char/drm/i915_irq.c69
-rw-r--r--drivers/char/drm/radeon_cp.c6
-rw-r--r--drivers/char/drm/radeon_drm.h7
-rw-r--r--drivers/char/drm/radeon_drv.h10
-rw-r--r--drivers/char/drm/radeon_state.c39
-rw-r--r--drivers/char/drm/via_dmablit.c2
-rw-r--r--drivers/char/epca.c2
-rw-r--r--drivers/char/esp.c4
-rw-r--r--drivers/char/hangcheck-timer.c4
-rw-r--r--drivers/char/hpet.c5
-rw-r--r--drivers/char/hvc_console.c4
-rw-r--r--drivers/char/hvc_rtas.c37
-rw-r--r--drivers/char/hvcs.c11
-rw-r--r--drivers/char/hvsi.c2
-rw-r--r--drivers/char/hw_random.c698
-rw-r--r--drivers/char/hw_random/Kconfig90
-rw-r--r--drivers/char/hw_random/Makefile11
-rw-r--r--drivers/char/hw_random/amd-rng.c152
-rw-r--r--drivers/char/hw_random/core.c354
-rw-r--r--drivers/char/hw_random/geode-rng.c128
-rw-r--r--drivers/char/hw_random/intel-rng.c189
-rw-r--r--drivers/char/hw_random/ixp4xx-rng.c73
-rw-r--r--drivers/char/hw_random/omap-rng.c208
-rw-r--r--drivers/char/hw_random/via-rng.c183
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c23
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c69
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c43
-rw-r--r--drivers/char/isicom.c4
-rw-r--r--drivers/char/istallion.c1819
-rw-r--r--drivers/char/keyboard.c27
-rw-r--r--drivers/char/mmtimer.c1
-rw-r--r--drivers/char/moxa.c2
-rw-r--r--drivers/char/mxser.c837
-rw-r--r--drivers/char/n_r3964.c3
-rw-r--r--drivers/char/n_tty.c6
-rw-r--r--drivers/char/nsc_gpio.c142
-rw-r--r--drivers/char/pc8736x_gpio.c340
-rw-r--r--drivers/char/pcmcia/synclink_cs.c58
-rw-r--r--drivers/char/pty.c2
-rw-r--r--drivers/char/rio/daemon.h12
-rw-r--r--drivers/char/rio/func.h25
-rw-r--r--drivers/char/rio/host.h16
-rw-r--r--drivers/char/rio/port.h16
-rw-r--r--drivers/char/rio/rio.h4
-rw-r--r--drivers/char/rio/rio_linux.c31
-rw-r--r--drivers/char/rio/rio_linux.h20
-rw-r--r--drivers/char/rio/rioboot.c54
-rw-r--r--drivers/char/rio/riocmd.c36
-rw-r--r--drivers/char/rio/rioctrl.c182
-rw-r--r--drivers/char/rio/rioinit.c28
-rw-r--r--drivers/char/rio/riointr.c44
-rw-r--r--drivers/char/rio/rioparam.c28
-rw-r--r--drivers/char/rio/rioroute.c22
-rw-r--r--drivers/char/rio/riotable.c24
-rw-r--r--drivers/char/rio/riotty.c2
-rw-r--r--drivers/char/rio/unixrup.h2
-rw-r--r--drivers/char/rocket.c62
-rw-r--r--drivers/char/rtc.c8
-rw-r--r--drivers/char/scx200_gpio.c162
-rw-r--r--drivers/char/sonypi.c10
-rw-r--r--drivers/char/specialix.c6
-rw-r--r--drivers/char/stallion.c211
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink_gt.c119
-rw-r--r--drivers/char/synclinkmp.c4
-rw-r--r--drivers/char/tlclk.c2
-rw-r--r--drivers/char/tty_io.c86
-rw-r--r--drivers/char/viotape.c2
-rw-r--r--drivers/char/vr41xx_giu.c4
-rw-r--r--drivers/char/vt.c580
-rw-r--r--drivers/char/watchdog/at91_wdt.c82
-rw-r--r--drivers/char/watchdog/i8xx_tco.c28
-rw-r--r--drivers/char/watchdog/pcwd_pci.c30
-rw-r--r--drivers/char/watchdog/pcwd_usb.c23
90 files changed, 4674 insertions, 3212 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 78d928f9d9f1..c40e487d9f5c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -62,6 +62,23 @@ config HW_CONSOLE
62 depends on VT && !S390 && !UML 62 depends on VT && !S390 && !UML
63 default y 63 default y
64 64
65config VT_HW_CONSOLE_BINDING
66 bool "Support for binding and unbinding console drivers"
67 depends on HW_CONSOLE
68 default n
69 ---help---
70 The virtual terminal is the device that interacts with the physical
71 terminal through console drivers. On these systems, at least one
72 console driver is loaded. In other configurations, additional console
73 drivers may be enabled, such as the framebuffer console. If more than
74 1 console driver is enabled, setting this to 'y' will allow you to
75 select the console driver that will serve as the backend for the
76 virtual terminals.
77
78 See <file:Documentation/console/console.txt> for more
79 information. For framebuffer console users, please refer to
80 <file:Documentation/fb/fbcon.txt>.
81
65config SERIAL_NONSTANDARD 82config SERIAL_NONSTANDARD
66 bool "Non-standard serial port support" 83 bool "Non-standard serial port support"
67 ---help--- 84 ---help---
@@ -670,20 +687,7 @@ config NWFLASH
670 687
671 If you're not sure, say N. 688 If you're not sure, say N.
672 689
673config HW_RANDOM 690source "drivers/char/hw_random/Kconfig"
674 tristate "Intel/AMD/VIA HW Random Number Generator support"
675 depends on (X86 || IA64) && PCI
676 ---help---
677 This driver provides kernel-side support for the Random Number
678 Generator hardware found on Intel i8xx-based motherboards,
679 AMD 76x-based motherboards, and Via Nehemiah CPUs.
680
681 Provides a character driver, used to read() entropy data.
682
683 To compile this driver as a module, choose M here: the
684 module will be called hw_random.
685
686 If unsure, say N.
687 691
688config NVRAM 692config NVRAM
689 tristate "/dev/nvram support" 693 tristate "/dev/nvram support"
@@ -865,6 +869,7 @@ config SONYPI
865config TANBAC_TB0219 869config TANBAC_TB0219
866 tristate "TANBAC TB0219 base board support" 870 tristate "TANBAC TB0219 base board support"
867 depends TANBAC_TB022X 871 depends TANBAC_TB022X
872 select GPIO_VR41XX
868 873
869menu "Ftape, the floppy tape device driver" 874menu "Ftape, the floppy tape device driver"
870 875
@@ -934,12 +939,36 @@ config MWAVE
934config SCx200_GPIO 939config SCx200_GPIO
935 tristate "NatSemi SCx200 GPIO Support" 940 tristate "NatSemi SCx200 GPIO Support"
936 depends on SCx200 941 depends on SCx200
942 select NSC_GPIO
937 help 943 help
938 Give userspace access to the GPIO pins on the National 944 Give userspace access to the GPIO pins on the National
939 Semiconductor SCx200 processors. 945 Semiconductor SCx200 processors.
940 946
941 If compiled as a module, it will be called scx200_gpio. 947 If compiled as a module, it will be called scx200_gpio.
942 948
949config PC8736x_GPIO
950 tristate "NatSemi PC8736x GPIO Support"
951 depends on X86
952 default SCx200_GPIO # mostly N
953 select NSC_GPIO # needed for support routines
954 help
955 Give userspace access to the GPIO pins on the National
956 Semiconductor PC-8736x (x=[03456]) SuperIO chip. The chip
957 has multiple functional units, inc several managed by
958 hwmon/pc87360 driver. Tested with PC-87366
959
960 If compiled as a module, it will be called pc8736x_gpio.
961
962config NSC_GPIO
963 tristate "NatSemi Base GPIO Support"
964 depends on X86_32
965 # selected by SCx200_GPIO and PC8736x_GPIO
966 # what about 2 selectors differing: m != y
967 help
968 Common support used (and needed) by scx200_gpio and
969 pc8736x_gpio drivers. If those drivers are built as
970 modules, this one will be too, named nsc_gpio
971
943config CS5535_GPIO 972config CS5535_GPIO
944 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)" 973 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)"
945 depends on X86_32 974 depends on X86_32
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index fb919bfb2824..6e0f4469d8bb 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -75,13 +75,15 @@ endif
75obj-$(CONFIG_TOSHIBA) += toshiba.o 75obj-$(CONFIG_TOSHIBA) += toshiba.o
76obj-$(CONFIG_I8K) += i8k.o 76obj-$(CONFIG_I8K) += i8k.o
77obj-$(CONFIG_DS1620) += ds1620.o 77obj-$(CONFIG_DS1620) += ds1620.o
78obj-$(CONFIG_HW_RANDOM) += hw_random.o 78obj-$(CONFIG_HW_RANDOM) += hw_random/
79obj-$(CONFIG_FTAPE) += ftape/ 79obj-$(CONFIG_FTAPE) += ftape/
80obj-$(CONFIG_COBALT_LCD) += lcd.o 80obj-$(CONFIG_COBALT_LCD) += lcd.o
81obj-$(CONFIG_PPDEV) += ppdev.o 81obj-$(CONFIG_PPDEV) += ppdev.o
82obj-$(CONFIG_NWBUTTON) += nwbutton.o 82obj-$(CONFIG_NWBUTTON) += nwbutton.o
83obj-$(CONFIG_NWFLASH) += nwflash.o 83obj-$(CONFIG_NWFLASH) += nwflash.o
84obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 84obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
85obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
86obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
85obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 87obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
86obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o 88obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
87obj-$(CONFIG_TANBAC_TB0219) += tb0219.o 89obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 3dbbb9544ae8..22f8cf218cc6 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -1,8 +1,7 @@
1config AGP 1config AGP
2 tristate "/dev/agpgart (AGP Support)" if !GART_IOMMU 2 tristate "/dev/agpgart (AGP Support)"
3 depends on ALPHA || IA64 || PPC || X86 3 depends on ALPHA || IA64 || PPC || X86
4 depends on PCI 4 depends on PCI
5 default y if GART_IOMMU
6 ---help--- 5 ---help---
7 AGP (Accelerated Graphics Port) is a bus system mainly used to 6 AGP (Accelerated Graphics Port) is a bus system mainly used to
8 connect graphics cards to the rest of the system. 7 connect graphics cards to the rest of the system.
@@ -57,9 +56,9 @@ config AGP_AMD
57 X on AMD Irongate, 761, and 762 chipsets. 56 X on AMD Irongate, 761, and 762 chipsets.
58 57
59config AGP_AMD64 58config AGP_AMD64
60 tristate "AMD Opteron/Athlon64 on-CPU GART support" if !GART_IOMMU 59 tristate "AMD Opteron/Athlon64 on-CPU GART support" if !IOMMU
61 depends on AGP && X86 60 depends on AGP && X86
62 default y if GART_IOMMU 61 default y if IOMMU
63 help 62 help
64 This option gives you AGP support for the GLX component of 63 This option gives you AGP support for the GLX component of
65 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs. 64 X using the on-CPU northbridge of the AMD Athlon64/Opteron CPUs.
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 1f776651ac64..51d0d562d01e 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -118,7 +118,7 @@ static int amd_create_gatt_pages(int nr_tables)
118 return retval; 118 return retval;
119} 119}
120 120
121/* Since we don't need contigious memory we just try 121/* Since we don't need contiguous memory we just try
122 * to get the gatt table once 122 * to get the gatt table once
123 */ 123 */
124 124
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index e449d949f7ea..f74eeeb8e377 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -15,11 +15,9 @@
15#include <linux/agp_backend.h> 15#include <linux/agp_backend.h>
16#include <linux/mmzone.h> 16#include <linux/mmzone.h>
17#include <asm/page.h> /* PAGE_SIZE */ 17#include <asm/page.h> /* PAGE_SIZE */
18#include <asm/k8.h>
18#include "agp.h" 19#include "agp.h"
19 20
20/* Will need to be increased if AMD64 ever goes >8-way. */
21#define MAX_HAMMER_GARTS 8
22
23/* PTE bits. */ 21/* PTE bits. */
24#define GPTE_VALID 1 22#define GPTE_VALID 1
25#define GPTE_COHERENT 2 23#define GPTE_COHERENT 2
@@ -53,28 +51,12 @@
53#define ULI_X86_64_HTT_FEA_REG 0x50 51#define ULI_X86_64_HTT_FEA_REG 0x50
54#define ULI_X86_64_ENU_SCR_REG 0x54 52#define ULI_X86_64_ENU_SCR_REG 0x54
55 53
56static int nr_garts;
57static struct pci_dev * hammers[MAX_HAMMER_GARTS];
58
59static struct resource *aperture_resource; 54static struct resource *aperture_resource;
60static int __initdata agp_try_unsupported = 1; 55static int __initdata agp_try_unsupported = 1;
61 56
62#define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
63
64static void flush_amd64_tlb(struct pci_dev *dev)
65{
66 u32 tmp;
67
68 pci_read_config_dword (dev, AMD64_GARTCACHECTL, &tmp);
69 tmp |= INVGART;
70 pci_write_config_dword (dev, AMD64_GARTCACHECTL, tmp);
71}
72
73static void amd64_tlbflush(struct agp_memory *temp) 57static void amd64_tlbflush(struct agp_memory *temp)
74{ 58{
75 int gart_iterator; 59 k8_flush_garts();
76 for_each_nb()
77 flush_amd64_tlb(hammers[gart_iterator]);
78} 60}
79 61
80static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 62static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
@@ -153,7 +135,7 @@ static int amd64_fetch_size(void)
153 u32 temp; 135 u32 temp;
154 struct aper_size_info_32 *values; 136 struct aper_size_info_32 *values;
155 137
156 dev = hammers[0]; 138 dev = k8_northbridges[0];
157 if (dev==NULL) 139 if (dev==NULL)
158 return 0; 140 return 0;
159 141
@@ -201,9 +183,6 @@ static u64 amd64_configure (struct pci_dev *hammer, u64 gatt_table)
201 tmp &= ~(DISGARTCPU | DISGARTIO); 183 tmp &= ~(DISGARTCPU | DISGARTIO);
202 pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp); 184 pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp);
203 185
204 /* keep CPU's coherent. */
205 flush_amd64_tlb (hammer);
206
207 return aper_base; 186 return aper_base;
208} 187}
209 188
@@ -222,13 +201,14 @@ static struct aper_size_info_32 amd_8151_sizes[7] =
222static int amd_8151_configure(void) 201static int amd_8151_configure(void)
223{ 202{
224 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real); 203 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
225 int gart_iterator; 204 int i;
226 205
227 /* Configure AGP regs in each x86-64 host bridge. */ 206 /* Configure AGP regs in each x86-64 host bridge. */
228 for_each_nb() { 207 for (i = 0; i < num_k8_northbridges; i++) {
229 agp_bridge->gart_bus_addr = 208 agp_bridge->gart_bus_addr =
230 amd64_configure(hammers[gart_iterator],gatt_bus); 209 amd64_configure(k8_northbridges[i], gatt_bus);
231 } 210 }
211 k8_flush_garts();
232 return 0; 212 return 0;
233} 213}
234 214
@@ -236,12 +216,13 @@ static int amd_8151_configure(void)
236static void amd64_cleanup(void) 216static void amd64_cleanup(void)
237{ 217{
238 u32 tmp; 218 u32 tmp;
239 int gart_iterator; 219 int i;
240 for_each_nb() { 220 for (i = 0; i < num_k8_northbridges; i++) {
221 struct pci_dev *dev = k8_northbridges[i];
241 /* disable gart translation */ 222 /* disable gart translation */
242 pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp); 223 pci_read_config_dword (dev, AMD64_GARTAPERTURECTL, &tmp);
243 tmp &= ~AMD64_GARTEN; 224 tmp &= ~AMD64_GARTEN;
244 pci_write_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, tmp); 225 pci_write_config_dword (dev, AMD64_GARTAPERTURECTL, tmp);
245 } 226 }
246} 227}
247 228
@@ -311,7 +292,7 @@ static int __devinit aperture_valid(u64 aper, u32 size)
311/* 292/*
312 * W*s centric BIOS sometimes only set up the aperture in the AGP 293 * W*s centric BIOS sometimes only set up the aperture in the AGP
313 * bridge, not the northbridge. On AMD64 this is handled early 294 * bridge, not the northbridge. On AMD64 this is handled early
314 * in aperture.c, but when GART_IOMMU is not enabled or we run 295 * in aperture.c, but when IOMMU is not enabled or we run
315 * on a 32bit kernel this needs to be redone. 296 * on a 32bit kernel this needs to be redone.
316 * Unfortunately it is impossible to fix the aperture here because it's too late 297 * Unfortunately it is impossible to fix the aperture here because it's too late
317 * to allocate that much memory. But at least error out cleanly instead of 298 * to allocate that much memory. But at least error out cleanly instead of
@@ -361,17 +342,15 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
361 342
362static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) 343static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
363{ 344{
364 struct pci_dev *loop_dev = NULL; 345 int i;
365 int i = 0; 346
366 347 if (cache_k8_northbridges() < 0)
367 /* cache pci_devs of northbridges. */ 348 return -ENODEV;
368 while ((loop_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, loop_dev)) 349
369 != NULL) { 350 i = 0;
370 if (i == MAX_HAMMER_GARTS) { 351 for (i = 0; i < num_k8_northbridges; i++) {
371 printk(KERN_ERR PFX "Too many northbridges for AGP\n"); 352 struct pci_dev *dev = k8_northbridges[i];
372 return -1; 353 if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
373 }
374 if (fix_northbridge(loop_dev, pdev, cap_ptr) < 0) {
375 printk(KERN_ERR PFX "No usable aperture found.\n"); 354 printk(KERN_ERR PFX "No usable aperture found.\n");
376#ifdef __x86_64__ 355#ifdef __x86_64__
377 /* should port this to i386 */ 356 /* should port this to i386 */
@@ -379,10 +358,8 @@ static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr)
379#endif 358#endif
380 return -1; 359 return -1;
381 } 360 }
382 hammers[i++] = loop_dev;
383 } 361 }
384 nr_garts = i; 362 return 0;
385 return i == 0 ? -1 : 0;
386} 363}
387 364
388/* Handle AMD 8151 quirks */ 365/* Handle AMD 8151 quirks */
@@ -450,7 +427,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev)
450 } 427 }
451 428
452 /* shadow x86-64 registers into ULi registers */ 429 /* shadow x86-64 registers into ULi registers */
453 pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &httfea); 430 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea);
454 431
455 /* if x86-64 aperture base is beyond 4G, exit here */ 432 /* if x86-64 aperture base is beyond 4G, exit here */
456 if ((httfea & 0x7fff) >> (32 - 25)) 433 if ((httfea & 0x7fff) >> (32 - 25))
@@ -513,7 +490,7 @@ static int __devinit nforce3_agp_init(struct pci_dev *pdev)
513 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); 490 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp);
514 491
515 /* shadow x86-64 registers into NVIDIA registers */ 492 /* shadow x86-64 registers into NVIDIA registers */
516 pci_read_config_dword (hammers[0], AMD64_GARTAPERTUREBASE, &apbase); 493 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase);
517 494
518 /* if x86-64 aperture base is beyond 4G, exit here */ 495 /* if x86-64 aperture base is beyond 4G, exit here */
519 if ( (apbase & 0x7fff) >> (32 - 25) ) { 496 if ( (apbase & 0x7fff) >> (32 - 25) ) {
@@ -754,10 +731,6 @@ static struct pci_driver agp_amd64_pci_driver = {
754int __init agp_amd64_init(void) 731int __init agp_amd64_init(void)
755{ 732{
756 int err = 0; 733 int err = 0;
757 static struct pci_device_id amd64nb[] = {
758 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x1103) },
759 { },
760 };
761 734
762 if (agp_off) 735 if (agp_off)
763 return -EINVAL; 736 return -EINVAL;
@@ -774,7 +747,7 @@ int __init agp_amd64_init(void)
774 } 747 }
775 748
776 /* First check that we have at least one AMD64 NB */ 749 /* First check that we have at least one AMD64 NB */
777 if (!pci_dev_present(amd64nb)) 750 if (!pci_dev_present(k8_nb_ids))
778 return -ENODEV; 751 return -ENODEV;
779 752
780 /* Look for any AGP bridge */ 753 /* Look for any AGP bridge */
@@ -802,7 +775,7 @@ static void __exit agp_amd64_cleanup(void)
802 775
803/* On AMD64 the PCI driver needs to initialize this driver early 776/* On AMD64 the PCI driver needs to initialize this driver early
804 for the IOMMU, so it has to be called via a backdoor. */ 777 for the IOMMU, so it has to be called via a backdoor. */
805#ifndef CONFIG_GART_IOMMU 778#ifndef CONFIG_IOMMU
806module_init(agp_amd64_init); 779module_init(agp_amd64_init);
807module_exit(agp_amd64_cleanup); 780module_exit(agp_amd64_cleanup);
808#endif 781#endif
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index d712078ed822..f244c6682738 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -263,7 +263,7 @@ static int agp_ati_resume(struct pci_dev *dev)
263#endif 263#endif
264 264
265/* 265/*
266 *Since we don't need contigious memory we just try 266 *Since we don't need contiguous memory we just try
267 * to get the gatt table once 267 * to get the gatt table once
268 */ 268 */
269 269
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 86a966b65236..b788b0a3bbf3 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -177,7 +177,7 @@ static int efficeon_free_gatt_table(struct agp_bridge_data *bridge)
177 177
178 178
179/* 179/*
180 * Since we don't need contigious memory we just try 180 * Since we don't need contiguous memory we just try
181 * to get the gatt table once 181 * to get the gatt table once
182 */ 182 */
183 183
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 8c4c6ef748ec..907fb66ec4a9 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -497,7 +497,7 @@ zx1_gart_probe (acpi_handle obj, u32 depth, void *context, void **ret)
497 info = buffer.pointer; 497 info = buffer.pointer;
498 info->hardware_id.value[sizeof(info->hardware_id)-1] = '\0'; 498 info->hardware_id.value[sizeof(info->hardware_id)-1] = '\0';
499 match = (strcmp(info->hardware_id.value, "HWP0001") == 0); 499 match = (strcmp(info->hardware_id.value, "HWP0001") == 0);
500 ACPI_MEM_FREE(info); 500 kfree(info);
501 if (match) { 501 if (match) {
502 status = hp_acpi_csr_space(handle, &sba_hpa, &length); 502 status = hp_acpi_csr_space(handle, &sba_hpa, &length);
503 if (ACPI_SUCCESS(status)) 503 if (ACPI_SUCCESS(status))
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index cfa7922cb431..d73be4c2db8a 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -329,9 +329,8 @@ static int __devinit agp_sgi_init(void)
329 329
330static void __devexit agp_sgi_cleanup(void) 330static void __devexit agp_sgi_cleanup(void)
331{ 331{
332 if (sgi_tioca_agp_bridges) 332 kfree(sgi_tioca_agp_bridges);
333 kfree(sgi_tioca_agp_bridges); 333 sgi_tioca_agp_bridges = NULL;
334 sgi_tioca_agp_bridges=NULL;
335} 334}
336 335
337module_init(agp_sgi_init); 336module_init(agp_sgi_init);
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a370e7a0bad5..72fb60765c45 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -166,11 +166,7 @@ static int ac_register_board(unsigned long physloc, void __iomem *loc,
166 return boardno + 1; 166 return boardno + 1;
167} 167}
168 168
169#ifdef MODULE 169static void __exit applicom_exit(void)
170
171#define applicom_init init_module
172
173void cleanup_module(void)
174{ 170{
175 unsigned int i; 171 unsigned int i;
176 172
@@ -188,9 +184,7 @@ void cleanup_module(void)
188 } 184 }
189} 185}
190 186
191#endif /* MODULE */ 187static int __init applicom_init(void)
192
193int __init applicom_init(void)
194{ 188{
195 int i, numisa = 0; 189 int i, numisa = 0;
196 struct pci_dev *dev = NULL; 190 struct pci_dev *dev = NULL;
@@ -215,13 +209,16 @@ int __init applicom_init(void)
215 RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO); 209 RamIO = ioremap(dev->resource[0].start, LEN_RAM_IO);
216 210
217 if (!RamIO) { 211 if (!RamIO) {
218 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory space at 0x%lx\n", dev->resource[0].start); 212 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory "
213 "space at 0x%llx\n",
214 (unsigned long long)dev->resource[0].start);
219 pci_disable_device(dev); 215 pci_disable_device(dev);
220 return -EIO; 216 return -EIO;
221 } 217 }
222 218
223 printk(KERN_INFO "Applicom %s found at mem 0x%lx, irq %d\n", 219 printk(KERN_INFO "Applicom %s found at mem 0x%llx, irq %d\n",
224 applicom_pci_devnames[dev->device-1], dev->resource[0].start, 220 applicom_pci_devnames[dev->device-1],
221 (unsigned long long)dev->resource[0].start,
225 dev->irq); 222 dev->irq);
226 223
227 boardno = ac_register_board(dev->resource[0].start, RamIO,0); 224 boardno = ac_register_board(dev->resource[0].start, RamIO,0);
@@ -355,10 +352,9 @@ out:
355 return ret; 352 return ret;
356} 353}
357 354
355module_init(applicom_init);
356module_exit(applicom_exit);
358 357
359#ifndef MODULE
360__initcall(applicom_init);
361#endif
362 358
363static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) 359static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
364{ 360{
@@ -851,28 +847,3 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
851 return 0; 847 return 0;
852} 848}
853 849
854#ifndef MODULE
855static int __init applicom_setup(char *str)
856{
857 int ints[4];
858
859 (void) get_options(str, 4, ints);
860
861 if (ints[0] > 2) {
862 printk(KERN_WARNING "Too many arguments to 'applicom=', expected mem,irq only.\n");
863 }
864
865 if (ints[0] < 2) {
866 printk(KERN_INFO"applicom numargs: %d\n", ints[0]);
867 return 0;
868 }
869
870 mem = ints[1];
871 irq = ints[2];
872 return 1;
873}
874
875__setup("applicom=", applicom_setup);
876
877#endif /* MODULE */
878
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index cc7acf877dc0..122e7a72a4e1 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -2833,9 +2833,8 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count)
2833 return 0; 2833 return 0;
2834 } 2834 }
2835 2835
2836 if (!tty || !info->xmit_buf || !tmp_buf){ 2836 if (!info->xmit_buf || !tmp_buf)
2837 return 0; 2837 return 0;
2838 }
2839 2838
2840 CY_LOCK(info, flags); 2839 CY_LOCK(info, flags);
2841 while (1) { 2840 while (1) {
@@ -2884,7 +2883,7 @@ cy_put_char(struct tty_struct *tty, unsigned char ch)
2884 if (serial_paranoia_check(info, tty->name, "cy_put_char")) 2883 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
2885 return; 2884 return;
2886 2885
2887 if (!tty || !info->xmit_buf) 2886 if (!info->xmit_buf)
2888 return; 2887 return;
2889 2888
2890 CY_LOCK(info, flags); 2889 CY_LOCK(info, flags);
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
index 6543b9a14c42..d117cc997192 100644
--- a/drivers/char/drm/drm_memory_debug.h
+++ b/drivers/char/drm/drm_memory_debug.h
@@ -43,7 +43,7 @@ typedef struct drm_mem_stats {
43 unsigned long bytes_freed; 43 unsigned long bytes_freed;
44} drm_mem_stats_t; 44} drm_mem_stats_t;
45 45
46static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED; 46static DEFINE_SPINLOCK(drm_mem_lock);
47static unsigned long drm_ram_available = 0; /* In pages */ 47static unsigned long drm_ram_available = 0; /* In pages */
48static unsigned long drm_ram_used = 0; 48static unsigned long drm_ram_used = 0;
49static drm_mem_stats_t drm_mem_stats[] = 49static drm_mem_stats_t drm_mem_stats[] =
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 9f4b8ce4c05e..a94233bdbc0e 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -758,7 +758,9 @@ drm_ioctl_desc_t i915_ioctls[] = {
758 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH}, 758 [DRM_IOCTL_NR(DRM_I915_FREE)] = {i915_mem_free, DRM_AUTH},
759 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 759 [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = {i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
760 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH}, 760 [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = {i915_cmdbuffer, DRM_AUTH},
761 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY } 761 [DRM_IOCTL_NR(DRM_I915_DESTROY_HEAP)] = { i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
762 [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY },
763 [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH },
762}; 764};
763 765
764int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 766int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h
index 4cb3da578330..5aa3e0e3bb45 100644
--- a/drivers/char/drm/i915_drm.h
+++ b/drivers/char/drm/i915_drm.h
@@ -124,6 +124,8 @@ typedef struct _drm_i915_sarea {
124#define DRM_I915_INIT_HEAP 0x0a 124#define DRM_I915_INIT_HEAP 0x0a
125#define DRM_I915_CMDBUFFER 0x0b 125#define DRM_I915_CMDBUFFER 0x0b
126#define DRM_I915_DESTROY_HEAP 0x0c 126#define DRM_I915_DESTROY_HEAP 0x0c
127#define DRM_I915_SET_VBLANK_PIPE 0x0d
128#define DRM_I915_GET_VBLANK_PIPE 0x0e
127 129
128#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 130#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
129#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 131#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -138,6 +140,8 @@ typedef struct _drm_i915_sarea {
138#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) 140#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
139#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) 141#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
140#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t) 142#define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
143#define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
144#define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
141 145
142/* Allow drivers to submit batchbuffers directly to hardware, relying 146/* Allow drivers to submit batchbuffers directly to hardware, relying
143 * on the security mechanisms provided by hardware. 147 * on the security mechanisms provided by hardware.
@@ -224,4 +228,13 @@ typedef struct drm_i915_mem_destroy_heap {
224 int region; 228 int region;
225} drm_i915_mem_destroy_heap_t; 229} drm_i915_mem_destroy_heap_t;
226 230
231/* Allow X server to configure which pipes to monitor for vblank signals
232 */
233#define DRM_I915_VBLANK_PIPE_A 1
234#define DRM_I915_VBLANK_PIPE_B 2
235
236typedef struct drm_i915_vblank_pipe {
237 int pipe;
238} drm_i915_vblank_pipe_t;
239
227#endif /* _I915_DRM_H_ */ 240#endif /* _I915_DRM_H_ */
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index 7a65666899e4..2d565031c002 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -45,9 +45,10 @@
45 * 1.2: Add Power Management 45 * 1.2: Add Power Management
46 * 1.3: Add vblank support 46 * 1.3: Add vblank support
47 * 1.4: Fix cmdbuffer path, add heap destroy 47 * 1.4: Fix cmdbuffer path, add heap destroy
48 * 1.5: Add vblank pipe configuration
48 */ 49 */
49#define DRIVER_MAJOR 1 50#define DRIVER_MAJOR 1
50#define DRIVER_MINOR 4 51#define DRIVER_MINOR 5
51#define DRIVER_PATCHLEVEL 0 52#define DRIVER_PATCHLEVEL 0
52 53
53typedef struct _drm_i915_ring_buffer { 54typedef struct _drm_i915_ring_buffer {
@@ -96,6 +97,7 @@ typedef struct drm_i915_private {
96 int allow_batchbuffer; 97 int allow_batchbuffer;
97 struct mem_block *agp_heap; 98 struct mem_block *agp_heap;
98 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds; 99 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
100 int vblank_pipe;
99} drm_i915_private_t; 101} drm_i915_private_t;
100 102
101extern drm_ioctl_desc_t i915_ioctls[]; 103extern drm_ioctl_desc_t i915_ioctls[];
@@ -119,6 +121,8 @@ extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
119extern void i915_driver_irq_preinstall(drm_device_t * dev); 121extern void i915_driver_irq_preinstall(drm_device_t * dev);
120extern void i915_driver_irq_postinstall(drm_device_t * dev); 122extern void i915_driver_irq_postinstall(drm_device_t * dev);
121extern void i915_driver_irq_uninstall(drm_device_t * dev); 123extern void i915_driver_irq_uninstall(drm_device_t * dev);
124extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS);
125extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS);
122 126
123/* i915_mem.c */ 127/* i915_mem.c */
124extern int i915_mem_alloc(DRM_IOCTL_ARGS); 128extern int i915_mem_alloc(DRM_IOCTL_ARGS);
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index a752afd86ab8..cd96cfa430db 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -44,7 +44,8 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
44 u16 temp; 44 u16 temp;
45 45
46 temp = I915_READ16(I915REG_INT_IDENTITY_R); 46 temp = I915_READ16(I915REG_INT_IDENTITY_R);
47 temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG); 47
48 temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG);
48 49
49 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); 50 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp);
50 51
@@ -58,7 +59,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
58 if (temp & USER_INT_FLAG) 59 if (temp & USER_INT_FLAG)
59 DRM_WAKEUP(&dev_priv->irq_queue); 60 DRM_WAKEUP(&dev_priv->irq_queue);
60 61
61 if (temp & VSYNC_PIPEA_FLAG) { 62 if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) {
62 atomic_inc(&dev->vbl_received); 63 atomic_inc(&dev->vbl_received);
63 DRM_WAKEUP(&dev->vbl_queue); 64 DRM_WAKEUP(&dev->vbl_queue);
64 drm_vbl_send_signals(dev); 65 drm_vbl_send_signals(dev);
@@ -182,6 +183,68 @@ int i915_irq_wait(DRM_IOCTL_ARGS)
182 return i915_wait_irq(dev, irqwait.irq_seq); 183 return i915_wait_irq(dev, irqwait.irq_seq);
183} 184}
184 185
186static int i915_enable_interrupt (drm_device_t *dev)
187{
188 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
189 u16 flag;
190
191 flag = 0;
192 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A)
193 flag |= VSYNC_PIPEA_FLAG;
194 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B)
195 flag |= VSYNC_PIPEB_FLAG;
196 if (dev_priv->vblank_pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
197 DRM_ERROR("%s called with invalid pipe 0x%x\n",
198 __FUNCTION__, dev_priv->vblank_pipe);
199 return DRM_ERR(EINVAL);
200 }
201 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | flag);
202 return 0;
203}
204
205/* Set the vblank monitor pipe
206 */
207int i915_vblank_pipe_set(DRM_IOCTL_ARGS)
208{
209 DRM_DEVICE;
210 drm_i915_private_t *dev_priv = dev->dev_private;
211 drm_i915_vblank_pipe_t pipe;
212
213 if (!dev_priv) {
214 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
215 return DRM_ERR(EINVAL);
216 }
217
218 DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data,
219 sizeof(pipe));
220
221 dev_priv->vblank_pipe = pipe.pipe;
222 return i915_enable_interrupt (dev);
223}
224
225int i915_vblank_pipe_get(DRM_IOCTL_ARGS)
226{
227 DRM_DEVICE;
228 drm_i915_private_t *dev_priv = dev->dev_private;
229 drm_i915_vblank_pipe_t pipe;
230 u16 flag;
231
232 if (!dev_priv) {
233 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
234 return DRM_ERR(EINVAL);
235 }
236
237 flag = I915_READ(I915REG_INT_ENABLE_R);
238 pipe.pipe = 0;
239 if (flag & VSYNC_PIPEA_FLAG)
240 pipe.pipe |= DRM_I915_VBLANK_PIPE_A;
241 if (flag & VSYNC_PIPEB_FLAG)
242 pipe.pipe |= DRM_I915_VBLANK_PIPE_B;
243 DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe,
244 sizeof(pipe));
245 return 0;
246}
247
185/* drm_dma.h hooks 248/* drm_dma.h hooks
186*/ 249*/
187void i915_driver_irq_preinstall(drm_device_t * dev) 250void i915_driver_irq_preinstall(drm_device_t * dev)
@@ -197,7 +260,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
197{ 260{
198 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 261 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
199 262
200 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG); 263 i915_enable_interrupt(dev);
201 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); 264 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
202} 265}
203 266
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 7f949c9c9691..5ad43ba7b5aa 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -39,7 +39,7 @@
39static int radeon_do_cleanup_cp(drm_device_t * dev); 39static int radeon_do_cleanup_cp(drm_device_t * dev);
40 40
41/* CP microcode (from ATI) */ 41/* CP microcode (from ATI) */
42static u32 R200_cp_microcode[][2] = { 42static const u32 R200_cp_microcode[][2] = {
43 {0x21007000, 0000000000}, 43 {0x21007000, 0000000000},
44 {0x20007000, 0000000000}, 44 {0x20007000, 0000000000},
45 {0x000000ab, 0x00000004}, 45 {0x000000ab, 0x00000004},
@@ -298,7 +298,7 @@ static u32 R200_cp_microcode[][2] = {
298 {0000000000, 0000000000}, 298 {0000000000, 0000000000},
299}; 299};
300 300
301static u32 radeon_cp_microcode[][2] = { 301static const u32 radeon_cp_microcode[][2] = {
302 {0x21007000, 0000000000}, 302 {0x21007000, 0000000000},
303 {0x20007000, 0000000000}, 303 {0x20007000, 0000000000},
304 {0x000000b4, 0x00000004}, 304 {0x000000b4, 0x00000004},
@@ -557,7 +557,7 @@ static u32 radeon_cp_microcode[][2] = {
557 {0000000000, 0000000000}, 557 {0000000000, 0000000000},
558}; 558};
559 559
560static u32 R300_cp_microcode[][2] = { 560static const u32 R300_cp_microcode[][2] = {
561 {0x4200e000, 0000000000}, 561 {0x4200e000, 0000000000},
562 {0x4000e000, 0000000000}, 562 {0x4000e000, 0000000000},
563 {0x000000af, 0x00000008}, 563 {0x000000af, 0x00000008},
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
index c8e279e89c2e..8d6350dd5360 100644
--- a/drivers/char/drm/radeon_drm.h
+++ b/drivers/char/drm/radeon_drm.h
@@ -161,7 +161,8 @@
161#define R200_EMIT_PP_TXCTLALL_3 91 161#define R200_EMIT_PP_TXCTLALL_3 91
162#define R200_EMIT_PP_TXCTLALL_4 92 162#define R200_EMIT_PP_TXCTLALL_4 92
163#define R200_EMIT_PP_TXCTLALL_5 93 163#define R200_EMIT_PP_TXCTLALL_5 93
164#define RADEON_MAX_STATE_PACKETS 94 164#define R200_EMIT_VAP_PVS_CNTL 94
165#define RADEON_MAX_STATE_PACKETS 95
165 166
166/* Commands understood by cmd_buffer ioctl. More can be added but 167/* Commands understood by cmd_buffer ioctl. More can be added but
167 * obviously these can't be removed or changed: 168 * obviously these can't be removed or changed:
@@ -176,6 +177,7 @@
176#define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note: 177#define RADEON_CMD_WAIT 8 /* emit hw wait commands -- note:
177 * doesn't make the cpu wait, just 178 * doesn't make the cpu wait, just
178 * the graphics hardware */ 179 * the graphics hardware */
180#define RADEON_CMD_VECLINEAR 9 /* another r200 stopgap */
179 181
180typedef union { 182typedef union {
181 int i; 183 int i;
@@ -192,6 +194,9 @@ typedef union {
192 unsigned char cmd_type, offset, stride, count; 194 unsigned char cmd_type, offset, stride, count;
193 } vectors; 195 } vectors;
194 struct { 196 struct {
197 unsigned char cmd_type, addr_lo, addr_hi, count;
198 } veclinear;
199 struct {
195 unsigned char cmd_type, buf_idx, pad0, pad1; 200 unsigned char cmd_type, buf_idx, pad0, pad1;
196 } dma; 201 } dma;
197 struct { 202 struct {
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 78345cee8f8e..e5a256f5429c 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -38,7 +38,7 @@
38 38
39#define DRIVER_NAME "radeon" 39#define DRIVER_NAME "radeon"
40#define DRIVER_DESC "ATI Radeon" 40#define DRIVER_DESC "ATI Radeon"
41#define DRIVER_DATE "20060225" 41#define DRIVER_DATE "20060524"
42 42
43/* Interface history: 43/* Interface history:
44 * 44 *
@@ -93,9 +93,11 @@
93 * 1.22- Add support for texture cache flushes (R300_TX_CNTL) 93 * 1.22- Add support for texture cache flushes (R300_TX_CNTL)
94 * 1.23- Add new radeon memory map work from benh 94 * 1.23- Add new radeon memory map work from benh
95 * 1.24- Add general-purpose packet for manipulating scratch registers (r300) 95 * 1.24- Add general-purpose packet for manipulating scratch registers (r300)
96 * 1.25- Add support for r200 vertex programs (R200_EMIT_VAP_PVS_CNTL,
97 * new packet type)
96 */ 98 */
97#define DRIVER_MAJOR 1 99#define DRIVER_MAJOR 1
98#define DRIVER_MINOR 24 100#define DRIVER_MINOR 25
99#define DRIVER_PATCHLEVEL 0 101#define DRIVER_PATCHLEVEL 0
100 102
101/* 103/*
@@ -884,6 +886,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp,
884#define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00 886#define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00
885#define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14 887#define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14
886 888
889#define RADEON_SE_TCL_STATE_FLUSH 0x2284
890
887#define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001 891#define SE_VAP_CNTL__TCL_ENA_MASK 0x00000001
888#define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000 892#define SE_VAP_CNTL__FORCE_W_TO_ONE_MASK 0x00010000
889#define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012 893#define SE_VAP_CNTL__VF_MAX_VTX_NUM__SHIFT 0x00000012
@@ -905,6 +909,8 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp,
905#define R200_PP_AFS_0 0x2f80 909#define R200_PP_AFS_0 0x2f80
906#define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */ 910#define R200_PP_AFS_1 0x2f00 /* same as txcblend_0 */
907 911
912#define R200_VAP_PVS_CNTL_1 0x22D0
913
908/* Constants */ 914/* Constants */
909#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 915#define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
910 916
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index c5b8f774a599..5bb2234a9094 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -249,6 +249,7 @@ static __inline__ int radeon_check_and_fixup_packets(drm_radeon_private_t *
249 case R200_EMIT_PP_TXCTLALL_3: 249 case R200_EMIT_PP_TXCTLALL_3:
250 case R200_EMIT_PP_TXCTLALL_4: 250 case R200_EMIT_PP_TXCTLALL_4:
251 case R200_EMIT_PP_TXCTLALL_5: 251 case R200_EMIT_PP_TXCTLALL_5:
252 case R200_EMIT_VAP_PVS_CNTL:
252 /* These packets don't contain memory offsets */ 253 /* These packets don't contain memory offsets */
253 break; 254 break;
254 255
@@ -626,6 +627,7 @@ static struct {
626 {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"}, 627 {R200_PP_TXFILTER_3, 8, "R200_PP_TXCTLALL_3"},
627 {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"}, 628 {R200_PP_TXFILTER_4, 8, "R200_PP_TXCTLALL_4"},
628 {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"}, 629 {R200_PP_TXFILTER_5, 8, "R200_PP_TXCTLALL_5"},
630 {R200_VAP_PVS_CNTL_1, 2, "R200_VAP_PVS_CNTL"},
629}; 631};
630 632
631/* ================================================================ 633/* ================================================================
@@ -2595,7 +2597,8 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv,
2595 int stride = header.vectors.stride; 2597 int stride = header.vectors.stride;
2596 RING_LOCALS; 2598 RING_LOCALS;
2597 2599
2598 BEGIN_RING(3 + sz); 2600 BEGIN_RING(5 + sz);
2601 OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0);
2599 OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0)); 2602 OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0));
2600 OUT_RING(start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT)); 2603 OUT_RING(start | (stride << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT));
2601 OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1))); 2604 OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1)));
@@ -2607,6 +2610,32 @@ static __inline__ int radeon_emit_vectors(drm_radeon_private_t *dev_priv,
2607 return 0; 2610 return 0;
2608} 2611}
2609 2612
2613static __inline__ int radeon_emit_veclinear(drm_radeon_private_t *dev_priv,
2614 drm_radeon_cmd_header_t header,
2615 drm_radeon_kcmd_buffer_t *cmdbuf)
2616{
2617 int sz = header.veclinear.count * 4;
2618 int start = header.veclinear.addr_lo | (header.veclinear.addr_hi << 8);
2619 RING_LOCALS;
2620
2621 if (!sz)
2622 return 0;
2623 if (sz * 4 > cmdbuf->bufsz)
2624 return DRM_ERR(EINVAL);
2625
2626 BEGIN_RING(5 + sz);
2627 OUT_RING_REG(RADEON_SE_TCL_STATE_FLUSH, 0);
2628 OUT_RING(CP_PACKET0(RADEON_SE_TCL_VECTOR_INDX_REG, 0));
2629 OUT_RING(start | (1 << RADEON_VEC_INDX_OCTWORD_STRIDE_SHIFT));
2630 OUT_RING(CP_PACKET0_TABLE(RADEON_SE_TCL_VECTOR_DATA_REG, (sz - 1)));
2631 OUT_RING_TABLE(cmdbuf->buf, sz);
2632 ADVANCE_RING();
2633
2634 cmdbuf->buf += sz * sizeof(int);
2635 cmdbuf->bufsz -= sz * sizeof(int);
2636 return 0;
2637}
2638
2610static int radeon_emit_packet3(drm_device_t * dev, 2639static int radeon_emit_packet3(drm_device_t * dev,
2611 drm_file_t * filp_priv, 2640 drm_file_t * filp_priv,
2612 drm_radeon_kcmd_buffer_t *cmdbuf) 2641 drm_radeon_kcmd_buffer_t *cmdbuf)
@@ -2865,6 +2894,14 @@ static int radeon_cp_cmdbuf(DRM_IOCTL_ARGS)
2865 goto err; 2894 goto err;
2866 } 2895 }
2867 break; 2896 break;
2897 case RADEON_CMD_VECLINEAR:
2898 DRM_DEBUG("RADEON_CMD_VECLINEAR\n");
2899 if (radeon_emit_veclinear(dev_priv, header, &cmdbuf)) {
2900 DRM_ERROR("radeon_emit_veclinear failed\n");
2901 goto err;
2902 }
2903 break;
2904
2868 default: 2905 default:
2869 DRM_ERROR("bad cmd_type %d at %p\n", 2906 DRM_ERROR("bad cmd_type %d at %p\n",
2870 header.header.cmd_type, 2907 header.header.cmd_type,
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index b7f17457b424..78a81a4a99c5 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -557,7 +557,7 @@ via_init_dmablit(drm_device_t *dev)
557 blitq->num_outstanding = 0; 557 blitq->num_outstanding = 0;
558 blitq->is_active = 0; 558 blitq->is_active = 0;
559 blitq->aborting = 0; 559 blitq->aborting = 0;
560 blitq->blit_lock = SPIN_LOCK_UNLOCKED; 560 spin_lock_init(&blitq->blit_lock);
561 for (j=0; j<VIA_NUM_BLIT_SLOTS; ++j) { 561 for (j=0; j<VIA_NUM_BLIT_SLOTS; ++j) {
562 DRM_INIT_WAITQUEUE(blitq->blit_queue + j); 562 DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
563 } 563 }
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 9cad8501d62c..dc0602ae8503 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -80,7 +80,7 @@ static int invalid_lilo_config;
80/* The ISA boards do window flipping into the same spaces so its only sane 80/* The ISA boards do window flipping into the same spaces so its only sane
81 with a single lock. It's still pretty efficient */ 81 with a single lock. It's still pretty efficient */
82 82
83static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED; 83static DEFINE_SPINLOCK(epca_lock);
84 84
85/* ----------------------------------------------------------------------- 85/* -----------------------------------------------------------------------
86 MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 86 MAXBOARDS is typically 12, but ISA and EISA cards are restricted to
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 09dc4b01232c..922174d527ae 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -1212,7 +1212,7 @@ static void rs_put_char(struct tty_struct *tty, unsigned char ch)
1212 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 1212 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
1213 return; 1213 return;
1214 1214
1215 if (!tty || !info->xmit_buf) 1215 if (!info->xmit_buf)
1216 return; 1216 return;
1217 1217
1218 spin_lock_irqsave(&info->lock, flags); 1218 spin_lock_irqsave(&info->lock, flags);
@@ -1256,7 +1256,7 @@ static int rs_write(struct tty_struct * tty,
1256 if (serial_paranoia_check(info, tty->name, "rs_write")) 1256 if (serial_paranoia_check(info, tty->name, "rs_write"))
1257 return 0; 1257 return 0;
1258 1258
1259 if (!tty || !info->xmit_buf) 1259 if (!info->xmit_buf)
1260 return 0; 1260 return 0;
1261 1261
1262 while (1) { 1262 while (1) {
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index ac626418b329..d69f2ad9a67d 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -117,12 +117,12 @@ __setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); 117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */ 118#endif /* not MODULE */
119 119
120#if defined(CONFIG_X86) || defined(CONFIG_S390) 120#if defined(CONFIG_X86_64) || defined(CONFIG_S390)
121# define HAVE_MONOTONIC 121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL 122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_IA64) 123#elif defined(CONFIG_IA64)
124# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq) 124# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
125#elif defined(CONFIG_PPC64) 125#else
126# define TIMER_FREQ (HZ*loops_per_jiffy) 126# define TIMER_FREQ (HZ*loops_per_jiffy)
127#endif 127#endif
128 128
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index ef140ebde117..07473cd84121 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -925,11 +925,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
925 status = acpi_resource_to_address64(res, &addr); 925 status = acpi_resource_to_address64(res, &addr);
926 926
927 if (ACPI_SUCCESS(status)) { 927 if (ACPI_SUCCESS(status)) {
928 unsigned long size;
929
930 size = addr.maximum - addr.minimum + 1;
931 hdp->hd_phys_address = addr.minimum; 928 hdp->hd_phys_address = addr.minimum;
932 hdp->hd_address = ioremap(addr.minimum, size); 929 hdp->hd_address = ioremap(addr.minimum, addr.address_length);
933 930
934 if (hpet_is_known(hdp)) { 931 if (hpet_is_known(hdp)) {
935 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 932 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 2b6a56b2bf35..a5c6a9d7ff08 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -553,7 +553,6 @@ static int hvc_chars_in_buffer(struct tty_struct *tty)
553 553
554#define HVC_POLL_READ 0x00000001 554#define HVC_POLL_READ 0x00000001
555#define HVC_POLL_WRITE 0x00000002 555#define HVC_POLL_WRITE 0x00000002
556#define HVC_POLL_QUICK 0x00000004
557 556
558static int hvc_poll(struct hvc_struct *hp) 557static int hvc_poll(struct hvc_struct *hp)
559{ 558{
@@ -568,6 +567,7 @@ static int hvc_poll(struct hvc_struct *hp)
568 /* Push pending writes */ 567 /* Push pending writes */
569 if (hp->n_outbuf > 0) 568 if (hp->n_outbuf > 0)
570 hvc_push(hp); 569 hvc_push(hp);
570
571 /* Reschedule us if still some write pending */ 571 /* Reschedule us if still some write pending */
572 if (hp->n_outbuf > 0) 572 if (hp->n_outbuf > 0)
573 poll_mask |= HVC_POLL_WRITE; 573 poll_mask |= HVC_POLL_WRITE;
@@ -680,7 +680,7 @@ int khvcd(void *unused)
680 poll_mask |= HVC_POLL_READ; 680 poll_mask |= HVC_POLL_READ;
681 if (hvc_kicked) 681 if (hvc_kicked)
682 continue; 682 continue;
683 if (poll_mask & HVC_POLL_QUICK) { 683 if (poll_mask & HVC_POLL_WRITE) {
684 yield(); 684 yield();
685 continue; 685 continue;
686 } 686 }
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index 83364ea63cba..57106e02fd2e 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -41,37 +41,28 @@
41#define hvc_rtas_cookie 0x67781e15 41#define hvc_rtas_cookie 0x67781e15
42struct hvc_struct *hvc_rtas_dev; 42struct hvc_struct *hvc_rtas_dev;
43 43
44#define RTASCONS_PUT_ATTEMPTS 16
45
46static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; 44static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
47static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; 45static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE;
48static int rtascons_put_delay = 100;
49module_param_named(put_delay, rtascons_put_delay, int, 0644);
50 46
51static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, int count) 47static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf,
48 int count)
52{ 49{
53 int done; 50 int i;
54 51
55 /* if there is more than one character to be displayed, wait a bit */ 52 for (i = 0; i < count; i++) {
56 for (done = 0; done < count; done++) { 53 if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i]))
57 int result;
58 result = rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[done]);
59 if (result)
60 break; 54 break;
61 } 55 }
62 /* the calling routine expects to receive the number of bytes sent */ 56
63 return done; 57 return i;
64} 58}
65 59
66static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) 60static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
67{ 61{
68 int i; 62 int i, c;
69 63
70 for (i = 0; i < count; i++) { 64 for (i = 0; i < count; i++) {
71 int c, err; 65 if (rtas_call(rtascons_get_char_token, 0, 2, &c))
72
73 err = rtas_call(rtascons_get_char_token, 0, 2, &c);
74 if (err)
75 break; 66 break;
76 67
77 buf[i] = c; 68 buf[i] = c;
@@ -106,7 +97,9 @@ static int hvc_rtas_init(void)
106 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops); 97 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops);
107 if (IS_ERR(hp)) 98 if (IS_ERR(hp))
108 return PTR_ERR(hp); 99 return PTR_ERR(hp);
100
109 hvc_rtas_dev = hp; 101 hvc_rtas_dev = hp;
102
110 return 0; 103 return 0;
111} 104}
112module_init(hvc_rtas_init); 105module_init(hvc_rtas_init);
@@ -114,8 +107,8 @@ module_init(hvc_rtas_init);
114/* This will tear down the tty portion of the driver */ 107/* This will tear down the tty portion of the driver */
115static void __exit hvc_rtas_exit(void) 108static void __exit hvc_rtas_exit(void)
116{ 109{
117 /* Really the fun isn't over until the worker thread breaks down and the 110 /* Really the fun isn't over until the worker thread breaks down and
118 * tty cleans up */ 111 * the tty cleans up */
119 if (hvc_rtas_dev) 112 if (hvc_rtas_dev)
120 hvc_remove(hvc_rtas_dev); 113 hvc_remove(hvc_rtas_dev);
121} 114}
@@ -127,12 +120,14 @@ static int hvc_rtas_console_init(void)
127 rtascons_put_char_token = rtas_token("put-term-char"); 120 rtascons_put_char_token = rtas_token("put-term-char");
128 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE) 121 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
129 return -EIO; 122 return -EIO;
123
130 rtascons_get_char_token = rtas_token("get-term-char"); 124 rtascons_get_char_token = rtas_token("get-term-char");
131 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE) 125 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
132 return -EIO; 126 return -EIO;
133 127
134 hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops ); 128 hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops);
135 add_preferred_console("hvc", 0, NULL); 129 add_preferred_console("hvc", 0, NULL);
130
136 return 0; 131 return 0;
137} 132}
138console_initcall(hvc_rtas_console_init); 133console_initcall(hvc_rtas_console_init);
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 8d97b3911293..afa26b65dac3 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -1320,11 +1320,12 @@ static struct tty_operations hvcs_ops = {
1320static int hvcs_alloc_index_list(int n) 1320static int hvcs_alloc_index_list(int n)
1321{ 1321{
1322 int i; 1322 int i;
1323
1323 hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); 1324 hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
1324 if (!hvcs_index_list) 1325 if (!hvcs_index_list)
1325 return -ENOMEM; 1326 return -ENOMEM;
1326 hvcs_index_count = n; 1327 hvcs_index_count = n;
1327 for(i = 0; i < hvcs_index_count; i++) 1328 for (i = 0; i < hvcs_index_count; i++)
1328 hvcs_index_list[i] = -1; 1329 hvcs_index_list[i] = -1;
1329 return 0; 1330 return 0;
1330} 1331}
@@ -1332,11 +1333,9 @@ static int hvcs_alloc_index_list(int n)
1332static void hvcs_free_index_list(void) 1333static void hvcs_free_index_list(void)
1333{ 1334{
1334 /* Paranoia check to be thorough. */ 1335 /* Paranoia check to be thorough. */
1335 if (hvcs_index_list) { 1336 kfree(hvcs_index_list);
1336 kfree(hvcs_index_list); 1337 hvcs_index_list = NULL;
1337 hvcs_index_list = NULL; 1338 hvcs_index_count = 0;
1338 hvcs_index_count = 0;
1339 }
1340} 1339}
1341 1340
1342static int __init hvcs_module_init(void) 1341static int __init hvcs_module_init(void)
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index a9522189fc9e..a0370ed752ce 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1179,7 +1179,7 @@ static int __init hvsi_init(void)
1179 if (tty_register_driver(hvsi_driver)) 1179 if (tty_register_driver(hvsi_driver))
1180 panic("Couldn't register hvsi console driver\n"); 1180 panic("Couldn't register hvsi console driver\n");
1181 1181
1182 printk(KERN_INFO "HVSI: registered %i devices\n", hvsi_count); 1182 printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
1183 1183
1184 return 0; 1184 return 0;
1185} 1185}
diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c
deleted file mode 100644
index 29dc87e59020..000000000000
--- a/drivers/char/hw_random.c
+++ /dev/null
@@ -1,698 +0,0 @@
1/*
2 Added support for the AMD Geode LX RNG
3 (c) Copyright 2004-2005 Advanced Micro Devices, Inc.
4
5 derived from
6
7 Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
8 (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
9
10 derived from
11
12 Hardware driver for the AMD 768 Random Number Generator (RNG)
13 (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
14
15 derived from
16
17 Hardware driver for Intel i810 Random Number Generator (RNG)
18 Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
19 Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
20
21 Please read Documentation/hw_random.txt for details on use.
22
23 ----------------------------------------------------------
24 This software may be used and distributed according to the terms
25 of the GNU General Public License, incorporated herein by reference.
26
27 */
28
29
30#include <linux/module.h>
31#include <linux/kernel.h>
32#include <linux/fs.h>
33#include <linux/init.h>
34#include <linux/pci.h>
35#include <linux/interrupt.h>
36#include <linux/spinlock.h>
37#include <linux/random.h>
38#include <linux/miscdevice.h>
39#include <linux/smp_lock.h>
40#include <linux/mm.h>
41#include <linux/delay.h>
42
43#ifdef __i386__
44#include <asm/msr.h>
45#include <asm/cpufeature.h>
46#endif
47
48#include <asm/io.h>
49#include <asm/uaccess.h>
50
51
52/*
53 * core module and version information
54 */
55#define RNG_VERSION "1.0.0"
56#define RNG_MODULE_NAME "hw_random"
57#define RNG_DRIVER_NAME RNG_MODULE_NAME " hardware driver " RNG_VERSION
58#define PFX RNG_MODULE_NAME ": "
59
60
61/*
62 * debugging macros
63 */
64
65/* pr_debug() collapses to a no-op if DEBUG is not defined */
66#define DPRINTK(fmt, args...) pr_debug(PFX "%s: " fmt, __FUNCTION__ , ## args)
67
68
69#undef RNG_NDEBUG /* define to enable lightweight runtime checks */
70#ifdef RNG_NDEBUG
71#define assert(expr) \
72 if(!(expr)) { \
73 printk(KERN_DEBUG PFX "Assertion failed! %s,%s,%s," \
74 "line=%d\n", #expr, __FILE__, __FUNCTION__, __LINE__); \
75 }
76#else
77#define assert(expr)
78#endif
79
80#define RNG_MISCDEV_MINOR 183 /* official */
81
82static int rng_dev_open (struct inode *inode, struct file *filp);
83static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
84 loff_t * offp);
85
86static int __init intel_init (struct pci_dev *dev);
87static void intel_cleanup(void);
88static unsigned int intel_data_present (void);
89static u32 intel_data_read (void);
90
91static int __init amd_init (struct pci_dev *dev);
92static void amd_cleanup(void);
93static unsigned int amd_data_present (void);
94static u32 amd_data_read (void);
95
96#ifdef __i386__
97static int __init via_init(struct pci_dev *dev);
98static void via_cleanup(void);
99static unsigned int via_data_present (void);
100static u32 via_data_read (void);
101#endif
102
103static int __init geode_init(struct pci_dev *dev);
104static void geode_cleanup(void);
105static unsigned int geode_data_present (void);
106static u32 geode_data_read (void);
107
108struct rng_operations {
109 int (*init) (struct pci_dev *dev);
110 void (*cleanup) (void);
111 unsigned int (*data_present) (void);
112 u32 (*data_read) (void);
113 unsigned int n_bytes; /* number of bytes per ->data_read */
114};
115static struct rng_operations *rng_ops;
116
117static struct file_operations rng_chrdev_ops = {
118 .owner = THIS_MODULE,
119 .open = rng_dev_open,
120 .read = rng_dev_read,
121};
122
123
124static struct miscdevice rng_miscdev = {
125 RNG_MISCDEV_MINOR,
126 RNG_MODULE_NAME,
127 &rng_chrdev_ops,
128};
129
130enum {
131 rng_hw_none,
132 rng_hw_intel,
133 rng_hw_amd,
134#ifdef __i386__
135 rng_hw_via,
136#endif
137 rng_hw_geode,
138};
139
140static struct rng_operations rng_vendor_ops[] = {
141 /* rng_hw_none */
142 { },
143
144 /* rng_hw_intel */
145 { intel_init, intel_cleanup, intel_data_present,
146 intel_data_read, 1 },
147
148 /* rng_hw_amd */
149 { amd_init, amd_cleanup, amd_data_present, amd_data_read, 4 },
150
151#ifdef __i386__
152 /* rng_hw_via */
153 { via_init, via_cleanup, via_data_present, via_data_read, 1 },
154#endif
155
156 /* rng_hw_geode */
157 { geode_init, geode_cleanup, geode_data_present, geode_data_read, 4 }
158};
159
160/*
161 * Data for PCI driver interface
162 *
163 * This data only exists for exporting the supported
164 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
165 * register a pci_driver, because someone else might one day
166 * want to register another driver on the same PCI id.
167 */
168static struct pci_device_id rng_pci_tbl[] = {
169 { 0x1022, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_amd },
170 { 0x1022, 0x746b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_amd },
171
172 { 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
173 { 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
174 { 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
175 { 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
176 { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
177 { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
178
179 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES,
180 PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_geode },
181
182 { 0, }, /* terminate list */
183};
184MODULE_DEVICE_TABLE (pci, rng_pci_tbl);
185
186
187/***********************************************************************
188 *
189 * Intel RNG operations
190 *
191 */
192
193/*
194 * RNG registers (offsets from rng_mem)
195 */
196#define INTEL_RNG_HW_STATUS 0
197#define INTEL_RNG_PRESENT 0x40
198#define INTEL_RNG_ENABLED 0x01
199#define INTEL_RNG_STATUS 1
200#define INTEL_RNG_DATA_PRESENT 0x01
201#define INTEL_RNG_DATA 2
202
203/*
204 * Magic address at which Intel PCI bridges locate the RNG
205 */
206#define INTEL_RNG_ADDR 0xFFBC015F
207#define INTEL_RNG_ADDR_LEN 3
208
209/* token to our ioremap'd RNG register area */
210static void __iomem *rng_mem;
211
212static inline u8 intel_hwstatus (void)
213{
214 assert (rng_mem != NULL);
215 return readb (rng_mem + INTEL_RNG_HW_STATUS);
216}
217
218static inline u8 intel_hwstatus_set (u8 hw_status)
219{
220 assert (rng_mem != NULL);
221 writeb (hw_status, rng_mem + INTEL_RNG_HW_STATUS);
222 return intel_hwstatus ();
223}
224
225static unsigned int intel_data_present(void)
226{
227 assert (rng_mem != NULL);
228
229 return (readb (rng_mem + INTEL_RNG_STATUS) & INTEL_RNG_DATA_PRESENT) ?
230 1 : 0;
231}
232
233static u32 intel_data_read(void)
234{
235 assert (rng_mem != NULL);
236
237 return readb (rng_mem + INTEL_RNG_DATA);
238}
239
240static int __init intel_init (struct pci_dev *dev)
241{
242 int rc;
243 u8 hw_status;
244
245 DPRINTK ("ENTER\n");
246
247 rng_mem = ioremap (INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN);
248 if (rng_mem == NULL) {
249 printk (KERN_ERR PFX "cannot ioremap RNG Memory\n");
250 rc = -EBUSY;
251 goto err_out;
252 }
253
254 /* Check for Intel 82802 */
255 hw_status = intel_hwstatus ();
256 if ((hw_status & INTEL_RNG_PRESENT) == 0) {
257 printk (KERN_ERR PFX "RNG not detected\n");
258 rc = -ENODEV;
259 goto err_out_free_map;
260 }
261
262 /* turn RNG h/w on, if it's off */
263 if ((hw_status & INTEL_RNG_ENABLED) == 0)
264 hw_status = intel_hwstatus_set (hw_status | INTEL_RNG_ENABLED);
265 if ((hw_status & INTEL_RNG_ENABLED) == 0) {
266 printk (KERN_ERR PFX "cannot enable RNG, aborting\n");
267 rc = -EIO;
268 goto err_out_free_map;
269 }
270
271 DPRINTK ("EXIT, returning 0\n");
272 return 0;
273
274err_out_free_map:
275 iounmap (rng_mem);
276 rng_mem = NULL;
277err_out:
278 DPRINTK ("EXIT, returning %d\n", rc);
279 return rc;
280}
281
282static void intel_cleanup(void)
283{
284 u8 hw_status;
285
286 hw_status = intel_hwstatus ();
287 if (hw_status & INTEL_RNG_ENABLED)
288 intel_hwstatus_set (hw_status & ~INTEL_RNG_ENABLED);
289 else
290 printk(KERN_WARNING PFX "unusual: RNG already disabled\n");
291 iounmap(rng_mem);
292 rng_mem = NULL;
293}
294
295/***********************************************************************
296 *
297 * AMD RNG operations
298 *
299 */
300
301static u32 pmbase; /* PMxx I/O base */
302static struct pci_dev *amd_dev;
303
304static unsigned int amd_data_present (void)
305{
306 return inl(pmbase + 0xF4) & 1;
307}
308
309
310static u32 amd_data_read (void)
311{
312 return inl(pmbase + 0xF0);
313}
314
315static int __init amd_init (struct pci_dev *dev)
316{
317 int rc;
318 u8 rnen;
319
320 DPRINTK ("ENTER\n");
321
322 pci_read_config_dword(dev, 0x58, &pmbase);
323
324 pmbase &= 0x0000FF00;
325
326 if (pmbase == 0)
327 {
328 printk (KERN_ERR PFX "power management base not set\n");
329 rc = -EIO;
330 goto err_out;
331 }
332
333 pci_read_config_byte(dev, 0x40, &rnen);
334 rnen |= (1 << 7); /* RNG on */
335 pci_write_config_byte(dev, 0x40, rnen);
336
337 pci_read_config_byte(dev, 0x41, &rnen);
338 rnen |= (1 << 7); /* PMIO enable */
339 pci_write_config_byte(dev, 0x41, rnen);
340
341 pr_info( PFX "AMD768 system management I/O registers at 0x%X.\n",
342 pmbase);
343
344 amd_dev = dev;
345
346 DPRINTK ("EXIT, returning 0\n");
347 return 0;
348
349err_out:
350 DPRINTK ("EXIT, returning %d\n", rc);
351 return rc;
352}
353
354static void amd_cleanup(void)
355{
356 u8 rnen;
357
358 pci_read_config_byte(amd_dev, 0x40, &rnen);
359 rnen &= ~(1 << 7); /* RNG off */
360 pci_write_config_byte(amd_dev, 0x40, rnen);
361
362 /* FIXME: twiddle pmio, also? */
363}
364
365#ifdef __i386__
366/***********************************************************************
367 *
368 * VIA RNG operations
369 *
370 */
371
372enum {
373 VIA_STRFILT_CNT_SHIFT = 16,
374 VIA_STRFILT_FAIL = (1 << 15),
375 VIA_STRFILT_ENABLE = (1 << 14),
376 VIA_RAWBITS_ENABLE = (1 << 13),
377 VIA_RNG_ENABLE = (1 << 6),
378 VIA_XSTORE_CNT_MASK = 0x0F,
379
380 VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */
381 VIA_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */
382 VIA_RNG_CHUNK_4_MASK = 0xFFFFFFFF,
383 VIA_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */
384 VIA_RNG_CHUNK_2_MASK = 0xFFFF,
385 VIA_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */
386 VIA_RNG_CHUNK_1_MASK = 0xFF,
387};
388
389static u32 via_rng_datum;
390
391/*
392 * Investigate using the 'rep' prefix to obtain 32 bits of random data
393 * in one insn. The upside is potentially better performance. The
394 * downside is that the instruction becomes no longer atomic. Due to
395 * this, just like familiar issues with /dev/random itself, the worst
396 * case of a 'rep xstore' could potentially pause a cpu for an
397 * unreasonably long time. In practice, this condition would likely
398 * only occur when the hardware is failing. (or so we hope :))
399 *
400 * Another possible performance boost may come from simply buffering
401 * until we have 4 bytes, thus returning a u32 at a time,
402 * instead of the current u8-at-a-time.
403 */
404
405static inline u32 xstore(u32 *addr, u32 edx_in)
406{
407 u32 eax_out;
408
409 asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */"
410 :"=m"(*addr), "=a"(eax_out)
411 :"D"(addr), "d"(edx_in));
412
413 return eax_out;
414}
415
416static unsigned int via_data_present(void)
417{
418 u32 bytes_out;
419
420 /* We choose the recommended 1-byte-per-instruction RNG rate,
421 * for greater randomness at the expense of speed. Larger
422 * values 2, 4, or 8 bytes-per-instruction yield greater
423 * speed at lesser randomness.
424 *
425 * If you change this to another VIA_CHUNK_n, you must also
426 * change the ->n_bytes values in rng_vendor_ops[] tables.
427 * VIA_CHUNK_8 requires further code changes.
428 *
429 * A copy of MSR_VIA_RNG is placed in eax_out when xstore
430 * completes.
431 */
432 via_rng_datum = 0; /* paranoia, not really necessary */
433 bytes_out = xstore(&via_rng_datum, VIA_RNG_CHUNK_1) & VIA_XSTORE_CNT_MASK;
434 if (bytes_out == 0)
435 return 0;
436
437 return 1;
438}
439
440static u32 via_data_read(void)
441{
442 return via_rng_datum;
443}
444
445static int __init via_init(struct pci_dev *dev)
446{
447 u32 lo, hi, old_lo;
448
449 /* Control the RNG via MSR. Tread lightly and pay very close
450 * close attention to values written, as the reserved fields
451 * are documented to be "undefined and unpredictable"; but it
452 * does not say to write them as zero, so I make a guess that
453 * we restore the values we find in the register.
454 */
455 rdmsr(MSR_VIA_RNG, lo, hi);
456
457 old_lo = lo;
458 lo &= ~(0x7f << VIA_STRFILT_CNT_SHIFT);
459 lo &= ~VIA_XSTORE_CNT_MASK;
460 lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE);
461 lo |= VIA_RNG_ENABLE;
462
463 if (lo != old_lo)
464 wrmsr(MSR_VIA_RNG, lo, hi);
465
466 /* perhaps-unnecessary sanity check; remove after testing if
467 unneeded */
468 rdmsr(MSR_VIA_RNG, lo, hi);
469 if ((lo & VIA_RNG_ENABLE) == 0) {
470 printk(KERN_ERR PFX "cannot enable VIA C3 RNG, aborting\n");
471 return -ENODEV;
472 }
473
474 return 0;
475}
476
477static void via_cleanup(void)
478{
479 /* do nothing */
480}
481#endif
482
483/***********************************************************************
484 *
485 * AMD Geode RNG operations
486 *
487 */
488
489static void __iomem *geode_rng_base = NULL;
490
491#define GEODE_RNG_DATA_REG 0x50
492#define GEODE_RNG_STATUS_REG 0x54
493
494static u32 geode_data_read(void)
495{
496 u32 val;
497
498 assert(geode_rng_base != NULL);
499 val = readl(geode_rng_base + GEODE_RNG_DATA_REG);
500 return val;
501}
502
503static unsigned int geode_data_present(void)
504{
505 u32 val;
506
507 assert(geode_rng_base != NULL);
508 val = readl(geode_rng_base + GEODE_RNG_STATUS_REG);
509 return val;
510}
511
512static void geode_cleanup(void)
513{
514 iounmap(geode_rng_base);
515 geode_rng_base = NULL;
516}
517
518static int geode_init(struct pci_dev *dev)
519{
520 unsigned long rng_base = pci_resource_start(dev, 0);
521
522 if (rng_base == 0)
523 return 1;
524
525 geode_rng_base = ioremap(rng_base, 0x58);
526
527 if (geode_rng_base == NULL) {
528 printk(KERN_ERR PFX "Cannot ioremap RNG memory\n");
529 return -EBUSY;
530 }
531
532 return 0;
533}
534
535/***********************************************************************
536 *
537 * /dev/hwrandom character device handling (major 10, minor 183)
538 *
539 */
540
541static int rng_dev_open (struct inode *inode, struct file *filp)
542{
543 /* enforce read-only access to this chrdev */
544 if ((filp->f_mode & FMODE_READ) == 0)
545 return -EINVAL;
546 if (filp->f_mode & FMODE_WRITE)
547 return -EINVAL;
548
549 return 0;
550}
551
552
553static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
554 loff_t * offp)
555{
556 static DEFINE_SPINLOCK(rng_lock);
557 unsigned int have_data;
558 u32 data = 0;
559 ssize_t ret = 0;
560
561 while (size) {
562 spin_lock(&rng_lock);
563
564 have_data = 0;
565 if (rng_ops->data_present()) {
566 data = rng_ops->data_read();
567 have_data = rng_ops->n_bytes;
568 }
569
570 spin_unlock (&rng_lock);
571
572 while (have_data && size) {
573 if (put_user((u8)data, buf++)) {
574 ret = ret ? : -EFAULT;
575 break;
576 }
577 size--;
578 ret++;
579 have_data--;
580 data>>=8;
581 }
582
583 if (filp->f_flags & O_NONBLOCK)
584 return ret ? : -EAGAIN;
585
586 if(need_resched())
587 schedule_timeout_interruptible(1);
588 else
589 udelay(200); /* FIXME: We could poll for 250uS ?? */
590
591 if (signal_pending (current))
592 return ret ? : -ERESTARTSYS;
593 }
594 return ret;
595}
596
597
598
599/*
600 * rng_init_one - look for and attempt to init a single RNG
601 */
602static int __init rng_init_one (struct pci_dev *dev)
603{
604 int rc;
605
606 DPRINTK ("ENTER\n");
607
608 assert(rng_ops != NULL);
609
610 rc = rng_ops->init(dev);
611 if (rc)
612 goto err_out;
613
614 rc = misc_register (&rng_miscdev);
615 if (rc) {
616 printk (KERN_ERR PFX "misc device register failed\n");
617 goto err_out_cleanup_hw;
618 }
619
620 DPRINTK ("EXIT, returning 0\n");
621 return 0;
622
623err_out_cleanup_hw:
624 rng_ops->cleanup();
625err_out:
626 DPRINTK ("EXIT, returning %d\n", rc);
627 return rc;
628}
629
630
631
632MODULE_AUTHOR("The Linux Kernel team");
633MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
634MODULE_LICENSE("GPL");
635
636
637/*
638 * rng_init - initialize RNG module
639 */
640static int __init rng_init (void)
641{
642 int rc;
643 struct pci_dev *pdev = NULL;
644 const struct pci_device_id *ent;
645
646 DPRINTK ("ENTER\n");
647
648 /* Probe for Intel, AMD, Geode RNGs */
649 for_each_pci_dev(pdev) {
650 ent = pci_match_id(rng_pci_tbl, pdev);
651 if (ent) {
652 rng_ops = &rng_vendor_ops[ent->driver_data];
653 goto match;
654 }
655 }
656
657#ifdef __i386__
658 /* Probe for VIA RNG */
659 if (cpu_has_xstore) {
660 rng_ops = &rng_vendor_ops[rng_hw_via];
661 pdev = NULL;
662 goto match;
663 }
664#endif
665
666 DPRINTK ("EXIT, returning -ENODEV\n");
667 return -ENODEV;
668
669match:
670 rc = rng_init_one (pdev);
671 if (rc)
672 return rc;
673
674 pr_info( RNG_DRIVER_NAME " loaded\n");
675
676 DPRINTK ("EXIT, returning 0\n");
677 return 0;
678}
679
680
681/*
682 * rng_init - shutdown RNG module
683 */
684static void __exit rng_cleanup (void)
685{
686 DPRINTK ("ENTER\n");
687
688 misc_deregister (&rng_miscdev);
689
690 if (rng_ops->cleanup)
691 rng_ops->cleanup();
692
693 DPRINTK ("EXIT\n");
694}
695
696
697module_init (rng_init);
698module_exit (rng_cleanup);
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
new file mode 100644
index 000000000000..9f7635f75178
--- /dev/null
+++ b/drivers/char/hw_random/Kconfig
@@ -0,0 +1,90 @@
1#
2# Hardware Random Number Generator (RNG) configuration
3#
4
5config HW_RANDOM
6 bool "Hardware Random Number Generator Core support"
7 default y
8 ---help---
9 Hardware Random Number Generator Core infrastructure.
10
11 If unsure, say Y.
12
13config HW_RANDOM_INTEL
14 tristate "Intel HW Random Number Generator support"
15 depends on HW_RANDOM && (X86 || IA64) && PCI
16 default y
17 ---help---
18 This driver provides kernel-side support for the Random Number
19 Generator hardware found on Intel i8xx-based motherboards.
20
21 To compile this driver as a module, choose M here: the
22 module will be called intel-rng.
23
24 If unsure, say Y.
25
26config HW_RANDOM_AMD
27 tristate "AMD HW Random Number Generator support"
28 depends on HW_RANDOM && X86 && PCI
29 default y
30 ---help---
31 This driver provides kernel-side support for the Random Number
32 Generator hardware found on AMD 76x-based motherboards.
33
34 To compile this driver as a module, choose M here: the
35 module will be called amd-rng.
36
37 If unsure, say Y.
38
39config HW_RANDOM_GEODE
40 tristate "AMD Geode HW Random Number Generator support"
41 depends on HW_RANDOM && X86 && PCI
42 default y
43 ---help---
44 This driver provides kernel-side support for the Random Number
45 Generator hardware found on the AMD Geode LX.
46
47 To compile this driver as a module, choose M here: the
48 module will be called geode-rng.
49
50 If unsure, say Y.
51
52config HW_RANDOM_VIA
53 tristate "VIA HW Random Number Generator support"
54 depends on HW_RANDOM && X86_32
55 default y
56 ---help---
57 This driver provides kernel-side support for the Random Number
58 Generator hardware found on VIA based motherboards.
59
60 To compile this driver as a module, choose M here: the
61 module will be called via-rng.
62
63 If unsure, say Y.
64
65config HW_RANDOM_IXP4XX
66 tristate "Intel IXP4xx NPU HW Random Number Generator support"
67 depends on HW_RANDOM && ARCH_IXP4XX
68 default y
69 ---help---
70 This driver provides kernel-side support for the Random
71 Number Generator hardware found on the Intel IXP4xx NPU.
72
73 To compile this driver as a module, choose M here: the
74 module will be called ixp4xx-rng.
75
76 If unsure, say Y.
77
78config HW_RANDOM_OMAP
79 tristate "OMAP Random Number Generator support"
80 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX)
81 default y
82 ---help---
83 This driver provides kernel-side support for the Random Number
84 Generator hardware found on OMAP16xx and OMAP24xx multimedia
85 processors.
86
87 To compile this driver as a module, choose M here: the
88 module will be called omap-rng.
89
90 If unsure, say Y.
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
new file mode 100644
index 000000000000..e263ae96f940
--- /dev/null
+++ b/drivers/char/hw_random/Makefile
@@ -0,0 +1,11 @@
1#
2# Makefile for HW Random Number Generator (RNG) device drivers.
3#
4
5obj-$(CONFIG_HW_RANDOM) += core.o
6obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
7obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
8obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
9obj-$(CONFIG_HW_RANDOM_VIA) += via-rng.o
10obj-$(CONFIG_HW_RANDOM_IXP4XX) += ixp4xx-rng.o
11obj-$(CONFIG_HW_RANDOM_OMAP) += omap-rng.o
diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
new file mode 100644
index 000000000000..71e4e0f3fd54
--- /dev/null
+++ b/drivers/char/hw_random/amd-rng.c
@@ -0,0 +1,152 @@
1/*
2 * RNG driver for AMD RNGs
3 *
4 * Copyright 2005 (c) MontaVista Software, Inc.
5 *
6 * with the majority of the code coming from:
7 *
8 * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
9 * (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
10 *
11 * derived from
12 *
13 * Hardware driver for the AMD 768 Random Number Generator (RNG)
14 * (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
15 *
16 * derived from
17 *
18 * Hardware driver for Intel i810 Random Number Generator (RNG)
19 * Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
20 * Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
21 *
22 * This file is licensed under the terms of the GNU General Public
23 * License version 2. This program is licensed "as is" without any
24 * warranty of any kind, whether express or implied.
25 */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h>
31#include <asm/io.h>
32
33
34#define PFX KBUILD_MODNAME ": "
35
36
37/*
38 * Data for PCI driver interface
39 *
40 * This data only exists for exporting the supported
41 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
42 * register a pci_driver, because someone else might one day
43 * want to register another driver on the same PCI id.
44 */
45static const struct pci_device_id pci_tbl[] = {
46 { 0x1022, 0x7443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
47 { 0x1022, 0x746b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
48 { 0, }, /* terminate list */
49};
50MODULE_DEVICE_TABLE(pci, pci_tbl);
51
52static struct pci_dev *amd_pdev;
53
54
55static int amd_rng_data_present(struct hwrng *rng)
56{
57 u32 pmbase = (u32)rng->priv;
58
59 return !!(inl(pmbase + 0xF4) & 1);
60}
61
62static int amd_rng_data_read(struct hwrng *rng, u32 *data)
63{
64 u32 pmbase = (u32)rng->priv;
65
66 *data = inl(pmbase + 0xF0);
67
68 return 4;
69}
70
71static int amd_rng_init(struct hwrng *rng)
72{
73 u8 rnen;
74
75 pci_read_config_byte(amd_pdev, 0x40, &rnen);
76 rnen |= (1 << 7); /* RNG on */
77 pci_write_config_byte(amd_pdev, 0x40, rnen);
78
79 pci_read_config_byte(amd_pdev, 0x41, &rnen);
80 rnen |= (1 << 7); /* PMIO enable */
81 pci_write_config_byte(amd_pdev, 0x41, rnen);
82
83 return 0;
84}
85
86static void amd_rng_cleanup(struct hwrng *rng)
87{
88 u8 rnen;
89
90 pci_read_config_byte(amd_pdev, 0x40, &rnen);
91 rnen &= ~(1 << 7); /* RNG off */
92 pci_write_config_byte(amd_pdev, 0x40, rnen);
93}
94
95
96static struct hwrng amd_rng = {
97 .name = "amd",
98 .init = amd_rng_init,
99 .cleanup = amd_rng_cleanup,
100 .data_present = amd_rng_data_present,
101 .data_read = amd_rng_data_read,
102};
103
104
105static int __init mod_init(void)
106{
107 int err = -ENODEV;
108 struct pci_dev *pdev = NULL;
109 const struct pci_device_id *ent;
110 u32 pmbase;
111
112 for_each_pci_dev(pdev) {
113 ent = pci_match_id(pci_tbl, pdev);
114 if (ent)
115 goto found;
116 }
117 /* Device not found. */
118 goto out;
119
120found:
121 err = pci_read_config_dword(pdev, 0x58, &pmbase);
122 if (err)
123 goto out;
124 err = -EIO;
125 pmbase &= 0x0000FF00;
126 if (pmbase == 0)
127 goto out;
128 amd_rng.priv = (unsigned long)pmbase;
129 amd_pdev = pdev;
130
131 printk(KERN_INFO "AMD768 RNG detected\n");
132 err = hwrng_register(&amd_rng);
133 if (err) {
134 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
135 err);
136 goto out;
137 }
138out:
139 return err;
140}
141
142static void __exit mod_exit(void)
143{
144 hwrng_unregister(&amd_rng);
145}
146
147subsys_initcall(mod_init);
148module_exit(mod_exit);
149
150MODULE_AUTHOR("The Linux Kernel team");
151MODULE_DESCRIPTION("H/W RNG driver for AMD chipsets");
152MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
new file mode 100644
index 000000000000..88b026639f10
--- /dev/null
+++ b/drivers/char/hw_random/core.c
@@ -0,0 +1,354 @@
1/*
2 Added support for the AMD Geode LX RNG
3 (c) Copyright 2004-2005 Advanced Micro Devices, Inc.
4
5 derived from
6
7 Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
8 (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
9
10 derived from
11
12 Hardware driver for the AMD 768 Random Number Generator (RNG)
13 (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
14
15 derived from
16
17 Hardware driver for Intel i810 Random Number Generator (RNG)
18 Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
19 Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
20
21 Added generic RNG API
22 Copyright 2006 Michael Buesch <mbuesch@freenet.de>
23 Copyright 2005 (c) MontaVista Software, Inc.
24
25 Please read Documentation/hw_random.txt for details on use.
26
27 ----------------------------------------------------------
28 This software may be used and distributed according to the terms
29 of the GNU General Public License, incorporated herein by reference.
30
31 */
32
33
34#include <linux/device.h>
35#include <linux/hw_random.h>
36#include <linux/module.h>
37#include <linux/kernel.h>
38#include <linux/fs.h>
39#include <linux/init.h>
40#include <linux/miscdevice.h>
41#include <linux/delay.h>
42#include <asm/uaccess.h>
43
44
45#define RNG_MODULE_NAME "hw_random"
46#define PFX RNG_MODULE_NAME ": "
47#define RNG_MISCDEV_MINOR 183 /* official */
48
49
50static struct hwrng *current_rng;
51static LIST_HEAD(rng_list);
52static DEFINE_MUTEX(rng_mutex);
53
54
55static inline int hwrng_init(struct hwrng *rng)
56{
57 if (!rng->init)
58 return 0;
59 return rng->init(rng);
60}
61
62static inline void hwrng_cleanup(struct hwrng *rng)
63{
64 if (rng && rng->cleanup)
65 rng->cleanup(rng);
66}
67
68static inline int hwrng_data_present(struct hwrng *rng)
69{
70 if (!rng->data_present)
71 return 1;
72 return rng->data_present(rng);
73}
74
75static inline int hwrng_data_read(struct hwrng *rng, u32 *data)
76{
77 return rng->data_read(rng, data);
78}
79
80
81static int rng_dev_open(struct inode *inode, struct file *filp)
82{
83 /* enforce read-only access to this chrdev */
84 if ((filp->f_mode & FMODE_READ) == 0)
85 return -EINVAL;
86 if (filp->f_mode & FMODE_WRITE)
87 return -EINVAL;
88 return 0;
89}
90
91static ssize_t rng_dev_read(struct file *filp, char __user *buf,
92 size_t size, loff_t *offp)
93{
94 u32 data;
95 ssize_t ret = 0;
96 int i, err = 0;
97 int data_present;
98 int bytes_read;
99
100 while (size) {
101 err = -ERESTARTSYS;
102 if (mutex_lock_interruptible(&rng_mutex))
103 goto out;
104 if (!current_rng) {
105 mutex_unlock(&rng_mutex);
106 err = -ENODEV;
107 goto out;
108 }
109 if (filp->f_flags & O_NONBLOCK) {
110 data_present = hwrng_data_present(current_rng);
111 } else {
112 /* Some RNG require some time between data_reads to gather
113 * new entropy. Poll it.
114 */
115 for (i = 0; i < 20; i++) {
116 data_present = hwrng_data_present(current_rng);
117 if (data_present)
118 break;
119 udelay(10);
120 }
121 }
122 bytes_read = 0;
123 if (data_present)
124 bytes_read = hwrng_data_read(current_rng, &data);
125 mutex_unlock(&rng_mutex);
126
127 err = -EAGAIN;
128 if (!bytes_read && (filp->f_flags & O_NONBLOCK))
129 goto out;
130
131 err = -EFAULT;
132 while (bytes_read && size) {
133 if (put_user((u8)data, buf++))
134 goto out;
135 size--;
136 ret++;
137 bytes_read--;
138 data >>= 8;
139 }
140
141 if (need_resched())
142 schedule_timeout_interruptible(1);
143 err = -ERESTARTSYS;
144 if (signal_pending(current))
145 goto out;
146 }
147out:
148 return ret ? : err;
149}
150
151
152static struct file_operations rng_chrdev_ops = {
153 .owner = THIS_MODULE,
154 .open = rng_dev_open,
155 .read = rng_dev_read,
156};
157
158static struct miscdevice rng_miscdev = {
159 .minor = RNG_MISCDEV_MINOR,
160 .name = RNG_MODULE_NAME,
161 .fops = &rng_chrdev_ops,
162};
163
164
165static ssize_t hwrng_attr_current_store(struct class_device *class,
166 const char *buf, size_t len)
167{
168 int err;
169 struct hwrng *rng;
170
171 err = mutex_lock_interruptible(&rng_mutex);
172 if (err)
173 return -ERESTARTSYS;
174 err = -ENODEV;
175 list_for_each_entry(rng, &rng_list, list) {
176 if (strcmp(rng->name, buf) == 0) {
177 if (rng == current_rng) {
178 err = 0;
179 break;
180 }
181 err = hwrng_init(rng);
182 if (err)
183 break;
184 hwrng_cleanup(current_rng);
185 current_rng = rng;
186 err = 0;
187 break;
188 }
189 }
190 mutex_unlock(&rng_mutex);
191
192 return err ? : len;
193}
194
195static ssize_t hwrng_attr_current_show(struct class_device *class,
196 char *buf)
197{
198 int err;
199 ssize_t ret;
200 const char *name = "none";
201
202 err = mutex_lock_interruptible(&rng_mutex);
203 if (err)
204 return -ERESTARTSYS;
205 if (current_rng)
206 name = current_rng->name;
207 ret = snprintf(buf, PAGE_SIZE, "%s\n", name);
208 mutex_unlock(&rng_mutex);
209
210 return ret;
211}
212
213static ssize_t hwrng_attr_available_show(struct class_device *class,
214 char *buf)
215{
216 int err;
217 ssize_t ret = 0;
218 struct hwrng *rng;
219
220 err = mutex_lock_interruptible(&rng_mutex);
221 if (err)
222 return -ERESTARTSYS;
223 buf[0] = '\0';
224 list_for_each_entry(rng, &rng_list, list) {
225 strncat(buf, rng->name, PAGE_SIZE - ret - 1);
226 ret += strlen(rng->name);
227 strncat(buf, " ", PAGE_SIZE - ret - 1);
228 ret++;
229 }
230 strncat(buf, "\n", PAGE_SIZE - ret - 1);
231 ret++;
232 mutex_unlock(&rng_mutex);
233
234 return ret;
235}
236
237static CLASS_DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR,
238 hwrng_attr_current_show,
239 hwrng_attr_current_store);
240static CLASS_DEVICE_ATTR(rng_available, S_IRUGO,
241 hwrng_attr_available_show,
242 NULL);
243
244
245static void unregister_miscdev(void)
246{
247 class_device_remove_file(rng_miscdev.class,
248 &class_device_attr_rng_available);
249 class_device_remove_file(rng_miscdev.class,
250 &class_device_attr_rng_current);
251 misc_deregister(&rng_miscdev);
252}
253
254static int register_miscdev(void)
255{
256 int err;
257
258 err = misc_register(&rng_miscdev);
259 if (err)
260 goto out;
261 err = class_device_create_file(rng_miscdev.class,
262 &class_device_attr_rng_current);
263 if (err)
264 goto err_misc_dereg;
265 err = class_device_create_file(rng_miscdev.class,
266 &class_device_attr_rng_available);
267 if (err)
268 goto err_remove_current;
269out:
270 return err;
271
272err_remove_current:
273 class_device_remove_file(rng_miscdev.class,
274 &class_device_attr_rng_current);
275err_misc_dereg:
276 misc_deregister(&rng_miscdev);
277 goto out;
278}
279
280int hwrng_register(struct hwrng *rng)
281{
282 int must_register_misc;
283 int err = -EINVAL;
284 struct hwrng *old_rng, *tmp;
285
286 if (rng->name == NULL ||
287 rng->data_read == NULL)
288 goto out;
289
290 mutex_lock(&rng_mutex);
291
292 /* Must not register two RNGs with the same name. */
293 err = -EEXIST;
294 list_for_each_entry(tmp, &rng_list, list) {
295 if (strcmp(tmp->name, rng->name) == 0)
296 goto out_unlock;
297 }
298
299 must_register_misc = (current_rng == NULL);
300 old_rng = current_rng;
301 if (!old_rng) {
302 err = hwrng_init(rng);
303 if (err)
304 goto out_unlock;
305 current_rng = rng;
306 }
307 err = 0;
308 if (must_register_misc) {
309 err = register_miscdev();
310 if (err) {
311 if (!old_rng) {
312 hwrng_cleanup(rng);
313 current_rng = NULL;
314 }
315 goto out_unlock;
316 }
317 }
318 INIT_LIST_HEAD(&rng->list);
319 list_add_tail(&rng->list, &rng_list);
320out_unlock:
321 mutex_unlock(&rng_mutex);
322out:
323 return err;
324}
325EXPORT_SYMBOL_GPL(hwrng_register);
326
327void hwrng_unregister(struct hwrng *rng)
328{
329 int err;
330
331 mutex_lock(&rng_mutex);
332
333 list_del(&rng->list);
334 if (current_rng == rng) {
335 hwrng_cleanup(rng);
336 if (list_empty(&rng_list)) {
337 current_rng = NULL;
338 } else {
339 current_rng = list_entry(rng_list.prev, struct hwrng, list);
340 err = hwrng_init(current_rng);
341 if (err)
342 current_rng = NULL;
343 }
344 }
345 if (list_empty(&rng_list))
346 unregister_miscdev();
347
348 mutex_unlock(&rng_mutex);
349}
350EXPORT_SYMBOL_GPL(hwrng_unregister);
351
352
353MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
354MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/geode-rng.c b/drivers/char/hw_random/geode-rng.c
new file mode 100644
index 000000000000..be61f22ee7bb
--- /dev/null
+++ b/drivers/char/hw_random/geode-rng.c
@@ -0,0 +1,128 @@
1/*
2 * RNG driver for AMD Geode RNGs
3 *
4 * Copyright 2005 (c) MontaVista Software, Inc.
5 *
6 * with the majority of the code coming from:
7 *
8 * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
9 * (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
10 *
11 * derived from
12 *
13 * Hardware driver for the AMD 768 Random Number Generator (RNG)
14 * (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
15 *
16 * derived from
17 *
18 * Hardware driver for Intel i810 Random Number Generator (RNG)
19 * Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
20 * Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
21 *
22 * This file is licensed under the terms of the GNU General Public
23 * License version 2. This program is licensed "as is" without any
24 * warranty of any kind, whether express or implied.
25 */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h>
31#include <asm/io.h>
32
33
34#define PFX KBUILD_MODNAME ": "
35
36#define GEODE_RNG_DATA_REG 0x50
37#define GEODE_RNG_STATUS_REG 0x54
38
39/*
40 * Data for PCI driver interface
41 *
42 * This data only exists for exporting the supported
43 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
44 * register a pci_driver, because someone else might one day
45 * want to register another driver on the same PCI id.
46 */
47static const struct pci_device_id pci_tbl[] = {
48 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES,
49 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
50 { 0, }, /* terminate list */
51};
52MODULE_DEVICE_TABLE(pci, pci_tbl);
53
54
55static int geode_rng_data_read(struct hwrng *rng, u32 *data)
56{
57 void __iomem *mem = (void __iomem *)rng->priv;
58
59 *data = readl(mem + GEODE_RNG_DATA_REG);
60
61 return 4;
62}
63
64static int geode_rng_data_present(struct hwrng *rng)
65{
66 void __iomem *mem = (void __iomem *)rng->priv;
67
68 return !!(readl(mem + GEODE_RNG_STATUS_REG));
69}
70
71
72static struct hwrng geode_rng = {
73 .name = "geode",
74 .data_present = geode_rng_data_present,
75 .data_read = geode_rng_data_read,
76};
77
78
79static int __init mod_init(void)
80{
81 int err = -ENODEV;
82 struct pci_dev *pdev = NULL;
83 const struct pci_device_id *ent;
84 void __iomem *mem;
85 unsigned long rng_base;
86
87 for_each_pci_dev(pdev) {
88 ent = pci_match_id(pci_tbl, pdev);
89 if (ent)
90 goto found;
91 }
92 /* Device not found. */
93 goto out;
94
95found:
96 rng_base = pci_resource_start(pdev, 0);
97 if (rng_base == 0)
98 goto out;
99 err = -ENOMEM;
100 mem = ioremap(rng_base, 0x58);
101 if (!mem)
102 goto out;
103 geode_rng.priv = (unsigned long)mem;
104
105 printk(KERN_INFO "AMD Geode RNG detected\n");
106 err = hwrng_register(&geode_rng);
107 if (err) {
108 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
109 err);
110 goto out;
111 }
112out:
113 return err;
114}
115
116static void __exit mod_exit(void)
117{
118 void __iomem *mem = (void __iomem *)geode_rng.priv;
119
120 hwrng_unregister(&geode_rng);
121 iounmap(mem);
122}
123
124subsys_initcall(mod_init);
125module_exit(mod_exit);
126
127MODULE_DESCRIPTION("H/W RNG driver for AMD Geode LX CPUs");
128MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
new file mode 100644
index 000000000000..6594bd5645f4
--- /dev/null
+++ b/drivers/char/hw_random/intel-rng.c
@@ -0,0 +1,189 @@
1/*
2 * RNG driver for Intel RNGs
3 *
4 * Copyright 2005 (c) MontaVista Software, Inc.
5 *
6 * with the majority of the code coming from:
7 *
8 * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
9 * (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
10 *
11 * derived from
12 *
13 * Hardware driver for the AMD 768 Random Number Generator (RNG)
14 * (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
15 *
16 * derived from
17 *
18 * Hardware driver for Intel i810 Random Number Generator (RNG)
19 * Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
20 * Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
21 *
22 * This file is licensed under the terms of the GNU General Public
23 * License version 2. This program is licensed "as is" without any
24 * warranty of any kind, whether express or implied.
25 */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h>
31#include <asm/io.h>
32
33
34#define PFX KBUILD_MODNAME ": "
35
36/*
37 * RNG registers
38 */
39#define INTEL_RNG_HW_STATUS 0
40#define INTEL_RNG_PRESENT 0x40
41#define INTEL_RNG_ENABLED 0x01
42#define INTEL_RNG_STATUS 1
43#define INTEL_RNG_DATA_PRESENT 0x01
44#define INTEL_RNG_DATA 2
45
46/*
47 * Magic address at which Intel PCI bridges locate the RNG
48 */
49#define INTEL_RNG_ADDR 0xFFBC015F
50#define INTEL_RNG_ADDR_LEN 3
51
52/*
53 * Data for PCI driver interface
54 *
55 * This data only exists for exporting the supported
56 * PCI ids via MODULE_DEVICE_TABLE. We do not actually
57 * register a pci_driver, because someone else might one day
58 * want to register another driver on the same PCI id.
59 */
60static const struct pci_device_id pci_tbl[] = {
61 { 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
62 { 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
63 { 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
64 { 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
65 { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
66 { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
67 { 0, }, /* terminate list */
68};
69MODULE_DEVICE_TABLE(pci, pci_tbl);
70
71
72static inline u8 hwstatus_get(void __iomem *mem)
73{
74 return readb(mem + INTEL_RNG_HW_STATUS);
75}
76
77static inline u8 hwstatus_set(void __iomem *mem,
78 u8 hw_status)
79{
80 writeb(hw_status, mem + INTEL_RNG_HW_STATUS);
81 return hwstatus_get(mem);
82}
83
84static int intel_rng_data_present(struct hwrng *rng)
85{
86 void __iomem *mem = (void __iomem *)rng->priv;
87
88 return !!(readb(mem + INTEL_RNG_STATUS) & INTEL_RNG_DATA_PRESENT);
89}
90
91static int intel_rng_data_read(struct hwrng *rng, u32 *data)
92{
93 void __iomem *mem = (void __iomem *)rng->priv;
94
95 *data = readb(mem + INTEL_RNG_DATA);
96
97 return 1;
98}
99
100static int intel_rng_init(struct hwrng *rng)
101{
102 void __iomem *mem = (void __iomem *)rng->priv;
103 u8 hw_status;
104 int err = -EIO;
105
106 hw_status = hwstatus_get(mem);
107 /* turn RNG h/w on, if it's off */
108 if ((hw_status & INTEL_RNG_ENABLED) == 0)
109 hw_status = hwstatus_set(mem, hw_status | INTEL_RNG_ENABLED);
110 if ((hw_status & INTEL_RNG_ENABLED) == 0) {
111 printk(KERN_ERR PFX "cannot enable RNG, aborting\n");
112 goto out;
113 }
114 err = 0;
115out:
116 return err;
117}
118
119static void intel_rng_cleanup(struct hwrng *rng)
120{
121 void __iomem *mem = (void __iomem *)rng->priv;
122 u8 hw_status;
123
124 hw_status = hwstatus_get(mem);
125 if (hw_status & INTEL_RNG_ENABLED)
126 hwstatus_set(mem, hw_status & ~INTEL_RNG_ENABLED);
127 else
128 printk(KERN_WARNING PFX "unusual: RNG already disabled\n");
129}
130
131
132static struct hwrng intel_rng = {
133 .name = "intel",
134 .init = intel_rng_init,
135 .cleanup = intel_rng_cleanup,
136 .data_present = intel_rng_data_present,
137 .data_read = intel_rng_data_read,
138};
139
140
141static int __init mod_init(void)
142{
143 int err = -ENODEV;
144 void __iomem *mem;
145 u8 hw_status;
146
147 if (!pci_dev_present(pci_tbl))
148 goto out; /* Device not found. */
149
150 err = -ENOMEM;
151 mem = ioremap(INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN);
152 if (!mem)
153 goto out;
154 intel_rng.priv = (unsigned long)mem;
155
156 /* Check for Intel 82802 */
157 err = -ENODEV;
158 hw_status = hwstatus_get(mem);
159 if ((hw_status & INTEL_RNG_PRESENT) == 0)
160 goto err_unmap;
161
162 printk(KERN_INFO "Intel 82802 RNG detected\n");
163 err = hwrng_register(&intel_rng);
164 if (err) {
165 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
166 err);
167 goto out;
168 }
169out:
170 return err;
171
172err_unmap:
173 iounmap(mem);
174 goto out;
175}
176
177static void __exit mod_exit(void)
178{
179 void __iomem *mem = (void __iomem *)intel_rng.priv;
180
181 hwrng_unregister(&intel_rng);
182 iounmap(mem);
183}
184
185subsys_initcall(mod_init);
186module_exit(mod_exit);
187
188MODULE_DESCRIPTION("H/W RNG driver for Intel chipsets");
189MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/ixp4xx-rng.c b/drivers/char/hw_random/ixp4xx-rng.c
new file mode 100644
index 000000000000..ef71022423c9
--- /dev/null
+++ b/drivers/char/hw_random/ixp4xx-rng.c
@@ -0,0 +1,73 @@
1/*
2 * drivers/char/rng/ixp4xx-rng.c
3 *
4 * RNG driver for Intel IXP4xx family of NPUs
5 *
6 * Author: Deepak Saxena <dsaxena@plexity.net>
7 *
8 * Copyright 2005 (c) MontaVista Software, Inc.
9 *
10 * Fixes by Michael Buesch
11 *
12 * This file is licensed under the terms of the GNU General Public
13 * License version 2. This program is licensed "as is" without any
14 * warranty of any kind, whether express or implied.
15 */
16
17#include <linux/kernel.h>
18#include <linux/config.h>
19#include <linux/types.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/init.h>
23#include <linux/bitops.h>
24#include <linux/hw_random.h>
25
26#include <asm/io.h>
27#include <asm/hardware.h>
28
29
30static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer)
31{
32 void __iomem * rng_base = (void __iomem *)rng->priv;
33
34 *buffer = __raw_readl(rng_base);
35
36 return 4;
37}
38
39static struct hwrng ixp4xx_rng_ops = {
40 .name = "ixp4xx",
41 .data_read = ixp4xx_rng_data_read,
42};
43
44static int __init ixp4xx_rng_init(void)
45{
46 void __iomem * rng_base;
47 int err;
48
49 rng_base = ioremap(0x70002100, 4);
50 if (!rng_base)
51 return -ENOMEM;
52 ixp4xx_rng_ops.priv = (unsigned long)rng_base;
53 err = hwrng_register(&ixp4xx_rng_ops);
54 if (err)
55 iounmap(rng_base);
56
57 return err;
58}
59
60static void __exit ixp4xx_rng_exit(void)
61{
62 void __iomem * rng_base = (void __iomem *)ixp4xx_rng_ops.priv;
63
64 hwrng_unregister(&ixp4xx_rng_ops);
65 iounmap(rng_base);
66}
67
68subsys_initcall(ixp4xx_rng_init);
69module_exit(ixp4xx_rng_exit);
70
71MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
72MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver for IXP4xx");
73MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
new file mode 100644
index 000000000000..819516b35a79
--- /dev/null
+++ b/drivers/char/hw_random/omap-rng.c
@@ -0,0 +1,208 @@
1/*
2 * driver/char/hw_random/omap-rng.c
3 *
4 * RNG driver for TI OMAP CPU family
5 *
6 * Author: Deepak Saxena <dsaxena@plexity.net>
7 *
8 * Copyright 2005 (c) MontaVista Software, Inc.
9 *
10 * Mostly based on original driver:
11 *
12 * Copyright (C) 2005 Nokia Corporation
13 * Author: Juha Yrj��<juha.yrjola@nokia.com>
14 *
15 * This file is licensed under the terms of the GNU General Public
16 * License version 2. This program is licensed "as is" without any
17 * warranty of any kind, whether express or implied.
18 *
19 * TODO:
20 *
21 * - Make status updated be interrupt driven so we don't poll
22 *
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/random.h>
28#include <linux/err.h>
29#include <linux/device.h>
30#include <linux/hw_random.h>
31
32#include <asm/io.h>
33#include <asm/hardware/clock.h>
34
35#define RNG_OUT_REG 0x00 /* Output register */
36#define RNG_STAT_REG 0x04 /* Status register
37 [0] = STAT_BUSY */
38#define RNG_ALARM_REG 0x24 /* Alarm register
39 [7:0] = ALARM_COUNTER */
40#define RNG_CONFIG_REG 0x28 /* Configuration register
41 [11:6] = RESET_COUNT
42 [5:3] = RING2_DELAY
43 [2:0] = RING1_DELAY */
44#define RNG_REV_REG 0x3c /* Revision register
45 [7:0] = REV_NB */
46#define RNG_MASK_REG 0x40 /* Mask and reset register
47 [2] = IT_EN
48 [1] = SOFTRESET
49 [0] = AUTOIDLE */
50#define RNG_SYSSTATUS 0x44 /* System status
51 [0] = RESETDONE */
52
53static void __iomem *rng_base;
54static struct clk *rng_ick;
55static struct device *rng_dev;
56
57static u32 omap_rng_read_reg(int reg)
58{
59 return __raw_readl(rng_base + reg);
60}
61
62static void omap_rng_write_reg(int reg, u32 val)
63{
64 __raw_writel(val, rng_base + reg);
65}
66
67/* REVISIT: Does the status bit really work on 16xx? */
68static int omap_rng_data_present(struct hwrng *rng)
69{
70 return omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1;
71}
72
73static int omap_rng_data_read(struct hwrng *rng, u32 *data)
74{
75 *data = omap_rng_read_reg(RNG_OUT_REG);
76
77 return 4;
78}
79
80static struct hwrng omap_rng_ops = {
81 .name = "omap",
82 .data_present = omap_rng_data_present,
83 .data_read = omap_rng_data_read,
84};
85
86static int __init omap_rng_probe(struct device *dev)
87{
88 struct platform_device *pdev = to_platform_device(dev);
89 struct resource *res, *mem;
90 int ret;
91
92 /*
93 * A bit ugly, and it will never actually happen but there can
94 * be only one RNG and this catches any bork
95 */
96 BUG_ON(rng_dev);
97
98 if (cpu_is_omap24xx()) {
99 rng_ick = clk_get(NULL, "rng_ick");
100 if (IS_ERR(rng_ick)) {
101 dev_err(dev, "Could not get rng_ick\n");
102 ret = PTR_ERR(rng_ick);
103 return ret;
104 }
105 else {
106 clk_use(rng_ick);
107 }
108 }
109
110 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
111
112 if (!res)
113 return -ENOENT;
114
115 mem = request_mem_region(res->start, res->end - res->start + 1,
116 pdev->name);
117 if (mem == NULL)
118 return -EBUSY;
119
120 dev_set_drvdata(dev, mem);
121 rng_base = (u32 __iomem *)io_p2v(res->start);
122
123 ret = hwrng_register(&omap_rng_ops);
124 if (ret) {
125 release_resource(mem);
126 rng_base = NULL;
127 return ret;
128 }
129
130 dev_info(dev, "OMAP Random Number Generator ver. %02x\n",
131 omap_rng_read_reg(RNG_REV_REG));
132 omap_rng_write_reg(RNG_MASK_REG, 0x1);
133
134 rng_dev = dev;
135
136 return 0;
137}
138
139static int __exit omap_rng_remove(struct device *dev)
140{
141 struct resource *mem = dev_get_drvdata(dev);
142
143 hwrng_unregister(&omap_rng_ops);
144
145 omap_rng_write_reg(RNG_MASK_REG, 0x0);
146
147 if (cpu_is_omap24xx()) {
148 clk_unuse(rng_ick);
149 clk_put(rng_ick);
150 }
151
152 release_resource(mem);
153 rng_base = NULL;
154
155 return 0;
156}
157
158#ifdef CONFIG_PM
159
160static int omap_rng_suspend(struct device *dev, pm_message_t message, u32 level)
161{
162 omap_rng_write_reg(RNG_MASK_REG, 0x0);
163
164 return 0;
165}
166
167static int omap_rng_resume(struct device *dev, pm_message_t message, u32 level)
168{
169 omap_rng_write_reg(RNG_MASK_REG, 0x1);
170
171 return 1;
172}
173
174#else
175
176#define omap_rng_suspend NULL
177#define omap_rng_resume NULL
178
179#endif
180
181
182static struct device_driver omap_rng_driver = {
183 .name = "omap_rng",
184 .bus = &platform_bus_type,
185 .probe = omap_rng_probe,
186 .remove = __exit_p(omap_rng_remove),
187 .suspend = omap_rng_suspend,
188 .resume = omap_rng_resume
189};
190
191static int __init omap_rng_init(void)
192{
193 if (!cpu_is_omap16xx() && !cpu_is_omap24xx())
194 return -ENODEV;
195
196 return driver_register(&omap_rng_driver);
197}
198
199static void __exit omap_rng_exit(void)
200{
201 driver_unregister(&omap_rng_driver);
202}
203
204module_init(omap_rng_init);
205module_exit(omap_rng_exit);
206
207MODULE_AUTHOR("Deepak Saxena (and others)");
208MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
new file mode 100644
index 000000000000..0e786b617bb8
--- /dev/null
+++ b/drivers/char/hw_random/via-rng.c
@@ -0,0 +1,183 @@
1/*
2 * RNG driver for VIA RNGs
3 *
4 * Copyright 2005 (c) MontaVista Software, Inc.
5 *
6 * with the majority of the code coming from:
7 *
8 * Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
9 * (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
10 *
11 * derived from
12 *
13 * Hardware driver for the AMD 768 Random Number Generator (RNG)
14 * (c) Copyright 2001 Red Hat Inc <alan@redhat.com>
15 *
16 * derived from
17 *
18 * Hardware driver for Intel i810 Random Number Generator (RNG)
19 * Copyright 2000,2001 Jeff Garzik <jgarzik@pobox.com>
20 * Copyright 2000,2001 Philipp Rumpf <prumpf@mandrakesoft.com>
21 *
22 * This file is licensed under the terms of the GNU General Public
23 * License version 2. This program is licensed "as is" without any
24 * warranty of any kind, whether express or implied.
25 */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/pci.h>
30#include <linux/hw_random.h>
31#include <asm/io.h>
32#include <asm/msr.h>
33#include <asm/cpufeature.h>
34
35
36#define PFX KBUILD_MODNAME ": "
37
38
39enum {
40 VIA_STRFILT_CNT_SHIFT = 16,
41 VIA_STRFILT_FAIL = (1 << 15),
42 VIA_STRFILT_ENABLE = (1 << 14),
43 VIA_RAWBITS_ENABLE = (1 << 13),
44 VIA_RNG_ENABLE = (1 << 6),
45 VIA_XSTORE_CNT_MASK = 0x0F,
46
47 VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */
48 VIA_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */
49 VIA_RNG_CHUNK_4_MASK = 0xFFFFFFFF,
50 VIA_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */
51 VIA_RNG_CHUNK_2_MASK = 0xFFFF,
52 VIA_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */
53 VIA_RNG_CHUNK_1_MASK = 0xFF,
54};
55
56/*
57 * Investigate using the 'rep' prefix to obtain 32 bits of random data
58 * in one insn. The upside is potentially better performance. The
59 * downside is that the instruction becomes no longer atomic. Due to
60 * this, just like familiar issues with /dev/random itself, the worst
61 * case of a 'rep xstore' could potentially pause a cpu for an
62 * unreasonably long time. In practice, this condition would likely
63 * only occur when the hardware is failing. (or so we hope :))
64 *
65 * Another possible performance boost may come from simply buffering
66 * until we have 4 bytes, thus returning a u32 at a time,
67 * instead of the current u8-at-a-time.
68 */
69
70static inline u32 xstore(u32 *addr, u32 edx_in)
71{
72 u32 eax_out;
73
74 asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */"
75 :"=m"(*addr), "=a"(eax_out)
76 :"D"(addr), "d"(edx_in));
77
78 return eax_out;
79}
80
81static int via_rng_data_present(struct hwrng *rng)
82{
83 u32 bytes_out;
84 u32 *via_rng_datum = (u32 *)(&rng->priv);
85
86 /* We choose the recommended 1-byte-per-instruction RNG rate,
87 * for greater randomness at the expense of speed. Larger
88 * values 2, 4, or 8 bytes-per-instruction yield greater
89 * speed at lesser randomness.
90 *
91 * If you change this to another VIA_CHUNK_n, you must also
92 * change the ->n_bytes values in rng_vendor_ops[] tables.
93 * VIA_CHUNK_8 requires further code changes.
94 *
95 * A copy of MSR_VIA_RNG is placed in eax_out when xstore
96 * completes.
97 */
98
99 *via_rng_datum = 0; /* paranoia, not really necessary */
100 bytes_out = xstore(via_rng_datum, VIA_RNG_CHUNK_1);
101 bytes_out &= VIA_XSTORE_CNT_MASK;
102 if (bytes_out == 0)
103 return 0;
104 return 1;
105}
106
107static int via_rng_data_read(struct hwrng *rng, u32 *data)
108{
109 u32 via_rng_datum = (u32)rng->priv;
110
111 *data = via_rng_datum;
112
113 return 1;
114}
115
116static int via_rng_init(struct hwrng *rng)
117{
118 u32 lo, hi, old_lo;
119
120 /* Control the RNG via MSR. Tread lightly and pay very close
121 * close attention to values written, as the reserved fields
122 * are documented to be "undefined and unpredictable"; but it
123 * does not say to write them as zero, so I make a guess that
124 * we restore the values we find in the register.
125 */
126 rdmsr(MSR_VIA_RNG, lo, hi);
127
128 old_lo = lo;
129 lo &= ~(0x7f << VIA_STRFILT_CNT_SHIFT);
130 lo &= ~VIA_XSTORE_CNT_MASK;
131 lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE);
132 lo |= VIA_RNG_ENABLE;
133
134 if (lo != old_lo)
135 wrmsr(MSR_VIA_RNG, lo, hi);
136
137 /* perhaps-unnecessary sanity check; remove after testing if
138 unneeded */
139 rdmsr(MSR_VIA_RNG, lo, hi);
140 if ((lo & VIA_RNG_ENABLE) == 0) {
141 printk(KERN_ERR PFX "cannot enable VIA C3 RNG, aborting\n");
142 return -ENODEV;
143 }
144
145 return 0;
146}
147
148
149static struct hwrng via_rng = {
150 .name = "via",
151 .init = via_rng_init,
152 .data_present = via_rng_data_present,
153 .data_read = via_rng_data_read,
154};
155
156
157static int __init mod_init(void)
158{
159 int err;
160
161 if (!cpu_has_xstore)
162 return -ENODEV;
163 printk(KERN_INFO "VIA RNG detected\n");
164 err = hwrng_register(&via_rng);
165 if (err) {
166 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
167 err);
168 goto out;
169 }
170out:
171 return err;
172}
173
174static void __exit mod_exit(void)
175{
176 hwrng_unregister(&via_rng);
177}
178
179subsys_initcall(mod_init);
180module_exit(mod_exit);
181
182MODULE_DESCRIPTION("H/W RNG driver for VIA chipsets");
183MODULE_LICENSE("GPL");
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 03db1cb3fa95..9ab33c3d359f 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -305,7 +305,7 @@ static struct class *ip2_class;
305 305
306// Some functions to keep track of what irq's we have 306// Some functions to keep track of what irq's we have
307 307
308static int __init 308static int
309is_valid_irq(int irq) 309is_valid_irq(int irq)
310{ 310{
311 int *i = Valid_Irqs; 311 int *i = Valid_Irqs;
@@ -316,14 +316,14 @@ is_valid_irq(int irq)
316 return (*i); 316 return (*i);
317} 317}
318 318
319static void __init 319static void
320mark_requested_irq( char irq ) 320mark_requested_irq( char irq )
321{ 321{
322 rirqs[iindx++] = irq; 322 rirqs[iindx++] = irq;
323} 323}
324 324
325#ifdef MODULE 325#ifdef MODULE
326static int __init 326static int
327clear_requested_irq( char irq ) 327clear_requested_irq( char irq )
328{ 328{
329 int i; 329 int i;
@@ -337,7 +337,7 @@ clear_requested_irq( char irq )
337} 337}
338#endif 338#endif
339 339
340static int __init 340static int
341have_requested_irq( char irq ) 341have_requested_irq( char irq )
342{ 342{
343 // array init to zeros so 0 irq will not be requested as a side effect 343 // array init to zeros so 0 irq will not be requested as a side effect
@@ -818,7 +818,7 @@ EXPORT_SYMBOL(ip2_loadmain);
818/* the board, the channel structures are initialized, and the board details */ 818/* the board, the channel structures are initialized, and the board details */
819/* are reported on the console. */ 819/* are reported on the console. */
820/******************************************************************************/ 820/******************************************************************************/
821static void __init 821static void
822ip2_init_board( int boardnum ) 822ip2_init_board( int boardnum )
823{ 823{
824 int i; 824 int i;
@@ -961,7 +961,7 @@ err_initialize:
961/* EISA motherboard, or no valid board ID is selected it returns 0. Otherwise */ 961/* EISA motherboard, or no valid board ID is selected it returns 0. Otherwise */
962/* it returns the base address of the controller. */ 962/* it returns the base address of the controller. */
963/******************************************************************************/ 963/******************************************************************************/
964static unsigned short __init 964static unsigned short
965find_eisa_board( int start_slot ) 965find_eisa_board( int start_slot )
966{ 966{
967 int i, j; 967 int i, j;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 9f2f8fdec69a..ad26f4b997c5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -57,8 +57,7 @@ static int ipmi_init_msghandler(void);
57static int initialized = 0; 57static int initialized = 0;
58 58
59#ifdef CONFIG_PROC_FS 59#ifdef CONFIG_PROC_FS
60struct proc_dir_entry *proc_ipmi_root = NULL; 60static struct proc_dir_entry *proc_ipmi_root = NULL;
61EXPORT_SYMBOL(proc_ipmi_root);
62#endif /* CONFIG_PROC_FS */ 61#endif /* CONFIG_PROC_FS */
63 62
64#define MAX_EVENTS_IN_QUEUE 25 63#define MAX_EVENTS_IN_QUEUE 25
@@ -936,11 +935,8 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
936 935
937 if (val) { 936 if (val) {
938 /* Deliver any queued events. */ 937 /* Deliver any queued events. */
939 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, 938 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
940 link) { 939 list_move_tail(&msg->link, &msgs);
941 list_del(&msg->link);
942 list_add_tail(&msg->link, &msgs);
943 }
944 intf->waiting_events_count = 0; 940 intf->waiting_events_count = 0;
945 } 941 }
946 942
@@ -3677,7 +3673,7 @@ static void send_panic_events(char *str)
3677} 3673}
3678#endif /* CONFIG_IPMI_PANIC_EVENT */ 3674#endif /* CONFIG_IPMI_PANIC_EVENT */
3679 3675
3680static int has_paniced = 0; 3676static int has_panicked = 0;
3681 3677
3682static int panic_event(struct notifier_block *this, 3678static int panic_event(struct notifier_block *this,
3683 unsigned long event, 3679 unsigned long event,
@@ -3686,9 +3682,9 @@ static int panic_event(struct notifier_block *this,
3686 int i; 3682 int i;
3687 ipmi_smi_t intf; 3683 ipmi_smi_t intf;
3688 3684
3689 if (has_paniced) 3685 if (has_panicked)
3690 return NOTIFY_DONE; 3686 return NOTIFY_DONE;
3691 has_paniced = 1; 3687 has_panicked = 1;
3692 3688
3693 /* For every registered interface, set it to run to completion. */ 3689 /* For every registered interface, set it to run to completion. */
3694 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3690 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
@@ -3742,11 +3738,8 @@ static int ipmi_init_msghandler(void)
3742 proc_ipmi_root->owner = THIS_MODULE; 3738 proc_ipmi_root->owner = THIS_MODULE;
3743#endif /* CONFIG_PROC_FS */ 3739#endif /* CONFIG_PROC_FS */
3744 3740
3745 init_timer(&ipmi_timer); 3741 setup_timer(&ipmi_timer, ipmi_timeout, 0);
3746 ipmi_timer.data = 0; 3742 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
3747 ipmi_timer.function = ipmi_timeout;
3748 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES;
3749 add_timer(&ipmi_timer);
3750 3743
3751 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 3744 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
3752 3745
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 02a7dd7a8a55..bd4f2248b758 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -55,23 +55,6 @@
55#include <linux/mutex.h> 55#include <linux/mutex.h>
56#include <linux/kthread.h> 56#include <linux/kthread.h>
57#include <asm/irq.h> 57#include <asm/irq.h>
58#ifdef CONFIG_HIGH_RES_TIMERS
59#include <linux/hrtime.h>
60# if defined(schedule_next_int)
61/* Old high-res timer code, do translations. */
62# define get_arch_cycles(a) quick_update_jiffies_sub(a)
63# define arch_cycles_per_jiffy cycles_per_jiffies
64# endif
65static inline void add_usec_to_timer(struct timer_list *t, long v)
66{
67 t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000);
68 while (t->arch_cycle_expires >= arch_cycles_per_jiffy)
69 {
70 t->expires++;
71 t->arch_cycle_expires -= arch_cycles_per_jiffy;
72 }
73}
74#endif
75#include <linux/interrupt.h> 58#include <linux/interrupt.h>
76#include <linux/rcupdate.h> 59#include <linux/rcupdate.h>
77#include <linux/ipmi_smi.h> 60#include <linux/ipmi_smi.h>
@@ -243,8 +226,6 @@ static int register_xaction_notifier(struct notifier_block * nb)
243 return atomic_notifier_chain_register(&xaction_notifier_list, nb); 226 return atomic_notifier_chain_register(&xaction_notifier_list, nb);
244} 227}
245 228
246static void si_restart_short_timer(struct smi_info *smi_info);
247
248static void deliver_recv_msg(struct smi_info *smi_info, 229static void deliver_recv_msg(struct smi_info *smi_info,
249 struct ipmi_smi_msg *msg) 230 struct ipmi_smi_msg *msg)
250{ 231{
@@ -768,7 +749,6 @@ static void sender(void *send_info,
768 && (smi_info->curr_msg == NULL)) 749 && (smi_info->curr_msg == NULL))
769 { 750 {
770 start_next_msg(smi_info); 751 start_next_msg(smi_info);
771 si_restart_short_timer(smi_info);
772 } 752 }
773 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 753 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
774} 754}
@@ -809,7 +789,7 @@ static int ipmi_thread(void *data)
809 /* do nothing */ 789 /* do nothing */
810 } 790 }
811 else if (smi_result == SI_SM_CALL_WITH_DELAY) 791 else if (smi_result == SI_SM_CALL_WITH_DELAY)
812 udelay(1); 792 schedule();
813 else 793 else
814 schedule_timeout_interruptible(1); 794 schedule_timeout_interruptible(1);
815 } 795 }
@@ -833,37 +813,6 @@ static void request_events(void *send_info)
833 813
834static int initialized = 0; 814static int initialized = 0;
835 815
836/* Must be called with interrupts off and with the si_lock held. */
837static void si_restart_short_timer(struct smi_info *smi_info)
838{
839#if defined(CONFIG_HIGH_RES_TIMERS)
840 unsigned long flags;
841 unsigned long jiffies_now;
842 unsigned long seq;
843
844 if (del_timer(&(smi_info->si_timer))) {
845 /* If we don't delete the timer, then it will go off
846 immediately, anyway. So we only process if we
847 actually delete the timer. */
848
849 do {
850 seq = read_seqbegin_irqsave(&xtime_lock, flags);
851 jiffies_now = jiffies;
852 smi_info->si_timer.expires = jiffies_now;
853 smi_info->si_timer.arch_cycle_expires
854 = get_arch_cycles(jiffies_now);
855 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
856
857 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
858
859 add_timer(&(smi_info->si_timer));
860 spin_lock_irqsave(&smi_info->count_lock, flags);
861 smi_info->timeout_restarts++;
862 spin_unlock_irqrestore(&smi_info->count_lock, flags);
863 }
864#endif
865}
866
867static void smi_timeout(unsigned long data) 816static void smi_timeout(unsigned long data)
868{ 817{
869 struct smi_info *smi_info = (struct smi_info *) data; 818 struct smi_info *smi_info = (struct smi_info *) data;
@@ -904,31 +853,15 @@ static void smi_timeout(unsigned long data)
904 /* If the state machine asks for a short delay, then shorten 853 /* If the state machine asks for a short delay, then shorten
905 the timer timeout. */ 854 the timer timeout. */
906 if (smi_result == SI_SM_CALL_WITH_DELAY) { 855 if (smi_result == SI_SM_CALL_WITH_DELAY) {
907#if defined(CONFIG_HIGH_RES_TIMERS)
908 unsigned long seq;
909#endif
910 spin_lock_irqsave(&smi_info->count_lock, flags); 856 spin_lock_irqsave(&smi_info->count_lock, flags);
911 smi_info->short_timeouts++; 857 smi_info->short_timeouts++;
912 spin_unlock_irqrestore(&smi_info->count_lock, flags); 858 spin_unlock_irqrestore(&smi_info->count_lock, flags);
913#if defined(CONFIG_HIGH_RES_TIMERS)
914 do {
915 seq = read_seqbegin_irqsave(&xtime_lock, flags);
916 smi_info->si_timer.expires = jiffies;
917 smi_info->si_timer.arch_cycle_expires
918 = get_arch_cycles(smi_info->si_timer.expires);
919 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
920 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
921#else
922 smi_info->si_timer.expires = jiffies + 1; 859 smi_info->si_timer.expires = jiffies + 1;
923#endif
924 } else { 860 } else {
925 spin_lock_irqsave(&smi_info->count_lock, flags); 861 spin_lock_irqsave(&smi_info->count_lock, flags);
926 smi_info->long_timeouts++; 862 smi_info->long_timeouts++;
927 spin_unlock_irqrestore(&smi_info->count_lock, flags); 863 spin_unlock_irqrestore(&smi_info->count_lock, flags);
928 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 864 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
929#if defined(CONFIG_HIGH_RES_TIMERS)
930 smi_info->si_timer.arch_cycle_expires = 0;
931#endif
932 } 865 }
933 866
934 do_add_timer: 867 do_add_timer:
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 2d11ddd99e55..1a0a19c53605 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp)
212{ 212{
213 action_fn fn = (action_fn) kp->arg; 213 action_fn fn = (action_fn) kp->arg;
214 int rv = 0; 214 int rv = 0;
215 const char *end; 215 char *dup, *s;
216 char valcp[16]; 216
217 int len; 217 dup = kstrdup(val, GFP_KERNEL);
218 218 if (!dup)
219 /* Truncate leading and trailing spaces. */ 219 return -ENOMEM;
220 while (isspace(*val)) 220
221 val++; 221 s = strstrip(dup);
222 end = val + strlen(val) - 1;
223 while ((end >= val) && isspace(*end))
224 end--;
225 len = end - val + 1;
226 if (len > sizeof(valcp) - 1)
227 return -EINVAL;
228 memcpy(valcp, val, len);
229 valcp[len] = '\0';
230 222
231 down_read(&register_sem); 223 down_read(&register_sem);
232 rv = fn(valcp, NULL); 224 rv = fn(s, NULL);
233 if (rv) 225 if (rv)
234 goto out_unlock; 226 goto out_unlock;
235 227
@@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp)
239 231
240 out_unlock: 232 out_unlock:
241 up_read(&register_sem); 233 up_read(&register_sem);
234 kfree(dup);
242 return rv; 235 return rv;
243} 236}
244 237
@@ -956,9 +949,10 @@ static int wdog_reboot_handler(struct notifier_block *this,
956 /* Disable the WDT if we are shutting down. */ 949 /* Disable the WDT if we are shutting down. */
957 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 950 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
958 panic_halt_ipmi_set_timeout(); 951 panic_halt_ipmi_set_timeout();
959 } else { 952 } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
960 /* Set a long timer to let the reboot happens, but 953 /* Set a long timer to let the reboot happens, but
961 reboot if it hangs. */ 954 reboot if it hangs, but only if the watchdog
955 timer was already running. */
962 timeout = 120; 956 timeout = 120;
963 pretimeout = 0; 957 pretimeout = 0;
964 ipmi_watchdog_state = WDOG_TIMEOUT_RESET; 958 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
@@ -980,16 +974,17 @@ static int wdog_panic_handler(struct notifier_block *this,
980{ 974{
981 static int panic_event_handled = 0; 975 static int panic_event_handled = 0;
982 976
983 /* On a panic, if we have a panic timeout, make sure that the thing 977 /* On a panic, if we have a panic timeout, make sure to extend
984 reboots, even if it hangs during that panic. */ 978 the watchdog timer to a reasonable value to complete the
985 if (watchdog_user && !panic_event_handled) { 979 panic, if the watchdog timer is running. Plus the
986 /* Make sure the panic doesn't hang, and make sure we 980 pretimeout is meaningless at panic time. */
987 do this only once. */ 981 if (watchdog_user && !panic_event_handled &&
982 ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
983 /* Make sure we do this only once. */
988 panic_event_handled = 1; 984 panic_event_handled = 1;
989 985
990 timeout = 255; 986 timeout = 255;
991 pretimeout = 0; 987 pretimeout = 0;
992 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
993 panic_halt_ipmi_set_timeout(); 988 panic_halt_ipmi_set_timeout();
994 } 989 }
995 990
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index e9ebabaf8cb0..efaaa1937ab6 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -1145,7 +1145,7 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,
1145 if (isicom_paranoia_check(port, tty->name, "isicom_write")) 1145 if (isicom_paranoia_check(port, tty->name, "isicom_write"))
1146 return 0; 1146 return 0;
1147 1147
1148 if (!tty || !port->xmit_buf) 1148 if (!port->xmit_buf)
1149 return 0; 1149 return 0;
1150 1150
1151 spin_lock_irqsave(&card->card_lock, flags); 1151 spin_lock_irqsave(&card->card_lock, flags);
@@ -1180,7 +1180,7 @@ static void isicom_put_char(struct tty_struct *tty, unsigned char ch)
1180 if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) 1180 if (isicom_paranoia_check(port, tty->name, "isicom_put_char"))
1181 return; 1181 return;
1182 1182
1183 if (!tty || !port->xmit_buf) 1183 if (!port->xmit_buf)
1184 return; 1184 return;
1185 1185
1186 spin_lock_irqsave(&card->card_lock, flags); 1186 spin_lock_irqsave(&card->card_lock, flags);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ef20c1fc9c4c..216c79256de3 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -42,13 +42,12 @@
42#include <linux/devfs_fs_kernel.h> 42#include <linux/devfs_fs_kernel.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/wait.h> 44#include <linux/wait.h>
45#include <linux/eisa.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#ifdef CONFIG_PCI
50#include <linux/pci.h> 50#include <linux/pci.h>
51#endif
52 51
53/*****************************************************************************/ 52/*****************************************************************************/
54 53
@@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = {
137 136
138static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); 137static int stli_nrbrds = ARRAY_SIZE(stli_brdconf);
139 138
139/* stli_lock must NOT be taken holding brd_lock */
140static spinlock_t stli_lock; /* TTY logic lock */
141static spinlock_t brd_lock; /* Board logic lock */
142
140/* 143/*
141 * There is some experimental EISA board detection code in this driver. 144 * There is some experimental EISA board detection code in this driver.
142 * By default it is disabled, but for those that want to try it out, 145 * By default it is disabled, but for those that want to try it out,
@@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE";
173 176
174static struct tty_driver *stli_serial; 177static struct tty_driver *stli_serial;
175 178
176/*
177 * We will need to allocate a temporary write buffer for chars that
178 * come direct from user space. The problem is that a copy from user
179 * space might cause a page fault (typically on a system that is
180 * swapping!). All ports will share one buffer - since if the system
181 * is already swapping a shared buffer won't make things any worse.
182 */
183static char *stli_tmpwritebuf;
184 179
185#define STLI_TXBUFSIZE 4096 180#define STLI_TXBUFSIZE 4096
186 181
@@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
419#endif 414#endif
420 415
421static struct pci_device_id istallion_pci_tbl[] = { 416static struct pci_device_id istallion_pci_tbl[] = {
422 { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 417 { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), },
423 { 0 } 418 { 0 }
424}; 419};
425MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); 420MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
@@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp);
682static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); 677static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
683static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); 678static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
684static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); 679static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
685static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); 680static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
686static void stli_poll(unsigned long arg); 681static void stli_poll(unsigned long arg);
687static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); 682static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
688static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); 683static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
@@ -693,7 +688,8 @@ static void stli_dohangup(void *arg);
693static int stli_setport(stliport_t *portp); 688static int stli_setport(stliport_t *portp);
694static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 689static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
695static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 690static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
696static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); 691static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
692static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
697static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); 693static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
698static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); 694static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
699static long stli_mktiocm(unsigned long sigvalue); 695static long stli_mktiocm(unsigned long sigvalue);
@@ -799,18 +795,8 @@ static struct class *istallion_class;
799 795
800static int __init istallion_module_init(void) 796static int __init istallion_module_init(void)
801{ 797{
802 unsigned long flags;
803
804#ifdef DEBUG
805 printk("init_module()\n");
806#endif
807
808 save_flags(flags);
809 cli();
810 stli_init(); 798 stli_init();
811 restore_flags(flags); 799 return 0;
812
813 return(0);
814} 800}
815 801
816/*****************************************************************************/ 802/*****************************************************************************/
@@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void)
819{ 805{
820 stlibrd_t *brdp; 806 stlibrd_t *brdp;
821 stliport_t *portp; 807 stliport_t *portp;
822 unsigned long flags;
823 int i, j; 808 int i, j;
824 809
825#ifdef DEBUG
826 printk("cleanup_module()\n");
827#endif
828
829 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, 810 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
830 stli_drvversion); 811 stli_drvversion);
831 812
832 save_flags(flags); 813 /*
833 cli(); 814 * Free up all allocated resources used by the ports. This includes
834 815 * memory and interrupts.
835/* 816 */
836 * Free up all allocated resources used by the ports. This includes
837 * memory and interrupts.
838 */
839 if (stli_timeron) { 817 if (stli_timeron) {
840 stli_timeron = 0; 818 stli_timeron = 0;
841 del_timer(&stli_timerlist); 819 del_timer_sync(&stli_timerlist);
842 } 820 }
843 821
844 i = tty_unregister_driver(stli_serial); 822 i = tty_unregister_driver(stli_serial);
845 if (i) { 823 if (i) {
846 printk("STALLION: failed to un-register tty driver, " 824 printk("STALLION: failed to un-register tty driver, "
847 "errno=%d\n", -i); 825 "errno=%d\n", -i);
848 restore_flags(flags);
849 return; 826 return;
850 } 827 }
851 put_tty_driver(stli_serial); 828 put_tty_driver(stli_serial);
@@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void)
859 printk("STALLION: failed to un-register serial memory device, " 836 printk("STALLION: failed to un-register serial memory device, "
860 "errno=%d\n", -i); 837 "errno=%d\n", -i);
861 838
862 kfree(stli_tmpwritebuf);
863 kfree(stli_txcookbuf); 839 kfree(stli_txcookbuf);
864 840
865 for (i = 0; (i < stli_nrbrds); i++) { 841 for (i = 0; (i < stli_nrbrds); i++) {
866 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) 842 if ((brdp = stli_brds[i]) == NULL)
867 continue; 843 continue;
868 for (j = 0; (j < STL_MAXPORTS); j++) { 844 for (j = 0; (j < STL_MAXPORTS); j++) {
869 portp = brdp->ports[j]; 845 portp = brdp->ports[j];
870 if (portp != (stliport_t *) NULL) { 846 if (portp != NULL) {
871 if (portp->tty != (struct tty_struct *) NULL) 847 if (portp->tty != NULL)
872 tty_hangup(portp->tty); 848 tty_hangup(portp->tty);
873 kfree(portp); 849 kfree(portp);
874 } 850 }
@@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void)
878 if (brdp->iosize > 0) 854 if (brdp->iosize > 0)
879 release_region(brdp->iobase, brdp->iosize); 855 release_region(brdp->iobase, brdp->iosize);
880 kfree(brdp); 856 kfree(brdp);
881 stli_brds[i] = (stlibrd_t *) NULL; 857 stli_brds[i] = NULL;
882 } 858 }
883
884 restore_flags(flags);
885} 859}
886 860
887module_init(istallion_module_init); 861module_init(istallion_module_init);
@@ -895,19 +869,15 @@ module_exit(istallion_module_exit);
895 869
896static void stli_argbrds(void) 870static void stli_argbrds(void)
897{ 871{
898 stlconf_t conf; 872 stlconf_t conf;
899 stlibrd_t *brdp; 873 stlibrd_t *brdp;
900 int i; 874 int i;
901
902#ifdef DEBUG
903 printk("stli_argbrds()\n");
904#endif
905 875
906 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { 876 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
907 memset(&conf, 0, sizeof(conf)); 877 memset(&conf, 0, sizeof(conf));
908 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) 878 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
909 continue; 879 continue;
910 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 880 if ((brdp = stli_allocbrd()) == NULL)
911 continue; 881 continue;
912 stli_nrbrds = i + 1; 882 stli_nrbrds = i + 1;
913 brdp->brdnr = i; 883 brdp->brdnr = i;
@@ -926,9 +896,9 @@ static void stli_argbrds(void)
926 896
927static unsigned long stli_atol(char *str) 897static unsigned long stli_atol(char *str)
928{ 898{
929 unsigned long val; 899 unsigned long val;
930 int base, c; 900 int base, c;
931 char *sp; 901 char *sp;
932 902
933 val = 0; 903 val = 0;
934 sp = str; 904 sp = str;
@@ -962,15 +932,11 @@ static unsigned long stli_atol(char *str)
962 932
963static int stli_parsebrd(stlconf_t *confp, char **argp) 933static int stli_parsebrd(stlconf_t *confp, char **argp)
964{ 934{
965 char *sp; 935 char *sp;
966 int i; 936 int i;
967
968#ifdef DEBUG
969 printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
970#endif
971 937
972 if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) 938 if (argp[0] == NULL || *argp[0] == 0)
973 return(0); 939 return 0;
974 940
975 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) 941 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
976 *sp = TOLOWER(*sp); 942 *sp = TOLOWER(*sp);
@@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
985 } 951 }
986 952
987 confp->brdtype = stli_brdstr[i].type; 953 confp->brdtype = stli_brdstr[i].type;
988 if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) 954 if (argp[1] != NULL && *argp[1] != 0)
989 confp->ioaddr1 = stli_atol(argp[1]); 955 confp->ioaddr1 = stli_atol(argp[1]);
990 if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) 956 if (argp[2] != NULL && *argp[2] != 0)
991 confp->memaddr = stli_atol(argp[2]); 957 confp->memaddr = stli_atol(argp[2]);
992 return(1); 958 return(1);
993} 959}
@@ -998,34 +964,29 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
998 964
999static int stli_open(struct tty_struct *tty, struct file *filp) 965static int stli_open(struct tty_struct *tty, struct file *filp)
1000{ 966{
1001 stlibrd_t *brdp; 967 stlibrd_t *brdp;
1002 stliport_t *portp; 968 stliport_t *portp;
1003 unsigned int minordev; 969 unsigned int minordev;
1004 int brdnr, portnr, rc; 970 int brdnr, portnr, rc;
1005
1006#ifdef DEBUG
1007 printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
1008 (int) filp, tty->name);
1009#endif
1010 971
1011 minordev = tty->index; 972 minordev = tty->index;
1012 brdnr = MINOR2BRD(minordev); 973 brdnr = MINOR2BRD(minordev);
1013 if (brdnr >= stli_nrbrds) 974 if (brdnr >= stli_nrbrds)
1014 return(-ENODEV); 975 return -ENODEV;
1015 brdp = stli_brds[brdnr]; 976 brdp = stli_brds[brdnr];
1016 if (brdp == (stlibrd_t *) NULL) 977 if (brdp == NULL)
1017 return(-ENODEV); 978 return -ENODEV;
1018 if ((brdp->state & BST_STARTED) == 0) 979 if ((brdp->state & BST_STARTED) == 0)
1019 return(-ENODEV); 980 return -ENODEV;
1020 portnr = MINOR2PORT(minordev); 981 portnr = MINOR2PORT(minordev);
1021 if ((portnr < 0) || (portnr > brdp->nrports)) 982 if ((portnr < 0) || (portnr > brdp->nrports))
1022 return(-ENODEV); 983 return -ENODEV;
1023 984
1024 portp = brdp->ports[portnr]; 985 portp = brdp->ports[portnr];
1025 if (portp == (stliport_t *) NULL) 986 if (portp == NULL)
1026 return(-ENODEV); 987 return -ENODEV;
1027 if (portp->devnr < 1) 988 if (portp->devnr < 1)
1028 return(-ENODEV); 989 return -ENODEV;
1029 990
1030 991
1031/* 992/*
@@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1037 if (portp->flags & ASYNC_CLOSING) { 998 if (portp->flags & ASYNC_CLOSING) {
1038 interruptible_sleep_on(&portp->close_wait); 999 interruptible_sleep_on(&portp->close_wait);
1039 if (portp->flags & ASYNC_HUP_NOTIFY) 1000 if (portp->flags & ASYNC_HUP_NOTIFY)
1040 return(-EAGAIN); 1001 return -EAGAIN;
1041 return(-ERESTARTSYS); 1002 return -ERESTARTSYS;
1042 } 1003 }
1043 1004
1044/* 1005/*
@@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1054 wait_event_interruptible(portp->raw_wait, 1015 wait_event_interruptible(portp->raw_wait,
1055 !test_bit(ST_INITIALIZING, &portp->state)); 1016 !test_bit(ST_INITIALIZING, &portp->state));
1056 if (signal_pending(current)) 1017 if (signal_pending(current))
1057 return(-ERESTARTSYS); 1018 return -ERESTARTSYS;
1058 1019
1059 if ((portp->flags & ASYNC_INITIALIZED) == 0) { 1020 if ((portp->flags & ASYNC_INITIALIZED) == 0) {
1060 set_bit(ST_INITIALIZING, &portp->state); 1021 set_bit(ST_INITIALIZING, &portp->state);
@@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1065 clear_bit(ST_INITIALIZING, &portp->state); 1026 clear_bit(ST_INITIALIZING, &portp->state);
1066 wake_up_interruptible(&portp->raw_wait); 1027 wake_up_interruptible(&portp->raw_wait);
1067 if (rc < 0) 1028 if (rc < 0)
1068 return(rc); 1029 return rc;
1069 } 1030 }
1070 1031
1071/* 1032/*
@@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1077 if (portp->flags & ASYNC_CLOSING) { 1038 if (portp->flags & ASYNC_CLOSING) {
1078 interruptible_sleep_on(&portp->close_wait); 1039 interruptible_sleep_on(&portp->close_wait);
1079 if (portp->flags & ASYNC_HUP_NOTIFY) 1040 if (portp->flags & ASYNC_HUP_NOTIFY)
1080 return(-EAGAIN); 1041 return -EAGAIN;
1081 return(-ERESTARTSYS); 1042 return -ERESTARTSYS;
1082 } 1043 }
1083 1044
1084/* 1045/*
@@ -1088,38 +1049,33 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1088 */ 1049 */
1089 if (!(filp->f_flags & O_NONBLOCK)) { 1050 if (!(filp->f_flags & O_NONBLOCK)) {
1090 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) 1051 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
1091 return(rc); 1052 return rc;
1092 } 1053 }
1093 portp->flags |= ASYNC_NORMAL_ACTIVE; 1054 portp->flags |= ASYNC_NORMAL_ACTIVE;
1094 return(0); 1055 return 0;
1095} 1056}
1096 1057
1097/*****************************************************************************/ 1058/*****************************************************************************/
1098 1059
1099static void stli_close(struct tty_struct *tty, struct file *filp) 1060static void stli_close(struct tty_struct *tty, struct file *filp)
1100{ 1061{
1101 stlibrd_t *brdp; 1062 stlibrd_t *brdp;
1102 stliport_t *portp; 1063 stliport_t *portp;
1103 unsigned long flags; 1064 unsigned long flags;
1104
1105#ifdef DEBUG
1106 printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
1107#endif
1108 1065
1109 portp = tty->driver_data; 1066 portp = tty->driver_data;
1110 if (portp == (stliport_t *) NULL) 1067 if (portp == NULL)
1111 return; 1068 return;
1112 1069
1113 save_flags(flags); 1070 spin_lock_irqsave(&stli_lock, flags);
1114 cli();
1115 if (tty_hung_up_p(filp)) { 1071 if (tty_hung_up_p(filp)) {
1116 restore_flags(flags); 1072 spin_unlock_irqrestore(&stli_lock, flags);
1117 return; 1073 return;
1118 } 1074 }
1119 if ((tty->count == 1) && (portp->refcount != 1)) 1075 if ((tty->count == 1) && (portp->refcount != 1))
1120 portp->refcount = 1; 1076 portp->refcount = 1;
1121 if (portp->refcount-- > 1) { 1077 if (portp->refcount-- > 1) {
1122 restore_flags(flags); 1078 spin_unlock_irqrestore(&stli_lock, flags);
1123 return; 1079 return;
1124 } 1080 }
1125 1081
@@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1134 if (tty == stli_txcooktty) 1090 if (tty == stli_txcooktty)
1135 stli_flushchars(tty); 1091 stli_flushchars(tty);
1136 tty->closing = 1; 1092 tty->closing = 1;
1093 spin_unlock_irqrestore(&stli_lock, flags);
1094
1137 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1095 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1138 tty_wait_until_sent(tty, portp->closing_wait); 1096 tty_wait_until_sent(tty, portp->closing_wait);
1139 1097
@@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1157 stli_flushbuffer(tty); 1115 stli_flushbuffer(tty);
1158 1116
1159 tty->closing = 0; 1117 tty->closing = 0;
1160 portp->tty = (struct tty_struct *) NULL; 1118 portp->tty = NULL;
1161 1119
1162 if (portp->openwaitcnt) { 1120 if (portp->openwaitcnt) {
1163 if (portp->close_delay) 1121 if (portp->close_delay)
@@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1167 1125
1168 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1126 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1169 wake_up_interruptible(&portp->close_wait); 1127 wake_up_interruptible(&portp->close_wait);
1170 restore_flags(flags);
1171} 1128}
1172 1129
1173/*****************************************************************************/ 1130/*****************************************************************************/
@@ -1182,45 +1139,41 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1182 1139
1183static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) 1140static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1184{ 1141{
1185 struct tty_struct *tty; 1142 struct tty_struct *tty;
1186 asynotify_t nt; 1143 asynotify_t nt;
1187 asyport_t aport; 1144 asyport_t aport;
1188 int rc; 1145 int rc;
1189
1190#ifdef DEBUG
1191 printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp);
1192#endif
1193 1146
1194 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) 1147 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0)
1195 return(rc); 1148 return rc;
1196 1149
1197 memset(&nt, 0, sizeof(asynotify_t)); 1150 memset(&nt, 0, sizeof(asynotify_t));
1198 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); 1151 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK);
1199 nt.signal = SG_DCD; 1152 nt.signal = SG_DCD;
1200 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, 1153 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt,
1201 sizeof(asynotify_t), 0)) < 0) 1154 sizeof(asynotify_t), 0)) < 0)
1202 return(rc); 1155 return rc;
1203 1156
1204 tty = portp->tty; 1157 tty = portp->tty;
1205 if (tty == (struct tty_struct *) NULL) 1158 if (tty == NULL)
1206 return(-ENODEV); 1159 return -ENODEV;
1207 stli_mkasyport(portp, &aport, tty->termios); 1160 stli_mkasyport(portp, &aport, tty->termios);
1208 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, 1161 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport,
1209 sizeof(asyport_t), 0)) < 0) 1162 sizeof(asyport_t), 0)) < 0)
1210 return(rc); 1163 return rc;
1211 1164
1212 set_bit(ST_GETSIGS, &portp->state); 1165 set_bit(ST_GETSIGS, &portp->state);
1213 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, 1166 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig,
1214 sizeof(asysigs_t), 1)) < 0) 1167 sizeof(asysigs_t), 1)) < 0)
1215 return(rc); 1168 return rc;
1216 if (test_and_clear_bit(ST_GETSIGS, &portp->state)) 1169 if (test_and_clear_bit(ST_GETSIGS, &portp->state))
1217 portp->sigs = stli_mktiocm(portp->asig.sigvalue); 1170 portp->sigs = stli_mktiocm(portp->asig.sigvalue);
1218 stli_mkasysigs(&portp->asig, 1, 1); 1171 stli_mkasysigs(&portp->asig, 1, 1);
1219 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, 1172 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
1220 sizeof(asysigs_t), 0)) < 0) 1173 sizeof(asysigs_t), 0)) < 0)
1221 return(rc); 1174 return rc;
1222 1175
1223 return(0); 1176 return 0;
1224} 1177}
1225 1178
1226/*****************************************************************************/ 1179/*****************************************************************************/
@@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1234 1187
1235static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1188static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1236{ 1189{
1237 volatile cdkhdr_t *hdrp; 1190 cdkhdr_t __iomem *hdrp;
1238 volatile cdkctrl_t *cp; 1191 cdkctrl_t __iomem *cp;
1239 volatile unsigned char *bits; 1192 unsigned char __iomem *bits;
1240 unsigned long flags; 1193 unsigned long flags;
1241 int rc; 1194 int rc;
1242
1243#ifdef DEBUG
1244 printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1245 (int) brdp, (int) portp, (int) arg, wait);
1246#endif
1247 1195
1248/* 1196/*
1249 * Send a message to the slave to open this port. 1197 * Send a message to the slave to open this port.
1250 */ 1198 */
1251 save_flags(flags);
1252 cli();
1253 1199
1254/* 1200/*
1255 * Slave is already closing this port. This can happen if a hangup 1201 * Slave is already closing this port. This can happen if a hangup
@@ -1260,7 +1206,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1260 wait_event_interruptible(portp->raw_wait, 1206 wait_event_interruptible(portp->raw_wait,
1261 !test_bit(ST_CLOSING, &portp->state)); 1207 !test_bit(ST_CLOSING, &portp->state));
1262 if (signal_pending(current)) { 1208 if (signal_pending(current)) {
1263 restore_flags(flags);
1264 return -ERESTARTSYS; 1209 return -ERESTARTSYS;
1265 } 1210 }
1266 1211
@@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1269 * memory. Once the message is in set the service bits to say that 1214 * memory. Once the message is in set the service bits to say that
1270 * this port wants service. 1215 * this port wants service.
1271 */ 1216 */
1217 spin_lock_irqsave(&brd_lock, flags);
1272 EBRDENABLE(brdp); 1218 EBRDENABLE(brdp);
1273 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1219 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1274 cp->openarg = arg; 1220 writel(arg, &cp->openarg);
1275 cp->open = 1; 1221 writeb(1, &cp->open);
1276 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1222 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1277 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1223 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1278 portp->portidx; 1224 portp->portidx;
1279 *bits |= portp->portbit; 1225 writeb(readb(bits) | portp->portbit, bits);
1280 EBRDDISABLE(brdp); 1226 EBRDDISABLE(brdp);
1281 1227
1282 if (wait == 0) { 1228 if (wait == 0) {
1283 restore_flags(flags); 1229 spin_unlock_irqrestore(&brd_lock, flags);
1284 return(0); 1230 return 0;
1285 } 1231 }
1286 1232
1287/* 1233/*
@@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1290 */ 1236 */
1291 rc = 0; 1237 rc = 0;
1292 set_bit(ST_OPENING, &portp->state); 1238 set_bit(ST_OPENING, &portp->state);
1239 spin_unlock_irqrestore(&brd_lock, flags);
1240
1293 wait_event_interruptible(portp->raw_wait, 1241 wait_event_interruptible(portp->raw_wait,
1294 !test_bit(ST_OPENING, &portp->state)); 1242 !test_bit(ST_OPENING, &portp->state));
1295 if (signal_pending(current)) 1243 if (signal_pending(current))
1296 rc = -ERESTARTSYS; 1244 rc = -ERESTARTSYS;
1297 restore_flags(flags);
1298 1245
1299 if ((rc == 0) && (portp->rc != 0)) 1246 if ((rc == 0) && (portp->rc != 0))
1300 rc = -EIO; 1247 rc = -EIO;
1301 return(rc); 1248 return rc;
1302} 1249}
1303 1250
1304/*****************************************************************************/ 1251/*****************************************************************************/
@@ -1311,19 +1258,11 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1311 1258
1312static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1259static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1313{ 1260{
1314 volatile cdkhdr_t *hdrp; 1261 cdkhdr_t __iomem *hdrp;
1315 volatile cdkctrl_t *cp; 1262 cdkctrl_t __iomem *cp;
1316 volatile unsigned char *bits; 1263 unsigned char __iomem *bits;
1317 unsigned long flags; 1264 unsigned long flags;
1318 int rc; 1265 int rc;
1319
1320#ifdef DEBUG
1321 printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1322 (int) brdp, (int) portp, (int) arg, wait);
1323#endif
1324
1325 save_flags(flags);
1326 cli();
1327 1266
1328/* 1267/*
1329 * Slave is already closing this port. This can happen if a hangup 1268 * Slave is already closing this port. This can happen if a hangup
@@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1333 wait_event_interruptible(portp->raw_wait, 1272 wait_event_interruptible(portp->raw_wait,
1334 !test_bit(ST_CLOSING, &portp->state)); 1273 !test_bit(ST_CLOSING, &portp->state));
1335 if (signal_pending(current)) { 1274 if (signal_pending(current)) {
1336 restore_flags(flags);
1337 return -ERESTARTSYS; 1275 return -ERESTARTSYS;
1338 } 1276 }
1339 } 1277 }
@@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1341/* 1279/*
1342 * Write the close command into shared memory. 1280 * Write the close command into shared memory.
1343 */ 1281 */
1282 spin_lock_irqsave(&brd_lock, flags);
1344 EBRDENABLE(brdp); 1283 EBRDENABLE(brdp);
1345 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1284 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1346 cp->closearg = arg; 1285 writel(arg, &cp->closearg);
1347 cp->close = 1; 1286 writeb(1, &cp->close);
1348 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1287 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1349 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1288 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1350 portp->portidx; 1289 portp->portidx;
1351 *bits |= portp->portbit; 1290 writeb(readb(bits) |portp->portbit, bits);
1352 EBRDDISABLE(brdp); 1291 EBRDDISABLE(brdp);
1353 1292
1354 set_bit(ST_CLOSING, &portp->state); 1293 set_bit(ST_CLOSING, &portp->state);
1355 if (wait == 0) { 1294 spin_unlock_irqrestore(&brd_lock, flags);
1356 restore_flags(flags); 1295
1357 return(0); 1296 if (wait == 0)
1358 } 1297 return 0;
1359 1298
1360/* 1299/*
1361 * Slave is in action, so now we must wait for the open acknowledgment 1300 * Slave is in action, so now we must wait for the open acknowledgment
@@ -1366,11 +1305,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1366 !test_bit(ST_CLOSING, &portp->state)); 1305 !test_bit(ST_CLOSING, &portp->state));
1367 if (signal_pending(current)) 1306 if (signal_pending(current))
1368 rc = -ERESTARTSYS; 1307 rc = -ERESTARTSYS;
1369 restore_flags(flags);
1370 1308
1371 if ((rc == 0) && (portp->rc != 0)) 1309 if ((rc == 0) && (portp->rc != 0))
1372 rc = -EIO; 1310 rc = -EIO;
1373 return(rc); 1311 return rc;
1374} 1312}
1375 1313
1376/*****************************************************************************/ 1314/*****************************************************************************/
@@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1384 1322
1385static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 1323static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
1386{ 1324{
1387 unsigned long flags;
1388
1389#ifdef DEBUG
1390 printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
1391 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
1392 (int) arg, size, copyback);
1393#endif
1394
1395 save_flags(flags);
1396 cli();
1397 wait_event_interruptible(portp->raw_wait, 1325 wait_event_interruptible(portp->raw_wait,
1398 !test_bit(ST_CMDING, &portp->state)); 1326 !test_bit(ST_CMDING, &portp->state));
1399 if (signal_pending(current)) { 1327 if (signal_pending(current))
1400 restore_flags(flags);
1401 return -ERESTARTSYS; 1328 return -ERESTARTSYS;
1402 }
1403 1329
1404 stli_sendcmd(brdp, portp, cmd, arg, size, copyback); 1330 stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
1405 1331
1406 wait_event_interruptible(portp->raw_wait, 1332 wait_event_interruptible(portp->raw_wait,
1407 !test_bit(ST_CMDING, &portp->state)); 1333 !test_bit(ST_CMDING, &portp->state));
1408 if (signal_pending(current)) { 1334 if (signal_pending(current))
1409 restore_flags(flags);
1410 return -ERESTARTSYS; 1335 return -ERESTARTSYS;
1411 }
1412 restore_flags(flags);
1413 1336
1414 if (portp->rc != 0) 1337 if (portp->rc != 0)
1415 return(-EIO); 1338 return -EIO;
1416 return(0); 1339 return 0;
1417} 1340}
1418 1341
1419/*****************************************************************************/ 1342/*****************************************************************************/
@@ -1425,22 +1348,18 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
1425 1348
1426static int stli_setport(stliport_t *portp) 1349static int stli_setport(stliport_t *portp)
1427{ 1350{
1428 stlibrd_t *brdp; 1351 stlibrd_t *brdp;
1429 asyport_t aport; 1352 asyport_t aport;
1430
1431#ifdef DEBUG
1432 printk("stli_setport(portp=%x)\n", (int) portp);
1433#endif
1434 1353
1435 if (portp == (stliport_t *) NULL) 1354 if (portp == NULL)
1436 return(-ENODEV); 1355 return -ENODEV;
1437 if (portp->tty == (struct tty_struct *) NULL) 1356 if (portp->tty == NULL)
1438 return(-ENODEV); 1357 return -ENODEV;
1439 if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds)) 1358 if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
1440 return(-ENODEV); 1359 return -ENODEV;
1441 brdp = stli_brds[portp->brdnr]; 1360 brdp = stli_brds[portp->brdnr];
1442 if (brdp == (stlibrd_t *) NULL) 1361 if (brdp == NULL)
1443 return(-ENODEV); 1362 return -ENODEV;
1444 1363
1445 stli_mkasyport(portp, &aport, portp->tty->termios); 1364 stli_mkasyport(portp, &aport, portp->tty->termios);
1446 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); 1365 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
@@ -1455,13 +1374,8 @@ static int stli_setport(stliport_t *portp)
1455 1374
1456static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) 1375static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp)
1457{ 1376{
1458 unsigned long flags; 1377 unsigned long flags;
1459 int rc, doclocal; 1378 int rc, doclocal;
1460
1461#ifdef DEBUG
1462 printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
1463 (int) brdp, (int) portp, (int) filp);
1464#endif
1465 1379
1466 rc = 0; 1380 rc = 0;
1467 doclocal = 0; 1381 doclocal = 0;
@@ -1469,11 +1383,11 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1469 if (portp->tty->termios->c_cflag & CLOCAL) 1383 if (portp->tty->termios->c_cflag & CLOCAL)
1470 doclocal++; 1384 doclocal++;
1471 1385
1472 save_flags(flags); 1386 spin_lock_irqsave(&stli_lock, flags);
1473 cli();
1474 portp->openwaitcnt++; 1387 portp->openwaitcnt++;
1475 if (! tty_hung_up_p(filp)) 1388 if (! tty_hung_up_p(filp))
1476 portp->refcount--; 1389 portp->refcount--;
1390 spin_unlock_irqrestore(&stli_lock, flags);
1477 1391
1478 for (;;) { 1392 for (;;) {
1479 stli_mkasysigs(&portp->asig, 1, 1); 1393 stli_mkasysigs(&portp->asig, 1, 1);
@@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1499 interruptible_sleep_on(&portp->open_wait); 1413 interruptible_sleep_on(&portp->open_wait);
1500 } 1414 }
1501 1415
1416 spin_lock_irqsave(&stli_lock, flags);
1502 if (! tty_hung_up_p(filp)) 1417 if (! tty_hung_up_p(filp))
1503 portp->refcount++; 1418 portp->refcount++;
1504 portp->openwaitcnt--; 1419 portp->openwaitcnt--;
1505 restore_flags(flags); 1420 spin_unlock_irqrestore(&stli_lock, flags);
1506 1421
1507 return(rc); 1422 return rc;
1508} 1423}
1509 1424
1510/*****************************************************************************/ 1425/*****************************************************************************/
@@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1517 1432
1518static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) 1433static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
1519{ 1434{
1520 volatile cdkasy_t *ap; 1435 cdkasy_t __iomem *ap;
1521 volatile cdkhdr_t *hdrp; 1436 cdkhdr_t __iomem *hdrp;
1522 volatile unsigned char *bits; 1437 unsigned char __iomem *bits;
1523 unsigned char *shbuf, *chbuf; 1438 unsigned char __iomem *shbuf;
1524 stliport_t *portp; 1439 unsigned char *chbuf;
1525 stlibrd_t *brdp; 1440 stliport_t *portp;
1526 unsigned int len, stlen, head, tail, size; 1441 stlibrd_t *brdp;
1527 unsigned long flags; 1442 unsigned int len, stlen, head, tail, size;
1528 1443 unsigned long flags;
1529#ifdef DEBUG
1530 printk("stli_write(tty=%x,buf=%x,count=%d)\n",
1531 (int) tty, (int) buf, count);
1532#endif
1533 1444
1534 if ((tty == (struct tty_struct *) NULL) ||
1535 (stli_tmpwritebuf == (char *) NULL))
1536 return(0);
1537 if (tty == stli_txcooktty) 1445 if (tty == stli_txcooktty)
1538 stli_flushchars(tty); 1446 stli_flushchars(tty);
1539 portp = tty->driver_data; 1447 portp = tty->driver_data;
1540 if (portp == (stliport_t *) NULL) 1448 if (portp == NULL)
1541 return(0); 1449 return 0;
1542 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1450 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1543 return(0); 1451 return 0;
1544 brdp = stli_brds[portp->brdnr]; 1452 brdp = stli_brds[portp->brdnr];
1545 if (brdp == (stlibrd_t *) NULL) 1453 if (brdp == NULL)
1546 return(0); 1454 return 0;
1547 chbuf = (unsigned char *) buf; 1455 chbuf = (unsigned char *) buf;
1548 1456
1549/* 1457/*
1550 * All data is now local, shove as much as possible into shared memory. 1458 * All data is now local, shove as much as possible into shared memory.
1551 */ 1459 */
1552 save_flags(flags); 1460 spin_lock_irqsave(&brd_lock, flags);
1553 cli();
1554 EBRDENABLE(brdp); 1461 EBRDENABLE(brdp);
1555 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1462 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1556 head = (unsigned int) ap->txq.head; 1463 head = (unsigned int) readw(&ap->txq.head);
1557 tail = (unsigned int) ap->txq.tail; 1464 tail = (unsigned int) readw(&ap->txq.tail);
1558 if (tail != ((unsigned int) ap->txq.tail)) 1465 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1559 tail = (unsigned int) ap->txq.tail; 1466 tail = (unsigned int) readw(&ap->txq.tail);
1560 size = portp->txsize; 1467 size = portp->txsize;
1561 if (head >= tail) { 1468 if (head >= tail) {
1562 len = size - (head - tail) - 1; 1469 len = size - (head - tail) - 1;
@@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1568 1475
1569 len = MIN(len, count); 1476 len = MIN(len, count);
1570 count = 0; 1477 count = 0;
1571 shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); 1478 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
1572 1479
1573 while (len > 0) { 1480 while (len > 0) {
1574 stlen = MIN(len, stlen); 1481 stlen = MIN(len, stlen);
1575 memcpy((shbuf + head), chbuf, stlen); 1482 memcpy_toio(shbuf + head, chbuf, stlen);
1576 chbuf += stlen; 1483 chbuf += stlen;
1577 len -= stlen; 1484 len -= stlen;
1578 count += stlen; 1485 count += stlen;
@@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1583 } 1490 }
1584 } 1491 }
1585 1492
1586 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1493 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1587 ap->txq.head = head; 1494 writew(head, &ap->txq.head);
1588 if (test_bit(ST_TXBUSY, &portp->state)) { 1495 if (test_bit(ST_TXBUSY, &portp->state)) {
1589 if (ap->changed.data & DT_TXEMPTY) 1496 if (readl(&ap->changed.data) & DT_TXEMPTY)
1590 ap->changed.data &= ~DT_TXEMPTY; 1497 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1591 } 1498 }
1592 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1499 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1593 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1500 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1594 portp->portidx; 1501 portp->portidx;
1595 *bits |= portp->portbit; 1502 writeb(readb(bits) | portp->portbit, bits);
1596 set_bit(ST_TXBUSY, &portp->state); 1503 set_bit(ST_TXBUSY, &portp->state);
1597 EBRDDISABLE(brdp); 1504 EBRDDISABLE(brdp);
1598 1505 spin_unlock_irqrestore(&brd_lock, flags);
1599 restore_flags(flags);
1600 1506
1601 return(count); 1507 return(count);
1602} 1508}
@@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1613 1519
1614static void stli_putchar(struct tty_struct *tty, unsigned char ch) 1520static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1615{ 1521{
1616#ifdef DEBUG
1617 printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
1618#endif
1619
1620 if (tty == (struct tty_struct *) NULL)
1621 return;
1622 if (tty != stli_txcooktty) { 1522 if (tty != stli_txcooktty) {
1623 if (stli_txcooktty != (struct tty_struct *) NULL) 1523 if (stli_txcooktty != NULL)
1624 stli_flushchars(stli_txcooktty); 1524 stli_flushchars(stli_txcooktty);
1625 stli_txcooktty = tty; 1525 stli_txcooktty = tty;
1626 } 1526 }
@@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1640 1540
1641static void stli_flushchars(struct tty_struct *tty) 1541static void stli_flushchars(struct tty_struct *tty)
1642{ 1542{
1643 volatile cdkhdr_t *hdrp; 1543 cdkhdr_t __iomem *hdrp;
1644 volatile unsigned char *bits; 1544 unsigned char __iomem *bits;
1645 volatile cdkasy_t *ap; 1545 cdkasy_t __iomem *ap;
1646 struct tty_struct *cooktty; 1546 struct tty_struct *cooktty;
1647 stliport_t *portp; 1547 stliport_t *portp;
1648 stlibrd_t *brdp; 1548 stlibrd_t *brdp;
1649 unsigned int len, stlen, head, tail, size, count, cooksize; 1549 unsigned int len, stlen, head, tail, size, count, cooksize;
1650 unsigned char *buf, *shbuf; 1550 unsigned char *buf;
1651 unsigned long flags; 1551 unsigned char __iomem *shbuf;
1652 1552 unsigned long flags;
1653#ifdef DEBUG
1654 printk("stli_flushchars(tty=%x)\n", (int) tty);
1655#endif
1656 1553
1657 cooksize = stli_txcooksize; 1554 cooksize = stli_txcooksize;
1658 cooktty = stli_txcooktty; 1555 cooktty = stli_txcooktty;
1659 stli_txcooksize = 0; 1556 stli_txcooksize = 0;
1660 stli_txcookrealsize = 0; 1557 stli_txcookrealsize = 0;
1661 stli_txcooktty = (struct tty_struct *) NULL; 1558 stli_txcooktty = NULL;
1662 1559
1663 if (tty == (struct tty_struct *) NULL) 1560 if (tty == NULL)
1664 return; 1561 return;
1665 if (cooktty == (struct tty_struct *) NULL) 1562 if (cooktty == NULL)
1666 return; 1563 return;
1667 if (tty != cooktty) 1564 if (tty != cooktty)
1668 tty = cooktty; 1565 tty = cooktty;
@@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty)
1670 return; 1567 return;
1671 1568
1672 portp = tty->driver_data; 1569 portp = tty->driver_data;
1673 if (portp == (stliport_t *) NULL) 1570 if (portp == NULL)
1674 return; 1571 return;
1675 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1572 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1676 return; 1573 return;
1677 brdp = stli_brds[portp->brdnr]; 1574 brdp = stli_brds[portp->brdnr];
1678 if (brdp == (stlibrd_t *) NULL) 1575 if (brdp == NULL)
1679 return; 1576 return;
1680 1577
1681 save_flags(flags); 1578 spin_lock_irqsave(&brd_lock, flags);
1682 cli();
1683 EBRDENABLE(brdp); 1579 EBRDENABLE(brdp);
1684 1580
1685 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1581 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1686 head = (unsigned int) ap->txq.head; 1582 head = (unsigned int) readw(&ap->txq.head);
1687 tail = (unsigned int) ap->txq.tail; 1583 tail = (unsigned int) readw(&ap->txq.tail);
1688 if (tail != ((unsigned int) ap->txq.tail)) 1584 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1689 tail = (unsigned int) ap->txq.tail; 1585 tail = (unsigned int) readw(&ap->txq.tail);
1690 size = portp->txsize; 1586 size = portp->txsize;
1691 if (head >= tail) { 1587 if (head >= tail) {
1692 len = size - (head - tail) - 1; 1588 len = size - (head - tail) - 1;
@@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty)
1703 1599
1704 while (len > 0) { 1600 while (len > 0) {
1705 stlen = MIN(len, stlen); 1601 stlen = MIN(len, stlen);
1706 memcpy((shbuf + head), buf, stlen); 1602 memcpy_toio(shbuf + head, buf, stlen);
1707 buf += stlen; 1603 buf += stlen;
1708 len -= stlen; 1604 len -= stlen;
1709 count += stlen; 1605 count += stlen;
@@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty)
1714 } 1610 }
1715 } 1611 }
1716 1612
1717 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1613 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1718 ap->txq.head = head; 1614 writew(head, &ap->txq.head);
1719 1615
1720 if (test_bit(ST_TXBUSY, &portp->state)) { 1616 if (test_bit(ST_TXBUSY, &portp->state)) {
1721 if (ap->changed.data & DT_TXEMPTY) 1617 if (readl(&ap->changed.data) & DT_TXEMPTY)
1722 ap->changed.data &= ~DT_TXEMPTY; 1618 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1723 } 1619 }
1724 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1620 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1725 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1621 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1726 portp->portidx; 1622 portp->portidx;
1727 *bits |= portp->portbit; 1623 writeb(readb(bits) | portp->portbit, bits);
1728 set_bit(ST_TXBUSY, &portp->state); 1624 set_bit(ST_TXBUSY, &portp->state);
1729 1625
1730 EBRDDISABLE(brdp); 1626 EBRDDISABLE(brdp);
1731 restore_flags(flags); 1627 spin_unlock_irqrestore(&brd_lock, flags);
1732} 1628}
1733 1629
1734/*****************************************************************************/ 1630/*****************************************************************************/
1735 1631
1736static int stli_writeroom(struct tty_struct *tty) 1632static int stli_writeroom(struct tty_struct *tty)
1737{ 1633{
1738 volatile cdkasyrq_t *rp; 1634 cdkasyrq_t __iomem *rp;
1739 stliport_t *portp; 1635 stliport_t *portp;
1740 stlibrd_t *brdp; 1636 stlibrd_t *brdp;
1741 unsigned int head, tail, len; 1637 unsigned int head, tail, len;
1742 unsigned long flags; 1638 unsigned long flags;
1743
1744#ifdef DEBUG
1745 printk("stli_writeroom(tty=%x)\n", (int) tty);
1746#endif
1747 1639
1748 if (tty == (struct tty_struct *) NULL)
1749 return(0);
1750 if (tty == stli_txcooktty) { 1640 if (tty == stli_txcooktty) {
1751 if (stli_txcookrealsize != 0) { 1641 if (stli_txcookrealsize != 0) {
1752 len = stli_txcookrealsize - stli_txcooksize; 1642 len = stli_txcookrealsize - stli_txcooksize;
1753 return(len); 1643 return len;
1754 } 1644 }
1755 } 1645 }
1756 1646
1757 portp = tty->driver_data; 1647 portp = tty->driver_data;
1758 if (portp == (stliport_t *) NULL) 1648 if (portp == NULL)
1759 return(0); 1649 return 0;
1760 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1650 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1761 return(0); 1651 return 0;
1762 brdp = stli_brds[portp->brdnr]; 1652 brdp = stli_brds[portp->brdnr];
1763 if (brdp == (stlibrd_t *) NULL) 1653 if (brdp == NULL)
1764 return(0); 1654 return 0;
1765 1655
1766 save_flags(flags); 1656 spin_lock_irqsave(&brd_lock, flags);
1767 cli();
1768 EBRDENABLE(brdp); 1657 EBRDENABLE(brdp);
1769 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1658 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1770 head = (unsigned int) rp->head; 1659 head = (unsigned int) readw(&rp->head);
1771 tail = (unsigned int) rp->tail; 1660 tail = (unsigned int) readw(&rp->tail);
1772 if (tail != ((unsigned int) rp->tail)) 1661 if (tail != ((unsigned int) readw(&rp->tail)))
1773 tail = (unsigned int) rp->tail; 1662 tail = (unsigned int) readw(&rp->tail);
1774 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); 1663 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
1775 len--; 1664 len--;
1776 EBRDDISABLE(brdp); 1665 EBRDDISABLE(brdp);
1777 restore_flags(flags); 1666 spin_unlock_irqrestore(&brd_lock, flags);
1778 1667
1779 if (tty == stli_txcooktty) { 1668 if (tty == stli_txcooktty) {
1780 stli_txcookrealsize = len; 1669 stli_txcookrealsize = len;
1781 len -= stli_txcooksize; 1670 len -= stli_txcooksize;
1782 } 1671 }
1783 return(len); 1672 return len;
1784} 1673}
1785 1674
1786/*****************************************************************************/ 1675/*****************************************************************************/
@@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty)
1795 1684
1796static int stli_charsinbuffer(struct tty_struct *tty) 1685static int stli_charsinbuffer(struct tty_struct *tty)
1797{ 1686{
1798 volatile cdkasyrq_t *rp; 1687 cdkasyrq_t __iomem *rp;
1799 stliport_t *portp; 1688 stliport_t *portp;
1800 stlibrd_t *brdp; 1689 stlibrd_t *brdp;
1801 unsigned int head, tail, len; 1690 unsigned int head, tail, len;
1802 unsigned long flags; 1691 unsigned long flags;
1803
1804#ifdef DEBUG
1805 printk("stli_charsinbuffer(tty=%x)\n", (int) tty);
1806#endif
1807 1692
1808 if (tty == (struct tty_struct *) NULL)
1809 return(0);
1810 if (tty == stli_txcooktty) 1693 if (tty == stli_txcooktty)
1811 stli_flushchars(tty); 1694 stli_flushchars(tty);
1812 portp = tty->driver_data; 1695 portp = tty->driver_data;
1813 if (portp == (stliport_t *) NULL) 1696 if (portp == NULL)
1814 return(0); 1697 return 0;
1815 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1698 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1816 return(0); 1699 return 0;
1817 brdp = stli_brds[portp->brdnr]; 1700 brdp = stli_brds[portp->brdnr];
1818 if (brdp == (stlibrd_t *) NULL) 1701 if (brdp == NULL)
1819 return(0); 1702 return 0;
1820 1703
1821 save_flags(flags); 1704 spin_lock_irqsave(&brd_lock, flags);
1822 cli();
1823 EBRDENABLE(brdp); 1705 EBRDENABLE(brdp);
1824 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1706 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1825 head = (unsigned int) rp->head; 1707 head = (unsigned int) readw(&rp->head);
1826 tail = (unsigned int) rp->tail; 1708 tail = (unsigned int) readw(&rp->tail);
1827 if (tail != ((unsigned int) rp->tail)) 1709 if (tail != ((unsigned int) readw(&rp->tail)))
1828 tail = (unsigned int) rp->tail; 1710 tail = (unsigned int) readw(&rp->tail);
1829 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); 1711 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head));
1830 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) 1712 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
1831 len = 1; 1713 len = 1;
1832 EBRDDISABLE(brdp); 1714 EBRDDISABLE(brdp);
1833 restore_flags(flags); 1715 spin_unlock_irqrestore(&brd_lock, flags);
1834 1716
1835 return(len); 1717 return len;
1836} 1718}
1837 1719
1838/*****************************************************************************/ 1720/*****************************************************************************/
@@ -1843,12 +1725,8 @@ static int stli_charsinbuffer(struct tty_struct *tty)
1843 1725
1844static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) 1726static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1845{ 1727{
1846 struct serial_struct sio; 1728 struct serial_struct sio;
1847 stlibrd_t *brdp; 1729 stlibrd_t *brdp;
1848
1849#ifdef DEBUG
1850 printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
1851#endif
1852 1730
1853 memset(&sio, 0, sizeof(struct serial_struct)); 1731 memset(&sio, 0, sizeof(struct serial_struct));
1854 sio.type = PORT_UNKNOWN; 1732 sio.type = PORT_UNKNOWN;
@@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1863 sio.hub6 = 0; 1741 sio.hub6 = 0;
1864 1742
1865 brdp = stli_brds[portp->brdnr]; 1743 brdp = stli_brds[portp->brdnr];
1866 if (brdp != (stlibrd_t *) NULL) 1744 if (brdp != NULL)
1867 sio.port = brdp->iobase; 1745 sio.port = brdp->iobase;
1868 1746
1869 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? 1747 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
@@ -1880,12 +1758,8 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1880 1758
1881static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) 1759static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1882{ 1760{
1883 struct serial_struct sio; 1761 struct serial_struct sio;
1884 int rc; 1762 int rc;
1885
1886#ifdef DEBUG
1887 printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp);
1888#endif
1889 1763
1890 if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) 1764 if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
1891 return -EFAULT; 1765 return -EFAULT;
@@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1894 (sio.close_delay != portp->close_delay) || 1768 (sio.close_delay != portp->close_delay) ||
1895 ((sio.flags & ~ASYNC_USR_MASK) != 1769 ((sio.flags & ~ASYNC_USR_MASK) !=
1896 (portp->flags & ~ASYNC_USR_MASK))) 1770 (portp->flags & ~ASYNC_USR_MASK)))
1897 return(-EPERM); 1771 return -EPERM;
1898 } 1772 }
1899 1773
1900 portp->flags = (portp->flags & ~ASYNC_USR_MASK) | 1774 portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
@@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1905 portp->custom_divisor = sio.custom_divisor; 1779 portp->custom_divisor = sio.custom_divisor;
1906 1780
1907 if ((rc = stli_setport(portp)) < 0) 1781 if ((rc = stli_setport(portp)) < 0)
1908 return(rc); 1782 return rc;
1909 return(0); 1783 return 0;
1910} 1784}
1911 1785
1912/*****************************************************************************/ 1786/*****************************************************************************/
@@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
1917 stlibrd_t *brdp; 1791 stlibrd_t *brdp;
1918 int rc; 1792 int rc;
1919 1793
1920 if (portp == (stliport_t *) NULL) 1794 if (portp == NULL)
1921 return(-ENODEV); 1795 return -ENODEV;
1922 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1796 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1923 return(0); 1797 return 0;
1924 brdp = stli_brds[portp->brdnr]; 1798 brdp = stli_brds[portp->brdnr];
1925 if (brdp == (stlibrd_t *) NULL) 1799 if (brdp == NULL)
1926 return(0); 1800 return 0;
1927 if (tty->flags & (1 << TTY_IO_ERROR)) 1801 if (tty->flags & (1 << TTY_IO_ERROR))
1928 return(-EIO); 1802 return -EIO;
1929 1803
1930 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, 1804 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS,
1931 &portp->asig, sizeof(asysigs_t), 1)) < 0) 1805 &portp->asig, sizeof(asysigs_t), 1)) < 0)
1932 return(rc); 1806 return rc;
1933 1807
1934 return stli_mktiocm(portp->asig.sigvalue); 1808 return stli_mktiocm(portp->asig.sigvalue);
1935} 1809}
@@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1941 stlibrd_t *brdp; 1815 stlibrd_t *brdp;
1942 int rts = -1, dtr = -1; 1816 int rts = -1, dtr = -1;
1943 1817
1944 if (portp == (stliport_t *) NULL) 1818 if (portp == NULL)
1945 return(-ENODEV); 1819 return -ENODEV;
1946 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1820 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1947 return(0); 1821 return 0;
1948 brdp = stli_brds[portp->brdnr]; 1822 brdp = stli_brds[portp->brdnr];
1949 if (brdp == (stlibrd_t *) NULL) 1823 if (brdp == NULL)
1950 return(0); 1824 return 0;
1951 if (tty->flags & (1 << TTY_IO_ERROR)) 1825 if (tty->flags & (1 << TTY_IO_ERROR))
1952 return(-EIO); 1826 return -EIO;
1953 1827
1954 if (set & TIOCM_RTS) 1828 if (set & TIOCM_RTS)
1955 rts = 1; 1829 rts = 1;
@@ -1968,32 +1842,25 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1968 1842
1969static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1843static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1970{ 1844{
1971 stliport_t *portp; 1845 stliport_t *portp;
1972 stlibrd_t *brdp; 1846 stlibrd_t *brdp;
1973 unsigned int ival; 1847 unsigned int ival;
1974 int rc; 1848 int rc;
1975 void __user *argp = (void __user *)arg; 1849 void __user *argp = (void __user *)arg;
1976 1850
1977#ifdef DEBUG
1978 printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
1979 (int) tty, (int) file, cmd, (int) arg);
1980#endif
1981
1982 if (tty == (struct tty_struct *) NULL)
1983 return(-ENODEV);
1984 portp = tty->driver_data; 1851 portp = tty->driver_data;
1985 if (portp == (stliport_t *) NULL) 1852 if (portp == NULL)
1986 return(-ENODEV); 1853 return -ENODEV;
1987 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1854 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1988 return(0); 1855 return 0;
1989 brdp = stli_brds[portp->brdnr]; 1856 brdp = stli_brds[portp->brdnr];
1990 if (brdp == (stlibrd_t *) NULL) 1857 if (brdp == NULL)
1991 return(0); 1858 return 0;
1992 1859
1993 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1860 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1994 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { 1861 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
1995 if (tty->flags & (1 << TTY_IO_ERROR)) 1862 if (tty->flags & (1 << TTY_IO_ERROR))
1996 return(-EIO); 1863 return -EIO;
1997 } 1864 }
1998 1865
1999 rc = 0; 1866 rc = 0;
@@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2040 break; 1907 break;
2041 } 1908 }
2042 1909
2043 return(rc); 1910 return rc;
2044} 1911}
2045 1912
2046/*****************************************************************************/ 1913/*****************************************************************************/
@@ -2052,24 +1919,20 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2052 1919
2053static void stli_settermios(struct tty_struct *tty, struct termios *old) 1920static void stli_settermios(struct tty_struct *tty, struct termios *old)
2054{ 1921{
2055 stliport_t *portp; 1922 stliport_t *portp;
2056 stlibrd_t *brdp; 1923 stlibrd_t *brdp;
2057 struct termios *tiosp; 1924 struct termios *tiosp;
2058 asyport_t aport; 1925 asyport_t aport;
2059
2060#ifdef DEBUG
2061 printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
2062#endif
2063 1926
2064 if (tty == (struct tty_struct *) NULL) 1927 if (tty == NULL)
2065 return; 1928 return;
2066 portp = tty->driver_data; 1929 portp = tty->driver_data;
2067 if (portp == (stliport_t *) NULL) 1930 if (portp == NULL)
2068 return; 1931 return;
2069 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1932 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2070 return; 1933 return;
2071 brdp = stli_brds[portp->brdnr]; 1934 brdp = stli_brds[portp->brdnr];
2072 if (brdp == (stlibrd_t *) NULL) 1935 if (brdp == NULL)
2073 return; 1936 return;
2074 1937
2075 tiosp = tty->termios; 1938 tiosp = tty->termios;
@@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
2102 1965
2103static void stli_throttle(struct tty_struct *tty) 1966static void stli_throttle(struct tty_struct *tty)
2104{ 1967{
2105 stliport_t *portp; 1968 stliport_t *portp = tty->driver_data;
2106 1969 if (portp == NULL)
2107#ifdef DEBUG
2108 printk("stli_throttle(tty=%x)\n", (int) tty);
2109#endif
2110
2111 if (tty == (struct tty_struct *) NULL)
2112 return; 1970 return;
2113 portp = tty->driver_data;
2114 if (portp == (stliport_t *) NULL)
2115 return;
2116
2117 set_bit(ST_RXSTOP, &portp->state); 1971 set_bit(ST_RXSTOP, &portp->state);
2118} 1972}
2119 1973
@@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty)
2127 1981
2128static void stli_unthrottle(struct tty_struct *tty) 1982static void stli_unthrottle(struct tty_struct *tty)
2129{ 1983{
2130 stliport_t *portp; 1984 stliport_t *portp = tty->driver_data;
2131 1985 if (portp == NULL)
2132#ifdef DEBUG
2133 printk("stli_unthrottle(tty=%x)\n", (int) tty);
2134#endif
2135
2136 if (tty == (struct tty_struct *) NULL)
2137 return;
2138 portp = tty->driver_data;
2139 if (portp == (stliport_t *) NULL)
2140 return; 1986 return;
2141
2142 clear_bit(ST_RXSTOP, &portp->state); 1987 clear_bit(ST_RXSTOP, &portp->state);
2143} 1988}
2144 1989
2145/*****************************************************************************/ 1990/*****************************************************************************/
2146 1991
2147/* 1992/*
2148 * Stop the transmitter. Basically to do this we will just turn TX 1993 * Stop the transmitter.
2149 * interrupts off.
2150 */ 1994 */
2151 1995
2152static void stli_stop(struct tty_struct *tty) 1996static void stli_stop(struct tty_struct *tty)
2153{ 1997{
2154 stlibrd_t *brdp;
2155 stliport_t *portp;
2156 asyctrl_t actrl;
2157
2158#ifdef DEBUG
2159 printk("stli_stop(tty=%x)\n", (int) tty);
2160#endif
2161
2162 if (tty == (struct tty_struct *) NULL)
2163 return;
2164 portp = tty->driver_data;
2165 if (portp == (stliport_t *) NULL)
2166 return;
2167 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2168 return;
2169 brdp = stli_brds[portp->brdnr];
2170 if (brdp == (stlibrd_t *) NULL)
2171 return;
2172
2173 memset(&actrl, 0, sizeof(asyctrl_t));
2174 actrl.txctrl = CT_STOPFLOW;
2175#if 0
2176 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2177#endif
2178} 1998}
2179 1999
2180/*****************************************************************************/ 2000/*****************************************************************************/
2181 2001
2182/* 2002/*
2183 * Start the transmitter again. Just turn TX interrupts back on. 2003 * Start the transmitter again.
2184 */ 2004 */
2185 2005
2186static void stli_start(struct tty_struct *tty) 2006static void stli_start(struct tty_struct *tty)
2187{ 2007{
2188 stliport_t *portp;
2189 stlibrd_t *brdp;
2190 asyctrl_t actrl;
2191
2192#ifdef DEBUG
2193 printk("stli_start(tty=%x)\n", (int) tty);
2194#endif
2195
2196 if (tty == (struct tty_struct *) NULL)
2197 return;
2198 portp = tty->driver_data;
2199 if (portp == (stliport_t *) NULL)
2200 return;
2201 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2202 return;
2203 brdp = stli_brds[portp->brdnr];
2204 if (brdp == (stlibrd_t *) NULL)
2205 return;
2206
2207 memset(&actrl, 0, sizeof(asyctrl_t));
2208 actrl.txctrl = CT_STARTFLOW;
2209#if 0
2210 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2211#endif
2212} 2008}
2213 2009
2214/*****************************************************************************/ 2010/*****************************************************************************/
@@ -2224,22 +2020,9 @@ static void stli_start(struct tty_struct *tty)
2224 2020
2225static void stli_dohangup(void *arg) 2021static void stli_dohangup(void *arg)
2226{ 2022{
2227 stliport_t *portp; 2023 stliport_t *portp = (stliport_t *) arg;
2228 2024 if (portp->tty != NULL) {
2229#ifdef DEBUG 2025 tty_hangup(portp->tty);
2230 printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg);
2231#endif
2232
2233 /*
2234 * FIXME: There's a module removal race here: tty_hangup
2235 * calls schedule_work which will call into this
2236 * driver later.
2237 */
2238 portp = (stliport_t *) arg;
2239 if (portp != (stliport_t *) NULL) {
2240 if (portp->tty != (struct tty_struct *) NULL) {
2241 tty_hangup(portp->tty);
2242 }
2243 } 2026 }
2244} 2027}
2245 2028
@@ -2254,31 +2037,25 @@ static void stli_dohangup(void *arg)
2254 2037
2255static void stli_hangup(struct tty_struct *tty) 2038static void stli_hangup(struct tty_struct *tty)
2256{ 2039{
2257 stliport_t *portp; 2040 stliport_t *portp;
2258 stlibrd_t *brdp; 2041 stlibrd_t *brdp;
2259 unsigned long flags; 2042 unsigned long flags;
2260
2261#ifdef DEBUG
2262 printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty);
2263#endif
2264 2043
2265 if (tty == (struct tty_struct *) NULL)
2266 return;
2267 portp = tty->driver_data; 2044 portp = tty->driver_data;
2268 if (portp == (stliport_t *) NULL) 2045 if (portp == NULL)
2269 return; 2046 return;
2270 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2047 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2271 return; 2048 return;
2272 brdp = stli_brds[portp->brdnr]; 2049 brdp = stli_brds[portp->brdnr];
2273 if (brdp == (stlibrd_t *) NULL) 2050 if (brdp == NULL)
2274 return; 2051 return;
2275 2052
2276 portp->flags &= ~ASYNC_INITIALIZED; 2053 portp->flags &= ~ASYNC_INITIALIZED;
2277 2054
2278 save_flags(flags); 2055 if (!test_bit(ST_CLOSING, &portp->state))
2279 cli();
2280 if (! test_bit(ST_CLOSING, &portp->state))
2281 stli_rawclose(brdp, portp, 0, 0); 2056 stli_rawclose(brdp, portp, 0, 0);
2057
2058 spin_lock_irqsave(&stli_lock, flags);
2282 if (tty->termios->c_cflag & HUPCL) { 2059 if (tty->termios->c_cflag & HUPCL) {
2283 stli_mkasysigs(&portp->asig, 0, 0); 2060 stli_mkasysigs(&portp->asig, 0, 0);
2284 if (test_bit(ST_CMDING, &portp->state)) { 2061 if (test_bit(ST_CMDING, &portp->state)) {
@@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty)
2290 &portp->asig, sizeof(asysigs_t), 0); 2067 &portp->asig, sizeof(asysigs_t), 0);
2291 } 2068 }
2292 } 2069 }
2293 restore_flags(flags);
2294 2070
2295 clear_bit(ST_TXBUSY, &portp->state); 2071 clear_bit(ST_TXBUSY, &portp->state);
2296 clear_bit(ST_RXSTOP, &portp->state); 2072 clear_bit(ST_RXSTOP, &portp->state);
2297 set_bit(TTY_IO_ERROR, &tty->flags); 2073 set_bit(TTY_IO_ERROR, &tty->flags);
2298 portp->tty = (struct tty_struct *) NULL; 2074 portp->tty = NULL;
2299 portp->flags &= ~ASYNC_NORMAL_ACTIVE; 2075 portp->flags &= ~ASYNC_NORMAL_ACTIVE;
2300 portp->refcount = 0; 2076 portp->refcount = 0;
2077 spin_unlock_irqrestore(&stli_lock, flags);
2078
2301 wake_up_interruptible(&portp->open_wait); 2079 wake_up_interruptible(&portp->open_wait);
2302} 2080}
2303 2081
@@ -2312,29 +2090,22 @@ static void stli_hangup(struct tty_struct *tty)
2312 2090
2313static void stli_flushbuffer(struct tty_struct *tty) 2091static void stli_flushbuffer(struct tty_struct *tty)
2314{ 2092{
2315 stliport_t *portp; 2093 stliport_t *portp;
2316 stlibrd_t *brdp; 2094 stlibrd_t *brdp;
2317 unsigned long ftype, flags; 2095 unsigned long ftype, flags;
2318
2319#ifdef DEBUG
2320 printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty);
2321#endif
2322 2096
2323 if (tty == (struct tty_struct *) NULL)
2324 return;
2325 portp = tty->driver_data; 2097 portp = tty->driver_data;
2326 if (portp == (stliport_t *) NULL) 2098 if (portp == NULL)
2327 return; 2099 return;
2328 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2100 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2329 return; 2101 return;
2330 brdp = stli_brds[portp->brdnr]; 2102 brdp = stli_brds[portp->brdnr];
2331 if (brdp == (stlibrd_t *) NULL) 2103 if (brdp == NULL)
2332 return; 2104 return;
2333 2105
2334 save_flags(flags); 2106 spin_lock_irqsave(&brd_lock, flags);
2335 cli();
2336 if (tty == stli_txcooktty) { 2107 if (tty == stli_txcooktty) {
2337 stli_txcooktty = (struct tty_struct *) NULL; 2108 stli_txcooktty = NULL;
2338 stli_txcooksize = 0; 2109 stli_txcooksize = 0;
2339 stli_txcookrealsize = 0; 2110 stli_txcookrealsize = 0;
2340 } 2111 }
@@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty)
2346 ftype |= FLUSHRX; 2117 ftype |= FLUSHRX;
2347 clear_bit(ST_DOFLUSHRX, &portp->state); 2118 clear_bit(ST_DOFLUSHRX, &portp->state);
2348 } 2119 }
2349 stli_sendcmd(brdp, portp, A_FLUSH, &ftype, 2120 __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0);
2350 sizeof(unsigned long), 0);
2351 } 2121 }
2352 restore_flags(flags); 2122 spin_unlock_irqrestore(&brd_lock, flags);
2353 2123 tty_wakeup(tty);
2354 wake_up_interruptible(&tty->write_wait);
2355 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
2356 tty->ldisc.write_wakeup)
2357 (tty->ldisc.write_wakeup)(tty);
2358} 2124}
2359 2125
2360/*****************************************************************************/ 2126/*****************************************************************************/
@@ -2364,55 +2130,31 @@ static void stli_breakctl(struct tty_struct *tty, int state)
2364 stlibrd_t *brdp; 2130 stlibrd_t *brdp;
2365 stliport_t *portp; 2131 stliport_t *portp;
2366 long arg; 2132 long arg;
2367 /* long savestate, savetime; */
2368 2133
2369#ifdef DEBUG
2370 printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state);
2371#endif
2372
2373 if (tty == (struct tty_struct *) NULL)
2374 return;
2375 portp = tty->driver_data; 2134 portp = tty->driver_data;
2376 if (portp == (stliport_t *) NULL) 2135 if (portp == NULL)
2377 return; 2136 return;
2378 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2137 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2379 return; 2138 return;
2380 brdp = stli_brds[portp->brdnr]; 2139 brdp = stli_brds[portp->brdnr];
2381 if (brdp == (stlibrd_t *) NULL) 2140 if (brdp == NULL)
2382 return; 2141 return;
2383 2142
2384/*
2385 * Due to a bug in the tty send_break() code we need to preserve
2386 * the current process state and timeout...
2387 savetime = current->timeout;
2388 savestate = current->state;
2389 */
2390
2391 arg = (state == -1) ? BREAKON : BREAKOFF; 2143 arg = (state == -1) ? BREAKON : BREAKOFF;
2392 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); 2144 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
2393
2394/*
2395 *
2396 current->timeout = savetime;
2397 current->state = savestate;
2398 */
2399} 2145}
2400 2146
2401/*****************************************************************************/ 2147/*****************************************************************************/
2402 2148
2403static void stli_waituntilsent(struct tty_struct *tty, int timeout) 2149static void stli_waituntilsent(struct tty_struct *tty, int timeout)
2404{ 2150{
2405 stliport_t *portp; 2151 stliport_t *portp;
2406 unsigned long tend; 2152 unsigned long tend;
2407 2153
2408#ifdef DEBUG 2154 if (tty == NULL)
2409 printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout);
2410#endif
2411
2412 if (tty == (struct tty_struct *) NULL)
2413 return; 2155 return;
2414 portp = tty->driver_data; 2156 portp = tty->driver_data;
2415 if (portp == (stliport_t *) NULL) 2157 if (portp == NULL)
2416 return; 2158 return;
2417 2159
2418 if (timeout == 0) 2160 if (timeout == 0)
@@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2436 stliport_t *portp; 2178 stliport_t *portp;
2437 asyctrl_t actrl; 2179 asyctrl_t actrl;
2438 2180
2439#ifdef DEBUG
2440 printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
2441#endif
2442
2443 if (tty == (struct tty_struct *) NULL)
2444 return;
2445 portp = tty->driver_data; 2181 portp = tty->driver_data;
2446 if (portp == (stliport_t *) NULL) 2182 if (portp == NULL)
2447 return; 2183 return;
2448 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2184 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2449 return; 2185 return;
2450 brdp = stli_brds[portp->brdnr]; 2186 brdp = stli_brds[portp->brdnr];
2451 if (brdp == (stlibrd_t *) NULL) 2187 if (brdp == NULL)
2452 return; 2188 return;
2453 2189
2454 memset(&actrl, 0, sizeof(asyctrl_t)); 2190 memset(&actrl, 0, sizeof(asyctrl_t));
@@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2460 actrl.txctrl = CT_SENDCHR; 2196 actrl.txctrl = CT_SENDCHR;
2461 actrl.tximdch = ch; 2197 actrl.tximdch = ch;
2462 } 2198 }
2463
2464 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 2199 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2465} 2200}
2466 2201
@@ -2476,17 +2211,17 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2476 2211
2477static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) 2212static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos)
2478{ 2213{
2479 char *sp, *uart; 2214 char *sp, *uart;
2480 int rc, cnt; 2215 int rc, cnt;
2481 2216
2482 rc = stli_portcmdstats(portp); 2217 rc = stli_portcmdstats(portp);
2483 2218
2484 uart = "UNKNOWN"; 2219 uart = "UNKNOWN";
2485 if (brdp->state & BST_STARTED) { 2220 if (brdp->state & BST_STARTED) {
2486 switch (stli_comstats.hwid) { 2221 switch (stli_comstats.hwid) {
2487 case 0: uart = "2681"; break; 2222 case 0: uart = "2681"; break;
2488 case 1: uart = "SC26198"; break; 2223 case 1: uart = "SC26198"; break;
2489 default: uart = "CD1400"; break; 2224 default:uart = "CD1400"; break;
2490 } 2225 }
2491 } 2226 }
2492 2227
@@ -2537,17 +2272,11 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
2537 2272
2538static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 2273static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
2539{ 2274{
2540 stlibrd_t *brdp; 2275 stlibrd_t *brdp;
2541 stliport_t *portp; 2276 stliport_t *portp;
2542 int brdnr, portnr, totalport; 2277 int brdnr, portnr, totalport;
2543 int curoff, maxoff; 2278 int curoff, maxoff;
2544 char *pos; 2279 char *pos;
2545
2546#ifdef DEBUG
2547 printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
2548 "data=%x\n", (int) page, (int) start, (int) off, count,
2549 (int) eof, (int) data);
2550#endif
2551 2280
2552 pos = page; 2281 pos = page;
2553 totalport = 0; 2282 totalport = 0;
@@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2568 */ 2297 */
2569 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2298 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
2570 brdp = stli_brds[brdnr]; 2299 brdp = stli_brds[brdnr];
2571 if (brdp == (stlibrd_t *) NULL) 2300 if (brdp == NULL)
2572 continue; 2301 continue;
2573 if (brdp->state == 0) 2302 if (brdp->state == 0)
2574 continue; 2303 continue;
@@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2583 for (portnr = 0; (portnr < brdp->nrports); portnr++, 2312 for (portnr = 0; (portnr < brdp->nrports); portnr++,
2584 totalport++) { 2313 totalport++) {
2585 portp = brdp->ports[portnr]; 2314 portp = brdp->ports[portnr];
2586 if (portp == (stliport_t *) NULL) 2315 if (portp == NULL)
2587 continue; 2316 continue;
2588 if (off >= (curoff += MAXLINE)) 2317 if (off >= (curoff += MAXLINE))
2589 continue; 2318 continue;
@@ -2610,49 +2339,54 @@ stli_readdone:
2610 * a poll routine that does not have user context. Therefore you cannot 2339 * a poll routine that does not have user context. Therefore you cannot
2611 * copy back directly into user space, or to the kernel stack of a 2340 * copy back directly into user space, or to the kernel stack of a
2612 * process. This routine does not sleep, so can be called from anywhere. 2341 * process. This routine does not sleep, so can be called from anywhere.
2342 *
2343 * The caller must hold the brd_lock (see also stli_sendcmd the usual
2344 * entry point)
2613 */ 2345 */
2614 2346
2615static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 2347static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2616{ 2348{
2617 volatile cdkhdr_t *hdrp; 2349 cdkhdr_t __iomem *hdrp;
2618 volatile cdkctrl_t *cp; 2350 cdkctrl_t __iomem *cp;
2619 volatile unsigned char *bits; 2351 unsigned char __iomem *bits;
2620 unsigned long flags; 2352 unsigned long flags;
2621 2353
2622#ifdef DEBUG 2354 spin_lock_irqsave(&brd_lock, flags);
2623 printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
2624 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
2625 (int) arg, size, copyback);
2626#endif
2627
2628 save_flags(flags);
2629 cli();
2630 2355
2631 if (test_bit(ST_CMDING, &portp->state)) { 2356 if (test_bit(ST_CMDING, &portp->state)) {
2632 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", 2357 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
2633 (int) cmd); 2358 (int) cmd);
2634 restore_flags(flags); 2359 spin_unlock_irqrestore(&brd_lock, flags);
2635 return; 2360 return;
2636 } 2361 }
2637 2362
2638 EBRDENABLE(brdp); 2363 EBRDENABLE(brdp);
2639 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 2364 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
2640 if (size > 0) { 2365 if (size > 0) {
2641 memcpy((void *) &(cp->args[0]), arg, size); 2366 memcpy_toio((void __iomem *) &(cp->args[0]), arg, size);
2642 if (copyback) { 2367 if (copyback) {
2643 portp->argp = arg; 2368 portp->argp = arg;
2644 portp->argsize = size; 2369 portp->argsize = size;
2645 } 2370 }
2646 } 2371 }
2647 cp->status = 0; 2372 writel(0, &cp->status);
2648 cp->cmd = cmd; 2373 writel(cmd, &cp->cmd);
2649 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2374 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2650 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 2375 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
2651 portp->portidx; 2376 portp->portidx;
2652 *bits |= portp->portbit; 2377 writeb(readb(bits) | portp->portbit, bits);
2653 set_bit(ST_CMDING, &portp->state); 2378 set_bit(ST_CMDING, &portp->state);
2654 EBRDDISABLE(brdp); 2379 EBRDDISABLE(brdp);
2655 restore_flags(flags); 2380 spin_unlock_irqrestore(&brd_lock, flags);
2381}
2382
2383static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2384{
2385 unsigned long flags;
2386
2387 spin_lock_irqsave(&brd_lock, flags);
2388 __stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
2389 spin_unlock_irqrestore(&brd_lock, flags);
2656} 2390}
2657 2391
2658/*****************************************************************************/ 2392/*****************************************************************************/
@@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
2667 2401
2668static void stli_read(stlibrd_t *brdp, stliport_t *portp) 2402static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2669{ 2403{
2670 volatile cdkasyrq_t *rp; 2404 cdkasyrq_t __iomem *rp;
2671 volatile char *shbuf; 2405 char __iomem *shbuf;
2672 struct tty_struct *tty; 2406 struct tty_struct *tty;
2673 unsigned int head, tail, size; 2407 unsigned int head, tail, size;
2674 unsigned int len, stlen; 2408 unsigned int len, stlen;
2675
2676#ifdef DEBUG
2677 printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n",
2678 (int) brdp, (int) portp);
2679#endif
2680 2409
2681 if (test_bit(ST_RXSTOP, &portp->state)) 2410 if (test_bit(ST_RXSTOP, &portp->state))
2682 return; 2411 return;
2683 tty = portp->tty; 2412 tty = portp->tty;
2684 if (tty == (struct tty_struct *) NULL) 2413 if (tty == NULL)
2685 return; 2414 return;
2686 2415
2687 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2416 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2688 head = (unsigned int) rp->head; 2417 head = (unsigned int) readw(&rp->head);
2689 if (head != ((unsigned int) rp->head)) 2418 if (head != ((unsigned int) readw(&rp->head)))
2690 head = (unsigned int) rp->head; 2419 head = (unsigned int) readw(&rp->head);
2691 tail = (unsigned int) rp->tail; 2420 tail = (unsigned int) readw(&rp->tail);
2692 size = portp->rxsize; 2421 size = portp->rxsize;
2693 if (head >= tail) { 2422 if (head >= tail) {
2694 len = head - tail; 2423 len = head - tail;
@@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2699 } 2428 }
2700 2429
2701 len = tty_buffer_request_room(tty, len); 2430 len = tty_buffer_request_room(tty, len);
2702 /* FIXME : iomap ? */ 2431
2703 shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); 2432 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset);
2704 2433
2705 while (len > 0) { 2434 while (len > 0) {
2435 unsigned char *cptr;
2436
2706 stlen = MIN(len, stlen); 2437 stlen = MIN(len, stlen);
2707 tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); 2438 tty_prepare_flip_string(tty, &cptr, stlen);
2439 memcpy_fromio(cptr, shbuf + tail, stlen);
2708 len -= stlen; 2440 len -= stlen;
2709 tail += stlen; 2441 tail += stlen;
2710 if (tail >= size) { 2442 if (tail >= size) {
@@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2712 stlen = head; 2444 stlen = head;
2713 } 2445 }
2714 } 2446 }
2715 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2447 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2716 rp->tail = tail; 2448 writew(tail, &rp->tail);
2717 2449
2718 if (head != tail) 2450 if (head != tail)
2719 set_bit(ST_RXING, &portp->state); 2451 set_bit(ST_RXING, &portp->state);
@@ -2729,9 +2461,9 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2729 * difficult to deal with them here. 2461 * difficult to deal with them here.
2730 */ 2462 */
2731 2463
2732static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) 2464static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
2733{ 2465{
2734 int cmd; 2466 int cmd;
2735 2467
2736 if (test_bit(ST_DOSIGS, &portp->state)) { 2468 if (test_bit(ST_DOSIGS, &portp->state)) {
2737 if (test_bit(ST_DOFLUSHTX, &portp->state) && 2469 if (test_bit(ST_DOFLUSHTX, &portp->state) &&
@@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2746 clear_bit(ST_DOFLUSHTX, &portp->state); 2478 clear_bit(ST_DOFLUSHTX, &portp->state);
2747 clear_bit(ST_DOFLUSHRX, &portp->state); 2479 clear_bit(ST_DOFLUSHRX, &portp->state);
2748 clear_bit(ST_DOSIGS, &portp->state); 2480 clear_bit(ST_DOSIGS, &portp->state);
2749 memcpy((void *) &(cp->args[0]), (void *) &portp->asig, 2481 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig,
2750 sizeof(asysigs_t)); 2482 sizeof(asysigs_t));
2751 cp->status = 0; 2483 writel(0, &cp->status);
2752 cp->cmd = cmd; 2484 writel(cmd, &cp->cmd);
2753 set_bit(ST_CMDING, &portp->state); 2485 set_bit(ST_CMDING, &portp->state);
2754 } else if (test_bit(ST_DOFLUSHTX, &portp->state) || 2486 } else if (test_bit(ST_DOFLUSHTX, &portp->state) ||
2755 test_bit(ST_DOFLUSHRX, &portp->state)) { 2487 test_bit(ST_DOFLUSHRX, &portp->state)) {
@@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2757 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); 2489 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0);
2758 clear_bit(ST_DOFLUSHTX, &portp->state); 2490 clear_bit(ST_DOFLUSHTX, &portp->state);
2759 clear_bit(ST_DOFLUSHRX, &portp->state); 2491 clear_bit(ST_DOFLUSHRX, &portp->state);
2760 memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); 2492 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int));
2761 cp->status = 0; 2493 writel(0, &cp->status);
2762 cp->cmd = A_FLUSH; 2494 writel(A_FLUSH, &cp->cmd);
2763 set_bit(ST_CMDING, &portp->state); 2495 set_bit(ST_CMDING, &portp->state);
2764 } 2496 }
2765} 2497}
@@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2779 2511
2780static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) 2512static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2781{ 2513{
2782 volatile cdkasy_t *ap; 2514 cdkasy_t __iomem *ap;
2783 volatile cdkctrl_t *cp; 2515 cdkctrl_t __iomem *cp;
2784 struct tty_struct *tty; 2516 struct tty_struct *tty;
2785 asynotify_t nt; 2517 asynotify_t nt;
2786 unsigned long oldsigs; 2518 unsigned long oldsigs;
2787 int rc, donerx; 2519 int rc, donerx;
2788 2520
2789#ifdef DEBUG 2521 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
2790 printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n",
2791 (int) brdp, channr);
2792#endif
2793
2794 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
2795 cp = &ap->ctrl; 2522 cp = &ap->ctrl;
2796 2523
2797/* 2524/*
2798 * Check if we are waiting for an open completion message. 2525 * Check if we are waiting for an open completion message.
2799 */ 2526 */
2800 if (test_bit(ST_OPENING, &portp->state)) { 2527 if (test_bit(ST_OPENING, &portp->state)) {
2801 rc = (int) cp->openarg; 2528 rc = readl(&cp->openarg);
2802 if ((cp->open == 0) && (rc != 0)) { 2529 if (readb(&cp->open) == 0 && rc != 0) {
2803 if (rc > 0) 2530 if (rc > 0)
2804 rc--; 2531 rc--;
2805 cp->openarg = 0; 2532 writel(0, &cp->openarg);
2806 portp->rc = rc; 2533 portp->rc = rc;
2807 clear_bit(ST_OPENING, &portp->state); 2534 clear_bit(ST_OPENING, &portp->state);
2808 wake_up_interruptible(&portp->raw_wait); 2535 wake_up_interruptible(&portp->raw_wait);
@@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2813 * Check if we are waiting for a close completion message. 2540 * Check if we are waiting for a close completion message.
2814 */ 2541 */
2815 if (test_bit(ST_CLOSING, &portp->state)) { 2542 if (test_bit(ST_CLOSING, &portp->state)) {
2816 rc = (int) cp->closearg; 2543 rc = (int) readl(&cp->closearg);
2817 if ((cp->close == 0) && (rc != 0)) { 2544 if (readb(&cp->close) == 0 && rc != 0) {
2818 if (rc > 0) 2545 if (rc > 0)
2819 rc--; 2546 rc--;
2820 cp->closearg = 0; 2547 writel(0, &cp->closearg);
2821 portp->rc = rc; 2548 portp->rc = rc;
2822 clear_bit(ST_CLOSING, &portp->state); 2549 clear_bit(ST_CLOSING, &portp->state);
2823 wake_up_interruptible(&portp->raw_wait); 2550 wake_up_interruptible(&portp->raw_wait);
@@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2829 * need to copy out the command results associated with this command. 2556 * need to copy out the command results associated with this command.
2830 */ 2557 */
2831 if (test_bit(ST_CMDING, &portp->state)) { 2558 if (test_bit(ST_CMDING, &portp->state)) {
2832 rc = cp->status; 2559 rc = readl(&cp->status);
2833 if ((cp->cmd == 0) && (rc != 0)) { 2560 if (readl(&cp->cmd) == 0 && rc != 0) {
2834 if (rc > 0) 2561 if (rc > 0)
2835 rc--; 2562 rc--;
2836 if (portp->argp != (void *) NULL) { 2563 if (portp->argp != NULL) {
2837 memcpy(portp->argp, (void *) &(cp->args[0]), 2564 memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]),
2838 portp->argsize); 2565 portp->argsize);
2839 portp->argp = (void *) NULL; 2566 portp->argp = NULL;
2840 } 2567 }
2841 cp->status = 0; 2568 writel(0, &cp->status);
2842 portp->rc = rc; 2569 portp->rc = rc;
2843 clear_bit(ST_CMDING, &portp->state); 2570 clear_bit(ST_CMDING, &portp->state);
2844 stli_dodelaycmd(portp, cp); 2571 stli_dodelaycmd(portp, cp);
@@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2877 if (nt.data & DT_TXEMPTY) 2604 if (nt.data & DT_TXEMPTY)
2878 clear_bit(ST_TXBUSY, &portp->state); 2605 clear_bit(ST_TXBUSY, &portp->state);
2879 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { 2606 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) {
2880 if (tty != (struct tty_struct *) NULL) { 2607 if (tty != NULL) {
2881 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 2608 tty_wakeup(tty);
2882 tty->ldisc.write_wakeup) { 2609 EBRDENABLE(brdp);
2883 (tty->ldisc.write_wakeup)(tty);
2884 EBRDENABLE(brdp);
2885 }
2886 wake_up_interruptible(&tty->write_wait); 2610 wake_up_interruptible(&tty->write_wait);
2887 } 2611 }
2888 } 2612 }
2889 2613
2890 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { 2614 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
2891 if (tty != (struct tty_struct *) NULL) { 2615 if (tty != NULL) {
2892 tty_insert_flip_char(tty, 0, TTY_BREAK); 2616 tty_insert_flip_char(tty, 0, TTY_BREAK);
2893 if (portp->flags & ASYNC_SAK) { 2617 if (portp->flags & ASYNC_SAK) {
2894 do_SAK(tty); 2618 do_SAK(tty);
@@ -2932,14 +2656,14 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2932 * at the cdk header structure. 2656 * at the cdk header structure.
2933 */ 2657 */
2934 2658
2935static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) 2659static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
2936{ 2660{
2937 stliport_t *portp; 2661 stliport_t *portp;
2938 unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; 2662 unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
2939 unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; 2663 unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
2940 unsigned char *slavep; 2664 unsigned char __iomem *slavep;
2941 int bitpos, bitat, bitsize; 2665 int bitpos, bitat, bitsize;
2942 int channr, nrdevs, slavebitchange; 2666 int channr, nrdevs, slavebitchange;
2943 2667
2944 bitsize = brdp->bitsize; 2668 bitsize = brdp->bitsize;
2945 nrdevs = brdp->nrdevs; 2669 nrdevs = brdp->nrdevs;
@@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2951 * 8 service bits at a time in the inner loop, so we can bypass 2675 * 8 service bits at a time in the inner loop, so we can bypass
2952 * the lot if none of them want service. 2676 * the lot if none of them want service.
2953 */ 2677 */
2954 memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), 2678 memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset),
2955 bitsize); 2679 bitsize);
2956 2680
2957 memset(&slavebits[0], 0, bitsize); 2681 memset(&slavebits[0], 0, bitsize);
@@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2978 * service may initiate more slave requests. 2702 * service may initiate more slave requests.
2979 */ 2703 */
2980 if (slavebitchange) { 2704 if (slavebitchange) {
2981 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2705 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2982 slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; 2706 slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset;
2983 for (bitpos = 0; (bitpos < bitsize); bitpos++) { 2707 for (bitpos = 0; (bitpos < bitsize); bitpos++) {
2984 if (slavebits[bitpos]) 2708 if (readb(slavebits + bitpos))
2985 slavep[bitpos] &= ~slavebits[bitpos]; 2709 writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos);
2986 } 2710 }
2987 } 2711 }
2988} 2712}
@@ -3000,9 +2724,9 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
3000 2724
3001static void stli_poll(unsigned long arg) 2725static void stli_poll(unsigned long arg)
3002{ 2726{
3003 volatile cdkhdr_t *hdrp; 2727 cdkhdr_t __iomem *hdrp;
3004 stlibrd_t *brdp; 2728 stlibrd_t *brdp;
3005 int brdnr; 2729 int brdnr;
3006 2730
3007 stli_timerlist.expires = STLI_TIMEOUT; 2731 stli_timerlist.expires = STLI_TIMEOUT;
3008 add_timer(&stli_timerlist); 2732 add_timer(&stli_timerlist);
@@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg)
3012 */ 2736 */
3013 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2737 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
3014 brdp = stli_brds[brdnr]; 2738 brdp = stli_brds[brdnr];
3015 if (brdp == (stlibrd_t *) NULL) 2739 if (brdp == NULL)
3016 continue; 2740 continue;
3017 if ((brdp->state & BST_STARTED) == 0) 2741 if ((brdp->state & BST_STARTED) == 0)
3018 continue; 2742 continue;
3019 2743
2744 spin_lock(&brd_lock);
3020 EBRDENABLE(brdp); 2745 EBRDENABLE(brdp);
3021 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2746 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
3022 if (hdrp->hostreq) 2747 if (readb(&hdrp->hostreq))
3023 stli_brdpoll(brdp, hdrp); 2748 stli_brdpoll(brdp, hdrp);
3024 EBRDDISABLE(brdp); 2749 EBRDDISABLE(brdp);
2750 spin_unlock(&brd_lock);
3025 } 2751 }
3026} 2752}
3027 2753
@@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg)
3034 2760
3035static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) 2761static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
3036{ 2762{
3037#ifdef DEBUG
3038 printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
3039 (int) portp, (int) pp, (int) tiosp);
3040#endif
3041
3042 memset(pp, 0, sizeof(asyport_t)); 2763 memset(pp, 0, sizeof(asyport_t));
3043 2764
3044/* 2765/*
@@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
3157 2878
3158static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) 2879static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3159{ 2880{
3160#ifdef DEBUG
3161 printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n",
3162 (int) sp, dtr, rts);
3163#endif
3164
3165 memset(sp, 0, sizeof(asysigs_t)); 2881 memset(sp, 0, sizeof(asysigs_t));
3166 if (dtr >= 0) { 2882 if (dtr >= 0) {
3167 sp->signal |= SG_DTR; 2883 sp->signal |= SG_DTR;
@@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3182 2898
3183static long stli_mktiocm(unsigned long sigvalue) 2899static long stli_mktiocm(unsigned long sigvalue)
3184{ 2900{
3185 long tiocm; 2901 long tiocm = 0;
3186
3187#ifdef DEBUG
3188 printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue);
3189#endif
3190
3191 tiocm = 0;
3192 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); 2902 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0);
3193 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); 2903 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0);
3194 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); 2904 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0);
@@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp)
3210 stliport_t *portp; 2920 stliport_t *portp;
3211 int i, panelnr, panelport; 2921 int i, panelnr, panelport;
3212 2922
3213#ifdef DEBUG
3214 printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp);
3215#endif
3216
3217 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { 2923 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
3218 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); 2924 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
3219 if (!portp) { 2925 if (!portp) {
@@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp)
3240 brdp->ports[i] = portp; 2946 brdp->ports[i] = portp;
3241 } 2947 }
3242 2948
3243 return(0); 2949 return 0;
3244} 2950}
3245 2951
3246/*****************************************************************************/ 2952/*****************************************************************************/
@@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3253{ 2959{
3254 unsigned long memconf; 2960 unsigned long memconf;
3255 2961
3256#ifdef DEBUG
3257 printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp);
3258#endif
3259
3260 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 2962 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3261 udelay(10); 2963 udelay(10);
3262 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2964 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3270 2972
3271static void stli_ecpenable(stlibrd_t *brdp) 2973static void stli_ecpenable(stlibrd_t *brdp)
3272{ 2974{
3273#ifdef DEBUG
3274 printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp);
3275#endif
3276 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); 2975 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
3277} 2976}
3278 2977
@@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp)
3280 2979
3281static void stli_ecpdisable(stlibrd_t *brdp) 2980static void stli_ecpdisable(stlibrd_t *brdp)
3282{ 2981{
3283#ifdef DEBUG
3284 printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp);
3285#endif
3286 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2982 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
3287} 2983}
3288 2984
@@ -3290,13 +2986,8 @@ static void stli_ecpdisable(stlibrd_t *brdp)
3290 2986
3291static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 2987static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3292{ 2988{
3293 void *ptr; 2989 void *ptr;
3294 unsigned char val; 2990 unsigned char val;
3295
3296#ifdef DEBUG
3297 printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3298 (int) offset);
3299#endif
3300 2991
3301 if (offset > brdp->memsize) { 2992 if (offset > brdp->memsize) {
3302 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 2993 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3316 3007
3317static void stli_ecpreset(stlibrd_t *brdp) 3008static void stli_ecpreset(stlibrd_t *brdp)
3318{ 3009{
3319#ifdef DEBUG
3320 printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp);
3321#endif
3322
3323 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 3010 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3324 udelay(10); 3011 udelay(10);
3325 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 3012 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp)
3330 3017
3331static void stli_ecpintr(stlibrd_t *brdp) 3018static void stli_ecpintr(stlibrd_t *brdp)
3332{ 3019{
3333#ifdef DEBUG
3334 printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp);
3335#endif
3336 outb(0x1, brdp->iobase); 3020 outb(0x1, brdp->iobase);
3337} 3021}
3338 3022
@@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
3346{ 3030{
3347 unsigned long memconf; 3031 unsigned long memconf;
3348 3032
3349#ifdef DEBUG
3350 printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp);
3351#endif
3352
3353 outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); 3033 outb(0x1, (brdp->iobase + ECP_EIBRDENAB));
3354 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); 3034 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
3355 udelay(10); 3035 udelay(10);
@@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line
3383 void *ptr; 3063 void *ptr;
3384 unsigned char val; 3064 unsigned char val;
3385 3065
3386#ifdef DEBUG
3387 printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3388 (int) brdp, (int) offset, line);
3389#endif
3390
3391 if (offset > brdp->memsize) { 3066 if (offset > brdp->memsize) {
3392 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3067 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3393 "range at line=%d(%d), brd=%d\n", 3068 "range at line=%d(%d), brd=%d\n",
@@ -3437,8 +3112,8 @@ static void stli_ecpmcdisable(stlibrd_t *brdp)
3437 3112
3438static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3113static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3439{ 3114{
3440 void *ptr; 3115 void *ptr;
3441 unsigned char val; 3116 unsigned char val;
3442 3117
3443 if (offset > brdp->memsize) { 3118 if (offset > brdp->memsize) {
3444 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3119 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
3472 3147
3473static void stli_ecppciinit(stlibrd_t *brdp) 3148static void stli_ecppciinit(stlibrd_t *brdp)
3474{ 3149{
3475#ifdef DEBUG
3476 printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp);
3477#endif
3478
3479 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); 3150 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
3480 udelay(10); 3151 udelay(10);
3481 outb(0, (brdp->iobase + ECP_PCICONFR)); 3152 outb(0, (brdp->iobase + ECP_PCICONFR));
@@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin
3489 void *ptr; 3160 void *ptr;
3490 unsigned char val; 3161 unsigned char val;
3491 3162
3492#ifdef DEBUG
3493 printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3494 (int) brdp, (int) offset, line);
3495#endif
3496
3497 if (offset > brdp->memsize) { 3163 if (offset > brdp->memsize) {
3498 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3164 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3499 "range at line=%d(%d), board=%d\n", 3165 "range at line=%d(%d), board=%d\n",
@@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3528{ 3194{
3529 unsigned long memconf; 3195 unsigned long memconf;
3530 3196
3531#ifdef DEBUG
3532 printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp);
3533#endif
3534
3535 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3197 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3536 udelay(10); 3198 udelay(10);
3537 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3199 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3547 3209
3548static void stli_onbenable(stlibrd_t *brdp) 3210static void stli_onbenable(stlibrd_t *brdp)
3549{ 3211{
3550#ifdef DEBUG
3551 printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp);
3552#endif
3553 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); 3212 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
3554} 3213}
3555 3214
@@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp)
3557 3216
3558static void stli_onbdisable(stlibrd_t *brdp) 3217static void stli_onbdisable(stlibrd_t *brdp)
3559{ 3218{
3560#ifdef DEBUG
3561 printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp);
3562#endif
3563 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); 3219 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
3564} 3220}
3565 3221
@@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3569{ 3225{
3570 void *ptr; 3226 void *ptr;
3571 3227
3572#ifdef DEBUG
3573 printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3574 (int) offset);
3575#endif
3576
3577 if (offset > brdp->memsize) { 3228 if (offset > brdp->memsize) {
3578 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3229 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3579 "range at line=%d(%d), brd=%d\n", 3230 "range at line=%d(%d), brd=%d\n",
@@ -3589,11 +3240,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3589 3240
3590static void stli_onbreset(stlibrd_t *brdp) 3241static void stli_onbreset(stlibrd_t *brdp)
3591{ 3242{
3592
3593#ifdef DEBUG
3594 printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp);
3595#endif
3596
3597 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3243 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3598 udelay(10); 3244 udelay(10);
3599 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3245 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3610{ 3256{
3611 unsigned long memconf; 3257 unsigned long memconf;
3612 3258
3613#ifdef DEBUG
3614 printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp);
3615#endif
3616
3617 outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); 3259 outb(0x1, (brdp->iobase + ONB_EIBRDENAB));
3618 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3260 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3619 udelay(10); 3261 udelay(10);
@@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3632 3274
3633static void stli_onbeenable(stlibrd_t *brdp) 3275static void stli_onbeenable(stlibrd_t *brdp)
3634{ 3276{
3635#ifdef DEBUG
3636 printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp);
3637#endif
3638 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); 3277 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
3639} 3278}
3640 3279
@@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp)
3642 3281
3643static void stli_onbedisable(stlibrd_t *brdp) 3282static void stli_onbedisable(stlibrd_t *brdp)
3644{ 3283{
3645#ifdef DEBUG
3646 printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp);
3647#endif
3648 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3284 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
3649} 3285}
3650 3286
@@ -3652,13 +3288,8 @@ static void stli_onbedisable(stlibrd_t *brdp)
3652 3288
3653static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3289static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3654{ 3290{
3655 void *ptr; 3291 void *ptr;
3656 unsigned char val; 3292 unsigned char val;
3657
3658#ifdef DEBUG
3659 printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
3660 (int) brdp, (int) offset, line);
3661#endif
3662 3293
3663 if (offset > brdp->memsize) { 3294 if (offset > brdp->memsize) {
3664 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3295 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3681 3312
3682static void stli_onbereset(stlibrd_t *brdp) 3313static void stli_onbereset(stlibrd_t *brdp)
3683{ 3314{
3684
3685#ifdef DEBUG
3686 printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp);
3687#endif
3688
3689 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3315 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3690 udelay(10); 3316 udelay(10);
3691 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3317 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
@@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp)
3700 3326
3701static void stli_bbyinit(stlibrd_t *brdp) 3327static void stli_bbyinit(stlibrd_t *brdp)
3702{ 3328{
3703
3704#ifdef DEBUG
3705 printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp);
3706#endif
3707
3708 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3329 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3709 udelay(10); 3330 udelay(10);
3710 outb(0, (brdp->iobase + BBY_ATCONFR)); 3331 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3717,24 +3338,13 @@ static void stli_bbyinit(stlibrd_t *brdp)
3717 3338
3718static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3339static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3719{ 3340{
3720 void *ptr; 3341 void *ptr;
3721 unsigned char val; 3342 unsigned char val;
3722 3343
3723#ifdef DEBUG 3344 BUG_ON(offset > brdp->memsize);
3724 printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3725 (int) offset);
3726#endif
3727 3345
3728 if (offset > brdp->memsize) { 3346 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3729 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3347 val = (unsigned char) (offset / BBY_PAGESIZE);
3730 "range at line=%d(%d), brd=%d\n",
3731 (int) offset, line, __LINE__, brdp->brdnr);
3732 ptr = NULL;
3733 val = 0;
3734 } else {
3735 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3736 val = (unsigned char) (offset / BBY_PAGESIZE);
3737 }
3738 outb(val, (brdp->iobase + BBY_ATCONFR)); 3348 outb(val, (brdp->iobase + BBY_ATCONFR));
3739 return(ptr); 3349 return(ptr);
3740} 3350}
@@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3743 3353
3744static void stli_bbyreset(stlibrd_t *brdp) 3354static void stli_bbyreset(stlibrd_t *brdp)
3745{ 3355{
3746
3747#ifdef DEBUG
3748 printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp);
3749#endif
3750
3751 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3356 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3752 udelay(10); 3357 udelay(10);
3753 outb(0, (brdp->iobase + BBY_ATCONFR)); 3358 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp)
3762 3367
3763static void stli_stalinit(stlibrd_t *brdp) 3368static void stli_stalinit(stlibrd_t *brdp)
3764{ 3369{
3765
3766#ifdef DEBUG
3767 printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp);
3768#endif
3769
3770 outb(0x1, brdp->iobase); 3370 outb(0x1, brdp->iobase);
3771 mdelay(1000); 3371 mdelay(1000);
3772} 3372}
@@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp)
3775 3375
3776static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3376static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3777{ 3377{
3778 void *ptr; 3378 BUG_ON(offset > brdp->memsize);
3779 3379 return brdp->membase + (offset % STAL_PAGESIZE);
3780#ifdef DEBUG
3781 printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3782 (int) offset);
3783#endif
3784
3785 if (offset > brdp->memsize) {
3786 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3787 "range at line=%d(%d), brd=%d\n",
3788 (int) offset, line, __LINE__, brdp->brdnr);
3789 ptr = NULL;
3790 } else {
3791 ptr = brdp->membase + (offset % STAL_PAGESIZE);
3792 }
3793 return(ptr);
3794} 3380}
3795 3381
3796/*****************************************************************************/ 3382/*****************************************************************************/
3797 3383
3798static void stli_stalreset(stlibrd_t *brdp) 3384static void stli_stalreset(stlibrd_t *brdp)
3799{ 3385{
3800 volatile unsigned long *vecp; 3386 u32 __iomem *vecp;
3801
3802#ifdef DEBUG
3803 printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp);
3804#endif
3805 3387
3806 vecp = (volatile unsigned long *) (brdp->membase + 0x30); 3388 vecp = (u32 __iomem *) (brdp->membase + 0x30);
3807 *vecp = 0xffff0000; 3389 writel(0xffff0000, vecp);
3808 outb(0, brdp->iobase); 3390 outb(0, brdp->iobase);
3809 mdelay(1000); 3391 mdelay(1000);
3810} 3392}
@@ -3818,15 +3400,11 @@ static void stli_stalreset(stlibrd_t *brdp)
3818 3400
3819static int stli_initecp(stlibrd_t *brdp) 3401static int stli_initecp(stlibrd_t *brdp)
3820{ 3402{
3821 cdkecpsig_t sig; 3403 cdkecpsig_t sig;
3822 cdkecpsig_t *sigsp; 3404 cdkecpsig_t __iomem *sigsp;
3823 unsigned int status, nxtid; 3405 unsigned int status, nxtid;
3824 char *name; 3406 char *name;
3825 int panelnr, nrports; 3407 int panelnr, nrports;
3826
3827#ifdef DEBUG
3828 printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
3829#endif
3830 3408
3831 if (!request_region(brdp->iobase, brdp->iosize, "istallion")) 3409 if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
3832 return -EIO; 3410 return -EIO;
@@ -3834,7 +3412,7 @@ static int stli_initecp(stlibrd_t *brdp)
3834 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3412 if ((brdp->iobase == 0) || (brdp->memaddr == 0))
3835 { 3413 {
3836 release_region(brdp->iobase, brdp->iosize); 3414 release_region(brdp->iobase, brdp->iosize);
3837 return(-ENODEV); 3415 return -ENODEV;
3838 } 3416 }
3839 3417
3840 brdp->iosize = ECP_IOSIZE; 3418 brdp->iosize = ECP_IOSIZE;
@@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp)
3903 3481
3904 default: 3482 default:
3905 release_region(brdp->iobase, brdp->iosize); 3483 release_region(brdp->iobase, brdp->iosize);
3906 return(-EINVAL); 3484 return -EINVAL;
3907 } 3485 }
3908 3486
3909/* 3487/*
@@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp)
3915 EBRDINIT(brdp); 3493 EBRDINIT(brdp);
3916 3494
3917 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3495 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
3918 if (brdp->membase == (void *) NULL) 3496 if (brdp->membase == NULL)
3919 { 3497 {
3920 release_region(brdp->iobase, brdp->iosize); 3498 release_region(brdp->iobase, brdp->iosize);
3921 return(-ENOMEM); 3499 return -ENOMEM;
3922 } 3500 }
3923 3501
3924/* 3502/*
@@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp)
3927 * this is, and what it is connected to it. 3505 * this is, and what it is connected to it.
3928 */ 3506 */
3929 EBRDENABLE(brdp); 3507 EBRDENABLE(brdp);
3930 sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3508 sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
3931 memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); 3509 memcpy(&sig, sigsp, sizeof(cdkecpsig_t));
3932 EBRDDISABLE(brdp); 3510 EBRDDISABLE(brdp);
3933 3511
3934#if 0 3512 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3935 printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
3936 __FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0],
3937 (int) sig.panelid[1], (int) sig.panelid[2],
3938 (int) sig.panelid[3], (int) sig.panelid[4],
3939 (int) sig.panelid[5], (int) sig.panelid[6],
3940 (int) sig.panelid[7]);
3941#endif
3942
3943 if (sig.magic != ECP_MAGIC)
3944 { 3513 {
3945 release_region(brdp->iobase, brdp->iosize); 3514 release_region(brdp->iobase, brdp->iosize);
3946 return(-ENODEV); 3515 return -ENODEV;
3947 } 3516 }
3948 3517
3949/* 3518/*
@@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp)
3967 3536
3968 3537
3969 brdp->state |= BST_FOUND; 3538 brdp->state |= BST_FOUND;
3970 return(0); 3539 return 0;
3971} 3540}
3972 3541
3973/*****************************************************************************/ 3542/*****************************************************************************/
@@ -3979,20 +3548,16 @@ static int stli_initecp(stlibrd_t *brdp)
3979 3548
3980static int stli_initonb(stlibrd_t *brdp) 3549static int stli_initonb(stlibrd_t *brdp)
3981{ 3550{
3982 cdkonbsig_t sig; 3551 cdkonbsig_t sig;
3983 cdkonbsig_t *sigsp; 3552 cdkonbsig_t __iomem *sigsp;
3984 char *name; 3553 char *name;
3985 int i; 3554 int i;
3986
3987#ifdef DEBUG
3988 printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp);
3989#endif
3990 3555
3991/* 3556/*
3992 * Do a basic sanity check on the IO and memory addresses. 3557 * Do a basic sanity check on the IO and memory addresses.
3993 */ 3558 */
3994 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3559 if (brdp->iobase == 0 || brdp->memaddr == 0)
3995 return(-ENODEV); 3560 return -ENODEV;
3996 3561
3997 brdp->iosize = ONB_IOSIZE; 3562 brdp->iosize = ONB_IOSIZE;
3998 3563
@@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp)
4010 case BRD_ONBOARD2: 3575 case BRD_ONBOARD2:
4011 case BRD_ONBOARD2_32: 3576 case BRD_ONBOARD2_32:
4012 case BRD_ONBOARDRS: 3577 case BRD_ONBOARDRS:
4013 brdp->membase = (void *) brdp->memaddr;
4014 brdp->memsize = ONB_MEMSIZE; 3578 brdp->memsize = ONB_MEMSIZE;
4015 brdp->pagesize = ONB_ATPAGESIZE; 3579 brdp->pagesize = ONB_ATPAGESIZE;
4016 brdp->init = stli_onbinit; 3580 brdp->init = stli_onbinit;
@@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp)
4028 break; 3592 break;
4029 3593
4030 case BRD_ONBOARDE: 3594 case BRD_ONBOARDE:
4031 brdp->membase = (void *) brdp->memaddr;
4032 brdp->memsize = ONB_EIMEMSIZE; 3595 brdp->memsize = ONB_EIMEMSIZE;
4033 brdp->pagesize = ONB_EIPAGESIZE; 3596 brdp->pagesize = ONB_EIPAGESIZE;
4034 brdp->init = stli_onbeinit; 3597 brdp->init = stli_onbeinit;
@@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp)
4044 case BRD_BRUMBY4: 3607 case BRD_BRUMBY4:
4045 case BRD_BRUMBY8: 3608 case BRD_BRUMBY8:
4046 case BRD_BRUMBY16: 3609 case BRD_BRUMBY16:
4047 brdp->membase = (void *) brdp->memaddr;
4048 brdp->memsize = BBY_MEMSIZE; 3610 brdp->memsize = BBY_MEMSIZE;
4049 brdp->pagesize = BBY_PAGESIZE; 3611 brdp->pagesize = BBY_PAGESIZE;
4050 brdp->init = stli_bbyinit; 3612 brdp->init = stli_bbyinit;
@@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp)
4058 break; 3620 break;
4059 3621
4060 case BRD_STALLION: 3622 case BRD_STALLION:
4061 brdp->membase = (void *) brdp->memaddr;
4062 brdp->memsize = STAL_MEMSIZE; 3623 brdp->memsize = STAL_MEMSIZE;
4063 brdp->pagesize = STAL_PAGESIZE; 3624 brdp->pagesize = STAL_PAGESIZE;
4064 brdp->init = stli_stalinit; 3625 brdp->init = stli_stalinit;
@@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp)
4073 3634
4074 default: 3635 default:
4075 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
4076 return(-EINVAL); 3637 return -EINVAL;
4077 } 3638 }
4078 3639
4079/* 3640/*
@@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp)
4085 EBRDINIT(brdp); 3646 EBRDINIT(brdp);
4086 3647
4087 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3648 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4088 if (brdp->membase == (void *) NULL) 3649 if (brdp->membase == NULL)
4089 { 3650 {
4090 release_region(brdp->iobase, brdp->iosize); 3651 release_region(brdp->iobase, brdp->iosize);
4091 return(-ENOMEM); 3652 return -ENOMEM;
4092 } 3653 }
4093 3654
4094/* 3655/*
@@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp)
4097 * this is, and how many ports. 3658 * this is, and how many ports.
4098 */ 3659 */
4099 EBRDENABLE(brdp); 3660 EBRDENABLE(brdp);
4100 sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3661 sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
4101 memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); 3662 memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t));
4102 EBRDDISABLE(brdp); 3663 EBRDDISABLE(brdp);
4103 3664
4104#if 0 3665 if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
4105 printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", 3666 sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
4106 __FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, 3667 sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
4107 sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); 3668 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
4108#endif
4109
4110 if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) ||
4111 (sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3))
4112 { 3669 {
4113 release_region(brdp->iobase, brdp->iosize); 3670 release_region(brdp->iobase, brdp->iosize);
4114 return(-ENODEV); 3671 return -ENODEV;
4115 } 3672 }
4116 3673
4117/* 3674/*
@@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp)
4132 3689
4133 3690
4134 brdp->state |= BST_FOUND; 3691 brdp->state |= BST_FOUND;
4135 return(0); 3692 return 0;
4136} 3693}
4137 3694
4138/*****************************************************************************/ 3695/*****************************************************************************/
@@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp)
4145 3702
4146static int stli_startbrd(stlibrd_t *brdp) 3703static int stli_startbrd(stlibrd_t *brdp)
4147{ 3704{
4148 volatile cdkhdr_t *hdrp; 3705 cdkhdr_t __iomem *hdrp;
4149 volatile cdkmem_t *memp; 3706 cdkmem_t __iomem *memp;
4150 volatile cdkasy_t *ap; 3707 cdkasy_t __iomem *ap;
4151 unsigned long flags; 3708 unsigned long flags;
4152 stliport_t *portp; 3709 stliport_t *portp;
4153 int portnr, nrdevs, i, rc; 3710 int portnr, nrdevs, i, rc = 0;
4154 3711 u32 memoff;
4155#ifdef DEBUG 3712
4156 printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp); 3713 spin_lock_irqsave(&brd_lock, flags);
4157#endif
4158
4159 rc = 0;
4160
4161 save_flags(flags);
4162 cli();
4163 EBRDENABLE(brdp); 3714 EBRDENABLE(brdp);
4164 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 3715 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
4165 nrdevs = hdrp->nrdevs; 3716 nrdevs = hdrp->nrdevs;
4166 3717
4167#if 0 3718#if 0
4168 printk("%s(%d): CDK version %d.%d.%d --> " 3719 printk("%s(%d): CDK version %d.%d.%d --> "
4169 "nrdevs=%d memp=%x hostp=%x slavep=%x\n", 3720 "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
4170 __FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, 3721 __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification),
4171 hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, 3722 readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp),
4172 (int) hdrp->slavep); 3723 readl(&hdrp->slavep));
4173#endif 3724#endif
4174 3725
4175 if (nrdevs < (brdp->nrports + 1)) { 3726 if (nrdevs < (brdp->nrports + 1)) {
@@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp)
4181 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; 3732 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR;
4182 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; 3733 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR;
4183 brdp->bitsize = (nrdevs + 7) / 8; 3734 brdp->bitsize = (nrdevs + 7) / 8;
4184 memp = (volatile cdkmem_t *) hdrp->memp; 3735 memoff = readl(&hdrp->memp);
4185 if (((unsigned long) memp) > brdp->memsize) { 3736 if (memoff > brdp->memsize) {
4186 printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); 3737 printk(KERN_ERR "STALLION: corrupted shared memory region?\n");
4187 rc = -EIO; 3738 rc = -EIO;
4188 goto stli_donestartup; 3739 goto stli_donestartup;
4189 } 3740 }
4190 memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); 3741 memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff);
4191 if (memp->dtype != TYP_ASYNCTRL) { 3742 if (readw(&memp->dtype) != TYP_ASYNCTRL) {
4192 printk(KERN_ERR "STALLION: no slave control device found\n"); 3743 printk(KERN_ERR "STALLION: no slave control device found\n");
4193 goto stli_donestartup; 3744 goto stli_donestartup;
4194 } 3745 }
@@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp)
4200 * change pages while reading memory map. 3751 * change pages while reading memory map.
4201 */ 3752 */
4202 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { 3753 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) {
4203 if (memp->dtype != TYP_ASYNC) 3754 if (readw(&memp->dtype) != TYP_ASYNC)
4204 break; 3755 break;
4205 portp = brdp->ports[portnr]; 3756 portp = brdp->ports[portnr];
4206 if (portp == (stliport_t *) NULL) 3757 if (portp == NULL)
4207 break; 3758 break;
4208 portp->devnr = i; 3759 portp->devnr = i;
4209 portp->addr = memp->offset; 3760 portp->addr = readl(&memp->offset);
4210 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); 3761 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs));
4211 portp->portidx = (unsigned char) (i / 8); 3762 portp->portidx = (unsigned char) (i / 8);
4212 portp->portbit = (unsigned char) (0x1 << (i % 8)); 3763 portp->portbit = (unsigned char) (0x1 << (i % 8));
4213 } 3764 }
4214 3765
4215 hdrp->slavereq = 0xff; 3766 writeb(0xff, &hdrp->slavereq);
4216 3767
4217/* 3768/*
4218 * For each port setup a local copy of the RX and TX buffer offsets 3769 * For each port setup a local copy of the RX and TX buffer offsets
@@ -4221,22 +3772,22 @@ static int stli_startbrd(stlibrd_t *brdp)
4221 */ 3772 */
4222 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { 3773 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) {
4223 portp = brdp->ports[portnr]; 3774 portp = brdp->ports[portnr];
4224 if (portp == (stliport_t *) NULL) 3775 if (portp == NULL)
4225 break; 3776 break;
4226 if (portp->addr == 0) 3777 if (portp->addr == 0)
4227 break; 3778 break;
4228 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 3779 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
4229 if (ap != (volatile cdkasy_t *) NULL) { 3780 if (ap != NULL) {
4230 portp->rxsize = ap->rxq.size; 3781 portp->rxsize = readw(&ap->rxq.size);
4231 portp->txsize = ap->txq.size; 3782 portp->txsize = readw(&ap->txq.size);
4232 portp->rxoffset = ap->rxq.offset; 3783 portp->rxoffset = readl(&ap->rxq.offset);
4233 portp->txoffset = ap->txq.offset; 3784 portp->txoffset = readl(&ap->txq.offset);
4234 } 3785 }
4235 } 3786 }
4236 3787
4237stli_donestartup: 3788stli_donestartup:
4238 EBRDDISABLE(brdp); 3789 EBRDDISABLE(brdp);
4239 restore_flags(flags); 3790 spin_unlock_irqrestore(&brd_lock, flags);
4240 3791
4241 if (rc == 0) 3792 if (rc == 0)
4242 brdp->state |= BST_STARTED; 3793 brdp->state |= BST_STARTED;
@@ -4247,7 +3798,7 @@ stli_donestartup:
4247 add_timer(&stli_timerlist); 3798 add_timer(&stli_timerlist);
4248 } 3799 }
4249 3800
4250 return(rc); 3801 return rc;
4251} 3802}
4252 3803
4253/*****************************************************************************/ 3804/*****************************************************************************/
@@ -4258,10 +3809,6 @@ stli_donestartup:
4258 3809
4259static int __init stli_brdinit(stlibrd_t *brdp) 3810static int __init stli_brdinit(stlibrd_t *brdp)
4260{ 3811{
4261#ifdef DEBUG
4262 printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp);
4263#endif
4264
4265 stli_brds[brdp->brdnr] = brdp; 3812 stli_brds[brdp->brdnr] = brdp;
4266 3813
4267 switch (brdp->brdtype) { 3814 switch (brdp->brdtype) {
@@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4289 case BRD_ECHPCI: 3836 case BRD_ECHPCI:
4290 printk(KERN_ERR "STALLION: %s board type not supported in " 3837 printk(KERN_ERR "STALLION: %s board type not supported in "
4291 "this driver\n", stli_brdnames[brdp->brdtype]); 3838 "this driver\n", stli_brdnames[brdp->brdtype]);
4292 return(ENODEV); 3839 return -ENODEV;
4293 default: 3840 default:
4294 printk(KERN_ERR "STALLION: board=%d is unknown board " 3841 printk(KERN_ERR "STALLION: board=%d is unknown board "
4295 "type=%d\n", brdp->brdnr, brdp->brdtype); 3842 "type=%d\n", brdp->brdnr, brdp->brdtype);
4296 return(ENODEV); 3843 return -ENODEV;
4297 } 3844 }
4298 3845
4299 if ((brdp->state & BST_FOUND) == 0) { 3846 if ((brdp->state & BST_FOUND) == 0) {
@@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4301 "io=%x mem=%x\n", 3848 "io=%x mem=%x\n",
4302 stli_brdnames[brdp->brdtype], brdp->brdnr, 3849 stli_brdnames[brdp->brdtype], brdp->brdnr,
4303 brdp->iobase, (int) brdp->memaddr); 3850 brdp->iobase, (int) brdp->memaddr);
4304 return(ENODEV); 3851 return -ENODEV;
4305 } 3852 }
4306 3853
4307 stli_initports(brdp); 3854 stli_initports(brdp);
@@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4309 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], 3856 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype],
4310 brdp->brdnr, brdp->iobase, (int) brdp->memaddr, 3857 brdp->brdnr, brdp->iobase, (int) brdp->memaddr,
4311 brdp->nrpanels, brdp->nrports); 3858 brdp->nrpanels, brdp->nrports);
4312 return(0); 3859 return 0;
4313} 3860}
4314 3861
4315/*****************************************************************************/ 3862/*****************************************************************************/
@@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4321 3868
4322static int stli_eisamemprobe(stlibrd_t *brdp) 3869static int stli_eisamemprobe(stlibrd_t *brdp)
4323{ 3870{
4324 cdkecpsig_t ecpsig, *ecpsigp; 3871 cdkecpsig_t ecpsig, __iomem *ecpsigp;
4325 cdkonbsig_t onbsig, *onbsigp; 3872 cdkonbsig_t onbsig, __iomem *onbsigp;
4326 int i, foundit; 3873 int i, foundit;
4327 3874
4328#ifdef DEBUG
4329 printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp);
4330#endif
4331
4332/* 3875/*
4333 * First up we reset the board, to get it into a known state. There 3876 * First up we reset the board, to get it into a known state. There
4334 * is only 2 board types here we need to worry about. Don;t use the 3877 * is only 2 board types here we need to worry about. Don;t use the
@@ -4352,7 +3895,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4352 mdelay(1); 3895 mdelay(1);
4353 stli_onbeenable(brdp); 3896 stli_onbeenable(brdp);
4354 } else { 3897 } else {
4355 return(-ENODEV); 3898 return -ENODEV;
4356 } 3899 }
4357 3900
4358 foundit = 0; 3901 foundit = 0;
@@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4364 */ 3907 */
4365 for (i = 0; (i < stli_eisamempsize); i++) { 3908 for (i = 0; (i < stli_eisamempsize); i++) {
4366 brdp->memaddr = stli_eisamemprobeaddrs[i]; 3909 brdp->memaddr = stli_eisamemprobeaddrs[i];
4367 brdp->membase = (void *) brdp->memaddr;
4368 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3910 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4369 if (brdp->membase == (void *) NULL) 3911 if (brdp->membase == NULL)
4370 continue; 3912 continue;
4371 3913
4372 if (brdp->brdtype == BRD_ECPE) { 3914 if (brdp->brdtype == BRD_ECPE) {
4373 ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, 3915 ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp,
4374 CDK_SIGADDR, __LINE__); 3916 CDK_SIGADDR, __LINE__);
4375 memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); 3917 memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t));
4376 if (ecpsig.magic == ECP_MAGIC) 3918 if (ecpsig.magic == cpu_to_le32(ECP_MAGIC))
4377 foundit = 1; 3919 foundit = 1;
4378 } else { 3920 } else {
4379 onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, 3921 onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp,
4380 CDK_SIGADDR, __LINE__); 3922 CDK_SIGADDR, __LINE__);
4381 memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); 3923 memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t));
4382 if ((onbsig.magic0 == ONB_MAGIC0) && 3924 if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) &&
4383 (onbsig.magic1 == ONB_MAGIC1) && 3925 (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) &&
4384 (onbsig.magic2 == ONB_MAGIC2) && 3926 (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) &&
4385 (onbsig.magic3 == ONB_MAGIC3)) 3927 (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3)))
4386 foundit = 1; 3928 foundit = 1;
4387 } 3929 }
4388 3930
@@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4406 printk(KERN_ERR "STALLION: failed to probe shared memory " 3948 printk(KERN_ERR "STALLION: failed to probe shared memory "
4407 "region for %s in EISA slot=%d\n", 3949 "region for %s in EISA slot=%d\n",
4408 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); 3950 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12));
4409 return(-ENODEV); 3951 return -ENODEV;
4410 } 3952 }
4411 return(0); 3953 return 0;
4412} 3954}
4413 3955
4414static int stli_getbrdnr(void) 3956static int stli_getbrdnr(void)
@@ -4439,22 +3981,16 @@ static int stli_getbrdnr(void)
4439 3981
4440static int stli_findeisabrds(void) 3982static int stli_findeisabrds(void)
4441{ 3983{
4442 stlibrd_t *brdp; 3984 stlibrd_t *brdp;
4443 unsigned int iobase, eid; 3985 unsigned int iobase, eid;
4444 int i; 3986 int i;
4445
4446#ifdef DEBUG
4447 printk(KERN_DEBUG "stli_findeisabrds()\n");
4448#endif
4449 3987
4450/* 3988/*
4451 * Firstly check if this is an EISA system. Do this by probing for 3989 * Firstly check if this is an EISA system. If this is not an EISA system then
4452 * the system board EISA ID. If this is not an EISA system then
4453 * don't bother going any further! 3990 * don't bother going any further!
4454 */ 3991 */
4455 outb(0xff, 0xc80); 3992 if (EISA_bus)
4456 if (inb(0xc80) == 0xff) 3993 return 0;
4457 return(0);
4458 3994
4459/* 3995/*
4460 * Looks like an EISA system, so go searching for EISA boards. 3996 * Looks like an EISA system, so go searching for EISA boards.
@@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void)
4472 */ 4008 */
4473 for (i = 0; (i < STL_MAXBRDS); i++) { 4009 for (i = 0; (i < STL_MAXBRDS); i++) {
4474 brdp = stli_brds[i]; 4010 brdp = stli_brds[i];
4475 if (brdp == (stlibrd_t *) NULL) 4011 if (brdp == NULL)
4476 continue; 4012 continue;
4477 if (brdp->iobase == iobase) 4013 if (brdp->iobase == iobase)
4478 break; 4014 break;
@@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void)
4484 * We have found a Stallion board and it is not configured already. 4020 * We have found a Stallion board and it is not configured already.
4485 * Allocate a board structure and initialize it. 4021 * Allocate a board structure and initialize it.
4486 */ 4022 */
4487 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4023 if ((brdp = stli_allocbrd()) == NULL)
4488 return(-ENOMEM); 4024 return -ENOMEM;
4489 if ((brdp->brdnr = stli_getbrdnr()) < 0) 4025 if ((brdp->brdnr = stli_getbrdnr()) < 0)
4490 return(-ENOMEM); 4026 return -ENOMEM;
4491 eid = inb(iobase + 0xc82); 4027 eid = inb(iobase + 0xc82);
4492 if (eid == ECP_EISAID) 4028 if (eid == ECP_EISAID)
4493 brdp->brdtype = BRD_ECPE; 4029 brdp->brdtype = BRD_ECPE;
@@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void)
4502 stli_brdinit(brdp); 4038 stli_brdinit(brdp);
4503 } 4039 }
4504 4040
4505 return(0); 4041 return 0;
4506} 4042}
4507 4043
4508/*****************************************************************************/ 4044/*****************************************************************************/
@@ -4523,32 +4059,18 @@ static int stli_findeisabrds(void)
4523 4059
4524static int stli_initpcibrd(int brdtype, struct pci_dev *devp) 4060static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4525{ 4061{
4526 stlibrd_t *brdp; 4062 stlibrd_t *brdp;
4527
4528#ifdef DEBUG
4529 printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n",
4530 brdtype, dev->bus->number, dev->devfn);
4531#endif
4532 4063
4533 if (pci_enable_device(devp)) 4064 if (pci_enable_device(devp))
4534 return(-EIO); 4065 return -EIO;
4535 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4066 if ((brdp = stli_allocbrd()) == NULL)
4536 return(-ENOMEM); 4067 return -ENOMEM;
4537 if ((brdp->brdnr = stli_getbrdnr()) < 0) { 4068 if ((brdp->brdnr = stli_getbrdnr()) < 0) {
4538 printk(KERN_INFO "STALLION: too many boards found, " 4069 printk(KERN_INFO "STALLION: too many boards found, "
4539 "maximum supported %d\n", STL_MAXBRDS); 4070 "maximum supported %d\n", STL_MAXBRDS);
4540 return(0); 4071 return 0;
4541 } 4072 }
4542 brdp->brdtype = brdtype; 4073 brdp->brdtype = brdtype;
4543
4544#ifdef DEBUG
4545 printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__,
4546 pci_resource_start(devp, 0),
4547 pci_resource_start(devp, 1),
4548 pci_resource_start(devp, 2),
4549 pci_resource_start(devp, 3));
4550#endif
4551
4552/* 4074/*
4553 * We have all resources from the board, so lets setup the actual 4075 * We have all resources from the board, so lets setup the actual
4554 * board structure now. 4076 * board structure now.
@@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4557 brdp->memaddr = pci_resource_start(devp, 2); 4079 brdp->memaddr = pci_resource_start(devp, 2);
4558 stli_brdinit(brdp); 4080 stli_brdinit(brdp);
4559 4081
4560 return(0); 4082 return 0;
4561} 4083}
4562 4084
4563/*****************************************************************************/ 4085/*****************************************************************************/
@@ -4569,20 +4091,12 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4569 4091
4570static int stli_findpcibrds(void) 4092static int stli_findpcibrds(void)
4571{ 4093{
4572 struct pci_dev *dev = NULL; 4094 struct pci_dev *dev = NULL;
4573 int rc;
4574
4575#ifdef DEBUG
4576 printk("stli_findpcibrds()\n");
4577#endif
4578 4095
4579 while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, 4096 while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
4580 PCI_DEVICE_ID_ECRA, dev))) { 4097 stli_initpcibrd(BRD_ECPPCI, dev);
4581 if ((rc = stli_initpcibrd(BRD_ECPPCI, dev)))
4582 return(rc);
4583 } 4098 }
4584 4099 return 0;
4585 return(0);
4586} 4100}
4587 4101
4588#endif 4102#endif
@@ -4595,17 +4109,16 @@ static int stli_findpcibrds(void)
4595 4109
4596static stlibrd_t *stli_allocbrd(void) 4110static stlibrd_t *stli_allocbrd(void)
4597{ 4111{
4598 stlibrd_t *brdp; 4112 stlibrd_t *brdp;
4599 4113
4600 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); 4114 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
4601 if (!brdp) { 4115 if (!brdp) {
4602 printk(KERN_ERR "STALLION: failed to allocate memory " 4116 printk(KERN_ERR "STALLION: failed to allocate memory "
4603 "(size=%d)\n", sizeof(stlibrd_t)); 4117 "(size=%Zd)\n", sizeof(stlibrd_t));
4604 return NULL; 4118 return NULL;
4605 } 4119 }
4606
4607 brdp->magic = STLI_BOARDMAGIC; 4120 brdp->magic = STLI_BOARDMAGIC;
4608 return(brdp); 4121 return brdp;
4609} 4122}
4610 4123
4611/*****************************************************************************/ 4124/*****************************************************************************/
@@ -4617,13 +4130,9 @@ static stlibrd_t *stli_allocbrd(void)
4617 4130
4618static int stli_initbrds(void) 4131static int stli_initbrds(void)
4619{ 4132{
4620 stlibrd_t *brdp, *nxtbrdp; 4133 stlibrd_t *brdp, *nxtbrdp;
4621 stlconf_t *confp; 4134 stlconf_t *confp;
4622 int i, j; 4135 int i, j;
4623
4624#ifdef DEBUG
4625 printk(KERN_DEBUG "stli_initbrds()\n");
4626#endif
4627 4136
4628 if (stli_nrbrds > STL_MAXBRDS) { 4137 if (stli_nrbrds > STL_MAXBRDS) {
4629 printk(KERN_INFO "STALLION: too many boards in configuration " 4138 printk(KERN_INFO "STALLION: too many boards in configuration "
@@ -4638,11 +4147,9 @@ static int stli_initbrds(void)
4638 */ 4147 */
4639 for (i = 0; (i < stli_nrbrds); i++) { 4148 for (i = 0; (i < stli_nrbrds); i++) {
4640 confp = &stli_brdconf[i]; 4149 confp = &stli_brdconf[i];
4641#ifdef MODULE
4642 stli_parsebrd(confp, stli_brdsp[i]); 4150 stli_parsebrd(confp, stli_brdsp[i]);
4643#endif 4151 if ((brdp = stli_allocbrd()) == NULL)
4644 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4152 return -ENOMEM;
4645 return(-ENOMEM);
4646 brdp->brdnr = i; 4153 brdp->brdnr = i;
4647 brdp->brdtype = confp->brdtype; 4154 brdp->brdtype = confp->brdtype;
4648 brdp->iobase = confp->ioaddr1; 4155 brdp->iobase = confp->ioaddr1;
@@ -4654,9 +4161,7 @@ static int stli_initbrds(void)
4654 * Static configuration table done, so now use dynamic methods to 4161 * Static configuration table done, so now use dynamic methods to
4655 * see if any more boards should be configured. 4162 * see if any more boards should be configured.
4656 */ 4163 */
4657#ifdef MODULE
4658 stli_argbrds(); 4164 stli_argbrds();
4659#endif
4660 if (STLI_EISAPROBE) 4165 if (STLI_EISAPROBE)
4661 stli_findeisabrds(); 4166 stli_findeisabrds();
4662#ifdef CONFIG_PCI 4167#ifdef CONFIG_PCI
@@ -4672,11 +4177,11 @@ static int stli_initbrds(void)
4672 if (stli_nrbrds > 1) { 4177 if (stli_nrbrds > 1) {
4673 for (i = 0; (i < stli_nrbrds); i++) { 4178 for (i = 0; (i < stli_nrbrds); i++) {
4674 brdp = stli_brds[i]; 4179 brdp = stli_brds[i];
4675 if (brdp == (stlibrd_t *) NULL) 4180 if (brdp == NULL)
4676 continue; 4181 continue;
4677 for (j = i + 1; (j < stli_nrbrds); j++) { 4182 for (j = i + 1; (j < stli_nrbrds); j++) {
4678 nxtbrdp = stli_brds[j]; 4183 nxtbrdp = stli_brds[j];
4679 if (nxtbrdp == (stlibrd_t *) NULL) 4184 if (nxtbrdp == NULL)
4680 continue; 4185 continue;
4681 if ((brdp->membase >= nxtbrdp->membase) && 4186 if ((brdp->membase >= nxtbrdp->membase) &&
4682 (brdp->membase <= (nxtbrdp->membase + 4187 (brdp->membase <= (nxtbrdp->membase +
@@ -4691,7 +4196,7 @@ static int stli_initbrds(void)
4691 if (stli_shared == 0) { 4196 if (stli_shared == 0) {
4692 for (i = 0; (i < stli_nrbrds); i++) { 4197 for (i = 0; (i < stli_nrbrds); i++) {
4693 brdp = stli_brds[i]; 4198 brdp = stli_brds[i];
4694 if (brdp == (stlibrd_t *) NULL) 4199 if (brdp == NULL)
4695 continue; 4200 continue;
4696 if (brdp->state & BST_FOUND) { 4201 if (brdp->state & BST_FOUND) {
4697 EBRDENABLE(brdp); 4202 EBRDENABLE(brdp);
@@ -4701,7 +4206,7 @@ static int stli_initbrds(void)
4701 } 4206 }
4702 } 4207 }
4703 4208
4704 return(0); 4209 return 0;
4705} 4210}
4706 4211
4707/*****************************************************************************/ 4212/*****************************************************************************/
@@ -4714,48 +4219,55 @@ static int stli_initbrds(void)
4714 4219
4715static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) 4220static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp)
4716{ 4221{
4717 unsigned long flags; 4222 unsigned long flags;
4718 void *memptr; 4223 void *memptr;
4719 stlibrd_t *brdp; 4224 stlibrd_t *brdp;
4720 int brdnr, size, n; 4225 int brdnr, size, n;
4721 4226 void *p;
4722#ifdef DEBUG 4227 loff_t off = *offp;
4723 printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
4724 (int) fp, (int) buf, count, (int) offp);
4725#endif
4726 4228
4727 brdnr = iminor(fp->f_dentry->d_inode); 4229 brdnr = iminor(fp->f_dentry->d_inode);
4728 if (brdnr >= stli_nrbrds) 4230 if (brdnr >= stli_nrbrds)
4729 return(-ENODEV); 4231 return -ENODEV;
4730 brdp = stli_brds[brdnr]; 4232 brdp = stli_brds[brdnr];
4731 if (brdp == (stlibrd_t *) NULL) 4233 if (brdp == NULL)
4732 return(-ENODEV); 4234 return -ENODEV;
4733 if (brdp->state == 0) 4235 if (brdp->state == 0)
4734 return(-ENODEV); 4236 return -ENODEV;
4735 if (fp->f_pos >= brdp->memsize) 4237 if (off >= brdp->memsize || off + count < off)
4736 return(0); 4238 return 0;
4737 4239
4738 size = MIN(count, (brdp->memsize - fp->f_pos)); 4240 size = MIN(count, (brdp->memsize - off));
4241
4242 /*
4243 * Copy the data a page at a time
4244 */
4245
4246 p = (void *)__get_free_page(GFP_KERNEL);
4247 if(p == NULL)
4248 return -ENOMEM;
4739 4249
4740 save_flags(flags);
4741 cli();
4742 EBRDENABLE(brdp);
4743 while (size > 0) { 4250 while (size > 0) {
4744 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4251 spin_lock_irqsave(&brd_lock, flags);
4745 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4252 EBRDENABLE(brdp);
4746 if (copy_to_user(buf, memptr, n)) { 4253 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4254 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4255 n = MIN(n, PAGE_SIZE);
4256 memcpy_fromio(p, memptr, n);
4257 EBRDDISABLE(brdp);
4258 spin_unlock_irqrestore(&brd_lock, flags);
4259 if (copy_to_user(buf, p, n)) {
4747 count = -EFAULT; 4260 count = -EFAULT;
4748 goto out; 4261 goto out;
4749 } 4262 }
4750 fp->f_pos += n; 4263 off += n;
4751 buf += n; 4264 buf += n;
4752 size -= n; 4265 size -= n;
4753 } 4266 }
4754out: 4267out:
4755 EBRDDISABLE(brdp); 4268 *offp = off;
4756 restore_flags(flags); 4269 free_page((unsigned long)p);
4757 4270 return count;
4758 return(count);
4759} 4271}
4760 4272
4761/*****************************************************************************/ 4273/*****************************************************************************/
@@ -4764,54 +4276,65 @@ out:
4764 * Code to handle an "staliomem" write operation. This device is the 4276 * Code to handle an "staliomem" write operation. This device is the
4765 * contents of the board shared memory. It is used for down loading 4277 * contents of the board shared memory. It is used for down loading
4766 * the slave image (and debugging :-) 4278 * the slave image (and debugging :-)
4279 *
4280 * FIXME: copy under lock
4767 */ 4281 */
4768 4282
4769static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) 4283static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp)
4770{ 4284{
4771 unsigned long flags; 4285 unsigned long flags;
4772 void *memptr; 4286 void *memptr;
4773 stlibrd_t *brdp; 4287 stlibrd_t *brdp;
4774 char __user *chbuf; 4288 char __user *chbuf;
4775 int brdnr, size, n; 4289 int brdnr, size, n;
4776 4290 void *p;
4777#ifdef DEBUG 4291 loff_t off = *offp;
4778 printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
4779 (int) fp, (int) buf, count, (int) offp);
4780#endif
4781 4292
4782 brdnr = iminor(fp->f_dentry->d_inode); 4293 brdnr = iminor(fp->f_dentry->d_inode);
4294
4783 if (brdnr >= stli_nrbrds) 4295 if (brdnr >= stli_nrbrds)
4784 return(-ENODEV); 4296 return -ENODEV;
4785 brdp = stli_brds[brdnr]; 4297 brdp = stli_brds[brdnr];
4786 if (brdp == (stlibrd_t *) NULL) 4298 if (brdp == NULL)
4787 return(-ENODEV); 4299 return -ENODEV;
4788 if (brdp->state == 0) 4300 if (brdp->state == 0)
4789 return(-ENODEV); 4301 return -ENODEV;
4790 if (fp->f_pos >= brdp->memsize) 4302 if (off >= brdp->memsize || off + count < off)
4791 return(0); 4303 return 0;
4792 4304
4793 chbuf = (char __user *) buf; 4305 chbuf = (char __user *) buf;
4794 size = MIN(count, (brdp->memsize - fp->f_pos)); 4306 size = MIN(count, (brdp->memsize - off));
4307
4308 /*
4309 * Copy the data a page at a time
4310 */
4311
4312 p = (void *)__get_free_page(GFP_KERNEL);
4313 if(p == NULL)
4314 return -ENOMEM;
4795 4315
4796 save_flags(flags);
4797 cli();
4798 EBRDENABLE(brdp);
4799 while (size > 0) { 4316 while (size > 0) {
4800 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4317 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4801 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4318 n = MIN(n, PAGE_SIZE);
4802 if (copy_from_user(memptr, chbuf, n)) { 4319 if (copy_from_user(p, chbuf, n)) {
4803 count = -EFAULT; 4320 if (count == 0)
4321 count = -EFAULT;
4804 goto out; 4322 goto out;
4805 } 4323 }
4806 fp->f_pos += n; 4324 spin_lock_irqsave(&brd_lock, flags);
4325 EBRDENABLE(brdp);
4326 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4327 memcpy_toio(memptr, p, n);
4328 EBRDDISABLE(brdp);
4329 spin_unlock_irqrestore(&brd_lock, flags);
4330 off += n;
4807 chbuf += n; 4331 chbuf += n;
4808 size -= n; 4332 size -= n;
4809 } 4333 }
4810out: 4334out:
4811 EBRDDISABLE(brdp); 4335 free_page((unsigned long) p);
4812 restore_flags(flags); 4336 *offp = off;
4813 4337 return count;
4814 return(count);
4815} 4338}
4816 4339
4817/*****************************************************************************/ 4340/*****************************************************************************/
@@ -4822,16 +4345,16 @@ out:
4822 4345
4823static int stli_getbrdstats(combrd_t __user *bp) 4346static int stli_getbrdstats(combrd_t __user *bp)
4824{ 4347{
4825 stlibrd_t *brdp; 4348 stlibrd_t *brdp;
4826 int i; 4349 int i;
4827 4350
4828 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) 4351 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
4829 return -EFAULT; 4352 return -EFAULT;
4830 if (stli_brdstats.brd >= STL_MAXBRDS) 4353 if (stli_brdstats.brd >= STL_MAXBRDS)
4831 return(-ENODEV); 4354 return -ENODEV;
4832 brdp = stli_brds[stli_brdstats.brd]; 4355 brdp = stli_brds[stli_brdstats.brd];
4833 if (brdp == (stlibrd_t *) NULL) 4356 if (brdp == NULL)
4834 return(-ENODEV); 4357 return -ENODEV;
4835 4358
4836 memset(&stli_brdstats, 0, sizeof(combrd_t)); 4359 memset(&stli_brdstats, 0, sizeof(combrd_t));
4837 stli_brdstats.brd = brdp->brdnr; 4360 stli_brdstats.brd = brdp->brdnr;
@@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
4850 4373
4851 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) 4374 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t)))
4852 return -EFAULT; 4375 return -EFAULT;
4853 return(0); 4376 return 0;
4854} 4377}
4855 4378
4856/*****************************************************************************/ 4379/*****************************************************************************/
@@ -4861,19 +4384,19 @@ static int stli_getbrdstats(combrd_t __user *bp)
4861 4384
4862static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) 4385static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
4863{ 4386{
4864 stlibrd_t *brdp; 4387 stlibrd_t *brdp;
4865 int i; 4388 int i;
4866 4389
4867 if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) 4390 if (brdnr < 0 || brdnr >= STL_MAXBRDS)
4868 return((stliport_t *) NULL); 4391 return NULL;
4869 brdp = stli_brds[brdnr]; 4392 brdp = stli_brds[brdnr];
4870 if (brdp == (stlibrd_t *) NULL) 4393 if (brdp == NULL)
4871 return((stliport_t *) NULL); 4394 return NULL;
4872 for (i = 0; (i < panelnr); i++) 4395 for (i = 0; (i < panelnr); i++)
4873 portnr += brdp->panels[i]; 4396 portnr += brdp->panels[i];
4874 if ((portnr < 0) || (portnr >= brdp->nrports)) 4397 if ((portnr < 0) || (portnr >= brdp->nrports))
4875 return((stliport_t *) NULL); 4398 return NULL;
4876 return(brdp->ports[portnr]); 4399 return brdp->ports[portnr];
4877} 4400}
4878 4401
4879/*****************************************************************************/ 4402/*****************************************************************************/
@@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp)
4892 4415
4893 memset(&stli_comstats, 0, sizeof(comstats_t)); 4416 memset(&stli_comstats, 0, sizeof(comstats_t));
4894 4417
4895 if (portp == (stliport_t *) NULL) 4418 if (portp == NULL)
4896 return(-ENODEV); 4419 return -ENODEV;
4897 brdp = stli_brds[portp->brdnr]; 4420 brdp = stli_brds[portp->brdnr];
4898 if (brdp == (stlibrd_t *) NULL) 4421 if (brdp == NULL)
4899 return(-ENODEV); 4422 return -ENODEV;
4900 4423
4901 if (brdp->state & BST_STARTED) { 4424 if (brdp->state & BST_STARTED) {
4902 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, 4425 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
4903 &stli_cdkstats, sizeof(asystats_t), 1)) < 0) 4426 &stli_cdkstats, sizeof(asystats_t), 1)) < 0)
4904 return(rc); 4427 return rc;
4905 } else { 4428 } else {
4906 memset(&stli_cdkstats, 0, sizeof(asystats_t)); 4429 memset(&stli_cdkstats, 0, sizeof(asystats_t));
4907 } 4430 }
@@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp)
4912 stli_comstats.state = portp->state; 4435 stli_comstats.state = portp->state;
4913 stli_comstats.flags = portp->flags; 4436 stli_comstats.flags = portp->flags;
4914 4437
4915 save_flags(flags); 4438 spin_lock_irqsave(&brd_lock, flags);
4916 cli(); 4439 if (portp->tty != NULL) {
4917 if (portp->tty != (struct tty_struct *) NULL) {
4918 if (portp->tty->driver_data == portp) { 4440 if (portp->tty->driver_data == portp) {
4919 stli_comstats.ttystate = portp->tty->flags; 4441 stli_comstats.ttystate = portp->tty->flags;
4920 stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; 4442 stli_comstats.rxbuffered = -1;
4921 if (portp->tty->termios != (struct termios *) NULL) { 4443 if (portp->tty->termios != NULL) {
4922 stli_comstats.cflags = portp->tty->termios->c_cflag; 4444 stli_comstats.cflags = portp->tty->termios->c_cflag;
4923 stli_comstats.iflags = portp->tty->termios->c_iflag; 4445 stli_comstats.iflags = portp->tty->termios->c_iflag;
4924 stli_comstats.oflags = portp->tty->termios->c_oflag; 4446 stli_comstats.oflags = portp->tty->termios->c_oflag;
@@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp)
4926 } 4448 }
4927 } 4449 }
4928 } 4450 }
4929 restore_flags(flags); 4451 spin_unlock_irqrestore(&brd_lock, flags);
4930 4452
4931 stli_comstats.txtotal = stli_cdkstats.txchars; 4453 stli_comstats.txtotal = stli_cdkstats.txchars;
4932 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; 4454 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;
@@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp)
4948 stli_comstats.hwid = stli_cdkstats.hwid; 4470 stli_comstats.hwid = stli_cdkstats.hwid;
4949 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); 4471 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals);
4950 4472
4951 return(0); 4473 return 0;
4952} 4474}
4953 4475
4954/*****************************************************************************/ 4476/*****************************************************************************/
@@ -4961,8 +4483,8 @@ static int stli_portcmdstats(stliport_t *portp)
4961 4483
4962static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) 4484static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4963{ 4485{
4964 stlibrd_t *brdp; 4486 stlibrd_t *brdp;
4965 int rc; 4487 int rc;
4966 4488
4967 if (!portp) { 4489 if (!portp) {
4968 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4490 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -4992,8 +4514,8 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4992 4514
4993static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) 4515static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
4994{ 4516{
4995 stlibrd_t *brdp; 4517 stlibrd_t *brdp;
4996 int rc; 4518 int rc;
4997 4519
4998 if (!portp) { 4520 if (!portp) {
4999 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4521 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -5031,7 +4553,7 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
5031 4553
5032static int stli_getportstruct(stliport_t __user *arg) 4554static int stli_getportstruct(stliport_t __user *arg)
5033{ 4555{
5034 stliport_t *portp; 4556 stliport_t *portp;
5035 4557
5036 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) 4558 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t)))
5037 return -EFAULT; 4559 return -EFAULT;
@@ -5052,7 +4574,7 @@ static int stli_getportstruct(stliport_t __user *arg)
5052 4574
5053static int stli_getbrdstruct(stlibrd_t __user *arg) 4575static int stli_getbrdstruct(stlibrd_t __user *arg)
5054{ 4576{
5055 stlibrd_t *brdp; 4577 stlibrd_t *brdp;
5056 4578
5057 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) 4579 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t)))
5058 return -EFAULT; 4580 return -EFAULT;
@@ -5076,15 +4598,10 @@ static int stli_getbrdstruct(stlibrd_t __user *arg)
5076 4598
5077static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) 4599static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
5078{ 4600{
5079 stlibrd_t *brdp; 4601 stlibrd_t *brdp;
5080 int brdnr, rc, done; 4602 int brdnr, rc, done;
5081 void __user *argp = (void __user *)arg; 4603 void __user *argp = (void __user *)arg;
5082 4604
5083#ifdef DEBUG
5084 printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n",
5085 (int) ip, (int) fp, cmd, (int) arg);
5086#endif
5087
5088/* 4605/*
5089 * First up handle the board independent ioctls. 4606 * First up handle the board independent ioctls.
5090 */ 4607 */
@@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5115 } 4632 }
5116 4633
5117 if (done) 4634 if (done)
5118 return(rc); 4635 return rc;
5119 4636
5120/* 4637/*
5121 * Now handle the board specific ioctls. These all depend on the 4638 * Now handle the board specific ioctls. These all depend on the
@@ -5123,12 +4640,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5123 */ 4640 */
5124 brdnr = iminor(ip); 4641 brdnr = iminor(ip);
5125 if (brdnr >= STL_MAXBRDS) 4642 if (brdnr >= STL_MAXBRDS)
5126 return(-ENODEV); 4643 return -ENODEV;
5127 brdp = stli_brds[brdnr]; 4644 brdp = stli_brds[brdnr];
5128 if (!brdp) 4645 if (!brdp)
5129 return(-ENODEV); 4646 return -ENODEV;
5130 if (brdp->state == 0) 4647 if (brdp->state == 0)
5131 return(-ENODEV); 4648 return -ENODEV;
5132 4649
5133 switch (cmd) { 4650 switch (cmd) {
5134 case STL_BINTR: 4651 case STL_BINTR:
@@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5152 rc = -ENOIOCTLCMD; 4669 rc = -ENOIOCTLCMD;
5153 break; 4670 break;
5154 } 4671 }
5155 4672 return rc;
5156 return(rc);
5157} 4673}
5158 4674
5159static struct tty_operations stli_ops = { 4675static struct tty_operations stli_ops = {
@@ -5187,6 +4703,9 @@ int __init stli_init(void)
5187 int i; 4703 int i;
5188 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); 4704 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
5189 4705
4706 spin_lock_init(&stli_lock);
4707 spin_lock_init(&brd_lock);
4708
5190 stli_initbrds(); 4709 stli_initbrds();
5191 4710
5192 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 4711 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -5196,10 +4715,6 @@ int __init stli_init(void)
5196/* 4715/*
5197 * Allocate a temporary write buffer. 4716 * Allocate a temporary write buffer.
5198 */ 4717 */
5199 stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5200 if (!stli_tmpwritebuf)
5201 printk(KERN_ERR "STALLION: failed to allocate memory "
5202 "(size=%d)\n", STLI_TXBUFSIZE);
5203 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); 4718 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5204 if (!stli_txcookbuf) 4719 if (!stli_txcookbuf)
5205 printk(KERN_ERR "STALLION: failed to allocate memory " 4720 printk(KERN_ERR "STALLION: failed to allocate memory "
@@ -5243,7 +4758,7 @@ int __init stli_init(void)
5243 printk(KERN_ERR "STALLION: failed to register serial driver\n"); 4758 printk(KERN_ERR "STALLION: failed to register serial driver\n");
5244 return -EBUSY; 4759 return -EBUSY;
5245 } 4760 }
5246 return(0); 4761 return 0;
5247} 4762}
5248 4763
5249/*****************************************************************************/ 4764/*****************************************************************************/
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 5755b7e5f187..4bb3d2272604 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -39,6 +39,7 @@
39#include <linux/vt_kern.h> 39#include <linux/vt_kern.h>
40#include <linux/sysrq.h> 40#include <linux/sysrq.h>
41#include <linux/input.h> 41#include <linux/input.h>
42#include <linux/reboot.h>
42 43
43static void kbd_disconnect(struct input_handle *handle); 44static void kbd_disconnect(struct input_handle *handle);
44extern void ctrl_alt_del(void); 45extern void ctrl_alt_del(void);
@@ -150,6 +151,7 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 1] =
150 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ 151 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
151 "\r\000/"; /* 0x60 - 0x6f */ 152 "\r\000/"; /* 0x60 - 0x6f */
152static int sysrq_down; 153static int sysrq_down;
154static int sysrq_alt_use;
153#endif 155#endif
154static int sysrq_alt; 156static int sysrq_alt;
155 157
@@ -672,7 +674,7 @@ static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struc
672 */ 674 */
673static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 675static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
674{ 676{
675 static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; 677 static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
676 value = ret_diacr[value]; 678 value = ret_diacr[value];
677 k_deadunicode(vc, value, up_flag, regs); 679 k_deadunicode(vc, value, up_flag, regs);
678} 680}
@@ -709,8 +711,8 @@ static void k_cur(struct vc_data *vc, unsigned char value, char up_flag, struct
709 711
710static void k_pad(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 712static void k_pad(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
711{ 713{
712 static const char *pad_chars = "0123456789+-*/\015,.?()#"; 714 static const char pad_chars[] = "0123456789+-*/\015,.?()#";
713 static const char *app_map = "pqrstuvwxylSRQMnnmPQS"; 715 static const char app_map[] = "pqrstuvwxylSRQMnnmPQS";
714 716
715 if (up_flag) 717 if (up_flag)
716 return; /* no action, if this is a key release */ 718 return; /* no action, if this is a key release */
@@ -1035,7 +1037,7 @@ static void kbd_refresh_leds(struct input_handle *handle)
1035#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\ 1037#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
1036 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001)) 1038 ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
1037 1039
1038static unsigned short x86_keycodes[256] = 1040static const unsigned short x86_keycodes[256] =
1039 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1041 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1040 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 1042 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1041 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 1043 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
@@ -1073,11 +1075,13 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
1073 put_queue(vc, 0x1d | up_flag); 1075 put_queue(vc, 0x1d | up_flag);
1074 put_queue(vc, 0x45 | up_flag); 1076 put_queue(vc, 0x45 | up_flag);
1075 return 0; 1077 return 0;
1076 case KEY_HANGUEL: 1078 case KEY_HANGEUL:
1077 if (!up_flag) put_queue(vc, 0xf1); 1079 if (!up_flag)
1080 put_queue(vc, 0xf2);
1078 return 0; 1081 return 0;
1079 case KEY_HANJA: 1082 case KEY_HANJA:
1080 if (!up_flag) put_queue(vc, 0xf2); 1083 if (!up_flag)
1084 put_queue(vc, 0xf1);
1081 return 0; 1085 return 0;
1082 } 1086 }
1083 1087
@@ -1142,7 +1146,7 @@ static void kbd_keycode(unsigned int keycode, int down,
1142 kbd = kbd_table + fg_console; 1146 kbd = kbd_table + fg_console;
1143 1147
1144 if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT) 1148 if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
1145 sysrq_alt = down; 1149 sysrq_alt = down ? keycode : 0;
1146#ifdef CONFIG_SPARC 1150#ifdef CONFIG_SPARC
1147 if (keycode == KEY_STOP) 1151 if (keycode == KEY_STOP)
1148 sparc_l1_a_state = down; 1152 sparc_l1_a_state = down;
@@ -1162,9 +1166,14 @@ static void kbd_keycode(unsigned int keycode, int down,
1162 1166
1163#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */ 1167#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
1164 if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) { 1168 if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
1165 sysrq_down = down; 1169 if (!sysrq_down) {
1170 sysrq_down = down;
1171 sysrq_alt_use = sysrq_alt;
1172 }
1166 return; 1173 return;
1167 } 1174 }
1175 if (sysrq_down && !down && keycode == sysrq_alt_use)
1176 sysrq_down = 0;
1168 if (sysrq_down && down && !rep) { 1177 if (sysrq_down && down && !rep) {
1169 handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty); 1178 handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
1170 return; 1179 return;
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 1b05fa688996..d65b3109318a 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -329,7 +329,6 @@ static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma)
329 if (PAGE_SIZE > (1 << 16)) 329 if (PAGE_SIZE > (1 << 16))
330 return -ENOSYS; 330 return -ENOSYS;
331 331
332 vma->vm_flags |= (VM_IO | VM_SHM | VM_LOCKED );
333 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 332 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
334 333
335 mmtimer_addr = __pa(RTC_COUNTER_ADDR); 334 mmtimer_addr = __pa(RTC_COUNTER_ADDR);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index f43c2e04eadd..01247cccb89f 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -301,7 +301,7 @@ static struct tty_operations moxa_ops = {
301 .tiocmset = moxa_tiocmset, 301 .tiocmset = moxa_tiocmset,
302}; 302};
303 303
304static spinlock_t moxa_lock = SPIN_LOCK_UNLOCKED; 304static DEFINE_SPINLOCK(moxa_lock);
305 305
306#ifdef CONFIG_PCI 306#ifdef CONFIG_PCI
307static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board) 307static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board)
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 0fb2fb9fb024..72cfd09091e0 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -9,7 +9,7 @@
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
12* (at your option) any later version. 12 * (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -71,8 +71,8 @@
71#define MXSERMAJOR 174 71#define MXSERMAJOR 174
72#define MXSERCUMAJOR 175 72#define MXSERCUMAJOR 175
73 73
74#define MXSER_EVENT_TXLOW 1 74#define MXSER_EVENT_TXLOW 1
75#define MXSER_EVENT_HANGUP 2 75#define MXSER_EVENT_HANGUP 2
76 76
77#define MXSER_BOARDS 4 /* Max. boards */ 77#define MXSER_BOARDS 4 /* Max. boards */
78#define MXSER_PORTS 32 /* Max. ports */ 78#define MXSER_PORTS 32 /* Max. ports */
@@ -92,7 +92,8 @@
92#define UART_MCR_AFE 0x20 92#define UART_MCR_AFE 0x20
93#define UART_LSR_SPECIAL 0x1E 93#define UART_LSR_SPECIAL 0x1E
94 94
95#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|IXON|IXOFF)) 95#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|\
96 IXON|IXOFF))
96 97
97#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT) 98#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
98 99
@@ -152,27 +153,27 @@ static char *mxser_brdname[] = {
152}; 153};
153 154
154static int mxser_numports[] = { 155static int mxser_numports[] = {
155 8, // C168-ISA 156 8, /* C168-ISA */
156 4, // C104-ISA 157 4, /* C104-ISA */
157 4, // CI104J 158 4, /* CI104J */
158 8, // C168-PCI 159 8, /* C168-PCI */
159 4, // C104-PCI 160 4, /* C104-PCI */
160 2, // C102-ISA 161 2, /* C102-ISA */
161 2, // CI132 162 2, /* CI132 */
162 4, // CI134 163 4, /* CI134 */
163 2, // CP132 164 2, /* CP132 */
164 4, // CP114 165 4, /* CP114 */
165 4, // CT114 166 4, /* CT114 */
166 2, // CP102 167 2, /* CP102 */
167 4, // CP104U 168 4, /* CP104U */
168 8, // CP168U 169 8, /* CP168U */
169 2, // CP132U 170 2, /* CP132U */
170 4, // CP134U 171 4, /* CP134U */
171 4, // CP104JU 172 4, /* CP104JU */
172 8, // RC7000 173 8, /* RC7000 */
173 8, // CP118U 174 8, /* CP118U */
174 2, // CP102UL 175 2, /* CP102UL */
175 2, // CP102U 176 2, /* CP102U */
176}; 177};
177 178
178#define UART_TYPE_NUM 2 179#define UART_TYPE_NUM 2
@@ -182,7 +183,7 @@ static const unsigned int Gmoxa_uart_id[UART_TYPE_NUM] = {
182 MOXA_MUST_MU860_HWID 183 MOXA_MUST_MU860_HWID
183}; 184};
184 185
185// This is only for PCI 186/* This is only for PCI */
186#define UART_INFO_NUM 3 187#define UART_INFO_NUM 3
187struct mxpciuart_info { 188struct mxpciuart_info {
188 int type; 189 int type;
@@ -231,7 +232,7 @@ MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
231typedef struct _moxa_pci_info { 232typedef struct _moxa_pci_info {
232 unsigned short busNum; 233 unsigned short busNum;
233 unsigned short devNum; 234 unsigned short devNum;
234 struct pci_dev *pdev; // add by Victor Yu. 06-23-2003 235 struct pci_dev *pdev; /* add by Victor Yu. 06-23-2003 */
235} moxa_pci_info; 236} moxa_pci_info;
236 237
237static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 }; 238static int ioaddr[MXSER_BOARDS] = { 0, 0, 0, 0 };
@@ -280,6 +281,7 @@ struct mxser_mon_ext {
280 int fifo[32]; 281 int fifo[32];
281 int iftype[32]; 282 int iftype[32];
282}; 283};
284
283struct mxser_hwconf { 285struct mxser_hwconf {
284 int board_type; 286 int board_type;
285 int ports; 287 int ports;
@@ -290,9 +292,9 @@ struct mxser_hwconf {
290 int ioaddr[MXSER_PORTS_PER_BOARD]; 292 int ioaddr[MXSER_PORTS_PER_BOARD];
291 int baud_base[MXSER_PORTS_PER_BOARD]; 293 int baud_base[MXSER_PORTS_PER_BOARD];
292 moxa_pci_info pciInfo; 294 moxa_pci_info pciInfo;
293 int IsMoxaMustChipFlag; // add by Victor Yu. 08-30-2002 295 int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */
294 int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; // add by Victor Yu. 09-04-2002 296 int MaxCanSetBaudRate[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 09-04-2002 */
295 int opmode_ioaddr[MXSER_PORTS_PER_BOARD]; // add by Victor Yu. 01-05-2004 297 int opmode_ioaddr[MXSER_PORTS_PER_BOARD]; /* add by Victor Yu. 01-05-2004 */
296}; 298};
297 299
298struct mxser_struct { 300struct mxser_struct {
@@ -334,9 +336,9 @@ struct mxser_struct {
334 wait_queue_head_t delta_msr_wait; 336 wait_queue_head_t delta_msr_wait;
335 struct async_icount icount; /* kernel counters for the 4 input interrupts */ 337 struct async_icount icount; /* kernel counters for the 4 input interrupts */
336 int timeout; 338 int timeout;
337 int IsMoxaMustChipFlag; // add by Victor Yu. 08-30-2002 339 int IsMoxaMustChipFlag; /* add by Victor Yu. 08-30-2002 */
338 int MaxCanSetBaudRate; // add by Victor Yu. 09-04-2002 340 int MaxCanSetBaudRate; /* add by Victor Yu. 09-04-2002 */
339 int opmode_ioaddr; // add by Victor Yu. 01-05-2004 341 int opmode_ioaddr; /* add by Victor Yu. 01-05-2004 */
340 unsigned char stop_rx; 342 unsigned char stop_rx;
341 unsigned char ldisc_stop_rx; 343 unsigned char ldisc_stop_rx;
342 long realbaud; 344 long realbaud;
@@ -345,7 +347,6 @@ struct mxser_struct {
345 spinlock_t slock; 347 spinlock_t slock;
346}; 348};
347 349
348
349struct mxser_mstatus { 350struct mxser_mstatus {
350 tcflag_t cflag; 351 tcflag_t cflag;
351 int cts; 352 int cts;
@@ -358,7 +359,7 @@ static struct mxser_mstatus GMStatus[MXSER_PORTS];
358 359
359static int mxserBoardCAP[MXSER_BOARDS] = { 360static int mxserBoardCAP[MXSER_BOARDS] = {
360 0, 0, 0, 0 361 0, 0, 0, 0
361 /* 0x180, 0x280, 0x200, 0x320 */ 362 /* 0x180, 0x280, 0x200, 0x320 */
362}; 363};
363 364
364static struct tty_driver *mxvar_sdriver; 365static struct tty_driver *mxvar_sdriver;
@@ -386,7 +387,7 @@ static struct mxser_hwconf mxsercfg[MXSER_BOARDS];
386static void mxser_getcfg(int board, struct mxser_hwconf *hwconf); 387static void mxser_getcfg(int board, struct mxser_hwconf *hwconf);
387static int mxser_init(void); 388static int mxser_init(void);
388 389
389//static void mxser_poll(unsigned long); 390/* static void mxser_poll(unsigned long); */
390static int mxser_get_ISA_conf(int, struct mxser_hwconf *); 391static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); 392static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
392static void mxser_do_softint(void *); 393static void mxser_do_softint(void *);
@@ -440,18 +441,18 @@ static int CheckIsMoxaMust(int io)
440 SET_MOXA_MUST_XON1_VALUE(io, 0x11); 441 SET_MOXA_MUST_XON1_VALUE(io, 0x11);
441 if ((hwid = inb(io + UART_MCR)) != 0) { 442 if ((hwid = inb(io + UART_MCR)) != 0) {
442 outb(oldmcr, io + UART_MCR); 443 outb(oldmcr, io + UART_MCR);
443 return (MOXA_OTHER_UART); 444 return MOXA_OTHER_UART;
444 } 445 }
445 446
446 GET_MOXA_MUST_HARDWARE_ID(io, &hwid); 447 GET_MOXA_MUST_HARDWARE_ID(io, &hwid);
447 for (i = 0; i < UART_TYPE_NUM; i++) { 448 for (i = 0; i < UART_TYPE_NUM; i++) {
448 if (hwid == Gmoxa_uart_id[i]) 449 if (hwid == Gmoxa_uart_id[i])
449 return (int) hwid; 450 return (int)hwid;
450 } 451 }
451 return MOXA_OTHER_UART; 452 return MOXA_OTHER_UART;
452} 453}
453 454
454// above is modified by Victor Yu. 08-15-2002 455/* above is modified by Victor Yu. 08-15-2002 */
455 456
456static struct tty_operations mxser_ops = { 457static struct tty_operations mxser_ops = {
457 .open = mxser_open, 458 .open = mxser_open,
@@ -504,7 +505,6 @@ static void __exit mxser_module_exit(void)
504 else 505 else
505 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); 506 printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n");
506 507
507
508 for (i = 0; i < MXSER_BOARDS; i++) { 508 for (i = 0; i < MXSER_BOARDS; i++) {
509 struct pci_dev *pdev; 509 struct pci_dev *pdev;
510 510
@@ -513,7 +513,7 @@ static void __exit mxser_module_exit(void)
513 else { 513 else {
514 pdev = mxsercfg[i].pciInfo.pdev; 514 pdev = mxsercfg[i].pciInfo.pdev;
515 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); 515 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);
516 if (pdev != NULL) { //PCI 516 if (pdev != NULL) { /* PCI */
517 release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); 517 release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
518 release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); 518 release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3));
519 } else { 519 } else {
@@ -524,7 +524,6 @@ static void __exit mxser_module_exit(void)
524 } 524 }
525 if (verbose) 525 if (verbose)
526 printk(KERN_DEBUG "Done.\n"); 526 printk(KERN_DEBUG "Done.\n");
527
528} 527}
529 528
530static void process_txrx_fifo(struct mxser_struct *info) 529static void process_txrx_fifo(struct mxser_struct *info)
@@ -558,8 +557,10 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
558 n = board * MXSER_PORTS_PER_BOARD; 557 n = board * MXSER_PORTS_PER_BOARD;
559 info = &mxvar_table[n]; 558 info = &mxvar_table[n];
560 /*if (verbose) */ { 559 /*if (verbose) */ {
561 printk(KERN_DEBUG " ttyM%d - ttyM%d ", n, n + hwconf->ports - 1); 560 printk(KERN_DEBUG " ttyM%d - ttyM%d ",
562 printk(" max. baud rate = %d bps.\n", hwconf->MaxCanSetBaudRate[0]); 561 n, n + hwconf->ports - 1);
562 printk(" max. baud rate = %d bps.\n",
563 hwconf->MaxCanSetBaudRate[0]);
563 } 564 }
564 565
565 for (i = 0; i < hwconf->ports; i++, n++, info++) { 566 for (i = 0; i < hwconf->ports; i++, n++, info++) {
@@ -568,12 +569,12 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
568 info->irq = hwconf->irq; 569 info->irq = hwconf->irq;
569 info->vector = hwconf->vector; 570 info->vector = hwconf->vector;
570 info->vectormask = hwconf->vector_mask; 571 info->vectormask = hwconf->vector_mask;
571 info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; // add by Victor Yu. 01-05-2004 572 info->opmode_ioaddr = hwconf->opmode_ioaddr[i]; /* add by Victor Yu. 01-05-2004 */
572 info->stop_rx = 0; 573 info->stop_rx = 0;
573 info->ldisc_stop_rx = 0; 574 info->ldisc_stop_rx = 0;
574 575
575 info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag; 576 info->IsMoxaMustChipFlag = hwconf->IsMoxaMustChipFlag;
576 //Enhance mode enabled here 577 /* Enhance mode enabled here */
577 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { 578 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) {
578 ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base); 579 ENABLE_MOXA_MUST_ENCHANCE_MODE(info->base);
579 } 580 }
@@ -606,22 +607,25 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
606 607
607 /* before set INT ISR, disable all int */ 608 /* before set INT ISR, disable all int */
608 for (i = 0; i < hwconf->ports; i++) { 609 for (i = 0; i < hwconf->ports; i++) {
609 outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0, hwconf->ioaddr[i] + UART_IER); 610 outb(inb(hwconf->ioaddr[i] + UART_IER) & 0xf0,
611 hwconf->ioaddr[i] + UART_IER);
610 } 612 }
611 613
612 n = board * MXSER_PORTS_PER_BOARD; 614 n = board * MXSER_PORTS_PER_BOARD;
613 info = &mxvar_table[n]; 615 info = &mxvar_table[n];
614 616
615 retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info), "mxser", info); 617 retval = request_irq(hwconf->irq, mxser_interrupt, IRQ_T(info),
618 "mxser", info);
616 if (retval) { 619 if (retval) {
617 printk(KERN_ERR "Board %d: %s", board, mxser_brdname[hwconf->board_type - 1]); 620 printk(KERN_ERR "Board %d: %s",
618 printk(" Request irq fail,IRQ (%d) may be conflit with another device.\n", info->irq); 621 board, mxser_brdname[hwconf->board_type - 1]);
622 printk(" Request irq failed, IRQ (%d) may conflict with"
623 " another device.\n", info->irq);
619 return retval; 624 return retval;
620 } 625 }
621 return 0; 626 return 0;
622} 627}
623 628
624
625static void mxser_getcfg(int board, struct mxser_hwconf *hwconf) 629static void mxser_getcfg(int board, struct mxser_hwconf *hwconf)
626{ 630{
627 mxsercfg[board] = *hwconf; 631 mxsercfg[board] = *hwconf;
@@ -631,26 +635,27 @@ static void mxser_getcfg(int board, struct mxser_hwconf *hwconf)
631static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf) 635static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxser_hwconf *hwconf)
632{ 636{
633 int i, j; 637 int i, j;
634// unsigned int val; 638 /* unsigned int val; */
635 unsigned int ioaddress; 639 unsigned int ioaddress;
636 struct pci_dev *pdev = hwconf->pciInfo.pdev; 640 struct pci_dev *pdev = hwconf->pciInfo.pdev;
637 641
638 //io address 642 /* io address */
639 hwconf->board_type = board_type; 643 hwconf->board_type = board_type;
640 hwconf->ports = mxser_numports[board_type - 1]; 644 hwconf->ports = mxser_numports[board_type - 1];
641 ioaddress = pci_resource_start(pdev, 2); 645 ioaddress = pci_resource_start(pdev, 2);
642 request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), "mxser(IO)"); 646 request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
647 "mxser(IO)");
643 648
644 for (i = 0; i < hwconf->ports; i++) { 649 for (i = 0; i < hwconf->ports; i++)
645 hwconf->ioaddr[i] = ioaddress + 8 * i; 650 hwconf->ioaddr[i] = ioaddress + 8 * i;
646 }
647 651
648 //vector 652 /* vector */
649 ioaddress = pci_resource_start(pdev, 3); 653 ioaddress = pci_resource_start(pdev, 3);
650 request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3), "mxser(vector)"); 654 request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
655 "mxser(vector)");
651 hwconf->vector = ioaddress; 656 hwconf->vector = ioaddress;
652 657
653 //irq 658 /* irq */
654 hwconf->irq = hwconf->pciInfo.pdev->irq; 659 hwconf->irq = hwconf->pciInfo.pdev->irq;
655 660
656 hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]); 661 hwconf->IsMoxaMustChipFlag = CheckIsMoxaMust(hwconf->ioaddr[0]);
@@ -663,7 +668,7 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs
663 if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) { 668 if (Gpci_uart_info[j].type == hwconf->IsMoxaMustChipFlag) {
664 hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud; 669 hwconf->MaxCanSetBaudRate[i] = Gpci_uart_info[j].max_baud;
665 670
666 //exception....CP-102 671 /* exception....CP-102 */
667 if (board_type == MXSER_BOARD_CP102) 672 if (board_type == MXSER_BOARD_CP102)
668 hwconf->MaxCanSetBaudRate[i] = 921600; 673 hwconf->MaxCanSetBaudRate[i] = 921600;
669 break; 674 break;
@@ -678,15 +683,15 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs
678 else 683 else
679 hwconf->opmode_ioaddr[i] = ioaddress + 0x0c; 684 hwconf->opmode_ioaddr[i] = ioaddress + 0x0c;
680 } 685 }
681 outb(0, ioaddress + 4); // default set to RS232 mode 686 outb(0, ioaddress + 4); /* default set to RS232 mode */
682 outb(0, ioaddress + 0x0c); //default set to RS232 mode 687 outb(0, ioaddress + 0x0c); /* default set to RS232 mode */
683 } 688 }
684 689
685 for (i = 0; i < hwconf->ports; i++) { 690 for (i = 0; i < hwconf->ports; i++) {
686 hwconf->vector_mask |= (1 << i); 691 hwconf->vector_mask |= (1 << i);
687 hwconf->baud_base[i] = 921600; 692 hwconf->baud_base[i] = 921600;
688 } 693 }
689 return (0); 694 return 0;
690} 695}
691#endif 696#endif
692 697
@@ -707,7 +712,8 @@ static int mxser_init(void)
707 mxsercfg[i].board_type = -1; 712 mxsercfg[i].board_type = -1;
708 } 713 }
709 714
710 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", MXSER_VERSION); 715 printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n",
716 MXSER_VERSION);
711 717
712 /* Initialize the tty_driver structure */ 718 /* Initialize the tty_driver structure */
713 memset(mxvar_sdriver, 0, sizeof(struct tty_driver)); 719 memset(mxvar_sdriver, 0, sizeof(struct tty_driver));
@@ -719,7 +725,7 @@ static int mxser_init(void)
719 mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL; 725 mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;
720 mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL; 726 mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
721 mxvar_sdriver->init_termios = tty_std_termios; 727 mxvar_sdriver->init_termios = tty_std_termios;
722 mxvar_sdriver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 728 mxvar_sdriver->init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
723 mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW; 729 mxvar_sdriver->flags = TTY_DRIVER_REAL_RAW;
724 tty_set_operations(mxvar_sdriver, &mxser_ops); 730 tty_set_operations(mxvar_sdriver, &mxser_ops);
725 mxvar_sdriver->ttys = mxvar_tty; 731 mxvar_sdriver->ttys = mxvar_tty;
@@ -739,23 +745,29 @@ static int mxser_init(void)
739 /* Start finding ISA boards here */ 745 /* Start finding ISA boards here */
740 for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) { 746 for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) {
741 int cap; 747 int cap;
748
742 if (!(cap = mxserBoardCAP[b])) 749 if (!(cap = mxserBoardCAP[b]))
743 continue; 750 continue;
744 751
745 retval = mxser_get_ISA_conf(cap, &hwconf); 752 retval = mxser_get_ISA_conf(cap, &hwconf);
746 753
747 if (retval != 0) 754 if (retval != 0)
748 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]); 755 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
756 mxser_brdname[hwconf.board_type - 1], ioaddr[b]);
749 757
750 if (retval <= 0) { 758 if (retval <= 0) {
751 if (retval == MXSER_ERR_IRQ) 759 if (retval == MXSER_ERR_IRQ)
752 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 760 printk(KERN_ERR "Invalid interrupt number, "
761 "board not configured\n");
753 else if (retval == MXSER_ERR_IRQ_CONFLIT) 762 else if (retval == MXSER_ERR_IRQ_CONFLIT)
754 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 763 printk(KERN_ERR "Invalid interrupt number, "
764 "board not configured\n");
755 else if (retval == MXSER_ERR_VECTOR) 765 else if (retval == MXSER_ERR_VECTOR)
756 printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); 766 printk(KERN_ERR "Invalid interrupt vector, "
767 "board not configured\n");
757 else if (retval == MXSER_ERR_IOADDR) 768 else if (retval == MXSER_ERR_IOADDR)
758 printk(KERN_ERR "Invalid I/O address,board not configured\n"); 769 printk(KERN_ERR "Invalid I/O address, "
770 "board not configured\n");
759 771
760 continue; 772 continue;
761 } 773 }
@@ -765,35 +777,43 @@ static int mxser_init(void)
765 hwconf.pciInfo.pdev = NULL; 777 hwconf.pciInfo.pdev = NULL;
766 778
767 mxser_getcfg(m, &hwconf); 779 mxser_getcfg(m, &hwconf);
768 //init mxsercfg first, or mxsercfg data is not correct on ISR. 780 /*
769 //mxser_initbrd will hook ISR. 781 * init mxsercfg first,
782 * or mxsercfg data is not correct on ISR.
783 */
784 /* mxser_initbrd will hook ISR. */
770 if (mxser_initbrd(m, &hwconf) < 0) 785 if (mxser_initbrd(m, &hwconf) < 0)
771 continue; 786 continue;
772 787
773
774 m++; 788 m++;
775 } 789 }
776 790
777 /* Start finding ISA boards from module arg */ 791 /* Start finding ISA boards from module arg */
778 for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) { 792 for (b = 0; b < MXSER_BOARDS && m < MXSER_BOARDS; b++) {
779 int cap; 793 int cap;
794
780 if (!(cap = ioaddr[b])) 795 if (!(cap = ioaddr[b]))
781 continue; 796 continue;
782 797
783 retval = mxser_get_ISA_conf(cap, &hwconf); 798 retval = mxser_get_ISA_conf(cap, &hwconf);
784 799
785 if (retval != 0) 800 if (retval != 0)
786 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n", mxser_brdname[hwconf.board_type - 1], ioaddr[b]); 801 printk(KERN_INFO "Found MOXA %s board (CAP=0x%x)\n",
802 mxser_brdname[hwconf.board_type - 1], ioaddr[b]);
787 803
788 if (retval <= 0) { 804 if (retval <= 0) {
789 if (retval == MXSER_ERR_IRQ) 805 if (retval == MXSER_ERR_IRQ)
790 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 806 printk(KERN_ERR "Invalid interrupt number, "
807 "board not configured\n");
791 else if (retval == MXSER_ERR_IRQ_CONFLIT) 808 else if (retval == MXSER_ERR_IRQ_CONFLIT)
792 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 809 printk(KERN_ERR "Invalid interrupt number, "
810 "board not configured\n");
793 else if (retval == MXSER_ERR_VECTOR) 811 else if (retval == MXSER_ERR_VECTOR)
794 printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); 812 printk(KERN_ERR "Invalid interrupt vector, "
813 "board not configured\n");
795 else if (retval == MXSER_ERR_IOADDR) 814 else if (retval == MXSER_ERR_IOADDR)
796 printk(KERN_ERR "Invalid I/O address,board not configured\n"); 815 printk(KERN_ERR "Invalid I/O address, "
816 "board not configured\n");
797 817
798 continue; 818 continue;
799 } 819 }
@@ -803,8 +823,11 @@ static int mxser_init(void)
803 hwconf.pciInfo.pdev = NULL; 823 hwconf.pciInfo.pdev = NULL;
804 824
805 mxser_getcfg(m, &hwconf); 825 mxser_getcfg(m, &hwconf);
806 //init mxsercfg first, or mxsercfg data is not correct on ISR. 826 /*
807 //mxser_initbrd will hook ISR. 827 * init mxsercfg first,
828 * or mxsercfg data is not correct on ISR.
829 */
830 /* mxser_initbrd will hook ISR. */
808 if (mxser_initbrd(m, &hwconf) < 0) 831 if (mxser_initbrd(m, &hwconf) < 0)
809 continue; 832 continue;
810 833
@@ -817,7 +840,8 @@ static int mxser_init(void)
817 index = 0; 840 index = 0;
818 b = 0; 841 b = 0;
819 while (b < n) { 842 while (b < n) {
820 pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev); 843 pdev = pci_find_device(mxser_pcibrds[b].vendor,
844 mxser_pcibrds[b].device, pdev);
821 if (pdev == NULL) { 845 if (pdev == NULL) {
822 b++; 846 b++;
823 continue; 847 continue;
@@ -825,30 +849,48 @@ static int mxser_init(void)
825 hwconf.pciInfo.busNum = busnum = pdev->bus->number; 849 hwconf.pciInfo.busNum = busnum = pdev->bus->number;
826 hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3; 850 hwconf.pciInfo.devNum = devnum = PCI_SLOT(pdev->devfn) << 3;
827 hwconf.pciInfo.pdev = pdev; 851 hwconf.pciInfo.pdev = pdev;
828 printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], busnum, devnum >> 3); 852 printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n",
853 mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1],
854 busnum, devnum >> 3);
829 index++; 855 index++;
830 if (m >= MXSER_BOARDS) { 856 if (m >= MXSER_BOARDS)
831 printk(KERN_ERR "Too many Smartio/Industio family boards find (maximum %d),board not configured\n", MXSER_BOARDS); 857 printk(KERN_ERR
832 } else { 858 "Too many Smartio/Industio family boards find "
859 "(maximum %d), board not configured\n",
860 MXSER_BOARDS);
861 else {
833 if (pci_enable_device(pdev)) { 862 if (pci_enable_device(pdev)) {
834 printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n"); 863 printk(KERN_ERR "Moxa SmartI/O PCI enable "
864 "fail !\n");
835 continue; 865 continue;
836 } 866 }
837 retval = mxser_get_PCI_conf(busnum, devnum, (int) mxser_pcibrds[b].driver_data, &hwconf); 867 retval = mxser_get_PCI_conf(busnum, devnum,
868 (int)mxser_pcibrds[b].driver_data,
869 &hwconf);
838 if (retval < 0) { 870 if (retval < 0) {
839 if (retval == MXSER_ERR_IRQ) 871 if (retval == MXSER_ERR_IRQ)
840 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 872 printk(KERN_ERR
873 "Invalid interrupt number, "
874 "board not configured\n");
841 else if (retval == MXSER_ERR_IRQ_CONFLIT) 875 else if (retval == MXSER_ERR_IRQ_CONFLIT)
842 printk(KERN_ERR "Invalid interrupt number,board not configured\n"); 876 printk(KERN_ERR
877 "Invalid interrupt number, "
878 "board not configured\n");
843 else if (retval == MXSER_ERR_VECTOR) 879 else if (retval == MXSER_ERR_VECTOR)
844 printk(KERN_ERR "Invalid interrupt vector,board not configured\n"); 880 printk(KERN_ERR
881 "Invalid interrupt vector, "
882 "board not configured\n");
845 else if (retval == MXSER_ERR_IOADDR) 883 else if (retval == MXSER_ERR_IOADDR)
846 printk(KERN_ERR "Invalid I/O address,board not configured\n"); 884 printk(KERN_ERR
885 "Invalid I/O address, "
886 "board not configured\n");
847 continue; 887 continue;
848 } 888 }
849 mxser_getcfg(m, &hwconf); 889 mxser_getcfg(m, &hwconf);
850 //init mxsercfg first, or mxsercfg data is not correct on ISR. 890 /* init mxsercfg first,
851 //mxser_initbrd will hook ISR. 891 * or mxsercfg data is not correct on ISR.
892 */
893 /* mxser_initbrd will hook ISR. */
852 if (mxser_initbrd(m, &hwconf) < 0) 894 if (mxser_initbrd(m, &hwconf) < 0)
853 continue; 895 continue;
854 m++; 896 m++;
@@ -858,7 +900,8 @@ static int mxser_init(void)
858 900
859 retval = tty_register_driver(mxvar_sdriver); 901 retval = tty_register_driver(mxvar_sdriver);
860 if (retval) { 902 if (retval) {
861 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); 903 printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family"
904 " driver !\n");
862 put_tty_driver(mxvar_sdriver); 905 put_tty_driver(mxvar_sdriver);
863 906
864 for (i = 0; i < MXSER_BOARDS; i++) { 907 for (i = 0; i < MXSER_BOARDS; i++) {
@@ -866,7 +909,7 @@ static int mxser_init(void)
866 continue; 909 continue;
867 else { 910 else {
868 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]); 911 free_irq(mxsercfg[i].irq, &mxvar_table[i * MXSER_PORTS_PER_BOARD]);
869 //todo: release io, vector 912 /* todo: release io, vector */
870 } 913 }
871 } 914 }
872 return retval; 915 return retval;
@@ -877,7 +920,7 @@ static int mxser_init(void)
877 920
878static void mxser_do_softint(void *private_) 921static void mxser_do_softint(void *private_)
879{ 922{
880 struct mxser_struct *info = (struct mxser_struct *) private_; 923 struct mxser_struct *info = private_;
881 struct tty_struct *tty; 924 struct tty_struct *tty;
882 925
883 tty = info->tty; 926 tty = info->tty;
@@ -926,7 +969,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
926 return -ENODEV; 969 return -ENODEV;
927 info = mxvar_table + line; 970 info = mxvar_table + line;
928 if (!info->base) 971 if (!info->base)
929 return (-ENODEV); 972 return -ENODEV;
930 973
931 tty->driver_data = info; 974 tty->driver_data = info;
932 info->tty = tty; 975 info->tty = tty;
@@ -935,11 +978,11 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
935 */ 978 */
936 retval = mxser_startup(info); 979 retval = mxser_startup(info);
937 if (retval) 980 if (retval)
938 return (retval); 981 return retval;
939 982
940 retval = mxser_block_til_ready(tty, filp, info); 983 retval = mxser_block_til_ready(tty, filp, info);
941 if (retval) 984 if (retval)
942 return (retval); 985 return retval;
943 986
944 info->count++; 987 info->count++;
945 988
@@ -953,13 +996,13 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
953 996
954 info->session = current->signal->session; 997 info->session = current->signal->session;
955 info->pgrp = process_group(current); 998 info->pgrp = process_group(current);
956 clear_bit(TTY_DONT_FLIP, &tty->flags);
957 999
958 //status = mxser_get_msr(info->base, 0, info->port); 1000 /*
959 //mxser_check_modem_status(info, status); 1001 status = mxser_get_msr(info->base, 0, info->port);
1002 mxser_check_modem_status(info, status);
1003 */
960 1004
961/* unmark here for very high baud rate (ex. 921600 bps) used 1005/* unmark here for very high baud rate (ex. 921600 bps) used */
962*/
963 tty->low_latency = 1; 1006 tty->low_latency = 1;
964 return 0; 1007 return 0;
965} 1008}
@@ -972,7 +1015,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
972 */ 1015 */
973static void mxser_close(struct tty_struct *tty, struct file *filp) 1016static void mxser_close(struct tty_struct *tty, struct file *filp)
974{ 1017{
975 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1018 struct mxser_struct *info = tty->driver_data;
976 1019
977 unsigned long timeout; 1020 unsigned long timeout;
978 unsigned long flags; 1021 unsigned long flags;
@@ -997,11 +1040,13 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
997 * one, we've got real problems, since it means the 1040 * one, we've got real problems, since it means the
998 * serial port won't be shutdown. 1041 * serial port won't be shutdown.
999 */ 1042 */
1000 printk(KERN_ERR "mxser_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count); 1043 printk(KERN_ERR "mxser_close: bad serial port count; "
1044 "tty->count is 1, info->count is %d\n", info->count);
1001 info->count = 1; 1045 info->count = 1;
1002 } 1046 }
1003 if (--info->count < 0) { 1047 if (--info->count < 0) {
1004 printk(KERN_ERR "mxser_close: bad serial port count for ttys%d: %d\n", info->port, info->count); 1048 printk(KERN_ERR "mxser_close: bad serial port count for "
1049 "ttys%d: %d\n", info->port, info->count);
1005 info->count = 0; 1050 info->count = 0;
1006 } 1051 }
1007 if (info->count) { 1052 if (info->count) {
@@ -1056,7 +1101,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1056 1101
1057 ld = tty_ldisc_ref(tty); 1102 ld = tty_ldisc_ref(tty);
1058 if (ld) { 1103 if (ld) {
1059 if(ld->flush_buffer) 1104 if (ld->flush_buffer)
1060 ld->flush_buffer(tty); 1105 ld->flush_buffer(tty);
1061 tty_ldisc_deref(ld); 1106 tty_ldisc_deref(ld);
1062 } 1107 }
@@ -1078,31 +1123,34 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1078static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) 1123static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
1079{ 1124{
1080 int c, total = 0; 1125 int c, total = 0;
1081 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1126 struct mxser_struct *info = tty->driver_data;
1082 unsigned long flags; 1127 unsigned long flags;
1083 1128
1084 if (!tty || !info->xmit_buf) 1129 if (!info->xmit_buf)
1085 return (0); 1130 return 0;
1086 1131
1087 while (1) { 1132 while (1) {
1088 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head)); 1133 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1134 SERIAL_XMIT_SIZE - info->xmit_head));
1089 if (c <= 0) 1135 if (c <= 0)
1090 break; 1136 break;
1091 1137
1092 memcpy(info->xmit_buf + info->xmit_head, buf, c); 1138 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1093 spin_lock_irqsave(&info->slock, flags); 1139 spin_lock_irqsave(&info->slock, flags);
1094 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1); 1140 info->xmit_head = (info->xmit_head + c) &
1141 (SERIAL_XMIT_SIZE - 1);
1095 info->xmit_cnt += c; 1142 info->xmit_cnt += c;
1096 spin_unlock_irqrestore(&info->slock, flags); 1143 spin_unlock_irqrestore(&info->slock, flags);
1097 1144
1098 buf += c; 1145 buf += c;
1099 count -= c; 1146 count -= c;
1100 total += c; 1147 total += c;
1101
1102 } 1148 }
1103 1149
1104 if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) { 1150 if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) {
1105 if (!tty->hw_stopped || (info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { 1151 if (!tty->hw_stopped ||
1152 (info->type == PORT_16550A) ||
1153 (info->IsMoxaMustChipFlag)) {
1106 spin_lock_irqsave(&info->slock, flags); 1154 spin_lock_irqsave(&info->slock, flags);
1107 info->IER |= UART_IER_THRI; 1155 info->IER |= UART_IER_THRI;
1108 outb(info->IER, info->base + UART_IER); 1156 outb(info->IER, info->base + UART_IER);
@@ -1114,10 +1162,10 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
1114 1162
1115static void mxser_put_char(struct tty_struct *tty, unsigned char ch) 1163static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1116{ 1164{
1117 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1165 struct mxser_struct *info = tty->driver_data;
1118 unsigned long flags; 1166 unsigned long flags;
1119 1167
1120 if (!tty || !info->xmit_buf) 1168 if (!info->xmit_buf)
1121 return; 1169 return;
1122 1170
1123 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) 1171 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
@@ -1129,7 +1177,9 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1129 info->xmit_cnt++; 1177 info->xmit_cnt++;
1130 spin_unlock_irqrestore(&info->slock, flags); 1178 spin_unlock_irqrestore(&info->slock, flags);
1131 if (!tty->stopped && !(info->IER & UART_IER_THRI)) { 1179 if (!tty->stopped && !(info->IER & UART_IER_THRI)) {
1132 if (!tty->hw_stopped || (info->type == PORT_16550A) || info->IsMoxaMustChipFlag) { 1180 if (!tty->hw_stopped ||
1181 (info->type == PORT_16550A) ||
1182 info->IsMoxaMustChipFlag) {
1133 spin_lock_irqsave(&info->slock, flags); 1183 spin_lock_irqsave(&info->slock, flags);
1134 info->IER |= UART_IER_THRI; 1184 info->IER |= UART_IER_THRI;
1135 outb(info->IER, info->base + UART_IER); 1185 outb(info->IER, info->base + UART_IER);
@@ -1141,10 +1191,16 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1141 1191
1142static void mxser_flush_chars(struct tty_struct *tty) 1192static void mxser_flush_chars(struct tty_struct *tty)
1143{ 1193{
1144 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1194 struct mxser_struct *info = tty->driver_data;
1145 unsigned long flags; 1195 unsigned long flags;
1146 1196
1147 if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) 1197 if (info->xmit_cnt <= 0 ||
1198 tty->stopped ||
1199 !info->xmit_buf ||
1200 (tty->hw_stopped &&
1201 (info->type != PORT_16550A) &&
1202 (!info->IsMoxaMustChipFlag)
1203 ))
1148 return; 1204 return;
1149 1205
1150 spin_lock_irqsave(&info->slock, flags); 1206 spin_lock_irqsave(&info->slock, flags);
@@ -1157,24 +1213,24 @@ static void mxser_flush_chars(struct tty_struct *tty)
1157 1213
1158static int mxser_write_room(struct tty_struct *tty) 1214static int mxser_write_room(struct tty_struct *tty)
1159{ 1215{
1160 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1216 struct mxser_struct *info = tty->driver_data;
1161 int ret; 1217 int ret;
1162 1218
1163 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; 1219 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
1164 if (ret < 0) 1220 if (ret < 0)
1165 ret = 0; 1221 ret = 0;
1166 return (ret); 1222 return ret;
1167} 1223}
1168 1224
1169static int mxser_chars_in_buffer(struct tty_struct *tty) 1225static int mxser_chars_in_buffer(struct tty_struct *tty)
1170{ 1226{
1171 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1227 struct mxser_struct *info = tty->driver_data;
1172 return info->xmit_cnt; 1228 return info->xmit_cnt;
1173} 1229}
1174 1230
1175static void mxser_flush_buffer(struct tty_struct *tty) 1231static void mxser_flush_buffer(struct tty_struct *tty)
1176{ 1232{
1177 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1233 struct mxser_struct *info = tty->driver_data;
1178 char fcr; 1234 char fcr;
1179 unsigned long flags; 1235 unsigned long flags;
1180 1236
@@ -1184,7 +1240,8 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1184 1240
1185 /* below added by shinhay */ 1241 /* below added by shinhay */
1186 fcr = inb(info->base + UART_FCR); 1242 fcr = inb(info->base + UART_FCR);
1187 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 1243 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1244 info->base + UART_FCR);
1188 outb(fcr, info->base + UART_FCR); 1245 outb(fcr, info->base + UART_FCR);
1189 1246
1190 spin_unlock_irqrestore(&info->slock, flags); 1247 spin_unlock_irqrestore(&info->slock, flags);
@@ -1197,7 +1254,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1197 1254
1198static 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)
1199{ 1256{
1200 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1257 struct mxser_struct *info = tty->driver_data;
1201 int retval; 1258 int retval;
1202 struct async_icount cprev, cnow; /* kernel counter temps */ 1259 struct async_icount cprev, cnow; /* kernel counter temps */
1203 struct serial_icounter_struct __user *p_cuser; 1260 struct serial_icounter_struct __user *p_cuser;
@@ -1206,9 +1263,9 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1206 void __user *argp = (void __user *)arg; 1263 void __user *argp = (void __user *)arg;
1207 1264
1208 if (tty->index == MXSER_PORTS) 1265 if (tty->index == MXSER_PORTS)
1209 return (mxser_ioctl_special(cmd, argp)); 1266 return mxser_ioctl_special(cmd, argp);
1210 1267
1211 // following add by Victor Yu. 01-05-2004 1268 /* following add by Victor Yu. 01-05-2004 */
1212 if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { 1269 if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
1213 int opmode, p; 1270 int opmode, p;
1214 static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; 1271 static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
@@ -1219,7 +1276,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1219 if (cmd == MOXA_SET_OP_MODE) { 1276 if (cmd == MOXA_SET_OP_MODE) {
1220 if (get_user(opmode, (int __user *) argp)) 1277 if (get_user(opmode, (int __user *) argp))
1221 return -EFAULT; 1278 return -EFAULT;
1222 if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE && opmode != RS422_MODE && opmode != RS485_4WIRE_MODE) 1279 if (opmode != RS232_MODE &&
1280 opmode != RS485_2WIRE_MODE &&
1281 opmode != RS422_MODE &&
1282 opmode != RS485_4WIRE_MODE)
1223 return -EFAULT; 1283 return -EFAULT;
1224 mask = ModeMask[p]; 1284 mask = ModeMask[p];
1225 shiftbit = p * 2; 1285 shiftbit = p * 2;
@@ -1236,36 +1296,36 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1236 } 1296 }
1237 return 0; 1297 return 0;
1238 } 1298 }
1239 // above add by Victor Yu. 01-05-2004 1299 /* above add by Victor Yu. 01-05-2004 */
1240 1300
1241 if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1301 if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
1242 if (tty->flags & (1 << TTY_IO_ERROR)) 1302 if (tty->flags & (1 << TTY_IO_ERROR))
1243 return (-EIO); 1303 return -EIO;
1244 } 1304 }
1245 switch (cmd) { 1305 switch (cmd) {
1246 case TCSBRK: /* SVID version: non-zero arg --> no break */ 1306 case TCSBRK: /* SVID version: non-zero arg --> no break */
1247 retval = tty_check_change(tty); 1307 retval = tty_check_change(tty);
1248 if (retval) 1308 if (retval)
1249 return (retval); 1309 return retval;
1250 tty_wait_until_sent(tty, 0); 1310 tty_wait_until_sent(tty, 0);
1251 if (!arg) 1311 if (!arg)
1252 mxser_send_break(info, HZ / 4); /* 1/4 second */ 1312 mxser_send_break(info, HZ / 4); /* 1/4 second */
1253 return (0); 1313 return 0;
1254 case TCSBRKP: /* support for POSIX tcsendbreak() */ 1314 case TCSBRKP: /* support for POSIX tcsendbreak() */
1255 retval = tty_check_change(tty); 1315 retval = tty_check_change(tty);
1256 if (retval) 1316 if (retval)
1257 return (retval); 1317 return retval;
1258 tty_wait_until_sent(tty, 0); 1318 tty_wait_until_sent(tty, 0);
1259 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4); 1319 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
1260 return (0); 1320 return 0;
1261 case TIOCGSOFTCAR: 1321 case TIOCGSOFTCAR:
1262 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); 1322 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
1263 case TIOCSSOFTCAR: 1323 case TIOCSSOFTCAR:
1264 if (get_user(templ, (unsigned long __user *) argp)) 1324 if (get_user(templ, (unsigned long __user *) argp))
1265 return -EFAULT; 1325 return -EFAULT;
1266 arg = templ; 1326 arg = templ;
1267 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); 1327 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
1268 return (0); 1328 return 0;
1269 case TIOCGSERIAL: 1329 case TIOCGSERIAL:
1270 return mxser_get_serial_info(info, argp); 1330 return mxser_get_serial_info(info, argp);
1271 case TIOCSSERIAL: 1331 case TIOCSSERIAL:
@@ -1278,7 +1338,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1278 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1338 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1279 * Caller should use TIOCGICOUNT to see which one it was 1339 * Caller should use TIOCGICOUNT to see which one it was
1280 */ 1340 */
1281 case TIOCMIWAIT:{ 1341 case TIOCMIWAIT: {
1282 DECLARE_WAITQUEUE(wait, current); 1342 DECLARE_WAITQUEUE(wait, current);
1283 int ret; 1343 int ret;
1284 spin_lock_irqsave(&info->slock, flags); 1344 spin_lock_irqsave(&info->slock, flags);
@@ -1292,7 +1352,14 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1292 spin_unlock_irqrestore(&info->slock, flags); 1352 spin_unlock_irqrestore(&info->slock, flags);
1293 1353
1294 set_current_state(TASK_INTERRUPTIBLE); 1354 set_current_state(TASK_INTERRUPTIBLE);
1295 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { 1355 if (((arg & TIOCM_RNG) &&
1356 (cnow.rng != cprev.rng)) ||
1357 ((arg & TIOCM_DSR) &&
1358 (cnow.dsr != cprev.dsr)) ||
1359 ((arg & TIOCM_CD) &&
1360 (cnow.dcd != cprev.dcd)) ||
1361 ((arg & TIOCM_CTS) &&
1362 (cnow.cts != cprev.cts))) {
1296 ret = 0; 1363 ret = 0;
1297 break; 1364 break;
1298 } 1365 }
@@ -1338,21 +1405,18 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1338 put_user(cnow.dsr, &p_cuser->dsr); 1405 put_user(cnow.dsr, &p_cuser->dsr);
1339 put_user(cnow.rng, &p_cuser->rng); 1406 put_user(cnow.rng, &p_cuser->rng);
1340 put_user(cnow.dcd, &p_cuser->dcd); 1407 put_user(cnow.dcd, &p_cuser->dcd);
1341
1342/* */
1343 return 0; 1408 return 0;
1344 case MOXA_HighSpeedOn: 1409 case MOXA_HighSpeedOn:
1345 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *) argp); 1410 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
1346 1411 case MOXA_SDS_RSTICOUNTER: {
1347 case MOXA_SDS_RSTICOUNTER:{
1348 info->mon_data.rxcnt = 0; 1412 info->mon_data.rxcnt = 0;
1349 info->mon_data.txcnt = 0; 1413 info->mon_data.txcnt = 0;
1350 return 0; 1414 return 0;
1351 } 1415 }
1352// (above) added by James. 1416/* (above) added by James. */
1353 case MOXA_ASPP_SETBAUD:{ 1417 case MOXA_ASPP_SETBAUD:{
1354 long baud; 1418 long baud;
1355 if (get_user(baud, (long __user *) argp)) 1419 if (get_user(baud, (long __user *)argp))
1356 return -EFAULT; 1420 return -EFAULT;
1357 mxser_set_baud(info, baud); 1421 mxser_set_baud(info, baud);
1358 return 0; 1422 return 0;
@@ -1377,9 +1441,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1377 1441
1378 return 0; 1442 return 0;
1379 } 1443 }
1380 case MOXA_ASPP_MON:{ 1444 case MOXA_ASPP_MON: {
1381 int mcr, status; 1445 int mcr, status;
1382// info->mon_data.ser_param = tty->termios->c_cflag; 1446
1447 /* info->mon_data.ser_param = tty->termios->c_cflag; */
1383 1448
1384 status = mxser_get_msr(info->base, 1, info->port, info); 1449 status = mxser_get_msr(info->base, 1, info->port, info);
1385 mxser_check_modem_status(info, status); 1450 mxser_check_modem_status(info, status);
@@ -1400,25 +1465,25 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1400 else 1465 else
1401 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; 1466 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
1402 1467
1403 1468 if (copy_to_user(argp, &info->mon_data,
1404 if (copy_to_user(argp, &info->mon_data, sizeof(struct mxser_mon))) 1469 sizeof(struct mxser_mon)))
1405 return -EFAULT; 1470 return -EFAULT;
1406 1471
1407 return 0; 1472 return 0;
1408
1409 } 1473 }
1410 1474
1411 case MOXA_ASPP_LSTATUS:{ 1475 case MOXA_ASPP_LSTATUS: {
1412 if (copy_to_user(argp, &info->err_shadow, sizeof(unsigned char))) 1476 if (copy_to_user(argp, &info->err_shadow,
1477 sizeof(unsigned char)))
1413 return -EFAULT; 1478 return -EFAULT;
1414 1479
1415 info->err_shadow = 0; 1480 info->err_shadow = 0;
1416 return 0; 1481 return 0;
1417
1418 } 1482 }
1419 case MOXA_SET_BAUD_METHOD:{ 1483 case MOXA_SET_BAUD_METHOD: {
1420 int method; 1484 int method;
1421 if (get_user(method, (int __user *) argp)) 1485
1486 if (get_user(method, (int __user *)argp))
1422 return -EFAULT; 1487 return -EFAULT;
1423 mxser_set_baud_method[info->port] = method; 1488 mxser_set_baud_method[info->port] = method;
1424 if (copy_to_user(argp, &method, sizeof(int))) 1489 if (copy_to_user(argp, &method, sizeof(int)))
@@ -1442,7 +1507,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1442 1507
1443 switch (cmd) { 1508 switch (cmd) {
1444 case MOXA_GET_CONF: 1509 case MOXA_GET_CONF:
1445 if (copy_to_user(argp, mxsercfg, sizeof(struct mxser_hwconf) * 4)) 1510 if (copy_to_user(argp, mxsercfg,
1511 sizeof(struct mxser_hwconf) * 4))
1446 return -EFAULT; 1512 return -EFAULT;
1447 return 0; 1513 return 0;
1448 case MOXA_GET_MAJOR: 1514 case MOXA_GET_MAJOR:
@@ -1461,11 +1527,11 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1461 if (mxvar_table[i].base) 1527 if (mxvar_table[i].base)
1462 result |= (1 << i); 1528 result |= (1 << i);
1463 } 1529 }
1464 return put_user(result, (unsigned long __user *) argp); 1530 return put_user(result, (unsigned long __user *)argp);
1465 case MOXA_GETDATACOUNT: 1531 case MOXA_GETDATACOUNT:
1466 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) 1532 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
1467 return -EFAULT; 1533 return -EFAULT;
1468 return (0); 1534 return 0;
1469 case MOXA_GETMSTATUS: 1535 case MOXA_GETMSTATUS:
1470 for (i = 0; i < MXSER_PORTS; i++) { 1536 for (i = 0; i < MXSER_PORTS; i++) {
1471 GMStatus[i].ri = 0; 1537 GMStatus[i].ri = 0;
@@ -1498,22 +1564,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1498 else 1564 else
1499 GMStatus[i].cts = 0; 1565 GMStatus[i].cts = 0;
1500 } 1566 }
1501 if (copy_to_user(argp, GMStatus, sizeof(struct mxser_mstatus) * MXSER_PORTS)) 1567 if (copy_to_user(argp, GMStatus,
1568 sizeof(struct mxser_mstatus) * MXSER_PORTS))
1502 return -EFAULT; 1569 return -EFAULT;
1503 return 0; 1570 return 0;
1504 case MOXA_ASPP_MON_EXT:{ 1571 case MOXA_ASPP_MON_EXT: {
1505 int status; 1572 int status;
1506 int opmode, p; 1573 int opmode, p;
1507 int shiftbit; 1574 int shiftbit;
1508 unsigned cflag, iflag; 1575 unsigned cflag, iflag;
1509 1576
1510 for (i = 0; i < MXSER_PORTS; i++) { 1577 for (i = 0; i < MXSER_PORTS; i++) {
1511
1512 if (!mxvar_table[i].base) 1578 if (!mxvar_table[i].base)
1513 continue; 1579 continue;
1514 1580
1515 status = mxser_get_msr(mxvar_table[i].base, 0, i, &(mxvar_table[i])); 1581 status = mxser_get_msr(mxvar_table[i].base, 0,
1516// mxser_check_modem_status(&mxvar_table[i], status); 1582 i, &(mxvar_table[i]));
1583 /*
1584 mxser_check_modem_status(&mxvar_table[i],
1585 status);
1586 */
1517 if (status & UART_MSR_TERI) 1587 if (status & UART_MSR_TERI)
1518 mxvar_table[i].icount.rng++; 1588 mxvar_table[i].icount.rng++;
1519 if (status & UART_MSR_DDSR) 1589 if (status & UART_MSR_DDSR)
@@ -1578,75 +1648,76 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1578 return 0; 1648 return 0;
1579} 1649}
1580 1650
1581
1582static void mxser_stoprx(struct tty_struct *tty) 1651static void mxser_stoprx(struct tty_struct *tty)
1583{ 1652{
1584 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1653 struct mxser_struct *info = tty->driver_data;
1585 //unsigned long flags; 1654 /* unsigned long flags; */
1586
1587 1655
1588 info->ldisc_stop_rx = 1; 1656 info->ldisc_stop_rx = 1;
1589 if (I_IXOFF(tty)) { 1657 if (I_IXOFF(tty)) {
1590 1658 /* MX_LOCK(&info->slock); */
1591 //MX_LOCK(&info->slock); 1659 /* following add by Victor Yu. 09-02-2002 */
1592 // following add by Victor Yu. 09-02-2002
1593 if (info->IsMoxaMustChipFlag) { 1660 if (info->IsMoxaMustChipFlag) {
1594 info->IER &= ~MOXA_MUST_RECV_ISR; 1661 info->IER &= ~MOXA_MUST_RECV_ISR;
1595 outb(info->IER, info->base + UART_IER); 1662 outb(info->IER, info->base + UART_IER);
1596 } else { 1663 } else {
1597 // above add by Victor Yu. 09-02-2002 1664 /* above add by Victor Yu. 09-02-2002 */
1598
1599 info->x_char = STOP_CHAR(tty); 1665 info->x_char = STOP_CHAR(tty);
1600 // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 1666 /* mask by Victor Yu. 09-02-2002 */
1667 /* outb(info->IER, 0); */
1601 outb(0, info->base + UART_IER); 1668 outb(0, info->base + UART_IER);
1602 info->IER |= UART_IER_THRI; 1669 info->IER |= UART_IER_THRI;
1603 outb(info->IER, info->base + UART_IER); /* force Tx interrupt */ 1670 /* force Tx interrupt */
1604 } // add by Victor Yu. 09-02-2002 1671 outb(info->IER, info->base + UART_IER);
1605 //MX_UNLOCK(&info->slock); 1672 } /* add by Victor Yu. 09-02-2002 */
1673 /* MX_UNLOCK(&info->slock); */
1606 } 1674 }
1607 1675
1608 if (info->tty->termios->c_cflag & CRTSCTS) { 1676 if (info->tty->termios->c_cflag & CRTSCTS) {
1609 //MX_LOCK(&info->slock); 1677 /* MX_LOCK(&info->slock); */
1610 info->MCR &= ~UART_MCR_RTS; 1678 info->MCR &= ~UART_MCR_RTS;
1611 outb(info->MCR, info->base + UART_MCR); 1679 outb(info->MCR, info->base + UART_MCR);
1612 //MX_UNLOCK(&info->slock); 1680 /* MX_UNLOCK(&info->slock); */
1613 } 1681 }
1614} 1682}
1615 1683
1616static void mxser_startrx(struct tty_struct *tty) 1684static void mxser_startrx(struct tty_struct *tty)
1617{ 1685{
1618 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1686 struct mxser_struct *info = tty->driver_data;
1619 //unsigned long flags; 1687 /* unsigned long flags; */
1620 1688
1621 info->ldisc_stop_rx = 0; 1689 info->ldisc_stop_rx = 0;
1622 if (I_IXOFF(tty)) { 1690 if (I_IXOFF(tty)) {
1623 if (info->x_char) 1691 if (info->x_char)
1624 info->x_char = 0; 1692 info->x_char = 0;
1625 else { 1693 else {
1626 //MX_LOCK(&info->slock); 1694 /* MX_LOCK(&info->slock); */
1627 1695
1628 // following add by Victor Yu. 09-02-2002 1696 /* following add by Victor Yu. 09-02-2002 */
1629 if (info->IsMoxaMustChipFlag) { 1697 if (info->IsMoxaMustChipFlag) {
1630 info->IER |= MOXA_MUST_RECV_ISR; 1698 info->IER |= MOXA_MUST_RECV_ISR;
1631 outb(info->IER, info->base + UART_IER); 1699 outb(info->IER, info->base + UART_IER);
1632 } else { 1700 } else {
1633 // above add by Victor Yu. 09-02-2002 1701 /* above add by Victor Yu. 09-02-2002 */
1634 1702
1635 info->x_char = START_CHAR(tty); 1703 info->x_char = START_CHAR(tty);
1636 // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 1704 /* mask by Victor Yu. 09-02-2002 */
1637 outb(0, info->base + UART_IER); // add by Victor Yu. 09-02-2002 1705 /* outb(info->IER, 0); */
1638 info->IER |= UART_IER_THRI; /* force Tx interrupt */ 1706 /* add by Victor Yu. 09-02-2002 */
1707 outb(0, info->base + UART_IER);
1708 /* force Tx interrupt */
1709 info->IER |= UART_IER_THRI;
1639 outb(info->IER, info->base + UART_IER); 1710 outb(info->IER, info->base + UART_IER);
1640 } // add by Victor Yu. 09-02-2002 1711 } /* add by Victor Yu. 09-02-2002 */
1641 //MX_UNLOCK(&info->slock); 1712 /* MX_UNLOCK(&info->slock); */
1642 } 1713 }
1643 } 1714 }
1644 1715
1645 if (info->tty->termios->c_cflag & CRTSCTS) { 1716 if (info->tty->termios->c_cflag & CRTSCTS) {
1646 //MX_LOCK(&info->slock); 1717 /* MX_LOCK(&info->slock); */
1647 info->MCR |= UART_MCR_RTS; 1718 info->MCR |= UART_MCR_RTS;
1648 outb(info->MCR, info->base + UART_MCR); 1719 outb(info->MCR, info->base + UART_MCR);
1649 //MX_UNLOCK(&info->slock); 1720 /* MX_UNLOCK(&info->slock); */
1650 } 1721 }
1651} 1722}
1652 1723
@@ -1656,48 +1727,53 @@ static void mxser_startrx(struct tty_struct *tty)
1656 */ 1727 */
1657static void mxser_throttle(struct tty_struct *tty) 1728static void mxser_throttle(struct tty_struct *tty)
1658{ 1729{
1659 //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; 1730 /* struct mxser_struct *info = tty->driver_data; */
1660 //unsigned long flags; 1731 /* unsigned long flags; */
1661 //MX_LOCK(&info->slock); 1732
1733 /* MX_LOCK(&info->slock); */
1662 mxser_stoprx(tty); 1734 mxser_stoprx(tty);
1663 //MX_UNLOCK(&info->slock); 1735 /* MX_UNLOCK(&info->slock); */
1664} 1736}
1665 1737
1666static void mxser_unthrottle(struct tty_struct *tty) 1738static void mxser_unthrottle(struct tty_struct *tty)
1667{ 1739{
1668 //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; 1740 /* struct mxser_struct *info = tty->driver_data; */
1669 //unsigned long flags; 1741 /* unsigned long flags; */
1670 //MX_LOCK(&info->slock); 1742
1743 /* MX_LOCK(&info->slock); */
1671 mxser_startrx(tty); 1744 mxser_startrx(tty);
1672 //MX_UNLOCK(&info->slock); 1745 /* MX_UNLOCK(&info->slock); */
1673} 1746}
1674 1747
1675static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) 1748static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
1676{ 1749{
1677 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1750 struct mxser_struct *info = tty->driver_data;
1678 unsigned long flags; 1751 unsigned long flags;
1679 1752
1680 if ((tty->termios->c_cflag != old_termios->c_cflag) || (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { 1753 if ((tty->termios->c_cflag != old_termios->c_cflag) ||
1754 (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
1681 1755
1682 mxser_change_speed(info, old_termios); 1756 mxser_change_speed(info, old_termios);
1683 1757
1684 if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) { 1758 if ((old_termios->c_cflag & CRTSCTS) &&
1759 !(tty->termios->c_cflag & CRTSCTS)) {
1685 tty->hw_stopped = 0; 1760 tty->hw_stopped = 0;
1686 mxser_start(tty); 1761 mxser_start(tty);
1687 } 1762 }
1688 } 1763 }
1689 1764
1690/* Handle sw stopped */ 1765/* Handle sw stopped */
1691 if ((old_termios->c_iflag & IXON) && !(tty->termios->c_iflag & IXON)) { 1766 if ((old_termios->c_iflag & IXON) &&
1767 !(tty->termios->c_iflag & IXON)) {
1692 tty->stopped = 0; 1768 tty->stopped = 0;
1693 1769
1694 // following add by Victor Yu. 09-02-2002 1770 /* following add by Victor Yu. 09-02-2002 */
1695 if (info->IsMoxaMustChipFlag) { 1771 if (info->IsMoxaMustChipFlag) {
1696 spin_lock_irqsave(&info->slock, flags); 1772 spin_lock_irqsave(&info->slock, flags);
1697 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); 1773 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base);
1698 spin_unlock_irqrestore(&info->slock, flags); 1774 spin_unlock_irqrestore(&info->slock, flags);
1699 } 1775 }
1700 // above add by Victor Yu. 09-02-2002 1776 /* above add by Victor Yu. 09-02-2002 */
1701 1777
1702 mxser_start(tty); 1778 mxser_start(tty);
1703 } 1779 }
@@ -1711,7 +1787,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
1711 */ 1787 */
1712static void mxser_stop(struct tty_struct *tty) 1788static void mxser_stop(struct tty_struct *tty)
1713{ 1789{
1714 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1790 struct mxser_struct *info = tty->driver_data;
1715 unsigned long flags; 1791 unsigned long flags;
1716 1792
1717 spin_lock_irqsave(&info->slock, flags); 1793 spin_lock_irqsave(&info->slock, flags);
@@ -1724,7 +1800,7 @@ static void mxser_stop(struct tty_struct *tty)
1724 1800
1725static void mxser_start(struct tty_struct *tty) 1801static void mxser_start(struct tty_struct *tty)
1726{ 1802{
1727 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1803 struct mxser_struct *info = tty->driver_data;
1728 unsigned long flags; 1804 unsigned long flags;
1729 1805
1730 spin_lock_irqsave(&info->slock, flags); 1806 spin_lock_irqsave(&info->slock, flags);
@@ -1740,7 +1816,7 @@ static void mxser_start(struct tty_struct *tty)
1740 */ 1816 */
1741static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) 1817static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1742{ 1818{
1743 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1819 struct mxser_struct *info = tty->driver_data;
1744 unsigned long orig_jiffies, char_time; 1820 unsigned long orig_jiffies, char_time;
1745 int lsr; 1821 int lsr;
1746 1822
@@ -1777,7 +1853,8 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1777 if (!timeout || timeout > 2 * info->timeout) 1853 if (!timeout || timeout > 2 * info->timeout)
1778 timeout = 2 * info->timeout; 1854 timeout = 2 * info->timeout;
1779#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1855#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1780 printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...", timeout, char_time); 1856 printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...",
1857 timeout, char_time);
1781 printk("jiff=%lu...", jiffies); 1858 printk("jiff=%lu...", jiffies);
1782#endif 1859#endif
1783 while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) { 1860 while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) {
@@ -1803,7 +1880,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1803 */ 1880 */
1804void mxser_hangup(struct tty_struct *tty) 1881void mxser_hangup(struct tty_struct *tty)
1805{ 1882{
1806 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1883 struct mxser_struct *info = tty->driver_data;
1807 1884
1808 mxser_flush_buffer(tty); 1885 mxser_flush_buffer(tty);
1809 mxser_shutdown(info); 1886 mxser_shutdown(info);
@@ -1815,24 +1892,26 @@ void mxser_hangup(struct tty_struct *tty)
1815} 1892}
1816 1893
1817 1894
1818// added by James 03-12-2004. 1895/* added by James 03-12-2004. */
1819/* 1896/*
1820 * mxser_rs_break() --- routine which turns the break handling on or off 1897 * mxser_rs_break() --- routine which turns the break handling on or off
1821 */ 1898 */
1822static void mxser_rs_break(struct tty_struct *tty, int break_state) 1899static void mxser_rs_break(struct tty_struct *tty, int break_state)
1823{ 1900{
1824 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1901 struct mxser_struct *info = tty->driver_data;
1825 unsigned long flags; 1902 unsigned long flags;
1826 1903
1827 spin_lock_irqsave(&info->slock, flags); 1904 spin_lock_irqsave(&info->slock, flags);
1828 if (break_state == -1) 1905 if (break_state == -1)
1829 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); 1906 outb(inb(info->base + UART_LCR) | UART_LCR_SBC,
1907 info->base + UART_LCR);
1830 else 1908 else
1831 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); 1909 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC,
1910 info->base + UART_LCR);
1832 spin_unlock_irqrestore(&info->slock, flags); 1911 spin_unlock_irqrestore(&info->slock, flags);
1833} 1912}
1834 1913
1835// (above) added by James. 1914/* (above) added by James. */
1836 1915
1837 1916
1838/* 1917/*
@@ -1848,7 +1927,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1848 int handled = IRQ_NONE; 1927 int handled = IRQ_NONE;
1849 1928
1850 port = NULL; 1929 port = NULL;
1851 //spin_lock(&gm_lock); 1930 /* spin_lock(&gm_lock); */
1852 1931
1853 for (i = 0; i < MXSER_BOARDS; i++) { 1932 for (i = 0; i < MXSER_BOARDS; i++) {
1854 if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) { 1933 if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) {
@@ -1857,29 +1936,25 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1857 } 1936 }
1858 } 1937 }
1859 1938
1860 if (i == MXSER_BOARDS) { 1939 if (i == MXSER_BOARDS)
1861 goto irq_stop; 1940 goto irq_stop;
1862 } 1941 if (port == 0)
1863 if (port == 0) {
1864 goto irq_stop; 1942 goto irq_stop;
1865 }
1866 max = mxser_numports[mxsercfg[i].board_type - 1]; 1943 max = mxser_numports[mxsercfg[i].board_type - 1];
1867 while (1) { 1944 while (1) {
1868 irqbits = inb(port->vector) & port->vectormask; 1945 irqbits = inb(port->vector) & port->vectormask;
1869 if (irqbits == port->vectormask) { 1946 if (irqbits == port->vectormask)
1870 break; 1947 break;
1871 }
1872 1948
1873 handled = IRQ_HANDLED; 1949 handled = IRQ_HANDLED;
1874 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { 1950 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
1875 if (irqbits == port->vectormask) { 1951 if (irqbits == port->vectormask)
1876 break; 1952 break;
1877 }
1878 if (bits & irqbits) 1953 if (bits & irqbits)
1879 continue; 1954 continue;
1880 info = port + i; 1955 info = port + i;
1881 1956
1882 // following add by Victor Yu. 09-13-2002 1957 /* following add by Victor Yu. 09-13-2002 */
1883 iir = inb(info->base + UART_IIR); 1958 iir = inb(info->base + UART_IIR);
1884 if (iir & UART_IIR_NO_INT) 1959 if (iir & UART_IIR_NO_INT)
1885 continue; 1960 continue;
@@ -1890,9 +1965,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1890 inb(info->base + UART_MSR); 1965 inb(info->base + UART_MSR);
1891 continue; 1966 continue;
1892 } 1967 }
1893 // above add by Victor Yu. 09-13-2002 1968 /* above add by Victor Yu. 09-13-2002 */
1894 /* 1969 /*
1895 if ( info->tty->flip.count < TTY_FLIPBUF_SIZE/4 ){ 1970 if (info->tty->flip.count < TTY_FLIPBUF_SIZE / 4) {
1896 info->IER |= MOXA_MUST_RECV_ISR; 1971 info->IER |= MOXA_MUST_RECV_ISR;
1897 outb(info->IER, info->base + UART_IER); 1972 outb(info->IER, info->base + UART_IER);
1898 } 1973 }
@@ -1908,18 +1983,15 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1908 status = inb(info->base + UART_LSR) & info->read_status_mask; 1983 status = inb(info->base + UART_LSR) & info->read_status_mask;
1909 */ 1984 */
1910 1985
1911 // following add by Victor Yu. 09-02-2002 1986 /* following add by Victor Yu. 09-02-2002 */
1912 status = inb(info->base + UART_LSR); 1987 status = inb(info->base + UART_LSR);
1913 1988
1914 if (status & UART_LSR_PE) { 1989 if (status & UART_LSR_PE)
1915 info->err_shadow |= NPPI_NOTIFY_PARITY; 1990 info->err_shadow |= NPPI_NOTIFY_PARITY;
1916 } 1991 if (status & UART_LSR_FE)
1917 if (status & UART_LSR_FE) {
1918 info->err_shadow |= NPPI_NOTIFY_FRAMING; 1992 info->err_shadow |= NPPI_NOTIFY_FRAMING;
1919 } 1993 if (status & UART_LSR_OE)
1920 if (status & UART_LSR_OE) {
1921 info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN; 1994 info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN;
1922 }
1923 if (status & UART_LSR_BI) 1995 if (status & UART_LSR_BI)
1924 info->err_shadow |= NPPI_NOTIFY_BREAK; 1996 info->err_shadow |= NPPI_NOTIFY_BREAK;
1925 1997
@@ -1930,11 +2002,14 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1930 continue; 2002 continue;
1931 } 2003 }
1932 */ 2004 */
1933 if (iir == MOXA_MUST_IIR_GDA || iir == MOXA_MUST_IIR_RDA || iir == MOXA_MUST_IIR_RTO || iir == MOXA_MUST_IIR_LSR) 2005 if (iir == MOXA_MUST_IIR_GDA ||
2006 iir == MOXA_MUST_IIR_RDA ||
2007 iir == MOXA_MUST_IIR_RTO ||
2008 iir == MOXA_MUST_IIR_LSR)
1934 mxser_receive_chars(info, &status); 2009 mxser_receive_chars(info, &status);
1935 2010
1936 } else { 2011 } else {
1937 // above add by Victor Yu. 09-02-2002 2012 /* above add by Victor Yu. 09-02-2002 */
1938 2013
1939 status &= info->read_status_mask; 2014 status &= info->read_status_mask;
1940 if (status & UART_LSR_DR) 2015 if (status & UART_LSR_DR)
@@ -1944,13 +2019,13 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1944 if (msr & UART_MSR_ANY_DELTA) { 2019 if (msr & UART_MSR_ANY_DELTA) {
1945 mxser_check_modem_status(info, msr); 2020 mxser_check_modem_status(info, msr);
1946 } 2021 }
1947 // following add by Victor Yu. 09-13-2002 2022 /* following add by Victor Yu. 09-13-2002 */
1948 if (info->IsMoxaMustChipFlag) { 2023 if (info->IsMoxaMustChipFlag) {
1949 if ((iir == 0x02) && (status & UART_LSR_THRE)) { 2024 if ((iir == 0x02) && (status & UART_LSR_THRE)) {
1950 mxser_transmit_chars(info); 2025 mxser_transmit_chars(info);
1951 } 2026 }
1952 } else { 2027 } else {
1953 // above add by Victor Yu. 09-13-2002 2028 /* above add by Victor Yu. 09-13-2002 */
1954 2029
1955 if (status & UART_LSR_THRE) { 2030 if (status & UART_LSR_THRE) {
1956/* 8-2-99 by William 2031/* 8-2-99 by William
@@ -1966,7 +2041,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1966 } 2041 }
1967 2042
1968 irq_stop: 2043 irq_stop:
1969 //spin_unlock(&gm_lock); 2044 /* spin_unlock(&gm_lock); */
1970 return handled; 2045 return handled;
1971} 2046}
1972 2047
@@ -1984,56 +2059,58 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
1984 2059
1985 recv_room = tty->receive_room; 2060 recv_room = tty->receive_room;
1986 if ((recv_room == 0) && (!info->ldisc_stop_rx)) { 2061 if ((recv_room == 0) && (!info->ldisc_stop_rx)) {
1987 //mxser_throttle(tty); 2062 /* mxser_throttle(tty); */
1988 mxser_stoprx(tty); 2063 mxser_stoprx(tty);
1989 //return; 2064 /* return; */
1990 } 2065 }
1991 2066
1992 // following add by Victor Yu. 09-02-2002 2067 /* following add by Victor Yu. 09-02-2002 */
1993 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { 2068 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) {
1994 2069
1995 if (*status & UART_LSR_SPECIAL) { 2070 if (*status & UART_LSR_SPECIAL) {
1996 goto intr_old; 2071 goto intr_old;
1997 } 2072 }
1998 // following add by Victor Yu. 02-11-2004 2073 /* following add by Victor Yu. 02-11-2004 */
1999 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && (*status & MOXA_MUST_LSR_RERR)) 2074 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID &&
2075 (*status & MOXA_MUST_LSR_RERR))
2000 goto intr_old; 2076 goto intr_old;
2001 // above add by Victor Yu. 02-14-2004 2077 /* above add by Victor Yu. 02-14-2004 */
2002 if (*status & MOXA_MUST_LSR_RERR) 2078 if (*status & MOXA_MUST_LSR_RERR)
2003 goto intr_old; 2079 goto intr_old;
2004 2080
2005 gdl = inb(info->base + MOXA_MUST_GDL_REGISTER); 2081 gdl = inb(info->base + MOXA_MUST_GDL_REGISTER);
2006 2082
2007 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) // add by Victor Yu. 02-11-2004 2083 /* add by Victor Yu. 02-11-2004 */
2084 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID)
2008 gdl &= MOXA_MUST_GDL_MASK; 2085 gdl &= MOXA_MUST_GDL_MASK;
2009 if (gdl >= recv_room) { 2086 if (gdl >= recv_room) {
2010 if (!info->ldisc_stop_rx) { 2087 if (!info->ldisc_stop_rx) {
2011 //mxser_throttle(tty); 2088 /* mxser_throttle(tty); */
2012 mxser_stoprx(tty); 2089 mxser_stoprx(tty);
2013 } 2090 }
2014 //return; 2091 /* return; */
2015 } 2092 }
2016 while (gdl--) { 2093 while (gdl--) {
2017 ch = inb(info->base + UART_RX); 2094 ch = inb(info->base + UART_RX);
2018 tty_insert_flip_char(tty, ch, 0); 2095 tty_insert_flip_char(tty, ch, 0);
2019 cnt++; 2096 cnt++;
2020 /* 2097 /*
2021 if((cnt>=HI_WATER) && (info->stop_rx==0)){ 2098 if ((cnt >= HI_WATER) && (info->stop_rx == 0)) {
2022 mxser_stoprx(tty); 2099 mxser_stoprx(tty);
2023 info->stop_rx=1; 2100 info->stop_rx = 1;
2024 break; 2101 break;
2025 } */ 2102 } */
2026 } 2103 }
2027 goto end_intr; 2104 goto end_intr;
2028 } 2105 }
2029intr_old: 2106 intr_old:
2030 // above add by Victor Yu. 09-02-2002 2107 /* above add by Victor Yu. 09-02-2002 */
2031 2108
2032 do { 2109 do {
2033 if (max-- < 0) 2110 if (max-- < 0)
2034 break; 2111 break;
2035 /* 2112 /*
2036 if((cnt>=HI_WATER) && (info->stop_rx==0)){ 2113 if ((cnt >= HI_WATER) && (info->stop_rx == 0)) {
2037 mxser_stoprx(tty); 2114 mxser_stoprx(tty);
2038 info->stop_rx=1; 2115 info->stop_rx=1;
2039 break; 2116 break;
@@ -2041,11 +2118,11 @@ intr_old:
2041 */ 2118 */
2042 2119
2043 ch = inb(info->base + UART_RX); 2120 ch = inb(info->base + UART_RX);
2044 // following add by Victor Yu. 09-02-2002 2121 /* following add by Victor Yu. 09-02-2002 */
2045 if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ ) 2122 if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ )
2046 outb(0x23, info->base + UART_FCR); 2123 outb(0x23, info->base + UART_FCR);
2047 *status &= info->read_status_mask; 2124 *status &= info->read_status_mask;
2048 // above add by Victor Yu. 09-02-2002 2125 /* above add by Victor Yu. 09-02-2002 */
2049 if (*status & info->ignore_status_mask) { 2126 if (*status & info->ignore_status_mask) {
2050 if (++ignored > 100) 2127 if (++ignored > 100)
2051 break; 2128 break;
@@ -2080,7 +2157,7 @@ intr_old:
2080 cnt++; 2157 cnt++;
2081 if (cnt >= recv_room) { 2158 if (cnt >= recv_room) {
2082 if (!info->ldisc_stop_rx) { 2159 if (!info->ldisc_stop_rx) {
2083 //mxser_throttle(tty); 2160 /* mxser_throttle(tty); */
2084 mxser_stoprx(tty); 2161 mxser_stoprx(tty);
2085 } 2162 }
2086 break; 2163 break;
@@ -2088,21 +2165,20 @@ intr_old:
2088 2165
2089 } 2166 }
2090 2167
2091 // following add by Victor Yu. 09-02-2002 2168 /* following add by Victor Yu. 09-02-2002 */
2092 if (info->IsMoxaMustChipFlag) 2169 if (info->IsMoxaMustChipFlag)
2093 break; 2170 break;
2094 // above add by Victor Yu. 09-02-2002 2171 /* above add by Victor Yu. 09-02-2002 */
2095 2172
2096 /* mask by Victor Yu. 09-02-2002 2173 /* mask by Victor Yu. 09-02-2002
2097 *status = inb(info->base + UART_LSR) & info->read_status_mask; 2174 *status = inb(info->base + UART_LSR) & info->read_status_mask;
2098 */ 2175 */
2099 // following add by Victor Yu. 09-02-2002 2176 /* following add by Victor Yu. 09-02-2002 */
2100 *status = inb(info->base + UART_LSR); 2177 *status = inb(info->base + UART_LSR);
2101 // above add by Victor Yu. 09-02-2002 2178 /* above add by Victor Yu. 09-02-2002 */
2102 } while (*status & UART_LSR_DR); 2179 } while (*status & UART_LSR_DR);
2103 2180
2104end_intr: // add by Victor Yu. 09-02-2002 2181end_intr: /* add by Victor Yu. 09-02-2002 */
2105
2106 mxvar_log.rxcnt[info->port] += cnt; 2182 mxvar_log.rxcnt[info->port] += cnt;
2107 info->mon_data.rxcnt += cnt; 2183 info->mon_data.rxcnt += cnt;
2108 info->mon_data.up_rxcnt += cnt; 2184 info->mon_data.up_rxcnt += cnt;
@@ -2137,7 +2213,10 @@ static void mxser_transmit_chars(struct mxser_struct *info)
2137 return; 2213 return;
2138 } 2214 }
2139 2215
2140 if ((info->xmit_cnt <= 0) || info->tty->stopped || (info->tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) { 2216 if ((info->xmit_cnt <= 0) || info->tty->stopped ||
2217 (info->tty->hw_stopped &&
2218 (info->type != PORT_16550A) &&
2219 (!info->IsMoxaMustChipFlag))) {
2141 info->IER &= ~UART_IER_THRI; 2220 info->IER &= ~UART_IER_THRI;
2142 outb(info->IER, info->base + UART_IER); 2221 outb(info->IER, info->base + UART_IER);
2143 spin_unlock_irqrestore(&info->slock, flags); 2222 spin_unlock_irqrestore(&info->slock, flags);
@@ -2147,17 +2226,18 @@ static void mxser_transmit_chars(struct mxser_struct *info)
2147 cnt = info->xmit_cnt; 2226 cnt = info->xmit_cnt;
2148 count = info->xmit_fifo_size; 2227 count = info->xmit_fifo_size;
2149 do { 2228 do {
2150 outb(info->xmit_buf[info->xmit_tail++], info->base + UART_TX); 2229 outb(info->xmit_buf[info->xmit_tail++],
2230 info->base + UART_TX);
2151 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1); 2231 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1);
2152 if (--info->xmit_cnt <= 0) 2232 if (--info->xmit_cnt <= 0)
2153 break; 2233 break;
2154 } while (--count > 0); 2234 } while (--count > 0);
2155 mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt); 2235 mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt);
2156 2236
2157// added by James 03-12-2004. 2237/* added by James 03-12-2004. */
2158 info->mon_data.txcnt += (cnt - info->xmit_cnt); 2238 info->mon_data.txcnt += (cnt - info->xmit_cnt);
2159 info->mon_data.up_txcnt += (cnt - info->xmit_cnt); 2239 info->mon_data.up_txcnt += (cnt - info->xmit_cnt);
2160// (above) added by James. 2240/* (above) added by James. */
2161 2241
2162/* added by casper 1/11/2000 */ 2242/* added by casper 1/11/2000 */
2163 info->icount.tx += (cnt - info->xmit_cnt); 2243 info->icount.tx += (cnt - info->xmit_cnt);
@@ -2188,7 +2268,6 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2188 info->mon_data.modem_status = status; 2268 info->mon_data.modem_status = status;
2189 wake_up_interruptible(&info->delta_msr_wait); 2269 wake_up_interruptible(&info->delta_msr_wait);
2190 2270
2191
2192 if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 2271 if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
2193 if (status & UART_MSR_DCD) 2272 if (status & UART_MSR_DCD)
2194 wake_up_interruptible(&info->open_wait); 2273 wake_up_interruptible(&info->open_wait);
@@ -2200,7 +2279,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2200 if (status & UART_MSR_CTS) { 2279 if (status & UART_MSR_CTS) {
2201 info->tty->hw_stopped = 0; 2280 info->tty->hw_stopped = 0;
2202 2281
2203 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2282 if ((info->type != PORT_16550A) &&
2283 (!info->IsMoxaMustChipFlag)) {
2204 info->IER |= UART_IER_THRI; 2284 info->IER |= UART_IER_THRI;
2205 outb(info->IER, info->base + UART_IER); 2285 outb(info->IER, info->base + UART_IER);
2206 } 2286 }
@@ -2209,7 +2289,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2209 } else { 2289 } else {
2210 if (!(status & UART_MSR_CTS)) { 2290 if (!(status & UART_MSR_CTS)) {
2211 info->tty->hw_stopped = 1; 2291 info->tty->hw_stopped = 1;
2212 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2292 if ((info->type != PORT_16550A) &&
2293 (!info->IsMoxaMustChipFlag)) {
2213 info->IER &= ~UART_IER_THRI; 2294 info->IER &= ~UART_IER_THRI;
2214 outb(info->IER, info->base + UART_IER); 2295 outb(info->IER, info->base + UART_IER);
2215 } 2296 }
@@ -2231,7 +2312,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2231 */ 2312 */
2232 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { 2313 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
2233 info->flags |= ASYNC_NORMAL_ACTIVE; 2314 info->flags |= ASYNC_NORMAL_ACTIVE;
2234 return (0); 2315 return 0;
2235 } 2316 }
2236 2317
2237 if (tty->termios->c_cflag & CLOCAL) 2318 if (tty->termios->c_cflag & CLOCAL)
@@ -2254,7 +2335,8 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2254 info->blocked_open++; 2335 info->blocked_open++;
2255 while (1) { 2336 while (1) {
2256 spin_lock_irqsave(&info->slock, flags); 2337 spin_lock_irqsave(&info->slock, flags);
2257 outb(inb(info->base + UART_MCR) | UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); 2338 outb(inb(info->base + UART_MCR) |
2339 UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR);
2258 spin_unlock_irqrestore(&info->slock, flags); 2340 spin_unlock_irqrestore(&info->slock, flags);
2259 set_current_state(TASK_INTERRUPTIBLE); 2341 set_current_state(TASK_INTERRUPTIBLE);
2260 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { 2342 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) {
@@ -2264,7 +2346,9 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2264 retval = -ERESTARTSYS; 2346 retval = -ERESTARTSYS;
2265 break; 2347 break;
2266 } 2348 }
2267 if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (inb(info->base + UART_MSR) & UART_MSR_DCD))) 2349 if (!(info->flags & ASYNC_CLOSING) &&
2350 (do_clocal ||
2351 (inb(info->base + UART_MSR) & UART_MSR_DCD)))
2268 break; 2352 break;
2269 if (signal_pending(current)) { 2353 if (signal_pending(current)) {
2270 retval = -ERESTARTSYS; 2354 retval = -ERESTARTSYS;
@@ -2278,27 +2362,26 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2278 info->count++; 2362 info->count++;
2279 info->blocked_open--; 2363 info->blocked_open--;
2280 if (retval) 2364 if (retval)
2281 return (retval); 2365 return retval;
2282 info->flags |= ASYNC_NORMAL_ACTIVE; 2366 info->flags |= ASYNC_NORMAL_ACTIVE;
2283 return (0); 2367 return 0;
2284} 2368}
2285 2369
2286static int mxser_startup(struct mxser_struct *info) 2370static int mxser_startup(struct mxser_struct *info)
2287{ 2371{
2288
2289 unsigned long page; 2372 unsigned long page;
2290 unsigned long flags; 2373 unsigned long flags;
2291 2374
2292 page = __get_free_page(GFP_KERNEL); 2375 page = __get_free_page(GFP_KERNEL);
2293 if (!page) 2376 if (!page)
2294 return (-ENOMEM); 2377 return -ENOMEM;
2295 2378
2296 spin_lock_irqsave(&info->slock, flags); 2379 spin_lock_irqsave(&info->slock, flags);
2297 2380
2298 if (info->flags & ASYNC_INITIALIZED) { 2381 if (info->flags & ASYNC_INITIALIZED) {
2299 free_page(page); 2382 free_page(page);
2300 spin_unlock_irqrestore(&info->slock, flags); 2383 spin_unlock_irqrestore(&info->slock, flags);
2301 return (0); 2384 return 0;
2302 } 2385 }
2303 2386
2304 if (!info->base || !info->type) { 2387 if (!info->base || !info->type) {
@@ -2306,7 +2389,7 @@ static int mxser_startup(struct mxser_struct *info)
2306 set_bit(TTY_IO_ERROR, &info->tty->flags); 2389 set_bit(TTY_IO_ERROR, &info->tty->flags);
2307 free_page(page); 2390 free_page(page);
2308 spin_unlock_irqrestore(&info->slock, flags); 2391 spin_unlock_irqrestore(&info->slock, flags);
2309 return (0); 2392 return 0;
2310 } 2393 }
2311 if (info->xmit_buf) 2394 if (info->xmit_buf)
2312 free_page(page); 2395 free_page(page);
@@ -2318,9 +2401,12 @@ static int mxser_startup(struct mxser_struct *info)
2318 * (they will be reenabled in mxser_change_speed()) 2401 * (they will be reenabled in mxser_change_speed())
2319 */ 2402 */
2320 if (info->IsMoxaMustChipFlag) 2403 if (info->IsMoxaMustChipFlag)
2321 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2404 outb((UART_FCR_CLEAR_RCVR |
2405 UART_FCR_CLEAR_XMIT |
2406 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
2322 else 2407 else
2323 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 2408 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
2409 info->base + UART_FCR);
2324 2410
2325 /* 2411 /*
2326 * At this point there's no way the LSR could still be 0xFF; 2412 * At this point there's no way the LSR could still be 0xFF;
@@ -2332,9 +2418,9 @@ static int mxser_startup(struct mxser_struct *info)
2332 if (capable(CAP_SYS_ADMIN)) { 2418 if (capable(CAP_SYS_ADMIN)) {
2333 if (info->tty) 2419 if (info->tty)
2334 set_bit(TTY_IO_ERROR, &info->tty->flags); 2420 set_bit(TTY_IO_ERROR, &info->tty->flags);
2335 return (0); 2421 return 0;
2336 } else 2422 } else
2337 return (-ENODEV); 2423 return -ENODEV;
2338 } 2424 }
2339 2425
2340 /* 2426 /*
@@ -2356,12 +2442,12 @@ static int mxser_startup(struct mxser_struct *info)
2356 * Finally, enable interrupts 2442 * Finally, enable interrupts
2357 */ 2443 */
2358 info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; 2444 info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
2359// info->IER = UART_IER_RLSI | UART_IER_RDI; 2445 /* info->IER = UART_IER_RLSI | UART_IER_RDI; */
2360 2446
2361 // following add by Victor Yu. 08-30-2002 2447 /* following add by Victor Yu. 08-30-2002 */
2362 if (info->IsMoxaMustChipFlag) 2448 if (info->IsMoxaMustChipFlag)
2363 info->IER |= MOXA_MUST_IER_EGDAI; 2449 info->IER |= MOXA_MUST_IER_EGDAI;
2364 // above add by Victor Yu. 08-30-2002 2450 /* above add by Victor Yu. 08-30-2002 */
2365 outb(info->IER, info->base + UART_IER); /* enable interrupts */ 2451 outb(info->IER, info->base + UART_IER); /* enable interrupts */
2366 2452
2367 /* 2453 /*
@@ -2383,7 +2469,7 @@ static int mxser_startup(struct mxser_struct *info)
2383 mxser_change_speed(info, NULL); 2469 mxser_change_speed(info, NULL);
2384 2470
2385 info->flags |= ASYNC_INITIALIZED; 2471 info->flags |= ASYNC_INITIALIZED;
2386 return (0); 2472 return 0;
2387} 2473}
2388 2474
2389/* 2475/*
@@ -2421,12 +2507,15 @@ static void mxser_shutdown(struct mxser_struct *info)
2421 outb(info->MCR, info->base + UART_MCR); 2507 outb(info->MCR, info->base + UART_MCR);
2422 2508
2423 /* clear Rx/Tx FIFO's */ 2509 /* clear Rx/Tx FIFO's */
2424 // following add by Victor Yu. 08-30-2002 2510 /* following add by Victor Yu. 08-30-2002 */
2425 if (info->IsMoxaMustChipFlag) 2511 if (info->IsMoxaMustChipFlag)
2426 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2512 outb((UART_FCR_CLEAR_RCVR |
2513 UART_FCR_CLEAR_XMIT |
2514 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
2427 else 2515 else
2428 // above add by Victor Yu. 08-30-2002 2516 /* above add by Victor Yu. 08-30-2002 */
2429 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 2517 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
2518 info->base + UART_FCR);
2430 2519
2431 /* read data port to reset things */ 2520 /* read data port to reset things */
2432 (void) inb(info->base + UART_RX); 2521 (void) inb(info->base + UART_RX);
@@ -2436,11 +2525,10 @@ static void mxser_shutdown(struct mxser_struct *info)
2436 2525
2437 info->flags &= ~ASYNC_INITIALIZED; 2526 info->flags &= ~ASYNC_INITIALIZED;
2438 2527
2439 // following add by Victor Yu. 09-23-2002 2528 /* following add by Victor Yu. 09-23-2002 */
2440 if (info->IsMoxaMustChipFlag) { 2529 if (info->IsMoxaMustChipFlag)
2441 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base); 2530 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base);
2442 } 2531 /* above add by Victor Yu. 09-23-2002 */
2443 // above add by Victor Yu. 09-23-2002
2444 2532
2445 spin_unlock_irqrestore(&info->slock, flags); 2533 spin_unlock_irqrestore(&info->slock, flags);
2446} 2534}
@@ -2457,14 +2545,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2457 long baud; 2545 long baud;
2458 unsigned long flags; 2546 unsigned long flags;
2459 2547
2460
2461 if (!info->tty || !info->tty->termios) 2548 if (!info->tty || !info->tty->termios)
2462 return ret; 2549 return ret;
2463 cflag = info->tty->termios->c_cflag; 2550 cflag = info->tty->termios->c_cflag;
2464 if (!(info->base)) 2551 if (!(info->base))
2465 return ret; 2552 return ret;
2466 2553
2467
2468#ifndef B921600 2554#ifndef B921600
2469#define B921600 (B460800 +1) 2555#define B921600 (B460800 +1)
2470#endif 2556#endif
@@ -2559,9 +2645,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2559 cval |= 0x04; 2645 cval |= 0x04;
2560 if (cflag & PARENB) 2646 if (cflag & PARENB)
2561 cval |= UART_LCR_PARITY; 2647 cval |= UART_LCR_PARITY;
2562 if (!(cflag & PARODD)) { 2648 if (!(cflag & PARODD))
2563 cval |= UART_LCR_EPAR; 2649 cval |= UART_LCR_EPAR;
2564 }
2565 if (cflag & CMSPAR) 2650 if (cflag & CMSPAR)
2566 cval |= UART_LCR_SPAR; 2651 cval |= UART_LCR_SPAR;
2567 2652
@@ -2574,13 +2659,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2574 fcr = 0; 2659 fcr = 0;
2575 } else { 2660 } else {
2576 fcr = UART_FCR_ENABLE_FIFO; 2661 fcr = UART_FCR_ENABLE_FIFO;
2577 // following add by Victor Yu. 08-30-2002 2662 /* following add by Victor Yu. 08-30-2002 */
2578 if (info->IsMoxaMustChipFlag) { 2663 if (info->IsMoxaMustChipFlag) {
2579 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 2664 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
2580 SET_MOXA_MUST_FIFO_VALUE(info); 2665 SET_MOXA_MUST_FIFO_VALUE(info);
2581 } else { 2666 } else {
2582 // above add by Victor Yu. 08-30-2002 2667 /* above add by Victor Yu. 08-30-2002 */
2583
2584 switch (info->rx_trigger) { 2668 switch (info->rx_trigger) {
2585 case 1: 2669 case 1:
2586 fcr |= UART_FCR_TRIGGER_1; 2670 fcr |= UART_FCR_TRIGGER_1;
@@ -2606,22 +2690,24 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2606 info->IER |= UART_IER_MSI; 2690 info->IER |= UART_IER_MSI;
2607 if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { 2691 if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) {
2608 info->MCR |= UART_MCR_AFE; 2692 info->MCR |= UART_MCR_AFE;
2609 //status = mxser_get_msr(info->base, 0, info->port); 2693 /* status = mxser_get_msr(info->base, 0, info->port); */
2610/* save_flags(flags); 2694/*
2695 save_flags(flags);
2611 cli(); 2696 cli();
2612 status = inb(baseaddr + UART_MSR); 2697 status = inb(baseaddr + UART_MSR);
2613 restore_flags(flags);*/ 2698 restore_flags(flags);
2614 //mxser_check_modem_status(info, status); 2699*/
2700 /* mxser_check_modem_status(info, status); */
2615 } else { 2701 } else {
2616 //status = mxser_get_msr(info->base, 0, info->port); 2702 /* status = mxser_get_msr(info->base, 0, info->port); */
2617 2703 /* MX_LOCK(&info->slock); */
2618 //MX_LOCK(&info->slock);
2619 status = inb(info->base + UART_MSR); 2704 status = inb(info->base + UART_MSR);
2620 //MX_UNLOCK(&info->slock); 2705 /* MX_UNLOCK(&info->slock); */
2621 if (info->tty->hw_stopped) { 2706 if (info->tty->hw_stopped) {
2622 if (status & UART_MSR_CTS) { 2707 if (status & UART_MSR_CTS) {
2623 info->tty->hw_stopped = 0; 2708 info->tty->hw_stopped = 0;
2624 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2709 if ((info->type != PORT_16550A) &&
2710 (!info->IsMoxaMustChipFlag)) {
2625 info->IER |= UART_IER_THRI; 2711 info->IER |= UART_IER_THRI;
2626 outb(info->IER, info->base + UART_IER); 2712 outb(info->IER, info->base + UART_IER);
2627 } 2713 }
@@ -2630,7 +2716,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2630 } else { 2716 } else {
2631 if (!(status & UART_MSR_CTS)) { 2717 if (!(status & UART_MSR_CTS)) {
2632 info->tty->hw_stopped = 1; 2718 info->tty->hw_stopped = 1;
2633 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2719 if ((info->type != PORT_16550A) &&
2720 (!info->IsMoxaMustChipFlag)) {
2634 info->IER &= ~UART_IER_THRI; 2721 info->IER &= ~UART_IER_THRI;
2635 outb(info->IER, info->base + UART_IER); 2722 outb(info->IER, info->base + UART_IER);
2636 } 2723 }
@@ -2668,11 +2755,17 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2668 * overruns too. (For real raw support). 2755 * overruns too. (For real raw support).
2669 */ 2756 */
2670 if (I_IGNPAR(info->tty)) { 2757 if (I_IGNPAR(info->tty)) {
2671 info->ignore_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; 2758 info->ignore_status_mask |=
2672 info->read_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; 2759 UART_LSR_OE |
2760 UART_LSR_PE |
2761 UART_LSR_FE;
2762 info->read_status_mask |=
2763 UART_LSR_OE |
2764 UART_LSR_PE |
2765 UART_LSR_FE;
2673 } 2766 }
2674 } 2767 }
2675 // following add by Victor Yu. 09-02-2002 2768 /* following add by Victor Yu. 09-02-2002 */
2676 if (info->IsMoxaMustChipFlag) { 2769 if (info->IsMoxaMustChipFlag) {
2677 spin_lock_irqsave(&info->slock, flags); 2770 spin_lock_irqsave(&info->slock, flags);
2678 SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty)); 2771 SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty));
@@ -2698,7 +2791,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2698 */ 2791 */
2699 spin_unlock_irqrestore(&info->slock, flags); 2792 spin_unlock_irqrestore(&info->slock, flags);
2700 } 2793 }
2701 // above add by Victor Yu. 09-02-2002 2794 /* above add by Victor Yu. 09-02-2002 */
2702 2795
2703 2796
2704 outb(fcr, info->base + UART_FCR); /* set fcr */ 2797 outb(fcr, info->base + UART_FCR); /* set fcr */
@@ -2729,10 +2822,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2729 quot = (2 * info->baud_base / 269); 2822 quot = (2 * info->baud_base / 269);
2730 } else if (newspd) { 2823 } else if (newspd) {
2731 quot = info->baud_base / newspd; 2824 quot = info->baud_base / newspd;
2732
2733 if (quot == 0) 2825 if (quot == 0)
2734 quot = 1; 2826 quot = 1;
2735
2736 } else { 2827 } else {
2737 quot = 0; 2828 quot = 0;
2738 } 2829 }
@@ -2765,8 +2856,6 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2765 return ret; 2856 return ret;
2766} 2857}
2767 2858
2768
2769
2770/* 2859/*
2771 * ------------------------------------------------------------ 2860 * ------------------------------------------------------------
2772 * friends of mxser_ioctl() 2861 * friends of mxser_ioctl()
@@ -2777,7 +2866,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2777 struct serial_struct tmp; 2866 struct serial_struct tmp;
2778 2867
2779 if (!retinfo) 2868 if (!retinfo)
2780 return (-EFAULT); 2869 return -EFAULT;
2781 memset(&tmp, 0, sizeof(tmp)); 2870 memset(&tmp, 0, sizeof(tmp));
2782 tmp.type = info->type; 2871 tmp.type = info->type;
2783 tmp.line = info->port; 2872 tmp.line = info->port;
@@ -2791,7 +2880,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2791 tmp.hub6 = 0; 2880 tmp.hub6 = 0;
2792 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 2881 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2793 return -EFAULT; 2882 return -EFAULT;
2794 return (0); 2883 return 0;
2795} 2884}
2796 2885
2797static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info) 2886static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info)
@@ -2801,29 +2890,37 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2801 int retval = 0; 2890 int retval = 0;
2802 2891
2803 if (!new_info || !info->base) 2892 if (!new_info || !info->base)
2804 return (-EFAULT); 2893 return -EFAULT;
2805 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2894 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
2806 return -EFAULT; 2895 return -EFAULT;
2807 2896
2808 if ((new_serial.irq != info->irq) || (new_serial.port != info->base) || (new_serial.custom_divisor != info->custom_divisor) || (new_serial.baud_base != info->baud_base)) 2897 if ((new_serial.irq != info->irq) ||
2809 return (-EPERM); 2898 (new_serial.port != info->base) ||
2899 (new_serial.custom_divisor != info->custom_divisor) ||
2900 (new_serial.baud_base != info->baud_base))
2901 return -EPERM;
2810 2902
2811 flags = info->flags & ASYNC_SPD_MASK; 2903 flags = info->flags & ASYNC_SPD_MASK;
2812 2904
2813 if (!capable(CAP_SYS_ADMIN)) { 2905 if (!capable(CAP_SYS_ADMIN)) {
2814 if ((new_serial.baud_base != info->baud_base) || (new_serial.close_delay != info->close_delay) || ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK))) 2906 if ((new_serial.baud_base != info->baud_base) ||
2815 return (-EPERM); 2907 (new_serial.close_delay != info->close_delay) ||
2816 info->flags = ((info->flags & ~ASYNC_USR_MASK) | (new_serial.flags & ASYNC_USR_MASK)); 2908 ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
2909 return -EPERM;
2910 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
2911 (new_serial.flags & ASYNC_USR_MASK));
2817 } else { 2912 } else {
2818 /* 2913 /*
2819 * OK, past this point, all the error checking has been done. 2914 * OK, past this point, all the error checking has been done.
2820 * At this point, we start making changes..... 2915 * At this point, we start making changes.....
2821 */ 2916 */
2822 info->flags = ((info->flags & ~ASYNC_FLAGS) | (new_serial.flags & ASYNC_FLAGS)); 2917 info->flags = ((info->flags & ~ASYNC_FLAGS) |
2918 (new_serial.flags & ASYNC_FLAGS));
2823 info->close_delay = new_serial.close_delay * HZ / 100; 2919 info->close_delay = new_serial.close_delay * HZ / 100;
2824 info->closing_wait = new_serial.closing_wait * HZ / 100; 2920 info->closing_wait = new_serial.closing_wait * HZ / 100;
2825 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 2921 info->tty->low_latency =
2826 info->tty->low_latency = 0; //(info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 2922 (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
2923 info->tty->low_latency = 0; /* (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; */
2827 } 2924 }
2828 2925
2829 /* added by casper, 3/17/2000, for mouse */ 2926 /* added by casper, 3/17/2000, for mouse */
@@ -2831,7 +2928,6 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2831 2928
2832 process_txrx_fifo(info); 2929 process_txrx_fifo(info);
2833 2930
2834 /* */
2835 if (info->flags & ASYNC_INITIALIZED) { 2931 if (info->flags & ASYNC_INITIALIZED) {
2836 if (flags != (info->flags & ASYNC_SPD_MASK)) { 2932 if (flags != (info->flags & ASYNC_SPD_MASK)) {
2837 mxser_change_speed(info, NULL); 2933 mxser_change_speed(info, NULL);
@@ -2839,7 +2935,7 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2839 } else { 2935 } else {
2840 retval = mxser_startup(info); 2936 retval = mxser_startup(info);
2841 } 2937 }
2842 return (retval); 2938 return retval;
2843} 2939}
2844 2940
2845/* 2941/*
@@ -2876,25 +2972,27 @@ static void mxser_send_break(struct mxser_struct *info, int duration)
2876 return; 2972 return;
2877 set_current_state(TASK_INTERRUPTIBLE); 2973 set_current_state(TASK_INTERRUPTIBLE);
2878 spin_lock_irqsave(&info->slock, flags); 2974 spin_lock_irqsave(&info->slock, flags);
2879 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); 2975 outb(inb(info->base + UART_LCR) | UART_LCR_SBC,
2976 info->base + UART_LCR);
2880 spin_unlock_irqrestore(&info->slock, flags); 2977 spin_unlock_irqrestore(&info->slock, flags);
2881 schedule_timeout(duration); 2978 schedule_timeout(duration);
2882 spin_lock_irqsave(&info->slock, flags); 2979 spin_lock_irqsave(&info->slock, flags);
2883 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); 2980 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC,
2981 info->base + UART_LCR);
2884 spin_unlock_irqrestore(&info->slock, flags); 2982 spin_unlock_irqrestore(&info->slock, flags);
2885} 2983}
2886 2984
2887static int mxser_tiocmget(struct tty_struct *tty, struct file *file) 2985static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2888{ 2986{
2889 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 2987 struct mxser_struct *info = tty->driver_data;
2890 unsigned char control, status; 2988 unsigned char control, status;
2891 unsigned long flags; 2989 unsigned long flags;
2892 2990
2893 2991
2894 if (tty->index == MXSER_PORTS) 2992 if (tty->index == MXSER_PORTS)
2895 return (-ENOIOCTLCMD); 2993 return -ENOIOCTLCMD;
2896 if (tty->flags & (1 << TTY_IO_ERROR)) 2994 if (tty->flags & (1 << TTY_IO_ERROR))
2897 return (-EIO); 2995 return -EIO;
2898 2996
2899 control = info->MCR; 2997 control = info->MCR;
2900 2998
@@ -2904,12 +3002,16 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2904 mxser_check_modem_status(info, status); 3002 mxser_check_modem_status(info, status);
2905 spin_unlock_irqrestore(&info->slock, flags); 3003 spin_unlock_irqrestore(&info->slock, flags);
2906 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | 3004 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) |
2907 ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) | ((status & UART_MSR_RI) ? TIOCM_RNG : 0) | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0); 3005 ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
3006 ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) |
3007 ((status & UART_MSR_RI) ? TIOCM_RNG : 0) |
3008 ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) |
3009 ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
2908} 3010}
2909 3011
2910static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) 3012static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
2911{ 3013{
2912 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 3014 struct mxser_struct *info = tty->driver_data;
2913 unsigned long flags; 3015 unsigned long flags;
2914 3016
2915 3017
@@ -2968,38 +3070,36 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
2968 hwconf->board_type = MXSER_BOARD_CI104J; 3070 hwconf->board_type = MXSER_BOARD_CI104J;
2969 hwconf->ports = 4; 3071 hwconf->ports = 4;
2970 } else 3072 } else
2971 return (0); 3073 return 0;
2972 3074
2973 irq = 0; 3075 irq = 0;
2974 if (hwconf->ports == 2) { 3076 if (hwconf->ports == 2) {
2975 irq = regs[9] & 0xF000; 3077 irq = regs[9] & 0xF000;
2976 irq = irq | (irq >> 4); 3078 irq = irq | (irq >> 4);
2977 if (irq != (regs[9] & 0xFF00)) 3079 if (irq != (regs[9] & 0xFF00))
2978 return (MXSER_ERR_IRQ_CONFLIT); 3080 return MXSER_ERR_IRQ_CONFLIT;
2979 } else if (hwconf->ports == 4) { 3081 } else if (hwconf->ports == 4) {
2980 irq = regs[9] & 0xF000; 3082 irq = regs[9] & 0xF000;
2981 irq = irq | (irq >> 4); 3083 irq = irq | (irq >> 4);
2982 irq = irq | (irq >> 8); 3084 irq = irq | (irq >> 8);
2983 if (irq != regs[9]) 3085 if (irq != regs[9])
2984 return (MXSER_ERR_IRQ_CONFLIT); 3086 return MXSER_ERR_IRQ_CONFLIT;
2985 } else if (hwconf->ports == 8) { 3087 } else if (hwconf->ports == 8) {
2986 irq = regs[9] & 0xF000; 3088 irq = regs[9] & 0xF000;
2987 irq = irq | (irq >> 4); 3089 irq = irq | (irq >> 4);
2988 irq = irq | (irq >> 8); 3090 irq = irq | (irq >> 8);
2989 if ((irq != regs[9]) || (irq != regs[10])) 3091 if ((irq != regs[9]) || (irq != regs[10]))
2990 return (MXSER_ERR_IRQ_CONFLIT); 3092 return MXSER_ERR_IRQ_CONFLIT;
2991 } 3093 }
2992 3094
2993 if (!irq) { 3095 if (!irq)
2994 return (MXSER_ERR_IRQ); 3096 return MXSER_ERR_IRQ;
2995 } 3097 hwconf->irq = ((int)(irq & 0xF000) >> 12);
2996 hwconf->irq = ((int) (irq & 0xF000) >> 12);
2997 for (i = 0; i < 8; i++) 3098 for (i = 0; i < 8; i++)
2998 hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8; 3099 hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8;
2999 if ((regs[12] & 0x80) == 0) { 3100 if ((regs[12] & 0x80) == 0)
3000 return (MXSER_ERR_VECTOR); 3101 return MXSER_ERR_VECTOR;
3001 } 3102 hwconf->vector = (int)regs[11]; /* interrupt vector */
3002 hwconf->vector = (int) regs[11]; /* interrupt vector */
3003 if (id == 1) 3103 if (id == 1)
3004 hwconf->vector_mask = 0x00FF; 3104 hwconf->vector_mask = 0x00FF;
3005 else 3105 else
@@ -3007,10 +3107,10 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3007 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { 3107 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
3008 if (regs[12] & bits) { 3108 if (regs[12] & bits) {
3009 hwconf->baud_base[i] = 921600; 3109 hwconf->baud_base[i] = 921600;
3010 hwconf->MaxCanSetBaudRate[i] = 921600; // add by Victor Yu. 09-04-2002 3110 hwconf->MaxCanSetBaudRate[i] = 921600; /* add by Victor Yu. 09-04-2002 */
3011 } else { 3111 } else {
3012 hwconf->baud_base[i] = 115200; 3112 hwconf->baud_base[i] = 115200;
3013 hwconf->MaxCanSetBaudRate[i] = 115200; // add by Victor Yu. 09-04-2002 3113 hwconf->MaxCanSetBaudRate[i] = 115200; /* add by Victor Yu. 09-04-2002 */
3014 } 3114 }
3015 } 3115 }
3016 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); 3116 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
@@ -3030,7 +3130,7 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3030 hwconf->ports = 4; 3130 hwconf->ports = 4;
3031 request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)"); 3131 request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)");
3032 request_region(hwconf->vector, 1, "mxser(vector)"); 3132 request_region(hwconf->vector, 1, "mxser(vector)");
3033 return (hwconf->ports); 3133 return hwconf->ports;
3034} 3134}
3035 3135
3036#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ 3136#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */
@@ -3053,7 +3153,7 @@ static int mxser_read_register(int port, unsigned short *regs)
3053 3153
3054 id = mxser_program_mode(port); 3154 id = mxser_program_mode(port);
3055 if (id < 0) 3155 if (id < 0)
3056 return (id); 3156 return id;
3057 for (i = 0; i < 14; i++) { 3157 for (i = 0; i < 14; i++) {
3058 k = (i & 0x3F) | 0x180; 3158 k = (i & 0x3F) | 0x180;
3059 for (j = 0x100; j > 0; j >>= 1) { 3159 for (j = 0x100; j > 0; j >>= 1) {
@@ -3066,7 +3166,7 @@ static int mxser_read_register(int port, unsigned short *regs)
3066 outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */ 3166 outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */
3067 } 3167 }
3068 } 3168 }
3069 (void) inb(port); 3169 (void)inb(port);
3070 value = 0; 3170 value = 0;
3071 for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) { 3171 for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) {
3072 outb(CHIP_CS, port); 3172 outb(CHIP_CS, port);
@@ -3078,28 +3178,33 @@ static int mxser_read_register(int port, unsigned short *regs)
3078 outb(0, port); 3178 outb(0, port);
3079 } 3179 }
3080 mxser_normal_mode(port); 3180 mxser_normal_mode(port);
3081 return (id); 3181 return id;
3082} 3182}
3083 3183
3084static int mxser_program_mode(int port) 3184static int mxser_program_mode(int port)
3085{ 3185{
3086 int id, i, j, n; 3186 int id, i, j, n;
3087 //unsigned long flags; 3187 /* unsigned long flags; */
3088 3188
3089 spin_lock(&gm_lock); 3189 spin_lock(&gm_lock);
3090 outb(0, port); 3190 outb(0, port);
3091 outb(0, port); 3191 outb(0, port);
3092 outb(0, port); 3192 outb(0, port);
3093 (void) inb(port); 3193 (void)inb(port);
3094 (void) inb(port); 3194 (void)inb(port);
3095 outb(0, port); 3195 outb(0, port);
3096 (void) inb(port); 3196 (void)inb(port);
3097 //restore_flags(flags); 3197 /* restore_flags(flags); */
3098 spin_unlock(&gm_lock); 3198 spin_unlock(&gm_lock);
3099 3199
3100 id = inb(port + 1) & 0x1F; 3200 id = inb(port + 1) & 0x1F;
3101 if ((id != C168_ASIC_ID) && (id != C104_ASIC_ID) && (id != C102_ASIC_ID) && (id != CI132_ASIC_ID) && (id != CI134_ASIC_ID) && (id != CI104J_ASIC_ID)) 3201 if ((id != C168_ASIC_ID) &&
3102 return (-1); 3202 (id != C104_ASIC_ID) &&
3203 (id != C102_ASIC_ID) &&
3204 (id != CI132_ASIC_ID) &&
3205 (id != CI134_ASIC_ID) &&
3206 (id != CI104J_ASIC_ID))
3207 return -1;
3103 for (i = 0, j = 0; i < 4; i++) { 3208 for (i = 0, j = 0; i < 4; i++) {
3104 n = inb(port + 2); 3209 n = inb(port + 2);
3105 if (n == 'M') { 3210 if (n == 'M') {
@@ -3112,7 +3217,7 @@ static int mxser_program_mode(int port)
3112 } 3217 }
3113 if (j != 2) 3218 if (j != 2)
3114 id = -2; 3219 id = -2;
3115 return (id); 3220 return id;
3116} 3221}
3117 3222
3118static void mxser_normal_mode(int port) 3223static void mxser_normal_mode(int port)
@@ -3130,7 +3235,7 @@ static void mxser_normal_mode(int port)
3130 if ((n & 0x61) == 0x60) 3235 if ((n & 0x61) == 0x60)
3131 break; 3236 break;
3132 if ((n & 1) == 1) 3237 if ((n & 1) == 1)
3133 (void) inb(port); 3238 (void)inb(port);
3134 } 3239 }
3135 outb(0x00, port + 4); 3240 outb(0x00, port + 4);
3136} 3241}
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index c48de09d68f0..203dc2b661d5 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -951,7 +951,8 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg,
951 { 951 {
952queue_the_message: 952queue_the_message:
953 953
954 pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); 954 pMsg = kmalloc(sizeof(struct r3964_message),
955 error_code?GFP_ATOMIC:GFP_KERNEL);
955 TRACE_M("add_msg - kmalloc %p",pMsg); 956 TRACE_M("add_msg - kmalloc %p",pMsg);
956 if(pMsg==NULL) { 957 if(pMsg==NULL) {
957 return; 958 return;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b9371d5bf790..603b9ade5eb0 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1132 * buffer, and once to drain the space from the (physical) beginning of 1132 * buffer, and once to drain the space from the (physical) beginning of
1133 * the buffer to head pointer. 1133 * the buffer to head pointer.
1134 * 1134 *
1135 * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set 1135 * Called under the tty->atomic_read_lock sem
1136 * 1136 *
1137 */ 1137 */
1138 1138
@@ -1271,7 +1271,6 @@ do_it_again:
1271 } 1271 }
1272 1272
1273 add_wait_queue(&tty->read_wait, &wait); 1273 add_wait_queue(&tty->read_wait, &wait);
1274 set_bit(TTY_DONT_FLIP, &tty->flags);
1275 while (nr) { 1274 while (nr) {
1276 /* First test for status change. */ 1275 /* First test for status change. */
1277 if (tty->packet && tty->link->ctrl_status) { 1276 if (tty->packet && tty->link->ctrl_status) {
@@ -1315,9 +1314,7 @@ do_it_again:
1315 break; 1314 break;
1316 } 1315 }
1317 n_tty_set_room(tty); 1316 n_tty_set_room(tty);
1318 clear_bit(TTY_DONT_FLIP, &tty->flags);
1319 timeout = schedule_timeout(timeout); 1317 timeout = schedule_timeout(timeout);
1320 set_bit(TTY_DONT_FLIP, &tty->flags);
1321 continue; 1318 continue;
1322 } 1319 }
1323 __set_current_state(TASK_RUNNING); 1320 __set_current_state(TASK_RUNNING);
@@ -1394,7 +1391,6 @@ do_it_again:
1394 if (time) 1391 if (time)
1395 timeout = time; 1392 timeout = time;
1396 } 1393 }
1397 clear_bit(TTY_DONT_FLIP, &tty->flags);
1398 mutex_unlock(&tty->atomic_read_lock); 1394 mutex_unlock(&tty->atomic_read_lock);
1399 remove_wait_queue(&tty->read_wait, &wait); 1395 remove_wait_queue(&tty->read_wait, &wait);
1400 1396
diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
new file mode 100644
index 000000000000..5b91e4e25641
--- /dev/null
+++ b/drivers/char/nsc_gpio.c
@@ -0,0 +1,142 @@
1/* linux/drivers/char/nsc_gpio.c
2
3 National Semiconductor common GPIO device-file/VFS methods.
4 Allows a user space process to control the GPIO pins.
5
6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
7 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com>
8*/
9
10#include <linux/config.h>
11#include <linux/fs.h>
12#include <linux/module.h>
13#include <linux/errno.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/nsc_gpio.h>
17#include <linux/platform_device.h>
18#include <asm/uaccess.h>
19#include <asm/io.h>
20
21#define NAME "nsc_gpio"
22
23void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
24{
25 /* retrieve current config w/o changing it */
26 u32 config = amp->gpio_config(index, ~0, 0);
27
28 /* user requested via 'v' command, so its INFO */
29 dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\tio:%d/%d\n",
30 index, config,
31 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */
32 (config & 2) ? "PP" : "OD", /* push pull / open drain */
33 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */
34 (config & 8) ? "LOCKED" : "", /* locked / unlocked */
35 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */
36 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */
37 (config & 64) ? "DEBOUNCE" : "", /* debounce */
38
39 amp->gpio_get(index), amp->gpio_current(index));
40}
41
42ssize_t nsc_gpio_write(struct file *file, const char __user *data,
43 size_t len, loff_t *ppos)
44{
45 unsigned m = iminor(file->f_dentry->d_inode);
46 struct nsc_gpio_ops *amp = file->private_data;
47 struct device *dev = amp->dev;
48 size_t i;
49 int err = 0;
50
51 for (i = 0; i < len; ++i) {
52 char c;
53 if (get_user(c, data + i))
54 return -EFAULT;
55 switch (c) {
56 case '0':
57 amp->gpio_set(m, 0);
58 break;
59 case '1':
60 amp->gpio_set(m, 1);
61 break;
62 case 'O':
63 dev_dbg(dev, "GPIO%d output enabled\n", m);
64 amp->gpio_config(m, ~1, 1);
65 break;
66 case 'o':
67 dev_dbg(dev, "GPIO%d output disabled\n", m);
68 amp->gpio_config(m, ~1, 0);
69 break;
70 case 'T':
71 dev_dbg(dev, "GPIO%d output is push pull\n",
72 m);
73 amp->gpio_config(m, ~2, 2);
74 break;
75 case 't':
76 dev_dbg(dev, "GPIO%d output is open drain\n",
77 m);
78 amp->gpio_config(m, ~2, 0);
79 break;
80 case 'P':
81 dev_dbg(dev, "GPIO%d pull up enabled\n", m);
82 amp->gpio_config(m, ~4, 4);
83 break;
84 case 'p':
85 dev_dbg(dev, "GPIO%d pull up disabled\n", m);
86 amp->gpio_config(m, ~4, 0);
87 break;
88 case 'v':
89 /* View Current pin settings */
90 amp->gpio_dump(amp, m);
91 break;
92 case '\n':
93 /* end of settings string, do nothing */
94 break;
95 default:
96 dev_err(dev, "io%2d bad setting: chr<0x%2x>\n",
97 m, (int)c);
98 err++;
99 }
100 }
101 if (err)
102 return -EINVAL; /* full string handled, report error */
103
104 return len;
105}
106
107ssize_t nsc_gpio_read(struct file *file, char __user * buf,
108 size_t len, loff_t * ppos)
109{
110 unsigned m = iminor(file->f_dentry->d_inode);
111 int value;
112 struct nsc_gpio_ops *amp = file->private_data;
113
114 value = amp->gpio_get(m);
115 if (put_user(value ? '1' : '0', buf))
116 return -EFAULT;
117
118 return 1;
119}
120
121/* common file-ops routines for both scx200_gpio and pc87360_gpio */
122EXPORT_SYMBOL(nsc_gpio_write);
123EXPORT_SYMBOL(nsc_gpio_read);
124EXPORT_SYMBOL(nsc_gpio_dump);
125
126static int __init nsc_gpio_init(void)
127{
128 printk(KERN_DEBUG NAME " initializing\n");
129 return 0;
130}
131
132static void __exit nsc_gpio_cleanup(void)
133{
134 printk(KERN_DEBUG NAME " cleanup\n");
135}
136
137module_init(nsc_gpio_init);
138module_exit(nsc_gpio_cleanup);
139
140MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>");
141MODULE_DESCRIPTION("NatSemi GPIO Common Methods");
142MODULE_LICENSE("GPL");
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
new file mode 100644
index 000000000000..1c706ccfdbb3
--- /dev/null
+++ b/drivers/char/pc8736x_gpio.c
@@ -0,0 +1,340 @@
1/* linux/drivers/char/pc8736x_gpio.c
2
3 National Semiconductor PC8736x GPIO driver. Allows a user space
4 process to play with the GPIO pins.
5
6 Copyright (c) 2005 Jim Cromie <jim.cromie@gmail.com>
7
8 adapted from linux/drivers/char/scx200_gpio.c
9 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>,
10*/
11
12#include <linux/config.h>
13#include <linux/fs.h>
14#include <linux/module.h>
15#include <linux/errno.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/io.h>
19#include <linux/ioport.h>
20#include <linux/mutex.h>
21#include <linux/nsc_gpio.h>
22#include <linux/platform_device.h>
23#include <asm/uaccess.h>
24
25#define DEVNAME "pc8736x_gpio"
26
27MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>");
28MODULE_DESCRIPTION("NatSemi PC-8736x GPIO Pin Driver");
29MODULE_LICENSE("GPL");
30
31static int major; /* default to dynamic major */
32module_param(major, int, 0);
33MODULE_PARM_DESC(major, "Major device number");
34
35static DEFINE_MUTEX(pc8736x_gpio_config_lock);
36static unsigned pc8736x_gpio_base;
37static u8 pc8736x_gpio_shadow[4];
38
39#define SIO_BASE1 0x2E /* 1st command-reg to check */
40#define SIO_BASE2 0x4E /* alt command-reg to check */
41#define SIO_BASE_OFFSET 0x20
42
43#define SIO_SID 0x20 /* SuperI/O ID Register */
44#define SIO_SID_VALUE 0xe9 /* Expected value in SuperI/O ID Register */
45
46#define SIO_CF1 0x21 /* chip config, bit0 is chip enable */
47
48#define PC8736X_GPIO_SIZE 16
49
50#define SIO_UNIT_SEL 0x7 /* unit select reg */
51#define SIO_UNIT_ACT 0x30 /* unit enable */
52#define SIO_GPIO_UNIT 0x7 /* unit number of GPIO */
53#define SIO_VLM_UNIT 0x0D
54#define SIO_TMS_UNIT 0x0E
55
56/* config-space addrs to read/write each unit's runtime addr */
57#define SIO_BASE_HADDR 0x60
58#define SIO_BASE_LADDR 0x61
59
60/* GPIO config-space pin-control addresses */
61#define SIO_GPIO_PIN_SELECT 0xF0
62#define SIO_GPIO_PIN_CONFIG 0xF1
63#define SIO_GPIO_PIN_EVENT 0xF2
64
65static unsigned char superio_cmd = 0;
66static unsigned char selected_device = 0xFF; /* bogus start val */
67
68/* GPIO port runtime access, functionality */
69static int port_offset[] = { 0, 4, 8, 10 }; /* non-uniform offsets ! */
70/* static int event_capable[] = { 1, 1, 0, 0 }; ports 2,3 are hobbled */
71
72#define PORT_OUT 0
73#define PORT_IN 1
74#define PORT_EVT_EN 2
75#define PORT_EVT_STST 3
76
77static struct platform_device *pdev; /* use in dev_*() */
78
79static inline void superio_outb(int addr, int val)
80{
81 outb_p(addr, superio_cmd);
82 outb_p(val, superio_cmd + 1);
83}
84
85static inline int superio_inb(int addr)
86{
87 outb_p(addr, superio_cmd);
88 return inb_p(superio_cmd + 1);
89}
90
91static int pc8736x_superio_present(void)
92{
93 /* try the 2 possible values, read a hardware reg to verify */
94 superio_cmd = SIO_BASE1;
95 if (superio_inb(SIO_SID) == SIO_SID_VALUE)
96 return superio_cmd;
97
98 superio_cmd = SIO_BASE2;
99 if (superio_inb(SIO_SID) == SIO_SID_VALUE)
100 return superio_cmd;
101
102 return 0;
103}
104
105static void device_select(unsigned devldn)
106{
107 superio_outb(SIO_UNIT_SEL, devldn);
108 selected_device = devldn;
109}
110
111static void select_pin(unsigned iminor)
112{
113 /* select GPIO port/pin from device minor number */
114 device_select(SIO_GPIO_UNIT);
115 superio_outb(SIO_GPIO_PIN_SELECT,
116 ((iminor << 1) & 0xF0) | (iminor & 0x7));
117}
118
119static inline u32 pc8736x_gpio_configure_fn(unsigned index, u32 mask, u32 bits,
120 u32 func_slct)
121{
122 u32 config, new_config;
123
124 mutex_lock(&pc8736x_gpio_config_lock);
125
126 device_select(SIO_GPIO_UNIT);
127 select_pin(index);
128
129 /* read current config value */
130 config = superio_inb(func_slct);
131
132 /* set new config */
133 new_config = (config & mask) | bits;
134 superio_outb(func_slct, new_config);
135
136 mutex_unlock(&pc8736x_gpio_config_lock);
137
138 return config;
139}
140
141static u32 pc8736x_gpio_configure(unsigned index, u32 mask, u32 bits)
142{
143 return pc8736x_gpio_configure_fn(index, mask, bits,
144 SIO_GPIO_PIN_CONFIG);
145}
146
147static int pc8736x_gpio_get(unsigned minor)
148{
149 int port, bit, val;
150
151 port = minor >> 3;
152 bit = minor & 7;
153 val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN);
154 val >>= bit;
155 val &= 1;
156
157 dev_dbg(&pdev->dev, "_gpio_get(%d from %x bit %d) == val %d\n",
158 minor, pc8736x_gpio_base + port_offset[port] + PORT_IN, bit,
159 val);
160
161 return val;
162}
163
164static void pc8736x_gpio_set(unsigned minor, int val)
165{
166 int port, bit, curval;
167
168 minor &= 0x1f;
169 port = minor >> 3;
170 bit = minor & 7;
171 curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT);
172
173 dev_dbg(&pdev->dev, "addr:%x cur:%x bit-pos:%d cur-bit:%x + new:%d -> bit-new:%d\n",
174 pc8736x_gpio_base + port_offset[port] + PORT_OUT,
175 curval, bit, (curval & ~(1 << bit)), val, (val << bit));
176
177 val = (curval & ~(1 << bit)) | (val << bit);
178
179 dev_dbg(&pdev->dev, "gpio_set(minor:%d port:%d bit:%d)"
180 " %2x -> %2x\n", minor, port, bit, curval, val);
181
182 outb_p(val, pc8736x_gpio_base + port_offset[port] + PORT_OUT);
183
184 curval = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_OUT);
185 val = inb_p(pc8736x_gpio_base + port_offset[port] + PORT_IN);
186
187 dev_dbg(&pdev->dev, "wrote %x, read: %x\n", curval, val);
188 pc8736x_gpio_shadow[port] = val;
189}
190
191static void pc8736x_gpio_set_high(unsigned index)
192{
193 pc8736x_gpio_set(index, 1);
194}
195
196static void pc8736x_gpio_set_low(unsigned index)
197{
198 pc8736x_gpio_set(index, 0);
199}
200
201static int pc8736x_gpio_current(unsigned minor)
202{
203 int port, bit;
204 minor &= 0x1f;
205 port = minor >> 3;
206 bit = minor & 7;
207 return ((pc8736x_gpio_shadow[port] >> bit) & 0x01);
208}
209
210static void pc8736x_gpio_change(unsigned index)
211{
212 pc8736x_gpio_set(index, !pc8736x_gpio_current(index));
213}
214
215static struct nsc_gpio_ops pc8736x_access = {
216 .owner = THIS_MODULE,
217 .gpio_config = pc8736x_gpio_configure,
218 .gpio_dump = nsc_gpio_dump,
219 .gpio_get = pc8736x_gpio_get,
220 .gpio_set = pc8736x_gpio_set,
221 .gpio_set_high = pc8736x_gpio_set_high,
222 .gpio_set_low = pc8736x_gpio_set_low,
223 .gpio_change = pc8736x_gpio_change,
224 .gpio_current = pc8736x_gpio_current
225};
226
227static int pc8736x_gpio_open(struct inode *inode, struct file *file)
228{
229 unsigned m = iminor(inode);
230 file->private_data = &pc8736x_access;
231
232 dev_dbg(&pdev->dev, "open %d\n", m);
233
234 if (m > 63)
235 return -EINVAL;
236 return nonseekable_open(inode, file);
237}
238
239static struct file_operations pc8736x_gpio_fops = {
240 .owner = THIS_MODULE,
241 .open = pc8736x_gpio_open,
242 .write = nsc_gpio_write,
243 .read = nsc_gpio_read,
244};
245
246static void __init pc8736x_init_shadow(void)
247{
248 int port;
249
250 /* read the current values driven on the GPIO signals */
251 for (port = 0; port < 4; ++port)
252 pc8736x_gpio_shadow[port]
253 = inb_p(pc8736x_gpio_base + port_offset[port]
254 + PORT_OUT);
255
256}
257
258static int __init pc8736x_gpio_init(void)
259{
260 int rc = 0;
261
262 pdev = platform_device_alloc(DEVNAME, 0);
263 if (!pdev)
264 return -ENOMEM;
265
266 rc = platform_device_add(pdev);
267 if (rc) {
268 rc = -ENODEV;
269 goto undo_platform_dev_alloc;
270 }
271 dev_info(&pdev->dev, "NatSemi pc8736x GPIO Driver Initializing\n");
272
273 if (!pc8736x_superio_present()) {
274 rc = -ENODEV;
275 dev_err(&pdev->dev, "no device found\n");
276 goto undo_platform_dev_add;
277 }
278 pc8736x_access.dev = &pdev->dev;
279
280 /* Verify that chip and it's GPIO unit are both enabled.
281 My BIOS does this, so I take minimum action here
282 */
283 rc = superio_inb(SIO_CF1);
284 if (!(rc & 0x01)) {
285 rc = -ENODEV;
286 dev_err(&pdev->dev, "device not enabled\n");
287 goto undo_platform_dev_add;
288 }
289 device_select(SIO_GPIO_UNIT);
290 if (!superio_inb(SIO_UNIT_ACT)) {
291 rc = -ENODEV;
292 dev_err(&pdev->dev, "GPIO unit not enabled\n");
293 goto undo_platform_dev_add;
294 }
295
296 /* read the GPIO unit base addr that chip responds to */
297 pc8736x_gpio_base = (superio_inb(SIO_BASE_HADDR) << 8
298 | superio_inb(SIO_BASE_LADDR));
299
300 if (!request_region(pc8736x_gpio_base, 16, DEVNAME)) {
301 rc = -ENODEV;
302 dev_err(&pdev->dev, "GPIO ioport %x busy\n",
303 pc8736x_gpio_base);
304 goto undo_platform_dev_add;
305 }
306 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);
307
308 rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops);
309 if (rc < 0) {
310 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
311 goto undo_platform_dev_add;
312 }
313 if (!major) {
314 major = rc;
315 dev_dbg(&pdev->dev, "got dynamic major %d\n", major);
316 }
317
318 pc8736x_init_shadow();
319 return 0;
320
321undo_platform_dev_add:
322 platform_device_put(pdev);
323undo_platform_dev_alloc:
324 kfree(pdev);
325 return rc;
326}
327
328static void __exit pc8736x_gpio_cleanup(void)
329{
330 dev_dbg(&pdev->dev, " cleanup\n");
331
332 release_region(pc8736x_gpio_base, 16);
333
334 unregister_chrdev(major, DEVNAME);
335}
336
337EXPORT_SYMBOL(pc8736x_access);
338
339module_init(pc8736x_gpio_init);
340module_exit(pc8736x_gpio_cleanup);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 07213454c458..17bc8abd5df5 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -844,7 +844,7 @@ static int bh_action(MGSLPC_INFO *info)
844 return rc; 844 return rc;
845} 845}
846 846
847void bh_handler(void* Context) 847static void bh_handler(void* Context)
848{ 848{
849 MGSLPC_INFO *info = (MGSLPC_INFO*)Context; 849 MGSLPC_INFO *info = (MGSLPC_INFO*)Context;
850 int action; 850 int action;
@@ -888,7 +888,7 @@ void bh_handler(void* Context)
888 __FILE__,__LINE__,info->device_name); 888 __FILE__,__LINE__,info->device_name);
889} 889}
890 890
891void bh_transmit(MGSLPC_INFO *info) 891static void bh_transmit(MGSLPC_INFO *info)
892{ 892{
893 struct tty_struct *tty = info->tty; 893 struct tty_struct *tty = info->tty;
894 if (debug_level >= DEBUG_LEVEL_BH) 894 if (debug_level >= DEBUG_LEVEL_BH)
@@ -900,7 +900,7 @@ void bh_transmit(MGSLPC_INFO *info)
900 } 900 }
901} 901}
902 902
903void bh_status(MGSLPC_INFO *info) 903static void bh_status(MGSLPC_INFO *info)
904{ 904{
905 info->ri_chkcount = 0; 905 info->ri_chkcount = 0;
906 info->dsr_chkcount = 0; 906 info->dsr_chkcount = 0;
@@ -1582,7 +1582,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
1582 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) 1582 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char"))
1583 return; 1583 return;
1584 1584
1585 if (!tty || !info->tx_buf) 1585 if (!info->tx_buf)
1586 return; 1586 return;
1587 1587
1588 spin_lock_irqsave(&info->lock,flags); 1588 spin_lock_irqsave(&info->lock,flags);
@@ -1649,7 +1649,7 @@ static int mgslpc_write(struct tty_struct * tty,
1649 __FILE__,__LINE__,info->device_name,count); 1649 __FILE__,__LINE__,info->device_name,count);
1650 1650
1651 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") || 1651 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write") ||
1652 !tty || !info->tx_buf) 1652 !info->tx_buf)
1653 goto cleanup; 1653 goto cleanup;
1654 1654
1655 if (info->params.mode == MGSL_MODE_HDLC) { 1655 if (info->params.mode == MGSL_MODE_HDLC) {
@@ -2305,7 +2305,7 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file,
2305 return ioctl_common(info, cmd, arg); 2305 return ioctl_common(info, cmd, arg);
2306} 2306}
2307 2307
2308int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) 2308static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg)
2309{ 2309{
2310 int error; 2310 int error;
2311 struct mgsl_icount cnow; /* kernel counter temps */ 2311 struct mgsl_icount cnow; /* kernel counter temps */
@@ -2877,7 +2877,7 @@ done:
2877 return ((count < begin+len-off) ? count : begin+len-off); 2877 return ((count < begin+len-off) ? count : begin+len-off);
2878} 2878}
2879 2879
2880int rx_alloc_buffers(MGSLPC_INFO *info) 2880static int rx_alloc_buffers(MGSLPC_INFO *info)
2881{ 2881{
2882 /* each buffer has header and data */ 2882 /* each buffer has header and data */
2883 info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size; 2883 info->rx_buf_size = sizeof(RXBUF) + info->max_frame_size;
@@ -2900,13 +2900,13 @@ int rx_alloc_buffers(MGSLPC_INFO *info)
2900 return 0; 2900 return 0;
2901} 2901}
2902 2902
2903void rx_free_buffers(MGSLPC_INFO *info) 2903static void rx_free_buffers(MGSLPC_INFO *info)
2904{ 2904{
2905 kfree(info->rx_buf); 2905 kfree(info->rx_buf);
2906 info->rx_buf = NULL; 2906 info->rx_buf = NULL;
2907} 2907}
2908 2908
2909int claim_resources(MGSLPC_INFO *info) 2909static int claim_resources(MGSLPC_INFO *info)
2910{ 2910{
2911 if (rx_alloc_buffers(info) < 0 ) { 2911 if (rx_alloc_buffers(info) < 0 ) {
2912 printk( "Cant allocate rx buffer %s\n", info->device_name); 2912 printk( "Cant allocate rx buffer %s\n", info->device_name);
@@ -2916,7 +2916,7 @@ int claim_resources(MGSLPC_INFO *info)
2916 return 0; 2916 return 0;
2917} 2917}
2918 2918
2919void release_resources(MGSLPC_INFO *info) 2919static void release_resources(MGSLPC_INFO *info)
2920{ 2920{
2921 if (debug_level >= DEBUG_LEVEL_INFO) 2921 if (debug_level >= DEBUG_LEVEL_INFO)
2922 printk("release_resources(%s)\n", info->device_name); 2922 printk("release_resources(%s)\n", info->device_name);
@@ -2928,7 +2928,7 @@ void release_resources(MGSLPC_INFO *info)
2928 * 2928 *
2929 * Arguments: info pointer to device instance data 2929 * Arguments: info pointer to device instance data
2930 */ 2930 */
2931void mgslpc_add_device(MGSLPC_INFO *info) 2931static void mgslpc_add_device(MGSLPC_INFO *info)
2932{ 2932{
2933 info->next_device = NULL; 2933 info->next_device = NULL;
2934 info->line = mgslpc_device_count; 2934 info->line = mgslpc_device_count;
@@ -2964,7 +2964,7 @@ void mgslpc_add_device(MGSLPC_INFO *info)
2964#endif 2964#endif
2965} 2965}
2966 2966
2967void mgslpc_remove_device(MGSLPC_INFO *remove_info) 2967static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
2968{ 2968{
2969 MGSLPC_INFO *info = mgslpc_device_list; 2969 MGSLPC_INFO *info = mgslpc_device_list;
2970 MGSLPC_INFO *last = NULL; 2970 MGSLPC_INFO *last = NULL;
@@ -3257,7 +3257,7 @@ static void loopback_enable(MGSLPC_INFO *info)
3257 write_reg(info, CHA + MODE, val); 3257 write_reg(info, CHA + MODE, val);
3258} 3258}
3259 3259
3260void hdlc_mode(MGSLPC_INFO *info) 3260static void hdlc_mode(MGSLPC_INFO *info)
3261{ 3261{
3262 unsigned char val; 3262 unsigned char val;
3263 unsigned char clkmode, clksubmode; 3263 unsigned char clkmode, clksubmode;
@@ -3497,7 +3497,7 @@ void hdlc_mode(MGSLPC_INFO *info)
3497 rx_stop(info); 3497 rx_stop(info);
3498} 3498}
3499 3499
3500void rx_stop(MGSLPC_INFO *info) 3500static void rx_stop(MGSLPC_INFO *info)
3501{ 3501{
3502 if (debug_level >= DEBUG_LEVEL_ISR) 3502 if (debug_level >= DEBUG_LEVEL_ISR)
3503 printk("%s(%d):rx_stop(%s)\n", 3503 printk("%s(%d):rx_stop(%s)\n",
@@ -3510,7 +3510,7 @@ void rx_stop(MGSLPC_INFO *info)
3510 info->rx_overflow = 0; 3510 info->rx_overflow = 0;
3511} 3511}
3512 3512
3513void rx_start(MGSLPC_INFO *info) 3513static void rx_start(MGSLPC_INFO *info)
3514{ 3514{
3515 if (debug_level >= DEBUG_LEVEL_ISR) 3515 if (debug_level >= DEBUG_LEVEL_ISR)
3516 printk("%s(%d):rx_start(%s)\n", 3516 printk("%s(%d):rx_start(%s)\n",
@@ -3526,7 +3526,7 @@ void rx_start(MGSLPC_INFO *info)
3526 info->rx_enabled = 1; 3526 info->rx_enabled = 1;
3527} 3527}
3528 3528
3529void tx_start(MGSLPC_INFO *info) 3529static void tx_start(MGSLPC_INFO *info)
3530{ 3530{
3531 if (debug_level >= DEBUG_LEVEL_ISR) 3531 if (debug_level >= DEBUG_LEVEL_ISR)
3532 printk("%s(%d):tx_start(%s)\n", 3532 printk("%s(%d):tx_start(%s)\n",
@@ -3564,7 +3564,7 @@ void tx_start(MGSLPC_INFO *info)
3564 info->tx_enabled = 1; 3564 info->tx_enabled = 1;
3565} 3565}
3566 3566
3567void tx_stop(MGSLPC_INFO *info) 3567static void tx_stop(MGSLPC_INFO *info)
3568{ 3568{
3569 if (debug_level >= DEBUG_LEVEL_ISR) 3569 if (debug_level >= DEBUG_LEVEL_ISR)
3570 printk("%s(%d):tx_stop(%s)\n", 3570 printk("%s(%d):tx_stop(%s)\n",
@@ -3578,7 +3578,7 @@ void tx_stop(MGSLPC_INFO *info)
3578 3578
3579/* Reset the adapter to a known state and prepare it for further use. 3579/* Reset the adapter to a known state and prepare it for further use.
3580 */ 3580 */
3581void reset_device(MGSLPC_INFO *info) 3581static void reset_device(MGSLPC_INFO *info)
3582{ 3582{
3583 /* power up both channels (set BIT7) */ 3583 /* power up both channels (set BIT7) */
3584 write_reg(info, CHA + CCR0, 0x80); 3584 write_reg(info, CHA + CCR0, 0x80);
@@ -3628,7 +3628,7 @@ void reset_device(MGSLPC_INFO *info)
3628 write_reg(info, IPC, 0x05); 3628 write_reg(info, IPC, 0x05);
3629} 3629}
3630 3630
3631void async_mode(MGSLPC_INFO *info) 3631static void async_mode(MGSLPC_INFO *info)
3632{ 3632{
3633 unsigned char val; 3633 unsigned char val;
3634 3634
@@ -3799,7 +3799,7 @@ void async_mode(MGSLPC_INFO *info)
3799 3799
3800/* Set the HDLC idle mode for the transmitter. 3800/* Set the HDLC idle mode for the transmitter.
3801 */ 3801 */
3802void tx_set_idle(MGSLPC_INFO *info) 3802static void tx_set_idle(MGSLPC_INFO *info)
3803{ 3803{
3804 /* Note: ESCC2 only supports flags and one idle modes */ 3804 /* Note: ESCC2 only supports flags and one idle modes */
3805 if (info->idle_mode == HDLC_TXIDLE_FLAGS) 3805 if (info->idle_mode == HDLC_TXIDLE_FLAGS)
@@ -3810,7 +3810,7 @@ void tx_set_idle(MGSLPC_INFO *info)
3810 3810
3811/* get state of the V24 status (input) signals. 3811/* get state of the V24 status (input) signals.
3812 */ 3812 */
3813void get_signals(MGSLPC_INFO *info) 3813static void get_signals(MGSLPC_INFO *info)
3814{ 3814{
3815 unsigned char status = 0; 3815 unsigned char status = 0;
3816 3816
@@ -3832,7 +3832,7 @@ void get_signals(MGSLPC_INFO *info)
3832/* Set the state of DTR and RTS based on contents of 3832/* Set the state of DTR and RTS based on contents of
3833 * serial_signals member of device extension. 3833 * serial_signals member of device extension.
3834 */ 3834 */
3835void set_signals(MGSLPC_INFO *info) 3835static void set_signals(MGSLPC_INFO *info)
3836{ 3836{
3837 unsigned char val; 3837 unsigned char val;
3838 3838
@@ -3856,7 +3856,7 @@ void set_signals(MGSLPC_INFO *info)
3856 set_reg_bits(info, CHA + PVR, PVR_DTR); 3856 set_reg_bits(info, CHA + PVR, PVR_DTR);
3857} 3857}
3858 3858
3859void rx_reset_buffers(MGSLPC_INFO *info) 3859static void rx_reset_buffers(MGSLPC_INFO *info)
3860{ 3860{
3861 RXBUF *buf; 3861 RXBUF *buf;
3862 int i; 3862 int i;
@@ -3875,7 +3875,7 @@ void rx_reset_buffers(MGSLPC_INFO *info)
3875 * 3875 *
3876 * Returns 1 if frame returned, otherwise 0 3876 * Returns 1 if frame returned, otherwise 0
3877 */ 3877 */
3878int rx_get_frame(MGSLPC_INFO *info) 3878static int rx_get_frame(MGSLPC_INFO *info)
3879{ 3879{
3880 unsigned short status; 3880 unsigned short status;
3881 RXBUF *buf; 3881 RXBUF *buf;
@@ -3961,7 +3961,7 @@ int rx_get_frame(MGSLPC_INFO *info)
3961 return 1; 3961 return 1;
3962} 3962}
3963 3963
3964BOOLEAN register_test(MGSLPC_INFO *info) 3964static BOOLEAN register_test(MGSLPC_INFO *info)
3965{ 3965{
3966 static unsigned char patterns[] = 3966 static unsigned char patterns[] =
3967 { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; 3967 { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f };
@@ -3987,7 +3987,7 @@ BOOLEAN register_test(MGSLPC_INFO *info)
3987 return rc; 3987 return rc;
3988} 3988}
3989 3989
3990BOOLEAN irq_test(MGSLPC_INFO *info) 3990static BOOLEAN irq_test(MGSLPC_INFO *info)
3991{ 3991{
3992 unsigned long end_time; 3992 unsigned long end_time;
3993 unsigned long flags; 3993 unsigned long flags;
@@ -4022,7 +4022,7 @@ BOOLEAN irq_test(MGSLPC_INFO *info)
4022 return info->irq_occurred ? TRUE : FALSE; 4022 return info->irq_occurred ? TRUE : FALSE;
4023} 4023}
4024 4024
4025int adapter_test(MGSLPC_INFO *info) 4025static int adapter_test(MGSLPC_INFO *info)
4026{ 4026{
4027 if (!register_test(info)) { 4027 if (!register_test(info)) {
4028 info->init_error = DiagStatus_AddressFailure; 4028 info->init_error = DiagStatus_AddressFailure;
@@ -4044,7 +4044,7 @@ int adapter_test(MGSLPC_INFO *info)
4044 return 0; 4044 return 0;
4045} 4045}
4046 4046
4047void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit) 4047static void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit)
4048{ 4048{
4049 int i; 4049 int i;
4050 int linecount; 4050 int linecount;
@@ -4079,7 +4079,7 @@ void trace_block(MGSLPC_INFO *info,const char* data, int count, int xmit)
4079/* HDLC frame time out 4079/* HDLC frame time out
4080 * update stats and do tx completion processing 4080 * update stats and do tx completion processing
4081 */ 4081 */
4082void tx_timeout(unsigned long context) 4082static void tx_timeout(unsigned long context)
4083{ 4083{
4084 MGSLPC_INFO *info = (MGSLPC_INFO*)context; 4084 MGSLPC_INFO *info = (MGSLPC_INFO*)context;
4085 unsigned long flags; 4085 unsigned long flags;
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 9b5a2c0e7008..0c17f61549b4 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -101,7 +101,7 @@ static void pty_unthrottle(struct tty_struct * tty)
101 * 101 *
102 * FIXME: Our pty_write method is called with our ldisc lock held but 102 * FIXME: Our pty_write method is called with our ldisc lock held but
103 * not our partners. We can't just take the other one blindly without 103 * not our partners. We can't just take the other one blindly without
104 * risking deadlocks. There is also the small matter of TTY_DONT_FLIP 104 * risking deadlocks.
105 */ 105 */
106static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count) 106static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count)
107{ 107{
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 5818a8aa46e0..6e63f8b2c479 100644
--- a/drivers/char/rio/daemon.h
+++ b/drivers/char/rio/daemon.h
@@ -51,7 +51,7 @@ struct Error {
51}; 51};
52 52
53struct DownLoad { 53struct DownLoad {
54 char *DataP; 54 char __user *DataP;
55 unsigned int Count; 55 unsigned int Count;
56 unsigned int ProductCode; 56 unsigned int ProductCode;
57}; 57};
@@ -83,18 +83,18 @@ struct PortSetup {
83struct LpbReq { 83struct LpbReq {
84 unsigned int Host; 84 unsigned int Host;
85 unsigned int Link; 85 unsigned int Link;
86 struct LPB *LpbP; 86 struct LPB __user *LpbP;
87}; 87};
88 88
89struct RupReq { 89struct RupReq {
90 unsigned int HostNum; 90 unsigned int HostNum;
91 unsigned int RupNum; 91 unsigned int RupNum;
92 struct RUP *RupP; 92 struct RUP __user *RupP;
93}; 93};
94 94
95struct PortReq { 95struct PortReq {
96 unsigned int SysPort; 96 unsigned int SysPort;
97 struct Port *PortP; 97 struct Port __user *PortP;
98}; 98};
99 99
100struct StreamInfo { 100struct StreamInfo {
@@ -105,12 +105,12 @@ struct StreamInfo {
105 105
106struct HostReq { 106struct HostReq {
107 unsigned int HostNum; 107 unsigned int HostNum;
108 struct Host *HostP; 108 struct Host __user *HostP;
109}; 109};
110 110
111struct HostDpRam { 111struct HostDpRam {
112 unsigned int HostNum; 112 unsigned int HostNum;
113 struct DpRam *DpRamP; 113 struct DpRam __user *DpRamP;
114}; 114};
115 115
116struct DebugCtrl { 116struct DebugCtrl {
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index e64fe9912394..6b039186856d 100644
--- a/drivers/char/rio/func.h
+++ b/drivers/char/rio/func.h
@@ -46,7 +46,7 @@ int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
46int RIOBootCodeHOST(struct rio_info *, struct DownLoad *); 46int RIOBootCodeHOST(struct rio_info *, struct DownLoad *);
47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *); 47int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
48void msec_timeout(struct Host *); 48void msec_timeout(struct Host *);
49int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *); 49int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *);
50int RIOBootOk(struct rio_info *, struct Host *, unsigned long); 50int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
51int RIORtaBound(struct rio_info *, unsigned int); 51int RIORtaBound(struct rio_info *, unsigned int);
52void rio_fill_host_slot(int, int, unsigned int, struct Host *); 52void rio_fill_host_slot(int, int, unsigned int, struct Host *);
@@ -55,8 +55,8 @@ void rio_fill_host_slot(int, int, unsigned int, struct Host *);
55int RIOFoadRta(struct Host *, struct Map *); 55int RIOFoadRta(struct Host *, struct Map *);
56int RIOZombieRta(struct Host *, struct Map *); 56int RIOZombieRta(struct Host *, struct Map *);
57int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *)); 57int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
58int RIOIdentifyRta(struct rio_info *, void *); 58int RIOIdentifyRta(struct rio_info *, void __user *);
59int RIOKillNeighbour(struct rio_info *, void *); 59int RIOKillNeighbour(struct rio_info *, void __user *);
60int RIOSuspendBootRta(struct Host *, int, int); 60int RIOSuspendBootRta(struct Host *, int, int);
61int RIOFoadWakeup(struct rio_info *); 61int RIOFoadWakeup(struct rio_info *);
62struct CmdBlk *RIOGetCmdBlk(void); 62struct CmdBlk *RIOGetCmdBlk(void);
@@ -68,7 +68,8 @@ int RIORFlushEnable(unsigned long, struct CmdBlk *);
68int RIOUnUse(unsigned long, struct CmdBlk *); 68int RIOUnUse(unsigned long, struct CmdBlk *);
69 69
70/* rioctrl.c */ 70/* rioctrl.c */
71int riocontrol(struct rio_info *, dev_t, int, caddr_t, int); 71int riocontrol(struct rio_info *, dev_t, int, unsigned long, int);
72
72int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char); 73int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);
73 74
74/* rioinit.c */ 75/* rioinit.c */
@@ -77,13 +78,13 @@ void RIOInitHosts(struct rio_info *, struct RioHostInfo *);
77void RIOISAinit(struct rio_info *, int); 78void RIOISAinit(struct rio_info *, int);
78int RIODoAT(struct rio_info *, int, int); 79int RIODoAT(struct rio_info *, int, int);
79caddr_t RIOCheckForATCard(int); 80caddr_t RIOCheckForATCard(int);
80int RIOAssignAT(struct rio_info *, int, caddr_t, int); 81int RIOAssignAT(struct rio_info *, int, void __iomem *, int);
81int RIOBoardTest(unsigned long, caddr_t, unsigned char, int); 82int RIOBoardTest(unsigned long, void __iomem *, unsigned char, int);
82void RIOAllocDataStructs(struct rio_info *); 83void RIOAllocDataStructs(struct rio_info *);
83void RIOSetupDataStructs(struct rio_info *); 84void RIOSetupDataStructs(struct rio_info *);
84int RIODefaultName(struct rio_info *, struct Host *, unsigned int); 85int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
85struct rioVersion *RIOVersid(void); 86struct rioVersion *RIOVersid(void);
86void RIOHostReset(unsigned int, struct DpRam *, unsigned int); 87void RIOHostReset(unsigned int, struct DpRam __iomem *, unsigned int);
87 88
88/* riointr.c */ 89/* riointr.c */
89void RIOTxEnable(char *); 90void RIOTxEnable(char *);
@@ -95,14 +96,14 @@ int RIOParam(struct Port *, int, int, int);
95int RIODelay(struct Port *PortP, int); 96int RIODelay(struct Port *PortP, int);
96int RIODelay_ni(struct Port *PortP, int); 97int RIODelay_ni(struct Port *PortP, int);
97void ms_timeout(struct Port *); 98void ms_timeout(struct Port *);
98int can_add_transmit(struct PKT **, struct Port *); 99int can_add_transmit(struct PKT __iomem **, struct Port *);
99void add_transmit(struct Port *); 100void add_transmit(struct Port *);
100void put_free_end(struct Host *, struct PKT *); 101void put_free_end(struct Host *, struct PKT __iomem *);
101int can_remove_receive(struct PKT **, struct Port *); 102int can_remove_receive(struct PKT __iomem **, struct Port *);
102void remove_receive(struct Port *); 103void remove_receive(struct Port *);
103 104
104/* rioroute.c */ 105/* rioroute.c */
105int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *); 106int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *);
106void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int); 107void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
107unsigned int GetUnitType(unsigned int); 108unsigned int GetUnitType(unsigned int);
108int RIOSetChange(struct rio_info *); 109int RIOSetChange(struct rio_info *);
@@ -139,7 +140,7 @@ int rio_isr_thread(char *);
139struct rio_info *rio_info_store(int cmd, struct rio_info *p); 140struct rio_info *rio_info_store(int cmd, struct rio_info *p);
140#endif 141#endif
141 142
142extern void rio_copy_to_card(void *to, void *from, int len); 143extern void rio_copy_to_card(void *from, void __iomem *to, int len);
143extern int rio_minor(struct tty_struct *tty); 144extern int rio_minor(struct tty_struct *tty);
144extern int rio_ismodem(struct tty_struct *tty); 145extern int rio_ismodem(struct tty_struct *tty);
145 146
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index 179cdbea712b..ee2ddea7a63a 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -48,8 +48,8 @@ struct Host {
48 unsigned char Ivec; /* POLLED or ivec number */ 48 unsigned char Ivec; /* POLLED or ivec number */
49 unsigned char Mode; /* Control stuff */ 49 unsigned char Mode; /* Control stuff */
50 unsigned char Slot; /* Slot */ 50 unsigned char Slot; /* Slot */
51 caddr_t Caddr; /* KV address of DPRAM */ 51 void __iomem *Caddr; /* KV address of DPRAM */
52 struct DpRam *CardP; /* KV address of DPRAM, with overlay */ 52 struct DpRam __iomem *CardP; /* KV address of DPRAM, with overlay */
53 unsigned long PaddrP; /* Phys. address of DPRAM */ 53 unsigned long PaddrP; /* Phys. address of DPRAM */
54 char Name[MAX_NAME_LEN]; /* The name of the host */ 54 char Name[MAX_NAME_LEN]; /* The name of the host */
55 unsigned int UniqueNum; /* host unique number */ 55 unsigned int UniqueNum; /* host unique number */
@@ -57,7 +57,7 @@ struct Host {
57 unsigned int WorkToBeDone; /* set to true each interrupt */ 57 unsigned int WorkToBeDone; /* set to true each interrupt */
58 unsigned int InIntr; /* Being serviced? */ 58 unsigned int InIntr; /* Being serviced? */
59 unsigned int IntSrvDone; /* host's interrupt has been serviced */ 59 unsigned int IntSrvDone; /* host's interrupt has been serviced */
60 void (*Copy) (void *, void *, int); /* copy func */ 60 void (*Copy) (void *, void __iomem *, int); /* copy func */
61 struct timer_list timer; 61 struct timer_list timer;
62 /* 62 /*
63 ** I M P O R T A N T ! 63 ** I M P O R T A N T !
@@ -83,11 +83,11 @@ struct Host {
83 83
84 struct Top Topology[LINKS_PER_UNIT]; /* one per link */ 84 struct Top Topology[LINKS_PER_UNIT]; /* one per link */
85 struct Map Mapping[MAX_RUP]; /* Mappings for host */ 85 struct Map Mapping[MAX_RUP]; /* Mappings for host */
86 struct PHB *PhbP; /* Pointer to the PHB array */ 86 struct PHB __iomem *PhbP; /* Pointer to the PHB array */
87 unsigned short *PhbNumP; /* Ptr to Number of PHB's */ 87 unsigned short __iomem *PhbNumP; /* Ptr to Number of PHB's */
88 struct LPB *LinkStrP; /* Link Structure Array */ 88 struct LPB __iomem *LinkStrP; /* Link Structure Array */
89 struct RUP *RupP; /* Sixteen real rups here */ 89 struct RUP __iomem *RupP; /* Sixteen real rups here */
90 struct PARM_MAP *ParmMapP; /* points to the parmmap */ 90 struct PARM_MAP __iomem *ParmMapP; /* points to the parmmap */
91 unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */ 91 unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
92 unsigned int NumExtraBooted; /* how many of the above */ 92 unsigned int NumExtraBooted; /* how many of the above */
93 /* 93 /*
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index 9b5fa3eb0402..49cf6d15ee54 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -40,7 +40,7 @@ struct Port {
40 struct gs_port gs; 40 struct gs_port gs;
41 int PortNum; /* RIO port no., 0-511 */ 41 int PortNum; /* RIO port no., 0-511 */
42 struct Host *HostP; 42 struct Host *HostP;
43 caddr_t Caddr; 43 void __iomem *Caddr;
44 unsigned short HostPort; /* Port number on host card */ 44 unsigned short HostPort; /* Port number on host card */
45 unsigned char RupNum; /* Number of RUP for port */ 45 unsigned char RupNum; /* Number of RUP for port */
46 unsigned char ID2; /* Second ID of RTA for port */ 46 unsigned char ID2; /* Second ID of RTA for port */
@@ -92,13 +92,13 @@ struct Port {
92#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */ 92#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
93 93
94 94
95 struct PHB *PhbP; /* pointer to PHB for port */ 95 struct PHB __iomem *PhbP; /* pointer to PHB for port */
96 u16 *TxAdd; /* Add packets here */ 96 u16 __iomem *TxAdd; /* Add packets here */
97 u16 *TxStart; /* Start of add array */ 97 u16 __iomem *TxStart; /* Start of add array */
98 u16 *TxEnd; /* End of add array */ 98 u16 __iomem *TxEnd; /* End of add array */
99 u16 *RxRemove; /* Remove packets here */ 99 u16 __iomem *RxRemove; /* Remove packets here */
100 u16 *RxStart; /* Start of remove array */ 100 u16 __iomem *RxStart; /* Start of remove array */
101 u16 *RxEnd; /* End of remove array */ 101 u16 __iomem *RxEnd; /* End of remove array */
102 unsigned int RtaUniqueNum; /* Unique number of RTA */ 102 unsigned int RtaUniqueNum; /* Unique number of RTA */
103 unsigned short PortState; /* status of port */ 103 unsigned short PortState; /* status of port */
104 unsigned short ModemState; /* status of modem lines */ 104 unsigned short ModemState; /* status of modem lines */
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index b4c91871ba28..1bf36223a4e8 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -129,8 +129,8 @@
129** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and 129** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
130** returns the offset into the DP RAM area. 130** returns the offset into the DP RAM area.
131*/ 131*/
132#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O))) 132#define RIO_PTR(C,O) (((unsigned char __iomem *)(C))+(0xFFFF&(O)))
133#define RIO_OFF(C,O) ((long)(O)-(long)(C)) 133#define RIO_OFF(C,O) ((unsigned char __iomem *)(O)-(unsigned char __iomem *)(C))
134 134
135/* 135/*
136** How to convert from various different device number formats: 136** How to convert from various different device number formats:
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 78dd856534ce..aa43436d5d1b 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -333,9 +333,9 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
333 return !RIO_FAIL; 333 return !RIO_FAIL;
334} 334}
335 335
336void rio_copy_to_card(void *to, void *from, int len) 336void rio_copy_to_card(void *from, void __iomem *to, int len)
337{ 337{
338 rio_memcpy_toio(NULL, to, from, len); 338 rio_copy_toio(to, from, len);
339} 339}
340 340
341int rio_minor(struct tty_struct *tty) 341int rio_minor(struct tty_struct *tty)
@@ -573,7 +573,7 @@ static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd
573 func_enter(); 573 func_enter();
574 574
575 /* The "dev" argument isn't used. */ 575 /* The "dev" argument isn't used. */
576 rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN)); 576 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN));
577 577
578 func_exit(); 578 func_exit();
579 return rc; 579 return rc;
@@ -583,6 +583,7 @@ extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command,
583 583
584static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg) 584static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
585{ 585{
586 void __user *argp = (void __user *)arg;
586 int rc; 587 int rc;
587 struct Port *PortP; 588 struct Port *PortP;
588 int ival; 589 int ival;
@@ -594,14 +595,14 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
594 rc = 0; 595 rc = 0;
595 switch (cmd) { 596 switch (cmd) {
596 case TIOCSSOFTCAR: 597 case TIOCSSOFTCAR:
597 if ((rc = get_user(ival, (unsigned int *) arg)) == 0) { 598 if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) {
598 tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0); 599 tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0);
599 } 600 }
600 break; 601 break;
601 case TIOCGSERIAL: 602 case TIOCGSERIAL:
602 rc = -EFAULT; 603 rc = -EFAULT;
603 if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct))) 604 if (access_ok(VERIFY_WRITE, argp, sizeof(struct serial_struct)))
604 rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg); 605 rc = gs_getserial(&PortP->gs, argp);
605 break; 606 break;
606 case TCSBRK: 607 case TCSBRK:
607 if (PortP->State & RIO_DELETED) { 608 if (PortP->State & RIO_DELETED) {
@@ -631,8 +632,8 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
631 break; 632 break;
632 case TIOCSSERIAL: 633 case TIOCSSERIAL:
633 rc = -EFAULT; 634 rc = -EFAULT;
634 if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct))) 635 if (access_ok(VERIFY_READ, argp, sizeof(struct serial_struct)))
635 rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg); 636 rc = gs_setserial(&PortP->gs, argp);
636 break; 637 break;
637 default: 638 default:
638 rc = -ENOIOCTLCMD; 639 rc = -ENOIOCTLCMD;
@@ -919,7 +920,7 @@ static void __exit rio_release_drivers(void)
919static void fix_rio_pci(struct pci_dev *pdev) 920static void fix_rio_pci(struct pci_dev *pdev)
920{ 921{
921 unsigned long hwbase; 922 unsigned long hwbase;
922 unsigned char *rebase; 923 unsigned char __iomem *rebase;
923 unsigned int t; 924 unsigned int t;
924 925
925#define CNTRL_REG_OFFSET 0x50 926#define CNTRL_REG_OFFSET 0x50
@@ -999,7 +1000,7 @@ static int __init rio_init(void)
999 if (((1 << hp->Ivec) & rio_irqmask) == 0) 1000 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1000 hp->Ivec = 0; 1001 hp->Ivec = 0;
1001 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1002 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1002 hp->CardP = (struct DpRam *) hp->Caddr; 1003 hp->CardP = (struct DpRam __iomem *) hp->Caddr;
1003 hp->Type = RIO_PCI; 1004 hp->Type = RIO_PCI;
1004 hp->Copy = rio_copy_to_card; 1005 hp->Copy = rio_copy_to_card;
1005 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1006 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
@@ -1021,7 +1022,7 @@ static int __init rio_init(void)
1021 p->RIONumHosts++; 1022 p->RIONumHosts++;
1022 found++; 1023 found++;
1023 } else { 1024 } else {
1024 iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); 1025 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1025 } 1026 }
1026 } 1027 }
1027 1028
@@ -1047,7 +1048,7 @@ static int __init rio_init(void)
1047 hp->Ivec = 0; 1048 hp->Ivec = 0;
1048 hp->Ivec |= 0x8000; /* Mark as non-sharable */ 1049 hp->Ivec |= 0x8000; /* Mark as non-sharable */
1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1050 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1050 hp->CardP = (struct DpRam *) hp->Caddr; 1051 hp->CardP = (struct DpRam __iomem *) hp->Caddr;
1051 hp->Type = RIO_PCI; 1052 hp->Type = RIO_PCI;
1052 hp->Copy = rio_copy_to_card; 1053 hp->Copy = rio_copy_to_card;
1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1054 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
@@ -1070,7 +1071,7 @@ static int __init rio_init(void)
1070 p->RIONumHosts++; 1071 p->RIONumHosts++;
1071 found++; 1072 found++;
1072 } else { 1073 } else {
1073 iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr)); 1074 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1074 } 1075 }
1075#else 1076#else
1076 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); 1077 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1085,7 +1086,7 @@ static int __init rio_init(void)
1085 /* There was something about the IRQs of these cards. 'Forget what.--REW */ 1086 /* There was something about the IRQs of these cards. 'Forget what.--REW */
1086 hp->Ivec = 0; 1087 hp->Ivec = 0;
1087 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1088 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1088 hp->CardP = (struct DpRam *) hp->Caddr; 1089 hp->CardP = (struct DpRam __iomem *) hp->Caddr;
1089 hp->Type = RIO_AT; 1090 hp->Type = RIO_AT;
1090 hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL 1091 hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
1091 * -- YES! this is now a normal copy. Only the 1092 * -- YES! this is now a normal copy. Only the
@@ -1111,7 +1112,7 @@ static int __init rio_init(void)
1111 } 1112 }
1112 1113
1113 if (!okboard) 1114 if (!okboard)
1114 iounmap((char *) (hp->Caddr)); 1115 iounmap(hp->Caddr);
1115 } 1116 }
1116 } 1117 }
1117 1118
diff --git a/drivers/char/rio/rio_linux.h b/drivers/char/rio/rio_linux.h
index 4ce77fb1fae5..55b9c97e8477 100644
--- a/drivers/char/rio/rio_linux.h
+++ b/drivers/char/rio/rio_linux.h
@@ -131,9 +131,9 @@ struct vpd_prom {
131 131
132 132
133#ifdef CONFIG_RIO_OLDPCI 133#ifdef CONFIG_RIO_OLDPCI
134static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n) 134static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
135{ 135{
136 char *dst = dest; 136 char __iomem *dst = dest;
137 char *src = source; 137 char *src = source;
138 138
139 while (n--) { 139 while (n--) {
@@ -144,11 +144,22 @@ static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n
144 return dest; 144 return dest;
145} 145}
146 146
147static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n)
148{
149 char __iomem *dst = dest;
150 char *src = source;
151
152 while (n--)
153 writeb(*src++, dst++);
147 154
148static inline void *rio_memcpy_fromio(void *dest, void *source, int n) 155 return dest;
156}
157
158
159static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
149{ 160{
150 char *dst = dest; 161 char *dst = dest;
151 char *src = source; 162 char __iomem *src = source;
152 163
153 while (n--) 164 while (n--)
154 *dst++ = readb(src++); 165 *dst++ = readb(src++);
@@ -158,6 +169,7 @@ static inline void *rio_memcpy_fromio(void *dest, void *source, int n)
158 169
159#else 170#else
160#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n) 171#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
172#define rio_copy_toio memcpy_toio
161#define rio_memcpy_fromio memcpy_fromio 173#define rio_memcpy_fromio memcpy_fromio
162#endif 174#endif
163 175
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index 290143addd34..eca2b95343e2 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -71,7 +71,7 @@
71#include "cmdblk.h" 71#include "cmdblk.h"
72#include "route.h" 72#include "route.h"
73 73
74static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP); 74static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP);
75 75
76static const unsigned char RIOAtVec2Ctrl[] = { 76static const unsigned char RIOAtVec2Ctrl[] = {
77 /* 0 */ INTERRUPT_DISABLE, 77 /* 0 */ INTERRUPT_DISABLE,
@@ -204,13 +204,13 @@ void rio_start_card_running(struct Host *HostP)
204int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) 204int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
205{ 205{
206 struct Host *HostP; 206 struct Host *HostP;
207 u8 *Cad; 207 u8 __iomem *Cad;
208 PARM_MAP *ParmMapP; 208 PARM_MAP __iomem *ParmMapP;
209 int RupN; 209 int RupN;
210 int PortN; 210 int PortN;
211 unsigned int host; 211 unsigned int host;
212 u8 *StartP; 212 u8 __iomem *StartP;
213 u8 *DestP; 213 u8 __iomem *DestP;
214 int wait_count; 214 int wait_count;
215 u16 OldParmMap; 215 u16 OldParmMap;
216 u16 offset; /* It is very important that this is a u16 */ 216 u16 offset; /* It is very important that this is a u16 */
@@ -262,7 +262,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
262 ** Ensure that the host really is stopped. 262 ** Ensure that the host really is stopped.
263 ** Disable it's external bus & twang its reset line. 263 ** Disable it's external bus & twang its reset line.
264 */ 264 */
265 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot); 265 RIOHostReset(HostP->Type, HostP->CardP, HostP->Slot);
266 266
267 /* 267 /*
268 ** Copy the data directly from user space to the SRAM. 268 ** Copy the data directly from user space to the SRAM.
@@ -280,7 +280,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
280 func_exit(); 280 func_exit();
281 return -ENOMEM; 281 return -ENOMEM;
282 } 282 }
283 if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) { 283 if (copy_from_user(DownCode, rbp->DataP, rbp->Count)) {
284 kfree(DownCode); 284 kfree(DownCode);
285 p->RIOError.Error = COPYIN_FAILED; 285 p->RIOError.Error = COPYIN_FAILED;
286 func_exit(); 286 func_exit();
@@ -366,7 +366,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
366 ** a short branch to 0x7FF8, where a long branch is coded. 366 ** a short branch to 0x7FF8, where a long branch is coded.
367 */ 367 */
368 368
369 DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ 369 DestP = &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
370 370
371#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ 371#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
372#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ 372#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
@@ -438,7 +438,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
438 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); 438 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
439 HostP->Flags &= ~RUN_STATE; 439 HostP->Flags &= ~RUN_STATE;
440 HostP->Flags |= RC_STUFFED; 440 HostP->Flags |= RC_STUFFED;
441 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 441 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
442 continue; 442 continue;
443 } 443 }
444 444
@@ -453,9 +453,9 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
453 /* 453 /*
454 ** Grab a 32 bit pointer to the parmmap structure 454 ** Grab a 32 bit pointer to the parmmap structure
455 */ 455 */
456 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR)); 456 ParmMapP = (PARM_MAP __iomem *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
457 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); 457 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
458 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR)); 458 ParmMapP = (PARM_MAP __iomem *)(Cad + readw(&HostP->__ParmMapR));
459 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); 459 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
460 460
461 /* 461 /*
@@ -468,7 +468,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
468 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links)); 468 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
469 HostP->Flags &= ~RUN_STATE; 469 HostP->Flags &= ~RUN_STATE;
470 HostP->Flags |= RC_STUFFED; 470 HostP->Flags |= RC_STUFFED;
471 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 471 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
472 continue; 472 continue;
473 } 473 }
474 474
@@ -491,7 +491,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
491 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); 491 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
492 HostP->Flags &= ~RUN_STATE; 492 HostP->Flags &= ~RUN_STATE;
493 HostP->Flags |= RC_STUFFED; 493 HostP->Flags |= RC_STUFFED;
494 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 494 RIOHostReset( HostP->Type, HostP->CardP, HostP->Slot );
495 continue; 495 continue;
496 } 496 }
497 497
@@ -512,10 +512,10 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
512 ** 32 bit pointers for the driver in ioremap space. 512 ** 32 bit pointers for the driver in ioremap space.
513 */ 513 */
514 HostP->ParmMapP = ParmMapP; 514 HostP->ParmMapP = ParmMapP;
515 HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr)); 515 HostP->PhbP = (struct PHB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
516 HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups)); 516 HostP->RupP = (struct RUP __iomem *) RIO_PTR(Cad, readw(&ParmMapP->rups));
517 HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr)); 517 HostP->PhbNumP = (unsigned short __iomem *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
518 HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr)); 518 HostP->LinkStrP = (struct LPB __iomem *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
519 519
520 /* 520 /*
521 ** point the UnixRups at the real Rups 521 ** point the UnixRups at the real Rups
@@ -540,7 +540,7 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
540 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) { 540 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
541 if (p->RIOPortp[PortN]->HostP == HostP) { 541 if (p->RIOPortp[PortN]->HostP == HostP) {
542 struct Port *PortP = p->RIOPortp[PortN]; 542 struct Port *PortP = p->RIOPortp[PortN];
543 struct PHB *PhbP; 543 struct PHB __iomem *PhbP;
544 /* int oldspl; */ 544 /* int oldspl; */
545 545
546 if (!PortP->Mapped) 546 if (!PortP->Mapped)
@@ -551,12 +551,12 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
551 551
552 PortP->PhbP = PhbP; 552 PortP->PhbP = PhbP;
553 553
554 PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add)); 554 PortP->TxAdd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_add));
555 PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start)); 555 PortP->TxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_start));
556 PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end)); 556 PortP->TxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->tx_end));
557 PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove)); 557 PortP->RxRemove = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
558 PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start)); 558 PortP->RxStart = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_start));
559 PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end)); 559 PortP->RxEnd = (u16 __iomem *) RIO_PTR(Cad, readw(&PhbP->rx_end));
560 560
561 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 561 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
562 /* 562 /*
@@ -601,9 +601,9 @@ int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
601 * return 1. If we havent, then return 0. 601 * return 1. If we havent, then return 0.
602 */ 602 */
603 603
604int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP) 604int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem *PacketP)
605{ 605{
606 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 606 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
607 struct PktCmd_M *PktReplyP; 607 struct PktCmd_M *PktReplyP;
608 struct CmdBlk *CmdBlkP; 608 struct CmdBlk *CmdBlkP;
609 unsigned int sequence; 609 unsigned int sequence;
@@ -722,7 +722,7 @@ int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
722 * RtaUniq is the booted RTA. 722 * RtaUniq is the booted RTA.
723 */ 723 */
724 724
725static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP) 725static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd __iomem *PktCmdP)
726{ 726{
727 struct Map *MapP = NULL; 727 struct Map *MapP = NULL;
728 struct Map *MapP2 = NULL; 728 struct Map *MapP2 = NULL;
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index e6d2b14b5e65..4df6ab2206a1 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -180,7 +180,7 @@ int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (stru
180} 180}
181 181
182 182
183int RIOIdentifyRta(struct rio_info *p, void * arg) 183int RIOIdentifyRta(struct rio_info *p, void __user * arg)
184{ 184{
185 unsigned int Host; 185 unsigned int Host;
186 186
@@ -245,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, void * arg)
245} 245}
246 246
247 247
248int RIOKillNeighbour(struct rio_info *p, void * arg) 248int RIOKillNeighbour(struct rio_info *p, void __user * arg)
249{ 249{
250 uint Host; 250 uint Host;
251 uint ID; 251 uint ID;
@@ -370,9 +370,9 @@ int RIOFoadWakeup(struct rio_info *p)
370/* 370/*
371** Incoming command on the COMMAND_RUP to be processed. 371** Incoming command on the COMMAND_RUP to be processed.
372*/ 372*/
373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP) 373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT __iomem *PacketP)
374{ 374{
375 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 375 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *)PacketP->data;
376 struct Port *PortP; 376 struct Port *PortP;
377 struct UnixRup *UnixRupP; 377 struct UnixRup *UnixRupP;
378 unsigned short SysPort; 378 unsigned short SysPort;
@@ -407,12 +407,12 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
407 } else 407 } else
408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); 408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
409 409
410 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", PacketP->dest_unit, PacketP->dest_port); 410 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Destination 0x%x:0x%x\n", readb(&PacketP->dest_unit), readb(&PacketP->dest_port));
411 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", PacketP->src_unit, PacketP->src_port); 411 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Source 0x%x:0x%x\n", readb(&PacketP->src_unit), readb(&PacketP->src_port));
412 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", PacketP->len, PacketP->len); 412 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Length 0x%x (%d)\n", readb(&PacketP->len), readb(&PacketP->len));
413 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control); 413 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", readb(&PacketP->control), readb(&PacketP->control));
414 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum); 414 rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", readw(&PacketP->csum), readw(&PacketP->csum));
415 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command); 415 rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", readb(&PktCmdP->PhbNum), readb(&PktCmdP->Command));
416 return 1; 416 return 1;
417 } 417 }
418 PortP = p->RIOPortp[SysPort]; 418 PortP = p->RIOPortp[SysPort];
@@ -601,7 +601,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
601 /* 601 /*
602 ** Whammy! blat that pack! 602 ** Whammy! blat that pack!
603 */ 603 */
604 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); 604 HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT));
605 605
606 /* 606 /*
607 ** place command packet on the pending position. 607 ** place command packet on the pending position.
@@ -655,7 +655,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
655{ 655{
656 struct CmdBlk *CmdBlkP; 656 struct CmdBlk *CmdBlkP;
657 struct UnixRup *UnixRupP; 657 struct UnixRup *UnixRupP;
658 struct PKT *PacketP; 658 struct PKT __iomem *PacketP;
659 unsigned short Rup; 659 unsigned short Rup;
660 unsigned long flags; 660 unsigned long flags;
661 661
@@ -676,7 +676,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { 676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
677 int FreeMe; 677 int FreeMe;
678 678
679 PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt)); 679 PacketP = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
680 680
681 switch (readb(&PacketP->dest_port)) { 681 switch (readb(&PacketP->dest_port)) {
682 case BOOT_RUP: 682 case BOOT_RUP:
@@ -694,9 +694,9 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
694 */ 694 */
695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
697 if (PacketP->data[5] == MEMDUMP) { 697 if (readb(&PacketP->data[5]) == MEMDUMP) {
698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6])); 698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6])));
699 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); 699 rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32);
700 } 700 }
701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
702 break; 702 break;
@@ -782,7 +782,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
782 /* 782 /*
783 ** Whammy! blat that pack! 783 ** Whammy! blat that pack!
784 */ 784 */
785 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT)); 785 HostP->Copy(&CmdBlkP->Packet, RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->txpkt)), sizeof(struct PKT));
786 786
787 /* 787 /*
788 ** remove the command from the rup command queue... 788 ** remove the command from the rup command queue...
@@ -824,7 +824,7 @@ int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP) 824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
825{ 825{
826 struct Port *PortP = (struct Port *) iPortP; 826 struct Port *PortP = (struct Port *) iPortP;
827 struct PKT *PacketP; 827 struct PKT __iomem *PacketP;
828 unsigned long flags; 828 unsigned long flags;
829 829
830 rio_spin_lock_irqsave(&PortP->portSem, flags); 830 rio_spin_lock_irqsave(&PortP->portSem, flags);
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 75b2557c37ec..052e8120a471 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -80,7 +80,7 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
80static struct LpbReq LpbReq; 80static struct LpbReq LpbReq;
81static struct RupReq RupReq; 81static struct RupReq RupReq;
82static struct PortReq PortReq; 82static struct PortReq PortReq;
83static struct HostReq HostReq; 83static struct HostReq HostReq; /* oh really? global? and no locking? */
84static struct HostDpRam HostDpRam; 84static struct HostDpRam HostDpRam;
85static struct DebugCtrl DebugCtrl; 85static struct DebugCtrl DebugCtrl;
86static struct Map MapEnt; 86static struct Map MapEnt;
@@ -126,12 +126,19 @@ static int
126 126
127#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff)) 127#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
128 128
129int riocontrol(p, dev, cmd, arg, su) 129static int copy_from_io(void __user *to, void __iomem *from, size_t size)
130struct rio_info *p; 130{
131dev_t dev; 131 void *buf = kmalloc(size, GFP_KERNEL);
132int cmd; 132 int res = -ENOMEM;
133caddr_t arg; 133 if (buf) {
134int su; 134 rio_memcpy_fromio(buf, from, size);
135 res = copy_to_user(to, buf, size);
136 kfree(buf);
137 }
138 return res;
139}
140
141int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su)
135{ 142{
136 uint Host; /* leave me unsigned! */ 143 uint Host; /* leave me unsigned! */
137 uint port; /* and me! */ 144 uint port; /* and me! */
@@ -139,9 +146,10 @@ int su;
139 ushort loop; 146 ushort loop;
140 int Entry; 147 int Entry;
141 struct Port *PortP; 148 struct Port *PortP;
142 struct PKT *PacketP; 149 struct PKT __iomem *PacketP;
143 int retval = 0; 150 int retval = 0;
144 unsigned long flags; 151 unsigned long flags;
152 void __user *argp = (void __user *)arg;
145 153
146 func_enter(); 154 func_enter();
147 155
@@ -149,7 +157,7 @@ int su;
149 Host = 0; 157 Host = 0;
150 PortP = NULL; 158 PortP = NULL;
151 159
152 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg); 160 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, argp);
153 161
154 switch (cmd) { 162 switch (cmd) {
155 /* 163 /*
@@ -160,11 +168,11 @@ int su;
160 ** otherwise just the specified host card will be changed. 168 ** otherwise just the specified host card will be changed.
161 */ 169 */
162 case RIO_SET_TIMER: 170 case RIO_SET_TIMER:
163 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg); 171 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", arg);
164 { 172 {
165 int host, value; 173 int host, value;
166 host = ((unsigned long) arg >> 16) & 0x0000FFFF; 174 host = (arg >> 16) & 0x0000FFFF;
167 value = (unsigned long) arg & 0x0000ffff; 175 value = arg & 0x0000ffff;
168 if (host == -1) { 176 if (host == -1) {
169 for (host = 0; host < p->RIONumHosts; host++) { 177 for (host = 0; host < p->RIONumHosts; host++) {
170 if (p->RIOHosts[host].Flags == RC_RUNNING) { 178 if (p->RIOHosts[host].Flags == RC_RUNNING) {
@@ -183,26 +191,26 @@ int su;
183 191
184 case RIO_FOAD_RTA: 192 case RIO_FOAD_RTA:
185 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n"); 193 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
186 return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta); 194 return RIOCommandRta(p, arg, RIOFoadRta);
187 195
188 case RIO_ZOMBIE_RTA: 196 case RIO_ZOMBIE_RTA:
189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n"); 197 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
190 return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta); 198 return RIOCommandRta(p, arg, RIOZombieRta);
191 199
192 case RIO_IDENTIFY_RTA: 200 case RIO_IDENTIFY_RTA:
193 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n"); 201 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
194 return RIOIdentifyRta(p, arg); 202 return RIOIdentifyRta(p, argp);
195 203
196 case RIO_KILL_NEIGHBOUR: 204 case RIO_KILL_NEIGHBOUR:
197 rio_dprintk(RIO_DEBUG_CTRL, "RIO_KILL_NEIGHBOUR\n"); 205 rio_dprintk(RIO_DEBUG_CTRL, "RIO_KILL_NEIGHBOUR\n");
198 return RIOKillNeighbour(p, arg); 206 return RIOKillNeighbour(p, argp);
199 207
200 case SPECIAL_RUP_CMD: 208 case SPECIAL_RUP_CMD:
201 { 209 {
202 struct CmdBlk *CmdBlkP; 210 struct CmdBlk *CmdBlkP;
203 211
204 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n"); 212 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
205 if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) { 213 if (copy_from_user(&SpecialRupCmd, argp, sizeof(SpecialRupCmd))) {
206 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n"); 214 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
207 p->RIOError.Error = COPYIN_FAILED; 215 p->RIOError.Error = COPYIN_FAILED;
208 return -EFAULT; 216 return -EFAULT;
@@ -239,7 +247,7 @@ int su;
239 if ((retval = RIOApel(p)) != 0) 247 if ((retval = RIOApel(p)) != 0)
240 return retval; 248 return retval;
241 249
242 if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { 250 if (copy_to_user(argp, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
243 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n"); 251 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
244 p->RIOError.Error = COPYOUT_FAILED; 252 p->RIOError.Error = COPYOUT_FAILED;
245 return -EFAULT; 253 return -EFAULT;
@@ -284,7 +292,7 @@ int su;
284 p->RIOError.Error = NOT_SUPER_USER; 292 p->RIOError.Error = NOT_SUPER_USER;
285 return -EPERM; 293 return -EPERM;
286 } 294 }
287 if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) { 295 if (copy_from_user(&p->RIOConnectTable[0], argp, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
288 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n"); 296 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
289 p->RIOError.Error = COPYIN_FAILED; 297 p->RIOError.Error = COPYIN_FAILED;
290 return -EFAULT; 298 return -EFAULT;
@@ -330,7 +338,7 @@ int su;
330 p->RIOError.Error = NOT_SUPER_USER; 338 p->RIOError.Error = NOT_SUPER_USER;
331 return -EPERM; 339 return -EPERM;
332 } 340 }
333 if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) { 341 if (copy_to_user(argp, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
334 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n"); 342 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
335 p->RIOError.Error = COPYOUT_FAILED; 343 p->RIOError.Error = COPYOUT_FAILED;
336 return -EFAULT; 344 return -EFAULT;
@@ -349,7 +357,7 @@ int su;
349 p->RIOError.Error = NOT_SUPER_USER; 357 p->RIOError.Error = NOT_SUPER_USER;
350 return -EPERM; 358 return -EPERM;
351 } 359 }
352 if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) { 360 if (copy_from_user(&p->RIOBindTab[0], argp, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
353 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n"); 361 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
354 p->RIOError.Error = COPYIN_FAILED; 362 p->RIOError.Error = COPYIN_FAILED;
355 return -EFAULT; 363 return -EFAULT;
@@ -373,12 +381,12 @@ int su;
373 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) { 381 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
374 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L)) 382 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
375 EmptySlot = Entry; 383 EmptySlot = Entry;
376 else if (p->RIOBindTab[Entry] == (long)arg) { 384 else if (p->RIOBindTab[Entry] == arg) {
377 /* 385 /*
378 ** Already exists - delete 386 ** Already exists - delete
379 */ 387 */
380 p->RIOBindTab[Entry] = 0L; 388 p->RIOBindTab[Entry] = 0L;
381 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg); 389 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", arg);
382 return 0; 390 return 0;
383 } 391 }
384 } 392 }
@@ -386,10 +394,10 @@ int su;
386 ** Dosen't exist - add 394 ** Dosen't exist - add
387 */ 395 */
388 if (EmptySlot != -1) { 396 if (EmptySlot != -1) {
389 p->RIOBindTab[EmptySlot] = (unsigned long)arg; 397 p->RIOBindTab[EmptySlot] = arg;
390 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg); 398 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", arg);
391 } else { 399 } else {
392 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg); 400 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", arg);
393 return -ENOMEM; 401 return -ENOMEM;
394 } 402 }
395 return 0; 403 return 0;
@@ -397,7 +405,7 @@ int su;
397 405
398 case RIO_RESUME: 406 case RIO_RESUME:
399 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n"); 407 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
400 port = (unsigned long) arg; 408 port = arg;
401 if ((port < 0) || (port > 511)) { 409 if ((port < 0) || (port > 511)) {
402 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port); 410 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
403 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 411 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -433,7 +441,7 @@ int su;
433 p->RIOError.Error = NOT_SUPER_USER; 441 p->RIOError.Error = NOT_SUPER_USER;
434 return -EPERM; 442 return -EPERM;
435 } 443 }
436 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { 444 if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) {
437 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 445 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
438 p->RIOError.Error = COPYIN_FAILED; 446 p->RIOError.Error = COPYIN_FAILED;
439 return -EFAULT; 447 return -EFAULT;
@@ -447,7 +455,7 @@ int su;
447 p->RIOError.Error = NOT_SUPER_USER; 455 p->RIOError.Error = NOT_SUPER_USER;
448 return -EPERM; 456 return -EPERM;
449 } 457 }
450 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { 458 if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) {
451 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 459 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
452 p->RIOError.Error = COPYIN_FAILED; 460 p->RIOError.Error = COPYIN_FAILED;
453 return -EFAULT; 461 return -EFAULT;
@@ -461,7 +469,7 @@ int su;
461 p->RIOError.Error = NOT_SUPER_USER; 469 p->RIOError.Error = NOT_SUPER_USER;
462 return -EPERM; 470 return -EPERM;
463 } 471 }
464 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) { 472 if (copy_from_user(&MapEnt, argp, sizeof(MapEnt))) {
465 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n"); 473 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
466 p->RIOError.Error = COPYIN_FAILED; 474 p->RIOError.Error = COPYIN_FAILED;
467 return -EFAULT; 475 return -EFAULT;
@@ -469,14 +477,14 @@ int su;
469 return RIODeleteRta(p, &MapEnt); 477 return RIODeleteRta(p, &MapEnt);
470 478
471 case RIO_QUICK_CHECK: 479 case RIO_QUICK_CHECK:
472 if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) { 480 if (copy_to_user(argp, &p->RIORtaDisCons, sizeof(unsigned int))) {
473 p->RIOError.Error = COPYOUT_FAILED; 481 p->RIOError.Error = COPYOUT_FAILED;
474 return -EFAULT; 482 return -EFAULT;
475 } 483 }
476 return 0; 484 return 0;
477 485
478 case RIO_LAST_ERROR: 486 case RIO_LAST_ERROR:
479 if (copy_to_user(arg, &p->RIOError, sizeof(struct Error))) 487 if (copy_to_user(argp, &p->RIOError, sizeof(struct Error)))
480 return -EFAULT; 488 return -EFAULT;
481 return 0; 489 return 0;
482 490
@@ -485,7 +493,7 @@ int su;
485 return -EINVAL; 493 return -EINVAL;
486 494
487 case RIO_GET_MODTYPE: 495 case RIO_GET_MODTYPE:
488 if (copy_from_user(&port, arg, sizeof(unsigned int))) { 496 if (copy_from_user(&port, argp, sizeof(unsigned int))) {
489 p->RIOError.Error = COPYIN_FAILED; 497 p->RIOError.Error = COPYIN_FAILED;
490 return -EFAULT; 498 return -EFAULT;
491 } 499 }
@@ -505,7 +513,7 @@ int su;
505 ** Return module type of port 513 ** Return module type of port
506 */ 514 */
507 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes; 515 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
508 if (copy_to_user(arg, &port, sizeof(unsigned int))) { 516 if (copy_to_user(argp, &port, sizeof(unsigned int))) {
509 p->RIOError.Error = COPYOUT_FAILED; 517 p->RIOError.Error = COPYOUT_FAILED;
510 return -EFAULT; 518 return -EFAULT;
511 } 519 }
@@ -521,7 +529,7 @@ int su;
521 529
522 case RIO_SETUP_PORTS: 530 case RIO_SETUP_PORTS:
523 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n"); 531 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
524 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) { 532 if (copy_from_user(&PortSetup, argp, sizeof(PortSetup))) {
525 p->RIOError.Error = COPYIN_FAILED; 533 p->RIOError.Error = COPYIN_FAILED;
526 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT"); 534 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
527 return -EFAULT; 535 return -EFAULT;
@@ -551,7 +559,7 @@ int su;
551 559
552 case RIO_GET_PORT_SETUP: 560 case RIO_GET_PORT_SETUP:
553 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n"); 561 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
554 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) { 562 if (copy_from_user(&PortSetup, argp, sizeof(PortSetup))) {
555 p->RIOError.Error = COPYIN_FAILED; 563 p->RIOError.Error = COPYIN_FAILED;
556 return -EFAULT; 564 return -EFAULT;
557 } 565 }
@@ -572,7 +580,7 @@ int su;
572 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; 580 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
573 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; 581 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
574 582
575 if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) { 583 if (copy_to_user(argp, &PortSetup, sizeof(PortSetup))) {
576 p->RIOError.Error = COPYOUT_FAILED; 584 p->RIOError.Error = COPYOUT_FAILED;
577 return -EFAULT; 585 return -EFAULT;
578 } 586 }
@@ -580,7 +588,7 @@ int su;
580 588
581 case RIO_GET_PORT_PARAMS: 589 case RIO_GET_PORT_PARAMS:
582 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n"); 590 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
583 if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) { 591 if (copy_from_user(&PortParams, argp, sizeof(struct PortParams))) {
584 p->RIOError.Error = COPYIN_FAILED; 592 p->RIOError.Error = COPYIN_FAILED;
585 return -EFAULT; 593 return -EFAULT;
586 } 594 }
@@ -593,7 +601,7 @@ int su;
593 PortParams.State = PortP->State; 601 PortParams.State = PortP->State;
594 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port); 602 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
595 603
596 if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) { 604 if (copy_to_user(argp, &PortParams, sizeof(struct PortParams))) {
597 p->RIOError.Error = COPYOUT_FAILED; 605 p->RIOError.Error = COPYOUT_FAILED;
598 return -EFAULT; 606 return -EFAULT;
599 } 607 }
@@ -601,7 +609,7 @@ int su;
601 609
602 case RIO_GET_PORT_TTY: 610 case RIO_GET_PORT_TTY:
603 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n"); 611 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
604 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) { 612 if (copy_from_user(&PortTty, argp, sizeof(struct PortTty))) {
605 p->RIOError.Error = COPYIN_FAILED; 613 p->RIOError.Error = COPYIN_FAILED;
606 return -EFAULT; 614 return -EFAULT;
607 } 615 }
@@ -612,14 +620,14 @@ int su;
612 620
613 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port); 621 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
614 PortP = (p->RIOPortp[PortTty.port]); 622 PortP = (p->RIOPortp[PortTty.port]);
615 if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) { 623 if (copy_to_user(argp, &PortTty, sizeof(struct PortTty))) {
616 p->RIOError.Error = COPYOUT_FAILED; 624 p->RIOError.Error = COPYOUT_FAILED;
617 return -EFAULT; 625 return -EFAULT;
618 } 626 }
619 return retval; 627 return retval;
620 628
621 case RIO_SET_PORT_TTY: 629 case RIO_SET_PORT_TTY:
622 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) { 630 if (copy_from_user(&PortTty, argp, sizeof(struct PortTty))) {
623 p->RIOError.Error = COPYIN_FAILED; 631 p->RIOError.Error = COPYIN_FAILED;
624 return -EFAULT; 632 return -EFAULT;
625 } 633 }
@@ -634,7 +642,7 @@ int su;
634 642
635 case RIO_SET_PORT_PARAMS: 643 case RIO_SET_PORT_PARAMS:
636 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n"); 644 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
637 if (copy_from_user(&PortParams, arg, sizeof(PortParams))) { 645 if (copy_from_user(&PortParams, argp, sizeof(PortParams))) {
638 p->RIOError.Error = COPYIN_FAILED; 646 p->RIOError.Error = COPYIN_FAILED;
639 return -EFAULT; 647 return -EFAULT;
640 } 648 }
@@ -650,7 +658,7 @@ int su;
650 658
651 case RIO_GET_PORT_STATS: 659 case RIO_GET_PORT_STATS:
652 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n"); 660 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
653 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) { 661 if (copy_from_user(&portStats, argp, sizeof(struct portStats))) {
654 p->RIOError.Error = COPYIN_FAILED; 662 p->RIOError.Error = COPYIN_FAILED;
655 return -EFAULT; 663 return -EFAULT;
656 } 664 }
@@ -665,14 +673,14 @@ int su;
665 portStats.opens = PortP->opens; 673 portStats.opens = PortP->opens;
666 portStats.closes = PortP->closes; 674 portStats.closes = PortP->closes;
667 portStats.ioctls = PortP->ioctls; 675 portStats.ioctls = PortP->ioctls;
668 if (copy_to_user(arg, &portStats, sizeof(struct portStats))) { 676 if (copy_to_user(argp, &portStats, sizeof(struct portStats))) {
669 p->RIOError.Error = COPYOUT_FAILED; 677 p->RIOError.Error = COPYOUT_FAILED;
670 return -EFAULT; 678 return -EFAULT;
671 } 679 }
672 return retval; 680 return retval;
673 681
674 case RIO_RESET_PORT_STATS: 682 case RIO_RESET_PORT_STATS:
675 port = (unsigned long) arg; 683 port = arg;
676 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n"); 684 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
677 if (port >= RIO_PORTS) { 685 if (port >= RIO_PORTS) {
678 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 686 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -690,7 +698,7 @@ int su;
690 698
691 case RIO_GATHER_PORT_STATS: 699 case RIO_GATHER_PORT_STATS:
692 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n"); 700 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
693 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) { 701 if (copy_from_user(&portStats, argp, sizeof(struct portStats))) {
694 p->RIOError.Error = COPYIN_FAILED; 702 p->RIOError.Error = COPYIN_FAILED;
695 return -EFAULT; 703 return -EFAULT;
696 } 704 }
@@ -706,7 +714,7 @@ int su;
706 714
707 case RIO_READ_CONFIG: 715 case RIO_READ_CONFIG:
708 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); 716 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
709 if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) { 717 if (copy_to_user(argp, &p->RIOConf, sizeof(struct Conf))) {
710 p->RIOError.Error = COPYOUT_FAILED; 718 p->RIOError.Error = COPYOUT_FAILED;
711 return -EFAULT; 719 return -EFAULT;
712 } 720 }
@@ -718,7 +726,7 @@ int su;
718 p->RIOError.Error = NOT_SUPER_USER; 726 p->RIOError.Error = NOT_SUPER_USER;
719 return -EPERM; 727 return -EPERM;
720 } 728 }
721 if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) { 729 if (copy_from_user(&p->RIOConf, argp, sizeof(struct Conf))) {
722 p->RIOError.Error = COPYIN_FAILED; 730 p->RIOError.Error = COPYIN_FAILED;
723 return -EFAULT; 731 return -EFAULT;
724 } 732 }
@@ -746,7 +754,7 @@ int su;
746 case RIO_SETDEBUG: 754 case RIO_SETDEBUG:
747 case RIO_GETDEBUG: 755 case RIO_GETDEBUG:
748 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); 756 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
749 if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) { 757 if (copy_from_user(&DebugCtrl, argp, sizeof(DebugCtrl))) {
750 p->RIOError.Error = COPYIN_FAILED; 758 p->RIOError.Error = COPYIN_FAILED;
751 return -EFAULT; 759 return -EFAULT;
752 } 760 }
@@ -763,7 +771,7 @@ int su;
763 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait); 771 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
764 DebugCtrl.Debug = p->rio_debug; 772 DebugCtrl.Debug = p->rio_debug;
765 DebugCtrl.Wait = p->RIODebugWait; 773 DebugCtrl.Wait = p->RIODebugWait;
766 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) { 774 if (copy_to_user(argp, &DebugCtrl, sizeof(DebugCtrl))) {
767 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); 775 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
768 p->RIOError.Error = COPYOUT_FAILED; 776 p->RIOError.Error = COPYOUT_FAILED;
769 return -EFAULT; 777 return -EFAULT;
@@ -785,7 +793,7 @@ int su;
785 } else { 793 } else {
786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); 794 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
787 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; 795 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
788 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) { 796 if (copy_to_user(argp, &DebugCtrl, sizeof(DebugCtrl))) {
789 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); 797 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
790 p->RIOError.Error = COPYOUT_FAILED; 798 p->RIOError.Error = COPYOUT_FAILED;
791 return -EFAULT; 799 return -EFAULT;
@@ -800,7 +808,7 @@ int su;
800 ** textual null terminated string. 808 ** textual null terminated string.
801 */ 809 */
802 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n"); 810 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
803 if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) { 811 if (copy_to_user(argp, RIOVersid(), sizeof(struct rioVersion))) {
804 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); 812 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
805 p->RIOError.Error = COPYOUT_FAILED; 813 p->RIOError.Error = COPYOUT_FAILED;
806 return -EFAULT; 814 return -EFAULT;
@@ -813,7 +821,7 @@ int su;
813 ** at init time. 821 ** at init time.
814 */ 822 */
815 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); 823 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
816 if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) { 824 if (copy_to_user(argp, &p->RIONumHosts, sizeof(p->RIONumHosts))) {
817 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); 825 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
818 p->RIOError.Error = COPYOUT_FAILED; 826 p->RIOError.Error = COPYOUT_FAILED;
819 return -EFAULT; 827 return -EFAULT;
@@ -824,7 +832,7 @@ int su;
824 /* 832 /*
825 ** Kill host. This may not be in the final version... 833 ** Kill host. This may not be in the final version...
826 */ 834 */
827 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg); 835 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", arg);
828 if (!su) { 836 if (!su) {
829 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); 837 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
830 p->RIOError.Error = NOT_SUPER_USER; 838 p->RIOError.Error = NOT_SUPER_USER;
@@ -858,7 +866,7 @@ int su;
858 p->RIOError.Error = NOT_SUPER_USER; 866 p->RIOError.Error = NOT_SUPER_USER;
859 return -EPERM; 867 return -EPERM;
860 } 868 }
861 if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) { 869 if (copy_from_user(&DownLoad, argp, sizeof(DownLoad))) {
862 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); 870 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
863 p->RIOError.Error = COPYIN_FAILED; 871 p->RIOError.Error = COPYIN_FAILED;
864 return -EFAULT; 872 return -EFAULT;
@@ -888,7 +896,7 @@ int su;
888 { 896 {
889 unsigned int host; 897 unsigned int host;
890 898
891 if (copy_from_user(&host, arg, sizeof(host))) { 899 if (copy_from_user(&host, argp, sizeof(host))) {
892 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 900 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
893 p->RIOError.Error = COPYIN_FAILED; 901 p->RIOError.Error = COPYIN_FAILED;
894 return -EFAULT; 902 return -EFAULT;
@@ -897,7 +905,7 @@ int su;
897 ** Fetch the parmmap 905 ** Fetch the parmmap
898 */ 906 */
899 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); 907 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
900 if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) { 908 if (copy_from_io(argp, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) {
901 p->RIOError.Error = COPYOUT_FAILED; 909 p->RIOError.Error = COPYOUT_FAILED;
902 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); 910 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
903 return -EFAULT; 911 return -EFAULT;
@@ -907,7 +915,7 @@ int su;
907 915
908 case RIO_HOST_REQ: 916 case RIO_HOST_REQ:
909 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); 917 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
910 if (copy_from_user(&HostReq, arg, sizeof(HostReq))) { 918 if (copy_from_user(&HostReq, argp, sizeof(HostReq))) {
911 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 919 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
912 p->RIOError.Error = COPYIN_FAILED; 920 p->RIOError.Error = COPYIN_FAILED;
913 return -EFAULT; 921 return -EFAULT;
@@ -928,7 +936,7 @@ int su;
928 936
929 case RIO_HOST_DPRAM: 937 case RIO_HOST_DPRAM:
930 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n"); 938 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
931 if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) { 939 if (copy_from_user(&HostDpRam, argp, sizeof(HostDpRam))) {
932 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); 940 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
933 p->RIOError.Error = COPYIN_FAILED; 941 p->RIOError.Error = COPYIN_FAILED;
934 return -EFAULT; 942 return -EFAULT;
@@ -945,13 +953,13 @@ int su;
945 /* It's hardware like this that really gets on my tits. */ 953 /* It's hardware like this that really gets on my tits. */
946 static unsigned char copy[sizeof(struct DpRam)]; 954 static unsigned char copy[sizeof(struct DpRam)];
947 for (off = 0; off < sizeof(struct DpRam); off++) 955 for (off = 0; off < sizeof(struct DpRam); off++)
948 copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]); 956 copy[off] = readb(p->RIOHosts[HostDpRam.HostNum].Caddr + off);
949 if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) { 957 if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) {
950 p->RIOError.Error = COPYOUT_FAILED; 958 p->RIOError.Error = COPYOUT_FAILED;
951 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 959 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
952 return -EFAULT; 960 return -EFAULT;
953 } 961 }
954 } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) { 962 } else if (copy_from_io(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) {
955 p->RIOError.Error = COPYOUT_FAILED; 963 p->RIOError.Error = COPYOUT_FAILED;
956 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 964 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
957 return -EFAULT; 965 return -EFAULT;
@@ -960,13 +968,13 @@ int su;
960 968
961 case RIO_SET_BUSY: 969 case RIO_SET_BUSY:
962 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); 970 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
963 if ((unsigned long) arg > 511) { 971 if (arg > 511) {
964 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg); 972 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", arg);
965 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 973 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
966 return -EINVAL; 974 return -EINVAL;
967 } 975 }
968 rio_spin_lock_irqsave(&PortP->portSem, flags); 976 rio_spin_lock_irqsave(&PortP->portSem, flags);
969 p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY; 977 p->RIOPortp[arg]->State |= RIO_BUSY;
970 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 978 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
971 return retval; 979 return retval;
972 980
@@ -976,7 +984,7 @@ int su;
976 ** (probably for debug reasons) 984 ** (probably for debug reasons)
977 */ 985 */
978 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); 986 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
979 if (copy_from_user(&PortReq, arg, sizeof(PortReq))) { 987 if (copy_from_user(&PortReq, argp, sizeof(PortReq))) {
980 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); 988 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
981 p->RIOError.Error = COPYIN_FAILED; 989 p->RIOError.Error = COPYIN_FAILED;
982 return -EFAULT; 990 return -EFAULT;
@@ -1001,7 +1009,7 @@ int su;
1001 ** (probably for debug reasons) 1009 ** (probably for debug reasons)
1002 */ 1010 */
1003 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); 1011 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
1004 if (copy_from_user(&RupReq, arg, sizeof(RupReq))) { 1012 if (copy_from_user(&RupReq, argp, sizeof(RupReq))) {
1005 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); 1013 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
1006 p->RIOError.Error = COPYIN_FAILED; 1014 p->RIOError.Error = COPYIN_FAILED;
1007 return -EFAULT; 1015 return -EFAULT;
@@ -1025,7 +1033,7 @@ int su;
1025 } 1033 }
1026 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); 1034 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
1027 1035
1028 if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) { 1036 if (copy_from_io(RupReq.RupP, HostP->UnixRups[RupReq.RupNum].RupP, sizeof(struct RUP))) {
1029 p->RIOError.Error = COPYOUT_FAILED; 1037 p->RIOError.Error = COPYOUT_FAILED;
1030 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); 1038 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
1031 return -EFAULT; 1039 return -EFAULT;
@@ -1038,7 +1046,7 @@ int su;
1038 ** (probably for debug reasons) 1046 ** (probably for debug reasons)
1039 */ 1047 */
1040 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); 1048 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
1041 if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) { 1049 if (copy_from_user(&LpbReq, argp, sizeof(LpbReq))) {
1042 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); 1050 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
1043 p->RIOError.Error = COPYIN_FAILED; 1051 p->RIOError.Error = COPYIN_FAILED;
1044 return -EFAULT; 1052 return -EFAULT;
@@ -1062,7 +1070,7 @@ int su;
1062 } 1070 }
1063 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host); 1071 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
1064 1072
1065 if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) { 1073 if (copy_from_io(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) {
1066 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n"); 1074 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
1067 p->RIOError.Error = COPYOUT_FAILED; 1075 p->RIOError.Error = COPYOUT_FAILED;
1068 return -EFAULT; 1076 return -EFAULT;
@@ -1136,7 +1144,7 @@ int su;
1136 case RIO_MAP_B110_TO_110: 1144 case RIO_MAP_B110_TO_110:
1137 case RIO_MAP_B110_TO_115200: 1145 case RIO_MAP_B110_TO_115200:
1138 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n"); 1146 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
1139 port = (unsigned long) arg; 1147 port = arg;
1140 if (port < 0 || port > 511) { 1148 if (port < 0 || port > 511) {
1141 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port); 1149 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
1142 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 1150 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -1166,7 +1174,7 @@ int su;
1166 1174
1167 case RIO_SEND_PACKET: 1175 case RIO_SEND_PACKET:
1168 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n"); 1176 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
1169 if (copy_from_user(&SendPack, arg, sizeof(SendPack))) { 1177 if (copy_from_user(&SendPack, argp, sizeof(SendPack))) {
1170 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n"); 1178 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
1171 p->RIOError.Error = COPYIN_FAILED; 1179 p->RIOError.Error = COPYIN_FAILED;
1172 return -EFAULT; 1180 return -EFAULT;
@@ -1210,7 +1218,7 @@ int su;
1210 return su ? 0 : -EPERM; 1218 return su ? 0 : -EPERM;
1211 1219
1212 case RIO_WHAT_MESG: 1220 case RIO_WHAT_MESG:
1213 if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) { 1221 if (copy_to_user(argp, &p->RIONoMessage, sizeof(p->RIONoMessage))) {
1214 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n"); 1222 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
1215 p->RIOError.Error = COPYOUT_FAILED; 1223 p->RIOError.Error = COPYOUT_FAILED;
1216 return -EFAULT; 1224 return -EFAULT;
@@ -1218,7 +1226,7 @@ int su;
1218 return 0; 1226 return 0;
1219 1227
1220 case RIO_MEM_DUMP: 1228 case RIO_MEM_DUMP:
1221 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) { 1229 if (copy_from_user(&SubCmd, argp, sizeof(struct SubCmdStruct))) {
1222 p->RIOError.Error = COPYIN_FAILED; 1230 p->RIOError.Error = COPYIN_FAILED;
1223 return -EFAULT; 1231 return -EFAULT;
1224 } 1232 }
@@ -1248,7 +1256,7 @@ int su;
1248 PortP->State |= RIO_BUSY; 1256 PortP->State |= RIO_BUSY;
1249 1257
1250 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1258 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1251 if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) { 1259 if (copy_to_user(argp, p->RIOMemDump, MEMDUMP_SIZE)) {
1252 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n"); 1260 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
1253 p->RIOError.Error = COPYOUT_FAILED; 1261 p->RIOError.Error = COPYOUT_FAILED;
1254 return -EFAULT; 1262 return -EFAULT;
@@ -1256,30 +1264,30 @@ int su;
1256 return 0; 1264 return 0;
1257 1265
1258 case RIO_TICK: 1266 case RIO_TICK:
1259 if ((unsigned long) arg >= p->RIONumHosts) 1267 if (arg >= p->RIONumHosts)
1260 return -EINVAL; 1268 return -EINVAL;
1261 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg); 1269 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", arg);
1262 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt); 1270 writeb(0xFF, &p->RIOHosts[arg].SetInt);
1263 return 0; 1271 return 0;
1264 1272
1265 case RIO_TOCK: 1273 case RIO_TOCK:
1266 if ((unsigned long) arg >= p->RIONumHosts) 1274 if (arg >= p->RIONumHosts)
1267 return -EINVAL; 1275 return -EINVAL;
1268 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg); 1276 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", arg);
1269 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt); 1277 writeb(0xFF, &p->RIOHosts[arg].ResetInt);
1270 return 0; 1278 return 0;
1271 1279
1272 case RIO_READ_CHECK: 1280 case RIO_READ_CHECK:
1273 /* Check reads for pkts with data[0] the same */ 1281 /* Check reads for pkts with data[0] the same */
1274 p->RIOReadCheck = !p->RIOReadCheck; 1282 p->RIOReadCheck = !p->RIOReadCheck;
1275 if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) { 1283 if (copy_to_user(argp, &p->RIOReadCheck, sizeof(unsigned int))) {
1276 p->RIOError.Error = COPYOUT_FAILED; 1284 p->RIOError.Error = COPYOUT_FAILED;
1277 return -EFAULT; 1285 return -EFAULT;
1278 } 1286 }
1279 return 0; 1287 return 0;
1280 1288
1281 case RIO_READ_REGISTER: 1289 case RIO_READ_REGISTER:
1282 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) { 1290 if (copy_from_user(&SubCmd, argp, sizeof(struct SubCmdStruct))) {
1283 p->RIOError.Error = COPYIN_FAILED; 1291 p->RIOError.Error = COPYIN_FAILED;
1284 return -EFAULT; 1292 return -EFAULT;
1285 } 1293 }
@@ -1314,7 +1322,7 @@ int su;
1314 PortP->State |= RIO_BUSY; 1322 PortP->State |= RIO_BUSY;
1315 1323
1316 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1324 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1317 if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) { 1325 if (copy_to_user(argp, &p->CdRegister, sizeof(unsigned int))) {
1318 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n"); 1326 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
1319 p->RIOError.Error = COPYOUT_FAILED; 1327 p->RIOError.Error = COPYOUT_FAILED;
1320 return -EFAULT; 1328 return -EFAULT;
@@ -1327,10 +1335,10 @@ int su;
1327 */ 1335 */
1328 case RIO_MAKE_DEV: 1336 case RIO_MAKE_DEV:
1329 { 1337 {
1330 unsigned int port = (unsigned long) arg & RIO_MODEM_MASK; 1338 unsigned int port = arg & RIO_MODEM_MASK;
1331 unsigned int ret; 1339 unsigned int ret;
1332 1340
1333 switch ((unsigned long) arg & RIO_DEV_MASK) { 1341 switch (arg & RIO_DEV_MASK) {
1334 case RIO_DEV_DIRECT: 1342 case RIO_DEV_DIRECT:
1335 ret = drv_makedev(MAJOR(dev), port); 1343 ret = drv_makedev(MAJOR(dev), port);
1336 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret); 1344 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret);
@@ -1358,7 +1366,7 @@ int su;
1358 int mino; 1366 int mino;
1359 unsigned long ret; 1367 unsigned long ret;
1360 1368
1361 dv = (dev_t) ((unsigned long) arg); 1369 dv = (dev_t) (arg);
1362 mino = RIO_UNMODEM(dv); 1370 mino = RIO_UNMODEM(dv);
1363 1371
1364 if (RIO_ISMODEM(dv)) { 1372 if (RIO_ISMODEM(dv)) {
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 24d2992154cc..12e34bc3f7ce 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -79,7 +79,7 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
79 79
80int RIOPCIinit(struct rio_info *p, int Mode); 80int RIOPCIinit(struct rio_info *p, int Mode);
81 81
82static int RIOScrub(int, u8 *, int); 82static int RIOScrub(int, u8 __iomem *, int);
83 83
84 84
85/** 85/**
@@ -92,10 +92,10 @@ static int RIOScrub(int, u8 *, int);
92** bits > 0 indicates 16 bit operation. 92** bits > 0 indicates 16 bit operation.
93*/ 93*/
94 94
95int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode) 95int RIOAssignAT(struct rio_info *p, int Base, void __iomem *virtAddr, int mode)
96{ 96{
97 int bits; 97 int bits;
98 struct DpRam *cardp = (struct DpRam *)virtAddr; 98 struct DpRam __iomem *cardp = (struct DpRam __iomem *)virtAddr;
99 99
100 if ((Base < ONE_MEG) || (mode & BYTE_ACCESS_MODE)) 100 if ((Base < ONE_MEG) || (mode & BYTE_ACCESS_MODE))
101 bits = BYTE_OPERATION; 101 bits = BYTE_OPERATION;
@@ -107,7 +107,7 @@ int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode)
107 ** transient stuff. 107 ** transient stuff.
108 */ 108 */
109 p->RIOHosts[p->RIONumHosts].Caddr = virtAddr; 109 p->RIOHosts[p->RIONumHosts].Caddr = virtAddr;
110 p->RIOHosts[p->RIONumHosts].CardP = (struct DpRam *)virtAddr; 110 p->RIOHosts[p->RIONumHosts].CardP = virtAddr;
111 111
112 /* 112 /*
113 ** Revision 01 AT host cards don't support WORD operations, 113 ** Revision 01 AT host cards don't support WORD operations,
@@ -151,10 +151,10 @@ static u8 val[] = {
151** RAM test a board. 151** RAM test a board.
152** Nothing too complicated, just enough to check it out. 152** Nothing too complicated, just enough to check it out.
153*/ 153*/
154int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot) 154int RIOBoardTest(unsigned long paddr, void __iomem *caddr, unsigned char type, int slot)
155{ 155{
156 struct DpRam *DpRam = (struct DpRam *)caddr; 156 struct DpRam __iomem *DpRam = caddr;
157 char *ram[4]; 157 void __iomem *ram[4];
158 int size[4]; 158 int size[4];
159 int op, bank; 159 int op, bank;
160 int nbanks; 160 int nbanks;
@@ -179,12 +179,12 @@ int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slo
179 size[2] = DP_SRAM3_SIZE; 179 size[2] = DP_SRAM3_SIZE;
180 size[3] = DP_SCRATCH_SIZE; 180 size[3] = DP_SCRATCH_SIZE;
181 181
182 ram[0] = (char *)&DpRam->DpSram1[0]; 182 ram[0] = DpRam->DpSram1;
183 ram[1] = (char *)&DpRam->DpSram2[0]; 183 ram[1] = DpRam->DpSram2;
184 ram[2] = (char *)&DpRam->DpSram3[0]; 184 ram[2] = DpRam->DpSram3;
185 nbanks = (type == RIO_PCI) ? 3 : 4; 185 nbanks = (type == RIO_PCI) ? 3 : 4;
186 if (nbanks == 4) 186 if (nbanks == 4)
187 ram[3] = (char *)&DpRam->DpScratch[0]; 187 ram[3] = DpRam->DpScratch;
188 188
189 189
190 if (nbanks == 3) { 190 if (nbanks == 3) {
@@ -202,7 +202,7 @@ int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slo
202 */ 202 */
203 for (op=0; op<TEST_END; op++) { 203 for (op=0; op<TEST_END; op++) {
204 for (bank=0; bank<nbanks; bank++) { 204 for (bank=0; bank<nbanks; bank++) {
205 if (RIOScrub(op, (u8 *)ram[bank], size[bank]) == RIO_FAIL) { 205 if (RIOScrub(op, ram[bank], size[bank]) == RIO_FAIL) {
206 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n", 206 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n",
207 bank, op); 207 bank, op);
208 return RIO_FAIL; 208 return RIO_FAIL;
@@ -227,7 +227,7 @@ int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slo
227** to check that the data from the previous phase was retained. 227** to check that the data from the previous phase was retained.
228*/ 228*/
229 229
230static int RIOScrub(int op, u8 *ram, int size) 230static int RIOScrub(int op, u8 __iomem *ram, int size)
231{ 231{
232 int off; 232 int off;
233 unsigned char oldbyte; 233 unsigned char oldbyte;
@@ -393,7 +393,7 @@ struct rioVersion *RIOVersid(void)
393 return &stVersion; 393 return &stVersion;
394} 394}
395 395
396void RIOHostReset(unsigned int Type, struct DpRam *DpRamP, unsigned int Slot) 396void RIOHostReset(unsigned int Type, struct DpRam __iomem *DpRamP, unsigned int Slot)
397{ 397{
398 /* 398 /*
399 ** Reset the Tpu 399 ** Reset the Tpu
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 97f0fa550652..0bd09040a5c0 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -102,7 +102,7 @@ void RIOTxEnable(char *en)
102 struct rio_info *p; 102 struct rio_info *p;
103 struct tty_struct *tty; 103 struct tty_struct *tty;
104 int c; 104 int c;
105 struct PKT *PacketP; 105 struct PKT __iomem *PacketP;
106 unsigned long flags; 106 unsigned long flags;
107 107
108 PortP = (struct Port *) en; 108 PortP = (struct Port *) en;
@@ -144,7 +144,7 @@ void RIOTxEnable(char *en)
144 if (c == 0) 144 if (c == 0)
145 break; 145 break;
146 146
147 rio_memcpy_toio(PortP->HostP->Caddr, (caddr_t) PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c); 147 rio_memcpy_toio(PortP->HostP->Caddr, PacketP->data, PortP->gs.xmit_buf + PortP->gs.xmit_tail, c);
148 /* udelay (1); */ 148 /* udelay (1); */
149 149
150 writeb(c, &(PacketP->len)); 150 writeb(c, &(PacketP->len));
@@ -219,7 +219,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
219 for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { 219 for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) {
220 struct Port *PortP = p->RIOPortp[port]; 220 struct Port *PortP = p->RIOPortp[port];
221 struct tty_struct *ttyP; 221 struct tty_struct *ttyP;
222 struct PKT *PacketP; 222 struct PKT __iomem *PacketP;
223 223
224 /* 224 /*
225 ** not mapped in - most of the RIOPortp[] information 225 ** not mapped in - most of the RIOPortp[] information
@@ -298,7 +298,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
298 for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) { 298 for (port = p->RIOFirstPortsBooted; port < p->RIOLastPortsBooted + PORTS_PER_RTA; port++) {
299 struct Port *PortP = p->RIOPortp[port]; 299 struct Port *PortP = p->RIOPortp[port];
300 struct tty_struct *ttyP; 300 struct tty_struct *ttyP;
301 struct PKT *PacketP; 301 struct PKT __iomem *PacketP;
302 302
303 /* 303 /*
304 ** not mapped in - most of the RIOPortp[] information 304 ** not mapped in - most of the RIOPortp[] information
@@ -427,13 +427,13 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
427 427
428 while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) { 428 while (PortP->WflushFlag && can_add_transmit(&PacketP, PortP) && (PortP->InUse == NOT_INUSE)) {
429 int p; 429 int p;
430 struct PktCmd *PktCmdP; 430 struct PktCmd __iomem *PktCmdP;
431 431
432 rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n"); 432 rio_dprintk(RIO_DEBUG_INTR, "Add WFLUSH marker to data queue\n");
433 /* 433 /*
434 ** make it look just like a WFLUSH command 434 ** make it look just like a WFLUSH command
435 */ 435 */
436 PktCmdP = (struct PktCmd *) &PacketP->data[0]; 436 PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0];
437 437
438 writeb(WFLUSH, &PktCmdP->Command); 438 writeb(WFLUSH, &PktCmdP->Command);
439 439
@@ -525,9 +525,9 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)
525{ 525{
526 struct tty_struct *TtyP; 526 struct tty_struct *TtyP;
527 unsigned short transCount; 527 unsigned short transCount;
528 struct PKT *PacketP; 528 struct PKT __iomem *PacketP;
529 register unsigned int DataCnt; 529 register unsigned int DataCnt;
530 unsigned char *ptr; 530 unsigned char __iomem *ptr;
531 unsigned char *buf; 531 unsigned char *buf;
532 int copied = 0; 532 int copied = 0;
533 533
@@ -546,7 +546,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)
546 ** run out of space it will be set to the offset of the 546 ** run out of space it will be set to the offset of the
547 ** next byte to copy from the packet data area. The packet 547 ** next byte to copy from the packet data area. The packet
548 ** length field is decremented by the number of bytes that 548 ** length field is decremented by the number of bytes that
549 ** we succesfully removed from the packet. When this reaches 549 ** we successfully removed from the packet. When this reaches
550 ** zero, we reset the offset pointer to be zero, and free 550 ** zero, we reset the offset pointer to be zero, and free
551 ** the packet from the front of the queue. 551 ** the packet from the front of the queue.
552 */ 552 */
@@ -585,19 +585,19 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)
585 /* 585 /*
586 ** check that it is not a command! 586 ** check that it is not a command!
587 */ 587 */
588 if (PacketP->len & PKT_CMD_BIT) { 588 if (readb(&PacketP->len) & PKT_CMD_BIT) {
589 rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n"); 589 rio_dprintk(RIO_DEBUG_INTR, "RIO: unexpected command packet received on PHB\n");
590 /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */ 590 /* rio_dprint(RIO_DEBUG_INTR, (" sysport = %d\n", p->RIOPortp->PortNum)); */
591 rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", PacketP->dest_unit); 591 rio_dprintk(RIO_DEBUG_INTR, " dest_unit = %d\n", readb(&PacketP->dest_unit));
592 rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", PacketP->dest_port); 592 rio_dprintk(RIO_DEBUG_INTR, " dest_port = %d\n", readb(&PacketP->dest_port));
593 rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", PacketP->src_unit); 593 rio_dprintk(RIO_DEBUG_INTR, " src_unit = %d\n", readb(&PacketP->src_unit));
594 rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", PacketP->src_port); 594 rio_dprintk(RIO_DEBUG_INTR, " src_port = %d\n", readb(&PacketP->src_port));
595 rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", PacketP->len); 595 rio_dprintk(RIO_DEBUG_INTR, " len = %d\n", readb(&PacketP->len));
596 rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", PacketP->control); 596 rio_dprintk(RIO_DEBUG_INTR, " control = %d\n", readb(&PacketP->control));
597 rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", PacketP->csum); 597 rio_dprintk(RIO_DEBUG_INTR, " csum = %d\n", readw(&PacketP->csum));
598 rio_dprintk(RIO_DEBUG_INTR, " data bytes: "); 598 rio_dprintk(RIO_DEBUG_INTR, " data bytes: ");
599 for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++) 599 for (DataCnt = 0; DataCnt < PKT_MAX_DATA_LEN; DataCnt++)
600 rio_dprintk(RIO_DEBUG_INTR, "%d\n", PacketP->data[DataCnt]); 600 rio_dprintk(RIO_DEBUG_INTR, "%d\n", readb(&PacketP->data[DataCnt]));
601 remove_receive(PortP); 601 remove_receive(PortP);
602 put_free_end(PortP->HostP, PacketP); 602 put_free_end(PortP->HostP, PacketP);
603 continue; /* with next packet */ 603 continue; /* with next packet */
@@ -618,24 +618,24 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)
618 ** and available space. 618 ** and available space.
619 */ 619 */
620 620
621 transCount = tty_buffer_request_room(TtyP, PacketP->len & PKT_LEN_MASK); 621 transCount = tty_buffer_request_room(TtyP, readb(&PacketP->len) & PKT_LEN_MASK);
622 rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount); 622 rio_dprintk(RIO_DEBUG_REC, "port %d: Copy %d bytes\n", PortP->PortNum, transCount);
623 /* 623 /*
624 ** To use the following 'kkprintfs' for debugging - change the '#undef' 624 ** To use the following 'kkprintfs' for debugging - change the '#undef'
625 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the 625 ** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
626 ** driver). 626 ** driver).
627 */ 627 */
628 ptr = (unsigned char *) PacketP->data + PortP->RxDataStart; 628 ptr = (unsigned char __iomem *) PacketP->data + PortP->RxDataStart;
629 629
630 tty_prepare_flip_string(TtyP, &buf, transCount); 630 tty_prepare_flip_string(TtyP, &buf, transCount);
631 rio_memcpy_fromio(buf, ptr, transCount); 631 rio_memcpy_fromio(buf, ptr, transCount);
632 PortP->RxDataStart += transCount; 632 PortP->RxDataStart += transCount;
633 PacketP->len -= transCount; 633 writeb(readb(&PacketP->len)-transCount, &PacketP->len);
634 copied += transCount; 634 copied += transCount;
635 635
636 636
637 637
638 if (PacketP->len == 0) { 638 if (readb(&PacketP->len) == 0) {
639 /* 639 /*
640 ** If we have emptied the packet, then we can 640 ** If we have emptied the packet, then we can
641 ** free it, and reset the start pointer for 641 ** free it, and reset the start pointer for
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index d2e8092cdb29..1066d9760704 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -154,8 +154,8 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
154{ 154{
155 struct tty_struct *TtyP; 155 struct tty_struct *TtyP;
156 int retval; 156 int retval;
157 struct phb_param *phb_param_ptr; 157 struct phb_param __iomem *phb_param_ptr;
158 struct PKT *PacketP; 158 struct PKT __iomem *PacketP;
159 int res; 159 int res;
160 u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; 160 u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
161 u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; 161 u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
@@ -235,7 +235,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
235 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res); 235 rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
236 rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP); 236 rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP);
237 237
238 phb_param_ptr = (struct phb_param *) PacketP->data; 238 phb_param_ptr = (struct phb_param __iomem *) PacketP->data;
239 239
240 240
241 switch (TtyP->termios->c_cflag & CSIZE) { 241 switch (TtyP->termios->c_cflag & CSIZE) {
@@ -580,11 +580,11 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
580** We can add another packet to a transmit queue if the packet pointer pointed 580** We can add another packet to a transmit queue if the packet pointer pointed
581** to by the TxAdd pointer has PKT_IN_USE clear in its address. 581** to by the TxAdd pointer has PKT_IN_USE clear in its address.
582*/ 582*/
583int can_add_transmit(struct PKT **PktP, struct Port *PortP) 583int can_add_transmit(struct PKT __iomem **PktP, struct Port *PortP)
584{ 584{
585 struct PKT *tp; 585 struct PKT __iomem *tp;
586 586
587 *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd)); 587 *PktP = tp = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
588 588
589 return !((unsigned long) tp & PKT_IN_USE); 589 return !((unsigned long) tp & PKT_IN_USE);
590} 590}
@@ -608,9 +608,9 @@ void add_transmit(struct Port *PortP)
608 * Put a packet onto the end of the 608 * Put a packet onto the end of the
609 * free list 609 * free list
610 ****************************************/ 610 ****************************************/
611void put_free_end(struct Host *HostP, struct PKT *PktP) 611void put_free_end(struct Host *HostP, struct PKT __iomem *PktP)
612{ 612{
613 struct rio_free_list *tmp_pointer; 613 struct rio_free_list __iomem *tmp_pointer;
614 unsigned short old_end, new_end; 614 unsigned short old_end, new_end;
615 unsigned long flags; 615 unsigned long flags;
616 616
@@ -625,15 +625,15 @@ void put_free_end(struct Host *HostP, struct PKT *PktP)
625 625
626 if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) { 626 if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
627 new_end = RIO_OFF(HostP->Caddr, PktP); 627 new_end = RIO_OFF(HostP->Caddr, PktP);
628 tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end); 628 tmp_pointer = (struct rio_free_list __iomem *) RIO_PTR(HostP->Caddr, old_end);
629 writew(new_end, &tmp_pointer->next); 629 writew(new_end, &tmp_pointer->next);
630 writew(old_end, &((struct rio_free_list *) PktP)->prev); 630 writew(old_end, &((struct rio_free_list __iomem *) PktP)->prev);
631 writew(TPNULL, &((struct rio_free_list *) PktP)->next); 631 writew(TPNULL, &((struct rio_free_list __iomem *) PktP)->next);
632 writew(new_end, &HostP->ParmMapP->free_list_end); 632 writew(new_end, &HostP->ParmMapP->free_list_end);
633 } else { /* First packet on the free list this should never happen! */ 633 } else { /* First packet on the free list this should never happen! */
634 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n"); 634 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
635 writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end); 635 writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
636 tmp_pointer = (struct rio_free_list *) PktP; 636 tmp_pointer = (struct rio_free_list __iomem *) PktP;
637 writew(TPNULL, &tmp_pointer->prev); 637 writew(TPNULL, &tmp_pointer->prev);
638 writew(TPNULL, &tmp_pointer->next); 638 writew(TPNULL, &tmp_pointer->next);
639 } 639 }
@@ -647,10 +647,10 @@ void put_free_end(struct Host *HostP, struct PKT *PktP)
647** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear, 647** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
648** then can_remove_receive() returns 0. 648** then can_remove_receive() returns 0.
649*/ 649*/
650int can_remove_receive(struct PKT **PktP, struct Port *PortP) 650int can_remove_receive(struct PKT __iomem **PktP, struct Port *PortP)
651{ 651{
652 if (readw(PortP->RxRemove) & PKT_IN_USE) { 652 if (readw(PortP->RxRemove) & PKT_IN_USE) {
653 *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE); 653 *PktP = (struct PKT __iomem *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
654 return 1; 654 return 1;
655 } 655 }
656 return 0; 656 return 0;
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index 357085337942..a99f3d9d7d65 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -86,9 +86,9 @@ static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned i
86** Incoming on the ROUTE_RUP 86** Incoming on the ROUTE_RUP
87** I wrote this while I was tired. Forgive me. 87** I wrote this while I was tired. Forgive me.
88*/ 88*/
89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP) 89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT __iomem * PacketP)
90{ 90{
91 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 91 struct PktCmd __iomem *PktCmdP = (struct PktCmd __iomem *) PacketP->data;
92 struct PktCmd_M *PktReplyP; 92 struct PktCmd_M *PktReplyP;
93 struct CmdBlk *CmdBlkP; 93 struct CmdBlk *CmdBlkP;
94 struct Port *PortP; 94 struct Port *PortP;
@@ -307,7 +307,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
307 if (!RIOBootOk(p, HostP, RtaUniq)) { 307 if (!RIOBootOk(p, HostP, RtaUniq)) {
308 rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq); 308 rio_dprintk(RIO_DEBUG_ROUTE, "RTA %x tried to get an ID, but does not belong - FOAD it!\n", RtaUniq);
309 PktReplyP->Command = ROUTE_FOAD; 309 PktReplyP->Command = ROUTE_FOAD;
310 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 310 memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
312 return 1; 312 return 1;
313 } 313 }
@@ -341,7 +341,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
341 HostP->Mapping[ThisUnit].Flags |= MSG_DONE; 341 HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
342 } 342 }
343 PktReplyP->Command = ROUTE_FOAD; 343 PktReplyP->Command = ROUTE_FOAD;
344 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 344 memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
346 return 1; 346 return 1;
347 } 347 }
@@ -367,7 +367,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
367 PktReplyP->IDNum2 = ROUTE_NO_ID; 367 PktReplyP->IDNum2 = ROUTE_NO_ID;
368 rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum); 368 rio_dprintk(RIO_DEBUG_ROUTE, "RTA '%s' has been allocated ID %d\n", HostP->Mapping[ThisUnit].Name, PktReplyP->IDNum);
369 } 369 }
370 HostP->Copy("RT_ALLOCAT", PktReplyP->CommandText, 10); 370 memcpy(PktReplyP->CommandText, "RT_ALLOCAT", 10);
371 371
372 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 372 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
373 373
@@ -469,7 +469,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
469 } 469 }
470 470
471 PktReplyP->Command = ROUTE_FOAD; 471 PktReplyP->Command = ROUTE_FOAD;
472 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 472 memcpy(PktReplyP->CommandText, "RT_FOAD", 7);
473 } else { 473 } else {
474 /* 474 /*
475 ** we did boot it (as an extra), and there may now be a table 475 ** we did boot it (as an extra), and there may now be a table
@@ -489,7 +489,7 @@ int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct
489 } 489 }
490 } 490 }
491 PktReplyP->Command = ROUTE_USED; 491 PktReplyP->Command = ROUTE_USED;
492 HostP->Copy("RT_USED", PktReplyP->CommandText, 7); 492 memcpy(PktReplyP->CommandText, "RT_USED", 7);
493 } 493 }
494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
495 return 1; 495 return 1;
@@ -517,8 +517,8 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
517 517
518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { 518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
519 unsigned short dest_port = port + 8; 519 unsigned short dest_port = port + 8;
520 u16 *TxPktP; 520 u16 __iomem *TxPktP;
521 struct PKT *Pkt; 521 struct PKT __iomem *Pkt;
522 522
523 PortP = p->RIOPortp[PortN]; 523 PortP = p->RIOPortp[PortN];
524 524
@@ -555,12 +555,12 @@ void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
555 ** card. This needs to be translated into a 32 bit pointer 555 ** card. This needs to be translated into a 32 bit pointer
556 ** so it can be accessed from the driver. 556 ** so it can be accessed from the driver.
557 */ 557 */
558 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP)); 558 Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(TxPktP));
559 559
560 /* 560 /*
561 ** If the packet is used, reset it. 561 ** If the packet is used, reset it.
562 */ 562 */
563 Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE); 563 Pkt = (struct PKT __iomem *) ((unsigned long) Pkt & ~PKT_IN_USE);
564 writeb(dest_unit, &Pkt->dest_unit); 564 writeb(dest_unit, &Pkt->dest_unit);
565 writeb(dest_port, &Pkt->dest_port); 565 writeb(dest_port, &Pkt->dest_port);
566 } 566 }
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index d3abe0d37d64..7e988357326e 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -534,8 +534,8 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP)
534 if (PortP->SecondBlock) { 534 if (PortP->SecondBlock) {
535 u16 dest_unit = HostMapP->ID; 535 u16 dest_unit = HostMapP->ID;
536 u16 dest_port = port - SysPort; 536 u16 dest_port = port - SysPort;
537 u16 *TxPktP; 537 u16 __iomem *TxPktP;
538 struct PKT *Pkt; 538 struct PKT __iomem *Pkt;
539 539
540 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { 540 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
541 /* 541 /*
@@ -545,12 +545,12 @@ int RIODeleteRta(struct rio_info *p, struct Map *MapP)
545 ** a 32 bit pointer so it can be 545 ** a 32 bit pointer so it can be
546 ** accessed from the driver. 546 ** accessed from the driver.
547 */ 547 */
548 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP)); 548 Pkt = (struct PKT __iomem *) RIO_PTR(HostP->Caddr, readw(&*TxPktP));
549 rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port); 549 rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", readw(TxPktP), readb(&Pkt->dest_unit), readb(&Pkt->dest_port), dest_unit, dest_port);
550 writew(dest_unit, &Pkt->dest_unit); 550 writew(dest_unit, &Pkt->dest_unit);
551 writew(dest_port, &Pkt->dest_port); 551 writew(dest_port, &Pkt->dest_port);
552 } 552 }
553 rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port); 553 rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, readb(&PortP->PhbP->destination) & 0xff, (readb(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
554 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination); 554 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
555 } 555 }
556 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); 556 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
@@ -781,13 +781,13 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
781 ** unless the host has been booted 781 ** unless the host has been booted
782 */ 782 */
783 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { 783 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
784 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; 784 struct PHB __iomem *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
785 PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add)); 785 PortP->TxAdd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
786 PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start)); 786 PortP->TxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
787 PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end)); 787 PortP->TxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
788 PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove)); 788 PortP->RxRemove = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
789 PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start)); 789 PortP->RxStart = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
790 PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end)); 790 PortP->RxEnd = (u16 __iomem *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
791 } else 791 } else
792 PortP->PhbP = NULL; 792 PortP->PhbP = NULL;
793 793
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 204267613c9c..a4f0b1e3e7fa 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -576,7 +576,7 @@ static void RIOClearUp(struct Port *PortP)
576*/ 576*/
577int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg) 577int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
578{ 578{
579 struct PKT *PacketP; 579 struct PKT __iomem *PacketP;
580 int retries = 20; /* at 10 per second -> 2 seconds */ 580 int retries = 20; /* at 10 per second -> 2 seconds */
581 unsigned long flags; 581 unsigned long flags;
582 582
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index 4306e01dbf01..46bd532f7746 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -44,7 +44,7 @@ static char *_unixrup_h_sccs_ = "@(#)unixrup.h 1.2";
44struct UnixRup { 44struct UnixRup {
45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */ 45 struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */
46 struct CmdBlk *CmdPendingP; /* The command currently being sent */ 46 struct CmdBlk *CmdPendingP; /* The command currently being sent */
47 struct RUP *RupP; /* the Rup to send it to */ 47 struct RUP __iomem *RupP; /* the Rup to send it to */
48 unsigned int Id; /* Id number */ 48 unsigned int Id; /* Id number */
49 unsigned int BaseSysPort; /* SysPort of first tty on this RTA */ 49 unsigned int BaseSysPort; /* SysPort of first tty on this RTA */
50 unsigned int ModTypes; /* Modules on this RTA */ 50 unsigned int ModTypes; /* Modules on this RTA */
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 7edc6a4dbdc4..0708c5164c83 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -324,35 +324,15 @@ static void rp_do_receive(struct r_port *info,
324 CHANNEL_t * cp, unsigned int ChanStatus) 324 CHANNEL_t * cp, unsigned int ChanStatus)
325{ 325{
326 unsigned int CharNStat; 326 unsigned int CharNStat;
327 int ToRecv, wRecv, space = 0, count; 327 int ToRecv, wRecv, space;
328 unsigned char *cbuf, *chead; 328 unsigned char *cbuf;
329 char *fbuf, *fhead;
330 struct tty_ldisc *ld;
331
332 ld = tty_ldisc_ref(tty);
333 329
334 ToRecv = sGetRxCnt(cp); 330 ToRecv = sGetRxCnt(cp);
335 space = tty->receive_room;
336 if (space > 2 * TTY_FLIPBUF_SIZE)
337 space = 2 * TTY_FLIPBUF_SIZE;
338 count = 0;
339#ifdef ROCKET_DEBUG_INTR 331#ifdef ROCKET_DEBUG_INTR
340 printk(KERN_INFO "rp_do_receive(%d, %d)...", ToRecv, space); 332 printk(KERN_INFO "rp_do_receive(%d)...", ToRecv);
341#endif 333#endif
342 334 if (ToRecv == 0)
343 /* 335 return;
344 * determine how many we can actually read in. If we can't
345 * read any in then we have a software overrun condition.
346 */
347 if (ToRecv > space)
348 ToRecv = space;
349
350 ToRecv = tty_prepare_flip_string_flags(tty, &chead, &fhead, ToRecv);
351 if (ToRecv <= 0)
352 goto done;
353
354 cbuf = chead;
355 fbuf = fhead;
356 336
357 /* 337 /*
358 * if status indicates there are errored characters in the 338 * if status indicates there are errored characters in the
@@ -380,6 +360,8 @@ static void rp_do_receive(struct r_port *info,
380 info->read_status_mask); 360 info->read_status_mask);
381#endif 361#endif
382 while (ToRecv) { 362 while (ToRecv) {
363 char flag;
364
383 CharNStat = sInW(sGetTxRxDataIO(cp)); 365 CharNStat = sInW(sGetTxRxDataIO(cp));
384#ifdef ROCKET_DEBUG_RECEIVE 366#ifdef ROCKET_DEBUG_RECEIVE
385 printk(KERN_INFO "%x...", CharNStat); 367 printk(KERN_INFO "%x...", CharNStat);
@@ -392,17 +374,16 @@ static void rp_do_receive(struct r_port *info,
392 } 374 }
393 CharNStat &= info->read_status_mask; 375 CharNStat &= info->read_status_mask;
394 if (CharNStat & STMBREAKH) 376 if (CharNStat & STMBREAKH)
395 *fbuf++ = TTY_BREAK; 377 flag = TTY_BREAK;
396 else if (CharNStat & STMPARITYH) 378 else if (CharNStat & STMPARITYH)
397 *fbuf++ = TTY_PARITY; 379 flag = TTY_PARITY;
398 else if (CharNStat & STMFRAMEH) 380 else if (CharNStat & STMFRAMEH)
399 *fbuf++ = TTY_FRAME; 381 flag = TTY_FRAME;
400 else if (CharNStat & STMRCVROVRH) 382 else if (CharNStat & STMRCVROVRH)
401 *fbuf++ = TTY_OVERRUN; 383 flag = TTY_OVERRUN;
402 else 384 else
403 *fbuf++ = TTY_NORMAL; 385 flag = TTY_NORMAL;
404 *cbuf++ = CharNStat & 0xff; 386 tty_insert_flip_char(tty, CharNStat & 0xff, flag);
405 count++;
406 ToRecv--; 387 ToRecv--;
407 } 388 }
408 389
@@ -422,20 +403,23 @@ static void rp_do_receive(struct r_port *info,
422 * characters at time by doing repeated word IO 403 * characters at time by doing repeated word IO
423 * transfer. 404 * transfer.
424 */ 405 */
406 space = tty_prepare_flip_string(tty, &cbuf, ToRecv);
407 if (space < ToRecv) {
408#ifdef ROCKET_DEBUG_RECEIVE
409 printk(KERN_INFO "rp_do_receive:insufficient space ToRecv=%d space=%d\n", ToRecv, space);
410#endif
411 if (space <= 0)
412 return;
413 ToRecv = space;
414 }
425 wRecv = ToRecv >> 1; 415 wRecv = ToRecv >> 1;
426 if (wRecv) 416 if (wRecv)
427 sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv); 417 sInStrW(sGetTxRxDataIO(cp), (unsigned short *) cbuf, wRecv);
428 if (ToRecv & 1) 418 if (ToRecv & 1)
429 cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp)); 419 cbuf[ToRecv - 1] = sInB(sGetTxRxDataIO(cp));
430 memset(fbuf, TTY_NORMAL, ToRecv);
431 cbuf += ToRecv;
432 fbuf += ToRecv;
433 count += ToRecv;
434 } 420 }
435 /* Push the data up to the tty layer */ 421 /* Push the data up to the tty layer */
436 ld->receive_buf(tty, chead, fhead, count); 422 tty_flip_buffer_push(tty);
437done:
438 tty_ldisc_deref(ld);
439} 423}
440 424
441/* 425/*
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 7cac6d05d723..0897b0c8d528 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -928,7 +928,7 @@ static int __init rtc_init(void)
928#ifdef __sparc__ 928#ifdef __sparc__
929 for_each_ebus(ebus) { 929 for_each_ebus(ebus) {
930 for_each_ebusdev(edev, ebus) { 930 for_each_ebusdev(edev, ebus) {
931 if(strcmp(edev->prom_name, "rtc") == 0) { 931 if(strcmp(edev->prom_node->name, "rtc") == 0) {
932 rtc_port = edev->resource[0].start; 932 rtc_port = edev->resource[0].start;
933 rtc_irq = edev->irqs[0]; 933 rtc_irq = edev->irqs[0];
934 goto found; 934 goto found;
@@ -938,7 +938,7 @@ static int __init rtc_init(void)
938#ifdef __sparc_v9__ 938#ifdef __sparc_v9__
939 for_each_isa(isa_br) { 939 for_each_isa(isa_br) {
940 for_each_isadev(isa_dev, isa_br) { 940 for_each_isadev(isa_dev, isa_br) {
941 if (strcmp(isa_dev->prom_name, "rtc") == 0) { 941 if (strcmp(isa_dev->prom_node->name, "rtc") == 0) {
942 rtc_port = isa_dev->resource.start; 942 rtc_port = isa_dev->resource.start;
943 rtc_irq = isa_dev->irq; 943 rtc_irq = isa_dev->irq;
944 goto found; 944 goto found;
@@ -960,10 +960,6 @@ found:
960 * PCI Slot 2 INTA# (and some INTx# in Slot 1). 960 * PCI Slot 2 INTA# (and some INTx# in Slot 1).
961 */ 961 */
962 if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) { 962 if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) {
963 /*
964 * Standard way for sparc to print irq's is to use
965 * __irq_itoa(). I think for EBus it's ok to use %d.
966 */
967 printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); 963 printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq);
968 return -EIO; 964 return -EIO;
969 } 965 }
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 664a6e97eb1a..5a280a330401 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -1,4 +1,4 @@
1/* linux/drivers/char/scx200_gpio.c 1/* linux/drivers/char/scx200_gpio.c
2 2
3 National Semiconductor SCx200 GPIO driver. Allows a user space 3 National Semiconductor SCx200 GPIO driver. Allows a user space
4 process to play with the GPIO pins. 4 process to play with the GPIO pins.
@@ -6,17 +6,26 @@
6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> */ 6 Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com> */
7 7
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/device.h>
9#include <linux/fs.h> 10#include <linux/fs.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h>
14#include <asm/uaccess.h> 16#include <asm/uaccess.h>
15#include <asm/io.h> 17#include <asm/io.h>
16 18
19#include <linux/types.h>
20#include <linux/cdev.h>
21
17#include <linux/scx200_gpio.h> 22#include <linux/scx200_gpio.h>
23#include <linux/nsc_gpio.h>
18 24
19#define NAME "scx200_gpio" 25#define NAME "scx200_gpio"
26#define DEVNAME NAME
27
28static struct platform_device *pdev;
20 29
21MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>"); 30MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
22MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver"); 31MODULE_DESCRIPTION("NatSemi SCx200 GPIO Pin Driver");
@@ -26,70 +35,23 @@ static int major = 0; /* default to dynamic major */
26module_param(major, int, 0); 35module_param(major, int, 0);
27MODULE_PARM_DESC(major, "Major device number"); 36MODULE_PARM_DESC(major, "Major device number");
28 37
29static ssize_t scx200_gpio_write(struct file *file, const char __user *data, 38struct nsc_gpio_ops scx200_access = {
30 size_t len, loff_t *ppos) 39 .owner = THIS_MODULE,
31{ 40 .gpio_config = scx200_gpio_configure,
32 unsigned m = iminor(file->f_dentry->d_inode); 41 .gpio_dump = nsc_gpio_dump,
33 size_t i; 42 .gpio_get = scx200_gpio_get,
34 43 .gpio_set = scx200_gpio_set,
35 for (i = 0; i < len; ++i) { 44 .gpio_set_high = scx200_gpio_set_high,
36 char c; 45 .gpio_set_low = scx200_gpio_set_low,
37 if (get_user(c, data+i)) 46 .gpio_change = scx200_gpio_change,
38 return -EFAULT; 47 .gpio_current = scx200_gpio_current
39 switch (c) 48};
40 {
41 case '0':
42 scx200_gpio_set(m, 0);
43 break;
44 case '1':
45 scx200_gpio_set(m, 1);
46 break;
47 case 'O':
48 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
49 scx200_gpio_configure(m, ~1, 1);
50 break;
51 case 'o':
52 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
53 scx200_gpio_configure(m, ~1, 0);
54 break;
55 case 'T':
56 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m);
57 scx200_gpio_configure(m, ~2, 2);
58 break;
59 case 't':
60 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m);
61 scx200_gpio_configure(m, ~2, 0);
62 break;
63 case 'P':
64 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
65 scx200_gpio_configure(m, ~4, 4);
66 break;
67 case 'p':
68 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
69 scx200_gpio_configure(m, ~4, 0);
70 break;
71 }
72 }
73
74 return len;
75}
76
77static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
78 size_t len, loff_t *ppos)
79{
80 unsigned m = iminor(file->f_dentry->d_inode);
81 int value;
82
83 value = scx200_gpio_get(m);
84 if (put_user(value ? '1' : '0', buf))
85 return -EFAULT;
86
87 return 1;
88}
89 49
90static int scx200_gpio_open(struct inode *inode, struct file *file) 50static int scx200_gpio_open(struct inode *inode, struct file *file)
91{ 51{
92 unsigned m = iminor(inode); 52 unsigned m = iminor(inode);
53 file->private_data = &scx200_access;
54
93 if (m > 63) 55 if (m > 63)
94 return -EINVAL; 56 return -EINVAL;
95 return nonseekable_open(inode, file); 57 return nonseekable_open(inode, file);
@@ -103,47 +65,81 @@ static int scx200_gpio_release(struct inode *inode, struct file *file)
103 65
104static struct file_operations scx200_gpio_fops = { 66static struct file_operations scx200_gpio_fops = {
105 .owner = THIS_MODULE, 67 .owner = THIS_MODULE,
106 .write = scx200_gpio_write, 68 .write = nsc_gpio_write,
107 .read = scx200_gpio_read, 69 .read = nsc_gpio_read,
108 .open = scx200_gpio_open, 70 .open = scx200_gpio_open,
109 .release = scx200_gpio_release, 71 .release = scx200_gpio_release,
110}; 72};
111 73
74struct cdev *scx200_devices;
75static int num_pins = 32;
76
112static int __init scx200_gpio_init(void) 77static int __init scx200_gpio_init(void)
113{ 78{
114 int r; 79 int rc, i;
115 80 dev_t dev = MKDEV(major, 0);
116 printk(KERN_DEBUG NAME ": NatSemi SCx200 GPIO Driver\n");
117 81
118 if (!scx200_gpio_present()) { 82 if (!scx200_gpio_present()) {
119 printk(KERN_ERR NAME ": no SCx200 gpio pins available\n"); 83 printk(KERN_ERR NAME ": no SCx200 gpio present\n");
120 return -ENODEV; 84 return -ENODEV;
121 } 85 }
122 86
123 r = register_chrdev(major, NAME, &scx200_gpio_fops); 87 /* support dev_dbg() with pdev->dev */
124 if (r < 0) { 88 pdev = platform_device_alloc(DEVNAME, 0);
125 printk(KERN_ERR NAME ": unable to register character device\n"); 89 if (!pdev)
126 return r; 90 return -ENOMEM;
91
92 rc = platform_device_add(pdev);
93 if (rc)
94 goto undo_malloc;
95
96 /* nsc_gpio uses dev_dbg(), so needs this */
97 scx200_access.dev = &pdev->dev;
98
99 if (major)
100 rc = register_chrdev_region(dev, num_pins, "scx200_gpio");
101 else {
102 rc = alloc_chrdev_region(&dev, 0, num_pins, "scx200_gpio");
103 major = MAJOR(dev);
127 } 104 }
128 if (!major) { 105 if (rc < 0) {
129 major = r; 106 dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc);
130 printk(KERN_DEBUG NAME ": got dynamic major %d\n", major); 107 goto undo_platform_device_add;
108 }
109 scx200_devices = kzalloc(num_pins * sizeof(struct cdev), GFP_KERNEL);
110 if (!scx200_devices) {
111 rc = -ENOMEM;
112 goto undo_chrdev_region;
113 }
114 for (i = 0; i < num_pins; i++) {
115 struct cdev *cdev = &scx200_devices[i];
116 cdev_init(cdev, &scx200_gpio_fops);
117 cdev->owner = THIS_MODULE;
118 rc = cdev_add(cdev, MKDEV(major, i), 1);
119 /* tolerate 'minor' errors */
120 if (rc)
121 dev_err(&pdev->dev, "Error %d on minor %d", rc, i);
131 } 122 }
132 123
133 return 0; 124 return 0; /* succeed */
125
126undo_chrdev_region:
127 unregister_chrdev_region(dev, num_pins);
128undo_platform_device_add:
129 platform_device_put(pdev);
130undo_malloc:
131 kfree(pdev);
132 return rc;
134} 133}
135 134
136static void __exit scx200_gpio_cleanup(void) 135static void __exit scx200_gpio_cleanup(void)
137{ 136{
138 unregister_chrdev(major, NAME); 137 kfree(scx200_devices);
138 unregister_chrdev_region(MKDEV(major, 0), num_pins);
139 platform_device_put(pdev);
140 platform_device_unregister(pdev);
141 /* kfree(pdev); */
139} 142}
140 143
141module_init(scx200_gpio_init); 144module_init(scx200_gpio_init);
142module_exit(scx200_gpio_cleanup); 145module_exit(scx200_gpio_cleanup);
143
144/*
145 Local variables:
146 compile-command: "make -k -C ../.. SUBDIRS=drivers/char modules"
147 c-basic-offset: 8
148 End:
149*/
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index a90f5d97df35..43dfd8689dce 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -512,7 +512,7 @@ static struct sonypi_device {
512 512
513#ifdef CONFIG_ACPI 513#ifdef CONFIG_ACPI
514static struct acpi_device *sonypi_acpi_device; 514static struct acpi_device *sonypi_acpi_device;
515static int acpi_enabled; 515static int acpi_driver_registered;
516#endif 516#endif
517 517
518static int sonypi_ec_write(u8 addr, u8 value) 518static int sonypi_ec_write(u8 addr, u8 value)
@@ -869,7 +869,7 @@ found:
869 sonypi_report_input_event(event); 869 sonypi_report_input_event(event);
870 870
871#ifdef CONFIG_ACPI 871#ifdef CONFIG_ACPI
872 if (acpi_enabled) 872 if (sonypi_acpi_device)
873 acpi_bus_generate_event(sonypi_acpi_device, 1, event); 873 acpi_bus_generate_event(sonypi_acpi_device, 1, event);
874#endif 874#endif
875 875
@@ -1551,8 +1551,8 @@ static int __init sonypi_init(void)
1551 goto err_free_device; 1551 goto err_free_device;
1552 1552
1553#ifdef CONFIG_ACPI 1553#ifdef CONFIG_ACPI
1554 if (acpi_bus_register_driver(&sonypi_acpi_driver) > 0) 1554 if (acpi_bus_register_driver(&sonypi_acpi_driver) >= 0)
1555 acpi_enabled = 1; 1555 acpi_driver_registered = 1;
1556#endif 1556#endif
1557 1557
1558 return 0; 1558 return 0;
@@ -1567,7 +1567,7 @@ static int __init sonypi_init(void)
1567static void __exit sonypi_exit(void) 1567static void __exit sonypi_exit(void)
1568{ 1568{
1569#ifdef CONFIG_ACPI 1569#ifdef CONFIG_ACPI
1570 if (acpi_enabled) 1570 if (acpi_driver_registered)
1571 acpi_bus_unregister_driver(&sonypi_acpi_driver); 1571 acpi_bus_unregister_driver(&sonypi_acpi_driver);
1572#endif 1572#endif
1573 platform_device_unregister(sonypi_platform_device); 1573 platform_device_unregister(sonypi_platform_device);
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 5343e9fc6ab7..d2d6b01dcd05 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -1683,7 +1683,7 @@ static int sx_write(struct tty_struct * tty,
1683 1683
1684 bp = port_Board(port); 1684 bp = port_Board(port);
1685 1685
1686 if (!tty || !port->xmit_buf || !tmp_buf) { 1686 if (!port->xmit_buf || !tmp_buf) {
1687 func_exit(); 1687 func_exit();
1688 return 0; 1688 return 0;
1689 } 1689 }
@@ -1733,7 +1733,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
1733 return; 1733 return;
1734 } 1734 }
1735 dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf); 1735 dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
1736 if (!tty || !port->xmit_buf) { 1736 if (!port->xmit_buf) {
1737 func_exit(); 1737 func_exit();
1738 return; 1738 return;
1739 } 1739 }
@@ -2477,7 +2477,7 @@ static int __init specialix_init(void)
2477#endif 2477#endif
2478 2478
2479 for (i = 0; i < SX_NBOARD; i++) 2479 for (i = 0; i < SX_NBOARD; i++)
2480 sx_board[i].lock = SPIN_LOCK_UNLOCKED; 2480 spin_lock_init(&sx_board[i].lock);
2481 2481
2482 if (sx_init_drivers()) { 2482 if (sx_init_drivers()) {
2483 func_exit(); 2483 func_exit();
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index a9c5a7230f89..00b4a2187164 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -141,15 +141,6 @@ static char *stl_drvversion = "5.6.0";
141static struct tty_driver *stl_serial; 141static struct tty_driver *stl_serial;
142 142
143/* 143/*
144 * We will need to allocate a temporary write buffer for chars that
145 * come direct from user space. The problem is that a copy from user
146 * space might cause a page fault (typically on a system that is
147 * swapping!). All ports will share one buffer - since if the system
148 * is already swapping a shared buffer won't make things any worse.
149 */
150static char *stl_tmpwritebuf;
151
152/*
153 * Define a local default termios struct. All ports will be created 144 * Define a local default termios struct. All ports will be created
154 * with this termios initially. Basically all it defines is a raw port 145 * with this termios initially. Basically all it defines is a raw port
155 * at 9600, 8 data bits, 1 stop bit. 146 * at 9600, 8 data bits, 1 stop bit.
@@ -363,6 +354,14 @@ static unsigned char stl_vecmap[] = {
363}; 354};
364 355
365/* 356/*
357 * Lock ordering is that you may not take stallion_lock holding
358 * brd_lock.
359 */
360
361static spinlock_t brd_lock; /* Guard the board mapping */
362static spinlock_t stallion_lock; /* Guard the tty driver */
363
364/*
366 * Set up enable and disable macros for the ECH boards. They require 365 * Set up enable and disable macros for the ECH boards. They require
367 * the secondary io address space to be activated and deactivated. 366 * the secondary io address space to be activated and deactivated.
368 * This way all ECH boards can share their secondary io region. 367 * This way all ECH boards can share their secondary io region.
@@ -725,17 +724,7 @@ static struct class *stallion_class;
725 724
726static int __init stallion_module_init(void) 725static int __init stallion_module_init(void)
727{ 726{
728 unsigned long flags;
729
730#ifdef DEBUG
731 printk("init_module()\n");
732#endif
733
734 save_flags(flags);
735 cli();
736 stl_init(); 727 stl_init();
737 restore_flags(flags);
738
739 return 0; 728 return 0;
740} 729}
741 730
@@ -746,7 +735,6 @@ static void __exit stallion_module_exit(void)
746 stlbrd_t *brdp; 735 stlbrd_t *brdp;
747 stlpanel_t *panelp; 736 stlpanel_t *panelp;
748 stlport_t *portp; 737 stlport_t *portp;
749 unsigned long flags;
750 int i, j, k; 738 int i, j, k;
751 739
752#ifdef DEBUG 740#ifdef DEBUG
@@ -756,9 +744,6 @@ static void __exit stallion_module_exit(void)
756 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle, 744 printk(KERN_INFO "Unloading %s: version %s\n", stl_drvtitle,
757 stl_drvversion); 745 stl_drvversion);
758 746
759 save_flags(flags);
760 cli();
761
762/* 747/*
763 * Free up all allocated resources used by the ports. This includes 748 * Free up all allocated resources used by the ports. This includes
764 * memory and interrupts. As part of this process we will also do 749 * memory and interrupts. As part of this process we will also do
@@ -770,7 +755,6 @@ static void __exit stallion_module_exit(void)
770 if (i) { 755 if (i) {
771 printk("STALLION: failed to un-register tty driver, " 756 printk("STALLION: failed to un-register tty driver, "
772 "errno=%d\n", -i); 757 "errno=%d\n", -i);
773 restore_flags(flags);
774 return; 758 return;
775 } 759 }
776 for (i = 0; i < 4; i++) { 760 for (i = 0; i < 4; i++) {
@@ -783,8 +767,6 @@ static void __exit stallion_module_exit(void)
783 "errno=%d\n", -i); 767 "errno=%d\n", -i);
784 class_destroy(stallion_class); 768 class_destroy(stallion_class);
785 769
786 kfree(stl_tmpwritebuf);
787
788 for (i = 0; (i < stl_nrbrds); i++) { 770 for (i = 0; (i < stl_nrbrds); i++) {
789 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL) 771 if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
790 continue; 772 continue;
@@ -814,8 +796,6 @@ static void __exit stallion_module_exit(void)
814 kfree(brdp); 796 kfree(brdp);
815 stl_brds[i] = (stlbrd_t *) NULL; 797 stl_brds[i] = (stlbrd_t *) NULL;
816 } 798 }
817
818 restore_flags(flags);
819} 799}
820 800
821module_init(stallion_module_init); 801module_init(stallion_module_init);
@@ -948,7 +928,7 @@ static stlbrd_t *stl_allocbrd(void)
948 928
949 brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL); 929 brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL);
950 if (!brdp) { 930 if (!brdp) {
951 printk("STALLION: failed to allocate memory (size=%d)\n", 931 printk("STALLION: failed to allocate memory (size=%Zd)\n",
952 sizeof(stlbrd_t)); 932 sizeof(stlbrd_t));
953 return NULL; 933 return NULL;
954 } 934 }
@@ -1066,16 +1046,17 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
1066 rc = 0; 1046 rc = 0;
1067 doclocal = 0; 1047 doclocal = 0;
1068 1048
1049 spin_lock_irqsave(&stallion_lock, flags);
1050
1069 if (portp->tty->termios->c_cflag & CLOCAL) 1051 if (portp->tty->termios->c_cflag & CLOCAL)
1070 doclocal++; 1052 doclocal++;
1071 1053
1072 save_flags(flags);
1073 cli();
1074 portp->openwaitcnt++; 1054 portp->openwaitcnt++;
1075 if (! tty_hung_up_p(filp)) 1055 if (! tty_hung_up_p(filp))
1076 portp->refcount--; 1056 portp->refcount--;
1077 1057
1078 for (;;) { 1058 for (;;) {
1059 /* Takes brd_lock internally */
1079 stl_setsignals(portp, 1, 1); 1060 stl_setsignals(portp, 1, 1);
1080 if (tty_hung_up_p(filp) || 1061 if (tty_hung_up_p(filp) ||
1081 ((portp->flags & ASYNC_INITIALIZED) == 0)) { 1062 ((portp->flags & ASYNC_INITIALIZED) == 0)) {
@@ -1093,13 +1074,14 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp)
1093 rc = -ERESTARTSYS; 1074 rc = -ERESTARTSYS;
1094 break; 1075 break;
1095 } 1076 }
1077 /* FIXME */
1096 interruptible_sleep_on(&portp->open_wait); 1078 interruptible_sleep_on(&portp->open_wait);
1097 } 1079 }
1098 1080
1099 if (! tty_hung_up_p(filp)) 1081 if (! tty_hung_up_p(filp))
1100 portp->refcount++; 1082 portp->refcount++;
1101 portp->openwaitcnt--; 1083 portp->openwaitcnt--;
1102 restore_flags(flags); 1084 spin_unlock_irqrestore(&stallion_lock, flags);
1103 1085
1104 return rc; 1086 return rc;
1105} 1087}
@@ -1119,16 +1101,15 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1119 if (portp == (stlport_t *) NULL) 1101 if (portp == (stlport_t *) NULL)
1120 return; 1102 return;
1121 1103
1122 save_flags(flags); 1104 spin_lock_irqsave(&stallion_lock, flags);
1123 cli();
1124 if (tty_hung_up_p(filp)) { 1105 if (tty_hung_up_p(filp)) {
1125 restore_flags(flags); 1106 spin_unlock_irqrestore(&stallion_lock, flags);
1126 return; 1107 return;
1127 } 1108 }
1128 if ((tty->count == 1) && (portp->refcount != 1)) 1109 if ((tty->count == 1) && (portp->refcount != 1))
1129 portp->refcount = 1; 1110 portp->refcount = 1;
1130 if (portp->refcount-- > 1) { 1111 if (portp->refcount-- > 1) {
1131 restore_flags(flags); 1112 spin_unlock_irqrestore(&stallion_lock, flags);
1132 return; 1113 return;
1133 } 1114 }
1134 1115
@@ -1142,11 +1123,18 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1142 * (The sc26198 has no "end-of-data" interrupt only empty FIFO) 1123 * (The sc26198 has no "end-of-data" interrupt only empty FIFO)
1143 */ 1124 */
1144 tty->closing = 1; 1125 tty->closing = 1;
1126
1127 spin_unlock_irqrestore(&stallion_lock, flags);
1128
1145 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1129 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1146 tty_wait_until_sent(tty, portp->closing_wait); 1130 tty_wait_until_sent(tty, portp->closing_wait);
1147 stl_waituntilsent(tty, (HZ / 2)); 1131 stl_waituntilsent(tty, (HZ / 2));
1148 1132
1133
1134 spin_lock_irqsave(&stallion_lock, flags);
1149 portp->flags &= ~ASYNC_INITIALIZED; 1135 portp->flags &= ~ASYNC_INITIALIZED;
1136 spin_unlock_irqrestore(&stallion_lock, flags);
1137
1150 stl_disableintrs(portp); 1138 stl_disableintrs(portp);
1151 if (tty->termios->c_cflag & HUPCL) 1139 if (tty->termios->c_cflag & HUPCL)
1152 stl_setsignals(portp, 0, 0); 1140 stl_setsignals(portp, 0, 0);
@@ -1173,7 +1161,6 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
1173 1161
1174 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1162 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1175 wake_up_interruptible(&portp->close_wait); 1163 wake_up_interruptible(&portp->close_wait);
1176 restore_flags(flags);
1177} 1164}
1178 1165
1179/*****************************************************************************/ 1166/*****************************************************************************/
@@ -1195,9 +1182,6 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
1195 (int) tty, (int) buf, count); 1182 (int) tty, (int) buf, count);
1196#endif 1183#endif
1197 1184
1198 if ((tty == (struct tty_struct *) NULL) ||
1199 (stl_tmpwritebuf == (char *) NULL))
1200 return 0;
1201 portp = tty->driver_data; 1185 portp = tty->driver_data;
1202 if (portp == (stlport_t *) NULL) 1186 if (portp == (stlport_t *) NULL)
1203 return 0; 1187 return 0;
@@ -1302,11 +1286,6 @@ static void stl_flushchars(struct tty_struct *tty)
1302 if (portp->tx.buf == (char *) NULL) 1286 if (portp->tx.buf == (char *) NULL)
1303 return; 1287 return;
1304 1288
1305#if 0
1306 if (tty->stopped || tty->hw_stopped ||
1307 (portp->tx.head == portp->tx.tail))
1308 return;
1309#endif
1310 stl_startrxtx(portp, -1, 1); 1289 stl_startrxtx(portp, -1, 1);
1311} 1290}
1312 1291
@@ -1977,12 +1956,14 @@ static int stl_eiointr(stlbrd_t *brdp)
1977 unsigned int iobase; 1956 unsigned int iobase;
1978 int handled = 0; 1957 int handled = 0;
1979 1958
1959 spin_lock(&brd_lock);
1980 panelp = brdp->panels[0]; 1960 panelp = brdp->panels[0];
1981 iobase = panelp->iobase; 1961 iobase = panelp->iobase;
1982 while (inb(brdp->iostatus) & EIO_INTRPEND) { 1962 while (inb(brdp->iostatus) & EIO_INTRPEND) {
1983 handled = 1; 1963 handled = 1;
1984 (* panelp->isr)(panelp, iobase); 1964 (* panelp->isr)(panelp, iobase);
1985 } 1965 }
1966 spin_unlock(&brd_lock);
1986 return handled; 1967 return handled;
1987} 1968}
1988 1969
@@ -2168,7 +2149,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
2168 portp = kzalloc(sizeof(stlport_t), GFP_KERNEL); 2149 portp = kzalloc(sizeof(stlport_t), GFP_KERNEL);
2169 if (!portp) { 2150 if (!portp) {
2170 printk("STALLION: failed to allocate memory " 2151 printk("STALLION: failed to allocate memory "
2171 "(size=%d)\n", sizeof(stlport_t)); 2152 "(size=%Zd)\n", sizeof(stlport_t));
2172 break; 2153 break;
2173 } 2154 }
2174 2155
@@ -2304,7 +2285,7 @@ static inline int stl_initeio(stlbrd_t *brdp)
2304 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); 2285 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
2305 if (!panelp) { 2286 if (!panelp) {
2306 printk(KERN_WARNING "STALLION: failed to allocate memory " 2287 printk(KERN_WARNING "STALLION: failed to allocate memory "
2307 "(size=%d)\n", sizeof(stlpanel_t)); 2288 "(size=%Zd)\n", sizeof(stlpanel_t));
2308 return -ENOMEM; 2289 return -ENOMEM;
2309 } 2290 }
2310 2291
@@ -2478,7 +2459,7 @@ static inline int stl_initech(stlbrd_t *brdp)
2478 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); 2459 panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL);
2479 if (!panelp) { 2460 if (!panelp) {
2480 printk("STALLION: failed to allocate memory " 2461 printk("STALLION: failed to allocate memory "
2481 "(size=%d)\n", sizeof(stlpanel_t)); 2462 "(size=%Zd)\n", sizeof(stlpanel_t));
2482 break; 2463 break;
2483 } 2464 }
2484 panelp->magic = STL_PANELMAGIC; 2465 panelp->magic = STL_PANELMAGIC;
@@ -2879,8 +2860,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
2879 portp->stats.lflags = 0; 2860 portp->stats.lflags = 0;
2880 portp->stats.rxbuffered = 0; 2861 portp->stats.rxbuffered = 0;
2881 2862
2882 save_flags(flags); 2863 spin_lock_irqsave(&stallion_lock, flags);
2883 cli();
2884 if (portp->tty != (struct tty_struct *) NULL) { 2864 if (portp->tty != (struct tty_struct *) NULL) {
2885 if (portp->tty->driver_data == portp) { 2865 if (portp->tty->driver_data == portp) {
2886 portp->stats.ttystate = portp->tty->flags; 2866 portp->stats.ttystate = portp->tty->flags;
@@ -2894,7 +2874,7 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp)
2894 } 2874 }
2895 } 2875 }
2896 } 2876 }
2897 restore_flags(flags); 2877 spin_unlock_irqrestore(&stallion_lock, flags);
2898 2878
2899 head = portp->tx.head; 2879 head = portp->tx.head;
2900 tail = portp->tx.tail; 2880 tail = portp->tx.tail;
@@ -3049,6 +3029,9 @@ static int __init stl_init(void)
3049 int i; 3029 int i;
3050 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); 3030 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
3051 3031
3032 spin_lock_init(&stallion_lock);
3033 spin_lock_init(&brd_lock);
3034
3052 stl_initbrds(); 3035 stl_initbrds();
3053 3036
3054 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 3037 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -3056,14 +3039,6 @@ static int __init stl_init(void)
3056 return -1; 3039 return -1;
3057 3040
3058/* 3041/*
3059 * Allocate a temporary write buffer.
3060 */
3061 stl_tmpwritebuf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL);
3062 if (!stl_tmpwritebuf)
3063 printk("STALLION: failed to allocate memory (size=%d)\n",
3064 STL_TXBUFSIZE);
3065
3066/*
3067 * Set up a character driver for per board stuff. This is mainly used 3042 * Set up a character driver for per board stuff. This is mainly used
3068 * to do stats ioctls on the ports. 3043 * to do stats ioctls on the ports.
3069 */ 3044 */
@@ -3147,11 +3122,13 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3147 unsigned int gfrcr; 3122 unsigned int gfrcr;
3148 int chipmask, i, j; 3123 int chipmask, i, j;
3149 int nrchips, uartaddr, ioaddr; 3124 int nrchips, uartaddr, ioaddr;
3125 unsigned long flags;
3150 3126
3151#ifdef DEBUG 3127#ifdef DEBUG
3152 printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp); 3128 printk("stl_panelinit(brdp=%x,panelp=%x)\n", (int) brdp, (int) panelp);
3153#endif 3129#endif
3154 3130
3131 spin_lock_irqsave(&brd_lock, flags);
3155 BRDENABLE(panelp->brdnr, panelp->pagenr); 3132 BRDENABLE(panelp->brdnr, panelp->pagenr);
3156 3133
3157/* 3134/*
@@ -3189,6 +3166,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3189 } 3166 }
3190 3167
3191 BRDDISABLE(panelp->brdnr); 3168 BRDDISABLE(panelp->brdnr);
3169 spin_unlock_irqrestore(&brd_lock, flags);
3192 return chipmask; 3170 return chipmask;
3193} 3171}
3194 3172
@@ -3200,6 +3178,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp)
3200 3178
3201static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp) 3179static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *portp)
3202{ 3180{
3181 unsigned long flags;
3203#ifdef DEBUG 3182#ifdef DEBUG
3204 printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n", 3183 printk("stl_cd1400portinit(brdp=%x,panelp=%x,portp=%x)\n",
3205 (int) brdp, (int) panelp, (int) portp); 3184 (int) brdp, (int) panelp, (int) portp);
@@ -3209,6 +3188,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po
3209 (portp == (stlport_t *) NULL)) 3188 (portp == (stlport_t *) NULL))
3210 return; 3189 return;
3211 3190
3191 spin_lock_irqsave(&brd_lock, flags);
3212 portp->ioaddr = panelp->iobase + (((brdp->brdtype == BRD_ECHPCI) || 3192 portp->ioaddr = panelp->iobase + (((brdp->brdtype == BRD_ECHPCI) ||
3213 (portp->portnr < 8)) ? 0 : EREG_BANKSIZE); 3193 (portp->portnr < 8)) ? 0 : EREG_BANKSIZE);
3214 portp->uartaddr = (portp->portnr & 0x04) << 5; 3194 portp->uartaddr = (portp->portnr & 0x04) << 5;
@@ -3219,6 +3199,7 @@ static void stl_cd1400portinit(stlbrd_t *brdp, stlpanel_t *panelp, stlport_t *po
3219 stl_cd1400setreg(portp, LIVR, (portp->portnr << 3)); 3199 stl_cd1400setreg(portp, LIVR, (portp->portnr << 3));
3220 portp->hwid = stl_cd1400getreg(portp, GFRCR); 3200 portp->hwid = stl_cd1400getreg(portp, GFRCR);
3221 BRDDISABLE(portp->brdnr); 3201 BRDDISABLE(portp->brdnr);
3202 spin_unlock_irqrestore(&brd_lock, flags);
3222} 3203}
3223 3204
3224/*****************************************************************************/ 3205/*****************************************************************************/
@@ -3428,8 +3409,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
3428 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); 3409 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
3429#endif 3410#endif
3430 3411
3431 save_flags(flags); 3412 spin_lock_irqsave(&brd_lock, flags);
3432 cli();
3433 BRDENABLE(portp->brdnr, portp->pagenr); 3413 BRDENABLE(portp->brdnr, portp->pagenr);
3434 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3)); 3414 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x3));
3435 srer = stl_cd1400getreg(portp, SRER); 3415 srer = stl_cd1400getreg(portp, SRER);
@@ -3466,7 +3446,7 @@ static void stl_cd1400setport(stlport_t *portp, struct termios *tiosp)
3466 portp->sigs &= ~TIOCM_CD; 3446 portp->sigs &= ~TIOCM_CD;
3467 stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron)); 3447 stl_cd1400setreg(portp, SRER, ((srer & ~sreroff) | sreron));
3468 BRDDISABLE(portp->brdnr); 3448 BRDDISABLE(portp->brdnr);
3469 restore_flags(flags); 3449 spin_unlock_irqrestore(&brd_lock, flags);
3470} 3450}
3471 3451
3472/*****************************************************************************/ 3452/*****************************************************************************/
@@ -3492,8 +3472,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
3492 if (rts > 0) 3472 if (rts > 0)
3493 msvr2 = MSVR2_RTS; 3473 msvr2 = MSVR2_RTS;
3494 3474
3495 save_flags(flags); 3475 spin_lock_irqsave(&brd_lock, flags);
3496 cli();
3497 BRDENABLE(portp->brdnr, portp->pagenr); 3476 BRDENABLE(portp->brdnr, portp->pagenr);
3498 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3477 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3499 if (rts >= 0) 3478 if (rts >= 0)
@@ -3501,7 +3480,7 @@ static void stl_cd1400setsignals(stlport_t *portp, int dtr, int rts)
3501 if (dtr >= 0) 3480 if (dtr >= 0)
3502 stl_cd1400setreg(portp, MSVR1, msvr1); 3481 stl_cd1400setreg(portp, MSVR1, msvr1);
3503 BRDDISABLE(portp->brdnr); 3482 BRDDISABLE(portp->brdnr);
3504 restore_flags(flags); 3483 spin_unlock_irqrestore(&brd_lock, flags);
3505} 3484}
3506 3485
3507/*****************************************************************************/ 3486/*****************************************************************************/
@@ -3520,14 +3499,13 @@ static int stl_cd1400getsignals(stlport_t *portp)
3520 printk("stl_cd1400getsignals(portp=%x)\n", (int) portp); 3499 printk("stl_cd1400getsignals(portp=%x)\n", (int) portp);
3521#endif 3500#endif
3522 3501
3523 save_flags(flags); 3502 spin_lock_irqsave(&brd_lock, flags);
3524 cli();
3525 BRDENABLE(portp->brdnr, portp->pagenr); 3503 BRDENABLE(portp->brdnr, portp->pagenr);
3526 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3504 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3527 msvr1 = stl_cd1400getreg(portp, MSVR1); 3505 msvr1 = stl_cd1400getreg(portp, MSVR1);
3528 msvr2 = stl_cd1400getreg(portp, MSVR2); 3506 msvr2 = stl_cd1400getreg(portp, MSVR2);
3529 BRDDISABLE(portp->brdnr); 3507 BRDDISABLE(portp->brdnr);
3530 restore_flags(flags); 3508 spin_unlock_irqrestore(&brd_lock, flags);
3531 3509
3532 sigs = 0; 3510 sigs = 0;
3533 sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0; 3511 sigs |= (msvr1 & MSVR1_DCD) ? TIOCM_CD : 0;
@@ -3569,15 +3547,14 @@ static void stl_cd1400enablerxtx(stlport_t *portp, int rx, int tx)
3569 else if (rx > 0) 3547 else if (rx > 0)
3570 ccr |= CCR_RXENABLE; 3548 ccr |= CCR_RXENABLE;
3571 3549
3572 save_flags(flags); 3550 spin_lock_irqsave(&brd_lock, flags);
3573 cli();
3574 BRDENABLE(portp->brdnr, portp->pagenr); 3551 BRDENABLE(portp->brdnr, portp->pagenr);
3575 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3552 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3576 stl_cd1400ccrwait(portp); 3553 stl_cd1400ccrwait(portp);
3577 stl_cd1400setreg(portp, CCR, ccr); 3554 stl_cd1400setreg(portp, CCR, ccr);
3578 stl_cd1400ccrwait(portp); 3555 stl_cd1400ccrwait(portp);
3579 BRDDISABLE(portp->brdnr); 3556 BRDDISABLE(portp->brdnr);
3580 restore_flags(flags); 3557 spin_unlock_irqrestore(&brd_lock, flags);
3581} 3558}
3582 3559
3583/*****************************************************************************/ 3560/*****************************************************************************/
@@ -3609,8 +3586,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
3609 else if (rx > 0) 3586 else if (rx > 0)
3610 sreron |= SRER_RXDATA; 3587 sreron |= SRER_RXDATA;
3611 3588
3612 save_flags(flags); 3589 spin_lock_irqsave(&brd_lock, flags);
3613 cli();
3614 BRDENABLE(portp->brdnr, portp->pagenr); 3590 BRDENABLE(portp->brdnr, portp->pagenr);
3615 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3591 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3616 stl_cd1400setreg(portp, SRER, 3592 stl_cd1400setreg(portp, SRER,
@@ -3618,7 +3594,7 @@ static void stl_cd1400startrxtx(stlport_t *portp, int rx, int tx)
3618 BRDDISABLE(portp->brdnr); 3594 BRDDISABLE(portp->brdnr);
3619 if (tx > 0) 3595 if (tx > 0)
3620 set_bit(ASYI_TXBUSY, &portp->istate); 3596 set_bit(ASYI_TXBUSY, &portp->istate);
3621 restore_flags(flags); 3597 spin_unlock_irqrestore(&brd_lock, flags);
3622} 3598}
3623 3599
3624/*****************************************************************************/ 3600/*****************************************************************************/
@@ -3634,13 +3610,12 @@ static void stl_cd1400disableintrs(stlport_t *portp)
3634#ifdef DEBUG 3610#ifdef DEBUG
3635 printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp); 3611 printk("stl_cd1400disableintrs(portp=%x)\n", (int) portp);
3636#endif 3612#endif
3637 save_flags(flags); 3613 spin_lock_irqsave(&brd_lock, flags);
3638 cli();
3639 BRDENABLE(portp->brdnr, portp->pagenr); 3614 BRDENABLE(portp->brdnr, portp->pagenr);
3640 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3615 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3641 stl_cd1400setreg(portp, SRER, 0); 3616 stl_cd1400setreg(portp, SRER, 0);
3642 BRDDISABLE(portp->brdnr); 3617 BRDDISABLE(portp->brdnr);
3643 restore_flags(flags); 3618 spin_unlock_irqrestore(&brd_lock, flags);
3644} 3619}
3645 3620
3646/*****************************************************************************/ 3621/*****************************************************************************/
@@ -3653,8 +3628,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len)
3653 printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len); 3628 printk("stl_cd1400sendbreak(portp=%x,len=%d)\n", (int) portp, len);
3654#endif 3629#endif
3655 3630
3656 save_flags(flags); 3631 spin_lock_irqsave(&brd_lock, flags);
3657 cli();
3658 BRDENABLE(portp->brdnr, portp->pagenr); 3632 BRDENABLE(portp->brdnr, portp->pagenr);
3659 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3633 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3660 stl_cd1400setreg(portp, SRER, 3634 stl_cd1400setreg(portp, SRER,
@@ -3664,7 +3638,7 @@ static void stl_cd1400sendbreak(stlport_t *portp, int len)
3664 portp->brklen = len; 3638 portp->brklen = len;
3665 if (len == 1) 3639 if (len == 1)
3666 portp->stats.txbreaks++; 3640 portp->stats.txbreaks++;
3667 restore_flags(flags); 3641 spin_unlock_irqrestore(&brd_lock, flags);
3668} 3642}
3669 3643
3670/*****************************************************************************/ 3644/*****************************************************************************/
@@ -3688,8 +3662,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state)
3688 if (tty == (struct tty_struct *) NULL) 3662 if (tty == (struct tty_struct *) NULL)
3689 return; 3663 return;
3690 3664
3691 save_flags(flags); 3665 spin_lock_irqsave(&brd_lock, flags);
3692 cli();
3693 BRDENABLE(portp->brdnr, portp->pagenr); 3666 BRDENABLE(portp->brdnr, portp->pagenr);
3694 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3667 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3695 3668
@@ -3729,7 +3702,7 @@ static void stl_cd1400flowctrl(stlport_t *portp, int state)
3729 } 3702 }
3730 3703
3731 BRDDISABLE(portp->brdnr); 3704 BRDDISABLE(portp->brdnr);
3732 restore_flags(flags); 3705 spin_unlock_irqrestore(&brd_lock, flags);
3733} 3706}
3734 3707
3735/*****************************************************************************/ 3708/*****************************************************************************/
@@ -3753,8 +3726,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state)
3753 if (tty == (struct tty_struct *) NULL) 3726 if (tty == (struct tty_struct *) NULL)
3754 return; 3727 return;
3755 3728
3756 save_flags(flags); 3729 spin_lock_irqsave(&brd_lock, flags);
3757 cli();
3758 BRDENABLE(portp->brdnr, portp->pagenr); 3730 BRDENABLE(portp->brdnr, portp->pagenr);
3759 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3731 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3760 if (state) { 3732 if (state) {
@@ -3769,7 +3741,7 @@ static void stl_cd1400sendflow(stlport_t *portp, int state)
3769 stl_cd1400ccrwait(portp); 3741 stl_cd1400ccrwait(portp);
3770 } 3742 }
3771 BRDDISABLE(portp->brdnr); 3743 BRDDISABLE(portp->brdnr);
3772 restore_flags(flags); 3744 spin_unlock_irqrestore(&brd_lock, flags);
3773} 3745}
3774 3746
3775/*****************************************************************************/ 3747/*****************************************************************************/
@@ -3785,8 +3757,7 @@ static void stl_cd1400flush(stlport_t *portp)
3785 if (portp == (stlport_t *) NULL) 3757 if (portp == (stlport_t *) NULL)
3786 return; 3758 return;
3787 3759
3788 save_flags(flags); 3760 spin_lock_irqsave(&brd_lock, flags);
3789 cli();
3790 BRDENABLE(portp->brdnr, portp->pagenr); 3761 BRDENABLE(portp->brdnr, portp->pagenr);
3791 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03)); 3762 stl_cd1400setreg(portp, CAR, (portp->portnr & 0x03));
3792 stl_cd1400ccrwait(portp); 3763 stl_cd1400ccrwait(portp);
@@ -3794,7 +3765,7 @@ static void stl_cd1400flush(stlport_t *portp)
3794 stl_cd1400ccrwait(portp); 3765 stl_cd1400ccrwait(portp);
3795 portp->tx.tail = portp->tx.head; 3766 portp->tx.tail = portp->tx.head;
3796 BRDDISABLE(portp->brdnr); 3767 BRDDISABLE(portp->brdnr);
3797 restore_flags(flags); 3768 spin_unlock_irqrestore(&brd_lock, flags);
3798} 3769}
3799 3770
3800/*****************************************************************************/ 3771/*****************************************************************************/
@@ -3833,6 +3804,7 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
3833 (int) panelp, iobase); 3804 (int) panelp, iobase);
3834#endif 3805#endif
3835 3806
3807 spin_lock(&brd_lock);
3836 outb(SVRR, iobase); 3808 outb(SVRR, iobase);
3837 svrtype = inb(iobase + EREG_DATA); 3809 svrtype = inb(iobase + EREG_DATA);
3838 if (panelp->nrports > 4) { 3810 if (panelp->nrports > 4) {
@@ -3846,6 +3818,8 @@ static void stl_cd1400eiointr(stlpanel_t *panelp, unsigned int iobase)
3846 stl_cd1400txisr(panelp, iobase); 3818 stl_cd1400txisr(panelp, iobase);
3847 else if (svrtype & SVRR_MDM) 3819 else if (svrtype & SVRR_MDM)
3848 stl_cd1400mdmisr(panelp, iobase); 3820 stl_cd1400mdmisr(panelp, iobase);
3821
3822 spin_unlock(&brd_lock);
3849} 3823}
3850 3824
3851/*****************************************************************************/ 3825/*****************************************************************************/
@@ -4433,8 +4407,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
4433 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]); 4407 tiosp->c_cc[VSTART], tiosp->c_cc[VSTOP]);
4434#endif 4408#endif
4435 4409
4436 save_flags(flags); 4410 spin_lock_irqsave(&brd_lock, flags);
4437 cli();
4438 BRDENABLE(portp->brdnr, portp->pagenr); 4411 BRDENABLE(portp->brdnr, portp->pagenr);
4439 stl_sc26198setreg(portp, IMR, 0); 4412 stl_sc26198setreg(portp, IMR, 0);
4440 stl_sc26198updatereg(portp, MR0, mr0); 4413 stl_sc26198updatereg(portp, MR0, mr0);
@@ -4461,7 +4434,7 @@ static void stl_sc26198setport(stlport_t *portp, struct termios *tiosp)
4461 portp->imr = (portp->imr & ~imroff) | imron; 4434 portp->imr = (portp->imr & ~imroff) | imron;
4462 stl_sc26198setreg(portp, IMR, portp->imr); 4435 stl_sc26198setreg(portp, IMR, portp->imr);
4463 BRDDISABLE(portp->brdnr); 4436 BRDDISABLE(portp->brdnr);
4464 restore_flags(flags); 4437 spin_unlock_irqrestore(&brd_lock, flags);
4465} 4438}
4466 4439
4467/*****************************************************************************/ 4440/*****************************************************************************/
@@ -4491,13 +4464,12 @@ static void stl_sc26198setsignals(stlport_t *portp, int dtr, int rts)
4491 else if (rts > 0) 4464 else if (rts > 0)
4492 iopioron |= IPR_RTS; 4465 iopioron |= IPR_RTS;
4493 4466
4494 save_flags(flags); 4467 spin_lock_irqsave(&brd_lock, flags);
4495 cli();
4496 BRDENABLE(portp->brdnr, portp->pagenr); 4468 BRDENABLE(portp->brdnr, portp->pagenr);
4497 stl_sc26198setreg(portp, IOPIOR, 4469 stl_sc26198setreg(portp, IOPIOR,
4498 ((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron)); 4470 ((stl_sc26198getreg(portp, IOPIOR) & ~iopioroff) | iopioron));
4499 BRDDISABLE(portp->brdnr); 4471 BRDDISABLE(portp->brdnr);
4500 restore_flags(flags); 4472 spin_unlock_irqrestore(&brd_lock, flags);
4501} 4473}
4502 4474
4503/*****************************************************************************/ 4475/*****************************************************************************/
@@ -4516,12 +4488,11 @@ static int stl_sc26198getsignals(stlport_t *portp)
4516 printk("stl_sc26198getsignals(portp=%x)\n", (int) portp); 4488 printk("stl_sc26198getsignals(portp=%x)\n", (int) portp);
4517#endif 4489#endif
4518 4490
4519 save_flags(flags); 4491 spin_lock_irqsave(&brd_lock, flags);
4520 cli();
4521 BRDENABLE(portp->brdnr, portp->pagenr); 4492 BRDENABLE(portp->brdnr, portp->pagenr);
4522 ipr = stl_sc26198getreg(portp, IPR); 4493 ipr = stl_sc26198getreg(portp, IPR);
4523 BRDDISABLE(portp->brdnr); 4494 BRDDISABLE(portp->brdnr);
4524 restore_flags(flags); 4495 spin_unlock_irqrestore(&brd_lock, flags);
4525 4496
4526 sigs = 0; 4497 sigs = 0;
4527 sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD; 4498 sigs |= (ipr & IPR_DCD) ? 0 : TIOCM_CD;
@@ -4558,13 +4529,12 @@ static void stl_sc26198enablerxtx(stlport_t *portp, int rx, int tx)
4558 else if (rx > 0) 4529 else if (rx > 0)
4559 ccr |= CR_RXENABLE; 4530 ccr |= CR_RXENABLE;
4560 4531
4561 save_flags(flags); 4532 spin_lock_irqsave(&brd_lock, flags);
4562 cli();
4563 BRDENABLE(portp->brdnr, portp->pagenr); 4533 BRDENABLE(portp->brdnr, portp->pagenr);
4564 stl_sc26198setreg(portp, SCCR, ccr); 4534 stl_sc26198setreg(portp, SCCR, ccr);
4565 BRDDISABLE(portp->brdnr); 4535 BRDDISABLE(portp->brdnr);
4566 portp->crenable = ccr; 4536 portp->crenable = ccr;
4567 restore_flags(flags); 4537 spin_unlock_irqrestore(&brd_lock, flags);
4568} 4538}
4569 4539
4570/*****************************************************************************/ 4540/*****************************************************************************/
@@ -4593,15 +4563,14 @@ static void stl_sc26198startrxtx(stlport_t *portp, int rx, int tx)
4593 else if (rx > 0) 4563 else if (rx > 0)
4594 imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG; 4564 imr |= IR_RXRDY | IR_RXBREAK | IR_RXWATCHDOG;
4595 4565
4596 save_flags(flags); 4566 spin_lock_irqsave(&brd_lock, flags);
4597 cli();
4598 BRDENABLE(portp->brdnr, portp->pagenr); 4567 BRDENABLE(portp->brdnr, portp->pagenr);
4599 stl_sc26198setreg(portp, IMR, imr); 4568 stl_sc26198setreg(portp, IMR, imr);
4600 BRDDISABLE(portp->brdnr); 4569 BRDDISABLE(portp->brdnr);
4601 portp->imr = imr; 4570 portp->imr = imr;
4602 if (tx > 0) 4571 if (tx > 0)
4603 set_bit(ASYI_TXBUSY, &portp->istate); 4572 set_bit(ASYI_TXBUSY, &portp->istate);
4604 restore_flags(flags); 4573 spin_unlock_irqrestore(&brd_lock, flags);
4605} 4574}
4606 4575
4607/*****************************************************************************/ 4576/*****************************************************************************/
@@ -4618,13 +4587,12 @@ static void stl_sc26198disableintrs(stlport_t *portp)
4618 printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp); 4587 printk("stl_sc26198disableintrs(portp=%x)\n", (int) portp);
4619#endif 4588#endif
4620 4589
4621 save_flags(flags); 4590 spin_lock_irqsave(&brd_lock, flags);
4622 cli();
4623 BRDENABLE(portp->brdnr, portp->pagenr); 4591 BRDENABLE(portp->brdnr, portp->pagenr);
4624 portp->imr = 0; 4592 portp->imr = 0;
4625 stl_sc26198setreg(portp, IMR, 0); 4593 stl_sc26198setreg(portp, IMR, 0);
4626 BRDDISABLE(portp->brdnr); 4594 BRDDISABLE(portp->brdnr);
4627 restore_flags(flags); 4595 spin_unlock_irqrestore(&brd_lock, flags);
4628} 4596}
4629 4597
4630/*****************************************************************************/ 4598/*****************************************************************************/
@@ -4637,8 +4605,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len)
4637 printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len); 4605 printk("stl_sc26198sendbreak(portp=%x,len=%d)\n", (int) portp, len);
4638#endif 4606#endif
4639 4607
4640 save_flags(flags); 4608 spin_lock_irqsave(&brd_lock, flags);
4641 cli();
4642 BRDENABLE(portp->brdnr, portp->pagenr); 4609 BRDENABLE(portp->brdnr, portp->pagenr);
4643 if (len == 1) { 4610 if (len == 1) {
4644 stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK); 4611 stl_sc26198setreg(portp, SCCR, CR_TXSTARTBREAK);
@@ -4647,7 +4614,7 @@ static void stl_sc26198sendbreak(stlport_t *portp, int len)
4647 stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK); 4614 stl_sc26198setreg(portp, SCCR, CR_TXSTOPBREAK);
4648 } 4615 }
4649 BRDDISABLE(portp->brdnr); 4616 BRDDISABLE(portp->brdnr);
4650 restore_flags(flags); 4617 spin_unlock_irqrestore(&brd_lock, flags);
4651} 4618}
4652 4619
4653/*****************************************************************************/ 4620/*****************************************************************************/
@@ -4672,8 +4639,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state)
4672 if (tty == (struct tty_struct *) NULL) 4639 if (tty == (struct tty_struct *) NULL)
4673 return; 4640 return;
4674 4641
4675 save_flags(flags); 4642 spin_lock_irqsave(&brd_lock, flags);
4676 cli();
4677 BRDENABLE(portp->brdnr, portp->pagenr); 4643 BRDENABLE(portp->brdnr, portp->pagenr);
4678 4644
4679 if (state) { 4645 if (state) {
@@ -4719,7 +4685,7 @@ static void stl_sc26198flowctrl(stlport_t *portp, int state)
4719 } 4685 }
4720 4686
4721 BRDDISABLE(portp->brdnr); 4687 BRDDISABLE(portp->brdnr);
4722 restore_flags(flags); 4688 spin_unlock_irqrestore(&brd_lock, flags);
4723} 4689}
4724 4690
4725/*****************************************************************************/ 4691/*****************************************************************************/
@@ -4744,8 +4710,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state)
4744 if (tty == (struct tty_struct *) NULL) 4710 if (tty == (struct tty_struct *) NULL)
4745 return; 4711 return;
4746 4712
4747 save_flags(flags); 4713 spin_lock_irqsave(&brd_lock, flags);
4748 cli();
4749 BRDENABLE(portp->brdnr, portp->pagenr); 4714 BRDENABLE(portp->brdnr, portp->pagenr);
4750 if (state) { 4715 if (state) {
4751 mr0 = stl_sc26198getreg(portp, MR0); 4716 mr0 = stl_sc26198getreg(portp, MR0);
@@ -4765,7 +4730,7 @@ static void stl_sc26198sendflow(stlport_t *portp, int state)
4765 stl_sc26198setreg(portp, MR0, mr0); 4730 stl_sc26198setreg(portp, MR0, mr0);
4766 } 4731 }
4767 BRDDISABLE(portp->brdnr); 4732 BRDDISABLE(portp->brdnr);
4768 restore_flags(flags); 4733 spin_unlock_irqrestore(&brd_lock, flags);
4769} 4734}
4770 4735
4771/*****************************************************************************/ 4736/*****************************************************************************/
@@ -4781,14 +4746,13 @@ static void stl_sc26198flush(stlport_t *portp)
4781 if (portp == (stlport_t *) NULL) 4746 if (portp == (stlport_t *) NULL)
4782 return; 4747 return;
4783 4748
4784 save_flags(flags); 4749 spin_lock_irqsave(&brd_lock, flags);
4785 cli();
4786 BRDENABLE(portp->brdnr, portp->pagenr); 4750 BRDENABLE(portp->brdnr, portp->pagenr);
4787 stl_sc26198setreg(portp, SCCR, CR_TXRESET); 4751 stl_sc26198setreg(portp, SCCR, CR_TXRESET);
4788 stl_sc26198setreg(portp, SCCR, portp->crenable); 4752 stl_sc26198setreg(portp, SCCR, portp->crenable);
4789 BRDDISABLE(portp->brdnr); 4753 BRDDISABLE(portp->brdnr);
4790 portp->tx.tail = portp->tx.head; 4754 portp->tx.tail = portp->tx.head;
4791 restore_flags(flags); 4755 spin_unlock_irqrestore(&brd_lock, flags);
4792} 4756}
4793 4757
4794/*****************************************************************************/ 4758/*****************************************************************************/
@@ -4815,12 +4779,11 @@ static int stl_sc26198datastate(stlport_t *portp)
4815 if (test_bit(ASYI_TXBUSY, &portp->istate)) 4779 if (test_bit(ASYI_TXBUSY, &portp->istate))
4816 return 1; 4780 return 1;
4817 4781
4818 save_flags(flags); 4782 spin_lock_irqsave(&brd_lock, flags);
4819 cli();
4820 BRDENABLE(portp->brdnr, portp->pagenr); 4783 BRDENABLE(portp->brdnr, portp->pagenr);
4821 sr = stl_sc26198getreg(portp, SR); 4784 sr = stl_sc26198getreg(portp, SR);
4822 BRDDISABLE(portp->brdnr); 4785 BRDDISABLE(portp->brdnr);
4823 restore_flags(flags); 4786 spin_unlock_irqrestore(&brd_lock, flags);
4824 4787
4825 return (sr & SR_TXEMPTY) ? 0 : 1; 4788 return (sr & SR_TXEMPTY) ? 0 : 1;
4826} 4789}
@@ -4878,6 +4841,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
4878 stlport_t *portp; 4841 stlport_t *portp;
4879 unsigned int iack; 4842 unsigned int iack;
4880 4843
4844 spin_lock(&brd_lock);
4845
4881/* 4846/*
4882 * Work around bug in sc26198 chip... Cannot have A6 address 4847 * Work around bug in sc26198 chip... Cannot have A6 address
4883 * line of UART high, else iack will be returned as 0. 4848 * line of UART high, else iack will be returned as 0.
@@ -4893,6 +4858,8 @@ static void stl_sc26198intr(stlpanel_t *panelp, unsigned int iobase)
4893 stl_sc26198txisr(portp); 4858 stl_sc26198txisr(portp);
4894 else 4859 else
4895 stl_sc26198otherisr(portp, iack); 4860 stl_sc26198otherisr(portp, iack);
4861
4862 spin_unlock(&brd_lock);
4896} 4863}
4897 4864
4898/*****************************************************************************/ 4865/*****************************************************************************/
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 3b4747230270..76b9107f7f81 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2320,7 +2320,7 @@ static int sx_init_portstructs (int nboards, int nports)
2320#ifdef NEW_WRITE_LOCKING 2320#ifdef NEW_WRITE_LOCKING
2321 port->gs.port_write_mutex = MUTEX; 2321 port->gs.port_write_mutex = MUTEX;
2322#endif 2322#endif
2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED; 2323 spin_lock_init(&port->gs.driver_lock);
2324 /* 2324 /*
2325 * Initializing wait queue 2325 * Initializing wait queue
2326 */ 2326 */
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index b4d1f4eea435..4e35d4181224 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -101,6 +101,7 @@ MODULE_LICENSE("GPL");
101 101
102static struct pci_device_id pci_table[] = { 102static struct pci_device_id pci_table[] = {
103 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 103 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
104 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT2_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
104 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 105 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
105 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_AC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 106 {PCI_VENDOR_ID_MICROGATE, SYNCLINK_AC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
106 {0,}, /* terminate list */ 107 {0,}, /* terminate list */
@@ -870,7 +871,7 @@ static int write(struct tty_struct *tty,
870 goto cleanup; 871 goto cleanup;
871 DBGINFO(("%s write count=%d\n", info->device_name, count)); 872 DBGINFO(("%s write count=%d\n", info->device_name, count));
872 873
873 if (!tty || !info->tx_buf) 874 if (!info->tx_buf)
874 goto cleanup; 875 goto cleanup;
875 876
876 if (count > info->max_frame_size) { 877 if (count > info->max_frame_size) {
@@ -924,7 +925,7 @@ static void put_char(struct tty_struct *tty, unsigned char ch)
924 if (sanity_check(info, tty->name, "put_char")) 925 if (sanity_check(info, tty->name, "put_char"))
925 return; 926 return;
926 DBGINFO(("%s put_char(%d)\n", info->device_name, ch)); 927 DBGINFO(("%s put_char(%d)\n", info->device_name, ch));
927 if (!tty || !info->tx_buf) 928 if (!info->tx_buf)
928 return; 929 return;
929 spin_lock_irqsave(&info->lock,flags); 930 spin_lock_irqsave(&info->lock,flags);
930 if (!info->tx_active && (info->tx_count < info->max_frame_size)) 931 if (!info->tx_active && (info->tx_count < info->max_frame_size))
@@ -2515,7 +2516,8 @@ static int set_txidle(struct slgt_info *info, int idle_mode)
2515 DBGINFO(("%s set_txidle(%d)\n", info->device_name, idle_mode)); 2516 DBGINFO(("%s set_txidle(%d)\n", info->device_name, idle_mode));
2516 spin_lock_irqsave(&info->lock,flags); 2517 spin_lock_irqsave(&info->lock,flags);
2517 info->idle_mode = idle_mode; 2518 info->idle_mode = idle_mode;
2518 tx_set_idle(info); 2519 if (info->params.mode != MGSL_MODE_ASYNC)
2520 tx_set_idle(info);
2519 spin_unlock_irqrestore(&info->lock,flags); 2521 spin_unlock_irqrestore(&info->lock,flags);
2520 return 0; 2522 return 0;
2521} 2523}
@@ -3076,7 +3078,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
3076 3078
3077static int alloc_tmp_rbuf(struct slgt_info *info) 3079static int alloc_tmp_rbuf(struct slgt_info *info)
3078{ 3080{
3079 info->tmp_rbuf = kmalloc(info->max_frame_size, GFP_KERNEL); 3081 info->tmp_rbuf = kmalloc(info->max_frame_size + 5, GFP_KERNEL);
3080 if (info->tmp_rbuf == NULL) 3082 if (info->tmp_rbuf == NULL)
3081 return -ENOMEM; 3083 return -ENOMEM;
3082 return 0; 3084 return 0;
@@ -3276,6 +3278,9 @@ static void add_device(struct slgt_info *info)
3276 case SYNCLINK_GT_DEVICE_ID: 3278 case SYNCLINK_GT_DEVICE_ID:
3277 devstr = "GT"; 3279 devstr = "GT";
3278 break; 3280 break;
3281 case SYNCLINK_GT2_DEVICE_ID:
3282 devstr = "GT2";
3283 break;
3279 case SYNCLINK_GT4_DEVICE_ID: 3284 case SYNCLINK_GT4_DEVICE_ID:
3280 devstr = "GT4"; 3285 devstr = "GT4";
3281 break; 3286 break;
@@ -3353,7 +3358,9 @@ static void device_init(int adapter_num, struct pci_dev *pdev)
3353 int i; 3358 int i;
3354 int port_count = 1; 3359 int port_count = 1;
3355 3360
3356 if (pdev->device == SYNCLINK_GT4_DEVICE_ID) 3361 if (pdev->device == SYNCLINK_GT2_DEVICE_ID)
3362 port_count = 2;
3363 else if (pdev->device == SYNCLINK_GT4_DEVICE_ID)
3357 port_count = 4; 3364 port_count = 4;
3358 3365
3359 /* allocate device instances for all ports */ 3366 /* allocate device instances for all ports */
@@ -3940,8 +3947,6 @@ static void async_mode(struct slgt_info *info)
3940 3947
3941 msc_set_vcr(info); 3948 msc_set_vcr(info);
3942 3949
3943 tx_set_idle(info);
3944
3945 /* SCR (serial control) 3950 /* SCR (serial control)
3946 * 3951 *
3947 * 15 1=tx req on FIFO half empty 3952 * 15 1=tx req on FIFO half empty
@@ -4012,7 +4017,7 @@ static void hdlc_mode(struct slgt_info *info)
4012 case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break; 4017 case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break;
4013 } 4018 }
4014 4019
4015 switch (info->params.crc_type) 4020 switch (info->params.crc_type & HDLC_CRC_MASK)
4016 { 4021 {
4017 case HDLC_CRC_16_CCITT: val |= BIT9; break; 4022 case HDLC_CRC_16_CCITT: val |= BIT9; break;
4018 case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break; 4023 case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break;
@@ -4073,7 +4078,7 @@ static void hdlc_mode(struct slgt_info *info)
4073 case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break; 4078 case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break;
4074 } 4079 }
4075 4080
4076 switch (info->params.crc_type) 4081 switch (info->params.crc_type & HDLC_CRC_MASK)
4077 { 4082 {
4078 case HDLC_CRC_16_CCITT: val |= BIT9; break; 4083 case HDLC_CRC_16_CCITT: val |= BIT9; break;
4079 case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break; 4084 case HDLC_CRC_32_CCITT: val |= BIT9 + BIT8; break;
@@ -4175,17 +4180,38 @@ static void hdlc_mode(struct slgt_info *info)
4175 */ 4180 */
4176static void tx_set_idle(struct slgt_info *info) 4181static void tx_set_idle(struct slgt_info *info)
4177{ 4182{
4178 unsigned char val = 0xff; 4183 unsigned char val;
4184 unsigned short tcr;
4179 4185
4180 switch(info->idle_mode) 4186 /* if preamble enabled (tcr[6] == 1) then tx idle size = 8 bits
4181 { 4187 * else tcr[5:4] = tx idle size: 00 = 8 bits, 01 = 16 bits
4182 case HDLC_TXIDLE_FLAGS: val = 0x7e; break; 4188 */
4183 case HDLC_TXIDLE_ALT_ZEROS_ONES: val = 0xaa; break; 4189 tcr = rd_reg16(info, TCR);
4184 case HDLC_TXIDLE_ZEROS: val = 0x00; break; 4190 if (info->idle_mode & HDLC_TXIDLE_CUSTOM_16) {
4185 case HDLC_TXIDLE_ONES: val = 0xff; break; 4191 /* disable preamble, set idle size to 16 bits */
4186 case HDLC_TXIDLE_ALT_MARK_SPACE: val = 0xaa; break; 4192 tcr = (tcr & ~(BIT6 + BIT5)) | BIT4;
4187 case HDLC_TXIDLE_SPACE: val = 0x00; break; 4193 /* MSB of 16 bit idle specified in tx preamble register (TPR) */
4188 case HDLC_TXIDLE_MARK: val = 0xff; break; 4194 wr_reg8(info, TPR, (unsigned char)((info->idle_mode >> 8) & 0xff));
4195 } else if (!(tcr & BIT6)) {
4196 /* preamble is disabled, set idle size to 8 bits */
4197 tcr &= ~(BIT5 + BIT4);
4198 }
4199 wr_reg16(info, TCR, tcr);
4200
4201 if (info->idle_mode & (HDLC_TXIDLE_CUSTOM_8 | HDLC_TXIDLE_CUSTOM_16)) {
4202 /* LSB of custom tx idle specified in tx idle register */
4203 val = (unsigned char)(info->idle_mode & 0xff);
4204 } else {
4205 /* standard 8 bit idle patterns */
4206 switch(info->idle_mode)
4207 {
4208 case HDLC_TXIDLE_FLAGS: val = 0x7e; break;
4209 case HDLC_TXIDLE_ALT_ZEROS_ONES:
4210 case HDLC_TXIDLE_ALT_MARK_SPACE: val = 0xaa; break;
4211 case HDLC_TXIDLE_ZEROS:
4212 case HDLC_TXIDLE_SPACE: val = 0x00; break;
4213 default: val = 0xff;
4214 }
4189 } 4215 }
4190 4216
4191 wr_reg8(info, TIR, val); 4217 wr_reg8(info, TIR, val);
@@ -4313,6 +4339,12 @@ static int rx_get_frame(struct slgt_info *info)
4313 unsigned long flags; 4339 unsigned long flags;
4314 struct tty_struct *tty = info->tty; 4340 struct tty_struct *tty = info->tty;
4315 unsigned char addr_field = 0xff; 4341 unsigned char addr_field = 0xff;
4342 unsigned int crc_size = 0;
4343
4344 switch (info->params.crc_type & HDLC_CRC_MASK) {
4345 case HDLC_CRC_16_CCITT: crc_size = 2; break;
4346 case HDLC_CRC_32_CCITT: crc_size = 4; break;
4347 }
4316 4348
4317check_again: 4349check_again:
4318 4350
@@ -4357,7 +4389,7 @@ check_again:
4357 status = desc_status(info->rbufs[end]); 4389 status = desc_status(info->rbufs[end]);
4358 4390
4359 /* ignore CRC bit if not using CRC (bit is undefined) */ 4391 /* ignore CRC bit if not using CRC (bit is undefined) */
4360 if (info->params.crc_type == HDLC_CRC_NONE) 4392 if ((info->params.crc_type & HDLC_CRC_MASK) == HDLC_CRC_NONE)
4361 status &= ~BIT1; 4393 status &= ~BIT1;
4362 4394
4363 if (framesize == 0 || 4395 if (framesize == 0 ||
@@ -4366,34 +4398,34 @@ check_again:
4366 goto check_again; 4398 goto check_again;
4367 } 4399 }
4368 4400
4369 if (framesize < 2 || status & (BIT1+BIT0)) { 4401 if (framesize < (2 + crc_size) || status & BIT0) {
4370 if (framesize < 2 || (status & BIT0)) 4402 info->icount.rxshort++;
4371 info->icount.rxshort++;
4372 else
4373 info->icount.rxcrc++;
4374 framesize = 0; 4403 framesize = 0;
4404 } else if (status & BIT1) {
4405 info->icount.rxcrc++;
4406 if (!(info->params.crc_type & HDLC_CRC_RETURN_EX))
4407 framesize = 0;
4408 }
4375 4409
4376#ifdef CONFIG_HDLC 4410#ifdef CONFIG_HDLC
4377 { 4411 if (framesize == 0) {
4378 struct net_device_stats *stats = hdlc_stats(info->netdev); 4412 struct net_device_stats *stats = hdlc_stats(info->netdev);
4379 stats->rx_errors++; 4413 stats->rx_errors++;
4380 stats->rx_frame_errors++; 4414 stats->rx_frame_errors++;
4381 }
4382#endif
4383 } else {
4384 /* adjust frame size for CRC, if any */
4385 if (info->params.crc_type == HDLC_CRC_16_CCITT)
4386 framesize -= 2;
4387 else if (info->params.crc_type == HDLC_CRC_32_CCITT)
4388 framesize -= 4;
4389 } 4415 }
4416#endif
4390 4417
4391 DBGBH(("%s rx frame status=%04X size=%d\n", 4418 DBGBH(("%s rx frame status=%04X size=%d\n",
4392 info->device_name, status, framesize)); 4419 info->device_name, status, framesize));
4393 DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, DMABUFSIZE), "rx"); 4420 DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, DMABUFSIZE), "rx");
4394 4421
4395 if (framesize) { 4422 if (framesize) {
4396 if (framesize > info->max_frame_size) 4423 if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) {
4424 framesize -= crc_size;
4425 crc_size = 0;
4426 }
4427
4428 if (framesize > info->max_frame_size + crc_size)
4397 info->icount.rxlong++; 4429 info->icount.rxlong++;
4398 else { 4430 else {
4399 /* copy dma buffer(s) to contiguous temp buffer */ 4431 /* copy dma buffer(s) to contiguous temp buffer */
@@ -4413,6 +4445,11 @@ check_again:
4413 i = 0; 4445 i = 0;
4414 } 4446 }
4415 4447
4448 if (info->params.crc_type & HDLC_CRC_RETURN_EX) {
4449 *p = (status & BIT1) ? RX_CRC_ERROR : RX_OK;
4450 framesize++;
4451 }
4452
4416#ifdef CONFIG_HDLC 4453#ifdef CONFIG_HDLC
4417 if (info->netcount) 4454 if (info->netcount)
4418 hdlcdev_rx(info,info->tmp_rbuf, framesize); 4455 hdlcdev_rx(info,info->tmp_rbuf, framesize);
@@ -4671,13 +4708,13 @@ static int loopback_test(struct slgt_info *info)
4671static int adapter_test(struct slgt_info *info) 4708static int adapter_test(struct slgt_info *info)
4672{ 4709{
4673 DBGINFO(("testing %s\n", info->device_name)); 4710 DBGINFO(("testing %s\n", info->device_name));
4674 if ((info->init_error = register_test(info)) < 0) { 4711 if (register_test(info) < 0) {
4675 printk("register test failure %s addr=%08X\n", 4712 printk("register test failure %s addr=%08X\n",
4676 info->device_name, info->phys_reg_addr); 4713 info->device_name, info->phys_reg_addr);
4677 } else if ((info->init_error = irq_test(info)) < 0) { 4714 } else if (irq_test(info) < 0) {
4678 printk("IRQ test failure %s IRQ=%d\n", 4715 printk("IRQ test failure %s IRQ=%d\n",
4679 info->device_name, info->irq_level); 4716 info->device_name, info->irq_level);
4680 } else if ((info->init_error = loopback_test(info)) < 0) { 4717 } else if (loopback_test(info) < 0) {
4681 printk("loopback test failure %s\n", info->device_name); 4718 printk("loopback test failure %s\n", info->device_name);
4682 } 4719 }
4683 return info->init_error; 4720 return info->init_error;
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 858740131115..21bf15ad9980 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -988,7 +988,7 @@ static int write(struct tty_struct *tty,
988 if (sanity_check(info, tty->name, "write")) 988 if (sanity_check(info, tty->name, "write"))
989 goto cleanup; 989 goto cleanup;
990 990
991 if (!tty || !info->tx_buf) 991 if (!info->tx_buf)
992 goto cleanup; 992 goto cleanup;
993 993
994 if (info->params.mode == MGSL_MODE_HDLC) { 994 if (info->params.mode == MGSL_MODE_HDLC) {
@@ -1067,7 +1067,7 @@ static void put_char(struct tty_struct *tty, unsigned char ch)
1067 if (sanity_check(info, tty->name, "put_char")) 1067 if (sanity_check(info, tty->name, "put_char"))
1068 return; 1068 return;
1069 1069
1070 if (!tty || !info->tx_buf) 1070 if (!info->tx_buf)
1071 return; 1071 return;
1072 1072
1073 spin_lock_irqsave(&info->lock,flags); 1073 spin_lock_irqsave(&info->lock,flags);
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index f58ad7f68267..ef68d152d3e4 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -343,7 +343,7 @@ static ssize_t store_received_ref_clk3b(struct device *d,
343 343
344 val = (unsigned char)tmp; 344 val = (unsigned char)tmp;
345 spin_lock_irqsave(&event_lock, flags); 345 spin_lock_irqsave(&event_lock, flags);
346 SET_PORT_BITS(TLCLK_REG1, 0xef, val << 1); 346 SET_PORT_BITS(TLCLK_REG1, 0xdf, val << 1);
347 spin_unlock_irqrestore(&event_lock, flags); 347 spin_unlock_irqrestore(&event_lock, flags);
348 348
349 return strnlen(buf, count); 349 return strnlen(buf, count);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a88b94a82b14..8d19f7281f0b 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -267,7 +267,6 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
267 p->used = 0; 267 p->used = 0;
268 p->size = size; 268 p->size = size;
269 p->next = NULL; 269 p->next = NULL;
270 p->active = 0;
271 p->commit = 0; 270 p->commit = 0;
272 p->read = 0; 271 p->read = 0;
273 p->char_buf_ptr = (char *)(p->data); 272 p->char_buf_ptr = (char *)(p->data);
@@ -327,10 +326,9 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
327 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 326 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
328 remove this conditional if its worth it. This would be invisible 327 remove this conditional if its worth it. This would be invisible
329 to the callers */ 328 to the callers */
330 if ((b = tty->buf.tail) != NULL) { 329 if ((b = tty->buf.tail) != NULL)
331 left = b->size - b->used; 330 left = b->size - b->used;
332 b->active = 1; 331 else
333 } else
334 left = 0; 332 left = 0;
335 333
336 if (left < size) { 334 if (left < size) {
@@ -338,12 +336,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
338 if ((n = tty_buffer_find(tty, size)) != NULL) { 336 if ((n = tty_buffer_find(tty, size)) != NULL) {
339 if (b != NULL) { 337 if (b != NULL) {
340 b->next = n; 338 b->next = n;
341 b->active = 0;
342 b->commit = b->used; 339 b->commit = b->used;
343 } else 340 } else
344 tty->buf.head = n; 341 tty->buf.head = n;
345 tty->buf.tail = n; 342 tty->buf.tail = n;
346 n->active = 1;
347 } else 343 } else
348 size = left; 344 size = left;
349 } 345 }
@@ -404,10 +400,8 @@ void tty_schedule_flip(struct tty_struct *tty)
404{ 400{
405 unsigned long flags; 401 unsigned long flags;
406 spin_lock_irqsave(&tty->buf.lock, flags); 402 spin_lock_irqsave(&tty->buf.lock, flags);
407 if (tty->buf.tail != NULL) { 403 if (tty->buf.tail != NULL)
408 tty->buf.tail->active = 0;
409 tty->buf.tail->commit = tty->buf.tail->used; 404 tty->buf.tail->commit = tty->buf.tail->used;
410 }
411 spin_unlock_irqrestore(&tty->buf.lock, flags); 405 spin_unlock_irqrestore(&tty->buf.lock, flags);
412 schedule_delayed_work(&tty->buf.work, 1); 406 schedule_delayed_work(&tty->buf.work, 1);
413} 407}
@@ -784,11 +778,8 @@ restart:
784 } 778 }
785 779
786 clear_bit(TTY_LDISC, &tty->flags); 780 clear_bit(TTY_LDISC, &tty->flags);
787 clear_bit(TTY_DONT_FLIP, &tty->flags); 781 if (o_tty)
788 if (o_tty) {
789 clear_bit(TTY_LDISC, &o_tty->flags); 782 clear_bit(TTY_LDISC, &o_tty->flags);
790 clear_bit(TTY_DONT_FLIP, &o_tty->flags);
791 }
792 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 783 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
793 784
794 /* 785 /*
@@ -1955,7 +1946,6 @@ static void release_dev(struct file * filp)
1955 * race with the set_ldisc code path. 1946 * race with the set_ldisc code path.
1956 */ 1947 */
1957 clear_bit(TTY_LDISC, &tty->flags); 1948 clear_bit(TTY_LDISC, &tty->flags);
1958 clear_bit(TTY_DONT_FLIP, &tty->flags);
1959 cancel_delayed_work(&tty->buf.work); 1949 cancel_delayed_work(&tty->buf.work);
1960 1950
1961 /* 1951 /*
@@ -2621,10 +2611,9 @@ int tty_ioctl(struct inode * inode, struct file * file,
2621 tty->driver->break_ctl(tty, 0); 2611 tty->driver->break_ctl(tty, 0);
2622 return 0; 2612 return 0;
2623 case TCSBRK: /* SVID version: non-zero arg --> no break */ 2613 case TCSBRK: /* SVID version: non-zero arg --> no break */
2624 /* 2614 /* non-zero arg means wait for all output data
2625 * XXX is the above comment correct, or the 2615 * to be sent (performed above) but don't send break.
2626 * code below correct? Is this ioctl used at 2616 * This is used by the tcdrain() termios function.
2627 * all by anyone?
2628 */ 2617 */
2629 if (!arg) 2618 if (!arg)
2630 return send_break(tty, 250); 2619 return send_break(tty, 250);
@@ -2776,8 +2765,7 @@ static void flush_to_ldisc(void *private_)
2776 struct tty_struct *tty = (struct tty_struct *) private_; 2765 struct tty_struct *tty = (struct tty_struct *) private_;
2777 unsigned long flags; 2766 unsigned long flags;
2778 struct tty_ldisc *disc; 2767 struct tty_ldisc *disc;
2779 struct tty_buffer *tbuf; 2768 struct tty_buffer *tbuf, *head;
2780 int count;
2781 char *char_buf; 2769 char *char_buf;
2782 unsigned char *flag_buf; 2770 unsigned char *flag_buf;
2783 2771
@@ -2785,32 +2773,37 @@ static void flush_to_ldisc(void *private_)
2785 if (disc == NULL) /* !TTY_LDISC */ 2773 if (disc == NULL) /* !TTY_LDISC */
2786 return; 2774 return;
2787 2775
2788 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
2789 /*
2790 * Do it after the next timer tick:
2791 */
2792 schedule_delayed_work(&tty->buf.work, 1);
2793 goto out;
2794 }
2795 spin_lock_irqsave(&tty->buf.lock, flags); 2776 spin_lock_irqsave(&tty->buf.lock, flags);
2796 while((tbuf = tty->buf.head) != NULL) { 2777 head = tty->buf.head;
2797 while ((count = tbuf->commit - tbuf->read) != 0) { 2778 if (head != NULL) {
2798 char_buf = tbuf->char_buf_ptr + tbuf->read; 2779 tty->buf.head = NULL;
2799 flag_buf = tbuf->flag_buf_ptr + tbuf->read; 2780 for (;;) {
2800 tbuf->read += count; 2781 int count = head->commit - head->read;
2782 if (!count) {
2783 if (head->next == NULL)
2784 break;
2785 tbuf = head;
2786 head = head->next;
2787 tty_buffer_free(tty, tbuf);
2788 continue;
2789 }
2790 if (!tty->receive_room) {
2791 schedule_delayed_work(&tty->buf.work, 1);
2792 break;
2793 }
2794 if (count > tty->receive_room)
2795 count = tty->receive_room;
2796 char_buf = head->char_buf_ptr + head->read;
2797 flag_buf = head->flag_buf_ptr + head->read;
2798 head->read += count;
2801 spin_unlock_irqrestore(&tty->buf.lock, flags); 2799 spin_unlock_irqrestore(&tty->buf.lock, flags);
2802 disc->receive_buf(tty, char_buf, flag_buf, count); 2800 disc->receive_buf(tty, char_buf, flag_buf, count);
2803 spin_lock_irqsave(&tty->buf.lock, flags); 2801 spin_lock_irqsave(&tty->buf.lock, flags);
2804 } 2802 }
2805 if (tbuf->active) 2803 tty->buf.head = head;
2806 break;
2807 tty->buf.head = tbuf->next;
2808 if (tty->buf.head == NULL)
2809 tty->buf.tail = NULL;
2810 tty_buffer_free(tty, tbuf);
2811 } 2804 }
2812 spin_unlock_irqrestore(&tty->buf.lock, flags); 2805 spin_unlock_irqrestore(&tty->buf.lock, flags);
2813out: 2806
2814 tty_ldisc_deref(disc); 2807 tty_ldisc_deref(disc);
2815} 2808}
2816 2809
@@ -2903,10 +2896,8 @@ void tty_flip_buffer_push(struct tty_struct *tty)
2903{ 2896{
2904 unsigned long flags; 2897 unsigned long flags;
2905 spin_lock_irqsave(&tty->buf.lock, flags); 2898 spin_lock_irqsave(&tty->buf.lock, flags);
2906 if (tty->buf.tail != NULL) { 2899 if (tty->buf.tail != NULL)
2907 tty->buf.tail->active = 0;
2908 tty->buf.tail->commit = tty->buf.tail->used; 2900 tty->buf.tail->commit = tty->buf.tail->used;
2909 }
2910 spin_unlock_irqrestore(&tty->buf.lock, flags); 2901 spin_unlock_irqrestore(&tty->buf.lock, flags);
2911 2902
2912 if (tty->low_latency) 2903 if (tty->low_latency)
@@ -2961,12 +2952,14 @@ static struct class *tty_class;
2961 * This field is optional, if there is no known struct device for this 2952 * This field is optional, if there is no known struct device for this
2962 * tty device it can be set to NULL safely. 2953 * tty device it can be set to NULL safely.
2963 * 2954 *
2955 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error).
2956 *
2964 * This call is required to be made to register an individual tty device if 2957 * This call is required to be made to register an individual tty device if
2965 * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that 2958 * the tty driver's flags have the TTY_DRIVER_NO_DEVFS bit set. If that
2966 * bit is not set, this function should not be called. 2959 * bit is not set, this function should not be called.
2967 */ 2960 */
2968void tty_register_device(struct tty_driver *driver, unsigned index, 2961struct class_device *tty_register_device(struct tty_driver *driver,
2969 struct device *device) 2962 unsigned index, struct device *device)
2970{ 2963{
2971 char name[64]; 2964 char name[64];
2972 dev_t dev = MKDEV(driver->major, driver->minor_start) + index; 2965 dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -2974,7 +2967,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2974 if (index >= driver->num) { 2967 if (index >= driver->num) {
2975 printk(KERN_ERR "Attempt to register invalid tty line number " 2968 printk(KERN_ERR "Attempt to register invalid tty line number "
2976 " (%d).\n", index); 2969 " (%d).\n", index);
2977 return; 2970 return ERR_PTR(-EINVAL);
2978 } 2971 }
2979 2972
2980 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 2973 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
@@ -2984,7 +2977,8 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2984 pty_line_name(driver, index, name); 2977 pty_line_name(driver, index, name);
2985 else 2978 else
2986 tty_line_name(driver, index, name); 2979 tty_line_name(driver, index, name);
2987 class_device_create(tty_class, NULL, dev, device, "%s", name); 2980
2981 return class_device_create(tty_class, NULL, dev, device, "%s", name);
2988} 2982}
2989 2983
2990/** 2984/**
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 60aabdb4a046..11c7e9de5958 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -989,7 +989,7 @@ static int viotape_remove(struct vio_dev *vdev)
989 * support. 989 * support.
990 */ 990 */
991static struct vio_device_id viotape_device_table[] __devinitdata = { 991static struct vio_device_id viotape_device_table[] __devinitdata = {
992 { "viotape", "" }, 992 { "byte", "IBM,iSeries-viotape" },
993 { "", "" } 993 { "", "" }
994}; 994};
995MODULE_DEVICE_TABLE(vio, viotape_device_table); 995MODULE_DEVICE_TABLE(vio, viotape_device_table);
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 05e6e814d86f..073da48c092e 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -689,9 +689,9 @@ static int __devinit giu_probe(struct platform_device *dev)
689 689
690 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) { 690 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) {
691 if (i < GIU_IRQ(GIUINT_HIGH_OFFSET)) 691 if (i < GIU_IRQ(GIUINT_HIGH_OFFSET))
692 irq_desc[i].handler = &giuint_low_irq_type; 692 irq_desc[i].chip = &giuint_low_irq_type;
693 else 693 else
694 irq_desc[i].handler = &giuint_high_irq_type; 694 irq_desc[i].chip = &giuint_high_irq_type;
695 } 695 }
696 696
697 return cascade_irq(GIUINT_IRQ, giu_get_irq); 697 return cascade_irq(GIUINT_IRQ, giu_get_irq);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 6c94879e0b99..714d95ff2f1e 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -98,7 +98,22 @@
98#include <asm/system.h> 98#include <asm/system.h>
99#include <asm/uaccess.h> 99#include <asm/uaccess.h>
100 100
101#define MAX_NR_CON_DRIVER 16
101 102
103#define CON_DRIVER_FLAG_MODULE 1
104#define CON_DRIVER_FLAG_INIT 2
105
106struct con_driver {
107 const struct consw *con;
108 const char *desc;
109 struct class_device *class_dev;
110 int node;
111 int first;
112 int last;
113 int flag;
114};
115
116static struct con_driver registered_con_driver[MAX_NR_CON_DRIVER];
102const struct consw *conswitchp; 117const struct consw *conswitchp;
103 118
104/* A bitmap for codes <32. A bit of 1 indicates that the code 119/* A bitmap for codes <32. A bit of 1 indicates that the code
@@ -2557,7 +2572,7 @@ static int __init con_init(void)
2557{ 2572{
2558 const char *display_desc = NULL; 2573 const char *display_desc = NULL;
2559 struct vc_data *vc; 2574 struct vc_data *vc;
2560 unsigned int currcons = 0; 2575 unsigned int currcons = 0, i;
2561 2576
2562 acquire_console_sem(); 2577 acquire_console_sem();
2563 2578
@@ -2569,6 +2584,22 @@ static int __init con_init(void)
2569 return 0; 2584 return 0;
2570 } 2585 }
2571 2586
2587 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2588 struct con_driver *con_driver = &registered_con_driver[i];
2589
2590 if (con_driver->con == NULL) {
2591 con_driver->con = conswitchp;
2592 con_driver->desc = display_desc;
2593 con_driver->flag = CON_DRIVER_FLAG_INIT;
2594 con_driver->first = 0;
2595 con_driver->last = MAX_NR_CONSOLES - 1;
2596 break;
2597 }
2598 }
2599
2600 for (i = 0; i < MAX_NR_CONSOLES; i++)
2601 con_driver_map[i] = conswitchp;
2602
2572 init_timer(&console_timer); 2603 init_timer(&console_timer);
2573 console_timer.function = blank_screen_t; 2604 console_timer.function = blank_screen_t;
2574 if (blankinterval) { 2605 if (blankinterval) {
@@ -2656,38 +2687,53 @@ int __init vty_init(void)
2656} 2687}
2657 2688
2658#ifndef VT_SINGLE_DRIVER 2689#ifndef VT_SINGLE_DRIVER
2690#include <linux/device.h>
2659 2691
2660/* 2692static struct class *vtconsole_class;
2661 * If we support more console drivers, this function is used
2662 * when a driver wants to take over some existing consoles
2663 * and become default driver for newly opened ones.
2664 */
2665 2693
2666int take_over_console(const struct consw *csw, int first, int last, int deflt) 2694static int bind_con_driver(const struct consw *csw, int first, int last,
2695 int deflt)
2667{ 2696{
2668 int i, j = -1; 2697 struct module *owner = csw->owner;
2669 const char *desc; 2698 const char *desc = NULL;
2670 struct module *owner; 2699 struct con_driver *con_driver;
2700 int i, j = -1, k = -1, retval = -ENODEV;
2671 2701
2672 owner = csw->owner;
2673 if (!try_module_get(owner)) 2702 if (!try_module_get(owner))
2674 return -ENODEV; 2703 return -ENODEV;
2675 2704
2676 acquire_console_sem(); 2705 acquire_console_sem();
2677 2706
2678 desc = csw->con_startup(); 2707 /* check if driver is registered */
2679 if (!desc) { 2708 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2680 release_console_sem(); 2709 con_driver = &registered_con_driver[i];
2681 module_put(owner); 2710
2682 return -ENODEV; 2711 if (con_driver->con == csw) {
2712 desc = con_driver->desc;
2713 retval = 0;
2714 break;
2715 }
2716 }
2717
2718 if (retval)
2719 goto err;
2720
2721 if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
2722 csw->con_startup();
2723 con_driver->flag |= CON_DRIVER_FLAG_INIT;
2683 } 2724 }
2725
2684 if (deflt) { 2726 if (deflt) {
2685 if (conswitchp) 2727 if (conswitchp)
2686 module_put(conswitchp->owner); 2728 module_put(conswitchp->owner);
2729
2687 __module_get(owner); 2730 __module_get(owner);
2688 conswitchp = csw; 2731 conswitchp = csw;
2689 } 2732 }
2690 2733
2734 first = max(first, con_driver->first);
2735 last = min(last, con_driver->last);
2736
2691 for (i = first; i <= last; i++) { 2737 for (i = first; i <= last; i++) {
2692 int old_was_color; 2738 int old_was_color;
2693 struct vc_data *vc = vc_cons[i].d; 2739 struct vc_data *vc = vc_cons[i].d;
@@ -2701,15 +2747,17 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt)
2701 continue; 2747 continue;
2702 2748
2703 j = i; 2749 j = i;
2704 if (CON_IS_VISIBLE(vc)) 2750
2751 if (CON_IS_VISIBLE(vc)) {
2752 k = i;
2705 save_screen(vc); 2753 save_screen(vc);
2754 }
2755
2706 old_was_color = vc->vc_can_do_color; 2756 old_was_color = vc->vc_can_do_color;
2707 vc->vc_sw->con_deinit(vc); 2757 vc->vc_sw->con_deinit(vc);
2708 vc->vc_origin = (unsigned long)vc->vc_screenbuf; 2758 vc->vc_origin = (unsigned long)vc->vc_screenbuf;
2709 vc->vc_visible_origin = vc->vc_origin;
2710 vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size;
2711 vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x;
2712 visual_init(vc, i, 0); 2759 visual_init(vc, i, 0);
2760 set_origin(vc);
2713 update_attr(vc); 2761 update_attr(vc);
2714 2762
2715 /* If the console changed between mono <-> color, then 2763 /* If the console changed between mono <-> color, then
@@ -2718,36 +2766,506 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt)
2718 */ 2766 */
2719 if (old_was_color != vc->vc_can_do_color) 2767 if (old_was_color != vc->vc_can_do_color)
2720 clear_buffer_attributes(vc); 2768 clear_buffer_attributes(vc);
2721
2722 if (CON_IS_VISIBLE(vc))
2723 update_screen(vc);
2724 } 2769 }
2770
2725 printk("Console: switching "); 2771 printk("Console: switching ");
2726 if (!deflt) 2772 if (!deflt)
2727 printk("consoles %d-%d ", first+1, last+1); 2773 printk("consoles %d-%d ", first+1, last+1);
2728 if (j >= 0) 2774 if (j >= 0) {
2775 struct vc_data *vc = vc_cons[j].d;
2776
2729 printk("to %s %s %dx%d\n", 2777 printk("to %s %s %dx%d\n",
2730 vc_cons[j].d->vc_can_do_color ? "colour" : "mono", 2778 vc->vc_can_do_color ? "colour" : "mono",
2731 desc, vc_cons[j].d->vc_cols, vc_cons[j].d->vc_rows); 2779 desc, vc->vc_cols, vc->vc_rows);
2732 else 2780
2781 if (k >= 0) {
2782 vc = vc_cons[k].d;
2783 update_screen(vc);
2784 }
2785 } else
2733 printk("to %s\n", desc); 2786 printk("to %s\n", desc);
2734 2787
2788 retval = 0;
2789err:
2735 release_console_sem(); 2790 release_console_sem();
2791 module_put(owner);
2792 return retval;
2793};
2794
2795#ifdef CONFIG_VT_HW_CONSOLE_BINDING
2796static int con_is_graphics(const struct consw *csw, int first, int last)
2797{
2798 int i, retval = 0;
2799
2800 for (i = first; i <= last; i++) {
2801 struct vc_data *vc = vc_cons[i].d;
2802
2803 if (vc && vc->vc_mode == KD_GRAPHICS) {
2804 retval = 1;
2805 break;
2806 }
2807 }
2808
2809 return retval;
2810}
2811
2812static int unbind_con_driver(const struct consw *csw, int first, int last,
2813 int deflt)
2814{
2815 struct module *owner = csw->owner;
2816 const struct consw *defcsw = NULL;
2817 struct con_driver *con_driver = NULL, *con_back = NULL;
2818 int i, retval = -ENODEV;
2819
2820 if (!try_module_get(owner))
2821 return -ENODEV;
2822
2823 acquire_console_sem();
2824
2825 /* check if driver is registered and if it is unbindable */
2826 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2827 con_driver = &registered_con_driver[i];
2828
2829 if (con_driver->con == csw &&
2830 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
2831 retval = 0;
2832 break;
2833 }
2834 }
2835
2836 if (retval) {
2837 release_console_sem();
2838 goto err;
2839 }
2840
2841 retval = -ENODEV;
2842
2843 /* check if backup driver exists */
2844 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2845 con_back = &registered_con_driver[i];
2846
2847 if (con_back->con &&
2848 !(con_back->flag & CON_DRIVER_FLAG_MODULE)) {
2849 defcsw = con_back->con;
2850 retval = 0;
2851 break;
2852 }
2853 }
2854
2855 if (retval) {
2856 release_console_sem();
2857 goto err;
2858 }
2859
2860 if (!con_is_bound(csw)) {
2861 release_console_sem();
2862 goto err;
2863 }
2864
2865 first = max(first, con_driver->first);
2866 last = min(last, con_driver->last);
2867
2868 for (i = first; i <= last; i++) {
2869 if (con_driver_map[i] == csw) {
2870 module_put(csw->owner);
2871 con_driver_map[i] = NULL;
2872 }
2873 }
2874
2875 if (!con_is_bound(defcsw)) {
2876 const struct consw *defconsw = conswitchp;
2877
2878 defcsw->con_startup();
2879 con_back->flag |= CON_DRIVER_FLAG_INIT;
2880 /*
2881 * vgacon may change the default driver to point
2882 * to dummycon, we restore it here...
2883 */
2884 conswitchp = defconsw;
2885 }
2886
2887 if (!con_is_bound(csw))
2888 con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
2736 2889
2890 release_console_sem();
2891 /* ignore return value, binding should not fail */
2892 bind_con_driver(defcsw, first, last, deflt);
2893err:
2737 module_put(owner); 2894 module_put(owner);
2895 return retval;
2896
2897}
2898
2899static int vt_bind(struct con_driver *con)
2900{
2901 const struct consw *defcsw = NULL, *csw = NULL;
2902 int i, more = 1, first = -1, last = -1, deflt = 0;
2903
2904 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) ||
2905 con_is_graphics(con->con, con->first, con->last))
2906 goto err;
2907
2908 csw = con->con;
2909
2910 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
2911 struct con_driver *con = &registered_con_driver[i];
2912
2913 if (con->con && !(con->flag & CON_DRIVER_FLAG_MODULE)) {
2914 defcsw = con->con;
2915 break;
2916 }
2917 }
2918
2919 if (!defcsw)
2920 goto err;
2921
2922 while (more) {
2923 more = 0;
2924
2925 for (i = con->first; i <= con->last; i++) {
2926 if (con_driver_map[i] == defcsw) {
2927 if (first == -1)
2928 first = i;
2929 last = i;
2930 more = 1;
2931 } else if (first != -1)
2932 break;
2933 }
2934
2935 if (first == 0 && last == MAX_NR_CONSOLES -1)
2936 deflt = 1;
2937
2938 if (first != -1)
2939 bind_con_driver(csw, first, last, deflt);
2940
2941 first = -1;
2942 last = -1;
2943 deflt = 0;
2944 }
2945
2946err:
2738 return 0; 2947 return 0;
2739} 2948}
2740 2949
2741void give_up_console(const struct consw *csw) 2950static int vt_unbind(struct con_driver *con)
2951{
2952 const struct consw *csw = NULL;
2953 int i, more = 1, first = -1, last = -1, deflt = 0;
2954
2955 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) ||
2956 con_is_graphics(con->con, con->first, con->last))
2957 goto err;
2958
2959 csw = con->con;
2960
2961 while (more) {
2962 more = 0;
2963
2964 for (i = con->first; i <= con->last; i++) {
2965 if (con_driver_map[i] == csw) {
2966 if (first == -1)
2967 first = i;
2968 last = i;
2969 more = 1;
2970 } else if (first != -1)
2971 break;
2972 }
2973
2974 if (first == 0 && last == MAX_NR_CONSOLES -1)
2975 deflt = 1;
2976
2977 if (first != -1)
2978 unbind_con_driver(csw, first, last, deflt);
2979
2980 first = -1;
2981 last = -1;
2982 deflt = 0;
2983 }
2984
2985err:
2986 return 0;
2987}
2988#else
2989static inline int vt_bind(struct con_driver *con)
2990{
2991 return 0;
2992}
2993static inline int vt_unbind(struct con_driver *con)
2994{
2995 return 0;
2996}
2997#endif /* CONFIG_VT_HW_CONSOLE_BINDING */
2998
2999static ssize_t store_bind(struct class_device *class_device,
3000 const char *buf, size_t count)
3001{
3002 struct con_driver *con = class_get_devdata(class_device);
3003 int bind = simple_strtoul(buf, NULL, 0);
3004
3005 if (bind)
3006 vt_bind(con);
3007 else
3008 vt_unbind(con);
3009
3010 return count;
3011}
3012
3013static ssize_t show_bind(struct class_device *class_device, char *buf)
3014{
3015 struct con_driver *con = class_get_devdata(class_device);
3016 int bind = con_is_bound(con->con);
3017
3018 return snprintf(buf, PAGE_SIZE, "%i\n", bind);
3019}
3020
3021static ssize_t show_name(struct class_device *class_device, char *buf)
3022{
3023 struct con_driver *con = class_get_devdata(class_device);
3024
3025 return snprintf(buf, PAGE_SIZE, "%s %s\n",
3026 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
3027 con->desc);
3028
3029}
3030
3031static struct class_device_attribute class_device_attrs[] = {
3032 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind),
3033 __ATTR(name, S_IRUGO, show_name, NULL),
3034};
3035
3036static int vtconsole_init_class_device(struct con_driver *con)
3037{
3038 int i;
3039
3040 class_set_devdata(con->class_dev, con);
3041 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
3042 class_device_create_file(con->class_dev,
3043 &class_device_attrs[i]);
3044
3045 return 0;
3046}
3047
3048static void vtconsole_deinit_class_device(struct con_driver *con)
2742{ 3049{
2743 int i; 3050 int i;
2744 3051
2745 for(i = 0; i < MAX_NR_CONSOLES; i++) 3052 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
3053 class_device_remove_file(con->class_dev,
3054 &class_device_attrs[i]);
3055}
3056
3057/**
3058 * con_is_bound - checks if driver is bound to the console
3059 * @csw: console driver
3060 *
3061 * RETURNS: zero if unbound, nonzero if bound
3062 *
3063 * Drivers can call this and if zero, they should release
3064 * all resources allocated on con_startup()
3065 */
3066int con_is_bound(const struct consw *csw)
3067{
3068 int i, bound = 0;
3069
3070 for (i = 0; i < MAX_NR_CONSOLES; i++) {
2746 if (con_driver_map[i] == csw) { 3071 if (con_driver_map[i] == csw) {
2747 module_put(csw->owner); 3072 bound = 1;
2748 con_driver_map[i] = NULL; 3073 break;
3074 }
3075 }
3076
3077 return bound;
3078}
3079EXPORT_SYMBOL(con_is_bound);
3080
3081/**
3082 * register_con_driver - register console driver to console layer
3083 * @csw: console driver
3084 * @first: the first console to take over, minimum value is 0
3085 * @last: the last console to take over, maximum value is MAX_NR_CONSOLES -1
3086 *
3087 * DESCRIPTION: This function registers a console driver which can later
3088 * bind to a range of consoles specified by @first and @last. It will
3089 * also initialize the console driver by calling con_startup().
3090 */
3091int register_con_driver(const struct consw *csw, int first, int last)
3092{
3093 struct module *owner = csw->owner;
3094 struct con_driver *con_driver;
3095 const char *desc;
3096 int i, retval = 0;
3097
3098 if (!try_module_get(owner))
3099 return -ENODEV;
3100
3101 acquire_console_sem();
3102
3103 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3104 con_driver = &registered_con_driver[i];
3105
3106 /* already registered */
3107 if (con_driver->con == csw)
3108 retval = -EINVAL;
3109 }
3110
3111 if (retval)
3112 goto err;
3113
3114 desc = csw->con_startup();
3115
3116 if (!desc)
3117 goto err;
3118
3119 retval = -EINVAL;
3120
3121 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3122 con_driver = &registered_con_driver[i];
3123
3124 if (con_driver->con == NULL) {
3125 con_driver->con = csw;
3126 con_driver->desc = desc;
3127 con_driver->node = i;
3128 con_driver->flag = CON_DRIVER_FLAG_MODULE |
3129 CON_DRIVER_FLAG_INIT;
3130 con_driver->first = first;
3131 con_driver->last = last;
3132 retval = 0;
3133 break;
3134 }
3135 }
3136
3137 if (retval)
3138 goto err;
3139
3140 con_driver->class_dev = class_device_create(vtconsole_class, NULL,
3141 MKDEV(0, con_driver->node),
3142 NULL, "vtcon%i",
3143 con_driver->node);
3144
3145 if (IS_ERR(con_driver->class_dev)) {
3146 printk(KERN_WARNING "Unable to create class_device for %s; "
3147 "errno = %ld\n", con_driver->desc,
3148 PTR_ERR(con_driver->class_dev));
3149 con_driver->class_dev = NULL;
3150 } else {
3151 vtconsole_init_class_device(con_driver);
3152 }
3153err:
3154 release_console_sem();
3155 module_put(owner);
3156 return retval;
3157}
3158EXPORT_SYMBOL(register_con_driver);
3159
3160/**
3161 * unregister_con_driver - unregister console driver from console layer
3162 * @csw: console driver
3163 *
3164 * DESCRIPTION: All drivers that registers to the console layer must
3165 * call this function upon exit, or if the console driver is in a state
3166 * where it won't be able to handle console services, such as the
3167 * framebuffer console without loaded framebuffer drivers.
3168 *
3169 * The driver must unbind first prior to unregistration.
3170 */
3171int unregister_con_driver(const struct consw *csw)
3172{
3173 int i, retval = -ENODEV;
3174
3175 acquire_console_sem();
3176
3177 /* cannot unregister a bound driver */
3178 if (con_is_bound(csw))
3179 goto err;
3180
3181 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3182 struct con_driver *con_driver = &registered_con_driver[i];
3183
3184 if (con_driver->con == csw &&
3185 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
3186 vtconsole_deinit_class_device(con_driver);
3187 class_device_destroy(vtconsole_class,
3188 MKDEV(0, con_driver->node));
3189 con_driver->con = NULL;
3190 con_driver->desc = NULL;
3191 con_driver->class_dev = NULL;
3192 con_driver->node = 0;
3193 con_driver->flag = 0;
3194 con_driver->first = 0;
3195 con_driver->last = 0;
3196 retval = 0;
3197 break;
3198 }
3199 }
3200err:
3201 release_console_sem();
3202 return retval;
3203}
3204EXPORT_SYMBOL(unregister_con_driver);
3205
3206/*
3207 * If we support more console drivers, this function is used
3208 * when a driver wants to take over some existing consoles
3209 * and become default driver for newly opened ones.
3210 *
3211 * take_over_console is basically a register followed by unbind
3212 */
3213int take_over_console(const struct consw *csw, int first, int last, int deflt)
3214{
3215 int err;
3216
3217 err = register_con_driver(csw, first, last);
3218
3219 if (!err)
3220 bind_con_driver(csw, first, last, deflt);
3221
3222 return err;
3223}
3224
3225/*
3226 * give_up_console is a wrapper to unregister_con_driver. It will only
3227 * work if driver is fully unbound.
3228 */
3229void give_up_console(const struct consw *csw)
3230{
3231 unregister_con_driver(csw);
3232}
3233
3234static int __init vtconsole_class_init(void)
3235{
3236 int i;
3237
3238 vtconsole_class = class_create(THIS_MODULE, "vtconsole");
3239 if (IS_ERR(vtconsole_class)) {
3240 printk(KERN_WARNING "Unable to create vt console class; "
3241 "errno = %ld\n", PTR_ERR(vtconsole_class));
3242 vtconsole_class = NULL;
3243 }
3244
3245 /* Add system drivers to sysfs */
3246 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3247 struct con_driver *con = &registered_con_driver[i];
3248
3249 if (con->con && !con->class_dev) {
3250 con->class_dev =
3251 class_device_create(vtconsole_class, NULL,
3252 MKDEV(0, con->node), NULL,
3253 "vtcon%i", con->node);
3254
3255 if (IS_ERR(con->class_dev)) {
3256 printk(KERN_WARNING "Unable to create "
3257 "class_device for %s; errno = %ld\n",
3258 con->desc, PTR_ERR(con->class_dev));
3259 con->class_dev = NULL;
3260 } else {
3261 vtconsole_init_class_device(con);
3262 }
2749 } 3263 }
3264 }
3265
3266 return 0;
2750} 3267}
3268postcore_initcall(vtconsole_class_init);
2751 3269
2752#endif 3270#endif
2753 3271
diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91_wdt.c
index ac83bc4b019a..00080655533d 100644
--- a/drivers/char/watchdog/at91_wdt.c
+++ b/drivers/char/watchdog/at91_wdt.c
@@ -17,14 +17,15 @@
17#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/platform_device.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/watchdog.h> 22#include <linux/watchdog.h>
22#include <asm/bitops.h> 23#include <asm/bitops.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
25 26
26#define WDT_DEFAULT_TIME 5 /* 5 seconds */ 27#define WDT_DEFAULT_TIME 5 /* seconds */
27#define WDT_MAX_TIME 256 /* 256 seconds */ 28#define WDT_MAX_TIME 256 /* seconds */
28 29
29static int wdt_time = WDT_DEFAULT_TIME; 30static int wdt_time = WDT_DEFAULT_TIME;
30static int nowayout = WATCHDOG_NOWAYOUT; 31static int nowayout = WATCHDOG_NOWAYOUT;
@@ -32,8 +33,10 @@ static int nowayout = WATCHDOG_NOWAYOUT;
32module_param(wdt_time, int, 0); 33module_param(wdt_time, int, 0);
33MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")"); 34MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
34 35
36#ifdef CONFIG_WATCHDOG_NOWAYOUT
35module_param(nowayout, int, 0); 37module_param(nowayout, int, 0);
36MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39#endif
37 40
38 41
39static unsigned long at91wdt_busy; 42static unsigned long at91wdt_busy;
@@ -138,7 +141,7 @@ static int at91_wdt_ioctl(struct inode *inode, struct file *file,
138 case WDIOC_SETTIMEOUT: 141 case WDIOC_SETTIMEOUT:
139 if (get_user(new_value, p)) 142 if (get_user(new_value, p))
140 return -EFAULT; 143 return -EFAULT;
141 144
142 if (at91_wdt_settimeout(new_value)) 145 if (at91_wdt_settimeout(new_value))
143 return -EINVAL; 146 return -EINVAL;
144 147
@@ -196,27 +199,84 @@ static struct miscdevice at91wdt_miscdev = {
196 .fops = &at91wdt_fops, 199 .fops = &at91wdt_fops,
197}; 200};
198 201
199static int __init at91_wdt_init(void) 202static int __init at91wdt_probe(struct platform_device *pdev)
200{ 203{
201 int res; 204 int res;
202 205
203 /* Check that the heartbeat value is within range; if not reset to the default */ 206 if (at91wdt_miscdev.dev)
204 if (at91_wdt_settimeout(wdt_time)) { 207 return -EBUSY;
205 at91_wdt_settimeout(WDT_DEFAULT_TIME); 208 at91wdt_miscdev.dev = &pdev->dev;
206 printk(KERN_INFO "at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
207 }
208 209
209 res = misc_register(&at91wdt_miscdev); 210 res = misc_register(&at91wdt_miscdev);
210 if (res) 211 if (res)
211 return res; 212 return res;
212 213
213 printk("AT91 Watchdog Timer enabled (%d seconds, nowayout=%d)\n", wdt_time, nowayout); 214 printk("AT91 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : "");
214 return 0; 215 return 0;
215} 216}
216 217
218static int __exit at91wdt_remove(struct platform_device *pdev)
219{
220 int res;
221
222 res = misc_deregister(&at91wdt_miscdev);
223 if (!res)
224 at91wdt_miscdev.dev = NULL;
225
226 return res;
227}
228
229static void at91wdt_shutdown(struct platform_device *pdev)
230{
231 at91_wdt_stop();
232}
233
234#ifdef CONFIG_PM
235
236static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
237{
238 at91_wdt_stop();
239 return 0;
240}
241
242static int at91wdt_resume(struct platform_device *pdev)
243{
244 if (at91wdt_busy)
245 at91_wdt_start();
246 return 0;
247}
248
249#else
250#define at91wdt_suspend NULL
251#define at91wdt_resume NULL
252#endif
253
254static struct platform_driver at91wdt_driver = {
255 .probe = at91wdt_probe,
256 .remove = __exit_p(at91wdt_remove),
257 .shutdown = at91wdt_shutdown,
258 .suspend = at91wdt_suspend,
259 .resume = at91wdt_resume,
260 .driver = {
261 .name = "at91_wdt",
262 .owner = THIS_MODULE,
263 },
264};
265
266static int __init at91_wdt_init(void)
267{
268 /* Check that the heartbeat value is within range; if not reset to the default */
269 if (at91_wdt_settimeout(wdt_time)) {
270 at91_wdt_settimeout(WDT_DEFAULT_TIME);
271 pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
272 }
273
274 return platform_driver_register(&at91wdt_driver);
275}
276
217static void __exit at91_wdt_exit(void) 277static void __exit at91_wdt_exit(void)
218{ 278{
219 misc_deregister(&at91wdt_miscdev); 279 platform_driver_unregister(&at91wdt_driver);
220} 280}
221 281
222module_init(at91_wdt_init); 282module_init(at91_wdt_init);
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index fa2ba9ebe42a..bfbdbbf3c2f2 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -205,6 +205,23 @@ static int tco_timer_set_heartbeat (int t)
205 return 0; 205 return 0;
206} 206}
207 207
208static int tco_timer_get_timeleft (int *time_left)
209{
210 unsigned char val;
211
212 spin_lock(&tco_lock);
213
214 /* read the TCO Timer */
215 val = inb (TCO1_RLD);
216 val &= 0x3f;
217
218 spin_unlock(&tco_lock);
219
220 *time_left = (int)((val * 6) / 10);
221
222 return 0;
223}
224
208/* 225/*
209 * /dev/watchdog handling 226 * /dev/watchdog handling
210 */ 227 */
@@ -272,6 +289,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
272{ 289{
273 int new_options, retval = -EINVAL; 290 int new_options, retval = -EINVAL;
274 int new_heartbeat; 291 int new_heartbeat;
292 int time_left;
275 void __user *argp = (void __user *)arg; 293 void __user *argp = (void __user *)arg;
276 int __user *p = argp; 294 int __user *p = argp;
277 static struct watchdog_info ident = { 295 static struct watchdog_info ident = {
@@ -320,7 +338,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
320 return -EFAULT; 338 return -EFAULT;
321 339
322 if (tco_timer_set_heartbeat(new_heartbeat)) 340 if (tco_timer_set_heartbeat(new_heartbeat))
323 return -EINVAL; 341 return -EINVAL;
324 342
325 tco_timer_keepalive (); 343 tco_timer_keepalive ();
326 /* Fall */ 344 /* Fall */
@@ -329,6 +347,14 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
329 case WDIOC_GETTIMEOUT: 347 case WDIOC_GETTIMEOUT:
330 return put_user(heartbeat, p); 348 return put_user(heartbeat, p);
331 349
350 case WDIOC_GETTIMELEFT:
351 {
352 if (tco_timer_get_timeleft(&time_left))
353 return -EINVAL;
354
355 return put_user(time_left, p);
356 }
357
332 default: 358 default:
333 return -ENOIOCTLCMD; 359 return -ENOIOCTLCMD;
334 } 360 }
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 2451edbefece..1f40ecefbf72 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23/* 23/*
24 * A bells and whistles driver is available from: 24 * A bells and whistles driver is available from:
25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ 25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/
26 * 26 *
27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ 27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/
@@ -390,6 +390,24 @@ static int pcipcwd_get_temperature(int *temperature)
390 return 0; 390 return 0;
391} 391}
392 392
393static int pcipcwd_get_timeleft(int *time_left)
394{
395 int msb;
396 int lsb;
397
398 /* Read the time that's left before rebooting */
399 /* Note: if the board is not yet armed then we will read 0xFFFF */
400 send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
401
402 *time_left = (msb << 8) + lsb;
403
404 if (debug >= VERBOSE)
405 printk(KERN_DEBUG PFX "Time left before next reboot: %d\n",
406 *time_left);
407
408 return 0;
409}
410
393/* 411/*
394 * /dev/watchdog handling 412 * /dev/watchdog handling
395 */ 413 */
@@ -512,6 +530,16 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file,
512 case WDIOC_GETTIMEOUT: 530 case WDIOC_GETTIMEOUT:
513 return put_user(heartbeat, p); 531 return put_user(heartbeat, p);
514 532
533 case WDIOC_GETTIMELEFT:
534 {
535 int time_left;
536
537 if (pcipcwd_get_timeleft(&time_left))
538 return -EFAULT;
539
540 return put_user(time_left, p);
541 }
542
515 default: 543 default:
516 return -ENOIOCTLCMD; 544 return -ENOIOCTLCMD;
517 } 545 }
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 3fdfda9324fa..0d072bed501d 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -317,6 +317,19 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp
317 return 0; 317 return 0;
318} 318}
319 319
320static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left)
321{
322 unsigned char msb, lsb;
323
324 /* Read the time that's left before rebooting */
325 /* Note: if the board is not yet armed then we will read 0xFFFF */
326 usb_pcwd_send_command(usb_pcwd, CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
327
328 *time_left = (msb << 8) + lsb;
329
330 return 0;
331}
332
320/* 333/*
321 * /dev/watchdog handling 334 * /dev/watchdog handling
322 */ 335 */
@@ -422,6 +435,16 @@ static int usb_pcwd_ioctl(struct inode *inode, struct file *file,
422 case WDIOC_GETTIMEOUT: 435 case WDIOC_GETTIMEOUT:
423 return put_user(heartbeat, p); 436 return put_user(heartbeat, p);
424 437
438 case WDIOC_GETTIMELEFT:
439 {
440 int time_left;
441
442 if (usb_pcwd_get_timeleft(usb_pcwd_device, &time_left))
443 return -EFAULT;
444
445 return put_user(time_left, p);
446 }
447
425 default: 448 default:
426 return -ENOIOCTLCMD; 449 return -ENOIOCTLCMD;
427 } 450 }