aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2006-06-26 01:31:38 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2006-06-26 01:31:38 -0400
commit4854c7b27f0975a2b629f35ea3996d2968eb7c4f (patch)
tree4102bdb70289764a2058aff0f907b13d7cf0e0d1 /drivers/char
parent3cbd5b32cb625f5c0f1b1476d154fac873dd49ce (diff)
parentfcc18e83e1f6fd9fa6b333735bf0fcd530655511 (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig1
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/agp/Kconfig5
-rw-r--r--drivers/char/agp/alpha-agp.c15
-rw-r--r--drivers/char/agp/amd64-agp.c3
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/agp/hp-agp.c2
-rw-r--r--drivers/char/agp/intel-agp.c2
-rw-r--r--drivers/char/agp/uninorth-agp.c4
-rw-r--r--drivers/char/agp/via-agp.c7
-rw-r--r--drivers/char/applicom.c40
-rw-r--r--drivers/char/cyclades.c7
-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/esp.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/hvsi.c2
-rw-r--r--drivers/char/ip2/ip2main.c12
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c38
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c25
-rw-r--r--drivers/char/isicom.c4
-rw-r--r--drivers/char/keyboard.c1
-rw-r--r--drivers/char/mmtimer.c1
-rw-r--r--drivers/char/mxser.c836
-rw-r--r--drivers/char/n_r3964.c3
-rw-r--r--drivers/char/n_tty.c4
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/synclink_cs.c58
-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.c42
-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/sonypi.c10
-rw-r--r--drivers/char/specialix.c4
-rw-r--r--drivers/char/synclink_gt.c119
-rw-r--r--drivers/char/synclinkmp.c4
-rw-r--r--drivers/char/tpm/tpm_bios.c89
-rw-r--r--drivers/char/tty_io.c11
-rw-r--r--drivers/char/viotape.c2
-rw-r--r--drivers/char/vt.c8
63 files changed, 1175 insertions, 968 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 78d928f9d9f1..63f28d169b36 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -865,6 +865,7 @@ config SONYPI
865config TANBAC_TB0219 865config TANBAC_TB0219
866 tristate "TANBAC TB0219 base board support" 866 tristate "TANBAC TB0219 base board support"
867 depends TANBAC_TB022X 867 depends TANBAC_TB022X
868 select GPIO_VR41XX
868 869
869menu "Ftape, the floppy tape device driver" 870menu "Ftape, the floppy tape device driver"
870 871
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index f5b01c6d498e..fb919bfb2824 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -41,9 +41,9 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
41obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o 41obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
42obj-$(CONFIG_SX) += sx.o generic_serial.o 42obj-$(CONFIG_SX) += sx.o generic_serial.o
43obj-$(CONFIG_RIO) += rio/ generic_serial.o 43obj-$(CONFIG_RIO) += rio/ generic_serial.o
44obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
45obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o 44obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
46obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o 45obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
46obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
47obj-$(CONFIG_RAW_DRIVER) += raw.o 47obj-$(CONFIG_RAW_DRIVER) += raw.o
48obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 48obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
49obj-$(CONFIG_MMTIMER) += mmtimer.o 49obj-$(CONFIG_MMTIMER) += mmtimer.o
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index 0b9cf9c59a21..46685a540772 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -1,7 +1,6 @@
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 default y if GART_IOMMU
5 ---help--- 4 ---help---
6 AGP (Accelerated Graphics Port) is a bus system mainly used to 5 AGP (Accelerated Graphics Port) is a bus system mainly used to
7 connect graphics cards to the rest of the system. 6 connect graphics cards to the rest of the system.
@@ -86,7 +85,7 @@ config AGP_NVIDIA
86 85
87config AGP_SIS 86config AGP_SIS
88 tristate "SiS chipset support" 87 tristate "SiS chipset support"
89 depends on AGP && X86_32 88 depends on AGP
90 help 89 help
91 This option gives you AGP support for the GLX component of 90 This option gives you AGP support for the GLX component of
92 X on Silicon Integrated Systems [SiS] chipsets. 91 X on Silicon Integrated Systems [SiS] chipsets.
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index 2b5838e64751..b4e00a343da9 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -46,12 +46,6 @@ struct vm_operations_struct alpha_core_agp_vm_ops = {
46}; 46};
47 47
48 48
49static int alpha_core_agp_nop(void)
50{
51 /* just return success */
52 return 0;
53}
54
55static int alpha_core_agp_fetch_size(void) 49static int alpha_core_agp_fetch_size(void)
56{ 50{
57 return alpha_core_agp_sizes[0].size; 51 return alpha_core_agp_sizes[0].size;
@@ -120,6 +114,11 @@ static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start,
120 return status; 114 return status;
121} 115}
122 116
117static int alpha_core_agp_create_free_gatt_table(struct agp_bridge_data *a)
118{
119 return 0;
120}
121
123struct agp_bridge_driver alpha_core_agp_driver = { 122struct agp_bridge_driver alpha_core_agp_driver = {
124 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
125 .aperture_sizes = alpha_core_agp_sizes, 124 .aperture_sizes = alpha_core_agp_sizes,
@@ -135,8 +134,8 @@ struct agp_bridge_driver alpha_core_agp_driver = {
135 .tlb_flush = alpha_core_agp_tlbflush, 134 .tlb_flush = alpha_core_agp_tlbflush,
136 .mask_memory = agp_generic_mask_memory, 135 .mask_memory = agp_generic_mask_memory,
137 .cache_flush = global_cache_flush, 136 .cache_flush = global_cache_flush,
138 .create_gatt_table = alpha_core_agp_nop, 137 .create_gatt_table = alpha_core_agp_create_free_gatt_table,
139 .free_gatt_table = alpha_core_agp_nop, 138 .free_gatt_table = alpha_core_agp_create_free_gatt_table,
140 .insert_memory = alpha_core_agp_insert_memory, 139 .insert_memory = alpha_core_agp_insert_memory,
141 .remove_memory = alpha_core_agp_remove_memory, 140 .remove_memory = alpha_core_agp_remove_memory,
142 .alloc_by_type = agp_generic_alloc_by_type, 141 .alloc_by_type = agp_generic_alloc_by_type,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 36517d4d1ad9..ac3c33a2e37d 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -617,6 +617,9 @@ static int agp_amd64_resume(struct pci_dev *pdev)
617 pci_set_power_state(pdev, PCI_D0); 617 pci_set_power_state(pdev, PCI_D0);
618 pci_restore_state(pdev); 618 pci_restore_state(pdev);
619 619
620 if (pdev->vendor == PCI_VENDOR_ID_NVIDIA)
621 nforce3_agp_init(pdev);
622
620 return amd_8151_configure(); 623 return amd_8151_configure();
621} 624}
622 625
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 4e1891e2c035..a92ab53a1370 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -809,12 +809,10 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
809 case U32_APER_SIZE: 809 case U32_APER_SIZE:
810 bridge->current_size = A_IDX32(bridge); 810 bridge->current_size = A_IDX32(bridge);
811 break; 811 break;
812 /* This case will never really happen. */ 812 /* These cases will never really happen. */
813 case FIXED_APER_SIZE: 813 case FIXED_APER_SIZE:
814 case LVL2_APER_SIZE: 814 case LVL2_APER_SIZE:
815 default: 815 default:
816 bridge->current_size =
817 bridge->current_size;
818 break; 816 break;
819 } 817 }
820 temp = bridge->current_size; 818 temp = bridge->current_size;
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/intel-agp.c b/drivers/char/agp/intel-agp.c
index bddcae54b16d..61ac3809f997 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -736,7 +736,7 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
736static int intel_i915_fetch_size(void) 736static int intel_i915_fetch_size(void)
737{ 737{
738 struct aper_size_info_fixed *values; 738 struct aper_size_info_fixed *values;
739 u32 temp, offset = 0; 739 u32 temp, offset;
740 740
741#define I915_256MB_ADDRESS_MASK (1<<27) 741#define I915_256MB_ADDRESS_MASK (1<<27)
742 742
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 9846defbddb4..1de1b12043bf 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -329,7 +329,7 @@ static int agp_uninorth_suspend(struct pci_dev *pdev)
329 /* turn off AGP on the bridge */ 329 /* turn off AGP on the bridge */
330 agp = pci_find_capability(pdev, PCI_CAP_ID_AGP); 330 agp = pci_find_capability(pdev, PCI_CAP_ID_AGP);
331 pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd); 331 pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd);
332 bridge->dev_private_data = (void *)cmd; 332 bridge->dev_private_data = (void *)(long)cmd;
333 if (cmd & PCI_AGP_COMMAND_AGP) { 333 if (cmd & PCI_AGP_COMMAND_AGP) {
334 printk("uninorth-agp: disabling AGP on bridge %s\n", 334 printk("uninorth-agp: disabling AGP on bridge %s\n",
335 pci_name(pdev)); 335 pci_name(pdev));
@@ -351,7 +351,7 @@ static int agp_uninorth_resume(struct pci_dev *pdev)
351 if (bridge == NULL) 351 if (bridge == NULL)
352 return -ENODEV; 352 return -ENODEV;
353 353
354 command = (u32)bridge->dev_private_data; 354 command = (long)bridge->dev_private_data;
355 bridge->dev_private_data = NULL; 355 bridge->dev_private_data = NULL;
356 if (!(command & PCI_AGP_COMMAND_AGP)) 356 if (!(command & PCI_AGP_COMMAND_AGP))
357 return 0; 357 return 0;
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 97b0a890ba7f..b8ec25d17478 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -345,6 +345,12 @@ static struct agp_device_ids via_agp_device_ids[] __devinitdata =
345 .chipset_name = "PT880", 345 .chipset_name = "PT880",
346 }, 346 },
347 347
348 /* PT880 Ultra */
349 {
350 .device_id = PCI_DEVICE_ID_VIA_PT880ULTRA,
351 .chipset_name = "PT880 Ultra",
352 },
353
348 /* PT890 */ 354 /* PT890 */
349 { 355 {
350 .device_id = PCI_DEVICE_ID_VIA_8783_0, 356 .device_id = PCI_DEVICE_ID_VIA_8783_0,
@@ -511,6 +517,7 @@ static struct pci_device_id agp_via_pci_table[] = {
511 ID(PCI_DEVICE_ID_VIA_8763_0), 517 ID(PCI_DEVICE_ID_VIA_8763_0),
512 ID(PCI_DEVICE_ID_VIA_8378_0), 518 ID(PCI_DEVICE_ID_VIA_8378_0),
513 ID(PCI_DEVICE_ID_VIA_PT880), 519 ID(PCI_DEVICE_ID_VIA_PT880),
520 ID(PCI_DEVICE_ID_VIA_PT880ULTRA),
514 ID(PCI_DEVICE_ID_VIA_8783_0), 521 ID(PCI_DEVICE_ID_VIA_8783_0),
515 ID(PCI_DEVICE_ID_VIA_PX8X0_0), 522 ID(PCI_DEVICE_ID_VIA_PX8X0_0),
516 ID(PCI_DEVICE_ID_VIA_3269_0), 523 ID(PCI_DEVICE_ID_VIA_3269_0),
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a370e7a0bad5..9275d5e52e6d 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;
@@ -355,10 +349,9 @@ out:
355 return ret; 349 return ret;
356} 350}
357 351
352module_init(applicom_init);
353module_exit(applicom_exit);
358 354
359#ifndef MODULE
360__initcall(applicom_init);
361#endif
362 355
363static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) 356static ssize_t ac_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
364{ 357{
@@ -851,28 +844,3 @@ static int ac_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un
851 return 0; 844 return 0;
852} 845}
853 846
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/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/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/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/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/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_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index b36eef0e9d19..02a7dd7a8a55 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1184,20 +1184,20 @@ static void port_outl(struct si_sm_io *io, unsigned int offset,
1184static void port_cleanup(struct smi_info *info) 1184static void port_cleanup(struct smi_info *info)
1185{ 1185{
1186 unsigned int addr = info->io.addr_data; 1186 unsigned int addr = info->io.addr_data;
1187 int mapsize; 1187 int idx;
1188 1188
1189 if (addr) { 1189 if (addr) {
1190 mapsize = ((info->io_size * info->io.regspacing) 1190 for (idx = 0; idx < info->io_size; idx++) {
1191 - (info->io.regspacing - info->io.regsize)); 1191 release_region(addr + idx * info->io.regspacing,
1192 1192 info->io.regsize);
1193 release_region (addr, mapsize); 1193 }
1194 } 1194 }
1195} 1195}
1196 1196
1197static int port_setup(struct smi_info *info) 1197static int port_setup(struct smi_info *info)
1198{ 1198{
1199 unsigned int addr = info->io.addr_data; 1199 unsigned int addr = info->io.addr_data;
1200 int mapsize; 1200 int idx;
1201 1201
1202 if (!addr) 1202 if (!addr)
1203 return -ENODEV; 1203 return -ENODEV;
@@ -1225,16 +1225,22 @@ static int port_setup(struct smi_info *info)
1225 return -EINVAL; 1225 return -EINVAL;
1226 } 1226 }
1227 1227
1228 /* Calculate the total amount of memory to claim. This is an 1228 /* Some BIOSes reserve disjoint I/O regions in their ACPI
1229 * unusual looking calculation, but it avoids claiming any 1229 * tables. This causes problems when trying to register the
1230 * more memory than it has to. It will claim everything 1230 * entire I/O region. Therefore we must register each I/O
1231 * between the first address to the end of the last full 1231 * port separately.
1232 * register. */ 1232 */
1233 mapsize = ((info->io_size * info->io.regspacing) 1233 for (idx = 0; idx < info->io_size; idx++) {
1234 - (info->io.regspacing - info->io.regsize)); 1234 if (request_region(addr + idx * info->io.regspacing,
1235 1235 info->io.regsize, DEVICE_NAME) == NULL) {
1236 if (request_region(addr, mapsize, DEVICE_NAME) == NULL) 1236 /* Undo allocations */
1237 return -EIO; 1237 while (idx--) {
1238 release_region(addr + idx * info->io.regspacing,
1239 info->io.regsize);
1240 }
1241 return -EIO;
1242 }
1243 }
1238 return 0; 1244 return 0;
1239} 1245}
1240 1246
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 2d11ddd99e55..8f8867170973 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
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/keyboard.c b/drivers/char/keyboard.c
index 24f2656000e8..1b63acfc6c78 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);
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/mxser.c b/drivers/char/mxser.c
index 0fb2fb9fb024..645d9d713aec 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
@@ -955,11 +998,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
955 info->pgrp = process_group(current); 998 info->pgrp = process_group(current);
956 clear_bit(TTY_DONT_FLIP, &tty->flags); 999 clear_bit(TTY_DONT_FLIP, &tty->flags);
957 1000
958 //status = mxser_get_msr(info->base, 0, info->port); 1001 /*
959 //mxser_check_modem_status(info, status); 1002 status = mxser_get_msr(info->base, 0, info->port);
1003 mxser_check_modem_status(info, status);
1004 */
960 1005
961/* unmark here for very high baud rate (ex. 921600 bps) used 1006/* unmark here for very high baud rate (ex. 921600 bps) used */
962*/
963 tty->low_latency = 1; 1007 tty->low_latency = 1;
964 return 0; 1008 return 0;
965} 1009}
@@ -972,7 +1016,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
972 */ 1016 */
973static void mxser_close(struct tty_struct *tty, struct file *filp) 1017static void mxser_close(struct tty_struct *tty, struct file *filp)
974{ 1018{
975 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1019 struct mxser_struct *info = tty->driver_data;
976 1020
977 unsigned long timeout; 1021 unsigned long timeout;
978 unsigned long flags; 1022 unsigned long flags;
@@ -997,11 +1041,13 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
997 * one, we've got real problems, since it means the 1041 * one, we've got real problems, since it means the
998 * serial port won't be shutdown. 1042 * serial port won't be shutdown.
999 */ 1043 */
1000 printk(KERN_ERR "mxser_close: bad serial port count; tty->count is 1, " "info->count is %d\n", info->count); 1044 printk(KERN_ERR "mxser_close: bad serial port count; "
1045 "tty->count is 1, info->count is %d\n", info->count);
1001 info->count = 1; 1046 info->count = 1;
1002 } 1047 }
1003 if (--info->count < 0) { 1048 if (--info->count < 0) {
1004 printk(KERN_ERR "mxser_close: bad serial port count for ttys%d: %d\n", info->port, info->count); 1049 printk(KERN_ERR "mxser_close: bad serial port count for "
1050 "ttys%d: %d\n", info->port, info->count);
1005 info->count = 0; 1051 info->count = 0;
1006 } 1052 }
1007 if (info->count) { 1053 if (info->count) {
@@ -1056,7 +1102,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1056 1102
1057 ld = tty_ldisc_ref(tty); 1103 ld = tty_ldisc_ref(tty);
1058 if (ld) { 1104 if (ld) {
1059 if(ld->flush_buffer) 1105 if (ld->flush_buffer)
1060 ld->flush_buffer(tty); 1106 ld->flush_buffer(tty);
1061 tty_ldisc_deref(ld); 1107 tty_ldisc_deref(ld);
1062 } 1108 }
@@ -1078,31 +1124,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) 1124static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
1079{ 1125{
1080 int c, total = 0; 1126 int c, total = 0;
1081 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1127 struct mxser_struct *info = tty->driver_data;
1082 unsigned long flags; 1128 unsigned long flags;
1083 1129
1084 if (!tty || !info->xmit_buf) 1130 if (!info->xmit_buf)
1085 return (0); 1131 return 0;
1086 1132
1087 while (1) { 1133 while (1) {
1088 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, SERIAL_XMIT_SIZE - info->xmit_head)); 1134 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1135 SERIAL_XMIT_SIZE - info->xmit_head));
1089 if (c <= 0) 1136 if (c <= 0)
1090 break; 1137 break;
1091 1138
1092 memcpy(info->xmit_buf + info->xmit_head, buf, c); 1139 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1093 spin_lock_irqsave(&info->slock, flags); 1140 spin_lock_irqsave(&info->slock, flags);
1094 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE - 1); 1141 info->xmit_head = (info->xmit_head + c) &
1142 (SERIAL_XMIT_SIZE - 1);
1095 info->xmit_cnt += c; 1143 info->xmit_cnt += c;
1096 spin_unlock_irqrestore(&info->slock, flags); 1144 spin_unlock_irqrestore(&info->slock, flags);
1097 1145
1098 buf += c; 1146 buf += c;
1099 count -= c; 1147 count -= c;
1100 total += c; 1148 total += c;
1101
1102 } 1149 }
1103 1150
1104 if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) { 1151 if (info->xmit_cnt && !tty->stopped && !(info->IER & UART_IER_THRI)) {
1105 if (!tty->hw_stopped || (info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { 1152 if (!tty->hw_stopped ||
1153 (info->type == PORT_16550A) ||
1154 (info->IsMoxaMustChipFlag)) {
1106 spin_lock_irqsave(&info->slock, flags); 1155 spin_lock_irqsave(&info->slock, flags);
1107 info->IER |= UART_IER_THRI; 1156 info->IER |= UART_IER_THRI;
1108 outb(info->IER, info->base + UART_IER); 1157 outb(info->IER, info->base + UART_IER);
@@ -1114,10 +1163,10 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
1114 1163
1115static void mxser_put_char(struct tty_struct *tty, unsigned char ch) 1164static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1116{ 1165{
1117 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1166 struct mxser_struct *info = tty->driver_data;
1118 unsigned long flags; 1167 unsigned long flags;
1119 1168
1120 if (!tty || !info->xmit_buf) 1169 if (!info->xmit_buf)
1121 return; 1170 return;
1122 1171
1123 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) 1172 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
@@ -1129,7 +1178,9 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1129 info->xmit_cnt++; 1178 info->xmit_cnt++;
1130 spin_unlock_irqrestore(&info->slock, flags); 1179 spin_unlock_irqrestore(&info->slock, flags);
1131 if (!tty->stopped && !(info->IER & UART_IER_THRI)) { 1180 if (!tty->stopped && !(info->IER & UART_IER_THRI)) {
1132 if (!tty->hw_stopped || (info->type == PORT_16550A) || info->IsMoxaMustChipFlag) { 1181 if (!tty->hw_stopped ||
1182 (info->type == PORT_16550A) ||
1183 info->IsMoxaMustChipFlag) {
1133 spin_lock_irqsave(&info->slock, flags); 1184 spin_lock_irqsave(&info->slock, flags);
1134 info->IER |= UART_IER_THRI; 1185 info->IER |= UART_IER_THRI;
1135 outb(info->IER, info->base + UART_IER); 1186 outb(info->IER, info->base + UART_IER);
@@ -1141,10 +1192,16 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1141 1192
1142static void mxser_flush_chars(struct tty_struct *tty) 1193static void mxser_flush_chars(struct tty_struct *tty)
1143{ 1194{
1144 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1195 struct mxser_struct *info = tty->driver_data;
1145 unsigned long flags; 1196 unsigned long flags;
1146 1197
1147 if (info->xmit_cnt <= 0 || tty->stopped || !info->xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) 1198 if (info->xmit_cnt <= 0 ||
1199 tty->stopped ||
1200 !info->xmit_buf ||
1201 (tty->hw_stopped &&
1202 (info->type != PORT_16550A) &&
1203 (!info->IsMoxaMustChipFlag)
1204 ))
1148 return; 1205 return;
1149 1206
1150 spin_lock_irqsave(&info->slock, flags); 1207 spin_lock_irqsave(&info->slock, flags);
@@ -1157,24 +1214,24 @@ static void mxser_flush_chars(struct tty_struct *tty)
1157 1214
1158static int mxser_write_room(struct tty_struct *tty) 1215static int mxser_write_room(struct tty_struct *tty)
1159{ 1216{
1160 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1217 struct mxser_struct *info = tty->driver_data;
1161 int ret; 1218 int ret;
1162 1219
1163 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; 1220 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
1164 if (ret < 0) 1221 if (ret < 0)
1165 ret = 0; 1222 ret = 0;
1166 return (ret); 1223 return ret;
1167} 1224}
1168 1225
1169static int mxser_chars_in_buffer(struct tty_struct *tty) 1226static int mxser_chars_in_buffer(struct tty_struct *tty)
1170{ 1227{
1171 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1228 struct mxser_struct *info = tty->driver_data;
1172 return info->xmit_cnt; 1229 return info->xmit_cnt;
1173} 1230}
1174 1231
1175static void mxser_flush_buffer(struct tty_struct *tty) 1232static void mxser_flush_buffer(struct tty_struct *tty)
1176{ 1233{
1177 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1234 struct mxser_struct *info = tty->driver_data;
1178 char fcr; 1235 char fcr;
1179 unsigned long flags; 1236 unsigned long flags;
1180 1237
@@ -1184,7 +1241,8 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1184 1241
1185 /* below added by shinhay */ 1242 /* below added by shinhay */
1186 fcr = inb(info->base + UART_FCR); 1243 fcr = inb(info->base + UART_FCR);
1187 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 1244 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1245 info->base + UART_FCR);
1188 outb(fcr, info->base + UART_FCR); 1246 outb(fcr, info->base + UART_FCR);
1189 1247
1190 spin_unlock_irqrestore(&info->slock, flags); 1248 spin_unlock_irqrestore(&info->slock, flags);
@@ -1197,7 +1255,7 @@ static void mxser_flush_buffer(struct tty_struct *tty)
1197 1255
1198static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1256static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1199{ 1257{
1200 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1258 struct mxser_struct *info = tty->driver_data;
1201 int retval; 1259 int retval;
1202 struct async_icount cprev, cnow; /* kernel counter temps */ 1260 struct async_icount cprev, cnow; /* kernel counter temps */
1203 struct serial_icounter_struct __user *p_cuser; 1261 struct serial_icounter_struct __user *p_cuser;
@@ -1206,9 +1264,9 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1206 void __user *argp = (void __user *)arg; 1264 void __user *argp = (void __user *)arg;
1207 1265
1208 if (tty->index == MXSER_PORTS) 1266 if (tty->index == MXSER_PORTS)
1209 return (mxser_ioctl_special(cmd, argp)); 1267 return mxser_ioctl_special(cmd, argp);
1210 1268
1211 // following add by Victor Yu. 01-05-2004 1269 /* following add by Victor Yu. 01-05-2004 */
1212 if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) { 1270 if (cmd == MOXA_SET_OP_MODE || cmd == MOXA_GET_OP_MODE) {
1213 int opmode, p; 1271 int opmode, p;
1214 static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f }; 1272 static unsigned char ModeMask[] = { 0xfc, 0xf3, 0xcf, 0x3f };
@@ -1219,7 +1277,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1219 if (cmd == MOXA_SET_OP_MODE) { 1277 if (cmd == MOXA_SET_OP_MODE) {
1220 if (get_user(opmode, (int __user *) argp)) 1278 if (get_user(opmode, (int __user *) argp))
1221 return -EFAULT; 1279 return -EFAULT;
1222 if (opmode != RS232_MODE && opmode != RS485_2WIRE_MODE && opmode != RS422_MODE && opmode != RS485_4WIRE_MODE) 1280 if (opmode != RS232_MODE &&
1281 opmode != RS485_2WIRE_MODE &&
1282 opmode != RS422_MODE &&
1283 opmode != RS485_4WIRE_MODE)
1223 return -EFAULT; 1284 return -EFAULT;
1224 mask = ModeMask[p]; 1285 mask = ModeMask[p];
1225 shiftbit = p * 2; 1286 shiftbit = p * 2;
@@ -1236,36 +1297,36 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1236 } 1297 }
1237 return 0; 1298 return 0;
1238 } 1299 }
1239 // above add by Victor Yu. 01-05-2004 1300 /* above add by Victor Yu. 01-05-2004 */
1240 1301
1241 if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1302 if ((cmd != TIOCGSERIAL) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
1242 if (tty->flags & (1 << TTY_IO_ERROR)) 1303 if (tty->flags & (1 << TTY_IO_ERROR))
1243 return (-EIO); 1304 return -EIO;
1244 } 1305 }
1245 switch (cmd) { 1306 switch (cmd) {
1246 case TCSBRK: /* SVID version: non-zero arg --> no break */ 1307 case TCSBRK: /* SVID version: non-zero arg --> no break */
1247 retval = tty_check_change(tty); 1308 retval = tty_check_change(tty);
1248 if (retval) 1309 if (retval)
1249 return (retval); 1310 return retval;
1250 tty_wait_until_sent(tty, 0); 1311 tty_wait_until_sent(tty, 0);
1251 if (!arg) 1312 if (!arg)
1252 mxser_send_break(info, HZ / 4); /* 1/4 second */ 1313 mxser_send_break(info, HZ / 4); /* 1/4 second */
1253 return (0); 1314 return 0;
1254 case TCSBRKP: /* support for POSIX tcsendbreak() */ 1315 case TCSBRKP: /* support for POSIX tcsendbreak() */
1255 retval = tty_check_change(tty); 1316 retval = tty_check_change(tty);
1256 if (retval) 1317 if (retval)
1257 return (retval); 1318 return retval;
1258 tty_wait_until_sent(tty, 0); 1319 tty_wait_until_sent(tty, 0);
1259 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4); 1320 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
1260 return (0); 1321 return 0;
1261 case TIOCGSOFTCAR: 1322 case TIOCGSOFTCAR:
1262 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp); 1323 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp);
1263 case TIOCSSOFTCAR: 1324 case TIOCSSOFTCAR:
1264 if (get_user(templ, (unsigned long __user *) argp)) 1325 if (get_user(templ, (unsigned long __user *) argp))
1265 return -EFAULT; 1326 return -EFAULT;
1266 arg = templ; 1327 arg = templ;
1267 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); 1328 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
1268 return (0); 1329 return 0;
1269 case TIOCGSERIAL: 1330 case TIOCGSERIAL:
1270 return mxser_get_serial_info(info, argp); 1331 return mxser_get_serial_info(info, argp);
1271 case TIOCSSERIAL: 1332 case TIOCSSERIAL:
@@ -1278,7 +1339,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) 1339 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1279 * Caller should use TIOCGICOUNT to see which one it was 1340 * Caller should use TIOCGICOUNT to see which one it was
1280 */ 1341 */
1281 case TIOCMIWAIT:{ 1342 case TIOCMIWAIT: {
1282 DECLARE_WAITQUEUE(wait, current); 1343 DECLARE_WAITQUEUE(wait, current);
1283 int ret; 1344 int ret;
1284 spin_lock_irqsave(&info->slock, flags); 1345 spin_lock_irqsave(&info->slock, flags);
@@ -1292,7 +1353,14 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1292 spin_unlock_irqrestore(&info->slock, flags); 1353 spin_unlock_irqrestore(&info->slock, flags);
1293 1354
1294 set_current_state(TASK_INTERRUPTIBLE); 1355 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))) { 1356 if (((arg & TIOCM_RNG) &&
1357 (cnow.rng != cprev.rng)) ||
1358 ((arg & TIOCM_DSR) &&
1359 (cnow.dsr != cprev.dsr)) ||
1360 ((arg & TIOCM_CD) &&
1361 (cnow.dcd != cprev.dcd)) ||
1362 ((arg & TIOCM_CTS) &&
1363 (cnow.cts != cprev.cts))) {
1296 ret = 0; 1364 ret = 0;
1297 break; 1365 break;
1298 } 1366 }
@@ -1338,21 +1406,18 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1338 put_user(cnow.dsr, &p_cuser->dsr); 1406 put_user(cnow.dsr, &p_cuser->dsr);
1339 put_user(cnow.rng, &p_cuser->rng); 1407 put_user(cnow.rng, &p_cuser->rng);
1340 put_user(cnow.dcd, &p_cuser->dcd); 1408 put_user(cnow.dcd, &p_cuser->dcd);
1341
1342/* */
1343 return 0; 1409 return 0;
1344 case MOXA_HighSpeedOn: 1410 case MOXA_HighSpeedOn:
1345 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *) argp); 1411 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
1346 1412 case MOXA_SDS_RSTICOUNTER: {
1347 case MOXA_SDS_RSTICOUNTER:{
1348 info->mon_data.rxcnt = 0; 1413 info->mon_data.rxcnt = 0;
1349 info->mon_data.txcnt = 0; 1414 info->mon_data.txcnt = 0;
1350 return 0; 1415 return 0;
1351 } 1416 }
1352// (above) added by James. 1417/* (above) added by James. */
1353 case MOXA_ASPP_SETBAUD:{ 1418 case MOXA_ASPP_SETBAUD:{
1354 long baud; 1419 long baud;
1355 if (get_user(baud, (long __user *) argp)) 1420 if (get_user(baud, (long __user *)argp))
1356 return -EFAULT; 1421 return -EFAULT;
1357 mxser_set_baud(info, baud); 1422 mxser_set_baud(info, baud);
1358 return 0; 1423 return 0;
@@ -1377,9 +1442,10 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1377 1442
1378 return 0; 1443 return 0;
1379 } 1444 }
1380 case MOXA_ASPP_MON:{ 1445 case MOXA_ASPP_MON: {
1381 int mcr, status; 1446 int mcr, status;
1382// info->mon_data.ser_param = tty->termios->c_cflag; 1447
1448 /* info->mon_data.ser_param = tty->termios->c_cflag; */
1383 1449
1384 status = mxser_get_msr(info->base, 1, info->port, info); 1450 status = mxser_get_msr(info->base, 1, info->port, info);
1385 mxser_check_modem_status(info, status); 1451 mxser_check_modem_status(info, status);
@@ -1400,25 +1466,25 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
1400 else 1466 else
1401 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; 1467 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
1402 1468
1403 1469 if (copy_to_user(argp, &info->mon_data,
1404 if (copy_to_user(argp, &info->mon_data, sizeof(struct mxser_mon))) 1470 sizeof(struct mxser_mon)))
1405 return -EFAULT; 1471 return -EFAULT;
1406 1472
1407 return 0; 1473 return 0;
1408
1409 } 1474 }
1410 1475
1411 case MOXA_ASPP_LSTATUS:{ 1476 case MOXA_ASPP_LSTATUS: {
1412 if (copy_to_user(argp, &info->err_shadow, sizeof(unsigned char))) 1477 if (copy_to_user(argp, &info->err_shadow,
1478 sizeof(unsigned char)))
1413 return -EFAULT; 1479 return -EFAULT;
1414 1480
1415 info->err_shadow = 0; 1481 info->err_shadow = 0;
1416 return 0; 1482 return 0;
1417
1418 } 1483 }
1419 case MOXA_SET_BAUD_METHOD:{ 1484 case MOXA_SET_BAUD_METHOD: {
1420 int method; 1485 int method;
1421 if (get_user(method, (int __user *) argp)) 1486
1487 if (get_user(method, (int __user *)argp))
1422 return -EFAULT; 1488 return -EFAULT;
1423 mxser_set_baud_method[info->port] = method; 1489 mxser_set_baud_method[info->port] = method;
1424 if (copy_to_user(argp, &method, sizeof(int))) 1490 if (copy_to_user(argp, &method, sizeof(int)))
@@ -1442,7 +1508,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1442 1508
1443 switch (cmd) { 1509 switch (cmd) {
1444 case MOXA_GET_CONF: 1510 case MOXA_GET_CONF:
1445 if (copy_to_user(argp, mxsercfg, sizeof(struct mxser_hwconf) * 4)) 1511 if (copy_to_user(argp, mxsercfg,
1512 sizeof(struct mxser_hwconf) * 4))
1446 return -EFAULT; 1513 return -EFAULT;
1447 return 0; 1514 return 0;
1448 case MOXA_GET_MAJOR: 1515 case MOXA_GET_MAJOR:
@@ -1461,11 +1528,11 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1461 if (mxvar_table[i].base) 1528 if (mxvar_table[i].base)
1462 result |= (1 << i); 1529 result |= (1 << i);
1463 } 1530 }
1464 return put_user(result, (unsigned long __user *) argp); 1531 return put_user(result, (unsigned long __user *)argp);
1465 case MOXA_GETDATACOUNT: 1532 case MOXA_GETDATACOUNT:
1466 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) 1533 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
1467 return -EFAULT; 1534 return -EFAULT;
1468 return (0); 1535 return 0;
1469 case MOXA_GETMSTATUS: 1536 case MOXA_GETMSTATUS:
1470 for (i = 0; i < MXSER_PORTS; i++) { 1537 for (i = 0; i < MXSER_PORTS; i++) {
1471 GMStatus[i].ri = 0; 1538 GMStatus[i].ri = 0;
@@ -1498,22 +1565,26 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1498 else 1565 else
1499 GMStatus[i].cts = 0; 1566 GMStatus[i].cts = 0;
1500 } 1567 }
1501 if (copy_to_user(argp, GMStatus, sizeof(struct mxser_mstatus) * MXSER_PORTS)) 1568 if (copy_to_user(argp, GMStatus,
1569 sizeof(struct mxser_mstatus) * MXSER_PORTS))
1502 return -EFAULT; 1570 return -EFAULT;
1503 return 0; 1571 return 0;
1504 case MOXA_ASPP_MON_EXT:{ 1572 case MOXA_ASPP_MON_EXT: {
1505 int status; 1573 int status;
1506 int opmode, p; 1574 int opmode, p;
1507 int shiftbit; 1575 int shiftbit;
1508 unsigned cflag, iflag; 1576 unsigned cflag, iflag;
1509 1577
1510 for (i = 0; i < MXSER_PORTS; i++) { 1578 for (i = 0; i < MXSER_PORTS; i++) {
1511
1512 if (!mxvar_table[i].base) 1579 if (!mxvar_table[i].base)
1513 continue; 1580 continue;
1514 1581
1515 status = mxser_get_msr(mxvar_table[i].base, 0, i, &(mxvar_table[i])); 1582 status = mxser_get_msr(mxvar_table[i].base, 0,
1516// mxser_check_modem_status(&mxvar_table[i], status); 1583 i, &(mxvar_table[i]));
1584 /*
1585 mxser_check_modem_status(&mxvar_table[i],
1586 status);
1587 */
1517 if (status & UART_MSR_TERI) 1588 if (status & UART_MSR_TERI)
1518 mxvar_table[i].icount.rng++; 1589 mxvar_table[i].icount.rng++;
1519 if (status & UART_MSR_DDSR) 1590 if (status & UART_MSR_DDSR)
@@ -1578,75 +1649,76 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1578 return 0; 1649 return 0;
1579} 1650}
1580 1651
1581
1582static void mxser_stoprx(struct tty_struct *tty) 1652static void mxser_stoprx(struct tty_struct *tty)
1583{ 1653{
1584 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1654 struct mxser_struct *info = tty->driver_data;
1585 //unsigned long flags; 1655 /* unsigned long flags; */
1586
1587 1656
1588 info->ldisc_stop_rx = 1; 1657 info->ldisc_stop_rx = 1;
1589 if (I_IXOFF(tty)) { 1658 if (I_IXOFF(tty)) {
1590 1659 /* MX_LOCK(&info->slock); */
1591 //MX_LOCK(&info->slock); 1660 /* following add by Victor Yu. 09-02-2002 */
1592 // following add by Victor Yu. 09-02-2002
1593 if (info->IsMoxaMustChipFlag) { 1661 if (info->IsMoxaMustChipFlag) {
1594 info->IER &= ~MOXA_MUST_RECV_ISR; 1662 info->IER &= ~MOXA_MUST_RECV_ISR;
1595 outb(info->IER, info->base + UART_IER); 1663 outb(info->IER, info->base + UART_IER);
1596 } else { 1664 } else {
1597 // above add by Victor Yu. 09-02-2002 1665 /* above add by Victor Yu. 09-02-2002 */
1598
1599 info->x_char = STOP_CHAR(tty); 1666 info->x_char = STOP_CHAR(tty);
1600 // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 1667 /* mask by Victor Yu. 09-02-2002 */
1668 /* outb(info->IER, 0); */
1601 outb(0, info->base + UART_IER); 1669 outb(0, info->base + UART_IER);
1602 info->IER |= UART_IER_THRI; 1670 info->IER |= UART_IER_THRI;
1603 outb(info->IER, info->base + UART_IER); /* force Tx interrupt */ 1671 /* force Tx interrupt */
1604 } // add by Victor Yu. 09-02-2002 1672 outb(info->IER, info->base + UART_IER);
1605 //MX_UNLOCK(&info->slock); 1673 } /* add by Victor Yu. 09-02-2002 */
1674 /* MX_UNLOCK(&info->slock); */
1606 } 1675 }
1607 1676
1608 if (info->tty->termios->c_cflag & CRTSCTS) { 1677 if (info->tty->termios->c_cflag & CRTSCTS) {
1609 //MX_LOCK(&info->slock); 1678 /* MX_LOCK(&info->slock); */
1610 info->MCR &= ~UART_MCR_RTS; 1679 info->MCR &= ~UART_MCR_RTS;
1611 outb(info->MCR, info->base + UART_MCR); 1680 outb(info->MCR, info->base + UART_MCR);
1612 //MX_UNLOCK(&info->slock); 1681 /* MX_UNLOCK(&info->slock); */
1613 } 1682 }
1614} 1683}
1615 1684
1616static void mxser_startrx(struct tty_struct *tty) 1685static void mxser_startrx(struct tty_struct *tty)
1617{ 1686{
1618 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1687 struct mxser_struct *info = tty->driver_data;
1619 //unsigned long flags; 1688 /* unsigned long flags; */
1620 1689
1621 info->ldisc_stop_rx = 0; 1690 info->ldisc_stop_rx = 0;
1622 if (I_IXOFF(tty)) { 1691 if (I_IXOFF(tty)) {
1623 if (info->x_char) 1692 if (info->x_char)
1624 info->x_char = 0; 1693 info->x_char = 0;
1625 else { 1694 else {
1626 //MX_LOCK(&info->slock); 1695 /* MX_LOCK(&info->slock); */
1627 1696
1628 // following add by Victor Yu. 09-02-2002 1697 /* following add by Victor Yu. 09-02-2002 */
1629 if (info->IsMoxaMustChipFlag) { 1698 if (info->IsMoxaMustChipFlag) {
1630 info->IER |= MOXA_MUST_RECV_ISR; 1699 info->IER |= MOXA_MUST_RECV_ISR;
1631 outb(info->IER, info->base + UART_IER); 1700 outb(info->IER, info->base + UART_IER);
1632 } else { 1701 } else {
1633 // above add by Victor Yu. 09-02-2002 1702 /* above add by Victor Yu. 09-02-2002 */
1634 1703
1635 info->x_char = START_CHAR(tty); 1704 info->x_char = START_CHAR(tty);
1636 // outb(info->IER, 0); // mask by Victor Yu. 09-02-2002 1705 /* mask by Victor Yu. 09-02-2002 */
1637 outb(0, info->base + UART_IER); // add by Victor Yu. 09-02-2002 1706 /* outb(info->IER, 0); */
1638 info->IER |= UART_IER_THRI; /* force Tx interrupt */ 1707 /* add by Victor Yu. 09-02-2002 */
1708 outb(0, info->base + UART_IER);
1709 /* force Tx interrupt */
1710 info->IER |= UART_IER_THRI;
1639 outb(info->IER, info->base + UART_IER); 1711 outb(info->IER, info->base + UART_IER);
1640 } // add by Victor Yu. 09-02-2002 1712 } /* add by Victor Yu. 09-02-2002 */
1641 //MX_UNLOCK(&info->slock); 1713 /* MX_UNLOCK(&info->slock); */
1642 } 1714 }
1643 } 1715 }
1644 1716
1645 if (info->tty->termios->c_cflag & CRTSCTS) { 1717 if (info->tty->termios->c_cflag & CRTSCTS) {
1646 //MX_LOCK(&info->slock); 1718 /* MX_LOCK(&info->slock); */
1647 info->MCR |= UART_MCR_RTS; 1719 info->MCR |= UART_MCR_RTS;
1648 outb(info->MCR, info->base + UART_MCR); 1720 outb(info->MCR, info->base + UART_MCR);
1649 //MX_UNLOCK(&info->slock); 1721 /* MX_UNLOCK(&info->slock); */
1650 } 1722 }
1651} 1723}
1652 1724
@@ -1656,48 +1728,53 @@ static void mxser_startrx(struct tty_struct *tty)
1656 */ 1728 */
1657static void mxser_throttle(struct tty_struct *tty) 1729static void mxser_throttle(struct tty_struct *tty)
1658{ 1730{
1659 //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; 1731 /* struct mxser_struct *info = tty->driver_data; */
1660 //unsigned long flags; 1732 /* unsigned long flags; */
1661 //MX_LOCK(&info->slock); 1733
1734 /* MX_LOCK(&info->slock); */
1662 mxser_stoprx(tty); 1735 mxser_stoprx(tty);
1663 //MX_UNLOCK(&info->slock); 1736 /* MX_UNLOCK(&info->slock); */
1664} 1737}
1665 1738
1666static void mxser_unthrottle(struct tty_struct *tty) 1739static void mxser_unthrottle(struct tty_struct *tty)
1667{ 1740{
1668 //struct mxser_struct *info = (struct mxser_struct *)tty->driver_data; 1741 /* struct mxser_struct *info = tty->driver_data; */
1669 //unsigned long flags; 1742 /* unsigned long flags; */
1670 //MX_LOCK(&info->slock); 1743
1744 /* MX_LOCK(&info->slock); */
1671 mxser_startrx(tty); 1745 mxser_startrx(tty);
1672 //MX_UNLOCK(&info->slock); 1746 /* MX_UNLOCK(&info->slock); */
1673} 1747}
1674 1748
1675static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios) 1749static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termios)
1676{ 1750{
1677 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1751 struct mxser_struct *info = tty->driver_data;
1678 unsigned long flags; 1752 unsigned long flags;
1679 1753
1680 if ((tty->termios->c_cflag != old_termios->c_cflag) || (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) { 1754 if ((tty->termios->c_cflag != old_termios->c_cflag) ||
1755 (RELEVANT_IFLAG(tty->termios->c_iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
1681 1756
1682 mxser_change_speed(info, old_termios); 1757 mxser_change_speed(info, old_termios);
1683 1758
1684 if ((old_termios->c_cflag & CRTSCTS) && !(tty->termios->c_cflag & CRTSCTS)) { 1759 if ((old_termios->c_cflag & CRTSCTS) &&
1760 !(tty->termios->c_cflag & CRTSCTS)) {
1685 tty->hw_stopped = 0; 1761 tty->hw_stopped = 0;
1686 mxser_start(tty); 1762 mxser_start(tty);
1687 } 1763 }
1688 } 1764 }
1689 1765
1690/* Handle sw stopped */ 1766/* Handle sw stopped */
1691 if ((old_termios->c_iflag & IXON) && !(tty->termios->c_iflag & IXON)) { 1767 if ((old_termios->c_iflag & IXON) &&
1768 !(tty->termios->c_iflag & IXON)) {
1692 tty->stopped = 0; 1769 tty->stopped = 0;
1693 1770
1694 // following add by Victor Yu. 09-02-2002 1771 /* following add by Victor Yu. 09-02-2002 */
1695 if (info->IsMoxaMustChipFlag) { 1772 if (info->IsMoxaMustChipFlag) {
1696 spin_lock_irqsave(&info->slock, flags); 1773 spin_lock_irqsave(&info->slock, flags);
1697 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base); 1774 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->base);
1698 spin_unlock_irqrestore(&info->slock, flags); 1775 spin_unlock_irqrestore(&info->slock, flags);
1699 } 1776 }
1700 // above add by Victor Yu. 09-02-2002 1777 /* above add by Victor Yu. 09-02-2002 */
1701 1778
1702 mxser_start(tty); 1779 mxser_start(tty);
1703 } 1780 }
@@ -1711,7 +1788,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct termios *old_termio
1711 */ 1788 */
1712static void mxser_stop(struct tty_struct *tty) 1789static void mxser_stop(struct tty_struct *tty)
1713{ 1790{
1714 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1791 struct mxser_struct *info = tty->driver_data;
1715 unsigned long flags; 1792 unsigned long flags;
1716 1793
1717 spin_lock_irqsave(&info->slock, flags); 1794 spin_lock_irqsave(&info->slock, flags);
@@ -1724,7 +1801,7 @@ static void mxser_stop(struct tty_struct *tty)
1724 1801
1725static void mxser_start(struct tty_struct *tty) 1802static void mxser_start(struct tty_struct *tty)
1726{ 1803{
1727 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1804 struct mxser_struct *info = tty->driver_data;
1728 unsigned long flags; 1805 unsigned long flags;
1729 1806
1730 spin_lock_irqsave(&info->slock, flags); 1807 spin_lock_irqsave(&info->slock, flags);
@@ -1740,7 +1817,7 @@ static void mxser_start(struct tty_struct *tty)
1740 */ 1817 */
1741static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) 1818static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1742{ 1819{
1743 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1820 struct mxser_struct *info = tty->driver_data;
1744 unsigned long orig_jiffies, char_time; 1821 unsigned long orig_jiffies, char_time;
1745 int lsr; 1822 int lsr;
1746 1823
@@ -1777,7 +1854,8 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1777 if (!timeout || timeout > 2 * info->timeout) 1854 if (!timeout || timeout > 2 * info->timeout)
1778 timeout = 2 * info->timeout; 1855 timeout = 2 * info->timeout;
1779#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1856#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1780 printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...", timeout, char_time); 1857 printk(KERN_DEBUG "In rs_wait_until_sent(%d) check=%lu...",
1858 timeout, char_time);
1781 printk("jiff=%lu...", jiffies); 1859 printk("jiff=%lu...", jiffies);
1782#endif 1860#endif
1783 while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) { 1861 while (!((lsr = inb(info->base + UART_LSR)) & UART_LSR_TEMT)) {
@@ -1803,7 +1881,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1803 */ 1881 */
1804void mxser_hangup(struct tty_struct *tty) 1882void mxser_hangup(struct tty_struct *tty)
1805{ 1883{
1806 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1884 struct mxser_struct *info = tty->driver_data;
1807 1885
1808 mxser_flush_buffer(tty); 1886 mxser_flush_buffer(tty);
1809 mxser_shutdown(info); 1887 mxser_shutdown(info);
@@ -1815,24 +1893,26 @@ void mxser_hangup(struct tty_struct *tty)
1815} 1893}
1816 1894
1817 1895
1818// added by James 03-12-2004. 1896/* added by James 03-12-2004. */
1819/* 1897/*
1820 * mxser_rs_break() --- routine which turns the break handling on or off 1898 * mxser_rs_break() --- routine which turns the break handling on or off
1821 */ 1899 */
1822static void mxser_rs_break(struct tty_struct *tty, int break_state) 1900static void mxser_rs_break(struct tty_struct *tty, int break_state)
1823{ 1901{
1824 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 1902 struct mxser_struct *info = tty->driver_data;
1825 unsigned long flags; 1903 unsigned long flags;
1826 1904
1827 spin_lock_irqsave(&info->slock, flags); 1905 spin_lock_irqsave(&info->slock, flags);
1828 if (break_state == -1) 1906 if (break_state == -1)
1829 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); 1907 outb(inb(info->base + UART_LCR) | UART_LCR_SBC,
1908 info->base + UART_LCR);
1830 else 1909 else
1831 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); 1910 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC,
1911 info->base + UART_LCR);
1832 spin_unlock_irqrestore(&info->slock, flags); 1912 spin_unlock_irqrestore(&info->slock, flags);
1833} 1913}
1834 1914
1835// (above) added by James. 1915/* (above) added by James. */
1836 1916
1837 1917
1838/* 1918/*
@@ -1848,7 +1928,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1848 int handled = IRQ_NONE; 1928 int handled = IRQ_NONE;
1849 1929
1850 port = NULL; 1930 port = NULL;
1851 //spin_lock(&gm_lock); 1931 /* spin_lock(&gm_lock); */
1852 1932
1853 for (i = 0; i < MXSER_BOARDS; i++) { 1933 for (i = 0; i < MXSER_BOARDS; i++) {
1854 if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) { 1934 if (dev_id == &(mxvar_table[i * MXSER_PORTS_PER_BOARD])) {
@@ -1857,29 +1937,25 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1857 } 1937 }
1858 } 1938 }
1859 1939
1860 if (i == MXSER_BOARDS) { 1940 if (i == MXSER_BOARDS)
1861 goto irq_stop; 1941 goto irq_stop;
1862 } 1942 if (port == 0)
1863 if (port == 0) {
1864 goto irq_stop; 1943 goto irq_stop;
1865 }
1866 max = mxser_numports[mxsercfg[i].board_type - 1]; 1944 max = mxser_numports[mxsercfg[i].board_type - 1];
1867 while (1) { 1945 while (1) {
1868 irqbits = inb(port->vector) & port->vectormask; 1946 irqbits = inb(port->vector) & port->vectormask;
1869 if (irqbits == port->vectormask) { 1947 if (irqbits == port->vectormask)
1870 break; 1948 break;
1871 }
1872 1949
1873 handled = IRQ_HANDLED; 1950 handled = IRQ_HANDLED;
1874 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) { 1951 for (i = 0, bits = 1; i < max; i++, irqbits |= bits, bits <<= 1) {
1875 if (irqbits == port->vectormask) { 1952 if (irqbits == port->vectormask)
1876 break; 1953 break;
1877 }
1878 if (bits & irqbits) 1954 if (bits & irqbits)
1879 continue; 1955 continue;
1880 info = port + i; 1956 info = port + i;
1881 1957
1882 // following add by Victor Yu. 09-13-2002 1958 /* following add by Victor Yu. 09-13-2002 */
1883 iir = inb(info->base + UART_IIR); 1959 iir = inb(info->base + UART_IIR);
1884 if (iir & UART_IIR_NO_INT) 1960 if (iir & UART_IIR_NO_INT)
1885 continue; 1961 continue;
@@ -1890,9 +1966,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1890 inb(info->base + UART_MSR); 1966 inb(info->base + UART_MSR);
1891 continue; 1967 continue;
1892 } 1968 }
1893 // above add by Victor Yu. 09-13-2002 1969 /* above add by Victor Yu. 09-13-2002 */
1894 /* 1970 /*
1895 if ( info->tty->flip.count < TTY_FLIPBUF_SIZE/4 ){ 1971 if (info->tty->flip.count < TTY_FLIPBUF_SIZE / 4) {
1896 info->IER |= MOXA_MUST_RECV_ISR; 1972 info->IER |= MOXA_MUST_RECV_ISR;
1897 outb(info->IER, info->base + UART_IER); 1973 outb(info->IER, info->base + UART_IER);
1898 } 1974 }
@@ -1908,18 +1984,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; 1984 status = inb(info->base + UART_LSR) & info->read_status_mask;
1909 */ 1985 */
1910 1986
1911 // following add by Victor Yu. 09-02-2002 1987 /* following add by Victor Yu. 09-02-2002 */
1912 status = inb(info->base + UART_LSR); 1988 status = inb(info->base + UART_LSR);
1913 1989
1914 if (status & UART_LSR_PE) { 1990 if (status & UART_LSR_PE)
1915 info->err_shadow |= NPPI_NOTIFY_PARITY; 1991 info->err_shadow |= NPPI_NOTIFY_PARITY;
1916 } 1992 if (status & UART_LSR_FE)
1917 if (status & UART_LSR_FE) {
1918 info->err_shadow |= NPPI_NOTIFY_FRAMING; 1993 info->err_shadow |= NPPI_NOTIFY_FRAMING;
1919 } 1994 if (status & UART_LSR_OE)
1920 if (status & UART_LSR_OE) {
1921 info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN; 1995 info->err_shadow |= NPPI_NOTIFY_HW_OVERRUN;
1922 }
1923 if (status & UART_LSR_BI) 1996 if (status & UART_LSR_BI)
1924 info->err_shadow |= NPPI_NOTIFY_BREAK; 1997 info->err_shadow |= NPPI_NOTIFY_BREAK;
1925 1998
@@ -1930,11 +2003,14 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1930 continue; 2003 continue;
1931 } 2004 }
1932 */ 2005 */
1933 if (iir == MOXA_MUST_IIR_GDA || iir == MOXA_MUST_IIR_RDA || iir == MOXA_MUST_IIR_RTO || iir == MOXA_MUST_IIR_LSR) 2006 if (iir == MOXA_MUST_IIR_GDA ||
2007 iir == MOXA_MUST_IIR_RDA ||
2008 iir == MOXA_MUST_IIR_RTO ||
2009 iir == MOXA_MUST_IIR_LSR)
1934 mxser_receive_chars(info, &status); 2010 mxser_receive_chars(info, &status);
1935 2011
1936 } else { 2012 } else {
1937 // above add by Victor Yu. 09-02-2002 2013 /* above add by Victor Yu. 09-02-2002 */
1938 2014
1939 status &= info->read_status_mask; 2015 status &= info->read_status_mask;
1940 if (status & UART_LSR_DR) 2016 if (status & UART_LSR_DR)
@@ -1944,13 +2020,13 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1944 if (msr & UART_MSR_ANY_DELTA) { 2020 if (msr & UART_MSR_ANY_DELTA) {
1945 mxser_check_modem_status(info, msr); 2021 mxser_check_modem_status(info, msr);
1946 } 2022 }
1947 // following add by Victor Yu. 09-13-2002 2023 /* following add by Victor Yu. 09-13-2002 */
1948 if (info->IsMoxaMustChipFlag) { 2024 if (info->IsMoxaMustChipFlag) {
1949 if ((iir == 0x02) && (status & UART_LSR_THRE)) { 2025 if ((iir == 0x02) && (status & UART_LSR_THRE)) {
1950 mxser_transmit_chars(info); 2026 mxser_transmit_chars(info);
1951 } 2027 }
1952 } else { 2028 } else {
1953 // above add by Victor Yu. 09-13-2002 2029 /* above add by Victor Yu. 09-13-2002 */
1954 2030
1955 if (status & UART_LSR_THRE) { 2031 if (status & UART_LSR_THRE) {
1956/* 8-2-99 by William 2032/* 8-2-99 by William
@@ -1966,7 +2042,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1966 } 2042 }
1967 2043
1968 irq_stop: 2044 irq_stop:
1969 //spin_unlock(&gm_lock); 2045 /* spin_unlock(&gm_lock); */
1970 return handled; 2046 return handled;
1971} 2047}
1972 2048
@@ -1984,56 +2060,58 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status)
1984 2060
1985 recv_room = tty->receive_room; 2061 recv_room = tty->receive_room;
1986 if ((recv_room == 0) && (!info->ldisc_stop_rx)) { 2062 if ((recv_room == 0) && (!info->ldisc_stop_rx)) {
1987 //mxser_throttle(tty); 2063 /* mxser_throttle(tty); */
1988 mxser_stoprx(tty); 2064 mxser_stoprx(tty);
1989 //return; 2065 /* return; */
1990 } 2066 }
1991 2067
1992 // following add by Victor Yu. 09-02-2002 2068 /* following add by Victor Yu. 09-02-2002 */
1993 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { 2069 if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) {
1994 2070
1995 if (*status & UART_LSR_SPECIAL) { 2071 if (*status & UART_LSR_SPECIAL) {
1996 goto intr_old; 2072 goto intr_old;
1997 } 2073 }
1998 // following add by Victor Yu. 02-11-2004 2074 /* following add by Victor Yu. 02-11-2004 */
1999 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID && (*status & MOXA_MUST_LSR_RERR)) 2075 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU860_HWID &&
2076 (*status & MOXA_MUST_LSR_RERR))
2000 goto intr_old; 2077 goto intr_old;
2001 // above add by Victor Yu. 02-14-2004 2078 /* above add by Victor Yu. 02-14-2004 */
2002 if (*status & MOXA_MUST_LSR_RERR) 2079 if (*status & MOXA_MUST_LSR_RERR)
2003 goto intr_old; 2080 goto intr_old;
2004 2081
2005 gdl = inb(info->base + MOXA_MUST_GDL_REGISTER); 2082 gdl = inb(info->base + MOXA_MUST_GDL_REGISTER);
2006 2083
2007 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID) // add by Victor Yu. 02-11-2004 2084 /* add by Victor Yu. 02-11-2004 */
2085 if (info->IsMoxaMustChipFlag == MOXA_MUST_MU150_HWID)
2008 gdl &= MOXA_MUST_GDL_MASK; 2086 gdl &= MOXA_MUST_GDL_MASK;
2009 if (gdl >= recv_room) { 2087 if (gdl >= recv_room) {
2010 if (!info->ldisc_stop_rx) { 2088 if (!info->ldisc_stop_rx) {
2011 //mxser_throttle(tty); 2089 /* mxser_throttle(tty); */
2012 mxser_stoprx(tty); 2090 mxser_stoprx(tty);
2013 } 2091 }
2014 //return; 2092 /* return; */
2015 } 2093 }
2016 while (gdl--) { 2094 while (gdl--) {
2017 ch = inb(info->base + UART_RX); 2095 ch = inb(info->base + UART_RX);
2018 tty_insert_flip_char(tty, ch, 0); 2096 tty_insert_flip_char(tty, ch, 0);
2019 cnt++; 2097 cnt++;
2020 /* 2098 /*
2021 if((cnt>=HI_WATER) && (info->stop_rx==0)){ 2099 if ((cnt >= HI_WATER) && (info->stop_rx == 0)) {
2022 mxser_stoprx(tty); 2100 mxser_stoprx(tty);
2023 info->stop_rx=1; 2101 info->stop_rx = 1;
2024 break; 2102 break;
2025 } */ 2103 } */
2026 } 2104 }
2027 goto end_intr; 2105 goto end_intr;
2028 } 2106 }
2029intr_old: 2107 intr_old:
2030 // above add by Victor Yu. 09-02-2002 2108 /* above add by Victor Yu. 09-02-2002 */
2031 2109
2032 do { 2110 do {
2033 if (max-- < 0) 2111 if (max-- < 0)
2034 break; 2112 break;
2035 /* 2113 /*
2036 if((cnt>=HI_WATER) && (info->stop_rx==0)){ 2114 if ((cnt >= HI_WATER) && (info->stop_rx == 0)) {
2037 mxser_stoprx(tty); 2115 mxser_stoprx(tty);
2038 info->stop_rx=1; 2116 info->stop_rx=1;
2039 break; 2117 break;
@@ -2041,11 +2119,11 @@ intr_old:
2041 */ 2119 */
2042 2120
2043 ch = inb(info->base + UART_RX); 2121 ch = inb(info->base + UART_RX);
2044 // following add by Victor Yu. 09-02-2002 2122 /* following add by Victor Yu. 09-02-2002 */
2045 if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ ) 2123 if (info->IsMoxaMustChipFlag && (*status & UART_LSR_OE) /*&& !(*status&UART_LSR_DR) */ )
2046 outb(0x23, info->base + UART_FCR); 2124 outb(0x23, info->base + UART_FCR);
2047 *status &= info->read_status_mask; 2125 *status &= info->read_status_mask;
2048 // above add by Victor Yu. 09-02-2002 2126 /* above add by Victor Yu. 09-02-2002 */
2049 if (*status & info->ignore_status_mask) { 2127 if (*status & info->ignore_status_mask) {
2050 if (++ignored > 100) 2128 if (++ignored > 100)
2051 break; 2129 break;
@@ -2080,7 +2158,7 @@ intr_old:
2080 cnt++; 2158 cnt++;
2081 if (cnt >= recv_room) { 2159 if (cnt >= recv_room) {
2082 if (!info->ldisc_stop_rx) { 2160 if (!info->ldisc_stop_rx) {
2083 //mxser_throttle(tty); 2161 /* mxser_throttle(tty); */
2084 mxser_stoprx(tty); 2162 mxser_stoprx(tty);
2085 } 2163 }
2086 break; 2164 break;
@@ -2088,21 +2166,20 @@ intr_old:
2088 2166
2089 } 2167 }
2090 2168
2091 // following add by Victor Yu. 09-02-2002 2169 /* following add by Victor Yu. 09-02-2002 */
2092 if (info->IsMoxaMustChipFlag) 2170 if (info->IsMoxaMustChipFlag)
2093 break; 2171 break;
2094 // above add by Victor Yu. 09-02-2002 2172 /* above add by Victor Yu. 09-02-2002 */
2095 2173
2096 /* mask by Victor Yu. 09-02-2002 2174 /* mask by Victor Yu. 09-02-2002
2097 *status = inb(info->base + UART_LSR) & info->read_status_mask; 2175 *status = inb(info->base + UART_LSR) & info->read_status_mask;
2098 */ 2176 */
2099 // following add by Victor Yu. 09-02-2002 2177 /* following add by Victor Yu. 09-02-2002 */
2100 *status = inb(info->base + UART_LSR); 2178 *status = inb(info->base + UART_LSR);
2101 // above add by Victor Yu. 09-02-2002 2179 /* above add by Victor Yu. 09-02-2002 */
2102 } while (*status & UART_LSR_DR); 2180 } while (*status & UART_LSR_DR);
2103 2181
2104end_intr: // add by Victor Yu. 09-02-2002 2182end_intr: /* add by Victor Yu. 09-02-2002 */
2105
2106 mxvar_log.rxcnt[info->port] += cnt; 2183 mxvar_log.rxcnt[info->port] += cnt;
2107 info->mon_data.rxcnt += cnt; 2184 info->mon_data.rxcnt += cnt;
2108 info->mon_data.up_rxcnt += cnt; 2185 info->mon_data.up_rxcnt += cnt;
@@ -2137,7 +2214,10 @@ static void mxser_transmit_chars(struct mxser_struct *info)
2137 return; 2214 return;
2138 } 2215 }
2139 2216
2140 if ((info->xmit_cnt <= 0) || info->tty->stopped || (info->tty->hw_stopped && (info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag))) { 2217 if ((info->xmit_cnt <= 0) || info->tty->stopped ||
2218 (info->tty->hw_stopped &&
2219 (info->type != PORT_16550A) &&
2220 (!info->IsMoxaMustChipFlag))) {
2141 info->IER &= ~UART_IER_THRI; 2221 info->IER &= ~UART_IER_THRI;
2142 outb(info->IER, info->base + UART_IER); 2222 outb(info->IER, info->base + UART_IER);
2143 spin_unlock_irqrestore(&info->slock, flags); 2223 spin_unlock_irqrestore(&info->slock, flags);
@@ -2147,17 +2227,18 @@ static void mxser_transmit_chars(struct mxser_struct *info)
2147 cnt = info->xmit_cnt; 2227 cnt = info->xmit_cnt;
2148 count = info->xmit_fifo_size; 2228 count = info->xmit_fifo_size;
2149 do { 2229 do {
2150 outb(info->xmit_buf[info->xmit_tail++], info->base + UART_TX); 2230 outb(info->xmit_buf[info->xmit_tail++],
2231 info->base + UART_TX);
2151 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1); 2232 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE - 1);
2152 if (--info->xmit_cnt <= 0) 2233 if (--info->xmit_cnt <= 0)
2153 break; 2234 break;
2154 } while (--count > 0); 2235 } while (--count > 0);
2155 mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt); 2236 mxvar_log.txcnt[info->port] += (cnt - info->xmit_cnt);
2156 2237
2157// added by James 03-12-2004. 2238/* added by James 03-12-2004. */
2158 info->mon_data.txcnt += (cnt - info->xmit_cnt); 2239 info->mon_data.txcnt += (cnt - info->xmit_cnt);
2159 info->mon_data.up_txcnt += (cnt - info->xmit_cnt); 2240 info->mon_data.up_txcnt += (cnt - info->xmit_cnt);
2160// (above) added by James. 2241/* (above) added by James. */
2161 2242
2162/* added by casper 1/11/2000 */ 2243/* added by casper 1/11/2000 */
2163 info->icount.tx += (cnt - info->xmit_cnt); 2244 info->icount.tx += (cnt - info->xmit_cnt);
@@ -2188,7 +2269,6 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2188 info->mon_data.modem_status = status; 2269 info->mon_data.modem_status = status;
2189 wake_up_interruptible(&info->delta_msr_wait); 2270 wake_up_interruptible(&info->delta_msr_wait);
2190 2271
2191
2192 if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) { 2272 if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
2193 if (status & UART_MSR_DCD) 2273 if (status & UART_MSR_DCD)
2194 wake_up_interruptible(&info->open_wait); 2274 wake_up_interruptible(&info->open_wait);
@@ -2200,7 +2280,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2200 if (status & UART_MSR_CTS) { 2280 if (status & UART_MSR_CTS) {
2201 info->tty->hw_stopped = 0; 2281 info->tty->hw_stopped = 0;
2202 2282
2203 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2283 if ((info->type != PORT_16550A) &&
2284 (!info->IsMoxaMustChipFlag)) {
2204 info->IER |= UART_IER_THRI; 2285 info->IER |= UART_IER_THRI;
2205 outb(info->IER, info->base + UART_IER); 2286 outb(info->IER, info->base + UART_IER);
2206 } 2287 }
@@ -2209,7 +2290,8 @@ static void mxser_check_modem_status(struct mxser_struct *info, int status)
2209 } else { 2290 } else {
2210 if (!(status & UART_MSR_CTS)) { 2291 if (!(status & UART_MSR_CTS)) {
2211 info->tty->hw_stopped = 1; 2292 info->tty->hw_stopped = 1;
2212 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2293 if ((info->type != PORT_16550A) &&
2294 (!info->IsMoxaMustChipFlag)) {
2213 info->IER &= ~UART_IER_THRI; 2295 info->IER &= ~UART_IER_THRI;
2214 outb(info->IER, info->base + UART_IER); 2296 outb(info->IER, info->base + UART_IER);
2215 } 2297 }
@@ -2231,7 +2313,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2231 */ 2313 */
2232 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { 2314 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) {
2233 info->flags |= ASYNC_NORMAL_ACTIVE; 2315 info->flags |= ASYNC_NORMAL_ACTIVE;
2234 return (0); 2316 return 0;
2235 } 2317 }
2236 2318
2237 if (tty->termios->c_cflag & CLOCAL) 2319 if (tty->termios->c_cflag & CLOCAL)
@@ -2254,7 +2336,8 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2254 info->blocked_open++; 2336 info->blocked_open++;
2255 while (1) { 2337 while (1) {
2256 spin_lock_irqsave(&info->slock, flags); 2338 spin_lock_irqsave(&info->slock, flags);
2257 outb(inb(info->base + UART_MCR) | UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR); 2339 outb(inb(info->base + UART_MCR) |
2340 UART_MCR_DTR | UART_MCR_RTS, info->base + UART_MCR);
2258 spin_unlock_irqrestore(&info->slock, flags); 2341 spin_unlock_irqrestore(&info->slock, flags);
2259 set_current_state(TASK_INTERRUPTIBLE); 2342 set_current_state(TASK_INTERRUPTIBLE);
2260 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { 2343 if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) {
@@ -2264,7 +2347,9 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2264 retval = -ERESTARTSYS; 2347 retval = -ERESTARTSYS;
2265 break; 2348 break;
2266 } 2349 }
2267 if (!(info->flags & ASYNC_CLOSING) && (do_clocal || (inb(info->base + UART_MSR) & UART_MSR_DCD))) 2350 if (!(info->flags & ASYNC_CLOSING) &&
2351 (do_clocal ||
2352 (inb(info->base + UART_MSR) & UART_MSR_DCD)))
2268 break; 2353 break;
2269 if (signal_pending(current)) { 2354 if (signal_pending(current)) {
2270 retval = -ERESTARTSYS; 2355 retval = -ERESTARTSYS;
@@ -2278,27 +2363,26 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, stru
2278 info->count++; 2363 info->count++;
2279 info->blocked_open--; 2364 info->blocked_open--;
2280 if (retval) 2365 if (retval)
2281 return (retval); 2366 return retval;
2282 info->flags |= ASYNC_NORMAL_ACTIVE; 2367 info->flags |= ASYNC_NORMAL_ACTIVE;
2283 return (0); 2368 return 0;
2284} 2369}
2285 2370
2286static int mxser_startup(struct mxser_struct *info) 2371static int mxser_startup(struct mxser_struct *info)
2287{ 2372{
2288
2289 unsigned long page; 2373 unsigned long page;
2290 unsigned long flags; 2374 unsigned long flags;
2291 2375
2292 page = __get_free_page(GFP_KERNEL); 2376 page = __get_free_page(GFP_KERNEL);
2293 if (!page) 2377 if (!page)
2294 return (-ENOMEM); 2378 return -ENOMEM;
2295 2379
2296 spin_lock_irqsave(&info->slock, flags); 2380 spin_lock_irqsave(&info->slock, flags);
2297 2381
2298 if (info->flags & ASYNC_INITIALIZED) { 2382 if (info->flags & ASYNC_INITIALIZED) {
2299 free_page(page); 2383 free_page(page);
2300 spin_unlock_irqrestore(&info->slock, flags); 2384 spin_unlock_irqrestore(&info->slock, flags);
2301 return (0); 2385 return 0;
2302 } 2386 }
2303 2387
2304 if (!info->base || !info->type) { 2388 if (!info->base || !info->type) {
@@ -2306,7 +2390,7 @@ static int mxser_startup(struct mxser_struct *info)
2306 set_bit(TTY_IO_ERROR, &info->tty->flags); 2390 set_bit(TTY_IO_ERROR, &info->tty->flags);
2307 free_page(page); 2391 free_page(page);
2308 spin_unlock_irqrestore(&info->slock, flags); 2392 spin_unlock_irqrestore(&info->slock, flags);
2309 return (0); 2393 return 0;
2310 } 2394 }
2311 if (info->xmit_buf) 2395 if (info->xmit_buf)
2312 free_page(page); 2396 free_page(page);
@@ -2318,9 +2402,12 @@ static int mxser_startup(struct mxser_struct *info)
2318 * (they will be reenabled in mxser_change_speed()) 2402 * (they will be reenabled in mxser_change_speed())
2319 */ 2403 */
2320 if (info->IsMoxaMustChipFlag) 2404 if (info->IsMoxaMustChipFlag)
2321 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2405 outb((UART_FCR_CLEAR_RCVR |
2406 UART_FCR_CLEAR_XMIT |
2407 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
2322 else 2408 else
2323 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 2409 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
2410 info->base + UART_FCR);
2324 2411
2325 /* 2412 /*
2326 * At this point there's no way the LSR could still be 0xFF; 2413 * At this point there's no way the LSR could still be 0xFF;
@@ -2332,9 +2419,9 @@ static int mxser_startup(struct mxser_struct *info)
2332 if (capable(CAP_SYS_ADMIN)) { 2419 if (capable(CAP_SYS_ADMIN)) {
2333 if (info->tty) 2420 if (info->tty)
2334 set_bit(TTY_IO_ERROR, &info->tty->flags); 2421 set_bit(TTY_IO_ERROR, &info->tty->flags);
2335 return (0); 2422 return 0;
2336 } else 2423 } else
2337 return (-ENODEV); 2424 return -ENODEV;
2338 } 2425 }
2339 2426
2340 /* 2427 /*
@@ -2356,12 +2443,12 @@ static int mxser_startup(struct mxser_struct *info)
2356 * Finally, enable interrupts 2443 * Finally, enable interrupts
2357 */ 2444 */
2358 info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI; 2445 info->IER = UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI;
2359// info->IER = UART_IER_RLSI | UART_IER_RDI; 2446 /* info->IER = UART_IER_RLSI | UART_IER_RDI; */
2360 2447
2361 // following add by Victor Yu. 08-30-2002 2448 /* following add by Victor Yu. 08-30-2002 */
2362 if (info->IsMoxaMustChipFlag) 2449 if (info->IsMoxaMustChipFlag)
2363 info->IER |= MOXA_MUST_IER_EGDAI; 2450 info->IER |= MOXA_MUST_IER_EGDAI;
2364 // above add by Victor Yu. 08-30-2002 2451 /* above add by Victor Yu. 08-30-2002 */
2365 outb(info->IER, info->base + UART_IER); /* enable interrupts */ 2452 outb(info->IER, info->base + UART_IER); /* enable interrupts */
2366 2453
2367 /* 2454 /*
@@ -2383,7 +2470,7 @@ static int mxser_startup(struct mxser_struct *info)
2383 mxser_change_speed(info, NULL); 2470 mxser_change_speed(info, NULL);
2384 2471
2385 info->flags |= ASYNC_INITIALIZED; 2472 info->flags |= ASYNC_INITIALIZED;
2386 return (0); 2473 return 0;
2387} 2474}
2388 2475
2389/* 2476/*
@@ -2421,12 +2508,15 @@ static void mxser_shutdown(struct mxser_struct *info)
2421 outb(info->MCR, info->base + UART_MCR); 2508 outb(info->MCR, info->base + UART_MCR);
2422 2509
2423 /* clear Rx/Tx FIFO's */ 2510 /* clear Rx/Tx FIFO's */
2424 // following add by Victor Yu. 08-30-2002 2511 /* following add by Victor Yu. 08-30-2002 */
2425 if (info->IsMoxaMustChipFlag) 2512 if (info->IsMoxaMustChipFlag)
2426 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR); 2513 outb((UART_FCR_CLEAR_RCVR |
2514 UART_FCR_CLEAR_XMIT |
2515 MOXA_MUST_FCR_GDA_MODE_ENABLE), info->base + UART_FCR);
2427 else 2516 else
2428 // above add by Victor Yu. 08-30-2002 2517 /* above add by Victor Yu. 08-30-2002 */
2429 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT), info->base + UART_FCR); 2518 outb((UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
2519 info->base + UART_FCR);
2430 2520
2431 /* read data port to reset things */ 2521 /* read data port to reset things */
2432 (void) inb(info->base + UART_RX); 2522 (void) inb(info->base + UART_RX);
@@ -2436,11 +2526,10 @@ static void mxser_shutdown(struct mxser_struct *info)
2436 2526
2437 info->flags &= ~ASYNC_INITIALIZED; 2527 info->flags &= ~ASYNC_INITIALIZED;
2438 2528
2439 // following add by Victor Yu. 09-23-2002 2529 /* following add by Victor Yu. 09-23-2002 */
2440 if (info->IsMoxaMustChipFlag) { 2530 if (info->IsMoxaMustChipFlag)
2441 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base); 2531 SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->base);
2442 } 2532 /* above add by Victor Yu. 09-23-2002 */
2443 // above add by Victor Yu. 09-23-2002
2444 2533
2445 spin_unlock_irqrestore(&info->slock, flags); 2534 spin_unlock_irqrestore(&info->slock, flags);
2446} 2535}
@@ -2457,14 +2546,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2457 long baud; 2546 long baud;
2458 unsigned long flags; 2547 unsigned long flags;
2459 2548
2460
2461 if (!info->tty || !info->tty->termios) 2549 if (!info->tty || !info->tty->termios)
2462 return ret; 2550 return ret;
2463 cflag = info->tty->termios->c_cflag; 2551 cflag = info->tty->termios->c_cflag;
2464 if (!(info->base)) 2552 if (!(info->base))
2465 return ret; 2553 return ret;
2466 2554
2467
2468#ifndef B921600 2555#ifndef B921600
2469#define B921600 (B460800 +1) 2556#define B921600 (B460800 +1)
2470#endif 2557#endif
@@ -2559,9 +2646,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2559 cval |= 0x04; 2646 cval |= 0x04;
2560 if (cflag & PARENB) 2647 if (cflag & PARENB)
2561 cval |= UART_LCR_PARITY; 2648 cval |= UART_LCR_PARITY;
2562 if (!(cflag & PARODD)) { 2649 if (!(cflag & PARODD))
2563 cval |= UART_LCR_EPAR; 2650 cval |= UART_LCR_EPAR;
2564 }
2565 if (cflag & CMSPAR) 2651 if (cflag & CMSPAR)
2566 cval |= UART_LCR_SPAR; 2652 cval |= UART_LCR_SPAR;
2567 2653
@@ -2574,13 +2660,12 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2574 fcr = 0; 2660 fcr = 0;
2575 } else { 2661 } else {
2576 fcr = UART_FCR_ENABLE_FIFO; 2662 fcr = UART_FCR_ENABLE_FIFO;
2577 // following add by Victor Yu. 08-30-2002 2663 /* following add by Victor Yu. 08-30-2002 */
2578 if (info->IsMoxaMustChipFlag) { 2664 if (info->IsMoxaMustChipFlag) {
2579 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 2665 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
2580 SET_MOXA_MUST_FIFO_VALUE(info); 2666 SET_MOXA_MUST_FIFO_VALUE(info);
2581 } else { 2667 } else {
2582 // above add by Victor Yu. 08-30-2002 2668 /* above add by Victor Yu. 08-30-2002 */
2583
2584 switch (info->rx_trigger) { 2669 switch (info->rx_trigger) {
2585 case 1: 2670 case 1:
2586 fcr |= UART_FCR_TRIGGER_1; 2671 fcr |= UART_FCR_TRIGGER_1;
@@ -2606,22 +2691,24 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2606 info->IER |= UART_IER_MSI; 2691 info->IER |= UART_IER_MSI;
2607 if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) { 2692 if ((info->type == PORT_16550A) || (info->IsMoxaMustChipFlag)) {
2608 info->MCR |= UART_MCR_AFE; 2693 info->MCR |= UART_MCR_AFE;
2609 //status = mxser_get_msr(info->base, 0, info->port); 2694 /* status = mxser_get_msr(info->base, 0, info->port); */
2610/* save_flags(flags); 2695/*
2696 save_flags(flags);
2611 cli(); 2697 cli();
2612 status = inb(baseaddr + UART_MSR); 2698 status = inb(baseaddr + UART_MSR);
2613 restore_flags(flags);*/ 2699 restore_flags(flags);
2614 //mxser_check_modem_status(info, status); 2700*/
2701 /* mxser_check_modem_status(info, status); */
2615 } else { 2702 } else {
2616 //status = mxser_get_msr(info->base, 0, info->port); 2703 /* status = mxser_get_msr(info->base, 0, info->port); */
2617 2704 /* MX_LOCK(&info->slock); */
2618 //MX_LOCK(&info->slock);
2619 status = inb(info->base + UART_MSR); 2705 status = inb(info->base + UART_MSR);
2620 //MX_UNLOCK(&info->slock); 2706 /* MX_UNLOCK(&info->slock); */
2621 if (info->tty->hw_stopped) { 2707 if (info->tty->hw_stopped) {
2622 if (status & UART_MSR_CTS) { 2708 if (status & UART_MSR_CTS) {
2623 info->tty->hw_stopped = 0; 2709 info->tty->hw_stopped = 0;
2624 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2710 if ((info->type != PORT_16550A) &&
2711 (!info->IsMoxaMustChipFlag)) {
2625 info->IER |= UART_IER_THRI; 2712 info->IER |= UART_IER_THRI;
2626 outb(info->IER, info->base + UART_IER); 2713 outb(info->IER, info->base + UART_IER);
2627 } 2714 }
@@ -2630,7 +2717,8 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2630 } else { 2717 } else {
2631 if (!(status & UART_MSR_CTS)) { 2718 if (!(status & UART_MSR_CTS)) {
2632 info->tty->hw_stopped = 1; 2719 info->tty->hw_stopped = 1;
2633 if ((info->type != PORT_16550A) && (!info->IsMoxaMustChipFlag)) { 2720 if ((info->type != PORT_16550A) &&
2721 (!info->IsMoxaMustChipFlag)) {
2634 info->IER &= ~UART_IER_THRI; 2722 info->IER &= ~UART_IER_THRI;
2635 outb(info->IER, info->base + UART_IER); 2723 outb(info->IER, info->base + UART_IER);
2636 } 2724 }
@@ -2668,11 +2756,17 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2668 * overruns too. (For real raw support). 2756 * overruns too. (For real raw support).
2669 */ 2757 */
2670 if (I_IGNPAR(info->tty)) { 2758 if (I_IGNPAR(info->tty)) {
2671 info->ignore_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; 2759 info->ignore_status_mask |=
2672 info->read_status_mask |= UART_LSR_OE | UART_LSR_PE | UART_LSR_FE; 2760 UART_LSR_OE |
2761 UART_LSR_PE |
2762 UART_LSR_FE;
2763 info->read_status_mask |=
2764 UART_LSR_OE |
2765 UART_LSR_PE |
2766 UART_LSR_FE;
2673 } 2767 }
2674 } 2768 }
2675 // following add by Victor Yu. 09-02-2002 2769 /* following add by Victor Yu. 09-02-2002 */
2676 if (info->IsMoxaMustChipFlag) { 2770 if (info->IsMoxaMustChipFlag) {
2677 spin_lock_irqsave(&info->slock, flags); 2771 spin_lock_irqsave(&info->slock, flags);
2678 SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty)); 2772 SET_MOXA_MUST_XON1_VALUE(info->base, START_CHAR(info->tty));
@@ -2698,7 +2792,7 @@ static int mxser_change_speed(struct mxser_struct *info, struct termios *old_ter
2698 */ 2792 */
2699 spin_unlock_irqrestore(&info->slock, flags); 2793 spin_unlock_irqrestore(&info->slock, flags);
2700 } 2794 }
2701 // above add by Victor Yu. 09-02-2002 2795 /* above add by Victor Yu. 09-02-2002 */
2702 2796
2703 2797
2704 outb(fcr, info->base + UART_FCR); /* set fcr */ 2798 outb(fcr, info->base + UART_FCR); /* set fcr */
@@ -2729,10 +2823,8 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2729 quot = (2 * info->baud_base / 269); 2823 quot = (2 * info->baud_base / 269);
2730 } else if (newspd) { 2824 } else if (newspd) {
2731 quot = info->baud_base / newspd; 2825 quot = info->baud_base / newspd;
2732
2733 if (quot == 0) 2826 if (quot == 0)
2734 quot = 1; 2827 quot = 1;
2735
2736 } else { 2828 } else {
2737 quot = 0; 2829 quot = 0;
2738 } 2830 }
@@ -2765,8 +2857,6 @@ static int mxser_set_baud(struct mxser_struct *info, long newspd)
2765 return ret; 2857 return ret;
2766} 2858}
2767 2859
2768
2769
2770/* 2860/*
2771 * ------------------------------------------------------------ 2861 * ------------------------------------------------------------
2772 * friends of mxser_ioctl() 2862 * friends of mxser_ioctl()
@@ -2777,7 +2867,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2777 struct serial_struct tmp; 2867 struct serial_struct tmp;
2778 2868
2779 if (!retinfo) 2869 if (!retinfo)
2780 return (-EFAULT); 2870 return -EFAULT;
2781 memset(&tmp, 0, sizeof(tmp)); 2871 memset(&tmp, 0, sizeof(tmp));
2782 tmp.type = info->type; 2872 tmp.type = info->type;
2783 tmp.line = info->port; 2873 tmp.line = info->port;
@@ -2791,7 +2881,7 @@ static int mxser_get_serial_info(struct mxser_struct *info, struct serial_struct
2791 tmp.hub6 = 0; 2881 tmp.hub6 = 0;
2792 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 2882 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2793 return -EFAULT; 2883 return -EFAULT;
2794 return (0); 2884 return 0;
2795} 2885}
2796 2886
2797static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info) 2887static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct __user *new_info)
@@ -2801,29 +2891,37 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2801 int retval = 0; 2891 int retval = 0;
2802 2892
2803 if (!new_info || !info->base) 2893 if (!new_info || !info->base)
2804 return (-EFAULT); 2894 return -EFAULT;
2805 if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2895 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
2806 return -EFAULT; 2896 return -EFAULT;
2807 2897
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)) 2898 if ((new_serial.irq != info->irq) ||
2809 return (-EPERM); 2899 (new_serial.port != info->base) ||
2900 (new_serial.custom_divisor != info->custom_divisor) ||
2901 (new_serial.baud_base != info->baud_base))
2902 return -EPERM;
2810 2903
2811 flags = info->flags & ASYNC_SPD_MASK; 2904 flags = info->flags & ASYNC_SPD_MASK;
2812 2905
2813 if (!capable(CAP_SYS_ADMIN)) { 2906 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))) 2907 if ((new_serial.baud_base != info->baud_base) ||
2815 return (-EPERM); 2908 (new_serial.close_delay != info->close_delay) ||
2816 info->flags = ((info->flags & ~ASYNC_USR_MASK) | (new_serial.flags & ASYNC_USR_MASK)); 2909 ((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
2910 return -EPERM;
2911 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
2912 (new_serial.flags & ASYNC_USR_MASK));
2817 } else { 2913 } else {
2818 /* 2914 /*
2819 * OK, past this point, all the error checking has been done. 2915 * OK, past this point, all the error checking has been done.
2820 * At this point, we start making changes..... 2916 * At this point, we start making changes.....
2821 */ 2917 */
2822 info->flags = ((info->flags & ~ASYNC_FLAGS) | (new_serial.flags & ASYNC_FLAGS)); 2918 info->flags = ((info->flags & ~ASYNC_FLAGS) |
2919 (new_serial.flags & ASYNC_FLAGS));
2823 info->close_delay = new_serial.close_delay * HZ / 100; 2920 info->close_delay = new_serial.close_delay * HZ / 100;
2824 info->closing_wait = new_serial.closing_wait * HZ / 100; 2921 info->closing_wait = new_serial.closing_wait * HZ / 100;
2825 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 2922 info->tty->low_latency =
2826 info->tty->low_latency = 0; //(info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 2923 (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
2924 info->tty->low_latency = 0; /* (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; */
2827 } 2925 }
2828 2926
2829 /* added by casper, 3/17/2000, for mouse */ 2927 /* added by casper, 3/17/2000, for mouse */
@@ -2831,7 +2929,6 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2831 2929
2832 process_txrx_fifo(info); 2930 process_txrx_fifo(info);
2833 2931
2834 /* */
2835 if (info->flags & ASYNC_INITIALIZED) { 2932 if (info->flags & ASYNC_INITIALIZED) {
2836 if (flags != (info->flags & ASYNC_SPD_MASK)) { 2933 if (flags != (info->flags & ASYNC_SPD_MASK)) {
2837 mxser_change_speed(info, NULL); 2934 mxser_change_speed(info, NULL);
@@ -2839,7 +2936,7 @@ static int mxser_set_serial_info(struct mxser_struct *info, struct serial_struct
2839 } else { 2936 } else {
2840 retval = mxser_startup(info); 2937 retval = mxser_startup(info);
2841 } 2938 }
2842 return (retval); 2939 return retval;
2843} 2940}
2844 2941
2845/* 2942/*
@@ -2876,25 +2973,27 @@ static void mxser_send_break(struct mxser_struct *info, int duration)
2876 return; 2973 return;
2877 set_current_state(TASK_INTERRUPTIBLE); 2974 set_current_state(TASK_INTERRUPTIBLE);
2878 spin_lock_irqsave(&info->slock, flags); 2975 spin_lock_irqsave(&info->slock, flags);
2879 outb(inb(info->base + UART_LCR) | UART_LCR_SBC, info->base + UART_LCR); 2976 outb(inb(info->base + UART_LCR) | UART_LCR_SBC,
2977 info->base + UART_LCR);
2880 spin_unlock_irqrestore(&info->slock, flags); 2978 spin_unlock_irqrestore(&info->slock, flags);
2881 schedule_timeout(duration); 2979 schedule_timeout(duration);
2882 spin_lock_irqsave(&info->slock, flags); 2980 spin_lock_irqsave(&info->slock, flags);
2883 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC, info->base + UART_LCR); 2981 outb(inb(info->base + UART_LCR) & ~UART_LCR_SBC,
2982 info->base + UART_LCR);
2884 spin_unlock_irqrestore(&info->slock, flags); 2983 spin_unlock_irqrestore(&info->slock, flags);
2885} 2984}
2886 2985
2887static int mxser_tiocmget(struct tty_struct *tty, struct file *file) 2986static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2888{ 2987{
2889 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 2988 struct mxser_struct *info = tty->driver_data;
2890 unsigned char control, status; 2989 unsigned char control, status;
2891 unsigned long flags; 2990 unsigned long flags;
2892 2991
2893 2992
2894 if (tty->index == MXSER_PORTS) 2993 if (tty->index == MXSER_PORTS)
2895 return (-ENOIOCTLCMD); 2994 return -ENOIOCTLCMD;
2896 if (tty->flags & (1 << TTY_IO_ERROR)) 2995 if (tty->flags & (1 << TTY_IO_ERROR))
2897 return (-EIO); 2996 return -EIO;
2898 2997
2899 control = info->MCR; 2998 control = info->MCR;
2900 2999
@@ -2904,12 +3003,16 @@ static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
2904 mxser_check_modem_status(info, status); 3003 mxser_check_modem_status(info, status);
2905 spin_unlock_irqrestore(&info->slock, flags); 3004 spin_unlock_irqrestore(&info->slock, flags);
2906 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) | 3005 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); 3006 ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) |
3007 ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) |
3008 ((status & UART_MSR_RI) ? TIOCM_RNG : 0) |
3009 ((status & UART_MSR_DSR) ? TIOCM_DSR : 0) |
3010 ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
2908} 3011}
2909 3012
2910static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) 3013static int mxser_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear)
2911{ 3014{
2912 struct mxser_struct *info = (struct mxser_struct *) tty->driver_data; 3015 struct mxser_struct *info = tty->driver_data;
2913 unsigned long flags; 3016 unsigned long flags;
2914 3017
2915 3018
@@ -2968,38 +3071,36 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
2968 hwconf->board_type = MXSER_BOARD_CI104J; 3071 hwconf->board_type = MXSER_BOARD_CI104J;
2969 hwconf->ports = 4; 3072 hwconf->ports = 4;
2970 } else 3073 } else
2971 return (0); 3074 return 0;
2972 3075
2973 irq = 0; 3076 irq = 0;
2974 if (hwconf->ports == 2) { 3077 if (hwconf->ports == 2) {
2975 irq = regs[9] & 0xF000; 3078 irq = regs[9] & 0xF000;
2976 irq = irq | (irq >> 4); 3079 irq = irq | (irq >> 4);
2977 if (irq != (regs[9] & 0xFF00)) 3080 if (irq != (regs[9] & 0xFF00))
2978 return (MXSER_ERR_IRQ_CONFLIT); 3081 return MXSER_ERR_IRQ_CONFLIT;
2979 } else if (hwconf->ports == 4) { 3082 } else if (hwconf->ports == 4) {
2980 irq = regs[9] & 0xF000; 3083 irq = regs[9] & 0xF000;
2981 irq = irq | (irq >> 4); 3084 irq = irq | (irq >> 4);
2982 irq = irq | (irq >> 8); 3085 irq = irq | (irq >> 8);
2983 if (irq != regs[9]) 3086 if (irq != regs[9])
2984 return (MXSER_ERR_IRQ_CONFLIT); 3087 return MXSER_ERR_IRQ_CONFLIT;
2985 } else if (hwconf->ports == 8) { 3088 } else if (hwconf->ports == 8) {
2986 irq = regs[9] & 0xF000; 3089 irq = regs[9] & 0xF000;
2987 irq = irq | (irq >> 4); 3090 irq = irq | (irq >> 4);
2988 irq = irq | (irq >> 8); 3091 irq = irq | (irq >> 8);
2989 if ((irq != regs[9]) || (irq != regs[10])) 3092 if ((irq != regs[9]) || (irq != regs[10]))
2990 return (MXSER_ERR_IRQ_CONFLIT); 3093 return MXSER_ERR_IRQ_CONFLIT;
2991 } 3094 }
2992 3095
2993 if (!irq) { 3096 if (!irq)
2994 return (MXSER_ERR_IRQ); 3097 return MXSER_ERR_IRQ;
2995 } 3098 hwconf->irq = ((int)(irq & 0xF000) >> 12);
2996 hwconf->irq = ((int) (irq & 0xF000) >> 12);
2997 for (i = 0; i < 8; i++) 3099 for (i = 0; i < 8; i++)
2998 hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8; 3100 hwconf->ioaddr[i] = (int) regs[i + 1] & 0xFFF8;
2999 if ((regs[12] & 0x80) == 0) { 3101 if ((regs[12] & 0x80) == 0)
3000 return (MXSER_ERR_VECTOR); 3102 return MXSER_ERR_VECTOR;
3001 } 3103 hwconf->vector = (int)regs[11]; /* interrupt vector */
3002 hwconf->vector = (int) regs[11]; /* interrupt vector */
3003 if (id == 1) 3104 if (id == 1)
3004 hwconf->vector_mask = 0x00FF; 3105 hwconf->vector_mask = 0x00FF;
3005 else 3106 else
@@ -3007,10 +3108,10 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3007 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) { 3108 for (i = 7, bits = 0x0100; i >= 0; i--, bits <<= 1) {
3008 if (regs[12] & bits) { 3109 if (regs[12] & bits) {
3009 hwconf->baud_base[i] = 921600; 3110 hwconf->baud_base[i] = 921600;
3010 hwconf->MaxCanSetBaudRate[i] = 921600; // add by Victor Yu. 09-04-2002 3111 hwconf->MaxCanSetBaudRate[i] = 921600; /* add by Victor Yu. 09-04-2002 */
3011 } else { 3112 } else {
3012 hwconf->baud_base[i] = 115200; 3113 hwconf->baud_base[i] = 115200;
3013 hwconf->MaxCanSetBaudRate[i] = 115200; // add by Victor Yu. 09-04-2002 3114 hwconf->MaxCanSetBaudRate[i] = 115200; /* add by Victor Yu. 09-04-2002 */
3014 } 3115 }
3015 } 3116 }
3016 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB); 3117 scratch2 = inb(cap + UART_LCR) & (~UART_LCR_DLAB);
@@ -3030,7 +3131,7 @@ static int mxser_get_ISA_conf(int cap, struct mxser_hwconf *hwconf)
3030 hwconf->ports = 4; 3131 hwconf->ports = 4;
3031 request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)"); 3132 request_region(hwconf->ioaddr[0], 8 * hwconf->ports, "mxser(IO)");
3032 request_region(hwconf->vector, 1, "mxser(vector)"); 3133 request_region(hwconf->vector, 1, "mxser(vector)");
3033 return (hwconf->ports); 3134 return hwconf->ports;
3034} 3135}
3035 3136
3036#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */ 3137#define CHIP_SK 0x01 /* Serial Data Clock in Eprom */
@@ -3053,7 +3154,7 @@ static int mxser_read_register(int port, unsigned short *regs)
3053 3154
3054 id = mxser_program_mode(port); 3155 id = mxser_program_mode(port);
3055 if (id < 0) 3156 if (id < 0)
3056 return (id); 3157 return id;
3057 for (i = 0; i < 14; i++) { 3158 for (i = 0; i < 14; i++) {
3058 k = (i & 0x3F) | 0x180; 3159 k = (i & 0x3F) | 0x180;
3059 for (j = 0x100; j > 0; j >>= 1) { 3160 for (j = 0x100; j > 0; j >>= 1) {
@@ -3066,7 +3167,7 @@ static int mxser_read_register(int port, unsigned short *regs)
3066 outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */ 3167 outb(CHIP_CS | CHIP_SK, port); /* A? bit of read */
3067 } 3168 }
3068 } 3169 }
3069 (void) inb(port); 3170 (void)inb(port);
3070 value = 0; 3171 value = 0;
3071 for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) { 3172 for (k = 0, j = 0x8000; k < 16; k++, j >>= 1) {
3072 outb(CHIP_CS, port); 3173 outb(CHIP_CS, port);
@@ -3078,28 +3179,33 @@ static int mxser_read_register(int port, unsigned short *regs)
3078 outb(0, port); 3179 outb(0, port);
3079 } 3180 }
3080 mxser_normal_mode(port); 3181 mxser_normal_mode(port);
3081 return (id); 3182 return id;
3082} 3183}
3083 3184
3084static int mxser_program_mode(int port) 3185static int mxser_program_mode(int port)
3085{ 3186{
3086 int id, i, j, n; 3187 int id, i, j, n;
3087 //unsigned long flags; 3188 /* unsigned long flags; */
3088 3189
3089 spin_lock(&gm_lock); 3190 spin_lock(&gm_lock);
3090 outb(0, port); 3191 outb(0, port);
3091 outb(0, port); 3192 outb(0, port);
3092 outb(0, port); 3193 outb(0, port);
3093 (void) inb(port); 3194 (void)inb(port);
3094 (void) inb(port); 3195 (void)inb(port);
3095 outb(0, port); 3196 outb(0, port);
3096 (void) inb(port); 3197 (void)inb(port);
3097 //restore_flags(flags); 3198 /* restore_flags(flags); */
3098 spin_unlock(&gm_lock); 3199 spin_unlock(&gm_lock);
3099 3200
3100 id = inb(port + 1) & 0x1F; 3201 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)) 3202 if ((id != C168_ASIC_ID) &&
3102 return (-1); 3203 (id != C104_ASIC_ID) &&
3204 (id != C102_ASIC_ID) &&
3205 (id != CI132_ASIC_ID) &&
3206 (id != CI134_ASIC_ID) &&
3207 (id != CI104J_ASIC_ID))
3208 return -1;
3103 for (i = 0, j = 0; i < 4; i++) { 3209 for (i = 0, j = 0; i < 4; i++) {
3104 n = inb(port + 2); 3210 n = inb(port + 2);
3105 if (n == 'M') { 3211 if (n == 'M') {
@@ -3112,7 +3218,7 @@ static int mxser_program_mode(int port)
3112 } 3218 }
3113 if (j != 2) 3219 if (j != 2)
3114 id = -2; 3220 id = -2;
3115 return (id); 3221 return id;
3116} 3222}
3117 3223
3118static void mxser_normal_mode(int port) 3224static void mxser_normal_mode(int port)
@@ -3130,7 +3236,7 @@ static void mxser_normal_mode(int port)
3130 if ((n & 0x61) == 0x60) 3236 if ((n & 0x61) == 0x60)
3131 break; 3237 break;
3132 if ((n & 1) == 1) 3238 if ((n & 1) == 1)
3133 (void) inb(port); 3239 (void)inb(port);
3134 } 3240 }
3135 outb(0x00, port + 4); 3241 outb(0x00, port + 4);
3136} 3242}
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 ede365d05387..b9371d5bf790 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1384,8 +1384,10 @@ do_it_again:
1384 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, 1384 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
1385 * we won't get any more characters. 1385 * we won't get any more characters.
1386 */ 1386 */
1387 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) 1387 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) {
1388 n_tty_set_room(tty);
1388 check_unthrottle(tty); 1389 check_unthrottle(tty);
1390 }
1389 1391
1390 if (b - buf >= minimum) 1392 if (b - buf >= minimum)
1391 break; 1393 break;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 128b2632512d..eab5394da666 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -149,7 +149,7 @@ struct cm4000_dev {
149#define ZERO_DEV(dev) \ 149#define ZERO_DEV(dev) \
150 memset(&dev->atr_csum,0, \ 150 memset(&dev->atr_csum,0, \
151 sizeof(struct cm4000_dev) - \ 151 sizeof(struct cm4000_dev) - \
152 /*link*/ sizeof(struct pcmcia_device) - \ 152 /*link*/ sizeof(struct pcmcia_device *) - \
153 /*node*/ sizeof(dev_node_t) - \ 153 /*node*/ sizeof(dev_node_t) - \
154 /*atr*/ MAX_ATR*sizeof(char) - \ 154 /*atr*/ MAX_ATR*sizeof(char) - \
155 /*rbuf*/ 512*sizeof(char) - \ 155 /*rbuf*/ 512*sizeof(char) - \
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/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..eec1fea0cb92 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
@@ -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/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..1b5330299e30 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 }
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/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index e45f0d3d12de..a611972024e6 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -105,6 +105,12 @@ static const char* tcpa_event_type_strings[] = {
105 "Non-Host Info" 105 "Non-Host Info"
106}; 106};
107 107
108struct tcpa_pc_event {
109 u32 event_id;
110 u32 event_size;
111 u8 event_data[0];
112};
113
108enum tcpa_pc_event_ids { 114enum tcpa_pc_event_ids {
109 SMBIOS = 1, 115 SMBIOS = 1,
110 BIS_CERT, 116 BIS_CERT,
@@ -114,14 +120,15 @@ enum tcpa_pc_event_ids {
114 NVRAM, 120 NVRAM,
115 OPTION_ROM_EXEC, 121 OPTION_ROM_EXEC,
116 OPTION_ROM_CONFIG, 122 OPTION_ROM_CONFIG,
117 OPTION_ROM_MICROCODE, 123 OPTION_ROM_MICROCODE = 10,
118 S_CRTM_VERSION, 124 S_CRTM_VERSION,
119 S_CRTM_CONTENTS, 125 S_CRTM_CONTENTS,
120 POST_CONTENTS, 126 POST_CONTENTS,
127 HOST_TABLE_OF_DEVICES,
121}; 128};
122 129
123static const char* tcpa_pc_event_id_strings[] = { 130static const char* tcpa_pc_event_id_strings[] = {
124 "" 131 "",
125 "SMBIOS", 132 "SMBIOS",
126 "BIS Certificate", 133 "BIS Certificate",
127 "POST BIOS ", 134 "POST BIOS ",
@@ -130,11 +137,12 @@ static const char* tcpa_pc_event_id_strings[] = {
130 "NVRAM", 137 "NVRAM",
131 "Option ROM", 138 "Option ROM",
132 "Option ROM config", 139 "Option ROM config",
133 "Option ROM microcode", 140 "",
141 "Option ROM microcode ",
134 "S-CRTM Version", 142 "S-CRTM Version",
135 "S-CRTM Contents", 143 "S-CRTM Contents ",
136 "S-CRTM POST Contents", 144 "POST Contents ",
137 "POST Contents", 145 "Table of Devices",
138}; 146};
139 147
140/* returns pointer to start of pos. entry of tcg log */ 148/* returns pointer to start of pos. entry of tcg log */
@@ -206,7 +214,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,
206 const char *name = ""; 214 const char *name = "";
207 char data[40] = ""; 215 char data[40] = "";
208 int i, n_len = 0, d_len = 0; 216 int i, n_len = 0, d_len = 0;
209 u32 event_id; 217 struct tcpa_pc_event *pc_event;
210 218
211 switch(event->event_type) { 219 switch(event->event_type) {
212 case PREBOOT: 220 case PREBOOT:
@@ -235,31 +243,32 @@ static int get_event_name(char *dest, struct tcpa_event *event,
235 } 243 }
236 break; 244 break;
237 case EVENT_TAG: 245 case EVENT_TAG:
238 event_id = be32_to_cpu(*((u32 *)event_entry)); 246 pc_event = (struct tcpa_pc_event *)event_entry;
239 247
240 /* ToDo Row data -> Base64 */ 248 /* ToDo Row data -> Base64 */
241 249
242 switch (event_id) { 250 switch (pc_event->event_id) {
243 case SMBIOS: 251 case SMBIOS:
244 case BIS_CERT: 252 case BIS_CERT:
245 case CMOS: 253 case CMOS:
246 case NVRAM: 254 case NVRAM:
247 case OPTION_ROM_EXEC: 255 case OPTION_ROM_EXEC:
248 case OPTION_ROM_CONFIG: 256 case OPTION_ROM_CONFIG:
249 case OPTION_ROM_MICROCODE:
250 case S_CRTM_VERSION: 257 case S_CRTM_VERSION:
251 case S_CRTM_CONTENTS: 258 name = tcpa_pc_event_id_strings[pc_event->event_id];
252 case POST_CONTENTS:
253 name = tcpa_pc_event_id_strings[event_id];
254 n_len = strlen(name); 259 n_len = strlen(name);
255 break; 260 break;
261 /* hash data */
256 case POST_BIOS_ROM: 262 case POST_BIOS_ROM:
257 case ESCD: 263 case ESCD:
258 name = tcpa_pc_event_id_strings[event_id]; 264 case OPTION_ROM_MICROCODE:
265 case S_CRTM_CONTENTS:
266 case POST_CONTENTS:
267 name = tcpa_pc_event_id_strings[pc_event->event_id];
259 n_len = strlen(name); 268 n_len = strlen(name);
260 for (i = 0; i < 20; i++) 269 for (i = 0; i < 20; i++)
261 d_len += sprintf(data, "%02x", 270 d_len += sprintf(&data[2*i], "%02x",
262 event_entry[8 + i]); 271 pc_event->event_data[i]);
263 break; 272 break;
264 default: 273 default:
265 break; 274 break;
@@ -275,53 +284,13 @@ static int get_event_name(char *dest, struct tcpa_event *event,
275 284
276static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) 285static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
277{ 286{
287 struct tcpa_event *event = v;
288 char *data = v;
289 int i;
278 290
279 char *eventname; 291 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
280 char data[4];
281 u32 help;
282 int i, len;
283 struct tcpa_event *event = (struct tcpa_event *) v;
284 unsigned char *event_entry =
285 (unsigned char *) (v + sizeof(struct tcpa_event));
286
287 eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
288 if (!eventname) {
289 printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
290 __func__);
291 return -ENOMEM;
292 }
293
294 /* 1st: PCR used is in little-endian format (4 bytes) */
295 help = le32_to_cpu(event->pcr_index);
296 memcpy(data, &help, 4);
297 for (i = 0; i < 4; i++)
298 seq_putc(m, data[i]);
299
300 /* 2nd: SHA1 (20 bytes) */
301 for (i = 0; i < 20; i++)
302 seq_putc(m, event->pcr_value[i]);
303
304 /* 3rd: event type identifier (4 bytes) */
305 help = le32_to_cpu(event->event_type);
306 memcpy(data, &help, 4);
307 for (i = 0; i < 4; i++)
308 seq_putc(m, data[i]); 292 seq_putc(m, data[i]);
309 293
310 len = 0;
311
312 len += get_event_name(eventname, event, event_entry);
313
314 /* 4th: filename <= 255 + \'0' delimiter */
315 if (len > TCG_EVENT_NAME_LEN_MAX)
316 len = TCG_EVENT_NAME_LEN_MAX;
317
318 for (i = 0; i < len; i++)
319 seq_putc(m, eventname[i]);
320
321 /* 5th: delimiter */
322 seq_putc(m, '\0');
323
324 kfree(eventname);
325 return 0; 294 return 0;
326} 295}
327 296
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a88b94a82b14..8b2a59969868 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2961,12 +2961,14 @@ static struct class *tty_class;
2961 * This field is optional, if there is no known struct device for this 2961 * This field is optional, if there is no known struct device for this
2962 * tty device it can be set to NULL safely. 2962 * tty device it can be set to NULL safely.
2963 * 2963 *
2964 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error).
2965 *
2964 * This call is required to be made to register an individual tty device if 2966 * 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 2967 * 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. 2968 * bit is not set, this function should not be called.
2967 */ 2969 */
2968void tty_register_device(struct tty_driver *driver, unsigned index, 2970struct class_device *tty_register_device(struct tty_driver *driver,
2969 struct device *device) 2971 unsigned index, struct device *device)
2970{ 2972{
2971 char name[64]; 2973 char name[64];
2972 dev_t dev = MKDEV(driver->major, driver->minor_start) + index; 2974 dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -2974,7 +2976,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2974 if (index >= driver->num) { 2976 if (index >= driver->num) {
2975 printk(KERN_ERR "Attempt to register invalid tty line number " 2977 printk(KERN_ERR "Attempt to register invalid tty line number "
2976 " (%d).\n", index); 2978 " (%d).\n", index);
2977 return; 2979 return ERR_PTR(-EINVAL);
2978 } 2980 }
2979 2981
2980 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 2982 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
@@ -2984,7 +2986,8 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2984 pty_line_name(driver, index, name); 2986 pty_line_name(driver, index, name);
2985 else 2987 else
2986 tty_line_name(driver, index, name); 2988 tty_line_name(driver, index, name);
2987 class_device_create(tty_class, NULL, dev, device, "%s", name); 2989
2990 return class_device_create(tty_class, NULL, dev, device, "%s", name);
2988} 2991}
2989 2992
2990/** 2993/**
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/vt.c b/drivers/char/vt.c
index acc5d47844eb..6c94879e0b99 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -3238,14 +3238,6 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
3238 } 3238 }
3239} 3239}
3240 3240
3241int is_console_suspend_safe(void)
3242{
3243 /* It is unsafe to suspend devices while X has control of the
3244 * hardware. Make sure we are running on a kernel-controlled console.
3245 */
3246 return vc_cons[fg_console].d->vc_mode == KD_TEXT;
3247}
3248
3249/* 3241/*
3250 * Visible symbols for modules 3242 * Visible symbols for modules
3251 */ 3243 */