aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig22
-rw-r--r--drivers/char/Makefile91
-rw-r--r--drivers/char/agp/Kconfig4
-rw-r--r--drivers/char/agp/agp.h11
-rw-r--r--drivers/char/agp/ali-agp.c2
-rw-r--r--drivers/char/agp/alpha-agp.c14
-rw-r--r--drivers/char/agp/amd64-agp.c4
-rw-r--r--drivers/char/agp/ati-agp.c10
-rw-r--r--drivers/char/agp/backend.c2
-rw-r--r--drivers/char/agp/efficeon-agp.c16
-rw-r--r--drivers/char/agp/frontend.c2
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/hp-agp.c6
-rw-r--r--drivers/char/agp/i460-agp.c16
-rw-r--r--drivers/char/agp/intel-agp.c45
-rw-r--r--drivers/char/agp/isoch.c20
-rw-r--r--drivers/char/agp/nvidia-agp.c23
-rw-r--r--drivers/char/agp/sgi-agp.c2
-rw-r--r--drivers/char/agp/sis-agp.c8
-rw-r--r--drivers/char/agp/sworks-agp.c15
-rw-r--r--drivers/char/agp/uninorth-agp.c12
-rw-r--r--drivers/char/amiserial.c18
-rw-r--r--drivers/char/drm/drm_fops.c2
-rw-r--r--drivers/char/drm/drm_vm.c1
-rw-r--r--drivers/char/drm/i810_dma.c2
-rw-r--r--drivers/char/drm/i830_dma.c2
-rw-r--r--drivers/char/epca.c3
-rw-r--r--drivers/char/ftape/lowlevel/fdc-io.c2
-rw-r--r--drivers/char/generic_nvram.c5
-rw-r--r--drivers/char/generic_serial.c14
-rw-r--r--drivers/char/hvc_console.c101
-rw-r--r--drivers/char/hvc_console.h63
-rw-r--r--drivers/char/hvc_rtas.c138
-rw-r--r--drivers/char/hvc_vio.c11
-rw-r--r--drivers/char/hvcs.c10
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c48
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c570
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c6
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c1064
-rw-r--r--drivers/char/ipmi/ipmi_si_sm.h3
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c8
-rw-r--r--drivers/char/istallion.c9
-rw-r--r--drivers/char/mem.c48
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/mxser.c8
-rw-r--r--drivers/char/mxser.h2
-rw-r--r--drivers/char/n_tty.c10
-rw-r--r--drivers/char/nwflash.c11
-rw-r--r--drivers/char/pcmcia/synclink_cs.c2
-rw-r--r--drivers/char/ppdev.c3
-rw-r--r--drivers/char/raw.c23
-rw-r--r--drivers/char/rio/Makefile2
-rw-r--r--drivers/char/rio/board.h58
-rw-r--r--drivers/char/rio/bootpkt.h61
-rw-r--r--drivers/char/rio/cirrus.h110
-rw-r--r--drivers/char/rio/cmdblk.h4
-rw-r--r--drivers/char/rio/cmdpkt.h94
-rw-r--r--drivers/char/rio/control.h61
-rw-r--r--drivers/char/rio/daemon.h67
-rw-r--r--drivers/char/rio/defaults.h51
-rw-r--r--drivers/char/rio/error.h82
-rw-r--r--drivers/char/rio/func.h52
-rw-r--r--drivers/char/rio/host.h56
-rw-r--r--drivers/char/rio/link.h124
-rw-r--r--drivers/char/rio/linux_compat.h45
-rw-r--r--drivers/char/rio/list.h56
-rw-r--r--drivers/char/rio/map.h12
-rw-r--r--drivers/char/rio/param.h24
-rw-r--r--drivers/char/rio/parmmap.h68
-rw-r--r--drivers/char/rio/phb.h39
-rw-r--r--drivers/char/rio/pkt.h24
-rw-r--r--drivers/char/rio/port.h250
-rw-r--r--drivers/char/rio/qbuf.h62
-rw-r--r--drivers/char/rio/rio.h173
-rw-r--r--drivers/char/rio/rio_linux.c139
-rw-r--r--drivers/char/rio/rioboot.c1688
-rw-r--r--drivers/char/rio/riocmd.c176
-rw-r--r--drivers/char/rio/rioctrl.c401
-rw-r--r--drivers/char/rio/riodrvr.h48
-rw-r--r--drivers/char/rio/rioinit.c199
-rw-r--r--drivers/char/rio/riointr.c320
-rw-r--r--drivers/char/rio/rioparam.c129
-rw-r--r--drivers/char/rio/riopcicopy.c8
-rw-r--r--drivers/char/rio/rioroute.c166
-rw-r--r--drivers/char/rio/riotable.c123
-rw-r--r--drivers/char/rio/riotty.c198
-rw-r--r--drivers/char/rio/riotypes.h68
-rw-r--r--drivers/char/rio/rom.h62
-rw-r--r--drivers/char/rio/rup.h25
-rw-r--r--drivers/char/rio/sam.h67
-rw-r--r--drivers/char/rio/space.h45
-rw-r--r--drivers/char/rio/top.h48
-rw-r--r--drivers/char/rio/typdef.h82
-rw-r--r--drivers/char/rio/unixrup.h6
-rw-r--r--drivers/char/riscom8.c8
-rw-r--r--drivers/char/ser_a2232.c4
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc_event.c5
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink.c35
-rw-r--r--drivers/char/synclink_gt.c252
-rw-r--r--drivers/char/synclinkmp.c2
-rw-r--r--drivers/char/sysrq.c250
-rw-r--r--drivers/char/tb0219.c24
-rw-r--r--drivers/char/tlclk.c1
-rw-r--r--drivers/char/toshiba.c38
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tty_io.c85
-rw-r--r--drivers/char/vme_scc.c2
-rw-r--r--drivers/char/vr41xx_giu.c19
-rw-r--r--drivers/char/vr41xx_rtc.c30
-rw-r--r--drivers/char/vt.c22
-rw-r--r--drivers/char/watchdog/Kconfig10
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/ep93xx_wdt.c257
-rw-r--r--drivers/char/watchdog/mv64x60_wdt.c20
-rw-r--r--drivers/char/watchdog/pcwd_usb.c7
118 files changed, 4261 insertions, 4912 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 05ba410682a3..889cad07774e 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -187,6 +187,7 @@ config MOXA_SMARTIO
187config ISI 187config ISI
188 tristate "Multi-Tech multiport card support (EXPERIMENTAL)" 188 tristate "Multi-Tech multiport card support (EXPERIMENTAL)"
189 depends on SERIAL_NONSTANDARD 189 depends on SERIAL_NONSTANDARD
190 select FW_LOADER
190 help 191 help
191 This is a driver for the Multi-Tech cards which provide several 192 This is a driver for the Multi-Tech cards which provide several
192 serial ports. The driver is experimental and can currently only be 193 serial ports. The driver is experimental and can currently only be
@@ -290,7 +291,7 @@ config SX
290 291
291config RIO 292config RIO
292 tristate "Specialix RIO system support" 293 tristate "Specialix RIO system support"
293 depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && !64BIT 294 depends on SERIAL_NONSTANDARD && !64BIT
294 help 295 help
295 This is a driver for the Specialix RIO, a smart serial card which 296 This is a driver for the Specialix RIO, a smart serial card which
296 drives an outboard box that can support up to 128 ports. Product 297 drives an outboard box that can support up to 128 ports. Product
@@ -560,14 +561,31 @@ config TIPAR
560 561
561 If unsure, say N. 562 If unsure, say N.
562 563
564config HVC_DRIVER
565 bool
566 help
567 Users of pSeries machines that want to utilize the hvc console front-end
568 module for their backend console driver should select this option.
569 It will automatically be selected if one of the back-end console drivers
570 is selected.
571
572
563config HVC_CONSOLE 573config HVC_CONSOLE
564 bool "pSeries Hypervisor Virtual Console support" 574 bool "pSeries Hypervisor Virtual Console support"
565 depends on PPC_PSERIES 575 depends on PPC_PSERIES
576 select HVC_DRIVER
566 help 577 help
567 pSeries machines when partitioned support a hypervisor virtual 578 pSeries machines when partitioned support a hypervisor virtual
568 console. This driver allows each pSeries partition to have a console 579 console. This driver allows each pSeries partition to have a console
569 which is accessed via the HMC. 580 which is accessed via the HMC.
570 581
582config HVC_RTAS
583 bool "IBM RTAS Console support"
584 depends on PPC_RTAS
585 select HVC_DRIVER
586 help
587 IBM Console device driver which makes use of RTAS
588
571config HVCS 589config HVCS
572 tristate "IBM Hypervisor Virtual Console Server support" 590 tristate "IBM Hypervisor Virtual Console Server support"
573 depends on PPC_PSERIES 591 depends on PPC_PSERIES
@@ -695,7 +713,7 @@ config NVRAM
695 713
696config RTC 714config RTC
697 tristate "Enhanced Real Time Clock Support" 715 tristate "Enhanced Real Time Clock Support"
698 depends on !PPC32 && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV 716 depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM
699 ---help--- 717 ---help---
700 If you say Y here and create a character special file /dev/rtc with 718 If you say Y here and create a character special file /dev/rtc with
701 major number 10 and minor number 135 using mknod ("man mknod"), you 719 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 090d154098bb..a73cb4956928 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -41,60 +41,63 @@ 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_CONSOLE) += hvc_console.o hvc_vio.o hvsi.o 44obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
45obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
46obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
45obj-$(CONFIG_RAW_DRIVER) += raw.o 47obj-$(CONFIG_RAW_DRIVER) += raw.o
46obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 48obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
47obj-$(CONFIG_MMTIMER) += mmtimer.o 49obj-$(CONFIG_MMTIMER) += mmtimer.o
48obj-$(CONFIG_VIOCONS) += viocons.o 50obj-$(CONFIG_VIOCONS) += viocons.o
49obj-$(CONFIG_VIOTAPE) += viotape.o 51obj-$(CONFIG_VIOTAPE) += viotape.o
50obj-$(CONFIG_HVCS) += hvcs.o 52obj-$(CONFIG_HVCS) += hvcs.o
51obj-$(CONFIG_SGI_MBCS) += mbcs.o 53obj-$(CONFIG_SGI_MBCS) += mbcs.o
52 54
53obj-$(CONFIG_PRINTER) += lp.o 55obj-$(CONFIG_PRINTER) += lp.o
54obj-$(CONFIG_TIPAR) += tipar.o 56obj-$(CONFIG_TIPAR) += tipar.o
55 57
56obj-$(CONFIG_DTLK) += dtlk.o 58obj-$(CONFIG_DTLK) += dtlk.o
57obj-$(CONFIG_R3964) += n_r3964.o 59obj-$(CONFIG_R3964) += n_r3964.o
58obj-$(CONFIG_APPLICOM) += applicom.o 60obj-$(CONFIG_APPLICOM) += applicom.o
59obj-$(CONFIG_SONYPI) += sonypi.o 61obj-$(CONFIG_SONYPI) += sonypi.o
60obj-$(CONFIG_RTC) += rtc.o 62obj-$(CONFIG_RTC) += rtc.o
61obj-$(CONFIG_HPET) += hpet.o 63obj-$(CONFIG_HPET) += hpet.o
62obj-$(CONFIG_GEN_RTC) += genrtc.o 64obj-$(CONFIG_GEN_RTC) += genrtc.o
63obj-$(CONFIG_EFI_RTC) += efirtc.o 65obj-$(CONFIG_EFI_RTC) += efirtc.o
64obj-$(CONFIG_SGI_DS1286) += ds1286.o 66obj-$(CONFIG_SGI_DS1286) += ds1286.o
65obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o 67obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
66obj-$(CONFIG_DS1302) += ds1302.o 68obj-$(CONFIG_DS1302) += ds1302.o
67obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o 69obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
68obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o 70obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o
69ifeq ($(CONFIG_GENERIC_NVRAM),y) 71ifeq ($(CONFIG_GENERIC_NVRAM),y)
70 obj-$(CONFIG_NVRAM) += generic_nvram.o 72 obj-$(CONFIG_NVRAM) += generic_nvram.o
71else 73else
72 obj-$(CONFIG_NVRAM) += nvram.o 74 obj-$(CONFIG_NVRAM) += nvram.o
73endif 75endif
74obj-$(CONFIG_TOSHIBA) += toshiba.o 76obj-$(CONFIG_TOSHIBA) += toshiba.o
75obj-$(CONFIG_I8K) += i8k.o 77obj-$(CONFIG_I8K) += i8k.o
76obj-$(CONFIG_DS1620) += ds1620.o 78obj-$(CONFIG_DS1620) += ds1620.o
77obj-$(CONFIG_HW_RANDOM) += hw_random.o 79obj-$(CONFIG_HW_RANDOM) += hw_random.o
78obj-$(CONFIG_FTAPE) += ftape/ 80obj-$(CONFIG_FTAPE) += ftape/
79obj-$(CONFIG_COBALT_LCD) += lcd.o 81obj-$(CONFIG_COBALT_LCD) += lcd.o
80obj-$(CONFIG_PPDEV) += ppdev.o 82obj-$(CONFIG_PPDEV) += ppdev.o
81obj-$(CONFIG_NWBUTTON) += nwbutton.o 83obj-$(CONFIG_NWBUTTON) += nwbutton.o
82obj-$(CONFIG_NWFLASH) += nwflash.o 84obj-$(CONFIG_NWFLASH) += nwflash.o
83obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 85obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
84obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o 86obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
85obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o 87obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
86obj-$(CONFIG_TANBAC_TB0219) += tb0219.o 88obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
87obj-$(CONFIG_TELCLOCK) += tlclk.o 89obj-$(CONFIG_TELCLOCK) += tlclk.o
88 90
89obj-$(CONFIG_WATCHDOG) += watchdog/ 91obj-$(CONFIG_WATCHDOG) += watchdog/
90obj-$(CONFIG_MWAVE) += mwave/ 92obj-$(CONFIG_MWAVE) += mwave/
91obj-$(CONFIG_AGP) += agp/ 93obj-$(CONFIG_AGP) += agp/
92obj-$(CONFIG_DRM) += drm/ 94obj-$(CONFIG_DRM) += drm/
93obj-$(CONFIG_PCMCIA) += pcmcia/ 95obj-$(CONFIG_PCMCIA) += pcmcia/
94obj-$(CONFIG_IPMI_HANDLER) += ipmi/ 96obj-$(CONFIG_IPMI_HANDLER) += ipmi/
95 97
96obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o 98obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
97obj-$(CONFIG_TCG_TPM) += tpm/ 99obj-$(CONFIG_TCG_TPM) += tpm/
100
98# Files generated that shall be removed upon make clean 101# Files generated that shall be removed upon make clean
99clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c 102clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c
100 103
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index a4d425d2dce2..0b9cf9c59a21 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -98,12 +98,12 @@ config AGP_SWORKS
98 tristate "Serverworks LE/HE chipset support" 98 tristate "Serverworks LE/HE chipset support"
99 depends on AGP && X86_32 99 depends on AGP && X86_32
100 help 100 help
101 Say Y here to support the Serverworks AGP card. See 101 Say Y here to support the Serverworks AGP card. See
102 <http://www.serverworks.com/> for product descriptions and images. 102 <http://www.serverworks.com/> for product descriptions and images.
103 103
104config AGP_VIA 104config AGP_VIA
105 tristate "VIA chipset support" 105 tristate "VIA chipset support"
106 depends on AGP && X86_32 106 depends on AGP
107 help 107 help
108 This option gives you AGP support for the GLX component of 108 This option gives you AGP support for the GLX component of
109 X on VIA MVP3/Apollo Pro chipsets. 109 X on VIA MVP3/Apollo Pro chipsets.
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index b4af87c6f9c8..3c623b67ea1c 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -19,9 +19,9 @@
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 22 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * 26 *
27 */ 27 */
@@ -53,7 +53,7 @@ enum aper_size_type {
53struct gatt_mask { 53struct gatt_mask {
54 unsigned long mask; 54 unsigned long mask;
55 u32 type; 55 u32 type;
56 /* totally device specific, for integrated chipsets that 56 /* totally device specific, for integrated chipsets that
57 * might have different types of memory masks. For other 57 * might have different types of memory masks. For other
58 * devices this will probably be ignored */ 58 * devices this will probably be ignored */
59}; 59};
@@ -104,8 +104,7 @@ struct agp_bridge_driver {
104 void (*agp_enable)(struct agp_bridge_data *, u32); 104 void (*agp_enable)(struct agp_bridge_data *, u32);
105 void (*cleanup)(void); 105 void (*cleanup)(void);
106 void (*tlb_flush)(struct agp_memory *); 106 void (*tlb_flush)(struct agp_memory *);
107 unsigned long (*mask_memory)(struct agp_bridge_data *, 107 unsigned long (*mask_memory)(struct agp_bridge_data *, unsigned long, int);
108 unsigned long, int);
109 void (*cache_flush)(void); 108 void (*cache_flush)(void);
110 int (*create_gatt_table)(struct agp_bridge_data *); 109 int (*create_gatt_table)(struct agp_bridge_data *);
111 int (*free_gatt_table)(struct agp_bridge_data *); 110 int (*free_gatt_table)(struct agp_bridge_data *);
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index b02fc2267159..5a31ec7c62fc 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -147,7 +147,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge)
147 147
148 if (!addr) 148 if (!addr)
149 return NULL; 149 return NULL;
150 150
151 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 151 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
152 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 152 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
153 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 153 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index a072d32005a4..2b5838e64751 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -23,8 +23,9 @@ static struct page *alpha_core_agp_vm_nopage(struct vm_area_struct *vma,
23 dma_addr = address - vma->vm_start + agp->aperture.bus_base; 23 dma_addr = address - vma->vm_start + agp->aperture.bus_base;
24 pa = agp->ops->translate(agp, dma_addr); 24 pa = agp->ops->translate(agp, dma_addr);
25 25
26 if (pa == (unsigned long)-EINVAL) return NULL; /* no translation */ 26 if (pa == (unsigned long)-EINVAL)
27 27 return NULL; /* no translation */
28
28 /* 29 /*
29 * Get the page, inc the use count, and return it 30 * Get the page, inc the use count, and return it
30 */ 31 */
@@ -89,7 +90,7 @@ static void alpha_core_agp_enable(struct agp_bridge_data *bridge, u32 mode)
89 agp_device_command(agp->mode.lw, 0); 90 agp_device_command(agp->mode.lw, 0);
90} 91}
91 92
92static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start, 93static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
93 int type) 94 int type)
94{ 95{
95 alpha_agp_info *agp = agp_bridge->dev_private_data; 96 alpha_agp_info *agp = agp_bridge->dev_private_data;
@@ -98,7 +99,8 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
98 99
99 temp = agp_bridge->current_size; 100 temp = agp_bridge->current_size;
100 num_entries = A_SIZE_FIX(temp)->num_entries; 101 num_entries = A_SIZE_FIX(temp)->num_entries;
101 if ((pg_start + mem->page_count) > num_entries) return -EINVAL; 102 if ((pg_start + mem->page_count) > num_entries)
103 return -EINVAL;
102 104
103 status = agp->ops->bind(agp, pg_start, mem); 105 status = agp->ops->bind(agp, pg_start, mem);
104 mb(); 106 mb();
@@ -107,7 +109,7 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start,
107 return status; 109 return status;
108} 110}
109 111
110static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start, 112static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start,
111 int type) 113 int type)
112{ 114{
113 alpha_agp_info *agp = agp_bridge->dev_private_data; 115 alpha_agp_info *agp = agp_bridge->dev_private_data;
@@ -125,7 +127,7 @@ struct agp_bridge_driver alpha_core_agp_driver = {
125 .size_type = FIXED_APER_SIZE, 127 .size_type = FIXED_APER_SIZE,
126 .cant_use_aperture = 1, 128 .cant_use_aperture = 1,
127 .masks = NULL, 129 .masks = NULL,
128 130
129 .fetch_size = alpha_core_agp_fetch_size, 131 .fetch_size = alpha_core_agp_fetch_size,
130 .configure = alpha_core_agp_configure, 132 .configure = alpha_core_agp_configure,
131 .agp_enable = alpha_core_agp_enable, 133 .agp_enable = alpha_core_agp_enable,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 1251b2515bbe..36517d4d1ad9 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -216,7 +216,7 @@ static struct aper_size_info_32 amd_8151_sizes[7] =
216 {256, 65536, 6, 0x00000700 }, /* 1 1 1 0 0 0 */ 216 {256, 65536, 6, 0x00000700 }, /* 1 1 1 0 0 0 */
217 {128, 32768, 5, 0x00000720 }, /* 1 1 1 1 0 0 */ 217 {128, 32768, 5, 0x00000720 }, /* 1 1 1 1 0 0 */
218 {64, 16384, 4, 0x00000730 }, /* 1 1 1 1 1 0 */ 218 {64, 16384, 4, 0x00000730 }, /* 1 1 1 1 1 0 */
219 {32, 8192, 3, 0x00000738 } /* 1 1 1 1 1 1 */ 219 {32, 8192, 3, 0x00000738 } /* 1 1 1 1 1 1 */
220}; 220};
221 221
222static int amd_8151_configure(void) 222static int amd_8151_configure(void)
@@ -725,7 +725,7 @@ static struct pci_device_id agp_amd64_pci_table[] = {
725 .class = (PCI_CLASS_BRIDGE_HOST << 8), 725 .class = (PCI_CLASS_BRIDGE_HOST << 8),
726 .class_mask = ~0, 726 .class_mask = ~0,
727 .vendor = PCI_VENDOR_ID_AL, 727 .vendor = PCI_VENDOR_ID_AL,
728 .device = 0x1689, 728 .device = 0x1695,
729 .subvendor = PCI_ANY_ID, 729 .subvendor = PCI_ANY_ID,
730 .subdevice = PCI_ANY_ID, 730 .subdevice = PCI_ANY_ID,
731 }, 731 },
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 5b74c36c116c..06fd10ba0c5e 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -74,7 +74,7 @@ static int ati_create_page_map(ati_page_map *page_map)
74 /*CACHE_FLUSH();*/ 74 /*CACHE_FLUSH();*/
75 global_cache_flush(); 75 global_cache_flush();
76 76
77 for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) { 77 for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
78 writel(agp_bridge->scratch_page, page_map->remapped+i); 78 writel(agp_bridge->scratch_page, page_map->remapped+i);
79 readl(page_map->remapped+i); /* PCI Posting. */ 79 readl(page_map->remapped+i); /* PCI Posting. */
80 } 80 }
@@ -99,7 +99,7 @@ static void ati_free_gatt_pages(void)
99 ati_page_map *entry; 99 ati_page_map *entry;
100 100
101 tables = ati_generic_private.gatt_pages; 101 tables = ati_generic_private.gatt_pages;
102 for(i = 0; i < ati_generic_private.num_tables; i++) { 102 for (i = 0; i < ati_generic_private.num_tables; i++) {
103 entry = tables[i]; 103 entry = tables[i];
104 if (entry != NULL) { 104 if (entry != NULL) {
105 if (entry->real != NULL) 105 if (entry->real != NULL)
@@ -387,7 +387,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
387 agp_bridge->gart_bus_addr = addr; 387 agp_bridge->gart_bus_addr = addr;
388 388
389 /* Calculate the agp offset */ 389 /* Calculate the agp offset */
390 for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 390 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
391 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1, 391 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1,
392 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 392 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
393 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 393 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
@@ -466,6 +466,10 @@ static struct agp_device_ids ati_agp_device_ids[] __devinitdata =
466 .device_id = PCI_DEVICE_ID_ATI_RS300_200, 466 .device_id = PCI_DEVICE_ID_ATI_RS300_200,
467 .chipset_name = "IGP9100/M", 467 .chipset_name = "IGP9100/M",
468 }, 468 },
469 {
470 .device_id = PCI_DEVICE_ID_ATI_RS350_200,
471 .chipset_name = "IGP9100/M",
472 },
469 { }, /* dummy final entry, always present */ 473 { }, /* dummy final entry, always present */
470}; 474};
471 475
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 80ee17a8fc23..509adc403250 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -228,7 +228,7 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
228struct agp_bridge_data *agp_alloc_bridge(void) 228struct agp_bridge_data *agp_alloc_bridge(void)
229{ 229{
230 struct agp_bridge_data *bridge; 230 struct agp_bridge_data *bridge;
231 231
232 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); 232 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
233 if (!bridge) 233 if (!bridge)
234 return NULL; 234 return NULL;
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index e7aea77a60f9..fed0a87448d8 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Transmeta's Efficeon AGPGART driver. 2 * Transmeta's Efficeon AGPGART driver.
3 * 3 *
4 * Based upon a diff by Linus around November '02. 4 * Based upon a diff by Linus around November '02.
5 * 5 *
6 * Ported to the 2.6 kernel by Carlos Puchol <cpglinux@puchol.com> 6 * Ported to the 2.6 kernel by Carlos Puchol <cpglinux@puchol.com>
@@ -9,7 +9,7 @@
9 9
10/* 10/*
11 * NOTE-cpg-040217: 11 * NOTE-cpg-040217:
12 * 12 *
13 * - when compiled as a module, after loading the module, 13 * - when compiled as a module, after loading the module,
14 * it will refuse to unload, indicating it is in use, 14 * it will refuse to unload, indicating it is in use,
15 * when it is not. 15 * when it is not.
@@ -45,7 +45,7 @@
45 * 8: Present 45 * 8: Present
46 * 7:6: reserved, write as zero 46 * 7:6: reserved, write as zero
47 * 5:0: GATT directory index: which 1st-level entry 47 * 5:0: GATT directory index: which 1st-level entry
48 * 48 *
49 * The Efficeon AGP spec requires pages to be WB-cacheable 49 * The Efficeon AGP spec requires pages to be WB-cacheable
50 * but to be explicitly CLFLUSH'd after any changes. 50 * but to be explicitly CLFLUSH'd after any changes.
51 */ 51 */
@@ -125,7 +125,7 @@ static int efficeon_configure(void)
125 struct aper_size_info_lvl2 *current_size; 125 struct aper_size_info_lvl2 *current_size;
126 126
127 printk(KERN_DEBUG PFX "efficeon_configure()\n"); 127 printk(KERN_DEBUG PFX "efficeon_configure()\n");
128 128
129 current_size = A_SIZE_LVL2(agp_bridge->current_size); 129 current_size = A_SIZE_LVL2(agp_bridge->current_size);
130 130
131 /* aperture size */ 131 /* aperture size */
@@ -190,7 +190,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
190 const int present = EFFICEON_PRESENT; 190 const int present = EFFICEON_PRESENT;
191 const int clflush_chunk = ((cpuid_ebx(1) >> 8) & 0xff) << 3; 191 const int clflush_chunk = ((cpuid_ebx(1) >> 8) & 0xff) << 3;
192 int num_entries, l1_pages; 192 int num_entries, l1_pages;
193 193
194 num_entries = A_SIZE_LVL2(agp_bridge->current_size)->num_entries; 194 num_entries = A_SIZE_LVL2(agp_bridge->current_size)->num_entries;
195 195
196 printk(KERN_DEBUG PFX "efficeon_create_gatt_table(%d)\n", num_entries); 196 printk(KERN_DEBUG PFX "efficeon_create_gatt_table(%d)\n", num_entries);
@@ -257,12 +257,12 @@ static int efficeon_insert_memory(struct agp_memory * mem, off_t pg_start, int t
257 257
258 if (!page) 258 if (!page)
259 continue; 259 continue;
260 260
261 page += (index & 0x3ff); 261 page += (index & 0x3ff);
262 *page = insert; 262 *page = insert;
263 263
264 /* clflush is slow, so don't clflush until we have to */ 264 /* clflush is slow, so don't clflush until we have to */
265 if ( last_page && 265 if ( last_page &&
266 ((unsigned long)page^(unsigned long)last_page) & clflush_mask ) 266 ((unsigned long)page^(unsigned long)last_page) & clflush_mask )
267 asm volatile("clflush %0" : : "m" (*last_page)); 267 asm volatile("clflush %0" : : "m" (*last_page));
268 268
@@ -373,7 +373,7 @@ static int __devinit agp_efficeon_probe(struct pci_dev *pdev,
373 */ 373 */
374 r = &pdev->resource[0]; 374 r = &pdev->resource[0];
375 if (!r->start && r->end) { 375 if (!r->start && r->end) {
376 if(pci_assign_resource(pdev, 0)) { 376 if (pci_assign_resource(pdev, 0)) {
377 printk(KERN_ERR PFX "could not assign resource 0\n"); 377 printk(KERN_ERR PFX "could not assign resource 0\n");
378 return -ENODEV; 378 return -ENODEV;
379 } 379 }
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 97eeb2345b18..ffcf15c30e90 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -781,7 +781,7 @@ static int agpioc_acquire_wrap(struct agp_file_private *priv)
781 if (agp_fe.current_controller != NULL) 781 if (agp_fe.current_controller != NULL)
782 return -EBUSY; 782 return -EBUSY;
783 783
784 if(!agp_bridge) 784 if (!agp_bridge)
785 return -ENODEV; 785 return -ENODEV;
786 786
787 if (atomic_read(&agp_bridge->agp_in_use)) 787 if (atomic_read(&agp_bridge->agp_in_use))
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 5567ce8d72b0..4e1891e2c035 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -299,7 +299,7 @@ EXPORT_SYMBOL_GPL(agp_num_entries);
299/** 299/**
300 * agp_copy_info - copy bridge state information 300 * agp_copy_info - copy bridge state information
301 * 301 *
302 * @info: agp_kern_info pointer. The caller should insure that this pointer is valid. 302 * @info: agp_kern_info pointer. The caller should insure that this pointer is valid.
303 * 303 *
304 * This function copies information about the agp bridge device and the state of 304 * This function copies information about the agp bridge device and the state of
305 * the agp backend into an agp_kern_info pointer. 305 * the agp backend into an agp_kern_info pointer.
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index de5d6d212674..8c4c6ef748ec 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -85,8 +85,8 @@ static int __init hp_zx1_ioc_shared(void)
85 /* 85 /*
86 * IOC already configured by sba_iommu module; just use 86 * IOC already configured by sba_iommu module; just use
87 * its setup. We assume: 87 * its setup. We assume:
88 * - IOVA space is 1Gb in size 88 * - IOVA space is 1Gb in size
89 * - first 512Mb is IOMMU, second 512Mb is GART 89 * - first 512Mb is IOMMU, second 512Mb is GART
90 */ 90 */
91 hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG); 91 hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG);
92 switch (hp->io_tlb_ps) { 92 switch (hp->io_tlb_ps) {
@@ -115,7 +115,7 @@ static int __init hp_zx1_ioc_shared(void)
115 115
116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { 116 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
117 /* Normal case when no AGP device in system */ 117 /* Normal case when no AGP device in system */
118 hp->gatt = NULL; 118 hp->gatt = NULL;
119 hp->gatt_entries = 0; 119 hp->gatt_entries = 0;
120 printk(KERN_ERR PFX "No reserved IO PDIR entry found; " 120 printk(KERN_ERR PFX "No reserved IO PDIR entry found; "
121 "GART disabled\n"); 121 "GART disabled\n");
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 8ee19a4a6bce..91769443d8fe 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -400,10 +400,10 @@ static int i460_insert_memory_large_io_page (struct agp_memory *mem,
400 num_entries = A_SIZE_8(temp)->num_entries; 400 num_entries = A_SIZE_8(temp)->num_entries;
401 401
402 /* Figure out what pg_start means in terms of our large GART pages */ 402 /* Figure out what pg_start means in terms of our large GART pages */
403 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE]; 403 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
404 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE]; 404 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
405 start_offset = pg_start % I460_KPAGES_PER_IOPAGE; 405 start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
406 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE; 406 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
407 407
408 if (end > i460.lp_desc + num_entries) { 408 if (end > i460.lp_desc + num_entries) {
409 printk(KERN_ERR PFX "Looks like we're out of AGP memory\n"); 409 printk(KERN_ERR PFX "Looks like we're out of AGP memory\n");
@@ -458,10 +458,10 @@ static int i460_remove_memory_large_io_page (struct agp_memory *mem,
458 num_entries = A_SIZE_8(temp)->num_entries; 458 num_entries = A_SIZE_8(temp)->num_entries;
459 459
460 /* Figure out what pg_start means in terms of our large GART pages */ 460 /* Figure out what pg_start means in terms of our large GART pages */
461 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE]; 461 start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
462 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE]; 462 end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
463 start_offset = pg_start % I460_KPAGES_PER_IOPAGE; 463 start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
464 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE; 464 end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
465 465
466 for (i = 0, lp = start; lp <= end; ++lp) { 466 for (i = 0, lp = start; lp <= end; ++lp) {
467 for (idx = ((lp == start) ? start_offset : 0); 467 for (idx = ((lp == start) ? start_offset : 0);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 631531fd97a5..bddcae54b16d 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -201,9 +201,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
201 temp = agp_bridge->current_size; 201 temp = agp_bridge->current_size;
202 num_entries = A_SIZE_FIX(temp)->num_entries; 202 num_entries = A_SIZE_FIX(temp)->num_entries;
203 203
204 if ((pg_start + mem->page_count) > num_entries) { 204 if ((pg_start + mem->page_count) > num_entries)
205 return -EINVAL; 205 return -EINVAL;
206 } 206
207 for (j = pg_start; j < (pg_start + mem->page_count); j++) { 207 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
208 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) 208 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j)))
209 return -EBUSY; 209 return -EBUSY;
@@ -221,7 +221,7 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
221 agp_bridge->driver->tlb_flush(mem); 221 agp_bridge->driver->tlb_flush(mem);
222 return 0; 222 return 0;
223 } 223 }
224 if((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY)) 224 if ((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY))
225 goto insert; 225 goto insert;
226 return -EINVAL; 226 return -EINVAL;
227 } 227 }
@@ -328,7 +328,7 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
328static void intel_i810_free_by_type(struct agp_memory *curr) 328static void intel_i810_free_by_type(struct agp_memory *curr)
329{ 329{
330 agp_free_key(curr->key); 330 agp_free_key(curr->key);
331 if(curr->type == AGP_PHYS_MEMORY) { 331 if (curr->type == AGP_PHYS_MEMORY) {
332 if (curr->page_count == 4) 332 if (curr->page_count == 4)
333 i8xx_destroy_pages(gart_to_virt(curr->memory[0])); 333 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
334 else { 334 else {
@@ -1603,11 +1603,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1603 name = "i820"; 1603 name = "i820";
1604 break; 1604 break;
1605 case PCI_DEVICE_ID_INTEL_82830_HB: 1605 case PCI_DEVICE_ID_INTEL_82830_HB:
1606 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC)) { 1606 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1607 bridge->driver = &intel_830_driver; 1607 bridge->driver = &intel_830_driver;
1608 } else { 1608 else
1609 bridge->driver = &intel_830mp_driver; 1609 bridge->driver = &intel_830mp_driver;
1610 }
1611 name = "830M"; 1610 name = "830M";
1612 break; 1611 break;
1613 case PCI_DEVICE_ID_INTEL_82840_HB: 1612 case PCI_DEVICE_ID_INTEL_82840_HB:
@@ -1619,11 +1618,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1619 name = "i845"; 1618 name = "i845";
1620 break; 1619 break;
1621 case PCI_DEVICE_ID_INTEL_82845G_HB: 1620 case PCI_DEVICE_ID_INTEL_82845G_HB:
1622 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG)) { 1621 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1623 bridge->driver = &intel_830_driver; 1622 bridge->driver = &intel_830_driver;
1624 } else { 1623 else
1625 bridge->driver = &intel_845_driver; 1624 bridge->driver = &intel_845_driver;
1626 }
1627 name = "845G"; 1625 name = "845G";
1628 break; 1626 break;
1629 case PCI_DEVICE_ID_INTEL_82850_HB: 1627 case PCI_DEVICE_ID_INTEL_82850_HB:
@@ -1648,11 +1646,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1648 name = "i860"; 1646 name = "i860";
1649 break; 1647 break;
1650 case PCI_DEVICE_ID_INTEL_82865_HB: 1648 case PCI_DEVICE_ID_INTEL_82865_HB:
1651 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG)) { 1649 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1652 bridge->driver = &intel_830_driver; 1650 bridge->driver = &intel_830_driver;
1653 } else { 1651 else
1654 bridge->driver = &intel_845_driver; 1652 bridge->driver = &intel_845_driver;
1655 }
1656 name = "865"; 1653 name = "865";
1657 break; 1654 break;
1658 case PCI_DEVICE_ID_INTEL_82875_HB: 1655 case PCI_DEVICE_ID_INTEL_82875_HB:
@@ -1660,35 +1657,31 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1660 name = "i875"; 1657 name = "i875";
1661 break; 1658 break;
1662 case PCI_DEVICE_ID_INTEL_82915G_HB: 1659 case PCI_DEVICE_ID_INTEL_82915G_HB:
1663 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG)) { 1660 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1664 bridge->driver = &intel_915_driver; 1661 bridge->driver = &intel_915_driver;
1665 } else { 1662 else
1666 bridge->driver = &intel_845_driver; 1663 bridge->driver = &intel_845_driver;
1667 }
1668 name = "915G"; 1664 name = "915G";
1669 break; 1665 break;
1670 case PCI_DEVICE_ID_INTEL_82915GM_HB: 1666 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1671 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG)) { 1667 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1672 bridge->driver = &intel_915_driver; 1668 bridge->driver = &intel_915_driver;
1673 } else { 1669 else
1674 bridge->driver = &intel_845_driver; 1670 bridge->driver = &intel_845_driver;
1675 }
1676 name = "915GM"; 1671 name = "915GM";
1677 break; 1672 break;
1678 case PCI_DEVICE_ID_INTEL_82945G_HB: 1673 case PCI_DEVICE_ID_INTEL_82945G_HB:
1679 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG)) { 1674 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1680 bridge->driver = &intel_915_driver; 1675 bridge->driver = &intel_915_driver;
1681 } else { 1676 else
1682 bridge->driver = &intel_845_driver; 1677 bridge->driver = &intel_845_driver;
1683 }
1684 name = "945G"; 1678 name = "945G";
1685 break; 1679 break;
1686 case PCI_DEVICE_ID_INTEL_82945GM_HB: 1680 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1687 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG)) { 1681 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1688 bridge->driver = &intel_915_driver; 1682 bridge->driver = &intel_915_driver;
1689 } else { 1683 else
1690 bridge->driver = &intel_845_driver; 1684 bridge->driver = &intel_845_driver;
1691 }
1692 name = "945GM"; 1685 name = "945GM";
1693 break; 1686 break;
1694 case PCI_DEVICE_ID_INTEL_7505_0: 1687 case PCI_DEVICE_ID_INTEL_7505_0:
@@ -1724,7 +1717,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1724 */ 1717 */
1725 r = &pdev->resource[0]; 1718 r = &pdev->resource[0];
1726 if (!r->start && r->end) { 1719 if (!r->start && r->end) {
1727 if(pci_assign_resource(pdev, 0)) { 1720 if (pci_assign_resource(pdev, 0)) {
1728 printk(KERN_ERR PFX "could not assign resource 0\n"); 1721 printk(KERN_ERR PFX "could not assign resource 0\n");
1729 agp_put_bridge(bridge); 1722 agp_put_bridge(bridge);
1730 return -ENODEV; 1723 return -ENODEV;
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c
index 7c14a096b85e..3f9ccde62377 100644
--- a/drivers/char/agp/isoch.c
+++ b/drivers/char/agp/isoch.c
@@ -26,7 +26,7 @@ static void agp_3_5_dev_list_insert(struct list_head *head, struct list_head *ne
26 26
27 list_for_each(pos, head) { 27 list_for_each(pos, head) {
28 cur = list_entry(pos, struct agp_3_5_dev, list); 28 cur = list_entry(pos, struct agp_3_5_dev, list);
29 if(cur->maxbw > n->maxbw) 29 if (cur->maxbw > n->maxbw)
30 break; 30 break;
31 } 31 }
32 list_add_tail(new, pos); 32 list_add_tail(new, pos);
@@ -54,9 +54,9 @@ static void agp_3_5_dev_list_sort(struct agp_3_5_dev *list, unsigned int ndevs)
54 } 54 }
55} 55}
56 56
57/* 57/*
58 * Initialize all isochronous transfer parameters for an AGP 3.0 58 * Initialize all isochronous transfer parameters for an AGP 3.0
59 * node (i.e. a host bridge in combination with the adapters 59 * node (i.e. a host bridge in combination with the adapters
60 * lying behind it...) 60 * lying behind it...)
61 */ 61 */
62 62
@@ -200,7 +200,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
200 * this to the hungriest device (as per the spec) */ 200 * this to the hungriest device (as per the spec) */
201 rem = target.n - tot_n; 201 rem = target.n - tot_n;
202 202
203 /* 203 /*
204 * Calculate the minimum isochronous RQ depth needed by each master. 204 * Calculate the minimum isochronous RQ depth needed by each master.
205 * Along the way, distribute the extra ISOCH_N capability calculated 205 * Along the way, distribute the extra ISOCH_N capability calculated
206 * above. 206 * above.
@@ -214,7 +214,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
214 * many writes on the AGP bus). 214 * many writes on the AGP bus).
215 */ 215 */
216 master[cdev].rq = master[cdev].n; 216 master[cdev].rq = master[cdev].n;
217 if(master[cdev].y > 0x1) 217 if (master[cdev].y > 0x1)
218 master[cdev].rq *= (1 << (master[cdev].y - 1)); 218 master[cdev].rq *= (1 << (master[cdev].y - 1));
219 219
220 tot_rq += master[cdev].rq; 220 tot_rq += master[cdev].rq;
@@ -334,9 +334,9 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
334 334
335 arqsz = (tstatus >> 13) & 0x7; 335 arqsz = (tstatus >> 13) & 0x7;
336 336
337 /* 337 /*
338 * Allocate a head for our AGP 3.5 device list 338 * Allocate a head for our AGP 3.5 device list
339 * (multiple AGP v3 devices are allowed behind a single bridge). 339 * (multiple AGP v3 devices are allowed behind a single bridge).
340 */ 340 */
341 if ((dev_list = kmalloc(sizeof(*dev_list), GFP_KERNEL)) == NULL) { 341 if ((dev_list = kmalloc(sizeof(*dev_list), GFP_KERNEL)) == NULL) {
342 ret = -ENOMEM; 342 ret = -ENOMEM;
@@ -366,7 +366,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
366 366
367 case 0x0300: /* Display controller */ 367 case 0x0300: /* Display controller */
368 case 0x0400: /* Multimedia controller */ 368 case 0x0400: /* Multimedia controller */
369 if((cur = kmalloc(sizeof(*cur), GFP_KERNEL)) == NULL) { 369 if ((cur = kmalloc(sizeof(*cur), GFP_KERNEL)) == NULL) {
370 ret = -ENOMEM; 370 ret = -ENOMEM;
371 goto free_and_exit; 371 goto free_and_exit;
372 } 372 }
@@ -391,7 +391,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge)
391 list_for_each(pos, head) { 391 list_for_each(pos, head) {
392 cur = list_entry(pos, struct agp_3_5_dev, list); 392 cur = list_entry(pos, struct agp_3_5_dev, list);
393 dev = cur->dev; 393 dev = cur->dev;
394 394
395 pci_read_config_word(dev, PCI_STATUS, &mpstat); 395 pci_read_config_word(dev, PCI_STATUS, &mpstat);
396 if ((mpstat & PCI_STATUS_CAP_LIST) == 0) 396 if ((mpstat & PCI_STATUS_CAP_LIST) == 0)
397 continue; 397 continue;
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 80dafa3030bd..4c67135c12d8 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -11,6 +11,7 @@
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12#include <linux/page-flags.h> 12#include <linux/page-flags.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/jiffies.h>
14#include "agp.h" 15#include "agp.h"
15 16
16/* NVIDIA registers */ 17/* NVIDIA registers */
@@ -72,7 +73,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
72 /* Find the iorr that is already used for the base */ 73 /* Find the iorr that is already used for the base */
73 /* If not found, determine the uppermost available iorr */ 74 /* If not found, determine the uppermost available iorr */
74 free_iorr_addr = AMD_K7_NUM_IORR; 75 free_iorr_addr = AMD_K7_NUM_IORR;
75 for(iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) { 76 for (iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) {
76 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi); 77 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi);
77 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi); 78 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi);
78 79
@@ -82,7 +83,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
82 if ((mask_lo & 0x00000800) == 0) 83 if ((mask_lo & 0x00000800) == 0)
83 free_iorr_addr = iorr_addr; 84 free_iorr_addr = iorr_addr;
84 } 85 }
85 86
86 if (iorr_addr >= AMD_K7_NUM_IORR) { 87 if (iorr_addr >= AMD_K7_NUM_IORR) {
87 iorr_addr = free_iorr_addr; 88 iorr_addr = free_iorr_addr;
88 if (iorr_addr >= AMD_K7_NUM_IORR) 89 if (iorr_addr >= AMD_K7_NUM_IORR)
@@ -139,7 +140,7 @@ static int nvidia_configure(void)
139 } 140 }
140 141
141 /* attbase */ 142 /* attbase */
142 for(i = 0; i < 8; i++) { 143 for (i = 0; i < 8; i++) {
143 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i), 144 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i),
144 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1); 145 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1);
145 } 146 }
@@ -197,15 +198,15 @@ extern int agp_memory_reserved;
197static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 198static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
198{ 199{
199 int i, j; 200 int i, j;
200 201
201 if ((type != 0) || (mem->type != 0)) 202 if ((type != 0) || (mem->type != 0))
202 return -EINVAL; 203 return -EINVAL;
203 204
204 if ((pg_start + mem->page_count) > 205 if ((pg_start + mem->page_count) >
205 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE)) 206 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE))
206 return -EINVAL; 207 return -EINVAL;
207 208
208 for(j = pg_start; j < (pg_start + mem->page_count); j++) { 209 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
209 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j))) 210 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j)))
210 return -EBUSY; 211 return -EBUSY;
211 } 212 }
@@ -256,7 +257,7 @@ static void nvidia_tlbflush(struct agp_memory *mem)
256 do { 257 do {
257 pci_read_config_dword(nvidia_private.dev_1, 258 pci_read_config_dword(nvidia_private.dev_1,
258 NVIDIA_1_WBC, &wbc_reg); 259 NVIDIA_1_WBC, &wbc_reg);
259 if ((signed)(end - jiffies) <= 0) { 260 if (time_before_eq(end, jiffies)) {
260 printk(KERN_ERR PFX 261 printk(KERN_ERR PFX
261 "TLB flush took more than 3 seconds.\n"); 262 "TLB flush took more than 3 seconds.\n");
262 } 263 }
@@ -264,9 +265,9 @@ static void nvidia_tlbflush(struct agp_memory *mem)
264 } 265 }
265 266
266 /* flush TLB entries */ 267 /* flush TLB entries */
267 for(i = 0; i < 32 + 1; i++) 268 for (i = 0; i < 32 + 1; i++)
268 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 269 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
269 for(i = 0; i < 32 + 1; i++) 270 for (i = 0; i < 32 + 1; i++)
270 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 271 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
271} 272}
272 273
@@ -323,7 +324,7 @@ static int __devinit agp_nvidia_probe(struct pci_dev *pdev,
323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 324 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
324 nvidia_private.dev_3 = 325 nvidia_private.dev_3 =
325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 326 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
326 327
327 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 328 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
328 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 " 329 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
329 "chipset, but could not find the secondary devices.\n"); 330 "chipset, but could not find the secondary devices.\n");
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 4df7734b51c2..cfa7922cb431 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -329,7 +329,7 @@ static int __devinit agp_sgi_init(void)
329 329
330static void __devexit agp_sgi_cleanup(void) 330static void __devexit agp_sgi_cleanup(void)
331{ 331{
332 if(sgi_tioca_agp_bridges) 332 if (sgi_tioca_agp_bridges)
333 kfree(sgi_tioca_agp_bridges); 333 kfree(sgi_tioca_agp_bridges);
334 sgi_tioca_agp_bridges=NULL; 334 sgi_tioca_agp_bridges=NULL;
335} 335}
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index ebc05554045c..a00fd48a6f05 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -121,7 +121,7 @@ static struct aper_size_info_8 sis_generic_sizes[7] =
121 121
122static struct agp_bridge_driver sis_driver = { 122static struct agp_bridge_driver sis_driver = {
123 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
124 .aperture_sizes = sis_generic_sizes, 124 .aperture_sizes = sis_generic_sizes,
125 .size_type = U8_APER_SIZE, 125 .size_type = U8_APER_SIZE,
126 .num_aperture_sizes = 7, 126 .num_aperture_sizes = 7,
127 .configure = sis_configure, 127 .configure = sis_configure,
@@ -243,11 +243,11 @@ static void __devinit sis_get_driver(struct agp_bridge_data *bridge)
243{ 243{
244 int i; 244 int i;
245 245
246 for(i=0; sis_broken_chipsets[i]!=0; ++i) 246 for (i=0; sis_broken_chipsets[i]!=0; ++i)
247 if(bridge->dev->device==sis_broken_chipsets[i]) 247 if (bridge->dev->device==sis_broken_chipsets[i])
248 break; 248 break;
249 249
250 if(sis_broken_chipsets[i] || agp_sis_force_delay) 250 if (sis_broken_chipsets[i] || agp_sis_force_delay)
251 sis_driver.agp_enable=sis_delayed_enable; 251 sis_driver.agp_enable=sis_delayed_enable;
252 252
253 // sis chipsets that indicate less than agp3.5 253 // sis chipsets that indicate less than agp3.5
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index efef9999f1cf..4f2d7d99902f 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -64,7 +64,7 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
64 } 64 }
65 global_cache_flush(); 65 global_cache_flush();
66 66
67 for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) 67 for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++)
68 writel(agp_bridge->scratch_page, page_map->remapped+i); 68 writel(agp_bridge->scratch_page, page_map->remapped+i);
69 69
70 return 0; 70 return 0;
@@ -84,7 +84,7 @@ static void serverworks_free_gatt_pages(void)
84 struct serverworks_page_map *entry; 84 struct serverworks_page_map *entry;
85 85
86 tables = serverworks_private.gatt_pages; 86 tables = serverworks_private.gatt_pages;
87 for(i = 0; i < serverworks_private.num_tables; i++) { 87 for (i = 0; i < serverworks_private.num_tables; i++) {
88 entry = tables[i]; 88 entry = tables[i];
89 if (entry != NULL) { 89 if (entry != NULL) {
90 if (entry->real != NULL) { 90 if (entry->real != NULL) {
@@ -103,7 +103,7 @@ static int serverworks_create_gatt_pages(int nr_tables)
103 int retval = 0; 103 int retval = 0;
104 int i; 104 int i;
105 105
106 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *), 106 tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
107 GFP_KERNEL); 107 GFP_KERNEL);
108 if (tables == NULL) 108 if (tables == NULL)
109 return -ENOMEM; 109 return -ENOMEM;
@@ -161,7 +161,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
161 return retval; 161 return retval;
162 } 162 }
163 /* Create a fake scratch directory */ 163 /* Create a fake scratch directory */
164 for(i = 0; i < 1024; i++) { 164 for (i = 0; i < 1024; i++) {
165 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); 165 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
166 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); 166 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
167 } 167 }
@@ -185,9 +185,8 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
185 pci_read_config_dword(agp_bridge->dev,serverworks_private.gart_addr_ofs,&temp); 185 pci_read_config_dword(agp_bridge->dev,serverworks_private.gart_addr_ofs,&temp);
186 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 186 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
187 187
188 /* Calculate the agp offset */ 188 /* Calculate the agp offset */
189 189 for (i = 0; i < value->num_entries / 1024; i++)
190 for(i = 0; i < value->num_entries / 1024; i++)
191 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); 190 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
192 191
193 return 0; 192 return 0;
@@ -196,7 +195,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
196static int serverworks_free_gatt_table(struct agp_bridge_data *bridge) 195static int serverworks_free_gatt_table(struct agp_bridge_data *bridge)
197{ 196{
198 struct serverworks_page_map page_dir; 197 struct serverworks_page_map page_dir;
199 198
200 page_dir.real = (unsigned long *)agp_bridge->gatt_table_real; 199 page_dir.real = (unsigned long *)agp_bridge->gatt_table_real;
201 page_dir.remapped = (unsigned long __iomem *)agp_bridge->gatt_table; 200 page_dir.remapped = (unsigned long __iomem *)agp_bridge->gatt_table;
202 201
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 50947e38501a..9846defbddb4 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -95,12 +95,12 @@ static void uninorth_cleanup(void)
95static int uninorth_configure(void) 95static int uninorth_configure(void)
96{ 96{
97 struct aper_size_info_32 *current_size; 97 struct aper_size_info_32 *current_size;
98 98
99 current_size = A_SIZE_32(agp_bridge->current_size); 99 current_size = A_SIZE_32(agp_bridge->current_size);
100 100
101 printk(KERN_INFO PFX "configuring for size idx: %d\n", 101 printk(KERN_INFO PFX "configuring for size idx: %d\n",
102 current_size->size_value); 102 current_size->size_value);
103 103
104 /* aperture size and gatt addr */ 104 /* aperture size and gatt addr */
105 pci_write_config_dword(agp_bridge->dev, 105 pci_write_config_dword(agp_bridge->dev,
106 UNI_N_CFG_GART_BASE, 106 UNI_N_CFG_GART_BASE,
@@ -127,7 +127,7 @@ static int uninorth_configure(void)
127 UNI_N_CFG_GART_DUMMY_PAGE, 127 UNI_N_CFG_GART_DUMMY_PAGE,
128 agp_bridge->scratch_page_real >> 12); 128 agp_bridge->scratch_page_real >> 12);
129 } 129 }
130 130
131 return 0; 131 return 0;
132} 132}
133 133
@@ -162,7 +162,7 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start,
162 } 162 }
163 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]); 163 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]);
164 mb(); 164 mb();
165 flush_dcache_range((unsigned long)&agp_bridge->gatt_table[pg_start], 165 flush_dcache_range((unsigned long)&agp_bridge->gatt_table[pg_start],
166 (unsigned long)&agp_bridge->gatt_table[pg_start + mem->page_count]); 166 (unsigned long)&agp_bridge->gatt_table[pg_start + mem->page_count]);
167 167
168 uninorth_tlbflush(mem); 168 uninorth_tlbflush(mem);
@@ -235,7 +235,7 @@ static void uninorth_agp_enable(struct agp_bridge_data *bridge, u32 mode)
235 235
236 command = agp_collect_device_status(bridge, mode, status); 236 command = agp_collect_device_status(bridge, mode, status);
237 command |= PCI_AGP_COMMAND_AGP; 237 command |= PCI_AGP_COMMAND_AGP;
238 238
239 if (uninorth_rev == 0x21) { 239 if (uninorth_rev == 0x21) {
240 /* 240 /*
241 * Darwin disable AGP 4x on this revision, thus we 241 * Darwin disable AGP 4x on this revision, thus we
@@ -456,7 +456,7 @@ static struct aper_size_info_32 uninorth_sizes[7] =
456 {256, 65536, 6, 64}, 456 {256, 65536, 6, 64},
457 {128, 32768, 5, 32}, 457 {128, 32768, 5, 32},
458 {64, 16384, 4, 16}, 458 {64, 16384, 4, 16},
459#endif 459#endif
460 {32, 8192, 3, 8}, 460 {32, 8192, 3, 8},
461 {16, 4096, 2, 4}, 461 {16, 4096, 2, 4},
462 {8, 2048, 1, 2}, 462 {8, 2048, 1, 2},
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 7ac365b5d9ec..6602b3156df5 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -46,8 +46,6 @@
46 46
47/* Sanity checks */ 47/* Sanity checks */
48 48
49#define SERIAL_INLINE
50
51#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 49#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
52#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 50#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
53 tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) 51 tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
@@ -95,10 +93,6 @@ static char *serial_version = "4.30";
95#include <asm/amigahw.h> 93#include <asm/amigahw.h>
96#include <asm/amigaints.h> 94#include <asm/amigaints.h>
97 95
98#ifdef SERIAL_INLINE
99#define _INLINE_ inline
100#endif
101
102#define custom amiga_custom 96#define custom amiga_custom
103static char *serial_name = "Amiga-builtin serial driver"; 97static char *serial_name = "Amiga-builtin serial driver";
104 98
@@ -253,14 +247,14 @@ static void rs_start(struct tty_struct *tty)
253 * This routine is used by the interrupt handler to schedule 247 * This routine is used by the interrupt handler to schedule
254 * processing in the software interrupt portion of the driver. 248 * processing in the software interrupt portion of the driver.
255 */ 249 */
256static _INLINE_ void rs_sched_event(struct async_struct *info, 250static void rs_sched_event(struct async_struct *info,
257 int event) 251 int event)
258{ 252{
259 info->event |= 1 << event; 253 info->event |= 1 << event;
260 tasklet_schedule(&info->tlet); 254 tasklet_schedule(&info->tlet);
261} 255}
262 256
263static _INLINE_ void receive_chars(struct async_struct *info) 257static void receive_chars(struct async_struct *info)
264{ 258{
265 int status; 259 int status;
266 int serdatr; 260 int serdatr;
@@ -349,7 +343,7 @@ out:
349 return; 343 return;
350} 344}
351 345
352static _INLINE_ void transmit_chars(struct async_struct *info) 346static void transmit_chars(struct async_struct *info)
353{ 347{
354 custom.intreq = IF_TBE; 348 custom.intreq = IF_TBE;
355 mb(); 349 mb();
@@ -389,7 +383,7 @@ static _INLINE_ void transmit_chars(struct async_struct *info)
389 } 383 }
390} 384}
391 385
392static _INLINE_ void check_modem_status(struct async_struct *info) 386static void check_modem_status(struct async_struct *info)
393{ 387{
394 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); 388 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
395 unsigned char dstatus; 389 unsigned char dstatus;
@@ -1959,7 +1953,7 @@ done:
1959 * number, and identifies which options were configured into this 1953 * number, and identifies which options were configured into this
1960 * driver. 1954 * driver.
1961 */ 1955 */
1962static _INLINE_ void show_serial_version(void) 1956static void show_serial_version(void)
1963{ 1957{
1964 printk(KERN_INFO "%s version %s\n", serial_name, serial_version); 1958 printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
1965} 1959}
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 641f7633878c..b7f7951c4587 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -175,7 +175,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
175 drm_device_t *dev = NULL; 175 drm_device_t *dev = NULL;
176 int minor = iminor(inode); 176 int minor = iminor(inode);
177 int err = -ENODEV; 177 int err = -ENODEV;
178 struct file_operations *old_fops; 178 const struct file_operations *old_fops;
179 179
180 DRM_DEBUG("\n"); 180 DRM_DEBUG("\n");
181 181
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 0291cd62c69f..ffd0800ed601 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -619,6 +619,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
619#endif 619#endif
620 offset = dev->driver->get_reg_ofs(dev); 620 offset = dev->driver->get_reg_ofs(dev);
621#ifdef __sparc__ 621#ifdef __sparc__
622 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
622 if (io_remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start, 623 if (io_remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start,
623 (map->offset + offset) >> PAGE_SHIFT, 624 (map->offset + offset) >> PAGE_SHIFT,
624 vma->vm_end - vma->vm_start, 625 vma->vm_end - vma->vm_start,
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index ae0aa6d7e0bb..c658dde3633b 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -126,7 +126,7 @@ static int i810_map_buffer(drm_buf_t * buf, struct file *filp)
126 drm_device_t *dev = priv->head->dev; 126 drm_device_t *dev = priv->head->dev;
127 drm_i810_buf_priv_t *buf_priv = buf->dev_private; 127 drm_i810_buf_priv_t *buf_priv = buf->dev_private;
128 drm_i810_private_t *dev_priv = dev->dev_private; 128 drm_i810_private_t *dev_priv = dev->dev_private;
129 struct file_operations *old_fops; 129 const struct file_operations *old_fops;
130 int retcode = 0; 130 int retcode = 0;
131 131
132 if (buf_priv->currently_mapped == I810_BUF_MAPPED) 132 if (buf_priv->currently_mapped == I810_BUF_MAPPED)
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 163f2cbfe60d..b0f815d8cea8 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -128,7 +128,7 @@ static int i830_map_buffer(drm_buf_t * buf, struct file *filp)
128 drm_device_t *dev = priv->head->dev; 128 drm_device_t *dev = priv->head->dev;
129 drm_i830_buf_priv_t *buf_priv = buf->dev_private; 129 drm_i830_buf_priv_t *buf_priv = buf->dev_private;
130 drm_i830_private_t *dev_priv = dev->dev_private; 130 drm_i830_private_t *dev_priv = dev->dev_private;
131 struct file_operations *old_fops; 131 const struct file_operations *old_fops;
132 unsigned long virtual; 132 unsigned long virtual;
133 int retcode = 0; 133 int retcode = 0;
134 134
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 765c5c108bf4..9cad8501d62c 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -486,8 +486,7 @@ static void pc_close(struct tty_struct * tty, struct file * filp)
486 } /* End channel is open more than once */ 486 } /* End channel is open more than once */
487 487
488 /* Port open only once go ahead with shutdown & reset */ 488 /* Port open only once go ahead with shutdown & reset */
489 if (ch->count < 0) 489 BUG_ON(ch->count < 0);
490 BUG();
491 490
492 /* --------------------------------------------------------------- 491 /* ---------------------------------------------------------------
493 Let the rest of the driver know the channel is being closed. 492 Let the rest of the driver know the channel is being closed.
diff --git a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
index b2e0928e8428..093fdf98b19a 100644
--- a/drivers/char/ftape/lowlevel/fdc-io.c
+++ b/drivers/char/ftape/lowlevel/fdc-io.c
@@ -607,7 +607,7 @@ void fdc_reset(void)
607 607
608 fdc_mode = fdc_idle; 608 fdc_mode = fdc_idle;
609 609
610 /* maybe the cli()/sti() pair is not necessary, BUT: 610 /* maybe the spin_lock_irq* pair is not necessary, BUT:
611 * the following line MUST be here. Otherwise fdc_interrupt_wait() 611 * the following line MUST be here. Otherwise fdc_interrupt_wait()
612 * won't wait. Note that fdc_reset() is called from 612 * won't wait. Note that fdc_reset() is called from
613 * ftape_dumb_stop() when the fdc is busy transferring data. In this 613 * ftape_dumb_stop() when the fdc is busy transferring data. In this
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index 1b5e01e6e129..43ff59816511 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -22,6 +22,9 @@
22#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/nvram.h> 24#include <asm/nvram.h>
25#ifdef CONFIG_PPC_PMAC
26#include <asm/machdep.h>
27#endif
25 28
26#define NVRAM_SIZE 8192 29#define NVRAM_SIZE 8192
27 30
@@ -92,7 +95,7 @@ static int nvram_ioctl(struct inode *inode, struct file *file,
92 case IOC_NVRAM_GET_OFFSET: { 95 case IOC_NVRAM_GET_OFFSET: {
93 int part, offset; 96 int part, offset;
94 97
95 if (_machine != _MACH_Pmac) 98 if (!machine_is(powermac))
96 return -EINVAL; 99 return -EINVAL;
97 if (copy_from_user(&part, (void __user*)arg, sizeof(part)) != 0) 100 if (copy_from_user(&part, (void __user*)arg, sizeof(part)) != 0)
98 return -EFAULT; 101 return -EFAULT;
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index e38a5f0e07bb..5e59c0b42731 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -48,8 +48,8 @@ static int gs_debug;
48#define NEW_WRITE_LOCKING 1 48#define NEW_WRITE_LOCKING 1
49#if NEW_WRITE_LOCKING 49#if NEW_WRITE_LOCKING
50#define DECL /* Nothing */ 50#define DECL /* Nothing */
51#define LOCKIT down (& port->port_write_sem); 51#define LOCKIT mutex_lock(& port->port_write_mutex);
52#define RELEASEIT up (&port->port_write_sem); 52#define RELEASEIT mutex_unlock(&port->port_write_mutex);
53#else 53#else
54#define DECL unsigned long flags; 54#define DECL unsigned long flags;
55#define LOCKIT save_flags (flags);cli () 55#define LOCKIT save_flags (flags);cli ()
@@ -124,14 +124,14 @@ int gs_write(struct tty_struct * tty,
124 /* get exclusive "write" access to this port (problem 3) */ 124 /* get exclusive "write" access to this port (problem 3) */
125 /* This is not a spinlock because we can have a disk access (page 125 /* This is not a spinlock because we can have a disk access (page
126 fault) in copy_from_user */ 126 fault) in copy_from_user */
127 down (& port->port_write_sem); 127 mutex_lock(& port->port_write_mutex);
128 128
129 while (1) { 129 while (1) {
130 130
131 c = count; 131 c = count;
132 132
133 /* This is safe because we "OWN" the "head". Noone else can 133 /* This is safe because we "OWN" the "head". Noone else can
134 change the "head": we own the port_write_sem. */ 134 change the "head": we own the port_write_mutex. */
135 /* Don't overrun the end of the buffer */ 135 /* Don't overrun the end of the buffer */
136 t = SERIAL_XMIT_SIZE - port->xmit_head; 136 t = SERIAL_XMIT_SIZE - port->xmit_head;
137 if (t < c) c = t; 137 if (t < c) c = t;
@@ -153,7 +153,7 @@ int gs_write(struct tty_struct * tty,
153 count -= c; 153 count -= c;
154 total += c; 154 total += c;
155 } 155 }
156 up (& port->port_write_sem); 156 mutex_unlock(& port->port_write_mutex);
157 157
158 gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", 158 gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n",
159 (port->flags & GS_TX_INTEN)?"enabled": "disabled"); 159 (port->flags & GS_TX_INTEN)?"enabled": "disabled");
@@ -214,7 +214,7 @@ int gs_write(struct tty_struct * tty,
214 c = count; 214 c = count;
215 215
216 /* This is safe because we "OWN" the "head". Noone else can 216 /* This is safe because we "OWN" the "head". Noone else can
217 change the "head": we own the port_write_sem. */ 217 change the "head": we own the port_write_mutex. */
218 /* Don't overrun the end of the buffer */ 218 /* Don't overrun the end of the buffer */
219 t = SERIAL_XMIT_SIZE - port->xmit_head; 219 t = SERIAL_XMIT_SIZE - port->xmit_head;
220 if (t < c) c = t; 220 if (t < c) c = t;
@@ -888,7 +888,7 @@ int gs_init_port(struct gs_port *port)
888 spin_lock_irqsave (&port->driver_lock, flags); 888 spin_lock_irqsave (&port->driver_lock, flags);
889 if (port->tty) 889 if (port->tty)
890 clear_bit(TTY_IO_ERROR, &port->tty->flags); 890 clear_bit(TTY_IO_ERROR, &port->tty->flags);
891 init_MUTEX(&port->port_write_sem); 891 mutex_init(&port->port_write_mutex);
892 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 892 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
893 spin_unlock_irqrestore(&port->driver_lock, flags); 893 spin_unlock_irqrestore(&port->driver_lock, flags);
894 gs_set_termios(port->tty, NULL); 894 gs_set_termios(port->tty, NULL);
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index f65b2e14a485..2b6a56b2bf35 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -39,8 +39,10 @@
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <asm/hvconsole.h> 44
45#include "hvc_console.h"
44 46
45#define HVC_MAJOR 229 47#define HVC_MAJOR 229
46#define HVC_MINOR 0 48#define HVC_MINOR 0
@@ -54,17 +56,14 @@
54#define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */ 56#define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
55 57
56/* 58/*
57 * The Linux TTY code does not support dynamic addition of tty derived devices 59 * These sizes are most efficient for vio, because they are the
58 * so we need to know how many tty devices we might need when space is allocated 60 * native transfer size. We could make them selectable in the
59 * for the tty device. Since this driver supports hotplug of vty adapters we 61 * future to better deal with backends that want other buffer sizes.
60 * need to make sure we have enough allocated.
61 */ 62 */
62#define HVC_ALLOC_TTY_ADAPTERS 8
63
64#define N_OUTBUF 16 63#define N_OUTBUF 16
65#define N_INBUF 16 64#define N_INBUF 16
66 65
67#define __ALIGNED__ __attribute__((__aligned__(8))) 66#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
68 67
69static struct tty_driver *hvc_driver; 68static struct tty_driver *hvc_driver;
70static struct task_struct *hvc_task; 69static struct task_struct *hvc_task;
@@ -154,7 +153,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
154 153
155void hvc_console_print(struct console *co, const char *b, unsigned count) 154void hvc_console_print(struct console *co, const char *b, unsigned count)
156{ 155{
157 char c[16] __ALIGNED__; 156 char c[N_OUTBUF] __ALIGNED__;
158 unsigned i = 0, n = 0; 157 unsigned i = 0, n = 0;
159 int r, donecr = 0, index = co->index; 158 int r, donecr = 0, index = co->index;
160 159
@@ -473,8 +472,10 @@ static void hvc_push(struct hvc_struct *hp)
473 472
474 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf); 473 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
475 if (n <= 0) { 474 if (n <= 0) {
476 if (n == 0) 475 if (n == 0) {
476 hp->do_wakeup = 1;
477 return; 477 return;
478 }
478 /* throw away output on error; this happens when 479 /* throw away output on error; this happens when
479 there is no session connected to the vterm. */ 480 there is no session connected to the vterm. */
480 hp->n_outbuf = 0; 481 hp->n_outbuf = 0;
@@ -486,12 +487,19 @@ static void hvc_push(struct hvc_struct *hp)
486 hp->do_wakeup = 1; 487 hp->do_wakeup = 1;
487} 488}
488 489
489static inline int __hvc_write_kernel(struct hvc_struct *hp, 490static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
490 const unsigned char *buf, int count)
491{ 491{
492 struct hvc_struct *hp = tty->driver_data;
492 unsigned long flags; 493 unsigned long flags;
493 int rsize, written = 0; 494 int rsize, written = 0;
494 495
496 /* This write was probably executed during a tty close. */
497 if (!hp)
498 return -EPIPE;
499
500 if (hp->count <= 0)
501 return -EIO;
502
495 spin_lock_irqsave(&hp->lock, flags); 503 spin_lock_irqsave(&hp->lock, flags);
496 504
497 /* Push pending writes */ 505 /* Push pending writes */
@@ -510,26 +518,8 @@ static inline int __hvc_write_kernel(struct hvc_struct *hp,
510 } 518 }
511 spin_unlock_irqrestore(&hp->lock, flags); 519 spin_unlock_irqrestore(&hp->lock, flags);
512 520
513 return written;
514}
515static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
516{
517 struct hvc_struct *hp = tty->driver_data;
518 int written;
519
520 /* This write was probably executed during a tty close. */
521 if (!hp)
522 return -EPIPE;
523
524 if (hp->count <= 0)
525 return -EIO;
526
527 written = __hvc_write_kernel(hp, buf, count);
528
529 /* 521 /*
530 * Racy, but harmless, kick thread if there is still pending data. 522 * Racy, but harmless, kick thread if there is still pending data.
531 * There really is nothing wrong with kicking the thread, even if there
532 * is no buffered data.
533 */ 523 */
534 if (hp->n_outbuf) 524 if (hp->n_outbuf)
535 hvc_kick(); 525 hvc_kick();
@@ -614,6 +604,13 @@ static int hvc_poll(struct hvc_struct *hp)
614 spin_unlock_irqrestore(&hp->lock, flags); 604 spin_unlock_irqrestore(&hp->lock, flags);
615 tty_hangup(tty); 605 tty_hangup(tty);
616 spin_lock_irqsave(&hp->lock, flags); 606 spin_lock_irqsave(&hp->lock, flags);
607 } else if ( n == -EAGAIN ) {
608 /*
609 * Some back-ends can only ensure a certain min
610 * num of bytes read, which may be > 'count'.
611 * Let the tty clear the flip buff to make room.
612 */
613 poll_mask |= HVC_POLL_READ;
617 } 614 }
618 break; 615 break;
619 } 616 }
@@ -635,16 +632,7 @@ static int hvc_poll(struct hvc_struct *hp)
635 tty_insert_flip_char(tty, buf[i], 0); 632 tty_insert_flip_char(tty, buf[i], 0);
636 } 633 }
637 634
638 /*
639 * Account for the total amount read in one loop, and if above
640 * 64 bytes, we do a quick schedule loop to let the tty grok
641 * the data and eventually throttle us.
642 */
643 read_total += n; 635 read_total += n;
644 if (read_total >= 64) {
645 poll_mask |= HVC_POLL_QUICK;
646 break;
647 }
648 } 636 }
649 throttled: 637 throttled:
650 /* Wakeup write queue if necessary */ 638 /* Wakeup write queue if necessary */
@@ -767,7 +755,8 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
767 * see if this vterm id matches one registered for console. 755 * see if this vterm id matches one registered for console.
768 */ 756 */
769 for (i=0; i < MAX_NR_HVC_CONSOLES; i++) 757 for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
770 if (vtermnos[i] == hp->vtermno) 758 if (vtermnos[i] == hp->vtermno &&
759 cons_ops[i] == hp->ops)
771 break; 760 break;
772 761
773 /* no matching slot, just use a counter */ 762 /* no matching slot, just use a counter */
@@ -823,34 +812,38 @@ EXPORT_SYMBOL(hvc_remove);
823 * interfaces start to become available. */ 812 * interfaces start to become available. */
824int __init hvc_init(void) 813int __init hvc_init(void)
825{ 814{
815 struct tty_driver *drv;
816
826 /* We need more than hvc_count adapters due to hotplug additions. */ 817 /* We need more than hvc_count adapters due to hotplug additions. */
827 hvc_driver = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS); 818 drv = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
828 if (!hvc_driver) 819 if (!drv)
829 return -ENOMEM; 820 return -ENOMEM;
830 821
831 hvc_driver->owner = THIS_MODULE; 822 drv->owner = THIS_MODULE;
832 hvc_driver->devfs_name = "hvc/"; 823 drv->devfs_name = "hvc/";
833 hvc_driver->driver_name = "hvc"; 824 drv->driver_name = "hvc";
834 hvc_driver->name = "hvc"; 825 drv->name = "hvc";
835 hvc_driver->major = HVC_MAJOR; 826 drv->major = HVC_MAJOR;
836 hvc_driver->minor_start = HVC_MINOR; 827 drv->minor_start = HVC_MINOR;
837 hvc_driver->type = TTY_DRIVER_TYPE_SYSTEM; 828 drv->type = TTY_DRIVER_TYPE_SYSTEM;
838 hvc_driver->init_termios = tty_std_termios; 829 drv->init_termios = tty_std_termios;
839 hvc_driver->flags = TTY_DRIVER_REAL_RAW; 830 drv->flags = TTY_DRIVER_REAL_RAW;
840 tty_set_operations(hvc_driver, &hvc_ops); 831 tty_set_operations(drv, &hvc_ops);
841 832
842 /* Always start the kthread because there can be hotplug vty adapters 833 /* Always start the kthread because there can be hotplug vty adapters
843 * added later. */ 834 * added later. */
844 hvc_task = kthread_run(khvcd, NULL, "khvcd"); 835 hvc_task = kthread_run(khvcd, NULL, "khvcd");
845 if (IS_ERR(hvc_task)) { 836 if (IS_ERR(hvc_task)) {
846 panic("Couldn't create kthread for console.\n"); 837 panic("Couldn't create kthread for console.\n");
847 put_tty_driver(hvc_driver); 838 put_tty_driver(drv);
848 return -EIO; 839 return -EIO;
849 } 840 }
850 841
851 if (tty_register_driver(hvc_driver)) 842 if (tty_register_driver(drv))
852 panic("Couldn't register hvc console driver\n"); 843 panic("Couldn't register hvc console driver\n");
853 844
845 mb();
846 hvc_driver = drv;
854 return 0; 847 return 0;
855} 848}
856module_init(hvc_init); 849module_init(hvc_init);
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h
new file mode 100644
index 000000000000..96b7401319c1
--- /dev/null
+++ b/drivers/char/hvc_console.h
@@ -0,0 +1,63 @@
1/*
2 * hvc_console.h
3 * Copyright (C) 2005 IBM Corporation
4 *
5 * Author(s):
6 * Ryan S. Arnold <rsa@us.ibm.com>
7 *
8 * hvc_console header information:
9 * moved here from include/asm-powerpc/hvconsole.h
10 * and drivers/char/hvc_console.c
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#ifndef HVC_CONSOLE_H
28#define HVC_CONSOLE_H
29
30/*
31 * This is the max number of console adapters that can/will be found as
32 * console devices on first stage console init. Any number beyond this range
33 * can't be used as a console device but is still a valid tty device.
34 */
35#define MAX_NR_HVC_CONSOLES 16
36
37/*
38 * The Linux TTY code does not support dynamic addition of tty derived devices
39 * so we need to know how many tty devices we might need when space is allocated
40 * for the tty device. Since this driver supports hotplug of vty adapters we
41 * need to make sure we have enough allocated.
42 */
43#define HVC_ALLOC_TTY_ADAPTERS 8
44
45
46/* implemented by a low level driver */
47struct hv_ops {
48 int (*get_chars)(uint32_t vtermno, char *buf, int count);
49 int (*put_chars)(uint32_t vtermno, const char *buf, int count);
50};
51
52struct hvc_struct;
53
54/* Register a vterm and a slot index for use as a console (console_init) */
55extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops);
56
57/* register a vterm for hvc tty operation (module_init or hotplug add) */
58extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq,
59 struct hv_ops *ops);
60/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */
61extern int __devexit hvc_remove(struct hvc_struct *hp);
62
63#endif // HVC_CONSOLE_H
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
new file mode 100644
index 000000000000..83364ea63cba
--- /dev/null
+++ b/drivers/char/hvc_rtas.c
@@ -0,0 +1,138 @@
1/*
2 * IBM RTAS driver interface to hvc_console.c
3 *
4 * (C) Copyright IBM Corporation 2001-2005
5 * (C) Copyright Red Hat, Inc. 2005
6 *
7 * Author(s): Maximino Augilar <IBM STI Design Center>
8 * : Ryan S. Arnold <rsa@us.ibm.com>
9 * : Utz Bacher <utz.bacher@de.ibm.com>
10 * : David Woodhouse <dwmw2@infradead.org>
11 *
12 * inspired by drivers/char/hvc_console.c
13 * written by Anton Blanchard and Paul Mackerras
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30#include <linux/console.h>
31#include <linux/delay.h>
32#include <linux/err.h>
33#include <linux/init.h>
34#include <linux/moduleparam.h>
35#include <linux/types.h>
36
37#include <asm/irq.h>
38#include <asm/rtas.h>
39#include "hvc_console.h"
40
41#define hvc_rtas_cookie 0x67781e15
42struct hvc_struct *hvc_rtas_dev;
43
44#define RTASCONS_PUT_ATTEMPTS 16
45
46static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
47static 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
51static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, int count)
52{
53 int done;
54
55 /* if there is more than one character to be displayed, wait a bit */
56 for (done = 0; done < count; done++) {
57 int result;
58 result = rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[done]);
59 if (result)
60 break;
61 }
62 /* the calling routine expects to receive the number of bytes sent */
63 return done;
64}
65
66static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
67{
68 int i;
69
70 for (i = 0; i < count; i++) {
71 int c, err;
72
73 err = rtas_call(rtascons_get_char_token, 0, 2, &c);
74 if (err)
75 break;
76
77 buf[i] = c;
78 }
79
80 return i;
81}
82
83static struct hv_ops hvc_rtas_get_put_ops = {
84 .get_chars = hvc_rtas_read_console,
85 .put_chars = hvc_rtas_write_console,
86};
87
88static int hvc_rtas_init(void)
89{
90 struct hvc_struct *hp;
91
92 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
93 rtascons_put_char_token = rtas_token("put-term-char");
94 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
95 return -EIO;
96
97 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
98 rtascons_get_char_token = rtas_token("get-term-char");
99 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
100 return -EIO;
101
102 BUG_ON(hvc_rtas_dev);
103
104 /* Allocate an hvc_struct for the console device we instantiated
105 * earlier. Save off hp so that we can return it on exit */
106 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops);
107 if (IS_ERR(hp))
108 return PTR_ERR(hp);
109 hvc_rtas_dev = hp;
110 return 0;
111}
112module_init(hvc_rtas_init);
113
114/* This will tear down the tty portion of the driver */
115static void __exit hvc_rtas_exit(void)
116{
117 /* Really the fun isn't over until the worker thread breaks down and the
118 * tty cleans up */
119 if (hvc_rtas_dev)
120 hvc_remove(hvc_rtas_dev);
121}
122module_exit(hvc_rtas_exit);
123
124/* This will happen prior to module init. There is no tty at this time? */
125static int hvc_rtas_console_init(void)
126{
127 rtascons_put_char_token = rtas_token("put-term-char");
128 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
129 return -EIO;
130 rtascons_get_char_token = rtas_token("get-term-char");
131 if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
132 return -EIO;
133
134 hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops );
135 add_preferred_console("hvc", 0, NULL);
136 return 0;
137}
138console_initcall(hvc_rtas_console_init);
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
index f5212eb2b41d..9add81ceb440 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/char/hvc_vio.c
@@ -31,10 +31,13 @@
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/init.h> 33#include <linux/init.h>
34
34#include <asm/hvconsole.h> 35#include <asm/hvconsole.h>
35#include <asm/vio.h> 36#include <asm/vio.h>
36#include <asm/prom.h> 37#include <asm/prom.h>
37 38
39#include "hvc_console.h"
40
38char hvc_driver_name[] = "hvc_console"; 41char hvc_driver_name[] = "hvc_console";
39 42
40static struct vio_device_id hvc_driver_table[] __devinitdata = { 43static struct vio_device_id hvc_driver_table[] __devinitdata = {
@@ -48,6 +51,14 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
48 unsigned long got; 51 unsigned long got;
49 int i; 52 int i;
50 53
54 /*
55 * Vio firmware will read up to SIZE_VIO_GET_CHARS at its own discretion
56 * so we play safe and avoid the situation where got > count which could
57 * overload the flip buffer.
58 */
59 if (count < SIZE_VIO_GET_CHARS)
60 return -EAGAIN;
61
51 got = hvc_get_chars(vtermno, buf, count); 62 got = hvc_get_chars(vtermno, buf, count);
52 63
53 /* 64 /*
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 831eb4e8d9d3..327b00c3c45e 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -118,7 +118,7 @@
118 * the hvcs_final_close() function in order to get it out of the spinlock. 118 * the hvcs_final_close() function in order to get it out of the spinlock.
119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping 119 * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping
120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from 120 * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from
121 * arch/ppc64/hvcserver.h. 121 * include/asm-powerpc/hvcserver.h
122 * 122 *
123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to 123 * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to
124 * prevent possible lockup with realtime scheduling as similarily pointed out by 124 * prevent possible lockup with realtime scheduling as similarily pointed out by
@@ -168,9 +168,10 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
168 168
169/* 169/*
170 * The hcall interface involves putting 8 chars into each of two registers. 170 * The hcall interface involves putting 8 chars into each of two registers.
171 * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16] 171 * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c)
172 * to long[2]. It would work without __ALIGNED__, but a little (tiny) bit 172 * by casting char[16] to long[2]. It would work without __ALIGNED__, but a
173 * slower because an unaligned load is slower than aligned load. 173 * little (tiny) bit slower because an unaligned load is slower than aligned
174 * load.
174 */ 175 */
175#define __ALIGNED__ __attribute__((__aligned__(8))) 176#define __ALIGNED__ __attribute__((__aligned__(8)))
176 177
@@ -438,7 +439,6 @@ static int hvcs_io(struct hvcs_struct *hvcsd)
438 char buf[HVCS_BUFF_LEN] __ALIGNED__; 439 char buf[HVCS_BUFF_LEN] __ALIGNED__;
439 unsigned long flags; 440 unsigned long flags;
440 int got = 0; 441 int got = 0;
441 int i;
442 442
443 spin_lock_irqsave(&hvcsd->lock, flags); 443 spin_lock_irqsave(&hvcsd->lock, flags);
444 444
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 7c0684deea06..932feedda262 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -90,7 +90,7 @@ static unsigned int ipmi_poll(struct file *file, poll_table *wait)
90 90
91 spin_lock_irqsave(&priv->recv_msg_lock, flags); 91 spin_lock_irqsave(&priv->recv_msg_lock, flags);
92 92
93 if (! list_empty(&(priv->recv_msgs))) 93 if (!list_empty(&(priv->recv_msgs)))
94 mask |= (POLLIN | POLLRDNORM); 94 mask |= (POLLIN | POLLRDNORM);
95 95
96 spin_unlock_irqrestore(&priv->recv_msg_lock, flags); 96 spin_unlock_irqrestore(&priv->recv_msg_lock, flags);
@@ -789,21 +789,53 @@ MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device. By"
789 " interface. Other values will set the major device number" 789 " interface. Other values will set the major device number"
790 " to that value."); 790 " to that value.");
791 791
792/* Keep track of the devices that are registered. */
793struct ipmi_reg_list {
794 dev_t dev;
795 struct list_head link;
796};
797static LIST_HEAD(reg_list);
798static DEFINE_MUTEX(reg_list_mutex);
799
792static struct class *ipmi_class; 800static struct class *ipmi_class;
793 801
794static void ipmi_new_smi(int if_num) 802static void ipmi_new_smi(int if_num, struct device *device)
795{ 803{
796 dev_t dev = MKDEV(ipmi_major, if_num); 804 dev_t dev = MKDEV(ipmi_major, if_num);
805 struct ipmi_reg_list *entry;
797 806
798 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 807 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
799 "ipmidev/%d", if_num); 808 "ipmidev/%d", if_num);
800 809
801 class_device_create(ipmi_class, NULL, dev, NULL, "ipmi%d", if_num); 810 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
811 if (!entry) {
812 printk(KERN_ERR "ipmi_devintf: Unable to create the"
813 " ipmi class device link\n");
814 return;
815 }
816 entry->dev = dev;
817
818 mutex_lock(&reg_list_mutex);
819 class_device_create(ipmi_class, NULL, dev, device, "ipmi%d", if_num);
820 list_add(&entry->link, &reg_list);
821 mutex_unlock(&reg_list_mutex);
802} 822}
803 823
804static void ipmi_smi_gone(int if_num) 824static void ipmi_smi_gone(int if_num)
805{ 825{
806 class_device_destroy(ipmi_class, MKDEV(ipmi_major, if_num)); 826 dev_t dev = MKDEV(ipmi_major, if_num);
827 struct ipmi_reg_list *entry;
828
829 mutex_lock(&reg_list_mutex);
830 list_for_each_entry(entry, &reg_list, link) {
831 if (entry->dev == dev) {
832 list_del(&entry->link);
833 kfree(entry);
834 break;
835 }
836 }
837 class_device_destroy(ipmi_class, dev);
838 mutex_unlock(&reg_list_mutex);
807 devfs_remove("ipmidev/%d", if_num); 839 devfs_remove("ipmidev/%d", if_num);
808} 840}
809 841
@@ -856,6 +888,14 @@ module_init(init_ipmi_devintf);
856 888
857static __exit void cleanup_ipmi(void) 889static __exit void cleanup_ipmi(void)
858{ 890{
891 struct ipmi_reg_list *entry, *entry2;
892 mutex_lock(&reg_list_mutex);
893 list_for_each_entry_safe(entry, entry2, &reg_list, link) {
894 list_del(&entry->link);
895 class_device_destroy(ipmi_class, entry->dev);
896 kfree(entry);
897 }
898 mutex_unlock(&reg_list_mutex);
859 class_destroy(ipmi_class); 899 class_destroy(ipmi_class);
860 ipmi_smi_watcher_unregister(&smi_watcher); 900 ipmi_smi_watcher_unregister(&smi_watcher);
861 devfs_remove(DEVICE_NAME); 901 devfs_remove(DEVICE_NAME);
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d745004281d0..40eb005b9d77 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -48,7 +48,7 @@
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
51#define IPMI_DRIVER_VERSION "38.0" 51#define IPMI_DRIVER_VERSION "39.0"
52 52
53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54static int ipmi_init_msghandler(void); 54static int ipmi_init_msghandler(void);
@@ -162,6 +162,28 @@ struct ipmi_proc_entry
162}; 162};
163#endif 163#endif
164 164
165struct bmc_device
166{
167 struct platform_device *dev;
168 struct ipmi_device_id id;
169 unsigned char guid[16];
170 int guid_set;
171
172 struct kref refcount;
173
174 /* bmc device attributes */
175 struct device_attribute device_id_attr;
176 struct device_attribute provides_dev_sdrs_attr;
177 struct device_attribute revision_attr;
178 struct device_attribute firmware_rev_attr;
179 struct device_attribute version_attr;
180 struct device_attribute add_dev_support_attr;
181 struct device_attribute manufacturer_id_attr;
182 struct device_attribute product_id_attr;
183 struct device_attribute guid_attr;
184 struct device_attribute aux_firmware_rev_attr;
185};
186
165#define IPMI_IPMB_NUM_SEQ 64 187#define IPMI_IPMB_NUM_SEQ 64
166#define IPMI_MAX_CHANNELS 16 188#define IPMI_MAX_CHANNELS 16
167struct ipmi_smi 189struct ipmi_smi
@@ -178,9 +200,8 @@ struct ipmi_smi
178 /* Used for wake ups at startup. */ 200 /* Used for wake ups at startup. */
179 wait_queue_head_t waitq; 201 wait_queue_head_t waitq;
180 202
181 /* The IPMI version of the BMC on the other end. */ 203 struct bmc_device *bmc;
182 unsigned char version_major; 204 char *my_dev_name;
183 unsigned char version_minor;
184 205
185 /* This is the lower-layer's sender routine. */ 206 /* This is the lower-layer's sender routine. */
186 struct ipmi_smi_handlers *handlers; 207 struct ipmi_smi_handlers *handlers;
@@ -194,6 +215,9 @@ struct ipmi_smi
194 struct ipmi_proc_entry *proc_entries; 215 struct ipmi_proc_entry *proc_entries;
195#endif 216#endif
196 217
218 /* Driver-model device for the system interface. */
219 struct device *si_dev;
220
197 /* A table of sequence numbers for this interface. We use the 221 /* A table of sequence numbers for this interface. We use the
198 sequence numbers for IPMB messages that go out of the 222 sequence numbers for IPMB messages that go out of the
199 interface to match them up with their responses. A routine 223 interface to match them up with their responses. A routine
@@ -312,6 +336,7 @@ struct ipmi_smi
312 /* Events that were received with the proper format. */ 336 /* Events that were received with the proper format. */
313 unsigned int events; 337 unsigned int events;
314}; 338};
339#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev)
315 340
316/* Used to mark an interface entry that cannot be used but is not a 341/* Used to mark an interface entry that cannot be used but is not a
317 * free entry, either, primarily used at creation and deletion time so 342 * free entry, either, primarily used at creation and deletion time so
@@ -320,6 +345,15 @@ struct ipmi_smi
320#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \ 345#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
321 || (i == IPMI_INVALID_INTERFACE_ENTRY)) 346 || (i == IPMI_INVALID_INTERFACE_ENTRY))
322 347
348/**
349 * The driver model view of the IPMI messaging driver.
350 */
351static struct device_driver ipmidriver = {
352 .name = "ipmi",
353 .bus = &platform_bus_type
354};
355static DEFINE_MUTEX(ipmidriver_mutex);
356
323#define MAX_IPMI_INTERFACES 4 357#define MAX_IPMI_INTERFACES 4
324static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; 358static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES];
325 359
@@ -393,7 +427,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
393 if (IPMI_INVALID_INTERFACE(intf)) 427 if (IPMI_INVALID_INTERFACE(intf))
394 continue; 428 continue;
395 spin_unlock_irqrestore(&interfaces_lock, flags); 429 spin_unlock_irqrestore(&interfaces_lock, flags);
396 watcher->new_smi(i); 430 watcher->new_smi(i, intf->si_dev);
397 spin_lock_irqsave(&interfaces_lock, flags); 431 spin_lock_irqsave(&interfaces_lock, flags);
398 } 432 }
399 spin_unlock_irqrestore(&interfaces_lock, flags); 433 spin_unlock_irqrestore(&interfaces_lock, flags);
@@ -409,14 +443,14 @@ int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
409} 443}
410 444
411static void 445static void
412call_smi_watchers(int i) 446call_smi_watchers(int i, struct device *dev)
413{ 447{
414 struct ipmi_smi_watcher *w; 448 struct ipmi_smi_watcher *w;
415 449
416 down_read(&smi_watchers_sem); 450 down_read(&smi_watchers_sem);
417 list_for_each_entry(w, &smi_watchers, link) { 451 list_for_each_entry(w, &smi_watchers, link) {
418 if (try_module_get(w->owner)) { 452 if (try_module_get(w->owner)) {
419 w->new_smi(i); 453 w->new_smi(i, dev);
420 module_put(w->owner); 454 module_put(w->owner);
421 } 455 }
422 } 456 }
@@ -736,7 +770,8 @@ int ipmi_create_user(unsigned int if_num,
736 intf = ipmi_interfaces[if_num]; 770 intf = ipmi_interfaces[if_num];
737 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) { 771 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
738 spin_unlock_irqrestore(&interfaces_lock, flags); 772 spin_unlock_irqrestore(&interfaces_lock, flags);
739 return -EINVAL; 773 rv = -EINVAL;
774 goto out_kfree;
740 } 775 }
741 776
742 /* Note that each existing user holds a refcount to the interface. */ 777 /* Note that each existing user holds a refcount to the interface. */
@@ -751,14 +786,14 @@ int ipmi_create_user(unsigned int if_num,
751 786
752 if (!try_module_get(intf->handlers->owner)) { 787 if (!try_module_get(intf->handlers->owner)) {
753 rv = -ENODEV; 788 rv = -ENODEV;
754 goto out_err; 789 goto out_kref;
755 } 790 }
756 791
757 if (intf->handlers->inc_usecount) { 792 if (intf->handlers->inc_usecount) {
758 rv = intf->handlers->inc_usecount(intf->send_info); 793 rv = intf->handlers->inc_usecount(intf->send_info);
759 if (rv) { 794 if (rv) {
760 module_put(intf->handlers->owner); 795 module_put(intf->handlers->owner);
761 goto out_err; 796 goto out_kref;
762 } 797 }
763 } 798 }
764 799
@@ -769,9 +804,10 @@ int ipmi_create_user(unsigned int if_num,
769 *user = new_user; 804 *user = new_user;
770 return 0; 805 return 0;
771 806
772 out_err: 807out_kref:
773 kfree(new_user);
774 kref_put(&intf->refcount, intf_free); 808 kref_put(&intf->refcount, intf_free);
809out_kfree:
810 kfree(new_user);
775 return rv; 811 return rv;
776} 812}
777 813
@@ -842,8 +878,8 @@ void ipmi_get_version(ipmi_user_t user,
842 unsigned char *major, 878 unsigned char *major,
843 unsigned char *minor) 879 unsigned char *minor)
844{ 880{
845 *major = user->intf->version_major; 881 *major = ipmi_version_major(&user->intf->bmc->id);
846 *minor = user->intf->version_minor; 882 *minor = ipmi_version_minor(&user->intf->bmc->id);
847} 883}
848 884
849int ipmi_set_my_address(ipmi_user_t user, 885int ipmi_set_my_address(ipmi_user_t user,
@@ -1551,7 +1587,8 @@ static int version_file_read_proc(char *page, char **start, off_t off,
1551 ipmi_smi_t intf = data; 1587 ipmi_smi_t intf = data;
1552 1588
1553 return sprintf(out, "%d.%d\n", 1589 return sprintf(out, "%d.%d\n",
1554 intf->version_major, intf->version_minor); 1590 ipmi_version_major(&intf->bmc->id),
1591 ipmi_version_minor(&intf->bmc->id));
1555} 1592}
1556 1593
1557static int stat_file_read_proc(char *page, char **start, off_t off, 1594static int stat_file_read_proc(char *page, char **start, off_t off,
@@ -1710,6 +1747,470 @@ static void remove_proc_entries(ipmi_smi_t smi)
1710#endif /* CONFIG_PROC_FS */ 1747#endif /* CONFIG_PROC_FS */
1711} 1748}
1712 1749
1750static int __find_bmc_guid(struct device *dev, void *data)
1751{
1752 unsigned char *id = data;
1753 struct bmc_device *bmc = dev_get_drvdata(dev);
1754 return memcmp(bmc->guid, id, 16) == 0;
1755}
1756
1757static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv,
1758 unsigned char *guid)
1759{
1760 struct device *dev;
1761
1762 dev = driver_find_device(drv, NULL, guid, __find_bmc_guid);
1763 if (dev)
1764 return dev_get_drvdata(dev);
1765 else
1766 return NULL;
1767}
1768
1769struct prod_dev_id {
1770 unsigned int product_id;
1771 unsigned char device_id;
1772};
1773
1774static int __find_bmc_prod_dev_id(struct device *dev, void *data)
1775{
1776 struct prod_dev_id *id = data;
1777 struct bmc_device *bmc = dev_get_drvdata(dev);
1778
1779 return (bmc->id.product_id == id->product_id
1780 && bmc->id.product_id == id->product_id
1781 && bmc->id.device_id == id->device_id);
1782}
1783
1784static struct bmc_device *ipmi_find_bmc_prod_dev_id(
1785 struct device_driver *drv,
1786 unsigned char product_id, unsigned char device_id)
1787{
1788 struct prod_dev_id id = {
1789 .product_id = product_id,
1790 .device_id = device_id,
1791 };
1792 struct device *dev;
1793
1794 dev = driver_find_device(drv, NULL, &id, __find_bmc_prod_dev_id);
1795 if (dev)
1796 return dev_get_drvdata(dev);
1797 else
1798 return NULL;
1799}
1800
1801static ssize_t device_id_show(struct device *dev,
1802 struct device_attribute *attr,
1803 char *buf)
1804{
1805 struct bmc_device *bmc = dev_get_drvdata(dev);
1806
1807 return snprintf(buf, 10, "%u\n", bmc->id.device_id);
1808}
1809
1810static ssize_t provides_dev_sdrs_show(struct device *dev,
1811 struct device_attribute *attr,
1812 char *buf)
1813{
1814 struct bmc_device *bmc = dev_get_drvdata(dev);
1815
1816 return snprintf(buf, 10, "%u\n",
1817 bmc->id.device_revision && 0x80 >> 7);
1818}
1819
1820static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
1821 char *buf)
1822{
1823 struct bmc_device *bmc = dev_get_drvdata(dev);
1824
1825 return snprintf(buf, 20, "%u\n",
1826 bmc->id.device_revision && 0x0F);
1827}
1828
1829static ssize_t firmware_rev_show(struct device *dev,
1830 struct device_attribute *attr,
1831 char *buf)
1832{
1833 struct bmc_device *bmc = dev_get_drvdata(dev);
1834
1835 return snprintf(buf, 20, "%u.%x\n", bmc->id.firmware_revision_1,
1836 bmc->id.firmware_revision_2);
1837}
1838
1839static ssize_t ipmi_version_show(struct device *dev,
1840 struct device_attribute *attr,
1841 char *buf)
1842{
1843 struct bmc_device *bmc = dev_get_drvdata(dev);
1844
1845 return snprintf(buf, 20, "%u.%u\n",
1846 ipmi_version_major(&bmc->id),
1847 ipmi_version_minor(&bmc->id));
1848}
1849
1850static ssize_t add_dev_support_show(struct device *dev,
1851 struct device_attribute *attr,
1852 char *buf)
1853{
1854 struct bmc_device *bmc = dev_get_drvdata(dev);
1855
1856 return snprintf(buf, 10, "0x%02x\n",
1857 bmc->id.additional_device_support);
1858}
1859
1860static ssize_t manufacturer_id_show(struct device *dev,
1861 struct device_attribute *attr,
1862 char *buf)
1863{
1864 struct bmc_device *bmc = dev_get_drvdata(dev);
1865
1866 return snprintf(buf, 20, "0x%6.6x\n", bmc->id.manufacturer_id);
1867}
1868
1869static ssize_t product_id_show(struct device *dev,
1870 struct device_attribute *attr,
1871 char *buf)
1872{
1873 struct bmc_device *bmc = dev_get_drvdata(dev);
1874
1875 return snprintf(buf, 10, "0x%4.4x\n", bmc->id.product_id);
1876}
1877
1878static ssize_t aux_firmware_rev_show(struct device *dev,
1879 struct device_attribute *attr,
1880 char *buf)
1881{
1882 struct bmc_device *bmc = dev_get_drvdata(dev);
1883
1884 return snprintf(buf, 21, "0x%02x 0x%02x 0x%02x 0x%02x\n",
1885 bmc->id.aux_firmware_revision[3],
1886 bmc->id.aux_firmware_revision[2],
1887 bmc->id.aux_firmware_revision[1],
1888 bmc->id.aux_firmware_revision[0]);
1889}
1890
1891static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1892 char *buf)
1893{
1894 struct bmc_device *bmc = dev_get_drvdata(dev);
1895
1896 return snprintf(buf, 100, "%Lx%Lx\n",
1897 (long long) bmc->guid[0],
1898 (long long) bmc->guid[8]);
1899}
1900
1901static void
1902cleanup_bmc_device(struct kref *ref)
1903{
1904 struct bmc_device *bmc;
1905
1906 bmc = container_of(ref, struct bmc_device, refcount);
1907
1908 device_remove_file(&bmc->dev->dev,
1909 &bmc->device_id_attr);
1910 device_remove_file(&bmc->dev->dev,
1911 &bmc->provides_dev_sdrs_attr);
1912 device_remove_file(&bmc->dev->dev,
1913 &bmc->revision_attr);
1914 device_remove_file(&bmc->dev->dev,
1915 &bmc->firmware_rev_attr);
1916 device_remove_file(&bmc->dev->dev,
1917 &bmc->version_attr);
1918 device_remove_file(&bmc->dev->dev,
1919 &bmc->add_dev_support_attr);
1920 device_remove_file(&bmc->dev->dev,
1921 &bmc->manufacturer_id_attr);
1922 device_remove_file(&bmc->dev->dev,
1923 &bmc->product_id_attr);
1924 if (bmc->id.aux_firmware_revision_set)
1925 device_remove_file(&bmc->dev->dev,
1926 &bmc->aux_firmware_rev_attr);
1927 if (bmc->guid_set)
1928 device_remove_file(&bmc->dev->dev,
1929 &bmc->guid_attr);
1930 platform_device_unregister(bmc->dev);
1931 kfree(bmc);
1932}
1933
1934static void ipmi_bmc_unregister(ipmi_smi_t intf)
1935{
1936 struct bmc_device *bmc = intf->bmc;
1937
1938 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
1939 if (intf->my_dev_name) {
1940 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
1941 kfree(intf->my_dev_name);
1942 intf->my_dev_name = NULL;
1943 }
1944
1945 mutex_lock(&ipmidriver_mutex);
1946 kref_put(&bmc->refcount, cleanup_bmc_device);
1947 mutex_unlock(&ipmidriver_mutex);
1948}
1949
1950static int ipmi_bmc_register(ipmi_smi_t intf)
1951{
1952 int rv;
1953 struct bmc_device *bmc = intf->bmc;
1954 struct bmc_device *old_bmc;
1955 int size;
1956 char dummy[1];
1957
1958 mutex_lock(&ipmidriver_mutex);
1959
1960 /*
1961 * Try to find if there is an bmc_device struct
1962 * representing the interfaced BMC already
1963 */
1964 if (bmc->guid_set)
1965 old_bmc = ipmi_find_bmc_guid(&ipmidriver, bmc->guid);
1966 else
1967 old_bmc = ipmi_find_bmc_prod_dev_id(&ipmidriver,
1968 bmc->id.product_id,
1969 bmc->id.device_id);
1970
1971 /*
1972 * If there is already an bmc_device, free the new one,
1973 * otherwise register the new BMC device
1974 */
1975 if (old_bmc) {
1976 kfree(bmc);
1977 intf->bmc = old_bmc;
1978 bmc = old_bmc;
1979
1980 kref_get(&bmc->refcount);
1981 mutex_unlock(&ipmidriver_mutex);
1982
1983 printk(KERN_INFO
1984 "ipmi: interfacing existing BMC (man_id: 0x%6.6x,"
1985 " prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n",
1986 bmc->id.manufacturer_id,
1987 bmc->id.product_id,
1988 bmc->id.device_id);
1989 } else {
1990 bmc->dev = platform_device_alloc("ipmi_bmc",
1991 bmc->id.device_id);
1992 if (! bmc->dev) {
1993 printk(KERN_ERR
1994 "ipmi_msghandler:"
1995 " Unable to allocate platform device\n");
1996 return -ENOMEM;
1997 }
1998 bmc->dev->dev.driver = &ipmidriver;
1999 dev_set_drvdata(&bmc->dev->dev, bmc);
2000 kref_init(&bmc->refcount);
2001
2002 rv = platform_device_register(bmc->dev);
2003 mutex_unlock(&ipmidriver_mutex);
2004 if (rv) {
2005 printk(KERN_ERR
2006 "ipmi_msghandler:"
2007 " Unable to register bmc device: %d\n",
2008 rv);
2009 /* Don't go to out_err, you can only do that if
2010 the device is registered already. */
2011 return rv;
2012 }
2013
2014 bmc->device_id_attr.attr.name = "device_id";
2015 bmc->device_id_attr.attr.owner = THIS_MODULE;
2016 bmc->device_id_attr.attr.mode = S_IRUGO;
2017 bmc->device_id_attr.show = device_id_show;
2018
2019 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2020 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2021 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2022 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2023
2024
2025 bmc->revision_attr.attr.name = "revision";
2026 bmc->revision_attr.attr.owner = THIS_MODULE;
2027 bmc->revision_attr.attr.mode = S_IRUGO;
2028 bmc->revision_attr.show = revision_show;
2029
2030 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2031 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2032 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2033 bmc->firmware_rev_attr.show = firmware_rev_show;
2034
2035 bmc->version_attr.attr.name = "ipmi_version";
2036 bmc->version_attr.attr.owner = THIS_MODULE;
2037 bmc->version_attr.attr.mode = S_IRUGO;
2038 bmc->version_attr.show = ipmi_version_show;
2039
2040 bmc->add_dev_support_attr.attr.name
2041 = "additional_device_support";
2042 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2043 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2044 bmc->add_dev_support_attr.show = add_dev_support_show;
2045
2046 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2047 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2048 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2049 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2050
2051 bmc->product_id_attr.attr.name = "product_id";
2052 bmc->product_id_attr.attr.owner = THIS_MODULE;
2053 bmc->product_id_attr.attr.mode = S_IRUGO;
2054 bmc->product_id_attr.show = product_id_show;
2055
2056 bmc->guid_attr.attr.name = "guid";
2057 bmc->guid_attr.attr.owner = THIS_MODULE;
2058 bmc->guid_attr.attr.mode = S_IRUGO;
2059 bmc->guid_attr.show = guid_show;
2060
2061 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2062 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2063 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2064 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2065
2066 device_create_file(&bmc->dev->dev,
2067 &bmc->device_id_attr);
2068 device_create_file(&bmc->dev->dev,
2069 &bmc->provides_dev_sdrs_attr);
2070 device_create_file(&bmc->dev->dev,
2071 &bmc->revision_attr);
2072 device_create_file(&bmc->dev->dev,
2073 &bmc->firmware_rev_attr);
2074 device_create_file(&bmc->dev->dev,
2075 &bmc->version_attr);
2076 device_create_file(&bmc->dev->dev,
2077 &bmc->add_dev_support_attr);
2078 device_create_file(&bmc->dev->dev,
2079 &bmc->manufacturer_id_attr);
2080 device_create_file(&bmc->dev->dev,
2081 &bmc->product_id_attr);
2082 if (bmc->id.aux_firmware_revision_set)
2083 device_create_file(&bmc->dev->dev,
2084 &bmc->aux_firmware_rev_attr);
2085 if (bmc->guid_set)
2086 device_create_file(&bmc->dev->dev,
2087 &bmc->guid_attr);
2088
2089 printk(KERN_INFO
2090 "ipmi: Found new BMC (man_id: 0x%6.6x, "
2091 " prod_id: 0x%4.4x, dev_id: 0x%2.2x)\n",
2092 bmc->id.manufacturer_id,
2093 bmc->id.product_id,
2094 bmc->id.device_id);
2095 }
2096
2097 /*
2098 * create symlink from system interface device to bmc device
2099 * and back.
2100 */
2101 rv = sysfs_create_link(&intf->si_dev->kobj,
2102 &bmc->dev->dev.kobj, "bmc");
2103 if (rv) {
2104 printk(KERN_ERR
2105 "ipmi_msghandler: Unable to create bmc symlink: %d\n",
2106 rv);
2107 goto out_err;
2108 }
2109
2110 size = snprintf(dummy, 0, "ipmi%d", intf->intf_num);
2111 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
2112 if (!intf->my_dev_name) {
2113 rv = -ENOMEM;
2114 printk(KERN_ERR
2115 "ipmi_msghandler: allocate link from BMC: %d\n",
2116 rv);
2117 goto out_err;
2118 }
2119 snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num);
2120
2121 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
2122 intf->my_dev_name);
2123 if (rv) {
2124 kfree(intf->my_dev_name);
2125 intf->my_dev_name = NULL;
2126 printk(KERN_ERR
2127 "ipmi_msghandler:"
2128 " Unable to create symlink to bmc: %d\n",
2129 rv);
2130 goto out_err;
2131 }
2132
2133 return 0;
2134
2135out_err:
2136 ipmi_bmc_unregister(intf);
2137 return rv;
2138}
2139
2140static int
2141send_guid_cmd(ipmi_smi_t intf, int chan)
2142{
2143 struct kernel_ipmi_msg msg;
2144 struct ipmi_system_interface_addr si;
2145
2146 si.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
2147 si.channel = IPMI_BMC_CHANNEL;
2148 si.lun = 0;
2149
2150 msg.netfn = IPMI_NETFN_APP_REQUEST;
2151 msg.cmd = IPMI_GET_DEVICE_GUID_CMD;
2152 msg.data = NULL;
2153 msg.data_len = 0;
2154 return i_ipmi_request(NULL,
2155 intf,
2156 (struct ipmi_addr *) &si,
2157 0,
2158 &msg,
2159 intf,
2160 NULL,
2161 NULL,
2162 0,
2163 intf->channels[0].address,
2164 intf->channels[0].lun,
2165 -1, 0);
2166}
2167
2168static void
2169guid_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2170{
2171 if ((msg->addr.addr_type != IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
2172 || (msg->msg.netfn != IPMI_NETFN_APP_RESPONSE)
2173 || (msg->msg.cmd != IPMI_GET_DEVICE_GUID_CMD))
2174 /* Not for me */
2175 return;
2176
2177 if (msg->msg.data[0] != 0) {
2178 /* Error from getting the GUID, the BMC doesn't have one. */
2179 intf->bmc->guid_set = 0;
2180 goto out;
2181 }
2182
2183 if (msg->msg.data_len < 17) {
2184 intf->bmc->guid_set = 0;
2185 printk(KERN_WARNING PFX
2186 "guid_handler: The GUID response from the BMC was too"
2187 " short, it was %d but should have been 17. Assuming"
2188 " GUID is not available.\n",
2189 msg->msg.data_len);
2190 goto out;
2191 }
2192
2193 memcpy(intf->bmc->guid, msg->msg.data, 16);
2194 intf->bmc->guid_set = 1;
2195 out:
2196 wake_up(&intf->waitq);
2197}
2198
2199static void
2200get_guid(ipmi_smi_t intf)
2201{
2202 int rv;
2203
2204 intf->bmc->guid_set = 0x2;
2205 intf->null_user_handler = guid_handler;
2206 rv = send_guid_cmd(intf, 0);
2207 if (rv)
2208 /* Send failed, no GUID available. */
2209 intf->bmc->guid_set = 0;
2210 wait_event(intf->waitq, intf->bmc->guid_set != 2);
2211 intf->null_user_handler = NULL;
2212}
2213
1713static int 2214static int
1714send_channel_info_cmd(ipmi_smi_t intf, int chan) 2215send_channel_info_cmd(ipmi_smi_t intf, int chan)
1715{ 2216{
@@ -1802,8 +2303,8 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
1802 2303
1803int ipmi_register_smi(struct ipmi_smi_handlers *handlers, 2304int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1804 void *send_info, 2305 void *send_info,
1805 unsigned char version_major, 2306 struct ipmi_device_id *device_id,
1806 unsigned char version_minor, 2307 struct device *si_dev,
1807 unsigned char slave_addr, 2308 unsigned char slave_addr,
1808 ipmi_smi_t *new_intf) 2309 ipmi_smi_t *new_intf)
1809{ 2310{
@@ -1811,7 +2312,11 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1811 int rv; 2312 int rv;
1812 ipmi_smi_t intf; 2313 ipmi_smi_t intf;
1813 unsigned long flags; 2314 unsigned long flags;
2315 int version_major;
2316 int version_minor;
1814 2317
2318 version_major = ipmi_version_major(device_id);
2319 version_minor = ipmi_version_minor(device_id);
1815 2320
1816 /* Make sure the driver is actually initialized, this handles 2321 /* Make sure the driver is actually initialized, this handles
1817 problems with initialization order. */ 2322 problems with initialization order. */
@@ -1829,10 +2334,15 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1829 if (!intf) 2334 if (!intf)
1830 return -ENOMEM; 2335 return -ENOMEM;
1831 memset(intf, 0, sizeof(*intf)); 2336 memset(intf, 0, sizeof(*intf));
2337 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL);
2338 if (!intf->bmc) {
2339 kfree(intf);
2340 return -ENOMEM;
2341 }
1832 intf->intf_num = -1; 2342 intf->intf_num = -1;
1833 kref_init(&intf->refcount); 2343 kref_init(&intf->refcount);
1834 intf->version_major = version_major; 2344 intf->bmc->id = *device_id;
1835 intf->version_minor = version_minor; 2345 intf->si_dev = si_dev;
1836 for (j = 0; j < IPMI_MAX_CHANNELS; j++) { 2346 for (j = 0; j < IPMI_MAX_CHANNELS; j++) {
1837 intf->channels[j].address = IPMI_BMC_SLAVE_ADDR; 2347 intf->channels[j].address = IPMI_BMC_SLAVE_ADDR;
1838 intf->channels[j].lun = 2; 2348 intf->channels[j].lun = 2;
@@ -1882,6 +2392,8 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1882 caller before sending any messages with it. */ 2392 caller before sending any messages with it. */
1883 *new_intf = intf; 2393 *new_intf = intf;
1884 2394
2395 get_guid(intf);
2396
1885 if ((version_major > 1) 2397 if ((version_major > 1)
1886 || ((version_major == 1) && (version_minor >= 5))) 2398 || ((version_major == 1) && (version_minor >= 5)))
1887 { 2399 {
@@ -1896,6 +2408,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1896 /* Wait for the channel info to be read. */ 2408 /* Wait for the channel info to be read. */
1897 wait_event(intf->waitq, 2409 wait_event(intf->waitq,
1898 intf->curr_channel >= IPMI_MAX_CHANNELS); 2410 intf->curr_channel >= IPMI_MAX_CHANNELS);
2411 intf->null_user_handler = NULL;
1899 } else { 2412 } else {
1900 /* Assume a single IPMB channel at zero. */ 2413 /* Assume a single IPMB channel at zero. */
1901 intf->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB; 2414 intf->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB;
@@ -1905,6 +2418,8 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1905 if (rv == 0) 2418 if (rv == 0)
1906 rv = add_proc_entries(intf, i); 2419 rv = add_proc_entries(intf, i);
1907 2420
2421 rv = ipmi_bmc_register(intf);
2422
1908 out: 2423 out:
1909 if (rv) { 2424 if (rv) {
1910 if (intf->proc_dir) 2425 if (intf->proc_dir)
@@ -1919,7 +2434,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1919 spin_lock_irqsave(&interfaces_lock, flags); 2434 spin_lock_irqsave(&interfaces_lock, flags);
1920 ipmi_interfaces[i] = intf; 2435 ipmi_interfaces[i] = intf;
1921 spin_unlock_irqrestore(&interfaces_lock, flags); 2436 spin_unlock_irqrestore(&interfaces_lock, flags);
1922 call_smi_watchers(i); 2437 call_smi_watchers(i, intf->si_dev);
1923 } 2438 }
1924 2439
1925 return rv; 2440 return rv;
@@ -1931,6 +2446,8 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
1931 struct ipmi_smi_watcher *w; 2446 struct ipmi_smi_watcher *w;
1932 unsigned long flags; 2447 unsigned long flags;
1933 2448
2449 ipmi_bmc_unregister(intf);
2450
1934 spin_lock_irqsave(&interfaces_lock, flags); 2451 spin_lock_irqsave(&interfaces_lock, flags);
1935 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2452 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
1936 if (ipmi_interfaces[i] == intf) { 2453 if (ipmi_interfaces[i] == intf) {
@@ -3194,10 +3711,17 @@ static struct notifier_block panic_block = {
3194static int ipmi_init_msghandler(void) 3711static int ipmi_init_msghandler(void)
3195{ 3712{
3196 int i; 3713 int i;
3714 int rv;
3197 3715
3198 if (initialized) 3716 if (initialized)
3199 return 0; 3717 return 0;
3200 3718
3719 rv = driver_register(&ipmidriver);
3720 if (rv) {
3721 printk(KERN_ERR PFX "Could not register IPMI driver\n");
3722 return rv;
3723 }
3724
3201 printk(KERN_INFO "ipmi message handler version " 3725 printk(KERN_INFO "ipmi message handler version "
3202 IPMI_DRIVER_VERSION "\n"); 3726 IPMI_DRIVER_VERSION "\n");
3203 3727
@@ -3220,7 +3744,7 @@ static int ipmi_init_msghandler(void)
3220 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES; 3744 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES;
3221 add_timer(&ipmi_timer); 3745 add_timer(&ipmi_timer);
3222 3746
3223 notifier_chain_register(&panic_notifier_list, &panic_block); 3747 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
3224 3748
3225 initialized = 1; 3749 initialized = 1;
3226 3750
@@ -3240,7 +3764,7 @@ static __exit void cleanup_ipmi(void)
3240 if (!initialized) 3764 if (!initialized)
3241 return; 3765 return;
3242 3766
3243 notifier_chain_unregister(&panic_notifier_list, &panic_block); 3767 atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
3244 3768
3245 /* This can't be called if any interfaces exist, so no worry about 3769 /* This can't be called if any interfaces exist, so no worry about
3246 shutting down the interfaces. */ 3770 shutting down the interfaces. */
@@ -3254,6 +3778,8 @@ static __exit void cleanup_ipmi(void)
3254 remove_proc_entry(proc_ipmi_root->name, &proc_root); 3778 remove_proc_entry(proc_ipmi_root->name, &proc_root);
3255#endif /* CONFIG_PROC_FS */ 3779#endif /* CONFIG_PROC_FS */
3256 3780
3781 driver_unregister(&ipmidriver);
3782
3257 initialized = 0; 3783 initialized = 0;
3258 3784
3259 /* Check for buffer leaks. */ 3785 /* Check for buffer leaks. */
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 49c09ae004bf..786a2802ca34 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -37,15 +37,13 @@
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/completion.h> 39#include <linux/completion.h>
40#include <linux/pm.h>
40#include <linux/kdev_t.h> 41#include <linux/kdev_t.h>
41#include <linux/ipmi.h> 42#include <linux/ipmi.h>
42#include <linux/ipmi_smi.h> 43#include <linux/ipmi_smi.h>
43 44
44#define PFX "IPMI poweroff: " 45#define PFX "IPMI poweroff: "
45 46
46/* Where to we insert our poweroff function? */
47extern void (*pm_power_off)(void);
48
49/* Definitions for controlling power off (if the system supports it). It 47/* Definitions for controlling power off (if the system supports it). It
50 * conveniently matches the IPMI chassis control values. */ 48 * conveniently matches the IPMI chassis control values. */
51#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */ 49#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
@@ -466,7 +464,7 @@ static void ipmi_poweroff_function (void)
466 464
467/* Wait for an IPMI interface to be installed, the first one installed 465/* Wait for an IPMI interface to be installed, the first one installed
468 will be grabbed by this code and used to perform the powerdown. */ 466 will be grabbed by this code and used to perform the powerdown. */
469static void ipmi_po_new_smi(int if_num) 467static void ipmi_po_new_smi(int if_num, struct device *device)
470{ 468{
471 struct ipmi_system_interface_addr smi_addr; 469 struct ipmi_system_interface_addr smi_addr;
472 struct kernel_ipmi_msg send_msg; 470 struct kernel_ipmi_msg send_msg;
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index e59b638766ef..35fbd4d8ed4b 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -52,6 +52,7 @@
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/ioport.h> 53#include <linux/ioport.h>
54#include <linux/notifier.h> 54#include <linux/notifier.h>
55#include <linux/mutex.h>
55#include <linux/kthread.h> 56#include <linux/kthread.h>
56#include <asm/irq.h> 57#include <asm/irq.h>
57#ifdef CONFIG_HIGH_RES_TIMERS 58#ifdef CONFIG_HIGH_RES_TIMERS
@@ -109,21 +110,15 @@ enum si_intf_state {
109enum si_type { 110enum si_type {
110 SI_KCS, SI_SMIC, SI_BT 111 SI_KCS, SI_SMIC, SI_BT
111}; 112};
113static char *si_to_str[] = { "KCS", "SMIC", "BT" };
112 114
113struct ipmi_device_id { 115#define DEVICE_NAME "ipmi_si"
114 unsigned char device_id; 116
115 unsigned char device_revision; 117static struct device_driver ipmi_driver =
116 unsigned char firmware_revision_1; 118{
117 unsigned char firmware_revision_2; 119 .name = DEVICE_NAME,
118 unsigned char ipmi_version; 120 .bus = &platform_bus_type
119 unsigned char additional_device_support; 121};
120 unsigned char manufacturer_id[3];
121 unsigned char product_id[2];
122 unsigned char aux_firmware_revision[4];
123} __attribute__((packed));
124
125#define ipmi_version_major(v) ((v)->ipmi_version & 0xf)
126#define ipmi_version_minor(v) ((v)->ipmi_version >> 4)
127 122
128struct smi_info 123struct smi_info
129{ 124{
@@ -147,6 +142,9 @@ struct smi_info
147 int (*irq_setup)(struct smi_info *info); 142 int (*irq_setup)(struct smi_info *info);
148 void (*irq_cleanup)(struct smi_info *info); 143 void (*irq_cleanup)(struct smi_info *info);
149 unsigned int io_size; 144 unsigned int io_size;
145 char *addr_source; /* ACPI, PCI, SMBIOS, hardcode, default. */
146 void (*addr_source_cleanup)(struct smi_info *info);
147 void *addr_source_data;
150 148
151 /* Per-OEM handler, called from handle_flags(). 149 /* Per-OEM handler, called from handle_flags().
152 Returns 1 when handle_flags() needs to be re-run 150 Returns 1 when handle_flags() needs to be re-run
@@ -203,8 +201,17 @@ struct smi_info
203 interrupts. */ 201 interrupts. */
204 int interrupt_disabled; 202 int interrupt_disabled;
205 203
204 /* From the get device id response... */
206 struct ipmi_device_id device_id; 205 struct ipmi_device_id device_id;
207 206
207 /* Driver model stuff. */
208 struct device *dev;
209 struct platform_device *pdev;
210
211 /* True if we allocated the device, false if it came from
212 * someplace else (like PCI). */
213 int dev_registered;
214
208 /* Slave address, could be reported from DMI. */ 215 /* Slave address, could be reported from DMI. */
209 unsigned char slave_addr; 216 unsigned char slave_addr;
210 217
@@ -224,12 +231,16 @@ struct smi_info
224 unsigned long incoming_messages; 231 unsigned long incoming_messages;
225 232
226 struct task_struct *thread; 233 struct task_struct *thread;
234
235 struct list_head link;
227}; 236};
228 237
229static struct notifier_block *xaction_notifier_list; 238static int try_smi_init(struct smi_info *smi);
239
240static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list);
230static int register_xaction_notifier(struct notifier_block * nb) 241static int register_xaction_notifier(struct notifier_block * nb)
231{ 242{
232 return notifier_chain_register(&xaction_notifier_list, nb); 243 return atomic_notifier_chain_register(&xaction_notifier_list, nb);
233} 244}
234 245
235static void si_restart_short_timer(struct smi_info *smi_info); 246static void si_restart_short_timer(struct smi_info *smi_info);
@@ -271,13 +282,13 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
271 spin_lock(&(smi_info->msg_lock)); 282 spin_lock(&(smi_info->msg_lock));
272 283
273 /* Pick the high priority queue first. */ 284 /* Pick the high priority queue first. */
274 if (! list_empty(&(smi_info->hp_xmit_msgs))) { 285 if (!list_empty(&(smi_info->hp_xmit_msgs))) {
275 entry = smi_info->hp_xmit_msgs.next; 286 entry = smi_info->hp_xmit_msgs.next;
276 } else if (! list_empty(&(smi_info->xmit_msgs))) { 287 } else if (!list_empty(&(smi_info->xmit_msgs))) {
277 entry = smi_info->xmit_msgs.next; 288 entry = smi_info->xmit_msgs.next;
278 } 289 }
279 290
280 if (! entry) { 291 if (!entry) {
281 smi_info->curr_msg = NULL; 292 smi_info->curr_msg = NULL;
282 rv = SI_SM_IDLE; 293 rv = SI_SM_IDLE;
283 } else { 294 } else {
@@ -291,7 +302,8 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
291 do_gettimeofday(&t); 302 do_gettimeofday(&t);
292 printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); 303 printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec);
293#endif 304#endif
294 err = notifier_call_chain(&xaction_notifier_list, 0, smi_info); 305 err = atomic_notifier_call_chain(&xaction_notifier_list,
306 0, smi_info);
295 if (err & NOTIFY_STOP_MASK) { 307 if (err & NOTIFY_STOP_MASK) {
296 rv = SI_SM_CALL_WITHOUT_DELAY; 308 rv = SI_SM_CALL_WITHOUT_DELAY;
297 goto out; 309 goto out;
@@ -344,7 +356,7 @@ static void start_clear_flags(struct smi_info *smi_info)
344 memory, we will re-enable the interrupt. */ 356 memory, we will re-enable the interrupt. */
345static inline void disable_si_irq(struct smi_info *smi_info) 357static inline void disable_si_irq(struct smi_info *smi_info)
346{ 358{
347 if ((smi_info->irq) && (! smi_info->interrupt_disabled)) { 359 if ((smi_info->irq) && (!smi_info->interrupt_disabled)) {
348 disable_irq_nosync(smi_info->irq); 360 disable_irq_nosync(smi_info->irq);
349 smi_info->interrupt_disabled = 1; 361 smi_info->interrupt_disabled = 1;
350 } 362 }
@@ -375,7 +387,7 @@ static void handle_flags(struct smi_info *smi_info)
375 } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) { 387 } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) {
376 /* Messages available. */ 388 /* Messages available. */
377 smi_info->curr_msg = ipmi_alloc_smi_msg(); 389 smi_info->curr_msg = ipmi_alloc_smi_msg();
378 if (! smi_info->curr_msg) { 390 if (!smi_info->curr_msg) {
379 disable_si_irq(smi_info); 391 disable_si_irq(smi_info);
380 smi_info->si_state = SI_NORMAL; 392 smi_info->si_state = SI_NORMAL;
381 return; 393 return;
@@ -394,7 +406,7 @@ static void handle_flags(struct smi_info *smi_info)
394 } else if (smi_info->msg_flags & EVENT_MSG_BUFFER_FULL) { 406 } else if (smi_info->msg_flags & EVENT_MSG_BUFFER_FULL) {
395 /* Events available. */ 407 /* Events available. */
396 smi_info->curr_msg = ipmi_alloc_smi_msg(); 408 smi_info->curr_msg = ipmi_alloc_smi_msg();
397 if (! smi_info->curr_msg) { 409 if (!smi_info->curr_msg) {
398 disable_si_irq(smi_info); 410 disable_si_irq(smi_info);
399 smi_info->si_state = SI_NORMAL; 411 smi_info->si_state = SI_NORMAL;
400 return; 412 return;
@@ -430,7 +442,7 @@ static void handle_transaction_done(struct smi_info *smi_info)
430#endif 442#endif
431 switch (smi_info->si_state) { 443 switch (smi_info->si_state) {
432 case SI_NORMAL: 444 case SI_NORMAL:
433 if (! smi_info->curr_msg) 445 if (!smi_info->curr_msg)
434 break; 446 break;
435 447
436 smi_info->curr_msg->rsp_size 448 smi_info->curr_msg->rsp_size
@@ -880,7 +892,7 @@ static void smi_timeout(unsigned long data)
880 892
881 smi_info->last_timeout_jiffies = jiffies_now; 893 smi_info->last_timeout_jiffies = jiffies_now;
882 894
883 if ((smi_info->irq) && (! smi_info->interrupt_disabled)) { 895 if ((smi_info->irq) && (!smi_info->interrupt_disabled)) {
884 /* Running with interrupts, only do long timeouts. */ 896 /* Running with interrupts, only do long timeouts. */
885 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 897 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
886 spin_lock_irqsave(&smi_info->count_lock, flags); 898 spin_lock_irqsave(&smi_info->count_lock, flags);
@@ -974,15 +986,10 @@ static struct ipmi_smi_handlers handlers =
974 a default IO port, and 1 ACPI/SPMI address. That sets SI_MAX_DRIVERS */ 986 a default IO port, and 1 ACPI/SPMI address. That sets SI_MAX_DRIVERS */
975 987
976#define SI_MAX_PARMS 4 988#define SI_MAX_PARMS 4
977#define SI_MAX_DRIVERS ((SI_MAX_PARMS * 2) + 2) 989static LIST_HEAD(smi_infos);
978static struct smi_info *smi_infos[SI_MAX_DRIVERS] = 990static DECLARE_MUTEX(smi_infos_lock);
979{ NULL, NULL, NULL, NULL }; 991static int smi_num; /* Used to sequence the SMIs */
980 992
981#define DEVICE_NAME "ipmi_si"
982
983#define DEFAULT_KCS_IO_PORT 0xca2
984#define DEFAULT_SMIC_IO_PORT 0xca9
985#define DEFAULT_BT_IO_PORT 0xe4
986#define DEFAULT_REGSPACING 1 993#define DEFAULT_REGSPACING 1
987 994
988static int si_trydefaults = 1; 995static int si_trydefaults = 1;
@@ -1053,38 +1060,23 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for"
1053 " by interface number."); 1060 " by interface number.");
1054 1061
1055 1062
1063#define IPMI_IO_ADDR_SPACE 0
1056#define IPMI_MEM_ADDR_SPACE 1 1064#define IPMI_MEM_ADDR_SPACE 1
1057#define IPMI_IO_ADDR_SPACE 2 1065static char *addr_space_to_str[] = { "I/O", "memory" };
1058 1066
1059#if defined(CONFIG_ACPI) || defined(CONFIG_DMI) || defined(CONFIG_PCI) 1067static void std_irq_cleanup(struct smi_info *info)
1060static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr)
1061{ 1068{
1062 int i; 1069 if (info->si_type == SI_BT)
1063 1070 /* Disable the interrupt in the BT interface. */
1064 for (i = 0; i < SI_MAX_PARMS; ++i) { 1071 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, 0);
1065 /* Don't check our address. */ 1072 free_irq(info->irq, info);
1066 if (i == intf)
1067 continue;
1068 if (si_type[i] != NULL) {
1069 if ((addr_space == IPMI_MEM_ADDR_SPACE &&
1070 base_addr == addrs[i]) ||
1071 (addr_space == IPMI_IO_ADDR_SPACE &&
1072 base_addr == ports[i]))
1073 return 0;
1074 }
1075 else
1076 break;
1077 }
1078
1079 return 1;
1080} 1073}
1081#endif
1082 1074
1083static int std_irq_setup(struct smi_info *info) 1075static int std_irq_setup(struct smi_info *info)
1084{ 1076{
1085 int rv; 1077 int rv;
1086 1078
1087 if (! info->irq) 1079 if (!info->irq)
1088 return 0; 1080 return 0;
1089 1081
1090 if (info->si_type == SI_BT) { 1082 if (info->si_type == SI_BT) {
@@ -1093,7 +1085,7 @@ static int std_irq_setup(struct smi_info *info)
1093 SA_INTERRUPT, 1085 SA_INTERRUPT,
1094 DEVICE_NAME, 1086 DEVICE_NAME,
1095 info); 1087 info);
1096 if (! rv) 1088 if (!rv)
1097 /* Enable the interrupt in the BT interface. */ 1089 /* Enable the interrupt in the BT interface. */
1098 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, 1090 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG,
1099 IPMI_BT_INTMASK_ENABLE_IRQ_BIT); 1091 IPMI_BT_INTMASK_ENABLE_IRQ_BIT);
@@ -1110,88 +1102,77 @@ static int std_irq_setup(struct smi_info *info)
1110 DEVICE_NAME, info->irq); 1102 DEVICE_NAME, info->irq);
1111 info->irq = 0; 1103 info->irq = 0;
1112 } else { 1104 } else {
1105 info->irq_cleanup = std_irq_cleanup;
1113 printk(" Using irq %d\n", info->irq); 1106 printk(" Using irq %d\n", info->irq);
1114 } 1107 }
1115 1108
1116 return rv; 1109 return rv;
1117} 1110}
1118 1111
1119static void std_irq_cleanup(struct smi_info *info)
1120{
1121 if (! info->irq)
1122 return;
1123
1124 if (info->si_type == SI_BT)
1125 /* Disable the interrupt in the BT interface. */
1126 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, 0);
1127 free_irq(info->irq, info);
1128}
1129
1130static unsigned char port_inb(struct si_sm_io *io, unsigned int offset) 1112static unsigned char port_inb(struct si_sm_io *io, unsigned int offset)
1131{ 1113{
1132 unsigned int *addr = io->info; 1114 unsigned int addr = io->addr_data;
1133 1115
1134 return inb((*addr)+(offset*io->regspacing)); 1116 return inb(addr + (offset * io->regspacing));
1135} 1117}
1136 1118
1137static void port_outb(struct si_sm_io *io, unsigned int offset, 1119static void port_outb(struct si_sm_io *io, unsigned int offset,
1138 unsigned char b) 1120 unsigned char b)
1139{ 1121{
1140 unsigned int *addr = io->info; 1122 unsigned int addr = io->addr_data;
1141 1123
1142 outb(b, (*addr)+(offset * io->regspacing)); 1124 outb(b, addr + (offset * io->regspacing));
1143} 1125}
1144 1126
1145static unsigned char port_inw(struct si_sm_io *io, unsigned int offset) 1127static unsigned char port_inw(struct si_sm_io *io, unsigned int offset)
1146{ 1128{
1147 unsigned int *addr = io->info; 1129 unsigned int addr = io->addr_data;
1148 1130
1149 return (inw((*addr)+(offset * io->regspacing)) >> io->regshift) & 0xff; 1131 return (inw(addr + (offset * io->regspacing)) >> io->regshift) & 0xff;
1150} 1132}
1151 1133
1152static void port_outw(struct si_sm_io *io, unsigned int offset, 1134static void port_outw(struct si_sm_io *io, unsigned int offset,
1153 unsigned char b) 1135 unsigned char b)
1154{ 1136{
1155 unsigned int *addr = io->info; 1137 unsigned int addr = io->addr_data;
1156 1138
1157 outw(b << io->regshift, (*addr)+(offset * io->regspacing)); 1139 outw(b << io->regshift, addr + (offset * io->regspacing));
1158} 1140}
1159 1141
1160static unsigned char port_inl(struct si_sm_io *io, unsigned int offset) 1142static unsigned char port_inl(struct si_sm_io *io, unsigned int offset)
1161{ 1143{
1162 unsigned int *addr = io->info; 1144 unsigned int addr = io->addr_data;
1163 1145
1164 return (inl((*addr)+(offset * io->regspacing)) >> io->regshift) & 0xff; 1146 return (inl(addr + (offset * io->regspacing)) >> io->regshift) & 0xff;
1165} 1147}
1166 1148
1167static void port_outl(struct si_sm_io *io, unsigned int offset, 1149static void port_outl(struct si_sm_io *io, unsigned int offset,
1168 unsigned char b) 1150 unsigned char b)
1169{ 1151{
1170 unsigned int *addr = io->info; 1152 unsigned int addr = io->addr_data;
1171 1153
1172 outl(b << io->regshift, (*addr)+(offset * io->regspacing)); 1154 outl(b << io->regshift, addr+(offset * io->regspacing));
1173} 1155}
1174 1156
1175static void port_cleanup(struct smi_info *info) 1157static void port_cleanup(struct smi_info *info)
1176{ 1158{
1177 unsigned int *addr = info->io.info; 1159 unsigned int addr = info->io.addr_data;
1178 int mapsize; 1160 int mapsize;
1179 1161
1180 if (addr && (*addr)) { 1162 if (addr) {
1181 mapsize = ((info->io_size * info->io.regspacing) 1163 mapsize = ((info->io_size * info->io.regspacing)
1182 - (info->io.regspacing - info->io.regsize)); 1164 - (info->io.regspacing - info->io.regsize));
1183 1165
1184 release_region (*addr, mapsize); 1166 release_region (addr, mapsize);
1185 } 1167 }
1186 kfree(info);
1187} 1168}
1188 1169
1189static int port_setup(struct smi_info *info) 1170static int port_setup(struct smi_info *info)
1190{ 1171{
1191 unsigned int *addr = info->io.info; 1172 unsigned int addr = info->io.addr_data;
1192 int mapsize; 1173 int mapsize;
1193 1174
1194 if (! addr || (! *addr)) 1175 if (!addr)
1195 return -ENODEV; 1176 return -ENODEV;
1196 1177
1197 info->io_cleanup = port_cleanup; 1178 info->io_cleanup = port_cleanup;
@@ -1225,51 +1206,11 @@ static int port_setup(struct smi_info *info)
1225 mapsize = ((info->io_size * info->io.regspacing) 1206 mapsize = ((info->io_size * info->io.regspacing)
1226 - (info->io.regspacing - info->io.regsize)); 1207 - (info->io.regspacing - info->io.regsize));
1227 1208
1228 if (request_region(*addr, mapsize, DEVICE_NAME) == NULL) 1209 if (request_region(addr, mapsize, DEVICE_NAME) == NULL)
1229 return -EIO; 1210 return -EIO;
1230 return 0; 1211 return 0;
1231} 1212}
1232 1213
1233static int try_init_port(int intf_num, struct smi_info **new_info)
1234{
1235 struct smi_info *info;
1236
1237 if (! ports[intf_num])
1238 return -ENODEV;
1239
1240 if (! is_new_interface(intf_num, IPMI_IO_ADDR_SPACE,
1241 ports[intf_num]))
1242 return -ENODEV;
1243
1244 info = kmalloc(sizeof(*info), GFP_KERNEL);
1245 if (! info) {
1246 printk(KERN_ERR "ipmi_si: Could not allocate SI data (1)\n");
1247 return -ENOMEM;
1248 }
1249 memset(info, 0, sizeof(*info));
1250
1251 info->io_setup = port_setup;
1252 info->io.info = &(ports[intf_num]);
1253 info->io.addr = NULL;
1254 info->io.regspacing = regspacings[intf_num];
1255 if (! info->io.regspacing)
1256 info->io.regspacing = DEFAULT_REGSPACING;
1257 info->io.regsize = regsizes[intf_num];
1258 if (! info->io.regsize)
1259 info->io.regsize = DEFAULT_REGSPACING;
1260 info->io.regshift = regshifts[intf_num];
1261 info->irq = 0;
1262 info->irq_setup = NULL;
1263 *new_info = info;
1264
1265 if (si_type[intf_num] == NULL)
1266 si_type[intf_num] = "kcs";
1267
1268 printk("ipmi_si: Trying \"%s\" at I/O port 0x%x\n",
1269 si_type[intf_num], ports[intf_num]);
1270 return 0;
1271}
1272
1273static unsigned char intf_mem_inb(struct si_sm_io *io, unsigned int offset) 1214static unsigned char intf_mem_inb(struct si_sm_io *io, unsigned int offset)
1274{ 1215{
1275 return readb((io->addr)+(offset * io->regspacing)); 1216 return readb((io->addr)+(offset * io->regspacing));
@@ -1321,7 +1262,7 @@ static void mem_outq(struct si_sm_io *io, unsigned int offset,
1321 1262
1322static void mem_cleanup(struct smi_info *info) 1263static void mem_cleanup(struct smi_info *info)
1323{ 1264{
1324 unsigned long *addr = info->io.info; 1265 unsigned long addr = info->io.addr_data;
1325 int mapsize; 1266 int mapsize;
1326 1267
1327 if (info->io.addr) { 1268 if (info->io.addr) {
@@ -1330,17 +1271,16 @@ static void mem_cleanup(struct smi_info *info)
1330 mapsize = ((info->io_size * info->io.regspacing) 1271 mapsize = ((info->io_size * info->io.regspacing)
1331 - (info->io.regspacing - info->io.regsize)); 1272 - (info->io.regspacing - info->io.regsize));
1332 1273
1333 release_mem_region(*addr, mapsize); 1274 release_mem_region(addr, mapsize);
1334 } 1275 }
1335 kfree(info);
1336} 1276}
1337 1277
1338static int mem_setup(struct smi_info *info) 1278static int mem_setup(struct smi_info *info)
1339{ 1279{
1340 unsigned long *addr = info->io.info; 1280 unsigned long addr = info->io.addr_data;
1341 int mapsize; 1281 int mapsize;
1342 1282
1343 if (! addr || (! *addr)) 1283 if (!addr)
1344 return -ENODEV; 1284 return -ENODEV;
1345 1285
1346 info->io_cleanup = mem_cleanup; 1286 info->io_cleanup = mem_cleanup;
@@ -1380,57 +1320,83 @@ static int mem_setup(struct smi_info *info)
1380 mapsize = ((info->io_size * info->io.regspacing) 1320 mapsize = ((info->io_size * info->io.regspacing)
1381 - (info->io.regspacing - info->io.regsize)); 1321 - (info->io.regspacing - info->io.regsize));
1382 1322
1383 if (request_mem_region(*addr, mapsize, DEVICE_NAME) == NULL) 1323 if (request_mem_region(addr, mapsize, DEVICE_NAME) == NULL)
1384 return -EIO; 1324 return -EIO;
1385 1325
1386 info->io.addr = ioremap(*addr, mapsize); 1326 info->io.addr = ioremap(addr, mapsize);
1387 if (info->io.addr == NULL) { 1327 if (info->io.addr == NULL) {
1388 release_mem_region(*addr, mapsize); 1328 release_mem_region(addr, mapsize);
1389 return -EIO; 1329 return -EIO;
1390 } 1330 }
1391 return 0; 1331 return 0;
1392} 1332}
1393 1333
1394static int try_init_mem(int intf_num, struct smi_info **new_info) 1334
1335static __devinit void hardcode_find_bmc(void)
1395{ 1336{
1337 int i;
1396 struct smi_info *info; 1338 struct smi_info *info;
1397 1339
1398 if (! addrs[intf_num]) 1340 for (i = 0; i < SI_MAX_PARMS; i++) {
1399 return -ENODEV; 1341 if (!ports[i] && !addrs[i])
1342 continue;
1400 1343
1401 if (! is_new_interface(intf_num, IPMI_MEM_ADDR_SPACE, 1344 info = kzalloc(sizeof(*info), GFP_KERNEL);
1402 addrs[intf_num])) 1345 if (!info)
1403 return -ENODEV; 1346 return;
1404 1347
1405 info = kmalloc(sizeof(*info), GFP_KERNEL); 1348 info->addr_source = "hardcoded";
1406 if (! info) {
1407 printk(KERN_ERR "ipmi_si: Could not allocate SI data (2)\n");
1408 return -ENOMEM;
1409 }
1410 memset(info, 0, sizeof(*info));
1411 1349
1412 info->io_setup = mem_setup; 1350 if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) {
1413 info->io.info = &addrs[intf_num]; 1351 info->si_type = SI_KCS;
1414 info->io.addr = NULL; 1352 } else if (strcmp(si_type[i], "smic") == 0) {
1415 info->io.regspacing = regspacings[intf_num]; 1353 info->si_type = SI_SMIC;
1416 if (! info->io.regspacing) 1354 } else if (strcmp(si_type[i], "bt") == 0) {
1417 info->io.regspacing = DEFAULT_REGSPACING; 1355 info->si_type = SI_BT;
1418 info->io.regsize = regsizes[intf_num]; 1356 } else {
1419 if (! info->io.regsize) 1357 printk(KERN_WARNING
1420 info->io.regsize = DEFAULT_REGSPACING; 1358 "ipmi_si: Interface type specified "
1421 info->io.regshift = regshifts[intf_num]; 1359 "for interface %d, was invalid: %s\n",
1422 info->irq = 0; 1360 i, si_type[i]);
1423 info->irq_setup = NULL; 1361 kfree(info);
1424 *new_info = info; 1362 continue;
1363 }
1425 1364
1426 if (si_type[intf_num] == NULL) 1365 if (ports[i]) {
1427 si_type[intf_num] = "kcs"; 1366 /* An I/O port */
1367 info->io_setup = port_setup;
1368 info->io.addr_data = ports[i];
1369 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1370 } else if (addrs[i]) {
1371 /* A memory port */
1372 info->io_setup = mem_setup;
1373 info->io.addr_data = addrs[i];
1374 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1375 } else {
1376 printk(KERN_WARNING
1377 "ipmi_si: Interface type specified "
1378 "for interface %d, "
1379 "but port and address were not set or "
1380 "set to zero.\n", i);
1381 kfree(info);
1382 continue;
1383 }
1428 1384
1429 printk("ipmi_si: Trying \"%s\" at memory address 0x%lx\n", 1385 info->io.addr = NULL;
1430 si_type[intf_num], addrs[intf_num]); 1386 info->io.regspacing = regspacings[i];
1431 return 0; 1387 if (!info->io.regspacing)
1432} 1388 info->io.regspacing = DEFAULT_REGSPACING;
1389 info->io.regsize = regsizes[i];
1390 if (!info->io.regsize)
1391 info->io.regsize = DEFAULT_REGSPACING;
1392 info->io.regshift = regshifts[i];
1393 info->irq = irqs[i];
1394 if (info->irq)
1395 info->irq_setup = std_irq_setup;
1433 1396
1397 try_smi_init(info);
1398 }
1399}
1434 1400
1435#ifdef CONFIG_ACPI 1401#ifdef CONFIG_ACPI
1436 1402
@@ -1470,11 +1436,19 @@ static u32 ipmi_acpi_gpe(void *context)
1470 return ACPI_INTERRUPT_HANDLED; 1436 return ACPI_INTERRUPT_HANDLED;
1471} 1437}
1472 1438
1439static void acpi_gpe_irq_cleanup(struct smi_info *info)
1440{
1441 if (!info->irq)
1442 return;
1443
1444 acpi_remove_gpe_handler(NULL, info->irq, &ipmi_acpi_gpe);
1445}
1446
1473static int acpi_gpe_irq_setup(struct smi_info *info) 1447static int acpi_gpe_irq_setup(struct smi_info *info)
1474{ 1448{
1475 acpi_status status; 1449 acpi_status status;
1476 1450
1477 if (! info->irq) 1451 if (!info->irq)
1478 return 0; 1452 return 0;
1479 1453
1480 /* FIXME - is level triggered right? */ 1454 /* FIXME - is level triggered right? */
@@ -1491,19 +1465,12 @@ static int acpi_gpe_irq_setup(struct smi_info *info)
1491 info->irq = 0; 1465 info->irq = 0;
1492 return -EINVAL; 1466 return -EINVAL;
1493 } else { 1467 } else {
1468 info->irq_cleanup = acpi_gpe_irq_cleanup;
1494 printk(" Using ACPI GPE %d\n", info->irq); 1469 printk(" Using ACPI GPE %d\n", info->irq);
1495 return 0; 1470 return 0;
1496 } 1471 }
1497} 1472}
1498 1473
1499static void acpi_gpe_irq_cleanup(struct smi_info *info)
1500{
1501 if (! info->irq)
1502 return;
1503
1504 acpi_remove_gpe_handler(NULL, info->irq, &ipmi_acpi_gpe);
1505}
1506
1507/* 1474/*
1508 * Defined at 1475 * Defined at
1509 * http://h21007.www2.hp.com/dspp/files/unprotected/devresource/Docs/TechPapers/IA64/hpspmi.pdf 1476 * http://h21007.www2.hp.com/dspp/files/unprotected/devresource/Docs/TechPapers/IA64/hpspmi.pdf
@@ -1546,28 +1513,12 @@ struct SPMITable {
1546 s8 spmi_id[1]; /* A '\0' terminated array starts here. */ 1513 s8 spmi_id[1]; /* A '\0' terminated array starts here. */
1547}; 1514};
1548 1515
1549static int try_init_acpi(int intf_num, struct smi_info **new_info) 1516static __devinit int try_init_acpi(struct SPMITable *spmi)
1550{ 1517{
1551 struct smi_info *info; 1518 struct smi_info *info;
1552 acpi_status status;
1553 struct SPMITable *spmi;
1554 char *io_type; 1519 char *io_type;
1555 u8 addr_space; 1520 u8 addr_space;
1556 1521
1557 if (acpi_disabled)
1558 return -ENODEV;
1559
1560 if (acpi_failure)
1561 return -ENODEV;
1562
1563 status = acpi_get_firmware_table("SPMI", intf_num+1,
1564 ACPI_LOGICAL_ADDRESSING,
1565 (struct acpi_table_header **) &spmi);
1566 if (status != AE_OK) {
1567 acpi_failure = 1;
1568 return -ENODEV;
1569 }
1570
1571 if (spmi->IPMIlegacy != 1) { 1522 if (spmi->IPMIlegacy != 1) {
1572 printk(KERN_INFO "IPMI: Bad SPMI legacy %d\n", spmi->IPMIlegacy); 1523 printk(KERN_INFO "IPMI: Bad SPMI legacy %d\n", spmi->IPMIlegacy);
1573 return -ENODEV; 1524 return -ENODEV;
@@ -1577,47 +1528,42 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1577 addr_space = IPMI_MEM_ADDR_SPACE; 1528 addr_space = IPMI_MEM_ADDR_SPACE;
1578 else 1529 else
1579 addr_space = IPMI_IO_ADDR_SPACE; 1530 addr_space = IPMI_IO_ADDR_SPACE;
1580 if (! is_new_interface(-1, addr_space, spmi->addr.address)) 1531
1581 return -ENODEV; 1532 info = kzalloc(sizeof(*info), GFP_KERNEL);
1533 if (!info) {
1534 printk(KERN_ERR "ipmi_si: Could not allocate SI data (3)\n");
1535 return -ENOMEM;
1536 }
1537
1538 info->addr_source = "ACPI";
1582 1539
1583 /* Figure out the interface type. */ 1540 /* Figure out the interface type. */
1584 switch (spmi->InterfaceType) 1541 switch (spmi->InterfaceType)
1585 { 1542 {
1586 case 1: /* KCS */ 1543 case 1: /* KCS */
1587 si_type[intf_num] = "kcs"; 1544 info->si_type = SI_KCS;
1588 break; 1545 break;
1589
1590 case 2: /* SMIC */ 1546 case 2: /* SMIC */
1591 si_type[intf_num] = "smic"; 1547 info->si_type = SI_SMIC;
1592 break; 1548 break;
1593
1594 case 3: /* BT */ 1549 case 3: /* BT */
1595 si_type[intf_num] = "bt"; 1550 info->si_type = SI_BT;
1596 break; 1551 break;
1597
1598 default: 1552 default:
1599 printk(KERN_INFO "ipmi_si: Unknown ACPI/SPMI SI type %d\n", 1553 printk(KERN_INFO "ipmi_si: Unknown ACPI/SPMI SI type %d\n",
1600 spmi->InterfaceType); 1554 spmi->InterfaceType);
1555 kfree(info);
1601 return -EIO; 1556 return -EIO;
1602 } 1557 }
1603 1558
1604 info = kmalloc(sizeof(*info), GFP_KERNEL);
1605 if (! info) {
1606 printk(KERN_ERR "ipmi_si: Could not allocate SI data (3)\n");
1607 return -ENOMEM;
1608 }
1609 memset(info, 0, sizeof(*info));
1610
1611 if (spmi->InterruptType & 1) { 1559 if (spmi->InterruptType & 1) {
1612 /* We've got a GPE interrupt. */ 1560 /* We've got a GPE interrupt. */
1613 info->irq = spmi->GPE; 1561 info->irq = spmi->GPE;
1614 info->irq_setup = acpi_gpe_irq_setup; 1562 info->irq_setup = acpi_gpe_irq_setup;
1615 info->irq_cleanup = acpi_gpe_irq_cleanup;
1616 } else if (spmi->InterruptType & 2) { 1563 } else if (spmi->InterruptType & 2) {
1617 /* We've got an APIC/SAPIC interrupt. */ 1564 /* We've got an APIC/SAPIC interrupt. */
1618 info->irq = spmi->GlobalSystemInterrupt; 1565 info->irq = spmi->GlobalSystemInterrupt;
1619 info->irq_setup = std_irq_setup; 1566 info->irq_setup = std_irq_setup;
1620 info->irq_cleanup = std_irq_cleanup;
1621 } else { 1567 } else {
1622 /* Use the default interrupt setting. */ 1568 /* Use the default interrupt setting. */
1623 info->irq = 0; 1569 info->irq = 0;
@@ -1626,43 +1572,60 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1626 1572
1627 if (spmi->addr.register_bit_width) { 1573 if (spmi->addr.register_bit_width) {
1628 /* A (hopefully) properly formed register bit width. */ 1574 /* A (hopefully) properly formed register bit width. */
1629 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1630 info->io.regspacing = spmi->addr.register_bit_width / 8; 1575 info->io.regspacing = spmi->addr.register_bit_width / 8;
1631 } else { 1576 } else {
1632 regspacings[intf_num] = DEFAULT_REGSPACING;
1633 info->io.regspacing = DEFAULT_REGSPACING; 1577 info->io.regspacing = DEFAULT_REGSPACING;
1634 } 1578 }
1635 regsizes[intf_num] = regspacings[intf_num]; 1579 info->io.regsize = info->io.regspacing;
1636 info->io.regsize = regsizes[intf_num]; 1580 info->io.regshift = spmi->addr.register_bit_offset;
1637 regshifts[intf_num] = spmi->addr.register_bit_offset;
1638 info->io.regshift = regshifts[intf_num];
1639 1581
1640 if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 1582 if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
1641 io_type = "memory"; 1583 io_type = "memory";
1642 info->io_setup = mem_setup; 1584 info->io_setup = mem_setup;
1643 addrs[intf_num] = spmi->addr.address; 1585 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1644 info->io.info = &(addrs[intf_num]);
1645 } else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 1586 } else if (spmi->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
1646 io_type = "I/O"; 1587 io_type = "I/O";
1647 info->io_setup = port_setup; 1588 info->io_setup = port_setup;
1648 ports[intf_num] = spmi->addr.address; 1589 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1649 info->io.info = &(ports[intf_num]);
1650 } else { 1590 } else {
1651 kfree(info); 1591 kfree(info);
1652 printk("ipmi_si: Unknown ACPI I/O Address type\n"); 1592 printk("ipmi_si: Unknown ACPI I/O Address type\n");
1653 return -EIO; 1593 return -EIO;
1654 } 1594 }
1595 info->io.addr_data = spmi->addr.address;
1655 1596
1656 *new_info = info; 1597 try_smi_init(info);
1657 1598
1658 printk("ipmi_si: ACPI/SPMI specifies \"%s\" %s SI @ 0x%lx\n",
1659 si_type[intf_num], io_type, (unsigned long) spmi->addr.address);
1660 return 0; 1599 return 0;
1661} 1600}
1601
1602static __devinit void acpi_find_bmc(void)
1603{
1604 acpi_status status;
1605 struct SPMITable *spmi;
1606 int i;
1607
1608 if (acpi_disabled)
1609 return;
1610
1611 if (acpi_failure)
1612 return;
1613
1614 for (i = 0; ; i++) {
1615 status = acpi_get_firmware_table("SPMI", i+1,
1616 ACPI_LOGICAL_ADDRESSING,
1617 (struct acpi_table_header **)
1618 &spmi);
1619 if (status != AE_OK)
1620 return;
1621
1622 try_init_acpi(spmi);
1623 }
1624}
1662#endif 1625#endif
1663 1626
1664#ifdef CONFIG_DMI 1627#ifdef CONFIG_DMI
1665typedef struct dmi_ipmi_data 1628struct dmi_ipmi_data
1666{ 1629{
1667 u8 type; 1630 u8 type;
1668 u8 addr_space; 1631 u8 addr_space;
@@ -1670,49 +1633,46 @@ typedef struct dmi_ipmi_data
1670 u8 irq; 1633 u8 irq;
1671 u8 offset; 1634 u8 offset;
1672 u8 slave_addr; 1635 u8 slave_addr;
1673} dmi_ipmi_data_t; 1636};
1674
1675static dmi_ipmi_data_t dmi_data[SI_MAX_DRIVERS];
1676static int dmi_data_entries;
1677 1637
1678static int __init decode_dmi(struct dmi_header *dm, int intf_num) 1638static int __devinit decode_dmi(struct dmi_header *dm,
1639 struct dmi_ipmi_data *dmi)
1679{ 1640{
1680 u8 *data = (u8 *)dm; 1641 u8 *data = (u8 *)dm;
1681 unsigned long base_addr; 1642 unsigned long base_addr;
1682 u8 reg_spacing; 1643 u8 reg_spacing;
1683 u8 len = dm->length; 1644 u8 len = dm->length;
1684 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num;
1685 1645
1686 ipmi_data->type = data[4]; 1646 dmi->type = data[4];
1687 1647
1688 memcpy(&base_addr, data+8, sizeof(unsigned long)); 1648 memcpy(&base_addr, data+8, sizeof(unsigned long));
1689 if (len >= 0x11) { 1649 if (len >= 0x11) {
1690 if (base_addr & 1) { 1650 if (base_addr & 1) {
1691 /* I/O */ 1651 /* I/O */
1692 base_addr &= 0xFFFE; 1652 base_addr &= 0xFFFE;
1693 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE; 1653 dmi->addr_space = IPMI_IO_ADDR_SPACE;
1694 } 1654 }
1695 else { 1655 else {
1696 /* Memory */ 1656 /* Memory */
1697 ipmi_data->addr_space = IPMI_MEM_ADDR_SPACE; 1657 dmi->addr_space = IPMI_MEM_ADDR_SPACE;
1698 } 1658 }
1699 /* If bit 4 of byte 0x10 is set, then the lsb for the address 1659 /* If bit 4 of byte 0x10 is set, then the lsb for the address
1700 is odd. */ 1660 is odd. */
1701 ipmi_data->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); 1661 dmi->base_addr = base_addr | ((data[0x10] & 0x10) >> 4);
1702 1662
1703 ipmi_data->irq = data[0x11]; 1663 dmi->irq = data[0x11];
1704 1664
1705 /* The top two bits of byte 0x10 hold the register spacing. */ 1665 /* The top two bits of byte 0x10 hold the register spacing. */
1706 reg_spacing = (data[0x10] & 0xC0) >> 6; 1666 reg_spacing = (data[0x10] & 0xC0) >> 6;
1707 switch(reg_spacing){ 1667 switch(reg_spacing){
1708 case 0x00: /* Byte boundaries */ 1668 case 0x00: /* Byte boundaries */
1709 ipmi_data->offset = 1; 1669 dmi->offset = 1;
1710 break; 1670 break;
1711 case 0x01: /* 32-bit boundaries */ 1671 case 0x01: /* 32-bit boundaries */
1712 ipmi_data->offset = 4; 1672 dmi->offset = 4;
1713 break; 1673 break;
1714 case 0x02: /* 16-byte boundaries */ 1674 case 0x02: /* 16-byte boundaries */
1715 ipmi_data->offset = 16; 1675 dmi->offset = 16;
1716 break; 1676 break;
1717 default: 1677 default:
1718 /* Some other interface, just ignore it. */ 1678 /* Some other interface, just ignore it. */
@@ -1726,217 +1686,227 @@ static int __init decode_dmi(struct dmi_header *dm, int intf_num)
1726 * wrong (and all that I have seen are I/O) so we just 1686 * wrong (and all that I have seen are I/O) so we just
1727 * ignore that bit and assume I/O. Systems that use 1687 * ignore that bit and assume I/O. Systems that use
1728 * memory should use the newer spec, anyway. */ 1688 * memory should use the newer spec, anyway. */
1729 ipmi_data->base_addr = base_addr & 0xfffe; 1689 dmi->base_addr = base_addr & 0xfffe;
1730 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE; 1690 dmi->addr_space = IPMI_IO_ADDR_SPACE;
1731 ipmi_data->offset = 1; 1691 dmi->offset = 1;
1732 }
1733
1734 ipmi_data->slave_addr = data[6];
1735
1736 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) {
1737 dmi_data_entries++;
1738 return 0;
1739 } 1692 }
1740 1693
1741 memset(ipmi_data, 0, sizeof(dmi_ipmi_data_t)); 1694 dmi->slave_addr = data[6];
1742 1695
1743 return -1; 1696 return 0;
1744} 1697}
1745 1698
1746static void __init dmi_find_bmc(void) 1699static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
1747{ 1700{
1748 struct dmi_device *dev = NULL; 1701 struct smi_info *info;
1749 int intf_num = 0;
1750
1751 while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) {
1752 if (intf_num >= SI_MAX_DRIVERS)
1753 break;
1754 1702
1755 decode_dmi((struct dmi_header *) dev->device_data, intf_num++); 1703 info = kzalloc(sizeof(*info), GFP_KERNEL);
1704 if (!info) {
1705 printk(KERN_ERR
1706 "ipmi_si: Could not allocate SI data\n");
1707 return;
1756 } 1708 }
1757}
1758
1759static int try_init_smbios(int intf_num, struct smi_info **new_info)
1760{
1761 struct smi_info *info;
1762 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num;
1763 char *io_type;
1764 1709
1765 if (intf_num >= dmi_data_entries) 1710 info->addr_source = "SMBIOS";
1766 return -ENODEV;
1767 1711
1768 switch (ipmi_data->type) { 1712 switch (ipmi_data->type) {
1769 case 0x01: /* KCS */ 1713 case 0x01: /* KCS */
1770 si_type[intf_num] = "kcs"; 1714 info->si_type = SI_KCS;
1771 break; 1715 break;
1772 case 0x02: /* SMIC */ 1716 case 0x02: /* SMIC */
1773 si_type[intf_num] = "smic"; 1717 info->si_type = SI_SMIC;
1774 break; 1718 break;
1775 case 0x03: /* BT */ 1719 case 0x03: /* BT */
1776 si_type[intf_num] = "bt"; 1720 info->si_type = SI_BT;
1777 break; 1721 break;
1778 default: 1722 default:
1779 return -EIO; 1723 return;
1780 }
1781
1782 info = kmalloc(sizeof(*info), GFP_KERNEL);
1783 if (! info) {
1784 printk(KERN_ERR "ipmi_si: Could not allocate SI data (4)\n");
1785 return -ENOMEM;
1786 } 1724 }
1787 memset(info, 0, sizeof(*info));
1788 1725
1789 if (ipmi_data->addr_space == 1) { 1726 switch (ipmi_data->addr_space) {
1790 io_type = "memory"; 1727 case IPMI_MEM_ADDR_SPACE:
1791 info->io_setup = mem_setup; 1728 info->io_setup = mem_setup;
1792 addrs[intf_num] = ipmi_data->base_addr; 1729 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1793 info->io.info = &(addrs[intf_num]); 1730 break;
1794 } else if (ipmi_data->addr_space == 2) { 1731
1795 io_type = "I/O"; 1732 case IPMI_IO_ADDR_SPACE:
1796 info->io_setup = port_setup; 1733 info->io_setup = port_setup;
1797 ports[intf_num] = ipmi_data->base_addr; 1734 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1798 info->io.info = &(ports[intf_num]); 1735 break;
1799 } else { 1736
1737 default:
1800 kfree(info); 1738 kfree(info);
1801 printk("ipmi_si: Unknown SMBIOS I/O Address type.\n"); 1739 printk(KERN_WARNING
1802 return -EIO; 1740 "ipmi_si: Unknown SMBIOS I/O Address type: %d.\n",
1741 ipmi_data->addr_space);
1742 return;
1803 } 1743 }
1744 info->io.addr_data = ipmi_data->base_addr;
1804 1745
1805 regspacings[intf_num] = ipmi_data->offset; 1746 info->io.regspacing = ipmi_data->offset;
1806 info->io.regspacing = regspacings[intf_num]; 1747 if (!info->io.regspacing)
1807 if (! info->io.regspacing)
1808 info->io.regspacing = DEFAULT_REGSPACING; 1748 info->io.regspacing = DEFAULT_REGSPACING;
1809 info->io.regsize = DEFAULT_REGSPACING; 1749 info->io.regsize = DEFAULT_REGSPACING;
1810 info->io.regshift = regshifts[intf_num]; 1750 info->io.regshift = 0;
1811 1751
1812 info->slave_addr = ipmi_data->slave_addr; 1752 info->slave_addr = ipmi_data->slave_addr;
1813 1753
1814 irqs[intf_num] = ipmi_data->irq; 1754 info->irq = ipmi_data->irq;
1755 if (info->irq)
1756 info->irq_setup = std_irq_setup;
1815 1757
1816 *new_info = info; 1758 try_smi_init(info);
1759}
1817 1760
1818 printk("ipmi_si: Found SMBIOS-specified state machine at %s" 1761static void __devinit dmi_find_bmc(void)
1819 " address 0x%lx, slave address 0x%x\n", 1762{
1820 io_type, (unsigned long)ipmi_data->base_addr, 1763 struct dmi_device *dev = NULL;
1821 ipmi_data->slave_addr); 1764 struct dmi_ipmi_data data;
1822 return 0; 1765 int rv;
1766
1767 while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) {
1768 rv = decode_dmi((struct dmi_header *) dev->device_data, &data);
1769 if (!rv)
1770 try_init_dmi(&data);
1771 }
1823} 1772}
1824#endif /* CONFIG_DMI */ 1773#endif /* CONFIG_DMI */
1825 1774
1826#ifdef CONFIG_PCI 1775#ifdef CONFIG_PCI
1827 1776
1828#define PCI_ERMC_CLASSCODE 0x0C0700 1777#define PCI_ERMC_CLASSCODE 0x0C0700
1778#define PCI_ERMC_CLASSCODE_MASK 0xffffff00
1779#define PCI_ERMC_CLASSCODE_TYPE_MASK 0xff
1780#define PCI_ERMC_CLASSCODE_TYPE_SMIC 0x00
1781#define PCI_ERMC_CLASSCODE_TYPE_KCS 0x01
1782#define PCI_ERMC_CLASSCODE_TYPE_BT 0x02
1783
1829#define PCI_HP_VENDOR_ID 0x103C 1784#define PCI_HP_VENDOR_ID 0x103C
1830#define PCI_MMC_DEVICE_ID 0x121A 1785#define PCI_MMC_DEVICE_ID 0x121A
1831#define PCI_MMC_ADDR_CW 0x10 1786#define PCI_MMC_ADDR_CW 0x10
1832 1787
1833/* Avoid more than one attempt to probe pci smic. */ 1788static void ipmi_pci_cleanup(struct smi_info *info)
1834static int pci_smic_checked = 0; 1789{
1790 struct pci_dev *pdev = info->addr_source_data;
1791
1792 pci_disable_device(pdev);
1793}
1835 1794
1836static int find_pci_smic(int intf_num, struct smi_info **new_info) 1795static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
1796 const struct pci_device_id *ent)
1837{ 1797{
1838 struct smi_info *info; 1798 int rv;
1839 int error; 1799 int class_type = pdev->class & PCI_ERMC_CLASSCODE_TYPE_MASK;
1840 struct pci_dev *pci_dev = NULL; 1800 struct smi_info *info;
1841 u16 base_addr; 1801 int first_reg_offset = 0;
1842 int fe_rmc = 0;
1843 1802
1844 if (pci_smic_checked) 1803 info = kzalloc(sizeof(*info), GFP_KERNEL);
1845 return -ENODEV; 1804 if (!info)
1805 return ENOMEM;
1846 1806
1847 pci_smic_checked = 1; 1807 info->addr_source = "PCI";
1848 1808
1849 pci_dev = pci_get_device(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID, NULL); 1809 switch (class_type) {
1850 if (! pci_dev) { 1810 case PCI_ERMC_CLASSCODE_TYPE_SMIC:
1851 pci_dev = pci_get_class(PCI_ERMC_CLASSCODE, NULL); 1811 info->si_type = SI_SMIC;
1852 if (pci_dev && (pci_dev->subsystem_vendor == PCI_HP_VENDOR_ID)) 1812 break;
1853 fe_rmc = 1;
1854 else
1855 return -ENODEV;
1856 }
1857 1813
1858 error = pci_read_config_word(pci_dev, PCI_MMC_ADDR_CW, &base_addr); 1814 case PCI_ERMC_CLASSCODE_TYPE_KCS:
1859 if (error) 1815 info->si_type = SI_KCS;
1860 { 1816 break;
1861 pci_dev_put(pci_dev); 1817
1862 printk(KERN_ERR 1818 case PCI_ERMC_CLASSCODE_TYPE_BT:
1863 "ipmi_si: pci_read_config_word() failed (%d).\n", 1819 info->si_type = SI_BT;
1864 error); 1820 break;
1865 return -ENODEV; 1821
1822 default:
1823 kfree(info);
1824 printk(KERN_INFO "ipmi_si: %s: Unknown IPMI type: %d\n",
1825 pci_name(pdev), class_type);
1826 return ENOMEM;
1866 } 1827 }
1867 1828
1868 /* Bit 0: 1 specifies programmed I/O, 0 specifies memory mapped I/O */ 1829 rv = pci_enable_device(pdev);
1869 if (! (base_addr & 0x0001)) 1830 if (rv) {
1870 { 1831 printk(KERN_ERR "ipmi_si: %s: couldn't enable PCI device\n",
1871 pci_dev_put(pci_dev); 1832 pci_name(pdev));
1872 printk(KERN_ERR 1833 kfree(info);
1873 "ipmi_si: memory mapped I/O not supported for PCI" 1834 return rv;
1874 " smic.\n");
1875 return -ENODEV;
1876 } 1835 }
1877 1836
1878 base_addr &= 0xFFFE; 1837 info->addr_source_cleanup = ipmi_pci_cleanup;
1879 if (! fe_rmc) 1838 info->addr_source_data = pdev;
1880 /* Data register starts at base address + 1 in eRMC */
1881 ++base_addr;
1882 1839
1883 if (! is_new_interface(-1, IPMI_IO_ADDR_SPACE, base_addr)) { 1840 if (pdev->subsystem_vendor == PCI_HP_VENDOR_ID)
1884 pci_dev_put(pci_dev); 1841 first_reg_offset = 1;
1885 return -ENODEV;
1886 }
1887 1842
1888 info = kmalloc(sizeof(*info), GFP_KERNEL); 1843 if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
1889 if (! info) { 1844 info->io_setup = port_setup;
1890 pci_dev_put(pci_dev); 1845 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1891 printk(KERN_ERR "ipmi_si: Could not allocate SI data (5)\n"); 1846 } else {
1892 return -ENOMEM; 1847 info->io_setup = mem_setup;
1848 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1893 } 1849 }
1894 memset(info, 0, sizeof(*info)); 1850 info->io.addr_data = pci_resource_start(pdev, 0);
1895 1851
1896 info->io_setup = port_setup; 1852 info->io.regspacing = DEFAULT_REGSPACING;
1897 ports[intf_num] = base_addr;
1898 info->io.info = &(ports[intf_num]);
1899 info->io.regspacing = regspacings[intf_num];
1900 if (! info->io.regspacing)
1901 info->io.regspacing = DEFAULT_REGSPACING;
1902 info->io.regsize = DEFAULT_REGSPACING; 1853 info->io.regsize = DEFAULT_REGSPACING;
1903 info->io.regshift = regshifts[intf_num]; 1854 info->io.regshift = 0;
1904 1855
1905 *new_info = info; 1856 info->irq = pdev->irq;
1857 if (info->irq)
1858 info->irq_setup = std_irq_setup;
1906 1859
1907 irqs[intf_num] = pci_dev->irq; 1860 info->dev = &pdev->dev;
1908 si_type[intf_num] = "smic";
1909 1861
1910 printk("ipmi_si: Found PCI SMIC at I/O address 0x%lx\n", 1862 return try_smi_init(info);
1911 (long unsigned int) base_addr); 1863}
1912 1864
1913 pci_dev_put(pci_dev); 1865static void __devexit ipmi_pci_remove(struct pci_dev *pdev)
1866{
1867}
1868
1869#ifdef CONFIG_PM
1870static int ipmi_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1871{
1914 return 0; 1872 return 0;
1915} 1873}
1916#endif /* CONFIG_PCI */
1917 1874
1918static int try_init_plug_and_play(int intf_num, struct smi_info **new_info) 1875static int ipmi_pci_resume(struct pci_dev *pdev)
1919{ 1876{
1920#ifdef CONFIG_PCI 1877 return 0;
1921 if (find_pci_smic(intf_num, new_info) == 0) 1878}
1922 return 0;
1923#endif 1879#endif
1924 /* Include other methods here. */
1925 1880
1926 return -ENODEV; 1881static struct pci_device_id ipmi_pci_devices[] = {
1927} 1882 { PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) },
1883 { PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE) }
1884};
1885MODULE_DEVICE_TABLE(pci, ipmi_pci_devices);
1886
1887static struct pci_driver ipmi_pci_driver = {
1888 .name = DEVICE_NAME,
1889 .id_table = ipmi_pci_devices,
1890 .probe = ipmi_pci_probe,
1891 .remove = __devexit_p(ipmi_pci_remove),
1892#ifdef CONFIG_PM
1893 .suspend = ipmi_pci_suspend,
1894 .resume = ipmi_pci_resume,
1895#endif
1896};
1897#endif /* CONFIG_PCI */
1928 1898
1929 1899
1930static int try_get_dev_id(struct smi_info *smi_info) 1900static int try_get_dev_id(struct smi_info *smi_info)
1931{ 1901{
1932 unsigned char msg[2]; 1902 unsigned char msg[2];
1933 unsigned char *resp; 1903 unsigned char *resp;
1934 unsigned long resp_len; 1904 unsigned long resp_len;
1935 enum si_sm_result smi_result; 1905 enum si_sm_result smi_result;
1936 int rv = 0; 1906 int rv = 0;
1937 1907
1938 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL); 1908 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
1939 if (! resp) 1909 if (!resp)
1940 return -ENOMEM; 1910 return -ENOMEM;
1941 1911
1942 /* Do a Get Device ID command, since it comes back with some 1912 /* Do a Get Device ID command, since it comes back with some
@@ -1972,7 +1942,7 @@ static int try_get_dev_id(struct smi_info *smi_info)
1972 /* Otherwise, we got some data. */ 1942 /* Otherwise, we got some data. */
1973 resp_len = smi_info->handlers->get_result(smi_info->si_sm, 1943 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
1974 resp, IPMI_MAX_MSG_LENGTH); 1944 resp, IPMI_MAX_MSG_LENGTH);
1975 if (resp_len < 6) { 1945 if (resp_len < 14) {
1976 /* That's odd, it should be longer. */ 1946 /* That's odd, it should be longer. */
1977 rv = -EINVAL; 1947 rv = -EINVAL;
1978 goto out; 1948 goto out;
@@ -1985,8 +1955,7 @@ static int try_get_dev_id(struct smi_info *smi_info)
1985 } 1955 }
1986 1956
1987 /* Record info from the get device id, in case we need it. */ 1957 /* Record info from the get device id, in case we need it. */
1988 memcpy(&smi_info->device_id, &resp[3], 1958 ipmi_demangle_device_id(resp+3, resp_len-3, &smi_info->device_id);
1989 min_t(unsigned long, resp_len-3, sizeof(smi_info->device_id)));
1990 1959
1991 out: 1960 out:
1992 kfree(resp); 1961 kfree(resp);
@@ -2018,7 +1987,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
2018 struct smi_info *smi = data; 1987 struct smi_info *smi = data;
2019 1988
2020 out += sprintf(out, "interrupts_enabled: %d\n", 1989 out += sprintf(out, "interrupts_enabled: %d\n",
2021 smi->irq && ! smi->interrupt_disabled); 1990 smi->irq && !smi->interrupt_disabled);
2022 out += sprintf(out, "short_timeouts: %ld\n", 1991 out += sprintf(out, "short_timeouts: %ld\n",
2023 smi->short_timeouts); 1992 smi->short_timeouts);
2024 out += sprintf(out, "long_timeouts: %ld\n", 1993 out += sprintf(out, "long_timeouts: %ld\n",
@@ -2089,15 +2058,14 @@ static int oem_data_avail_to_receive_msg_avail(struct smi_info *smi_info)
2089#define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20 2058#define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20
2090#define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80 2059#define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80
2091#define DELL_POWEREDGE_8G_BMC_IPMI_VERSION 0x51 2060#define DELL_POWEREDGE_8G_BMC_IPMI_VERSION 0x51
2092#define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} 2061#define DELL_IANA_MFR_ID 0x0002a2
2093static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info) 2062static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info)
2094{ 2063{
2095 struct ipmi_device_id *id = &smi_info->device_id; 2064 struct ipmi_device_id *id = &smi_info->device_id;
2096 const char mfr[3]=DELL_IANA_MFR_ID; 2065 if (id->manufacturer_id == DELL_IANA_MFR_ID) {
2097 if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr))) {
2098 if (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID && 2066 if (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID &&
2099 id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV && 2067 id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV &&
2100 id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION) { 2068 id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION) {
2101 smi_info->oem_data_avail_handler = 2069 smi_info->oem_data_avail_handler =
2102 oem_data_avail_to_receive_msg_avail; 2070 oem_data_avail_to_receive_msg_avail;
2103 } 2071 }
@@ -2169,8 +2137,7 @@ static void
2169setup_dell_poweredge_bt_xaction_handler(struct smi_info *smi_info) 2137setup_dell_poweredge_bt_xaction_handler(struct smi_info *smi_info)
2170{ 2138{
2171 struct ipmi_device_id *id = &smi_info->device_id; 2139 struct ipmi_device_id *id = &smi_info->device_id;
2172 const char mfr[3]=DELL_IANA_MFR_ID; 2140 if (id->manufacturer_id == DELL_IANA_MFR_ID &&
2173 if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr)) &&
2174 smi_info->si_type == SI_BT) 2141 smi_info->si_type == SI_BT)
2175 register_xaction_notifier(&dell_poweredge_bt_xaction_notifier); 2142 register_xaction_notifier(&dell_poweredge_bt_xaction_notifier);
2176} 2143}
@@ -2200,62 +2167,110 @@ static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
2200 del_timer_sync(&smi_info->si_timer); 2167 del_timer_sync(&smi_info->si_timer);
2201} 2168}
2202 2169
2203/* Returns 0 if initialized, or negative on an error. */ 2170static struct ipmi_default_vals
2204static int init_one_smi(int intf_num, struct smi_info **smi)
2205{ 2171{
2206 int rv; 2172 int type;
2207 struct smi_info *new_smi; 2173 int port;
2174} __devinit ipmi_defaults[] =
2175{
2176 { .type = SI_KCS, .port = 0xca2 },
2177 { .type = SI_SMIC, .port = 0xca9 },
2178 { .type = SI_BT, .port = 0xe4 },
2179 { .port = 0 }
2180};
2208 2181
2182static __devinit void default_find_bmc(void)
2183{
2184 struct smi_info *info;
2185 int i;
2209 2186
2210 rv = try_init_mem(intf_num, &new_smi); 2187 for (i = 0; ; i++) {
2211 if (rv) 2188 if (!ipmi_defaults[i].port)
2212 rv = try_init_port(intf_num, &new_smi); 2189 break;
2213#ifdef CONFIG_ACPI
2214 if (rv && si_trydefaults)
2215 rv = try_init_acpi(intf_num, &new_smi);
2216#endif
2217#ifdef CONFIG_DMI
2218 if (rv && si_trydefaults)
2219 rv = try_init_smbios(intf_num, &new_smi);
2220#endif
2221 if (rv && si_trydefaults)
2222 rv = try_init_plug_and_play(intf_num, &new_smi);
2223 2190
2224 if (rv) 2191 info = kzalloc(sizeof(*info), GFP_KERNEL);
2225 return rv; 2192 if (!info)
2193 return;
2226 2194
2227 /* So we know not to free it unless we have allocated one. */ 2195 info->addr_source = NULL;
2228 new_smi->intf = NULL;
2229 new_smi->si_sm = NULL;
2230 new_smi->handlers = NULL;
2231 2196
2232 if (! new_smi->irq_setup) { 2197 info->si_type = ipmi_defaults[i].type;
2233 new_smi->irq = irqs[intf_num]; 2198 info->io_setup = port_setup;
2234 new_smi->irq_setup = std_irq_setup; 2199 info->io.addr_data = ipmi_defaults[i].port;
2235 new_smi->irq_cleanup = std_irq_cleanup; 2200 info->io.addr_type = IPMI_IO_ADDR_SPACE;
2236 }
2237 2201
2238 /* Default to KCS if no type is specified. */ 2202 info->io.addr = NULL;
2239 if (si_type[intf_num] == NULL) { 2203 info->io.regspacing = DEFAULT_REGSPACING;
2240 if (si_trydefaults) 2204 info->io.regsize = DEFAULT_REGSPACING;
2241 si_type[intf_num] = "kcs"; 2205 info->io.regshift = 0;
2242 else { 2206
2243 rv = -EINVAL; 2207 if (try_smi_init(info) == 0) {
2244 goto out_err; 2208 /* Found one... */
2209 printk(KERN_INFO "ipmi_si: Found default %s state"
2210 " machine at %s address 0x%lx\n",
2211 si_to_str[info->si_type],
2212 addr_space_to_str[info->io.addr_type],
2213 info->io.addr_data);
2214 return;
2245 } 2215 }
2246 } 2216 }
2217}
2218
2219static int is_new_interface(struct smi_info *info)
2220{
2221 struct smi_info *e;
2222
2223 list_for_each_entry(e, &smi_infos, link) {
2224 if (e->io.addr_type != info->io.addr_type)
2225 continue;
2226 if (e->io.addr_data == info->io.addr_data)
2227 return 0;
2228 }
2229
2230 return 1;
2231}
2232
2233static int try_smi_init(struct smi_info *new_smi)
2234{
2235 int rv;
2236
2237 if (new_smi->addr_source) {
2238 printk(KERN_INFO "ipmi_si: Trying %s-specified %s state"
2239 " machine at %s address 0x%lx, slave address 0x%x,"
2240 " irq %d\n",
2241 new_smi->addr_source,
2242 si_to_str[new_smi->si_type],
2243 addr_space_to_str[new_smi->io.addr_type],
2244 new_smi->io.addr_data,
2245 new_smi->slave_addr, new_smi->irq);
2246 }
2247
2248 down(&smi_infos_lock);
2249 if (!is_new_interface(new_smi)) {
2250 printk(KERN_WARNING "ipmi_si: duplicate interface\n");
2251 rv = -EBUSY;
2252 goto out_err;
2253 }
2247 2254
2248 /* Set up the state machine to use. */ 2255 /* So we know not to free it unless we have allocated one. */
2249 if (strcmp(si_type[intf_num], "kcs") == 0) { 2256 new_smi->intf = NULL;
2257 new_smi->si_sm = NULL;
2258 new_smi->handlers = NULL;
2259
2260 switch (new_smi->si_type) {
2261 case SI_KCS:
2250 new_smi->handlers = &kcs_smi_handlers; 2262 new_smi->handlers = &kcs_smi_handlers;
2251 new_smi->si_type = SI_KCS; 2263 break;
2252 } else if (strcmp(si_type[intf_num], "smic") == 0) { 2264
2265 case SI_SMIC:
2253 new_smi->handlers = &smic_smi_handlers; 2266 new_smi->handlers = &smic_smi_handlers;
2254 new_smi->si_type = SI_SMIC; 2267 break;
2255 } else if (strcmp(si_type[intf_num], "bt") == 0) { 2268
2269 case SI_BT:
2256 new_smi->handlers = &bt_smi_handlers; 2270 new_smi->handlers = &bt_smi_handlers;
2257 new_smi->si_type = SI_BT; 2271 break;
2258 } else { 2272
2273 default:
2259 /* No support for anything else yet. */ 2274 /* No support for anything else yet. */
2260 rv = -EIO; 2275 rv = -EIO;
2261 goto out_err; 2276 goto out_err;
@@ -2263,7 +2278,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2263 2278
2264 /* Allocate the state machine's data and initialize it. */ 2279 /* Allocate the state machine's data and initialize it. */
2265 new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); 2280 new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL);
2266 if (! new_smi->si_sm) { 2281 if (!new_smi->si_sm) {
2267 printk(" Could not allocate state machine memory\n"); 2282 printk(" Could not allocate state machine memory\n");
2268 rv = -ENOMEM; 2283 rv = -ENOMEM;
2269 goto out_err; 2284 goto out_err;
@@ -2284,21 +2299,29 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2284 2299
2285 /* Do low-level detection first. */ 2300 /* Do low-level detection first. */
2286 if (new_smi->handlers->detect(new_smi->si_sm)) { 2301 if (new_smi->handlers->detect(new_smi->si_sm)) {
2302 if (new_smi->addr_source)
2303 printk(KERN_INFO "ipmi_si: Interface detection"
2304 " failed\n");
2287 rv = -ENODEV; 2305 rv = -ENODEV;
2288 goto out_err; 2306 goto out_err;
2289 } 2307 }
2290 2308
2291 /* Attempt a get device id command. If it fails, we probably 2309 /* Attempt a get device id command. If it fails, we probably
2292 don't have a SMI here. */ 2310 don't have a BMC here. */
2293 rv = try_get_dev_id(new_smi); 2311 rv = try_get_dev_id(new_smi);
2294 if (rv) 2312 if (rv) {
2313 if (new_smi->addr_source)
2314 printk(KERN_INFO "ipmi_si: There appears to be no BMC"
2315 " at this location\n");
2295 goto out_err; 2316 goto out_err;
2317 }
2296 2318
2297 setup_oem_data_handler(new_smi); 2319 setup_oem_data_handler(new_smi);
2298 setup_xaction_handlers(new_smi); 2320 setup_xaction_handlers(new_smi);
2299 2321
2300 /* Try to claim any interrupts. */ 2322 /* Try to claim any interrupts. */
2301 new_smi->irq_setup(new_smi); 2323 if (new_smi->irq_setup)
2324 new_smi->irq_setup(new_smi);
2302 2325
2303 INIT_LIST_HEAD(&(new_smi->xmit_msgs)); 2326 INIT_LIST_HEAD(&(new_smi->xmit_msgs));
2304 INIT_LIST_HEAD(&(new_smi->hp_xmit_msgs)); 2327 INIT_LIST_HEAD(&(new_smi->hp_xmit_msgs));
@@ -2308,7 +2331,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2308 2331
2309 new_smi->interrupt_disabled = 0; 2332 new_smi->interrupt_disabled = 0;
2310 atomic_set(&new_smi->stop_operation, 0); 2333 atomic_set(&new_smi->stop_operation, 0);
2311 new_smi->intf_num = intf_num; 2334 new_smi->intf_num = smi_num;
2335 smi_num++;
2312 2336
2313 /* Start clearing the flags before we enable interrupts or the 2337 /* Start clearing the flags before we enable interrupts or the
2314 timer to avoid racing with the timer. */ 2338 timer to avoid racing with the timer. */
@@ -2332,10 +2356,36 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2332 new_smi->thread = kthread_run(ipmi_thread, new_smi, 2356 new_smi->thread = kthread_run(ipmi_thread, new_smi,
2333 "kipmi%d", new_smi->intf_num); 2357 "kipmi%d", new_smi->intf_num);
2334 2358
2359 if (!new_smi->dev) {
2360 /* If we don't already have a device from something
2361 * else (like PCI), then register a new one. */
2362 new_smi->pdev = platform_device_alloc("ipmi_si",
2363 new_smi->intf_num);
2364 if (rv) {
2365 printk(KERN_ERR
2366 "ipmi_si_intf:"
2367 " Unable to allocate platform device\n");
2368 goto out_err_stop_timer;
2369 }
2370 new_smi->dev = &new_smi->pdev->dev;
2371 new_smi->dev->driver = &ipmi_driver;
2372
2373 rv = platform_device_register(new_smi->pdev);
2374 if (rv) {
2375 printk(KERN_ERR
2376 "ipmi_si_intf:"
2377 " Unable to register system interface device:"
2378 " %d\n",
2379 rv);
2380 goto out_err_stop_timer;
2381 }
2382 new_smi->dev_registered = 1;
2383 }
2384
2335 rv = ipmi_register_smi(&handlers, 2385 rv = ipmi_register_smi(&handlers,
2336 new_smi, 2386 new_smi,
2337 ipmi_version_major(&new_smi->device_id), 2387 &new_smi->device_id,
2338 ipmi_version_minor(&new_smi->device_id), 2388 new_smi->dev,
2339 new_smi->slave_addr, 2389 new_smi->slave_addr,
2340 &(new_smi->intf)); 2390 &(new_smi->intf));
2341 if (rv) { 2391 if (rv) {
@@ -2365,9 +2415,11 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2365 goto out_err_stop_timer; 2415 goto out_err_stop_timer;
2366 } 2416 }
2367 2417
2368 *smi = new_smi; 2418 list_add_tail(&new_smi->link, &smi_infos);
2419
2420 up(&smi_infos_lock);
2369 2421
2370 printk(" IPMI %s interface initialized\n", si_type[intf_num]); 2422 printk(" IPMI %s interface initialized\n",si_to_str[new_smi->si_type]);
2371 2423
2372 return 0; 2424 return 0;
2373 2425
@@ -2379,7 +2431,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2379 if (new_smi->intf) 2431 if (new_smi->intf)
2380 ipmi_unregister_smi(new_smi->intf); 2432 ipmi_unregister_smi(new_smi->intf);
2381 2433
2382 new_smi->irq_cleanup(new_smi); 2434 if (new_smi->irq_cleanup)
2435 new_smi->irq_cleanup(new_smi);
2383 2436
2384 /* Wait until we know that we are out of any interrupt 2437 /* Wait until we know that we are out of any interrupt
2385 handlers might have been running before we freed the 2438 handlers might have been running before we freed the
@@ -2391,23 +2444,41 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2391 new_smi->handlers->cleanup(new_smi->si_sm); 2444 new_smi->handlers->cleanup(new_smi->si_sm);
2392 kfree(new_smi->si_sm); 2445 kfree(new_smi->si_sm);
2393 } 2446 }
2447 if (new_smi->addr_source_cleanup)
2448 new_smi->addr_source_cleanup(new_smi);
2394 if (new_smi->io_cleanup) 2449 if (new_smi->io_cleanup)
2395 new_smi->io_cleanup(new_smi); 2450 new_smi->io_cleanup(new_smi);
2396 2451
2452 if (new_smi->dev_registered)
2453 platform_device_unregister(new_smi->pdev);
2454
2455 kfree(new_smi);
2456
2457 up(&smi_infos_lock);
2458
2397 return rv; 2459 return rv;
2398} 2460}
2399 2461
2400static __init int init_ipmi_si(void) 2462static __devinit int init_ipmi_si(void)
2401{ 2463{
2402 int rv = 0;
2403 int pos = 0;
2404 int i; 2464 int i;
2405 char *str; 2465 char *str;
2466 int rv;
2406 2467
2407 if (initialized) 2468 if (initialized)
2408 return 0; 2469 return 0;
2409 initialized = 1; 2470 initialized = 1;
2410 2471
2472 /* Register the device drivers. */
2473 rv = driver_register(&ipmi_driver);
2474 if (rv) {
2475 printk(KERN_ERR
2476 "init_ipmi_si: Unable to register driver: %d\n",
2477 rv);
2478 return rv;
2479 }
2480
2481
2411 /* Parse out the si_type string into its components. */ 2482 /* Parse out the si_type string into its components. */
2412 str = si_type_str; 2483 str = si_type_str;
2413 if (*str != '\0') { 2484 if (*str != '\0') {
@@ -2425,63 +2496,66 @@ static __init int init_ipmi_si(void)
2425 2496
2426 printk(KERN_INFO "IPMI System Interface driver.\n"); 2497 printk(KERN_INFO "IPMI System Interface driver.\n");
2427 2498
2499 hardcode_find_bmc();
2500
2428#ifdef CONFIG_DMI 2501#ifdef CONFIG_DMI
2429 dmi_find_bmc(); 2502 dmi_find_bmc();
2430#endif 2503#endif
2431 2504
2432 rv = init_one_smi(0, &(smi_infos[pos])); 2505#ifdef CONFIG_ACPI
2433 if (rv && ! ports[0] && si_trydefaults) { 2506 if (si_trydefaults)
2434 /* If we are trying defaults and the initial port is 2507 acpi_find_bmc();
2435 not set, then set it. */ 2508#endif
2436 si_type[0] = "kcs";
2437 ports[0] = DEFAULT_KCS_IO_PORT;
2438 rv = init_one_smi(0, &(smi_infos[pos]));
2439 if (rv) {
2440 /* No KCS - try SMIC */
2441 si_type[0] = "smic";
2442 ports[0] = DEFAULT_SMIC_IO_PORT;
2443 rv = init_one_smi(0, &(smi_infos[pos]));
2444 }
2445 if (rv) {
2446 /* No SMIC - try BT */
2447 si_type[0] = "bt";
2448 ports[0] = DEFAULT_BT_IO_PORT;
2449 rv = init_one_smi(0, &(smi_infos[pos]));
2450 }
2451 }
2452 if (rv == 0)
2453 pos++;
2454 2509
2455 for (i = 1; i < SI_MAX_PARMS; i++) { 2510#ifdef CONFIG_PCI
2456 rv = init_one_smi(i, &(smi_infos[pos])); 2511 pci_module_init(&ipmi_pci_driver);
2457 if (rv == 0) 2512#endif
2458 pos++; 2513
2514 if (si_trydefaults) {
2515 down(&smi_infos_lock);
2516 if (list_empty(&smi_infos)) {
2517 /* No BMC was found, try defaults. */
2518 up(&smi_infos_lock);
2519 default_find_bmc();
2520 } else {
2521 up(&smi_infos_lock);
2522 }
2459 } 2523 }
2460 2524
2461 if (smi_infos[0] == NULL) { 2525 down(&smi_infos_lock);
2526 if (list_empty(&smi_infos)) {
2527 up(&smi_infos_lock);
2528#ifdef CONFIG_PCI
2529 pci_unregister_driver(&ipmi_pci_driver);
2530#endif
2462 printk("ipmi_si: Unable to find any System Interface(s)\n"); 2531 printk("ipmi_si: Unable to find any System Interface(s)\n");
2463 return -ENODEV; 2532 return -ENODEV;
2533 } else {
2534 up(&smi_infos_lock);
2535 return 0;
2464 } 2536 }
2465
2466 return 0;
2467} 2537}
2468module_init(init_ipmi_si); 2538module_init(init_ipmi_si);
2469 2539
2470static void __exit cleanup_one_si(struct smi_info *to_clean) 2540static void __devexit cleanup_one_si(struct smi_info *to_clean)
2471{ 2541{
2472 int rv; 2542 int rv;
2473 unsigned long flags; 2543 unsigned long flags;
2474 2544
2475 if (! to_clean) 2545 if (!to_clean)
2476 return; 2546 return;
2477 2547
2548 list_del(&to_clean->link);
2549
2478 /* Tell the timer and interrupt handlers that we are shutting 2550 /* Tell the timer and interrupt handlers that we are shutting
2479 down. */ 2551 down. */
2480 spin_lock_irqsave(&(to_clean->si_lock), flags); 2552 spin_lock_irqsave(&(to_clean->si_lock), flags);
2481 spin_lock(&(to_clean->msg_lock)); 2553 spin_lock(&(to_clean->msg_lock));
2482 2554
2483 atomic_inc(&to_clean->stop_operation); 2555 atomic_inc(&to_clean->stop_operation);
2484 to_clean->irq_cleanup(to_clean); 2556
2557 if (to_clean->irq_cleanup)
2558 to_clean->irq_cleanup(to_clean);
2485 2559
2486 spin_unlock(&(to_clean->msg_lock)); 2560 spin_unlock(&(to_clean->msg_lock));
2487 spin_unlock_irqrestore(&(to_clean->si_lock), flags); 2561 spin_unlock_irqrestore(&(to_clean->si_lock), flags);
@@ -2511,20 +2585,34 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2511 2585
2512 kfree(to_clean->si_sm); 2586 kfree(to_clean->si_sm);
2513 2587
2588 if (to_clean->addr_source_cleanup)
2589 to_clean->addr_source_cleanup(to_clean);
2514 if (to_clean->io_cleanup) 2590 if (to_clean->io_cleanup)
2515 to_clean->io_cleanup(to_clean); 2591 to_clean->io_cleanup(to_clean);
2592
2593 if (to_clean->dev_registered)
2594 platform_device_unregister(to_clean->pdev);
2595
2596 kfree(to_clean);
2516} 2597}
2517 2598
2518static __exit void cleanup_ipmi_si(void) 2599static __exit void cleanup_ipmi_si(void)
2519{ 2600{
2520 int i; 2601 struct smi_info *e, *tmp_e;
2521 2602
2522 if (! initialized) 2603 if (!initialized)
2523 return; 2604 return;
2524 2605
2525 for (i = 0; i < SI_MAX_DRIVERS; i++) { 2606#ifdef CONFIG_PCI
2526 cleanup_one_si(smi_infos[i]); 2607 pci_unregister_driver(&ipmi_pci_driver);
2527 } 2608#endif
2609
2610 down(&smi_infos_lock);
2611 list_for_each_entry_safe(e, tmp_e, &smi_infos, link)
2612 cleanup_one_si(e);
2613 up(&smi_infos_lock);
2614
2615 driver_unregister(&ipmi_driver);
2528} 2616}
2529module_exit(cleanup_ipmi_si); 2617module_exit(cleanup_ipmi_si);
2530 2618
diff --git a/drivers/char/ipmi/ipmi_si_sm.h b/drivers/char/ipmi/ipmi_si_sm.h
index bf3d4962d6a5..4b731b24dc16 100644
--- a/drivers/char/ipmi/ipmi_si_sm.h
+++ b/drivers/char/ipmi/ipmi_si_sm.h
@@ -50,11 +50,12 @@ struct si_sm_io
50 50
51 /* Generic info used by the actual handling routines, the 51 /* Generic info used by the actual handling routines, the
52 state machine shouldn't touch these. */ 52 state machine shouldn't touch these. */
53 void *info;
54 void __iomem *addr; 53 void __iomem *addr;
55 int regspacing; 54 int regspacing;
56 int regsize; 55 int regsize;
57 int regshift; 56 int regshift;
57 int addr_type;
58 long addr_data;
58}; 59};
59 60
60/* Results of SMI events. */ 61/* Results of SMI events. */
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 1f3159eb1ede..7ece9f3c8f70 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -996,7 +996,7 @@ static struct notifier_block wdog_panic_notifier = {
996}; 996};
997 997
998 998
999static void ipmi_new_smi(int if_num) 999static void ipmi_new_smi(int if_num, struct device *device)
1000{ 1000{
1001 ipmi_register_watchdog(if_num); 1001 ipmi_register_watchdog(if_num);
1002} 1002}
@@ -1158,7 +1158,8 @@ static int __init ipmi_wdog_init(void)
1158 } 1158 }
1159 1159
1160 register_reboot_notifier(&wdog_reboot_notifier); 1160 register_reboot_notifier(&wdog_reboot_notifier);
1161 notifier_chain_register(&panic_notifier_list, &wdog_panic_notifier); 1161 atomic_notifier_chain_register(&panic_notifier_list,
1162 &wdog_panic_notifier);
1162 1163
1163 printk(KERN_INFO PFX "driver initialized\n"); 1164 printk(KERN_INFO PFX "driver initialized\n");
1164 1165
@@ -1176,7 +1177,8 @@ static __exit void ipmi_unregister_watchdog(void)
1176 release_nmi(&ipmi_nmi_handler); 1177 release_nmi(&ipmi_nmi_handler);
1177#endif 1178#endif
1178 1179
1179 notifier_chain_unregister(&panic_notifier_list, &wdog_panic_notifier); 1180 atomic_notifier_chain_unregister(&panic_notifier_list,
1181 &wdog_panic_notifier);
1180 unregister_reboot_notifier(&wdog_reboot_notifier); 1182 unregister_reboot_notifier(&wdog_reboot_notifier);
1181 1183
1182 if (! watchdog_user) 1184 if (! watchdog_user)
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 28c5a3193b81..e5247f85a446 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -181,7 +181,6 @@ static struct tty_driver *stli_serial;
181 * is already swapping a shared buffer won't make things any worse. 181 * is already swapping a shared buffer won't make things any worse.
182 */ 182 */
183static char *stli_tmpwritebuf; 183static char *stli_tmpwritebuf;
184static DECLARE_MUTEX(stli_tmpwritesem);
185 184
186#define STLI_TXBUFSIZE 4096 185#define STLI_TXBUFSIZE 4096
187 186
@@ -379,13 +378,13 @@ MODULE_DESCRIPTION("Stallion Intelligent Multiport Serial Driver");
379MODULE_LICENSE("GPL"); 378MODULE_LICENSE("GPL");
380 379
381 380
382MODULE_PARM(board0, "1-3s"); 381module_param_array(board0, charp, NULL, 0);
383MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,memaddr]"); 382MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,memaddr]");
384MODULE_PARM(board1, "1-3s"); 383module_param_array(board1, charp, NULL, 0);
385MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,memaddr]"); 384MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,memaddr]");
386MODULE_PARM(board2, "1-3s"); 385module_param_array(board2, charp, NULL, 0);
387MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]"); 386MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
388MODULE_PARM(board3, "1-3s"); 387module_param_array(board3, charp, NULL, 0);
389MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]"); 388MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
390 389
391#endif 390#endif
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 29c41f4418c0..66719f9d294c 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -88,21 +88,15 @@ static inline int uncached_access(struct file *file, unsigned long addr)
88} 88}
89 89
90#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE 90#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
91static inline int valid_phys_addr_range(unsigned long addr, size_t *count) 91static inline int valid_phys_addr_range(unsigned long addr, size_t count)
92{ 92{
93 unsigned long end_mem; 93 if (addr + count > __pa(high_memory))
94
95 end_mem = __pa(high_memory);
96 if (addr >= end_mem)
97 return 0; 94 return 0;
98 95
99 if (*count > end_mem - addr)
100 *count = end_mem - addr;
101
102 return 1; 96 return 1;
103} 97}
104 98
105static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t *size) 99static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size)
106{ 100{
107 return 1; 101 return 1;
108} 102}
@@ -119,7 +113,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
119 ssize_t read, sz; 113 ssize_t read, sz;
120 char *ptr; 114 char *ptr;
121 115
122 if (!valid_phys_addr_range(p, &count)) 116 if (!valid_phys_addr_range(p, count))
123 return -EFAULT; 117 return -EFAULT;
124 read = 0; 118 read = 0;
125#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 119#ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
@@ -177,7 +171,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
177 unsigned long copied; 171 unsigned long copied;
178 void *ptr; 172 void *ptr;
179 173
180 if (!valid_phys_addr_range(p, &count)) 174 if (!valid_phys_addr_range(p, count))
181 return -EFAULT; 175 return -EFAULT;
182 176
183 written = 0; 177 written = 0;
@@ -216,11 +210,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
216 210
217 copied = copy_from_user(ptr, buf, sz); 211 copied = copy_from_user(ptr, buf, sz);
218 if (copied) { 212 if (copied) {
219 ssize_t ret; 213 written += sz - copied;
220 214 if (written)
221 ret = written + (sz - copied); 215 break;
222 if (ret)
223 return ret;
224 return -EFAULT; 216 return -EFAULT;
225 } 217 }
226 buf += sz; 218 buf += sz;
@@ -251,7 +243,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
251{ 243{
252 size_t size = vma->vm_end - vma->vm_start; 244 size_t size = vma->vm_end - vma->vm_start;
253 245
254 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, &size)) 246 if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
255 return -EINVAL; 247 return -EINVAL;
256 248
257 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 249 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
@@ -456,11 +448,9 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
456 448
457 copied = copy_from_user(ptr, buf, sz); 449 copied = copy_from_user(ptr, buf, sz);
458 if (copied) { 450 if (copied) {
459 ssize_t ret; 451 written += sz - copied;
460 452 if (written)
461 ret = written + (sz - copied); 453 break;
462 if (ret)
463 return ret;
464 return -EFAULT; 454 return -EFAULT;
465 } 455 }
466 buf += sz; 456 buf += sz;
@@ -514,11 +504,10 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
514 if (len) { 504 if (len) {
515 written = copy_from_user(kbuf, buf, len); 505 written = copy_from_user(kbuf, buf, len);
516 if (written) { 506 if (written) {
517 ssize_t ret; 507 if (wrote + virtr)
518 508 break;
519 free_page((unsigned long)kbuf); 509 free_page((unsigned long)kbuf);
520 ret = wrote + virtr + (len - written); 510 return -EFAULT;
521 return ret ? ret : -EFAULT;
522 } 511 }
523 } 512 }
524 len = vwrite(kbuf, (char *)p, len); 513 len = vwrite(kbuf, (char *)p, len);
@@ -563,8 +552,11 @@ static ssize_t write_port(struct file * file, const char __user * buf,
563 return -EFAULT; 552 return -EFAULT;
564 while (count-- > 0 && i < 65536) { 553 while (count-- > 0 && i < 65536) {
565 char c; 554 char c;
566 if (__get_user(c, tmp)) 555 if (__get_user(c, tmp)) {
556 if (tmp > buf)
557 break;
567 return -EFAULT; 558 return -EFAULT;
559 }
568 outb(c,i); 560 outb(c,i);
569 i++; 561 i++;
570 tmp++; 562 tmp++;
@@ -907,7 +899,7 @@ static const struct {
907 unsigned int minor; 899 unsigned int minor;
908 char *name; 900 char *name;
909 umode_t mode; 901 umode_t mode;
910 struct file_operations *fops; 902 const struct file_operations *fops;
911} devlist[] = { /* list of minor devices */ 903} devlist[] = { /* list of minor devices */
912 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops}, 904 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
913 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops}, 905 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 3e4c0414a01a..96eb2a709e21 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -129,7 +129,7 @@ static int misc_open(struct inode * inode, struct file * file)
129 int minor = iminor(inode); 129 int minor = iminor(inode);
130 struct miscdevice *c; 130 struct miscdevice *c;
131 int err = -ENODEV; 131 int err = -ENODEV;
132 struct file_operations *old_fops, *new_fops = NULL; 132 const struct file_operations *old_fops, *new_fops = NULL;
133 133
134 down(&misc_sem); 134 down(&misc_sem);
135 135
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index ea725a9964e2..0fb2fb9fb024 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -243,10 +243,10 @@ static int verbose = 0;
243 243
244MODULE_AUTHOR("Casper Yang"); 244MODULE_AUTHOR("Casper Yang");
245MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver"); 245MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
246MODULE_PARM(ioaddr, "1-4i"); 246module_param_array(ioaddr, int, NULL, 0);
247MODULE_PARM(ttymajor, "i"); 247module_param(ttymajor, int, 0);
248MODULE_PARM(calloutmajor, "i"); 248module_param(calloutmajor, int, 0);
249MODULE_PARM(verbose, "i"); 249module_param(verbose, bool, 0);
250MODULE_LICENSE("GPL"); 250MODULE_LICENSE("GPL");
251 251
252struct mxser_log { 252struct mxser_log {
diff --git a/drivers/char/mxser.h b/drivers/char/mxser.h
index e7fd0b08e0b7..7e188a4d602a 100644
--- a/drivers/char/mxser.h
+++ b/drivers/char/mxser.h
@@ -118,7 +118,7 @@
118 118
119// enable CTS interrupt 119// enable CTS interrupt
120#define MOXA_MUST_IER_ECTSI 0x80 120#define MOXA_MUST_IER_ECTSI 0x80
121// eanble RTS interrupt 121// enable RTS interrupt
122#define MOXA_MUST_IER_ERTSI 0x40 122#define MOXA_MUST_IER_ERTSI 0x40
123// enable Xon/Xoff interrupt 123// enable Xon/Xoff interrupt
124#define MOXA_MUST_IER_XINT 0x20 124#define MOXA_MUST_IER_XINT 0x20
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index ccad7ae94541..ede365d05387 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty)
132 * We test the TTY_THROTTLED bit first so that it always 132 * We test the TTY_THROTTLED bit first so that it always
133 * indicates the current state. The decision about whether 133 * indicates the current state. The decision about whether
134 * it is worth allowing more input has been taken by the caller. 134 * it is worth allowing more input has been taken by the caller.
135 * Can sleep, may be called under the atomic_read semaphore but 135 * Can sleep, may be called under the atomic_read_lock mutex but
136 * this is not guaranteed. 136 * this is not guaranteed.
137 */ 137 */
138 138
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1132 * buffer, and once to drain the space from the (physical) beginning of 1132 * buffer, and once to drain the space from the (physical) beginning of
1133 * the buffer to head pointer. 1133 * the buffer to head pointer.
1134 * 1134 *
1135 * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set 1135 * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set
1136 * 1136 *
1137 */ 1137 */
1138 1138
@@ -1262,11 +1262,11 @@ do_it_again:
1262 * Internal serialization of reads. 1262 * Internal serialization of reads.
1263 */ 1263 */
1264 if (file->f_flags & O_NONBLOCK) { 1264 if (file->f_flags & O_NONBLOCK) {
1265 if (down_trylock(&tty->atomic_read)) 1265 if (!mutex_trylock(&tty->atomic_read_lock))
1266 return -EAGAIN; 1266 return -EAGAIN;
1267 } 1267 }
1268 else { 1268 else {
1269 if (down_interruptible(&tty->atomic_read)) 1269 if (mutex_lock_interruptible(&tty->atomic_read_lock))
1270 return -ERESTARTSYS; 1270 return -ERESTARTSYS;
1271 } 1271 }
1272 1272
@@ -1393,7 +1393,7 @@ do_it_again:
1393 timeout = time; 1393 timeout = time;
1394 } 1394 }
1395 clear_bit(TTY_DONT_FLIP, &tty->flags); 1395 clear_bit(TTY_DONT_FLIP, &tty->flags);
1396 up(&tty->atomic_read); 1396 mutex_unlock(&tty->atomic_read_lock);
1397 remove_wait_queue(&tty->read_wait, &wait); 1397 remove_wait_queue(&tty->read_wait, &wait);
1398 1398
1399 if (!waitqueue_active(&tty->read_wait)) 1399 if (!waitqueue_active(&tty->read_wait))
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index ca41d62b1d9d..8865387d3448 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -27,6 +27,7 @@
27#include <linux/rwsem.h> 27#include <linux/rwsem.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/smp_lock.h> 29#include <linux/smp_lock.h>
30#include <linux/mutex.h>
30 31
31#include <asm/hardware/dec21285.h> 32#include <asm/hardware/dec21285.h>
32#include <asm/io.h> 33#include <asm/io.h>
@@ -56,7 +57,7 @@ static int gbWriteEnable;
56static int gbWriteBase64Enable; 57static int gbWriteBase64Enable;
57static volatile unsigned char *FLASH_BASE; 58static volatile unsigned char *FLASH_BASE;
58static int gbFlashSize = KFLASH_SIZE; 59static int gbFlashSize = KFLASH_SIZE;
59static DECLARE_MUTEX(nwflash_sem); 60static DEFINE_MUTEX(nwflash_mutex);
60 61
61extern spinlock_t gpio_lock; 62extern spinlock_t gpio_lock;
62 63
@@ -140,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
140 /* 141 /*
141 * We now lock against reads and writes. --rmk 142 * We now lock against reads and writes. --rmk
142 */ 143 */
143 if (down_interruptible(&nwflash_sem)) 144 if (mutex_lock_interruptible(&nwflash_mutex))
144 return -ERESTARTSYS; 145 return -ERESTARTSYS;
145 146
146 ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); 147 ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
@@ -149,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
149 *ppos += count; 150 *ppos += count;
150 } else 151 } else
151 ret = -EFAULT; 152 ret = -EFAULT;
152 up(&nwflash_sem); 153 mutex_unlock(&nwflash_mutex);
153 } 154 }
154 return ret; 155 return ret;
155} 156}
@@ -188,7 +189,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
188 /* 189 /*
189 * We now lock against reads and writes. --rmk 190 * We now lock against reads and writes. --rmk
190 */ 191 */
191 if (down_interruptible(&nwflash_sem)) 192 if (mutex_lock_interruptible(&nwflash_mutex))
192 return -ERESTARTSYS; 193 return -ERESTARTSYS;
193 194
194 written = 0; 195 written = 0;
@@ -277,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
277 */ 278 */
278 leds_event(led_release); 279 leds_event(led_release);
279 280
280 up(&nwflash_sem); 281 mutex_unlock(&nwflash_mutex);
281 282
282 return written; 283 return written;
283} 284}
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 8a8ca32822ba..e6b714b6390d 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -4181,7 +4181,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
4181 } 4181 }
4182 4182
4183 info->params.encoding = new_encoding; 4183 info->params.encoding = new_encoding;
4184 info->params.crc_type = new_crctype;; 4184 info->params.crc_type = new_crctype;
4185 4185
4186 /* if network interface up, reprogram hardware */ 4186 /* if network interface up, reprogram hardware */
4187 if (info->netcount) 4187 if (info->netcount)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 306ee0f091a4..bee6c47b45bd 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -65,10 +65,11 @@
65#include <linux/parport.h> 65#include <linux/parport.h>
66#include <linux/ctype.h> 66#include <linux/ctype.h>
67#include <linux/poll.h> 67#include <linux/poll.h>
68#include <asm/uaccess.h> 68#include <linux/major.h>
69#include <linux/ppdev.h> 69#include <linux/ppdev.h>
70#include <linux/smp_lock.h> 70#include <linux/smp_lock.h>
71#include <linux/device.h> 71#include <linux/device.h>
72#include <asm/uaccess.h>
72 73
73#define PP_VERSION "ppdev: user-space parallel port driver" 74#define PP_VERSION "ppdev: user-space parallel port driver"
74#define CHRDEV "ppdev" 75#define CHRDEV "ppdev"
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 30e4cbe16bb0..15a7b4086524 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,6 +19,7 @@
19#include <linux/uio.h> 19#include <linux/uio.h>
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/mutex.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
@@ -29,7 +30,7 @@ struct raw_device_data {
29 30
30static struct class *raw_class; 31static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 32static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 33static DEFINE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 34static struct file_operations raw_ctl_fops; /* forward declaration */
34 35
35/* 36/*
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
53 return 0; 54 return 0;
54 } 55 }
55 56
56 down(&raw_mutex); 57 mutex_lock(&raw_mutex);
57 58
58 /* 59 /*
59 * All we need to do on open is check that the device is bound. 60 * All we need to do on open is check that the device is bound.
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp)
78 filp->f_dentry->d_inode->i_mapping = 79 filp->f_dentry->d_inode->i_mapping =
79 bdev->bd_inode->i_mapping; 80 bdev->bd_inode->i_mapping;
80 filp->private_data = bdev; 81 filp->private_data = bdev;
81 up(&raw_mutex); 82 mutex_unlock(&raw_mutex);
82 return 0; 83 return 0;
83 84
84out2: 85out2:
@@ -86,7 +87,7 @@ out2:
86out1: 87out1:
87 blkdev_put(bdev); 88 blkdev_put(bdev);
88out: 89out:
89 up(&raw_mutex); 90 mutex_unlock(&raw_mutex);
90 return err; 91 return err;
91} 92}
92 93
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp)
99 const int minor= iminor(inode); 100 const int minor= iminor(inode);
100 struct block_device *bdev; 101 struct block_device *bdev;
101 102
102 down(&raw_mutex); 103 mutex_lock(&raw_mutex);
103 bdev = raw_devices[minor].binding; 104 bdev = raw_devices[minor].binding;
104 if (--raw_devices[minor].inuse == 0) { 105 if (--raw_devices[minor].inuse == 0) {
105 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */ 106 /* Here inode->i_mapping == bdev->bd_inode->i_mapping */
106 inode->i_mapping = &inode->i_data; 107 inode->i_mapping = &inode->i_data;
107 inode->i_mapping->backing_dev_info = &default_backing_dev_info; 108 inode->i_mapping->backing_dev_info = &default_backing_dev_info;
108 } 109 }
109 up(&raw_mutex); 110 mutex_unlock(&raw_mutex);
110 111
111 bd_release(bdev); 112 bd_release(bdev);
112 blkdev_put(bdev); 113 blkdev_put(bdev);
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
187 goto out; 188 goto out;
188 } 189 }
189 190
190 down(&raw_mutex); 191 mutex_lock(&raw_mutex);
191 if (rawdev->inuse) { 192 if (rawdev->inuse) {
192 up(&raw_mutex); 193 mutex_unlock(&raw_mutex);
193 err = -EBUSY; 194 err = -EBUSY;
194 goto out; 195 goto out;
195 } 196 }
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
211 bind_device(&rq); 212 bind_device(&rq);
212 } 213 }
213 } 214 }
214 up(&raw_mutex); 215 mutex_unlock(&raw_mutex);
215 } else { 216 } else {
216 struct block_device *bdev; 217 struct block_device *bdev;
217 218
218 down(&raw_mutex); 219 mutex_lock(&raw_mutex);
219 bdev = rawdev->binding; 220 bdev = rawdev->binding;
220 if (bdev) { 221 if (bdev) {
221 rq.block_major = MAJOR(bdev->bd_dev); 222 rq.block_major = MAJOR(bdev->bd_dev);
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
223 } else { 224 } else {
224 rq.block_major = rq.block_minor = 0; 225 rq.block_major = rq.block_minor = 0;
225 } 226 }
226 up(&raw_mutex); 227 mutex_unlock(&raw_mutex);
227 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) { 228 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
228 err = -EFAULT; 229 err = -EFAULT;
229 goto out; 230 goto out;
diff --git a/drivers/char/rio/Makefile b/drivers/char/rio/Makefile
index bce2bd1204ed..2d1c5a7cba7d 100644
--- a/drivers/char/rio/Makefile
+++ b/drivers/char/rio/Makefile
@@ -9,4 +9,4 @@
9obj-$(CONFIG_RIO) += rio.o 9obj-$(CONFIG_RIO) += rio.o
10 10
11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \ 11rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
12 rioparam.o riopcicopy.o rioroute.o riotable.o riotty.o 12 rioparam.o rioroute.o riotable.o riotty.o
diff --git a/drivers/char/rio/board.h b/drivers/char/rio/board.h
index 29c980204098..bdea633a9076 100644
--- a/drivers/char/rio/board.h
+++ b/drivers/char/rio/board.h
@@ -33,10 +33,6 @@
33#ifndef __rio_board_h__ 33#ifndef __rio_board_h__
34#define __rio_board_h__ 34#define __rio_board_h__
35 35
36#ifdef SCCS_LABELS
37static char *_board_h_sccs_ = "@(#)board.h 1.2";
38#endif
39
40/* 36/*
41** board.h contains the definitions for the *hardware* of the host cards. 37** board.h contains the definitions for the *hardware* of the host cards.
42** It describes the memory overlay for the dual port RAM area. 38** It describes the memory overlay for the dual port RAM area.
@@ -53,29 +49,29 @@ static char *_board_h_sccs_ = "@(#)board.h 1.2";
53** The shape of the Host Control area, at offset 0x7C00, Write Only 49** The shape of the Host Control area, at offset 0x7C00, Write Only
54*/ 50*/
55struct s_Ctrl { 51struct s_Ctrl {
56 BYTE DpCtl; /* 7C00 */ 52 u8 DpCtl; /* 7C00 */
57 BYTE Dp_Unused2_[127]; 53 u8 Dp_Unused2_[127];
58 BYTE DpIntSet; /* 7C80 */ 54 u8 DpIntSet; /* 7C80 */
59 BYTE Dp_Unused3_[127]; 55 u8 Dp_Unused3_[127];
60 BYTE DpTpuReset; /* 7D00 */ 56 u8 DpTpuReset; /* 7D00 */
61 BYTE Dp_Unused4_[127]; 57 u8 Dp_Unused4_[127];
62 BYTE DpIntReset; /* 7D80 */ 58 u8 DpIntReset; /* 7D80 */
63 BYTE Dp_Unused5_[127]; 59 u8 Dp_Unused5_[127];
64}; 60};
65 61
66/* 62/*
67** The PROM data area on the host (0x7C00), Read Only 63** The PROM data area on the host (0x7C00), Read Only
68*/ 64*/
69struct s_Prom { 65struct s_Prom {
70 WORD DpSlxCode[2]; 66 u16 DpSlxCode[2];
71 WORD DpRev; 67 u16 DpRev;
72 WORD Dp_Unused6_; 68 u16 Dp_Unused6_;
73 WORD DpUniq[4]; 69 u16 DpUniq[4];
74 WORD DpJahre; 70 u16 DpJahre;
75 WORD DpWoche; 71 u16 DpWoche;
76 WORD DpHwFeature[5]; 72 u16 DpHwFeature[5];
77 WORD DpOemId; 73 u16 DpOemId;
78 WORD DpSiggy[16]; 74 u16 DpSiggy[16];
79}; 75};
80 76
81/* 77/*
@@ -90,19 +86,19 @@ union u_CtrlProm { /* This is the control/PROM area (0x7C00) */
90** The top end of memory! 86** The top end of memory!
91*/ 87*/
92struct s_ParmMapS { /* Area containing Parm Map Pointer */ 88struct s_ParmMapS { /* Area containing Parm Map Pointer */
93 BYTE Dp_Unused8_[DP_PARMMAP_ADDR]; 89 u8 Dp_Unused8_[DP_PARMMAP_ADDR];
94 WORD DpParmMapAd; 90 u16 DpParmMapAd;
95}; 91};
96 92
97struct s_StartUpS { 93struct s_StartUpS {
98 BYTE Dp_Unused9_[DP_STARTUP_ADDR]; 94 u8 Dp_Unused9_[DP_STARTUP_ADDR];
99 BYTE Dp_LongJump[0x4]; 95 u8 Dp_LongJump[0x4];
100 BYTE Dp_Unused10_[2]; 96 u8 Dp_Unused10_[2];
101 BYTE Dp_ShortJump[0x2]; 97 u8 Dp_ShortJump[0x2];
102}; 98};
103 99
104union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */ 100union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
105 BYTE DpSramMem[DP_SRAM2_SIZE]; 101 u8 DpSramMem[DP_SRAM2_SIZE];
106 struct s_ParmMapS DpParmMapS; 102 struct s_ParmMapS DpParmMapS;
107 struct s_StartUpS DpStartUpS; 103 struct s_StartUpS DpStartUpS;
108}; 104};
@@ -111,11 +107,11 @@ union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
111** This is the DP RAM overlay. 107** This is the DP RAM overlay.
112*/ 108*/
113struct DpRam { 109struct DpRam {
114 BYTE DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */ 110 u8 DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */
115 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */ 111 union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */
116 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */ 112 union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */
117 BYTE DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */ 113 u8 DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
118 BYTE DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */ 114 u8 DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */
119}; 115};
120 116
121#define DpControl DpCtrlProm.DpCtrl.DpCtl 117#define DpControl DpCtrlProm.DpCtrl.DpCtl
diff --git a/drivers/char/rio/bootpkt.h b/drivers/char/rio/bootpkt.h
deleted file mode 100644
index 602266e0c085..000000000000
--- a/drivers/char/rio/bootpkt.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* B O O T P A C K E T H E A D E R F I L E
6 ******* *******
7 ****************************************************************************
8
9 Author : Ian Nandhra
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39#ifndef _pkt_h
40#define _pkt_h 1
41
42#ifndef lint
43#ifdef SCCS
44static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h 1.1";
45#endif
46#endif
47
48 /*************************************************
49 * Overlayed onto the Data fields of a regular
50 * Packet
51 ************************************************/
52typedef struct BOOT_PKT BOOT_PKT;
53struct BOOT_PKT {
54 short seq_num;
55 char data[10];
56};
57
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 89bd94eb45be..f4f837f86829 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,73 +40,7 @@
40#endif 40#endif
41#define _cirrus_h 1 41#define _cirrus_h 1
42 42
43 43/* Bit fields for particular registers shared with driver */
44
45/* Bit fields for particular registers */
46
47/* GCR */
48#define GCR_SERIAL 0x00 /* Configure as serial channel */
49#define GCR_PARALLEL 0x80 /* Configure as parallel channel */
50
51/* RDSR - when status read from FIFO */
52#define RDSR_BREAK 0x08 /* Break received */
53#define RDSR_TIMEOUT 0x80 /* No new data timeout */
54#define RDSR_SC1 0x10 /* Special char 1 (tx XON) matched */
55#define RDSR_SC2 0x20 /* Special char 2 (tx XOFF) matched */
56#define RDSR_SC12_MASK 0x30 /* Mask for special chars 1 and 2 */
57
58/* PPR */
59#define PPR_DEFAULT 0x31 /* Default value - for a 25Mhz clock gives
60 a timeout period of 1ms */
61
62/* LIVR */
63#define LIVR_EXCEPTION 0x07 /* Receive exception interrupt */
64
65/* CCR */
66#define CCR_RESET 0x80 /* Reset channel */
67#define CCR_CHANGE 0x4e /* COR's have changed - NB always change all
68 COR's */
69#define CCR_WFLUSH 0x82 /* Flush transmit FIFO and TSR / THR */
70
71#define CCR_SENDSC1 0x21 /* Send special character one */
72#define CCR_SENDSC2 0x22 /* Send special character two */
73#define CCR_SENDSC3 0x23 /* Send special character three */
74#define CCR_SENDSC4 0x24 /* Send special character four */
75
76#define CCR_TENABLE 0x18 /* Enable transmitter */
77#define CCR_TDISABLE 0x14 /* Disable transmitter */
78#define CCR_RENABLE 0x12 /* Enable receiver */
79#define CCR_RDISABLE 0x11 /* Disable receiver */
80
81#define CCR_READY 0x00 /* CCR is ready for another command */
82
83/* CCSR */
84#define CCSR_TXENABLE 0x08 /* Transmitter enable */
85#define CCSR_RXENABLE 0x80 /* Receiver enable */
86#define CCSR_TXFLOWOFF 0x04 /* Transmit flow off */
87#define CCSR_TXFLOWON 0x02 /* Transmit flow on */
88
89/* SVRR */
90#define SVRR_RECEIVE 0x01 /* Receive interrupt pending */
91#define SVRR_TRANSMIT 0x02 /* Transmit interrupt pending */
92#define SVRR_MODEM 0x04 /* Modem interrupt pending */
93
94/* CAR */
95#define CAR_PORTS 0x03 /* Bit fields for ports */
96
97/* IER */
98#define IER_MODEM 0x80 /* Change in modem status */
99#define IER_RECEIVE 0x10 /* Good data / data exception */
100#define IER_TRANSMITR 0x04 /* Transmit ready (FIFO empty) */
101#define IER_TRANSMITE 0x02 /* Transmit empty */
102#define IER_TIMEOUT 0x01 /* Timeout on no data */
103
104#define IER_DEFAULT 0x94 /* Default values */
105#define IER_PARALLEL 0x84 /* Default for Parallel */
106#define IER_EMPTY 0x92 /* Transmitter empty rather than ready */
107
108/* COR1 - Driver only */
109#define COR1_INPCK 0x10 /* Check parity of received characters */
110 44
111/* COR1 - driver and RTA */ 45/* COR1 - driver and RTA */
112#define COR1_ODD 0x80 /* Odd parity */ 46#define COR1_ODD 0x80 /* Odd parity */
@@ -222,35 +156,6 @@
222 156
223#define MSVR1_HOST 0xf3 /* The bits the host wants */ 157#define MSVR1_HOST 0xf3 /* The bits the host wants */
224 158
225/* MSVR2 */
226#define MSVR2_DSR 0x02 /* DSR output pin (DTR on Cirrus) */
227
228/* MCOR */
229#define MCOR_CD 0x80 /* CD (DSR on Cirrus) */
230#define MCOR_RTS 0x40 /* RTS (CTS on Cirrus) */
231#define MCOR_RI 0x20 /* RI */
232#define MCOR_DTR 0x10 /* DTR (CD on Cirrus) */
233
234#define MCOR_DEFAULT (MCOR_CD | MCOR_RTS | MCOR_RI | MCOR_DTR)
235#define MCOR_FULLMODEM MCOR_DEFAULT
236#define MCOR_RJ45 (MCOR_CD | MCOR_RTS | MCOR_DTR)
237#define MCOR_RESTRICTED (MCOR_CD | MCOR_RTS)
238
239/* More MCOR - H/W Handshake (flowcontrol) stuff */
240#define MCOR_THRESH8 0x08 /* eight characters then we stop */
241#define MCOR_THRESH9 0x09 /* nine characters then we stop */
242#define MCOR_THRESH10 0x0A /* ten characters then we stop */
243#define MCOR_THRESH11 0x0B /* eleven characters then we stop */
244
245#define MCOR_THRESHBITS 0x0F /* mask for ANDing out the above */
246
247#define MCOR_THRESHOLD MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
248
249
250/* RTPR */
251#define RTPR_DEFAULT 0x02 /* Default */
252
253
254/* Defines for the subscripts of a CONFIG packet */ 159/* Defines for the subscripts of a CONFIG packet */
255#define CONFIG_COR1 1 /* Option register 1 */ 160#define CONFIG_COR1 1 /* Option register 1 */
256#define CONFIG_COR2 2 /* Option register 2 */ 161#define CONFIG_COR2 2 /* Option register 2 */
@@ -264,19 +169,6 @@
264#define CONFIG_TXBAUD 10 /* Tx baud rate */ 169#define CONFIG_TXBAUD 10 /* Tx baud rate */
265#define CONFIG_RXBAUD 11 /* Rx baud rate */ 170#define CONFIG_RXBAUD 11 /* Rx baud rate */
266 171
267/* Port status stuff */
268#define IDLE_CLOSED 0 /* Closed */
269#define IDLE_OPEN 1 /* Idle open */
270#define IDLE_BREAK 2 /* Idle on break */
271
272/* Subscript of MODEM STATUS packet */
273#define MODEM_VALUE 3 /* Current values of handshake pins */
274/* Subscript of SBREAK packet */
275#define BREAK_LENGTH 1 /* Length of a break in slices of 0.01 seconds
276 0 = stay on break until an EBREAK command
277 is sent */
278
279
280#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */ 172#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
281 173
282/* Packet types going from Host to remote - with the exception of OPEN, MOPEN, 174/* Packet types going from Host to remote - with the exception of OPEN, MOPEN,
diff --git a/drivers/char/rio/cmdblk.h b/drivers/char/rio/cmdblk.h
index a9a8c45631d7..c46b2fdb6626 100644
--- a/drivers/char/rio/cmdblk.h
+++ b/drivers/char/rio/cmdblk.h
@@ -48,10 +48,10 @@ struct CmdBlk {
48 struct CmdBlk *NextP; /* Pointer to next command block */ 48 struct CmdBlk *NextP; /* Pointer to next command block */
49 struct PKT Packet; /* A packet, to copy to the rup */ 49 struct PKT Packet; /* A packet, to copy to the rup */
50 /* The func to call to check if OK */ 50 /* The func to call to check if OK */
51 int (*PreFuncP) (int, struct CmdBlk *); 51 int (*PreFuncP) (unsigned long, struct CmdBlk *);
52 int PreArg; /* The arg for the func */ 52 int PreArg; /* The arg for the func */
53 /* The func to call when completed */ 53 /* The func to call when completed */
54 int (*PostFuncP) (int, struct CmdBlk *); 54 int (*PostFuncP) (unsigned long, struct CmdBlk *);
55 int PostArg; /* The arg for the func */ 55 int PostArg; /* The arg for the func */
56}; 56};
57 57
diff --git a/drivers/char/rio/cmdpkt.h b/drivers/char/rio/cmdpkt.h
index 77cee8df68ef..357ae5722436 100644
--- a/drivers/char/rio/cmdpkt.h
+++ b/drivers/char/rio/cmdpkt.h
@@ -55,24 +55,24 @@ static char *_cmdpkt_h_sccs_ = "@(#)cmdpkt.h 1.2";
55** at Data[2] in the actual pkt! 55** at Data[2] in the actual pkt!
56*/ 56*/
57struct BootSequence { 57struct BootSequence {
58 WORD NumPackets; 58 u16 NumPackets;
59 WORD LoadBase; 59 u16 LoadBase;
60 WORD CodeSize; 60 u16 CodeSize;
61}; 61};
62 62
63#define BOOT_SEQUENCE_LEN 8 63#define BOOT_SEQUENCE_LEN 8
64 64
65struct SamTop { 65struct SamTop {
66 BYTE Unit; 66 u8 Unit;
67 BYTE Link; 67 u8 Link;
68}; 68};
69 69
70struct CmdHdr { 70struct CmdHdr {
71 BYTE PcCommand; 71 u8 PcCommand;
72 union { 72 union {
73 BYTE PcPhbNum; 73 u8 PcPhbNum;
74 BYTE PcLinkNum; 74 u8 PcLinkNum;
75 BYTE PcIDNum; 75 u8 PcIDNum;
76 } U0; 76 } U0;
77}; 77};
78 78
@@ -84,28 +84,28 @@ struct PktCmd {
84 struct BootSequence PcBootSequence; 84 struct BootSequence PcBootSequence;
85 } S1; 85 } S1;
86 struct { 86 struct {
87 WORD PcSequence; 87 u16 PcSequence;
88 BYTE PcBootData[RTA_BOOT_DATA_SIZE]; 88 u8 PcBootData[RTA_BOOT_DATA_SIZE];
89 } S2; 89 } S2;
90 struct { 90 struct {
91 WORD __crud__; 91 u16 __crud__;
92 BYTE PcUniqNum[4]; /* this is really a uint. */ 92 u8 PcUniqNum[4]; /* this is really a uint. */
93 BYTE PcModuleTypes; /* what modules are fitted */ 93 u8 PcModuleTypes; /* what modules are fitted */
94 } S3; 94 } S3;
95 struct { 95 struct {
96 struct CmdHdr CmdHdr; 96 struct CmdHdr CmdHdr;
97 BYTE __undefined__; 97 u8 __undefined__;
98 BYTE PcModemStatus; 98 u8 PcModemStatus;
99 BYTE PcPortStatus; 99 u8 PcPortStatus;
100 BYTE PcSubCommand; /* commands like mem or register dump */ 100 u8 PcSubCommand; /* commands like mem or register dump */
101 WORD PcSubAddr; /* Address for command */ 101 u16 PcSubAddr; /* Address for command */
102 BYTE PcSubData[64]; /* Date area for command */ 102 u8 PcSubData[64]; /* Date area for command */
103 } S4; 103 } S4;
104 struct { 104 struct {
105 struct CmdHdr CmdHdr; 105 struct CmdHdr CmdHdr;
106 BYTE PcCommandText[1]; 106 u8 PcCommandText[1];
107 BYTE __crud__[20]; 107 u8 __crud__[20];
108 BYTE PcIDNum2; /* It had to go somewhere! */ 108 u8 PcIDNum2; /* It had to go somewhere! */
109 } S5; 109 } S5;
110 struct { 110 struct {
111 struct CmdHdr CmdHdr; 111 struct CmdHdr CmdHdr;
@@ -118,45 +118,45 @@ struct PktCmd_M {
118 union { 118 union {
119 struct { 119 struct {
120 struct { 120 struct {
121 uchar PcCommand; 121 u8 PcCommand;
122 union { 122 union {
123 uchar PcPhbNum; 123 u8 PcPhbNum;
124 uchar PcLinkNum; 124 u8 PcLinkNum;
125 uchar PcIDNum; 125 u8 PcIDNum;
126 } U0; 126 } U0;
127 } CmdHdr; 127 } CmdHdr;
128 struct { 128 struct {
129 ushort NumPackets; 129 u16 NumPackets;
130 ushort LoadBase; 130 u16 LoadBase;
131 ushort CodeSize; 131 u16 CodeSize;
132 } PcBootSequence; 132 } PcBootSequence;
133 } S1; 133 } S1;
134 struct { 134 struct {
135 ushort PcSequence; 135 u16 PcSequence;
136 uchar PcBootData[RTA_BOOT_DATA_SIZE]; 136 u8 PcBootData[RTA_BOOT_DATA_SIZE];
137 } S2; 137 } S2;
138 struct { 138 struct {
139 ushort __crud__; 139 u16 __crud__;
140 uchar PcUniqNum[4]; /* this is really a uint. */ 140 u8 PcUniqNum[4]; /* this is really a uint. */
141 uchar PcModuleTypes; /* what modules are fitted */ 141 u8 PcModuleTypes; /* what modules are fitted */
142 } S3; 142 } S3;
143 struct { 143 struct {
144 ushort __cmd_hdr__; 144 u16 __cmd_hdr__;
145 uchar __undefined__; 145 u8 __undefined__;
146 uchar PcModemStatus; 146 u8 PcModemStatus;
147 uchar PcPortStatus; 147 u8 PcPortStatus;
148 uchar PcSubCommand; 148 u8 PcSubCommand;
149 ushort PcSubAddr; 149 u16 PcSubAddr;
150 uchar PcSubData[64]; 150 u8 PcSubData[64];
151 } S4; 151 } S4;
152 struct { 152 struct {
153 ushort __cmd_hdr__; 153 u16 __cmd_hdr__;
154 uchar PcCommandText[1]; 154 u8 PcCommandText[1];
155 uchar __crud__[20]; 155 u8 __crud__[20];
156 uchar PcIDNum2; /* Tacked on end */ 156 u8 PcIDNum2; /* Tacked on end */
157 } S5; 157 } S5;
158 struct { 158 struct {
159 ushort __cmd_hdr__; 159 u16 __cmd_hdr__;
160 struct Top Topology[LINKS_PER_UNIT]; 160 struct Top Topology[LINKS_PER_UNIT];
161 } S6; 161 } S6;
162 } U1; 162 } U1;
diff --git a/drivers/char/rio/control.h b/drivers/char/rio/control.h
deleted file mode 100644
index 6853d03304a3..000000000000
--- a/drivers/char/rio/control.h
+++ /dev/null
@@ -1,61 +0,0 @@
1
2
3/****************************************************************************
4 ******* *******
5 ******* C O N T R O L P A C K E T H E A D E R S
6 ******* *******
7 ****************************************************************************
8
9 Author : Jon Brawn
10 Date :
11
12 *
13 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
29 Version : 0.01
30
31
32 Mods
33 ----------------------------------------------------------------------------
34 Date By Description
35 ----------------------------------------------------------------------------
36
37 ***************************************************************************/
38
39
40#ifndef _control_h
41#define _control_h
42
43#ifndef lint
44/* static char *_rio_control_h_sccs = "@(#)control.h 1.4"; */
45#endif
46
47#define CONTROL '^'
48#define IFOAD ( CONTROL + 1 )
49#define IDENTIFY ( CONTROL + 2 )
50#define ZOMBIE ( CONTROL + 3 )
51#define UFOAD ( CONTROL + 4 )
52#define IWAIT ( CONTROL + 5 )
53
54#define IFOAD_MAGIC 0xF0AD /* of course */
55#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
56#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
57#define IWAIT_MAGIC 0xB1DE /* Bide your time */
58
59#endif
60
61/*********** end of file ***********/
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 28a991bd4fe6..5818a8aa46e0 100644
--- a/drivers/char/rio/daemon.h
+++ b/drivers/char/rio/daemon.h
@@ -45,15 +45,15 @@ static char *_daemon_h_sccs_ = "@(#)daemon.h 1.3";
45*/ 45*/
46 46
47struct Error { 47struct Error {
48 uint Error; 48 unsigned int Error;
49 uint Entry; 49 unsigned int Entry;
50 uint Other; 50 unsigned int Other;
51}; 51};
52 52
53struct DownLoad { 53struct DownLoad {
54 char *DataP; 54 char *DataP;
55 uint Count; 55 unsigned int Count;
56 uint ProductCode; 56 unsigned int ProductCode;
57}; 57};
58 58
59/* 59/*
@@ -68,69 +68,64 @@ struct DownLoad {
68#endif 68#endif
69 69
70struct PortSetup { 70struct PortSetup {
71 uint From; /* Set/Clear XP & IXANY Control from this port.... */ 71 unsigned int From; /* Set/Clear XP & IXANY Control from this port.... */
72 uint To; /* .... to this port */ 72 unsigned int To; /* .... to this port */
73 uint XpCps; /* at this speed */ 73 unsigned int XpCps; /* at this speed */
74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */ 74 char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */
75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */ 75 char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */
76 uchar IxAny; /* enable/disable IXANY */ 76 u8 IxAny; /* enable/disable IXANY */
77 uchar IxOn; /* enable/disable IXON */ 77 u8 IxOn; /* enable/disable IXON */
78 uchar Lock; /* lock port params */ 78 u8 Lock; /* lock port params */
79 uchar Store; /* store params across closes */ 79 u8 Store; /* store params across closes */
80 uchar Drain; /* close only when drained */ 80 u8 Drain; /* close only when drained */
81}; 81};
82 82
83struct LpbReq { 83struct LpbReq {
84 uint Host; 84 unsigned int Host;
85 uint Link; 85 unsigned int Link;
86 struct LPB *LpbP; 86 struct LPB *LpbP;
87}; 87};
88 88
89struct RupReq { 89struct RupReq {
90 uint HostNum; 90 unsigned int HostNum;
91 uint RupNum; 91 unsigned int RupNum;
92 struct RUP *RupP; 92 struct RUP *RupP;
93}; 93};
94 94
95struct PortReq { 95struct PortReq {
96 uint SysPort; 96 unsigned int SysPort;
97 struct Port *PortP; 97 struct Port *PortP;
98}; 98};
99 99
100struct StreamInfo { 100struct StreamInfo {
101 uint SysPort; 101 unsigned int SysPort;
102#if 0
103 queue_t RQueue;
104 queue_t WQueue;
105#else
106 int RQueue; 102 int RQueue;
107 int WQueue; 103 int WQueue;
108#endif
109}; 104};
110 105
111struct HostReq { 106struct HostReq {
112 uint HostNum; 107 unsigned int HostNum;
113 struct Host *HostP; 108 struct Host *HostP;
114}; 109};
115 110
116struct HostDpRam { 111struct HostDpRam {
117 uint HostNum; 112 unsigned int HostNum;
118 struct DpRam *DpRamP; 113 struct DpRam *DpRamP;
119}; 114};
120 115
121struct DebugCtrl { 116struct DebugCtrl {
122 uint SysPort; 117 unsigned int SysPort;
123 uint Debug; 118 unsigned int Debug;
124 uint Wait; 119 unsigned int Wait;
125}; 120};
126 121
127struct MapInfo { 122struct MapInfo {
128 uint FirstPort; /* 8 ports, starting from this (tty) number */ 123 unsigned int FirstPort; /* 8 ports, starting from this (tty) number */
129 uint RtaUnique; /* reside on this RTA (unique number) */ 124 unsigned int RtaUnique; /* reside on this RTA (unique number) */
130}; 125};
131 126
132struct MapIn { 127struct MapIn {
133 uint NumEntries; /* How many port sets are we mapping? */ 128 unsigned int NumEntries; /* How many port sets are we mapping? */
134 struct MapInfo *MapInfoP; /* Pointer to (user space) info */ 129 struct MapInfo *MapInfoP; /* Pointer to (user space) info */
135}; 130};
136 131
@@ -147,13 +142,13 @@ struct SpecialRupCmd {
147}; 142};
148 143
149struct IdentifyRta { 144struct IdentifyRta {
150 ulong RtaUnique; 145 unsigned long RtaUnique;
151 uchar ID; 146 u8 ID;
152}; 147};
153 148
154struct KillNeighbour { 149struct KillNeighbour {
155 ulong UniqueNum; 150 unsigned long UniqueNum;
156 uchar Link; 151 u8 Link;
157}; 152};
158 153
159struct rioVersion { 154struct rioVersion {
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
deleted file mode 100644
index d55c2f6a9877..000000000000
--- a/drivers/char/rio/defaults.h
+++ /dev/null
@@ -1,51 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* D E F A U L T S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39#ifdef SCCS
40static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
41#endif
42#endif
43
44
45#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
46#define SECOND (int) 15625 /* Low priority ticks */
47
48#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
49
50
51/*********** end of file ***********/
diff --git a/drivers/char/rio/error.h b/drivers/char/rio/error.h
deleted file mode 100644
index f20f0789db8f..000000000000
--- a/drivers/char/rio/error.h
+++ /dev/null
@@ -1,82 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* E R R O R H E A D E R F I L E
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef lint
39/* static char *_rio_error_h_sccs = "@(#)error.h 1.3"; */
40#endif
41
42#define E_NO_ERROR ((ushort) 0)
43#define E_PROCESS_NOT_INIT ((ushort) 1)
44#define E_LINK_TIMEOUT ((ushort) 2)
45#define E_NO_ROUTE ((ushort) 3)
46#define E_CONFUSED ((ushort) 4)
47#define E_HOME ((ushort) 5)
48#define E_CSUM_FAIL ((ushort) 6)
49#define E_DISCONNECTED ((ushort) 7)
50#define E_BAD_RUP ((ushort) 8)
51#define E_NO_VIRGIN ((ushort) 9)
52#define E_BOOT_RUP_BUSY ((ushort) 10)
53
54
55
56 /*************************************************
57 * Parsed to mem_halt()
58 ************************************************/
59#define E_CHANALLOC ((ushort) 0x80)
60#define E_POLL_ALLOC ((ushort) 0x81)
61#define E_LTTWAKE ((ushort) 0x82)
62#define E_LTT_ALLOC ((ushort) 0x83)
63#define E_LRT_ALLOC ((ushort) 0x84)
64#define E_CIRRUS ((ushort) 0x85)
65#define E_MONITOR ((ushort) 0x86)
66#define E_PHB_ALLOC ((ushort) 0x87)
67#define E_ARRAY_ALLOC ((ushort) 0x88)
68#define E_QBUF_ALLOC ((ushort) 0x89)
69#define E_PKT_ALLOC ((ushort) 0x8a)
70#define E_GET_TX_Q_BUF ((ushort) 0x8b)
71#define E_GET_RX_Q_BUF ((ushort) 0x8c)
72#define E_MEM_OUT ((ushort) 0x8d)
73#define E_MMU_INIT ((ushort) 0x8e)
74#define E_LTT_INIT ((ushort) 0x8f)
75#define E_LRT_INIT ((ushort) 0x90)
76#define E_LINK_RUN ((ushort) 0x91)
77#define E_MONITOR_ALLOC ((ushort) 0x92)
78#define E_MONITOR_INIT ((ushort) 0x93)
79#define E_POLL_INIT ((ushort) 0x94)
80
81
82/*********** end of file ***********/
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index b4778410ec6e..e64fe9912394 100644
--- a/drivers/char/rio/func.h
+++ b/drivers/char/rio/func.h
@@ -43,35 +43,33 @@ static char *_func_h_sccs_ = "@(#)func.h 1.3";
43 43
44/* rioboot.c */ 44/* rioboot.c */
45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *); 45int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
46int RIOBootCodeHOST(struct rio_info *, register 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 *, uint, struct Host *, struct PKT *); 49int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
50int RIOBootOk(struct rio_info *, struct Host *, ulong); 50int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
51int RIORtaBound(struct rio_info *, uint); 51int RIORtaBound(struct rio_info *, unsigned int);
52void FillSlot(int, int, uint, struct Host *); 52void rio_fill_host_slot(int, int, unsigned int, struct Host *);
53 53
54/* riocmd.c */ 54/* riocmd.c */
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 *, uint, int (*func) (struct Host *, struct Map *)); 57int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
58int RIOIdentifyRta(struct rio_info *, caddr_t); 58int RIOIdentifyRta(struct rio_info *, void *);
59int RIOKillNeighbour(struct rio_info *, caddr_t); 59int RIOKillNeighbour(struct rio_info *, void *);
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);
63void RIOFreeCmdBlk(struct CmdBlk *); 63void RIOFreeCmdBlk(struct CmdBlk *);
64int RIOQueueCmdBlk(struct Host *, uint, struct CmdBlk *); 64int RIOQueueCmdBlk(struct Host *, unsigned int, struct CmdBlk *);
65void RIOPollHostCommands(struct rio_info *, struct Host *); 65void RIOPollHostCommands(struct rio_info *, struct Host *);
66int RIOWFlushMark(int, struct CmdBlk *); 66int RIOWFlushMark(unsigned long, struct CmdBlk *);
67int RIORFlushEnable(int, struct CmdBlk *); 67int RIORFlushEnable(unsigned long, struct CmdBlk *);
68int RIOUnUse(int, struct CmdBlk *); 68int RIOUnUse(unsigned long, struct CmdBlk *);
69void ShowPacket(uint, struct PKT *);
70 69
71/* rioctrl.c */ 70/* rioctrl.c */
72int copyin(int, caddr_t, int);
73int riocontrol(struct rio_info *, dev_t, int, caddr_t, int); 71int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
74int RIOPreemptiveCmd(struct rio_info *, struct Port *, uchar); 72int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);
75 73
76/* rioinit.c */ 74/* rioinit.c */
77void rioinit(struct rio_info *, struct RioHostInfo *); 75void rioinit(struct rio_info *, struct RioHostInfo *);
@@ -80,19 +78,17 @@ void RIOISAinit(struct rio_info *, int);
80int RIODoAT(struct rio_info *, int, int); 78int RIODoAT(struct rio_info *, int, int);
81caddr_t RIOCheckForATCard(int); 79caddr_t RIOCheckForATCard(int);
82int RIOAssignAT(struct rio_info *, int, caddr_t, int); 80int RIOAssignAT(struct rio_info *, int, caddr_t, int);
83int RIOBoardTest(paddr_t, caddr_t, uchar, int); 81int RIOBoardTest(unsigned long, caddr_t, unsigned char, int);
84void RIOAllocDataStructs(struct rio_info *); 82void RIOAllocDataStructs(struct rio_info *);
85void RIOSetupDataStructs(struct rio_info *); 83void RIOSetupDataStructs(struct rio_info *);
86int RIODefaultName(struct rio_info *, struct Host *, uint); 84int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
87struct rioVersion *RIOVersid(void); 85struct rioVersion *RIOVersid(void);
88int RIOMapin(paddr_t, int, caddr_t *); 86void RIOHostReset(unsigned int, struct DpRam *, unsigned int);
89void RIOMapout(paddr_t, long, caddr_t);
90void RIOHostReset(uint, volatile struct DpRam *, uint);
91 87
92/* riointr.c */ 88/* riointr.c */
93void RIOTxEnable(char *); 89void RIOTxEnable(char *);
94void RIOServiceHost(struct rio_info *, struct Host *, int); 90void RIOServiceHost(struct rio_info *, struct Host *, int);
95int riotproc(struct rio_info *, register struct ttystatics *, int, int); 91int riotproc(struct rio_info *, struct ttystatics *, int, int);
96 92
97/* rioparam.c */ 93/* rioparam.c */
98int RIOParam(struct Port *, int, int, int); 94int RIOParam(struct Port *, int, int, int);
@@ -106,18 +102,18 @@ int can_remove_receive(struct PKT **, struct Port *);
106void remove_receive(struct Port *); 102void remove_receive(struct Port *);
107 103
108/* rioroute.c */ 104/* rioroute.c */
109int RIORouteRup(struct rio_info *, uint, struct Host *, struct PKT *); 105int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
110void RIOFixPhbs(struct rio_info *, struct Host *, uint); 106void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
111uint GetUnitType(uint); 107unsigned int GetUnitType(unsigned int);
112int RIOSetChange(struct rio_info *); 108int RIOSetChange(struct rio_info *);
113int RIOFindFreeID(struct rio_info *, struct Host *, uint *, uint *); 109int RIOFindFreeID(struct rio_info *, struct Host *, unsigned int *, unsigned int *);
114 110
115 111
116/* riotty.c */ 112/* riotty.c */
117 113
118int riotopen(struct tty_struct *tty, struct file *filp); 114int riotopen(struct tty_struct *tty, struct file *filp);
119int riotclose(void *ptr); 115int riotclose(void *ptr);
120int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t); 116int riotioctl(struct rio_info *, struct tty_struct *, int, caddr_t);
121void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg); 117void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
122 118
123/* riotable.c */ 119/* riotable.c */
@@ -131,7 +127,7 @@ int RIOChangeName(struct rio_info *, struct Map *);
131#if 0 127#if 0
132/* riodrvr.c */ 128/* riodrvr.c */
133struct rio_info *rio_install(struct RioHostInfo *); 129struct rio_info *rio_install(struct RioHostInfo *);
134int rio_uninstall(register struct rio_info *); 130int rio_uninstall(struct rio_info *);
135int rio_open(struct rio_info *, int, struct file *); 131int rio_open(struct rio_info *, int, struct file *);
136int rio_close(struct rio_info *, struct file *); 132int rio_close(struct rio_info *, struct file *);
137int rio_read(struct rio_info *, struct file *, char *, int); 133int rio_read(struct rio_info *, struct file *, char *, int);
@@ -143,7 +139,7 @@ int rio_isr_thread(char *);
143struct rio_info *rio_info_store(int cmd, struct rio_info *p); 139struct rio_info *rio_info_store(int cmd, struct rio_info *p);
144#endif 140#endif
145 141
146extern int rio_pcicopy(char *src, char *dst, int n); 142extern void rio_copy_to_card(void *to, void *from, int len);
147extern int rio_minor(struct tty_struct *tty); 143extern int rio_minor(struct tty_struct *tty);
148extern int rio_ismodem(struct tty_struct *tty); 144extern int rio_ismodem(struct tty_struct *tty);
149 145
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index f7dfcedf7d45..3ec73d1a279a 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -50,22 +50,20 @@ static char *_host_h_sccs_ = "@(#)host.h 1.2";
50** the host. 50** the host.
51*/ 51*/
52struct Host { 52struct Host {
53 uchar Type; /* RIO_EISA, RIO_MCA, ... */ 53 unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
54 uchar Ivec; /* POLLED or ivec number */ 54 unsigned char Ivec; /* POLLED or ivec number */
55 uchar Mode; /* Control stuff */ 55 unsigned char Mode; /* Control stuff */
56 uchar Slot; /* Slot */ 56 unsigned char Slot; /* Slot */
57 volatile caddr_t Caddr; /* KV address of DPRAM */ 57 caddr_t Caddr; /* KV address of DPRAM */
58 volatile struct DpRam *CardP; /* KV address of DPRAM, with overlay */ 58 struct DpRam *CardP; /* KV address of DPRAM, with overlay */
59 paddr_t PaddrP; /* Phys. address of DPRAM */ 59 unsigned long PaddrP; /* Phys. address of DPRAM */
60 char Name[MAX_NAME_LEN]; /* The name of the host */ 60 char Name[MAX_NAME_LEN]; /* The name of the host */
61 uint UniqueNum; /* host unique number */ 61 unsigned int UniqueNum; /* host unique number */
62 spinlock_t HostLock; /* Lock structure for MPX */ 62 spinlock_t HostLock; /* Lock structure for MPX */
63 /*struct pci_devinfo PciDevInfo; *//* PCI Bus/Device/Function stuff */ 63 unsigned int WorkToBeDone; /* set to true each interrupt */
64 /*struct lockb HostLock; *//* Lock structure for MPX */ 64 unsigned int InIntr; /* Being serviced? */
65 uint WorkToBeDone; /* set to true each interrupt */ 65 unsigned int IntSrvDone; /* host's interrupt has been serviced */
66 uint InIntr; /* Being serviced? */ 66 void (*Copy) (void *, void *, int); /* copy func */
67 uint IntSrvDone; /* host's interrupt has been serviced */
68 int (*Copy) (caddr_t, caddr_t, int); /* copy func */
69 struct timer_list timer; 67 struct timer_list timer;
70 /* 68 /*
71 ** I M P O R T A N T ! 69 ** I M P O R T A N T !
@@ -74,7 +72,7 @@ struct Host {
74 ** a RIO_HOST_FOAD command. 72 ** a RIO_HOST_FOAD command.
75 */ 73 */
76 74
77 ulong Flags; /* Whats going down */ 75 unsigned long Flags; /* Whats going down */
78#define RC_WAITING 0 76#define RC_WAITING 0
79#define RC_STARTUP 1 77#define RC_STARTUP 1
80#define RC_RUNNING 2 78#define RC_RUNNING 2
@@ -88,28 +86,28 @@ struct Host {
88** Boot mode applies to the way in which hosts in this system will 86** Boot mode applies to the way in which hosts in this system will
89** boot RTAs 87** boot RTAs
90*/ 88*/
91#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */ 89#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */
92#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */ 90#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */
93#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */ 91#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */
94 92
95 struct Top Topology[LINKS_PER_UNIT]; /* one per link */ 93 struct Top Topology[LINKS_PER_UNIT]; /* one per link */
96 struct Map Mapping[MAX_RUP]; /* Mappings for host */ 94 struct Map Mapping[MAX_RUP]; /* Mappings for host */
97 struct PHB *PhbP; /* Pointer to the PHB array */ 95 struct PHB *PhbP; /* Pointer to the PHB array */
98 ushort *PhbNumP; /* Ptr to Number of PHB's */ 96 unsigned short *PhbNumP; /* Ptr to Number of PHB's */
99 struct LPB *LinkStrP; /* Link Structure Array */ 97 struct LPB *LinkStrP; /* Link Structure Array */
100 struct RUP *RupP; /* Sixteen real rups here */ 98 struct RUP *RupP; /* Sixteen real rups here */
101 struct PARM_MAP *ParmMapP; /* points to the parmmap */ 99 struct PARM_MAP *ParmMapP; /* points to the parmmap */
102 uint ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */ 100 unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
103 uint NumExtraBooted; /* how many of the above */ 101 unsigned int NumExtraBooted; /* how many of the above */
104 /* 102 /*
105 ** Twenty logical rups. 103 ** Twenty logical rups.
106 ** The first sixteen are the real Rup entries (above), the last four 104 ** The first sixteen are the real Rup entries (above), the last four
107 ** are the link RUPs. 105 ** are the link RUPs.
108 */ 106 */
109 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT]; 107 struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT];
110 int timeout_id; /* For calling 100 ms delays */ 108 int timeout_id; /* For calling 100 ms delays */
111 int timeout_sem; /* For calling 100 ms delays */ 109 int timeout_sem; /* For calling 100 ms delays */
112 long locks; /* long req'd for set_bit --RR */ 110 long locks; /* long req'd for set_bit --RR */
113 char ____end_marker____; 111 char ____end_marker____;
114}; 112};
115#define Control CardP->DpControl 113#define Control CardP->DpControl
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index 48d68ca7f825..f3bf11a04d41 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -37,38 +37,9 @@
37#ifndef _link_h 37#ifndef _link_h
38#define _link_h 1 38#define _link_h 1
39 39
40#ifndef lint
41#ifdef SCCS_LABELS
42/* static char *_rio_link_h_sccs = "@(#)link.h 1.15"; */
43#endif
44#endif
45
46
47
48/************************************************* 40/*************************************************
49 * Define the Link Status stuff 41 * Define the Link Status stuff
50 ************************************************/ 42 ************************************************/
51#define LRT_ACTIVE ((ushort) 0x01)
52#define LRT_SPARE1 ((ushort) 0x02)
53#define INTRO_RCVD ((ushort) 0x04)
54#define FORCED_DISCONNECT ((ushort) 0x08)
55#define LRT_SPARE2 ((ushort) 0x80)
56
57#define TOP_OF_RTA_RAM ((ushort) 0x7000)
58#define HOST_SERIAL_POINTER (unsigned char **) (TOP_OF_RTA_RAM - 2 * sizeof (ushort))
59
60/* Flags for ltt_status */
61#define WAITING_ACK (ushort) 0x0001
62#define DATA_SENT (ushort) 0x0002
63#define WAITING_RUP (ushort) 0x0004
64#define WAITING_RETRY (ushort) 0x0008
65#define WAITING_TOPOLOGY (ushort) 0x0010
66#define SEND_SYNC (ushort) 0x0020
67#define FOAD_THIS_LINK (ushort) 0x0040
68#define REQUEST_SYNC (ushort) 0x0080
69#define REMOTE_DYING (ushort) 0x0100
70#define DIE_NOW (ushort) 0x0200
71
72/* Boot request stuff */ 43/* Boot request stuff */
73#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */ 44#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */
74#define BOOT_ABORT ((ushort) 1) /* Abort a boot */ 45#define BOOT_ABORT ((ushort) 1) /* Abort a boot */
@@ -76,77 +47,48 @@
76 and load address */ 47 and load address */
77#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */ 48#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */
78 49
79/* States that a link can be in */
80#define LINK_DISCONNECTED ((ushort) 0) /* Disconnected */
81#define LINK_BOOT1 ((ushort) 1) /* Trying to send 1st stage boot */
82#define LINK_BOOT2 ((ushort) 2) /* Trying to send 2nd stage boot */
83#define LINK_BOOT2WAIT ((ushort) 3) /* Waiting for selftest results */
84#define LINK_BOOT3 ((ushort) 4) /* Trying to send 3rd stage boots */
85#define LINK_SYNC ((ushort) 5) /* Syncing */
86
87#define LINK_INTRO ((ushort) 10) /* Introductory packet */
88#define LINK_SUPPLYID ((ushort) 11) /* Trying to supply an ID */
89#define LINK_TOPOLOGY ((ushort) 12) /* Send a topology update */
90#define LINK_REQUESTID ((ushort) 13) /* Waiting for an ID */
91#define LINK_CONNECTED ((ushort) 14) /* Connected */
92
93#define LINK_INTERCONNECT ((ushort) 20) /* Subnets interconnected */
94
95#define LINK_SPARE ((ushort) 40)
96
97/*
98** Set the default timeout for link communications.
99*/
100#define LINKTIMEOUT (400 * MILLISECOND)
101
102/*
103** LED stuff
104*/
105#define LED_SET_COLOUR(colour)
106#define LED_OR_COLOUR(colour)
107#define LED_TIMEOUT(time)
108 50
109struct LPB { 51struct LPB {
110 WORD link_number; /* Link Number */ 52 u16 link_number; /* Link Number */
111 Channel_ptr in_ch; /* Link In Channel */ 53 u16 in_ch; /* Link In Channel */
112 Channel_ptr out_ch; /* Link Out Channel */ 54 u16 out_ch; /* Link Out Channel */
113 BYTE attached_serial[4]; /* Attached serial number */ 55 u8 attached_serial[4]; /* Attached serial number */
114 BYTE attached_host_serial[4]; 56 u8 attached_host_serial[4];
115 /* Serial number of Host who 57 /* Serial number of Host who
116 booted the other end */ 58 booted the other end */
117 WORD descheduled; /* Currently Descheduled */ 59 u16 descheduled; /* Currently Descheduled */
118 WORD state; /* Current state */ 60 u16 state; /* Current state */
119 WORD send_poll; /* Send a Poll Packet */ 61 u16 send_poll; /* Send a Poll Packet */
120 Process_ptr ltt_p; /* Process Descriptor */ 62 u16 ltt_p; /* Process Descriptor */
121 Process_ptr lrt_p; /* Process Descriptor */ 63 u16 lrt_p; /* Process Descriptor */
122 WORD lrt_status; /* Current lrt status */ 64 u16 lrt_status; /* Current lrt status */
123 WORD ltt_status; /* Current ltt status */ 65 u16 ltt_status; /* Current ltt status */
124 WORD timeout; /* Timeout value */ 66 u16 timeout; /* Timeout value */
125 WORD topology; /* Topology bits */ 67 u16 topology; /* Topology bits */
126 WORD mon_ltt; 68 u16 mon_ltt;
127 WORD mon_lrt; 69 u16 mon_lrt;
128 WORD WaitNoBoot; /* Secs to hold off booting */ 70 u16 WaitNoBoot; /* Secs to hold off booting */
129 PKT_ptr add_packet_list; /* Add packets to here */ 71 u16 add_packet_list; /* Add packets to here */
130 PKT_ptr remove_packet_list; /* Send packets from here */ 72 u16 remove_packet_list; /* Send packets from here */
131 73
132 Channel_ptr lrt_fail_chan; /* Lrt's failure channel */ 74 u16 lrt_fail_chan; /* Lrt's failure channel */
133 Channel_ptr ltt_fail_chan; /* Ltt's failure channel */ 75 u16 ltt_fail_chan; /* Ltt's failure channel */
134 76
135 /* RUP structure for HOST to driver communications */ 77 /* RUP structure for HOST to driver communications */
136 struct RUP rup; 78 struct RUP rup;
137 struct RUP link_rup; /* RUP for the link (POLL, 79 struct RUP link_rup; /* RUP for the link (POLL,
138 topology etc.) */ 80 topology etc.) */
139 WORD attached_link; /* Number of attached link */ 81 u16 attached_link; /* Number of attached link */
140 WORD csum_errors; /* csum errors */ 82 u16 csum_errors; /* csum errors */
141 WORD num_disconnects; /* number of disconnects */ 83 u16 num_disconnects; /* number of disconnects */
142 WORD num_sync_rcvd; /* # sync's received */ 84 u16 num_sync_rcvd; /* # sync's received */
143 WORD num_sync_rqst; /* # sync requests */ 85 u16 num_sync_rqst; /* # sync requests */
144 WORD num_tx; /* Num pkts sent */ 86 u16 num_tx; /* Num pkts sent */
145 WORD num_rx; /* Num pkts received */ 87 u16 num_rx; /* Num pkts received */
146 WORD module_attached; /* Module tpyes of attached */ 88 u16 module_attached; /* Module tpyes of attached */
147 WORD led_timeout; /* LED timeout */ 89 u16 led_timeout; /* LED timeout */
148 WORD first_port; /* First port to service */ 90 u16 first_port; /* First port to service */
149 WORD last_port; /* Last port to service */ 91 u16 last_port; /* Last port to service */
150}; 92};
151 93
152#endif 94#endif
diff --git a/drivers/char/rio/linux_compat.h b/drivers/char/rio/linux_compat.h
index 17a14c4a3420..34c0d2899ef1 100644
--- a/drivers/char/rio/linux_compat.h
+++ b/drivers/char/rio/linux_compat.h
@@ -19,56 +19,12 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21 21
22#define disable(oldspl) save_flags (oldspl)
23#define restore(oldspl) restore_flags (oldspl)
24
25#define sysbrk(x) kmalloc ((x),in_interrupt()? GFP_ATOMIC : GFP_KERNEL)
26#define sysfree(p,size) kfree ((p))
27
28#define WBYTE(p,v) writeb(v, &p)
29#define RBYTE(p) readb (&p)
30#define WWORD(p,v) writew(v, &p)
31#define RWORD(p) readw(&p)
32#define WINDW(p,v) writew(v, p)
33#define RINDW(p) readw(p)
34
35#define DEBUG_ALL 22#define DEBUG_ALL
36 23
37#define cprintf printk
38
39#ifdef __KERNEL__
40#define INKERNEL
41#endif
42
43struct ttystatics { 24struct ttystatics {
44 struct termios tm; 25 struct termios tm;
45}; 26};
46 27
47#define bzero(d, n) memset((d), 0, (n))
48#define bcopy(src, dest, n) memcpy ((dest), (src), (n))
49
50#define SEM_SIGIGNORE 0x1234
51
52#ifdef DEBUG_SEM
53#define swait(a,b) printk ("waiting: " __FILE__ " line %d\n", __LINE__)
54#define ssignal(sem) printk ("signalling: " __FILE__ " line %d\n", __LINE__)
55
56#define sreset(sem) printk ("sreset: " __FILE__ "\n")
57#define sem_init(sem,v) printk ("sreset: " __FILE__ "\n")
58#endif
59
60
61#define getpid() (current->pid)
62
63#define QSIZE SERIAL_XMIT_SIZE
64
65#define pseterr(errno) return (- errno)
66
67#define V_CBAUD CBAUD
68
69/* For one reason or another rioboot.c uses delay instead of RIODelay. */
70#define delay(x,y) RIODelay(NULL, y)
71
72extern int rio_debug; 28extern int rio_debug;
73 29
74#define RIO_DEBUG_INIT 0x000001 30#define RIO_DEBUG_INIT 0x000001
@@ -91,6 +47,7 @@ extern int rio_debug;
91#define RIO_DEBUG_DELAY 0x020000 47#define RIO_DEBUG_DELAY 0x020000
92#define RIO_DEBUG_MOD_COUNT 0x040000 48#define RIO_DEBUG_MOD_COUNT 0x040000
93 49
50
94/* Copied over from riowinif.h . This is ugly. The winif file declares 51/* Copied over from riowinif.h . This is ugly. The winif file declares
95also much other stuff which is incompatible with the headers from 52also much other stuff which is incompatible with the headers from
96the older driver. The older driver includes "brates.h" which shadows 53the older driver. The older driver includes "brates.h" which shadows
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
deleted file mode 100644
index 79b853140ae5..000000000000
--- a/drivers/char/rio/list.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* L I S T *******
4 ******* *******
5 ****************************************************************************
6
7 Author : Jeremy Rolls.
8 Date : 04-Nov-1990
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34 ***************************************************************************/
35
36#ifndef _list_h
37#define _list_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41static char *_rio_list_h_sccs = "@(#)list.h 1.9";
42#endif
43#endif
44
45#define PKT_IN_USE 0x1
46
47#define ZERO_PTR (ushort) 0x8000
48#define CaD PortP->Caddr
49
50/*
51** We can add another packet to a transmit queue if the packet pointer pointed
52** to by the TxAdd pointer has PKT_IN_USE clear in its address.
53*/
54
55#endif /* ifndef _list.h */
56/*********** end of file ***********/
diff --git a/drivers/char/rio/map.h b/drivers/char/rio/map.h
index 97fe287aab2a..bdbcd09c8b81 100644
--- a/drivers/char/rio/map.h
+++ b/drivers/char/rio/map.h
@@ -47,17 +47,17 @@ static char *_map_h_sccs_ = "@(#)map.h 1.2";
47#define MAX_NAME_LEN 32 47#define MAX_NAME_LEN 32
48 48
49struct Map { 49struct Map {
50 uint HostUniqueNum; /* Supporting hosts unique number */ 50 unsigned int HostUniqueNum; /* Supporting hosts unique number */
51 uint RtaUniqueNum; /* Unique number */ 51 unsigned int RtaUniqueNum; /* Unique number */
52 /* 52 /*
53 ** The next two IDs must be swapped on big-endian architectures 53 ** The next two IDs must be swapped on big-endian architectures
54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when 54 ** when using a v2.04 /etc/rio/config with a v3.00 driver (when
55 ** upgrading for example). 55 ** upgrading for example).
56 */ 56 */
57 ushort ID; /* ID used in the subnet */ 57 unsigned short ID; /* ID used in the subnet */
58 ushort ID2; /* ID of 2nd block of 8 for 16 port */ 58 unsigned short ID2; /* ID of 2nd block of 8 for 16 port */
59 ulong Flags; /* Booted, ID Given, Disconnected */ 59 unsigned long Flags; /* Booted, ID Given, Disconnected */
60 ulong SysPort; /* First tty mapped to this port */ 60 unsigned long SysPort; /* First tty mapped to this port */
61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */ 61 struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */
62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */ 62 char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */
63}; 63};
diff --git a/drivers/char/rio/param.h b/drivers/char/rio/param.h
index de7e57180c91..675c200b2459 100644
--- a/drivers/char/rio/param.h
+++ b/drivers/char/rio/param.h
@@ -43,18 +43,18 @@ static char *_param_h_sccs_ = "@(#)param.h 1.2";
43*/ 43*/
44 44
45struct phb_param { 45struct phb_param {
46 BYTE Cmd; /* It is very important that these line up */ 46 u8 Cmd; /* It is very important that these line up */
47 BYTE Cor1; /* with what is expected at the other end. */ 47 u8 Cor1; /* with what is expected at the other end. */
48 BYTE Cor2; /* to confirm that you've got it right, */ 48 u8 Cor2; /* to confirm that you've got it right, */
49 BYTE Cor4; /* check with cirrus/cirrus.h */ 49 u8 Cor4; /* check with cirrus/cirrus.h */
50 BYTE Cor5; 50 u8 Cor5;
51 BYTE TxXon; /* Transmit X-On character */ 51 u8 TxXon; /* Transmit X-On character */
52 BYTE TxXoff; /* Transmit X-Off character */ 52 u8 TxXoff; /* Transmit X-Off character */
53 BYTE RxXon; /* Receive X-On character */ 53 u8 RxXon; /* Receive X-On character */
54 BYTE RxXoff; /* Receive X-Off character */ 54 u8 RxXoff; /* Receive X-Off character */
55 BYTE LNext; /* Literal-next character */ 55 u8 LNext; /* Literal-next character */
56 BYTE TxBaud; /* Transmit baudrate */ 56 u8 TxBaud; /* Transmit baudrate */
57 BYTE RxBaud; /* Receive baudrate */ 57 u8 RxBaud; /* Receive baudrate */
58}; 58};
59 59
60#endif 60#endif
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index e24acc1d1844..9764ef85c5a6 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -47,40 +47,40 @@
47typedef struct PARM_MAP PARM_MAP; 47typedef struct PARM_MAP PARM_MAP;
48 48
49struct PARM_MAP { 49struct PARM_MAP {
50 PHB_ptr phb_ptr; /* Pointer to the PHB array */ 50 u16 phb_ptr; /* Pointer to the PHB array */
51 WORD_ptr phb_num_ptr; /* Ptr to Number of PHB's */ 51 u16 phb_num_ptr; /* Ptr to Number of PHB's */
52 FREE_LIST_ptr free_list; /* Free List pointer */ 52 u16 free_list; /* Free List pointer */
53 FREE_LIST_ptr free_list_end; /* Free List End pointer */ 53 u16 free_list_end; /* Free List End pointer */
54 Q_BUF_ptr_ptr q_free_list_ptr; /* Ptr to Q_BUF variable */ 54 u16 q_free_list_ptr; /* Ptr to Q_BUF variable */
55 BYTE_ptr unit_id_ptr; /* Unit Id */ 55 u16 unit_id_ptr; /* Unit Id */
56 LPB_ptr link_str_ptr; /* Link Structure Array */ 56 u16 link_str_ptr; /* Link Structure Array */
57 BYTE_ptr bootloader_1; /* 1st Stage Boot Loader */ 57 u16 bootloader_1; /* 1st Stage Boot Loader */
58 BYTE_ptr bootloader_2; /* 2nd Stage Boot Loader */ 58 u16 bootloader_2; /* 2nd Stage Boot Loader */
59 WORD_ptr port_route_map_ptr; /* Port Route Map */ 59 u16 port_route_map_ptr; /* Port Route Map */
60 ROUTE_STR_ptr route_ptr; /* Unit Route Map */ 60 u16 route_ptr; /* Unit Route Map */
61 NUMBER_ptr map_present; /* Route Map present */ 61 u16 map_present; /* Route Map present */
62 NUMBER pkt_num; /* Total number of packets */ 62 s16 pkt_num; /* Total number of packets */
63 NUMBER q_num; /* Total number of Q packets */ 63 s16 q_num; /* Total number of Q packets */
64 WORD buffers_per_port; /* Number of buffers per port */ 64 u16 buffers_per_port; /* Number of buffers per port */
65 WORD heap_size; /* Initial size of heap */ 65 u16 heap_size; /* Initial size of heap */
66 WORD heap_left; /* Current Heap left */ 66 u16 heap_left; /* Current Heap left */
67 WORD error; /* Error code */ 67 u16 error; /* Error code */
68 WORD tx_max; /* Max number of tx pkts per phb */ 68 u16 tx_max; /* Max number of tx pkts per phb */
69 WORD rx_max; /* Max number of rx pkts per phb */ 69 u16 rx_max; /* Max number of rx pkts per phb */
70 WORD rx_limit; /* For high / low watermarks */ 70 u16 rx_limit; /* For high / low watermarks */
71 NUMBER links; /* Links to use */ 71 s16 links; /* Links to use */
72 NUMBER timer; /* Interrupts per second */ 72 s16 timer; /* Interrupts per second */
73 RUP_ptr rups; /* Pointer to the RUPs */ 73 u16 rups; /* Pointer to the RUPs */
74 WORD max_phb; /* Mostly for debugging */ 74 u16 max_phb; /* Mostly for debugging */
75 WORD living; /* Just increments!! */ 75 u16 living; /* Just increments!! */
76 WORD init_done; /* Initialisation over */ 76 u16 init_done; /* Initialisation over */
77 WORD booting_link; 77 u16 booting_link;
78 WORD idle_count; /* Idle time counter */ 78 u16 idle_count; /* Idle time counter */
79 WORD busy_count; /* Busy counter */ 79 u16 busy_count; /* Busy counter */
80 WORD idle_control; /* Control Idle Process */ 80 u16 idle_control; /* Control Idle Process */
81 WORD tx_intr; /* TX interrupt pending */ 81 u16 tx_intr; /* TX interrupt pending */
82 WORD rx_intr; /* RX interrupt pending */ 82 u16 rx_intr; /* RX interrupt pending */
83 WORD rup_intr; /* RUP interrupt pending */ 83 u16 rup_intr; /* RUP interrupt pending */
84}; 84};
85 85
86#endif 86#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 2663ca0306e2..a4c48ae4e365 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -37,13 +37,6 @@
37#ifndef _phb_h 37#ifndef _phb_h
38#define _phb_h 1 38#define _phb_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_phb_h_sccs = "@(#)phb.h 1.12"; */
43#endif
44#endif
45
46
47/************************************************* 40/*************************************************
48 * Handshake asserted. Deasserted by the LTT(s) 41 * Handshake asserted. Deasserted by the LTT(s)
49 ************************************************/ 42 ************************************************/
@@ -124,23 +117,23 @@
124 * the start. The pointer tx_add points to a SPACE to put a Packet. 117 * the start. The pointer tx_add points to a SPACE to put a Packet.
125 * The pointer tx_remove points to the next Packet to remove 118 * The pointer tx_remove points to the next Packet to remove
126 *************************************************************************/ 119 *************************************************************************/
127typedef struct PHB PHB; 120
128struct PHB { 121struct PHB {
129 WORD source; 122 u8 source;
130 WORD handshake; 123 u8 handshake;
131 WORD status; 124 u8 status;
132 NUMBER timeout; /* Maximum of 1.9 seconds */ 125 u16 timeout; /* Maximum of 1.9 seconds */
133 WORD link; /* Send down this link */ 126 u8 link; /* Send down this link */
134 WORD destination; 127 u8 destination;
135 PKT_ptr_ptr tx_start; 128 u16 tx_start;
136 PKT_ptr_ptr tx_end; 129 u16 tx_end;
137 PKT_ptr_ptr tx_add; 130 u16 tx_add;
138 PKT_ptr_ptr tx_remove; 131 u16 tx_remove;
139 132
140 PKT_ptr_ptr rx_start; 133 u16 rx_start;
141 PKT_ptr_ptr rx_end; 134 u16 rx_end;
142 PKT_ptr_ptr rx_add; 135 u16 rx_add;
143 PKT_ptr_ptr rx_remove; 136 u16 rx_remove;
144 137
145}; 138};
146 139
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 7011e52e82db..a9458164f02f 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -37,14 +37,6 @@
37#ifndef _pkt_h 37#ifndef _pkt_h
38#define _pkt_h 1 38#define _pkt_h 1
39 39
40
41#ifdef SCCS_LABELS
42#ifndef lint
43/* static char *_rio_pkt_h_sccs = "@(#)pkt.h 1.8"; */
44#endif
45#endif
46
47#define MAX_TTL 0xf
48#define PKT_CMD_BIT ((ushort) 0x080) 40#define PKT_CMD_BIT ((ushort) 0x080)
49#define PKT_CMD_DATA ((ushort) 0x080) 41#define PKT_CMD_DATA ((ushort) 0x080)
50 42
@@ -70,15 +62,15 @@
70#define CONTROL_DATA_WNDW (DATA_WNDW << 8) 62#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
71 63
72struct PKT { 64struct PKT {
73 BYTE dest_unit; /* Destination Unit Id */ 65 u8 dest_unit; /* Destination Unit Id */
74 BYTE dest_port; /* Destination POrt */ 66 u8 dest_port; /* Destination POrt */
75 BYTE src_unit; /* Source Unit Id */ 67 u8 src_unit; /* Source Unit Id */
76 BYTE src_port; /* Source POrt */ 68 u8 src_port; /* Source POrt */
77 BYTE len; 69 u8 len;
78 BYTE control; 70 u8 control;
79 BYTE data[PKT_MAX_DATA_LEN]; 71 u8 data[PKT_MAX_DATA_LEN];
80 /* Actual data :-) */ 72 /* Actual data :-) */
81 WORD csum; /* C-SUM */ 73 u16 csum; /* C-SUM */
82}; 74};
83#endif 75#endif
84 76
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index c99b1e70fdc8..9b5fa3eb0402 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -33,91 +33,37 @@
33#ifndef __rio_port_h__ 33#ifndef __rio_port_h__
34#define __rio_port_h__ 34#define __rio_port_h__
35 35
36#ifdef SCCS_LABELS
37static char *_port_h_sccs_ = "@(#)port.h 1.3";
38#endif
39
40
41#undef VPIX
42
43
44/*
45** the port data structure - one per port in the system
46*/
47
48#ifdef STATS
49struct RIOStats {
50 /*
51 ** interrupt statistics
52 */
53 uint BreakIntCnt;
54 uint ModemOffCnt;
55 uint ModemOnCnt;
56 uint RxIntCnt;
57 uint TxIntCnt;
58 /*
59 ** throughput statistics
60 */
61 uint RxCharCnt;
62 uint RxPktCnt;
63 uint RxSaveCnt;
64 uint TxCharCnt;
65 uint TxPktCnt;
66 /*
67 ** driver entry statistics
68 */
69 uint CloseCnt;
70 uint IoctlCnt;
71 uint OpenCnt;
72 uint ReadCnt;
73 uint WriteCnt;
74 /*
75 ** proc statistics
76 */
77 uint BlockCnt;
78 uint OutputCnt;
79 uint ResumeCnt;
80 uint RflushCnt;
81 uint SuspendCnt;
82 uint TbreakCnt;
83 uint TimeoutCnt;
84 uint UnblockCnt;
85 uint WflushCnt;
86 uint WFBodgeCnt;
87};
88#endif
89
90/* 36/*
91** Port data structure 37** Port data structure
92*/ 38*/
93struct Port { 39struct Port {
94 struct gs_port gs; 40 struct gs_port gs;
95 int PortNum; /* RIO port no., 0-511 */ 41 int PortNum; /* RIO port no., 0-511 */
96 struct Host *HostP; 42 struct Host *HostP;
97 volatile caddr_t Caddr; 43 caddr_t Caddr;
98 ushort HostPort; /* Port number on host card */ 44 unsigned short HostPort; /* Port number on host card */
99 uchar RupNum; /* Number of RUP for port */ 45 unsigned char RupNum; /* Number of RUP for port */
100 uchar ID2; /* Second ID of RTA for port */ 46 unsigned char ID2; /* Second ID of RTA for port */
101 ulong State; /* FLAGS for open & xopen */ 47 unsigned long State; /* FLAGS for open & xopen */
102#define RIO_LOPEN 0x00001 /* Local open */ 48#define RIO_LOPEN 0x00001 /* Local open */
103#define RIO_MOPEN 0x00002 /* Modem open */ 49#define RIO_MOPEN 0x00002 /* Modem open */
104#define RIO_WOPEN 0x00004 /* Waiting for open */ 50#define RIO_WOPEN 0x00004 /* Waiting for open */
105#define RIO_CLOSING 0x00008 /* The port is being close */ 51#define RIO_CLOSING 0x00008 /* The port is being close */
106#define RIO_XPBUSY 0x00010 /* Transparent printer busy */ 52#define RIO_XPBUSY 0x00010 /* Transparent printer busy */
107#define RIO_BREAKING 0x00020 /* Break in progress */ 53#define RIO_BREAKING 0x00020 /* Break in progress */
108#define RIO_DIRECT 0x00040 /* Doing Direct output */ 54#define RIO_DIRECT 0x00040 /* Doing Direct output */
109#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */ 55#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
110#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */ 56#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
111#define RIO_CARR_ON 0x00200 /* Stream has carrier present */ 57#define RIO_CARR_ON 0x00200 /* Stream has carrier present */
112#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */ 58#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
113#define RIO_RBLK 0x00800 /* Stream is read-blocked */ 59#define RIO_RBLK 0x00800 /* Stream is read-blocked */
114#define RIO_BUSY 0x01000 /* Stream is BUSY for write */ 60#define RIO_BUSY 0x01000 /* Stream is BUSY for write */
115#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */ 61#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
116#define RIO_TXSTOP 0x04000 /* Stream output is stopped */ 62#define RIO_TXSTOP 0x04000 /* Stream output is stopped */
117#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */ 63#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
118#define RIO_DYNOROD 0x10000 /* Drain failed */ 64#define RIO_DYNOROD 0x10000 /* Drain failed */
119#define RIO_DELETED 0x20000 /* RTA has been deleted */ 65#define RIO_DELETED 0x20000 /* RTA has been deleted */
120#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */ 66#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
121#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */ 67#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */
122#define RIO_CAN_COOK 0x200000 /* This line can do cooking */ 68#define RIO_CAN_COOK 0x200000 /* This line can do cooking */
123#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */ 69#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */
@@ -125,15 +71,15 @@ struct Port {
125#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */ 71#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */
126#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */ 72#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */
127 73
128 ulong Config; /* FLAGS for NOREAD.... */ 74 unsigned long Config; /* FLAGS for NOREAD.... */
129#define RIO_NOREAD 0x0001 /* Are not allowed to read port */ 75#define RIO_NOREAD 0x0001 /* Are not allowed to read port */
130#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */ 76#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
131#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */ 77#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
132#define RIO_NOMASK 0x0007 /* All not allowed things */ 78#define RIO_NOMASK 0x0007 /* All not allowed things */
133#define RIO_IXANY 0x0008 /* Port is allowed ixany */ 79#define RIO_IXANY 0x0008 /* Port is allowed ixany */
134#define RIO_MODEM 0x0010 /* Stream is a modem device */ 80#define RIO_MODEM 0x0010 /* Stream is a modem device */
135#define RIO_IXON 0x0020 /* Port is allowed ixon */ 81#define RIO_IXON 0x0020 /* Port is allowed ixon */
136#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */ 82#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
137#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */ 83#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */
138#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */ 84#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */
139 85
@@ -142,36 +88,36 @@ struct Port {
142** As LynxOS does not appear to support Hardware Flow Control ..... 88** As LynxOS does not appear to support Hardware Flow Control .....
143** Define our own flow control flags in 'Config'. 89** Define our own flow control flags in 'Config'.
144*/ 90*/
145#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */ 91#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
146#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */ 92#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
147 93
148 94
149 struct PHB *PhbP; /* pointer to PHB for port */ 95 struct PHB *PhbP; /* pointer to PHB for port */
150 WORD *TxAdd; /* Add packets here */ 96 u16 *TxAdd; /* Add packets here */
151 WORD *TxStart; /* Start of add array */ 97 u16 *TxStart; /* Start of add array */
152 WORD *TxEnd; /* End of add array */ 98 u16 *TxEnd; /* End of add array */
153 WORD *RxRemove; /* Remove packets here */ 99 u16 *RxRemove; /* Remove packets here */
154 WORD *RxStart; /* Start of remove array */ 100 u16 *RxStart; /* Start of remove array */
155 WORD *RxEnd; /* End of remove array */ 101 u16 *RxEnd; /* End of remove array */
156 uint RtaUniqueNum; /* Unique number of RTA */ 102 unsigned int RtaUniqueNum; /* Unique number of RTA */
157 ushort PortState; /* status of port */ 103 unsigned short PortState; /* status of port */
158 ushort ModemState; /* status of modem lines */ 104 unsigned short ModemState; /* status of modem lines */
159 ulong ModemLines; /* Modem bits sent to RTA */ 105 unsigned long ModemLines; /* Modem bits sent to RTA */
160 uchar CookMode; /* who expands CR/LF? */ 106 unsigned char CookMode; /* who expands CR/LF? */
161 uchar ParamSem; /* Prevent write during param */ 107 unsigned char ParamSem; /* Prevent write during param */
162 uchar Mapped; /* if port mapped onto host */ 108 unsigned char Mapped; /* if port mapped onto host */
163 uchar SecondBlock; /* if port belongs to 2nd block 109 unsigned char SecondBlock; /* if port belongs to 2nd block
164 of 16 port RTA */ 110 of 16 port RTA */
165 uchar InUse; /* how many pre-emptive cmds */ 111 unsigned char InUse; /* how many pre-emptive cmds */
166 uchar Lock; /* if params locked */ 112 unsigned char Lock; /* if params locked */
167 uchar Store; /* if params stored across closes */ 113 unsigned char Store; /* if params stored across closes */
168 uchar FirstOpen; /* TRUE if first time port opened */ 114 unsigned char FirstOpen; /* TRUE if first time port opened */
169 uchar FlushCmdBodge; /* if doing a (non)flush */ 115 unsigned char FlushCmdBodge; /* if doing a (non)flush */
170 uchar MagicFlags; /* require intr processing */ 116 unsigned char MagicFlags; /* require intr processing */
171#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */ 117#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
172#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */ 118#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
173#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */ 119#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
174 uchar WflushFlag; /* 1 How many WFLUSHs active */ 120 unsigned char WflushFlag; /* 1 How many WFLUSHs active */
175/* 121/*
176** Transparent print stuff 122** Transparent print stuff
177*/ 123*/
@@ -179,63 +125,55 @@ struct Port {
179#ifndef MAX_XP_CTRL_LEN 125#ifndef MAX_XP_CTRL_LEN
180#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */ 126#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */
181#endif 127#endif
182 uint XpCps; 128 unsigned int XpCps;
183 char XpOn[MAX_XP_CTRL_LEN]; 129 char XpOn[MAX_XP_CTRL_LEN];
184 char XpOff[MAX_XP_CTRL_LEN]; 130 char XpOff[MAX_XP_CTRL_LEN];
185 ushort XpLen; /* strlen(XpOn)+strlen(XpOff) */ 131 unsigned short XpLen; /* strlen(XpOn)+strlen(XpOff) */
186 uchar XpActive; 132 unsigned char XpActive;
187 uchar XpLastTickOk; /* TRUE if we can process */ 133 unsigned char XpLastTickOk; /* TRUE if we can process */
188#define XP_OPEN 00001 134#define XP_OPEN 00001
189#define XP_RUNABLE 00002 135#define XP_RUNABLE 00002
190 struct ttystatics *XttyP; 136 struct ttystatics *XttyP;
191 } Xprint; 137 } Xprint;
192#ifdef VPIX 138 unsigned char RxDataStart;
193 v86_t *StashP; 139 unsigned char Cor2Copy; /* copy of COR2 */
194 uint IntMask; 140 char *Name; /* points to the Rta's name */
195 struct termss VpixSs;
196 uchar ModemStatusReg; /* Modem status register */
197#endif
198 uchar RxDataStart;
199 uchar Cor2Copy; /* copy of COR2 */
200 char *Name; /* points to the Rta's name */
201#ifdef STATS
202 struct RIOStats Stat; /* ports statistics */
203#endif
204 char *TxRingBuffer; 141 char *TxRingBuffer;
205 ushort TxBufferIn; /* New data arrives here */ 142 unsigned short TxBufferIn; /* New data arrives here */
206 ushort TxBufferOut; /* Intr removes data here */ 143 unsigned short TxBufferOut; /* Intr removes data here */
207 ushort OldTxBufferOut; /* Indicates if draining */ 144 unsigned short OldTxBufferOut; /* Indicates if draining */
208 int TimeoutId; /* Timeout ID */ 145 int TimeoutId; /* Timeout ID */
209 uint Debug; 146 unsigned int Debug;
210 uchar WaitUntilBooted; /* True if open should block */ 147 unsigned char WaitUntilBooted; /* True if open should block */
211 uint statsGather; /* True if gathering stats */ 148 unsigned int statsGather; /* True if gathering stats */
212 ulong txchars; /* Chars transmitted */ 149 unsigned long txchars; /* Chars transmitted */
213 ulong rxchars; /* Chars received */ 150 unsigned long rxchars; /* Chars received */
214 ulong opens; /* port open count */ 151 unsigned long opens; /* port open count */
215 ulong closes; /* port close count */ 152 unsigned long closes; /* port close count */
216 ulong ioctls; /* ioctl count */ 153 unsigned long ioctls; /* ioctl count */
217 uchar LastRxTgl; /* Last state of rx toggle bit */ 154 unsigned char LastRxTgl; /* Last state of rx toggle bit */
218 spinlock_t portSem; /* Lock using this sem */ 155 spinlock_t portSem; /* Lock using this sem */
219 int MonitorTstate; /* Monitoring ? */ 156 int MonitorTstate; /* Monitoring ? */
220 int timeout_id; /* For calling 100 ms delays */ 157 int timeout_id; /* For calling 100 ms delays */
221 int timeout_sem; /* For calling 100 ms delays */ 158 int timeout_sem; /* For calling 100 ms delays */
222 int firstOpen; /* First time open ? */ 159 int firstOpen; /* First time open ? */
223 char *p; /* save the global struc here .. */ 160 char *p; /* save the global struc here .. */
224}; 161};
225 162
226struct ModuleInfo { 163struct ModuleInfo {
227 char *Name; 164 char *Name;
228 uint Flags[4]; /* one per port on a module */ 165 unsigned int Flags[4]; /* one per port on a module */
229}; 166};
230#endif
231 167
232/* 168/*
233** This struct is required because trying to grab an entire Port structure 169** This struct is required because trying to grab an entire Port structure
234** runs into problems with differing struct sizes between driver and config. 170** runs into problems with differing struct sizes between driver and config.
235*/ 171*/
236struct PortParams { 172struct PortParams {
237 uint Port; 173 unsigned int Port;
238 ulong Config; 174 unsigned long Config;
239 ulong State; 175 unsigned long State;
240 struct ttystatics *TtyP; 176 struct ttystatics *TtyP;
241}; 177};
178
179#endif
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
deleted file mode 100644
index 391ffc335535..000000000000
--- a/drivers/char/rio/qbuf.h
+++ /dev/null
@@ -1,62 +0,0 @@
1
2/****************************************************************************
3 ******* *******
4 ******* Q U E U E B U F F E R S T R U C T U R E S
5 ******* *******
6 ****************************************************************************
7
8 Author : Ian Nandhra / Jeremy Rolls
9 Date :
10
11 *
12 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
28 Version : 0.01
29
30
31 Mods
32 ----------------------------------------------------------------------------
33 Date By Description
34 ----------------------------------------------------------------------------
35
36 ***************************************************************************/
37
38#ifndef _qbuf_h
39#define _qbuf_h 1
40
41#ifndef lint
42#ifdef SCCS_LABELS
43static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
44#endif
45#endif
46
47
48
49#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
50
51typedef struct Q_BUF Q_BUF;
52struct Q_BUF {
53 Q_BUF_ptr next;
54 Q_BUF_ptr prev;
55 PKT_ptr buf[PKTS_PER_BUFFER];
56};
57
58
59#endif
60
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index 7f45e1ab5332..b4c91871ba28 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -33,38 +33,6 @@
33#ifndef __rio_rio_h__ 33#ifndef __rio_rio_h__
34#define __rio_rio_h__ 34#define __rio_rio_h__
35 35
36#ifdef SCCS_LABELS
37static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
38#endif
39
40/*
41** 30.09.1998 ARG -
42** Introduced driver version and host card type strings
43*/
44#define RIO_DRV_STR "Specialix RIO Driver"
45#define RIO_AT_HOST_STR "ISA"
46#define RIO_PCI_HOST_STR "PCI"
47
48
49/*
50** rio_info_store() commands (arbitary values) :
51*/
52#define RIO_INFO_PUT 0xA4B3C2D1
53#define RIO_INFO_GET 0xF1E2D3C4
54
55
56/*
57** anything that I couldn't cram in somewhere else
58*/
59/*
60#ifndef RIODEBUG
61#define debug
62#else
63#define debug rioprint
64#endif
65*/
66
67
68/* 36/*
69** Maximum numbers of things 37** Maximum numbers of things
70*/ 38*/
@@ -101,9 +69,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
101/* 69/*
102** Flag values returned by functions 70** Flag values returned by functions
103*/ 71*/
72
104#define RIO_FAIL -1 73#define RIO_FAIL -1
105#define RIO_SUCCESS 0
106#define COPYFAIL -1 /* copy[in|out] failed */
107 74
108/* 75/*
109** SysPort value for something that hasn't any ports 76** SysPort value for something that hasn't any ports
@@ -142,30 +109,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
142/* 109/*
143** Generally useful constants 110** Generally useful constants
144*/ 111*/
145#define HALF_A_SECOND ((HZ)>>1) 112
146#define A_SECOND (HZ) 113#define HUNDRED_MS ((HZ/10)?(HZ/10):1)
147#define HUNDRED_HZ ((HZ/100)?(HZ/100):1)
148#define FIFTY_HZ ((HZ/50)?(HZ/50):1)
149#define TWENTY_HZ ((HZ/20)?(HZ/20):1)
150#define TEN_HZ ((HZ/10)?(HZ/10):1)
151#define FIVE_HZ ((HZ/5)?(HZ/5):1)
152#define HUNDRED_MS TEN_HZ
153#define FIFTY_MS TWENTY_HZ
154#define TWENTY_MS FIFTY_HZ
155#define TEN_MS HUNDRED_HZ
156#define TWO_SECONDS ((A_SECOND)*2)
157#define FIVE_SECONDS ((A_SECOND)*5)
158#define TEN_SECONDS ((A_SECOND)*10)
159#define FIFTEEN_SECONDS ((A_SECOND)*15)
160#define TWENTY_SECONDS ((A_SECOND)*20)
161#define HALF_A_MINUTE (A_MINUTE>>1)
162#define A_MINUTE (A_SECOND*60)
163#define FIVE_MINUTES (A_MINUTE*5)
164#define QUARTER_HOUR (A_MINUTE*15)
165#define HALF_HOUR (A_MINUTE*30)
166#define HOUR (A_MINUTE*60)
167
168#define SIXTEEN_MEG 0x1000000
169#define ONE_MEG 0x100000 114#define ONE_MEG 0x100000
170#define SIXTY_FOUR_K 0x10000 115#define SIXTY_FOUR_K 0x10000
171 116
@@ -173,8 +118,6 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
173#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K 118#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K
174#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K 119#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K
175 120
176#define POLL_VECTOR 0x100
177
178#define COOK_WELL 0 121#define COOK_WELL 0
179#define COOK_MEDIUM 1 122#define COOK_MEDIUM 1
180#define COOK_RAW 2 123#define COOK_RAW 2
@@ -186,69 +129,26 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
186** 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
187** returns the offset into the DP RAM area. 130** returns the offset into the DP RAM area.
188*/ 131*/
189#define RIO_PTR(C,O) (((caddr_t)(C))+(0xFFFF&(O))) 132#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
190#define RIO_OFF(C,O) ((int)(O)-(int)(C)) 133#define RIO_OFF(C,O) ((long)(O)-(long)(C))
191 134
192/* 135/*
193** How to convert from various different device number formats: 136** How to convert from various different device number formats:
194** DEV is a dev number, as passed to open, close etc - NOT a minor 137** DEV is a dev number, as passed to open, close etc - NOT a minor
195** number! 138** number!
196** 139**/
197** Note: LynxOS only gives us 8 bits for the device minor number, 140
198** so all this crap here to deal with 'modem' bits etc. is
199** just a load of irrelevant old bunkum!
200** This however does not stop us needing to define a value
201** for RIO_MODEMOFFSET which is required by the 'riomkdev'
202** utility in the New Config Utilities suite.
203*/
204/* 0-511: direct 512-1023: modem */
205#define RIO_MODEMOFFSET 0x200 /* doesn't mean anything */
206#define RIO_MODEM_MASK 0x1FF 141#define RIO_MODEM_MASK 0x1FF
207#define RIO_MODEM_BIT 0x200 142#define RIO_MODEM_BIT 0x200
208#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK) 143#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK)
209#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT) 144#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT)
210#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \ 145#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
211 + MINOR(DEV) 146 + MINOR(DEV)
212 147#define CSUM(pkt_ptr) (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
213#define splrio spltty 148 ((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
214 149 ((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
215#define RIO_IPL 5 150 ((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
216#define RIO_PRI (PZERO+10) 151 ((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )
217#define RIO_CLOSE_PRI PZERO-1 /* uninterruptible sleeps for close */
218
219typedef struct DbInf {
220 uint Flag;
221 char Name[8];
222} DbInf;
223
224#ifndef TRUE
225#define TRUE (1==1)
226#endif
227#ifndef FALSE
228#define FALSE (!TRUE)
229#endif
230
231#define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \
232 ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \
233 ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \
234 ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \
235 ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] )
236
237/*
238** This happy little macro copies SIZE bytes of data from FROM to TO
239** quite well. SIZE must be a constant.
240*/
241#define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); }
242
243/*
244** increment a buffer pointer modulo the size of the buffer...
245*/
246#define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask))
247
248#define INIT_PACKET( PK, PP ) \
249{ \
250 *((uint *)PK) = PP->PacketInfo; \
251}
252 152
253#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */ 153#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */
254 /* prevent a really stupid race condition. */ 154 /* prevent a really stupid race condition. */
@@ -267,27 +167,42 @@ typedef struct DbInf {
267#define DISCONNECT 0 167#define DISCONNECT 0
268#define CONNECT 1 168#define CONNECT 1
269 169
170/* ------ Control Codes ------ */
270 171
271/* 172#define CONTROL '^'
272** Machine types - these must NOT overlap with product codes 0-15 173#define IFOAD ( CONTROL + 1 )
273*/ 174#define IDENTIFY ( CONTROL + 2 )
274#define RIO_MIPS_R3230 31 175#define ZOMBIE ( CONTROL + 3 )
275#define RIO_MIPS_R4030 32 176#define UFOAD ( CONTROL + 4 )
177#define IWAIT ( CONTROL + 5 )
178
179#define IFOAD_MAGIC 0xF0AD /* of course */
180#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
181#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
182#define IWAIT_MAGIC 0xB1DE /* Bide your time */
183
184/* ------ Error Codes ------ */
185
186#define E_NO_ERROR ((ushort) 0)
187
188/* ------ Free Lists ------ */
276 189
277#define RIO_IO_UNKNOWN -2 190struct rio_free_list {
191 u16 next;
192 u16 prev;
193};
278 194
279#undef MODERN 195/* NULL for card side linked lists */
280#define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 ) 196#define TPNULL ((ushort)(0x8000))
197/* We can add another packet to a transmit queue if the packet pointer pointed
198 * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
199#define PKT_IN_USE 0x1
281 200
282/* Defines for MPX line discipline routines */ 201/* ------ Topology ------ */
283 202
284#define DIST_LINESW_OPEN 0x01 203struct Top {
285#define DIST_LINESW_CLOSE 0x02 204 u8 Unit;
286#define DIST_LINESW_READ 0x04 205 u8 Link;
287#define DIST_LINESW_WRITE 0x08 206};
288#define DIST_LINESW_IOCTL 0x10
289#define DIST_LINESW_INPUT 0x20
290#define DIST_LINESW_OUTPUT 0x40
291#define DIST_LINESW_MDMINT 0x80
292 207
293#endif /* __rio_h__ */ 208#endif /* __rio_h__ */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c9af283a811d..78dd856534ce 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -57,15 +57,12 @@
57#include <asm/uaccess.h> 57#include <asm/uaccess.h>
58 58
59#include "linux_compat.h" 59#include "linux_compat.h"
60#include "typdef.h"
61#include "pkt.h" 60#include "pkt.h"
62#include "daemon.h" 61#include "daemon.h"
63#include "rio.h" 62#include "rio.h"
64#include "riospace.h" 63#include "riospace.h"
65#include "top.h"
66#include "cmdpkt.h" 64#include "cmdpkt.h"
67#include "map.h" 65#include "map.h"
68#include "riotypes.h"
69#include "rup.h" 66#include "rup.h"
70#include "port.h" 67#include "port.h"
71#include "riodrvr.h" 68#include "riodrvr.h"
@@ -78,17 +75,13 @@
78#include "unixrup.h" 75#include "unixrup.h"
79#include "board.h" 76#include "board.h"
80#include "host.h" 77#include "host.h"
81#include "error.h"
82#include "phb.h" 78#include "phb.h"
83#include "link.h" 79#include "link.h"
84#include "cmdblk.h" 80#include "cmdblk.h"
85#include "route.h" 81#include "route.h"
86#include "control.h"
87#include "cirrus.h" 82#include "cirrus.h"
88#include "rioioctl.h" 83#include "rioioctl.h"
89#include "param.h" 84#include "param.h"
90#include "list.h"
91#include "sam.h"
92#include "protsts.h" 85#include "protsts.h"
93#include "rioboard.h" 86#include "rioboard.h"
94 87
@@ -297,7 +290,7 @@ static void my_hd(void *ad, int len)
297 unsigned char *addr = ad; 290 unsigned char *addr = ad;
298 291
299 for (i = 0; i < len; i += 16) { 292 for (i = 0; i < len; i += 16) {
300 rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i); 293 rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i);
301 for (j = 0; j < 16; j++) { 294 for (j = 0; j < 16; j++) {
302 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : ""); 295 rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
303 } 296 }
@@ -340,34 +333,19 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
340 return !RIO_FAIL; 333 return !RIO_FAIL;
341} 334}
342 335
343 336void rio_copy_to_card(void *to, void *from, int len)
344int rio_minor(struct tty_struct *tty)
345{ 337{
346 return tty->index + (tty->driver == rio_driver) ? 0 : 256; 338 rio_memcpy_toio(NULL, to, from, len);
347} 339}
348 340
349 341int rio_minor(struct tty_struct *tty)
350int rio_ismodem(struct tty_struct *tty)
351{ 342{
352 return 1; 343 return tty->index + (tty->driver == rio_driver) ? 0 : 256;
353} 344}
354 345
355
356static int rio_set_real_termios(void *ptr) 346static int rio_set_real_termios(void *ptr)
357{ 347{
358 int rv, modem; 348 return RIOParam((struct Port *) ptr, CONFIG, 1, 1);
359 struct tty_struct *tty;
360 func_enter();
361
362 tty = ((struct Port *) ptr)->gs.tty;
363
364 modem = rio_ismodem(tty);
365
366 rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
367
368 func_exit();
369
370 return rv;
371} 349}
372 350
373 351
@@ -379,7 +357,7 @@ static void rio_reset_interrupt(struct Host *HostP)
379 case RIO_AT: 357 case RIO_AT:
380 case RIO_MCA: 358 case RIO_MCA:
381 case RIO_PCI: 359 case RIO_PCI:
382 WBYTE(HostP->ResetInt, 0xff); 360 writeb(0xFF, &HostP->ResetInt);
383 } 361 }
384 362
385 func_exit(); 363 func_exit();
@@ -397,9 +375,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
397 /* AAargh! The order in which to do these things is essential and 375 /* AAargh! The order in which to do these things is essential and
398 not trivial. 376 not trivial.
399 377
400 - Rate limit goes before "recursive". Otherwise a series of
401 recursive calls will hang the machine in the interrupt routine.
402
403 - hardware twiddling goes before "recursive". Otherwise when we 378 - hardware twiddling goes before "recursive". Otherwise when we
404 poll the card, and a recursive interrupt happens, we won't 379 poll the card, and a recursive interrupt happens, we won't
405 ack the card, so it might keep on interrupting us. (especially 380 ack the card, so it might keep on interrupting us. (especially
@@ -414,26 +389,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
414 - The initialized test goes before recursive. 389 - The initialized test goes before recursive.
415 */ 390 */
416 391
417
418
419#ifdef IRQ_RATE_LIMIT
420 /* Aaargh! I'm ashamed. This costs more lines-of-code than the
421 actual interrupt routine!. (Well, used to when I wrote that comment) */
422 {
423 static int lastjif;
424 static int nintr = 0;
425
426 if (lastjif == jiffies) {
427 if (++nintr > IRQ_RATE_LIMIT) {
428 free_irq(HostP->Ivec, ptr);
429 printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
430 }
431 } else {
432 lastjif = jiffies;
433 nintr = 0;
434 }
435 }
436#endif
437 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n"); 392 rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
438 if (HostP->Ivec == irq) { 393 if (HostP->Ivec == irq) {
439 /* Tell the card we've noticed the interrupt. */ 394 /* Tell the card we've noticed the interrupt. */
@@ -444,13 +399,13 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
444 return IRQ_HANDLED; 399 return IRQ_HANDLED;
445 400
446 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) { 401 if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
447 printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec); 402 printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec);
448 return IRQ_HANDLED; 403 return IRQ_HANDLED;
449 } 404 }
450 405
451 RIOServiceHost(p, HostP, irq); 406 RIOServiceHost(p, HostP, irq);
452 407
453 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type); 408 rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);
454 409
455 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks); 410 clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
456 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec); 411 rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
@@ -873,7 +828,7 @@ static int rio_init_datastructures(void)
873#define HOST_SZ sizeof(struct Host) 828#define HOST_SZ sizeof(struct Host)
874#define PORT_SZ sizeof(struct Port *) 829#define PORT_SZ sizeof(struct Port *)
875#define TMIO_SZ sizeof(struct termios *) 830#define TMIO_SZ sizeof(struct termios *)
876 rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); 831 rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
877 832
878 if (!(p = ckmalloc(RI_SZ))) 833 if (!(p = ckmalloc(RI_SZ)))
879 goto free0; 834 goto free0;
@@ -963,22 +918,21 @@ static void __exit rio_release_drivers(void)
963 918
964static void fix_rio_pci(struct pci_dev *pdev) 919static void fix_rio_pci(struct pci_dev *pdev)
965{ 920{
966 unsigned int hwbase; 921 unsigned long hwbase;
967 unsigned long rebase; 922 unsigned char *rebase;
968 unsigned int t; 923 unsigned int t;
969 924
970#define CNTRL_REG_OFFSET 0x50 925#define CNTRL_REG_OFFSET 0x50
971#define CNTRL_REG_GOODVALUE 0x18260000 926#define CNTRL_REG_GOODVALUE 0x18260000
972 927
973 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); 928 hwbase = pci_resource_start(pdev, 0);
974 hwbase &= PCI_BASE_ADDRESS_MEM_MASK; 929 rebase = ioremap(hwbase, 0x80);
975 rebase = (ulong) ioremap(hwbase, 0x80);
976 t = readl(rebase + CNTRL_REG_OFFSET); 930 t = readl(rebase + CNTRL_REG_OFFSET);
977 if (t != CNTRL_REG_GOODVALUE) { 931 if (t != CNTRL_REG_GOODVALUE) {
978 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 932 printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
979 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET); 933 writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
980 } 934 }
981 iounmap((char *) rebase); 935 iounmap(rebase);
982} 936}
983#endif 937#endif
984 938
@@ -994,7 +948,6 @@ static int __init rio_init(void)
994 948
995#ifdef CONFIG_PCI 949#ifdef CONFIG_PCI
996 struct pci_dev *pdev = NULL; 950 struct pci_dev *pdev = NULL;
997 unsigned int tint;
998 unsigned short tshort; 951 unsigned short tshort;
999#endif 952#endif
1000 953
@@ -1019,6 +972,8 @@ static int __init rio_init(void)
1019#ifdef CONFIG_PCI 972#ifdef CONFIG_PCI
1020 /* First look for the JET devices: */ 973 /* First look for the JET devices: */
1021 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { 974 while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
975 u32 tint;
976
1022 if (pci_enable_device(pdev)) 977 if (pci_enable_device(pdev))
1023 continue; 978 continue;
1024 979
@@ -1029,7 +984,6 @@ static int __init rio_init(void)
1029 Also, reading a non-aligned dword doesn't work. So we read the 984 Also, reading a non-aligned dword doesn't work. So we read the
1030 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID) 985 whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
1031 ourselves */ 986 ourselves */
1032 /* I don't know why the define doesn't work, constant 0x2c does --REW */
1033 pci_read_config_dword(pdev, 0x2c, &tint); 987 pci_read_config_dword(pdev, 0x2c, &tint);
1034 tshort = (tint >> 16) & 0xffff; 988 tshort = (tint >> 16) & 0xffff;
1035 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint); 989 rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
@@ -1039,33 +993,31 @@ static int __init rio_init(void)
1039 } 993 }
1040 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n"); 994 rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
1041 995
1042 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
1043
1044 hp = &p->RIOHosts[p->RIONumHosts]; 996 hp = &p->RIOHosts[p->RIONumHosts];
1045 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 997 hp->PaddrP = pci_resource_start(pdev, 2);
1046 hp->Ivec = pdev->irq; 998 hp->Ivec = pdev->irq;
1047 if (((1 << hp->Ivec) & rio_irqmask) == 0) 999 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1048 hp->Ivec = 0; 1000 hp->Ivec = 0;
1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1001 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1050 hp->CardP = (struct DpRam *) hp->Caddr; 1002 hp->CardP = (struct DpRam *) hp->Caddr;
1051 hp->Type = RIO_PCI; 1003 hp->Type = RIO_PCI;
1052 hp->Copy = rio_pcicopy; 1004 hp->Copy = rio_copy_to_card;
1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1005 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1054 spin_lock_init(&hp->HostLock); 1006 spin_lock_init(&hp->HostLock);
1055 rio_reset_interrupt(hp); 1007 rio_reset_interrupt(hp);
1056 rio_start_card_running(hp); 1008 rio_start_card_running(hp);
1057 1009
1058 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1010 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1059 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1011 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1060 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n"); 1012 rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
1061 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1013 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1062 p->RIOHosts[p->RIONumHosts].UniqueNum = 1014 p->RIOHosts[p->RIONumHosts].UniqueNum =
1063 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1015 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1064 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1016 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1065 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1017 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1066 1018
1067 fix_rio_pci(pdev); 1019 fix_rio_pci(pdev);
1068 p->RIOLastPCISearch = RIO_SUCCESS; 1020 p->RIOLastPCISearch = 0;
1069 p->RIONumHosts++; 1021 p->RIONumHosts++;
1070 found++; 1022 found++;
1071 } else { 1023 } else {
@@ -1088,10 +1040,8 @@ static int __init rio_init(void)
1088 continue; 1040 continue;
1089 1041
1090#ifdef CONFIG_RIO_OLDPCI 1042#ifdef CONFIG_RIO_OLDPCI
1091 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
1092
1093 hp = &p->RIOHosts[p->RIONumHosts]; 1043 hp = &p->RIOHosts[p->RIONumHosts];
1094 hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK; 1044 hp->PaddrP = pci_resource_start(pdev, 0);
1095 hp->Ivec = pdev->irq; 1045 hp->Ivec = pdev->irq;
1096 if (((1 << hp->Ivec) & rio_irqmask) == 0) 1046 if (((1 << hp->Ivec) & rio_irqmask) == 0)
1097 hp->Ivec = 0; 1047 hp->Ivec = 0;
@@ -1099,7 +1049,7 @@ static int __init rio_init(void)
1099 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1049 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1100 hp->CardP = (struct DpRam *) hp->Caddr; 1050 hp->CardP = (struct DpRam *) hp->Caddr;
1101 hp->Type = RIO_PCI; 1051 hp->Type = RIO_PCI;
1102 hp->Copy = rio_pcicopy; 1052 hp->Copy = rio_copy_to_card;
1103 hp->Mode = RIO_PCI_BOOT_FROM_RAM; 1053 hp->Mode = RIO_PCI_BOOT_FROM_RAM;
1104 spin_lock_init(&hp->HostLock); 1054 spin_lock_init(&hp->HostLock);
1105 1055
@@ -1109,14 +1059,14 @@ static int __init rio_init(void)
1109 rio_reset_interrupt(hp); 1059 rio_reset_interrupt(hp);
1110 rio_start_card_running(hp); 1060 rio_start_card_running(hp);
1111 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr); 1061 rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
1112 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) { 1062 if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
1113 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff); 1063 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
1114 p->RIOHosts[p->RIONumHosts].UniqueNum = 1064 p->RIOHosts[p->RIONumHosts].UniqueNum =
1115 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) | 1065 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
1116 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24); 1066 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
1117 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1067 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1118 1068
1119 p->RIOLastPCISearch = RIO_SUCCESS; 1069 p->RIOLastPCISearch = 0;
1120 p->RIONumHosts++; 1070 p->RIONumHosts++;
1121 found++; 1071 found++;
1122 } else { 1072 } else {
@@ -1137,8 +1087,8 @@ static int __init rio_init(void)
1137 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN); 1087 hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
1138 hp->CardP = (struct DpRam *) hp->Caddr; 1088 hp->CardP = (struct DpRam *) hp->Caddr;
1139 hp->Type = RIO_AT; 1089 hp->Type = RIO_AT;
1140 hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL 1090 hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
1141 * -- YES! this is now a normal copy. Only the 1091 * -- YES! this is now a normal copy. Only the
1142 * old PCI card uses the special PCI copy. 1092 * old PCI card uses the special PCI copy.
1143 * Moreover, the ISA card will work with the 1093 * Moreover, the ISA card will work with the
1144 * special PCI copy anyway. -- REW */ 1094 * special PCI copy anyway. -- REW */
@@ -1150,7 +1100,7 @@ static int __init rio_init(void)
1150 okboard = 0; 1100 okboard = 0;
1151 if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) { 1101 if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
1152 /* Board is present... */ 1102 /* Board is present... */
1153 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) { 1103 if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) {
1154 /* ... and feeling fine!!!! */ 1104 /* ... and feeling fine!!!! */
1155 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum); 1105 rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
1156 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) { 1106 if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
@@ -1252,24 +1202,3 @@ static void __exit rio_exit(void)
1252 1202
1253module_init(rio_init); 1203module_init(rio_init);
1254module_exit(rio_exit); 1204module_exit(rio_exit);
1255
1256/*
1257 * Anybody who knows why this doesn't work for me, please tell me -- REW.
1258 * Snatched from scsi.c (fixed one spelling error):
1259 * Overrides for Emacs so that we follow Linus' tabbing style.
1260 * Emacs will notice this stuff at the end of the file and automatically
1261 * adjust the settings for this buffer only. This must remain at the end
1262 * of the file.
1263 * ---------------------------------------------------------------------------
1264 * Local Variables:
1265 * c-indent-level: 4
1266 * c-brace-imaginary-offset: 0
1267 * c-brace-offset: -4
1268 * c-argdecl-indent: 4
1269 * c-label-offset: -4
1270 * c-continued-statement-offset: 4
1271 * c-continued-brace-offset: 0
1272 * indent-tabs-mode: nil
1273 * tab-width: 8
1274 * End:
1275 */
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index 92df43552f15..acda9326c2ef 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -30,38 +30,29 @@
30** ----------------------------------------------------------------------------- 30** -----------------------------------------------------------------------------
31*/ 31*/
32 32
33#ifdef SCCS_LABELS
34static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
35#endif
36
37#include <linux/module.h> 33#include <linux/module.h>
38#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/termios.h>
36#include <linux/serial.h>
37#include <asm/semaphore.h>
38#include <linux/generic_serial.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/delay.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/string.h> 44#include <asm/string.h>
44#include <asm/semaphore.h> 45#include <asm/uaccess.h>
45
46
47#include <linux/termios.h>
48#include <linux/serial.h>
49
50#include <linux/generic_serial.h>
51
52 46
53 47
54#include "linux_compat.h" 48#include "linux_compat.h"
55#include "rio_linux.h" 49#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 50#include "pkt.h"
58#include "daemon.h" 51#include "daemon.h"
59#include "rio.h" 52#include "rio.h"
60#include "riospace.h" 53#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 54#include "cmdpkt.h"
63#include "map.h" 55#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 56#include "rup.h"
66#include "port.h" 57#include "port.h"
67#include "riodrvr.h" 58#include "riodrvr.h"
@@ -74,161 +65,130 @@ static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
74#include "unixrup.h" 65#include "unixrup.h"
75#include "board.h" 66#include "board.h"
76#include "host.h" 67#include "host.h"
77#include "error.h"
78#include "phb.h" 68#include "phb.h"
79#include "link.h" 69#include "link.h"
80#include "cmdblk.h" 70#include "cmdblk.h"
81#include "route.h" 71#include "route.h"
82 72
83static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ); 73static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP);
84 74
85static uchar 75static const unsigned char RIOAtVec2Ctrl[] = {
86RIOAtVec2Ctrl[] = 76 /* 0 */ INTERRUPT_DISABLE,
87{ 77 /* 1 */ INTERRUPT_DISABLE,
88 /* 0 */ INTERRUPT_DISABLE, 78 /* 2 */ INTERRUPT_DISABLE,
89 /* 1 */ INTERRUPT_DISABLE, 79 /* 3 */ INTERRUPT_DISABLE,
90 /* 2 */ INTERRUPT_DISABLE, 80 /* 4 */ INTERRUPT_DISABLE,
91 /* 3 */ INTERRUPT_DISABLE, 81 /* 5 */ INTERRUPT_DISABLE,
92 /* 4 */ INTERRUPT_DISABLE, 82 /* 6 */ INTERRUPT_DISABLE,
93 /* 5 */ INTERRUPT_DISABLE, 83 /* 7 */ INTERRUPT_DISABLE,
94 /* 6 */ INTERRUPT_DISABLE, 84 /* 8 */ INTERRUPT_DISABLE,
95 /* 7 */ INTERRUPT_DISABLE, 85 /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
96 /* 8 */ INTERRUPT_DISABLE,
97 /* 9 */ IRQ_9|INTERRUPT_ENABLE,
98 /* 10 */ INTERRUPT_DISABLE, 86 /* 10 */ INTERRUPT_DISABLE,
99 /* 11 */ IRQ_11|INTERRUPT_ENABLE, 87 /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
100 /* 12 */ IRQ_12|INTERRUPT_ENABLE, 88 /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
101 /* 13 */ INTERRUPT_DISABLE, 89 /* 13 */ INTERRUPT_DISABLE,
102 /* 14 */ INTERRUPT_DISABLE, 90 /* 14 */ INTERRUPT_DISABLE,
103 /* 15 */ IRQ_15|INTERRUPT_ENABLE 91 /* 15 */ IRQ_15 | INTERRUPT_ENABLE
104}; 92};
105 93
106/* 94/**
107** Load in the RTA boot code. 95 * RIOBootCodeRTA - Load RTA boot code
108*/ 96 * @p: RIO to load
109int 97 * @rbp: Download descriptor
110RIOBootCodeRTA(p, rbp) 98 *
111struct rio_info * p; 99 * Called when the user process initiates booting of the card firmware.
112struct DownLoad * rbp; 100 * Lads the firmware
101 */
102
103int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
113{ 104{
114 int offset; 105 int offset;
115 106
116 func_enter (); 107 func_enter();
117 108
118 /* Linux doesn't allow you to disable interrupts during a 109 rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
119 "copyin". (Crash when a pagefault occurs). */
120 /* disable(oldspl); */
121
122 rio_dprintk (RIO_DEBUG_BOOT, "Data at user address 0x%x\n",(int)rbp->DataP);
123 110
124 /* 111 /*
125 ** Check that we have set asside enough memory for this 112 ** Check that we have set asside enough memory for this
126 */ 113 */
127 if ( rbp->Count > SIXTY_FOUR_K ) { 114 if (rbp->Count > SIXTY_FOUR_K) {
128 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n"); 115 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
129 p->RIOError.Error = HOST_FILE_TOO_LARGE; 116 p->RIOError.Error = HOST_FILE_TOO_LARGE;
130 /* restore(oldspl); */ 117 func_exit();
131 func_exit ();
132 return -ENOMEM; 118 return -ENOMEM;
133 } 119 }
134 120
135 if ( p->RIOBooting ) { 121 if (p->RIOBooting) {
136 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n"); 122 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
137 p->RIOError.Error = BOOT_IN_PROGRESS; 123 p->RIOError.Error = BOOT_IN_PROGRESS;
138 /* restore(oldspl); */ 124 func_exit();
139 func_exit ();
140 return -EBUSY; 125 return -EBUSY;
141 } 126 }
142 127
143 /* 128 /*
144 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary, 129 ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
145 ** so calculate how far we have to move the data up the buffer 130 ** so calculate how far we have to move the data up the buffer
146 ** to achieve this. 131 ** to achieve this.
147 */ 132 */
148 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % 133 offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
149 RTA_BOOT_DATA_SIZE;
150 134
151 /* 135 /*
152 ** Be clean, and clear the 'unused' portion of the boot buffer, 136 ** Be clean, and clear the 'unused' portion of the boot buffer,
153 ** because it will (eventually) be part of the Rta run time environment 137 ** because it will (eventually) be part of the Rta run time environment
154 ** and so should be zeroed. 138 ** and so should be zeroed.
155 */ 139 */
156 bzero( (caddr_t)p->RIOBootPackets, offset ); 140 memset(p->RIOBootPackets, 0, offset);
157 141
158 /* 142 /*
159 ** Copy the data from user space. 143 ** Copy the data from user space into the array
160 */ 144 */
161 145
162 if ( copyin((int)rbp->DataP,((caddr_t)(p->RIOBootPackets))+offset, 146 if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
163 rbp->Count) ==COPYFAIL ) { 147 rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
164 rio_dprintk (RIO_DEBUG_BOOT, "Bad data copy from user space\n");
165 p->RIOError.Error = COPYIN_FAILED; 148 p->RIOError.Error = COPYIN_FAILED;
166 /* restore(oldspl); */ 149 func_exit();
167 func_exit ();
168 return -EFAULT; 150 return -EFAULT;
169 } 151 }
170 152
171 /* 153 /*
172 ** Make sure that our copy of the size includes that offset we discussed 154 ** Make sure that our copy of the size includes that offset we discussed
173 ** earlier. 155 ** earlier.
174 */ 156 */
175 p->RIONumBootPkts = (rbp->Count+offset)/RTA_BOOT_DATA_SIZE; 157 p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
176 p->RIOBootCount = rbp->Count; 158 p->RIOBootCount = rbp->Count;
177 159
178 /* restore(oldspl); */
179 func_exit(); 160 func_exit();
180 return 0; 161 return 0;
181} 162}
182 163
183void rio_start_card_running (struct Host * HostP) 164/**
184{ 165 * rio_start_card_running - host card start
185 func_enter (); 166 * @HostP: The RIO to kick off
167 *
168 * Start a RIO processor unit running. Encapsulates the knowledge
169 * of the card type.
170 */
186 171
187 switch ( HostP->Type ) { 172void rio_start_card_running(struct Host *HostP)
173{
174 switch (HostP->Type) {
188 case RIO_AT: 175 case RIO_AT:
189 rio_dprintk (RIO_DEBUG_BOOT, "Start ISA card running\n"); 176 rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
190 WBYTE(HostP->Control, 177 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
191 BOOT_FROM_RAM | EXTERNAL_BUS_ON
192 | HostP->Mode
193 | RIOAtVec2Ctrl[HostP->Ivec & 0xF] );
194 break;
195
196#ifdef FUTURE_RELEASE
197 case RIO_MCA:
198 /*
199 ** MCA handles IRQ vectors differently, so we don't write
200 ** them to this register.
201 */
202 rio_dprintk (RIO_DEBUG_BOOT, "Start MCA card running\n");
203 WBYTE(HostP->Control, McaTpBootFromRam | McaTpBusEnable | HostP->Mode);
204 break; 178 break;
205
206 case RIO_EISA:
207 /*
208 ** EISA is totally different and expects OUTBZs to turn it on.
209 */
210 rio_dprintk (RIO_DEBUG_BOOT, "Start EISA card running\n");
211 OUTBZ( HostP->Slot, EISA_CONTROL_PORT, HostP->Mode | RIOEisaVec2Ctrl[HostP->Ivec] | EISA_TP_RUN | EISA_TP_BUS_ENABLE | EISA_TP_BOOT_FROM_RAM );
212 break;
213#endif
214
215 case RIO_PCI: 179 case RIO_PCI:
216 /* 180 /*
217 ** PCI is much the same as MCA. Everything is once again memory 181 ** PCI is much the same as MCA. Everything is once again memory
218 ** mapped, so we are writing to memory registers instead of io 182 ** mapped, so we are writing to memory registers instead of io
219 ** ports. 183 ** ports.
220 */ 184 */
221 rio_dprintk (RIO_DEBUG_BOOT, "Start PCI card running\n"); 185 rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
222 WBYTE(HostP->Control, PCITpBootFromRam | PCITpBusEnable | HostP->Mode); 186 writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
223 break; 187 break;
224 default: 188 default:
225 rio_dprintk (RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type); 189 rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
226 break; 190 break;
227 } 191 }
228/*
229 printk (KERN_INFO "Done with starting the card\n");
230 func_exit ();
231*/
232 return; 192 return;
233} 193}
234 194
@@ -239,370 +199,350 @@ void rio_start_card_running (struct Host * HostP)
239** Put your rubber pants on before messing with this code - even the magic 199** Put your rubber pants on before messing with this code - even the magic
240** numbers have trouble understanding what they are doing here. 200** numbers have trouble understanding what they are doing here.
241*/ 201*/
242int 202
243RIOBootCodeHOST(p, rbp) 203int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
244struct rio_info * p;
245register struct DownLoad *rbp;
246{ 204{
247 register struct Host *HostP; 205 struct Host *HostP;
248 register caddr_t Cad; 206 u8 *Cad;
249 register PARM_MAP *ParmMapP; 207 PARM_MAP *ParmMapP;
250 register int RupN; 208 int RupN;
251 int PortN; 209 int PortN;
252 uint host; 210 unsigned int host;
253 caddr_t StartP; 211 u8 *StartP;
254 BYTE *DestP; 212 u8 *DestP;
255 int wait_count; 213 int wait_count;
256 ushort OldParmMap; 214 u16 OldParmMap;
257 ushort offset; /* It is very important that this is a ushort */ 215 u16 offset; /* It is very important that this is a u16 */
258 /* uint byte; */ 216 u8 *DownCode = NULL;
259 caddr_t DownCode = NULL;
260 unsigned long flags; 217 unsigned long flags;
261 218
262 HostP = NULL; /* Assure the compiler we've initialized it */ 219 HostP = NULL; /* Assure the compiler we've initialized it */
263 for ( host=0; host<p->RIONumHosts; host++ ) { 220
264 rio_dprintk (RIO_DEBUG_BOOT, "Attempt to boot host %d\n",host); 221
222 /* Walk the hosts */
223 for (host = 0; host < p->RIONumHosts; host++) {
224 rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
265 HostP = &p->RIOHosts[host]; 225 HostP = &p->RIOHosts[host];
266
267 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n",
268 HostP->Type, HostP->Mode, HostP->Ivec);
269 226
227 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
270 228
271 if ( (HostP->Flags & RUN_STATE) != RC_WAITING ) { 229 /* Don't boot hosts already running */
272 rio_dprintk (RIO_DEBUG_BOOT, "%s %d already running\n","Host",host); 230 if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
231 rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
273 continue; 232 continue;
274 } 233 }
275 234
276 /* 235 /*
277 ** Grab a 32 bit pointer to the card. 236 ** Grab a pointer to the card (ioremapped)
278 */ 237 */
279 Cad = HostP->Caddr; 238 Cad = HostP->Caddr;
280 239
281 /* 240 /*
282 ** We are going to (try) and load in rbp->Count bytes. 241 ** We are going to (try) and load in rbp->Count bytes.
283 ** The last byte will reside at p->RIOConf.HostLoadBase-1; 242 ** The last byte will reside at p->RIOConf.HostLoadBase-1;
284 ** Therefore, we need to start copying at address 243 ** Therefore, we need to start copying at address
285 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count) 244 ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
286 */ 245 */
287 StartP = (caddr_t)&Cad[p->RIOConf.HostLoadBase-rbp->Count]; 246 StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
288 247
289 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for host is 0x%x\n", (int)Cad ); 248 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
290 rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for download is 0x%x\n", (int)StartP); 249 rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
291 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 250 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
292 rio_dprintk (RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count); 251 rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
293 252
294 if ( p->RIOConf.HostLoadBase < rbp->Count ) { 253 /* Make sure it fits */
295 rio_dprintk (RIO_DEBUG_BOOT, "Bin too large\n"); 254 if (p->RIOConf.HostLoadBase < rbp->Count) {
255 rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
296 p->RIOError.Error = HOST_FILE_TOO_LARGE; 256 p->RIOError.Error = HOST_FILE_TOO_LARGE;
297 func_exit (); 257 func_exit();
298 return -EFBIG; 258 return -EFBIG;
299 } 259 }
300 /* 260 /*
301 ** Ensure that the host really is stopped. 261 ** Ensure that the host really is stopped.
302 ** Disable it's external bus & twang its reset line. 262 ** Disable it's external bus & twang its reset line.
303 */ 263 */
304 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); 264 RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
305
306 /*
307 ** Copy the data directly from user space to the SRAM.
308 ** This ain't going to be none too clever if the download
309 ** code is bigger than this segment.
310 */
311 rio_dprintk (RIO_DEBUG_BOOT, "Copy in code\n");
312 265
313 /* 266 /*
314 ** PCI hostcard can't cope with 32 bit accesses and so need to copy 267 ** Copy the data directly from user space to the SRAM.
315 ** data to a local buffer, and then dripfeed the card. 268 ** This ain't going to be none too clever if the download
316 */ 269 ** code is bigger than this segment.
317 if ( HostP->Type == RIO_PCI ) { 270 */
318 /* int offset; */ 271 rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
319 272
320 DownCode = sysbrk(rbp->Count); 273 /* Buffer to local memory as we want to use I/O space and
321 if ( !DownCode ) { 274 some cards only do 8 or 16 bit I/O */
322 rio_dprintk (RIO_DEBUG_BOOT, "No system memory available\n"); 275
323 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY; 276 DownCode = vmalloc(rbp->Count);
324 func_exit (); 277 if (!DownCode) {
325 return -ENOMEM; 278 p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
326 } 279 func_exit();
327 bzero(DownCode, rbp->Count); 280 return -ENOMEM;
328
329 if ( copyin((int)rbp->DataP,DownCode,rbp->Count)==COPYFAIL ) {
330 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
331 sysfree( DownCode, rbp->Count );
332 p->RIOError.Error = COPYIN_FAILED;
333 func_exit ();
334 return -EFAULT;
335 }
336
337 HostP->Copy( DownCode, StartP, rbp->Count );
338
339 sysfree( DownCode, rbp->Count );
340 } 281 }
341 else if ( copyin((int)rbp->DataP,StartP,rbp->Count)==COPYFAIL ) { 282 if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) {
342 rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n"); 283 kfree(DownCode);
343 p->RIOError.Error = COPYIN_FAILED; 284 p->RIOError.Error = COPYIN_FAILED;
344 func_exit (); 285 func_exit();
345 return -EFAULT; 286 return -EFAULT;
346 } 287 }
288 HostP->Copy(DownCode, StartP, rbp->Count);
289 vfree(DownCode);
347 290
348 rio_dprintk (RIO_DEBUG_BOOT, "Copy completed\n"); 291 rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
349 292
350 /* 293 /*
351 ** S T O P ! 294 ** S T O P !
352 ** 295 **
353 ** Upto this point the code has been fairly rational, and possibly 296 ** Upto this point the code has been fairly rational, and possibly
354 ** even straight forward. What follows is a pile of crud that will 297 ** even straight forward. What follows is a pile of crud that will
355 ** magically turn into six bytes of transputer assembler. Normally 298 ** magically turn into six bytes of transputer assembler. Normally
356 ** you would expect an array or something, but, being me, I have 299 ** you would expect an array or something, but, being me, I have
357 ** chosen [been told] to use a technique whereby the startup code 300 ** chosen [been told] to use a technique whereby the startup code
358 ** will be correct if we change the loadbase for the code. Which 301 ** will be correct if we change the loadbase for the code. Which
359 ** brings us onto another issue - the loadbase is the *end* of the 302 ** brings us onto another issue - the loadbase is the *end* of the
360 ** code, not the start. 303 ** code, not the start.
361 ** 304 **
362 ** If I were you I wouldn't start from here. 305 ** If I were you I wouldn't start from here.
363 */ 306 */
364 307
365 /* 308 /*
366 ** We now need to insert a short boot section into 309 ** We now need to insert a short boot section into
367 ** the memory at the end of Sram2. This is normally (de)composed 310 ** the memory at the end of Sram2. This is normally (de)composed
368 ** of the last eight bytes of the download code. The 311 ** of the last eight bytes of the download code. The
369 ** download has been assembled/compiled to expect to be 312 ** download has been assembled/compiled to expect to be
370 ** loaded from 0x7FFF downwards. We have loaded it 313 ** loaded from 0x7FFF downwards. We have loaded it
371 ** at some other address. The startup code goes into the small 314 ** at some other address. The startup code goes into the small
372 ** ram window at Sram2, in the last 8 bytes, which are really 315 ** ram window at Sram2, in the last 8 bytes, which are really
373 ** at addresses 0x7FF8-0x7FFF. 316 ** at addresses 0x7FF8-0x7FFF.
374 ** 317 **
375 ** If the loadbase is, say, 0x7C00, then we need to branch to 318 ** If the loadbase is, say, 0x7C00, then we need to branch to
376 ** address 0x7BFE to run the host.bin startup code. We assemble 319 ** address 0x7BFE to run the host.bin startup code. We assemble
377 ** this jump manually. 320 ** this jump manually.
378 ** 321 **
379 ** The two byte sequence 60 08 is loaded into memory at address 322 ** The two byte sequence 60 08 is loaded into memory at address
380 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0, 323 ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
381 ** which adds '0' to the .O register, complements .O, and then shifts 324 ** which adds '0' to the .O register, complements .O, and then shifts
382 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will 325 ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
383 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new 326 ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
384 ** location. Now, the branch starts from the value of .PC (or .IP or 327 ** location. Now, the branch starts from the value of .PC (or .IP or
385 ** whatever the bloody register is called on this chip), and the .PC 328 ** whatever the bloody register is called on this chip), and the .PC
386 ** will be pointing to the location AFTER the branch, in this case 329 ** will be pointing to the location AFTER the branch, in this case
387 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8. 330 ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
388 ** 331 **
389 ** A long branch is coded at 0x7FF8. This consists of loading a four 332 ** A long branch is coded at 0x7FF8. This consists of loading a four
390 ** byte offset into .O using nfix (as above) and pfix operators. The 333 ** byte offset into .O using nfix (as above) and pfix operators. The
391 ** pfix operates in exactly the same way as the nfix operator, but 334 ** pfix operates in exactly the same way as the nfix operator, but
392 ** without the complement operation. The offset, of course, must be 335 ** without the complement operation. The offset, of course, must be
393 ** relative to the address of the byte AFTER the branch instruction, 336 ** relative to the address of the byte AFTER the branch instruction,
394 ** which will be (urm) 0x7FFC, so, our final destination of the branch 337 ** which will be (urm) 0x7FFC, so, our final destination of the branch
395 ** (loadbase-2), has to be reached from here. Imagine that the loadbase 338 ** (loadbase-2), has to be reached from here. Imagine that the loadbase
396 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which 339 ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
397 ** is the first byte of the initial two byte short local branch of the 340 ** is the first byte of the initial two byte short local branch of the
398 ** download code). 341 ** download code).
399 ** 342 **
400 ** To code a jump from 0x7FFC (which is where the branch will start 343 ** To code a jump from 0x7FFC (which is where the branch will start
401 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)= 344 ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
402 ** 0x7BFE. 345 ** 0x7BFE.
403 ** This will be coded as four bytes: 346 ** This will be coded as four bytes:
404 ** 60 2C 20 02 347 ** 60 2C 20 02
405 ** being nfix .O+0 348 ** being nfix .O+0
406 ** pfix .O+C 349 ** pfix .O+C
407 ** pfix .O+0 350 ** pfix .O+0
408 ** jump .O+2 351 ** jump .O+2
409 ** 352 **
410 ** The nfix operator is used, so that the startup code will be 353 ** The nfix operator is used, so that the startup code will be
411 ** compatible with the whole Tp family. (lies, damn lies, it'll never 354 ** compatible with the whole Tp family. (lies, damn lies, it'll never
412 ** work in a month of Sundays). 355 ** work in a month of Sundays).
413 ** 356 **
414 ** The nfix nyble is the 1s complement of the nyble value you 357 ** The nfix nyble is the 1s complement of the nyble value you
415 ** want to load - in this case we wanted 'F' so we nfix loaded '0'. 358 ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
416 */ 359 */
417 360
418 361
419 /* 362 /*
420 ** Dest points to the top 8 bytes of Sram2. The Tp jumps 363 ** Dest points to the top 8 bytes of Sram2. The Tp jumps
421 ** to 0x7FFE at reset time, and starts executing. This is 364 ** to 0x7FFE at reset time, and starts executing. This is
422 ** a short branch to 0x7FF8, where a long branch is coded. 365 ** a short branch to 0x7FF8, where a long branch is coded.
423 */ 366 */
424 367
425 DestP = (BYTE *)&Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ 368 DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
426 369
427#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ 370#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
428#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ 371#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
429#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */ 372#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
430 373
431 /* 374 /*
432 ** 0x7FFC is the address of the location following the last byte of 375 ** 0x7FFC is the address of the location following the last byte of
433 ** the four byte jump instruction. 376 ** the four byte jump instruction.
434 ** READ THE ABOVE COMMENTS 377 ** READ THE ABOVE COMMENTS
435 ** 378 **
436 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about. 379 ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
437 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned, 380 ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
438 ** cos I don't understand 2's complement). 381 ** cos I don't understand 2's complement).
439 */ 382 */
440 offset = (p->RIOConf.HostLoadBase-2)-0x7FFC; 383 offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
441 WBYTE( DestP[0] , NFIX(((ushort)(~offset) >> (ushort)12) & 0xF) ); 384
442 WBYTE( DestP[1] , PFIX(( offset >> 8) & 0xF) ); 385 writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP);
443 WBYTE( DestP[2] , PFIX(( offset >> 4) & 0xF) ); 386 writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
444 WBYTE( DestP[3] , JUMP( offset & 0xF) ); 387 writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
445 388 writeb(JUMP(offset & 0xF), DestP + 3);
446 WBYTE( DestP[6] , NFIX(0) ); 389
447 WBYTE( DestP[7] , JUMP(8) ); 390 writeb(NFIX(0), DestP + 6);
448 391 writeb(JUMP(8), DestP + 7);
449 rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase); 392
450 rio_dprintk (RIO_DEBUG_BOOT, "startup offset is 0x%x\n",offset); 393 rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
394 rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
451 395
452 /* 396 /*
453 ** Flag what is going on 397 ** Flag what is going on
454 */ 398 */
455 HostP->Flags &= ~RUN_STATE; 399 HostP->Flags &= ~RUN_STATE;
456 HostP->Flags |= RC_STARTUP; 400 HostP->Flags |= RC_STARTUP;
457 401
458 /* 402 /*
459 ** Grab a copy of the current ParmMap pointer, so we 403 ** Grab a copy of the current ParmMap pointer, so we
460 ** can tell when it has changed. 404 ** can tell when it has changed.
461 */ 405 */
462 OldParmMap = RWORD(HostP->__ParmMapR); 406 OldParmMap = readw(&HostP->__ParmMapR);
463 407
464 rio_dprintk (RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n",OldParmMap); 408 rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
465 409
466 /* 410 /*
467 ** And start it running (I hope). 411 ** And start it running (I hope).
468 ** As there is nothing dodgy or obscure about the 412 ** As there is nothing dodgy or obscure about the
469 ** above code, this is guaranteed to work every time. 413 ** above code, this is guaranteed to work every time.
470 */ 414 */
471 rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", 415 rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
472 HostP->Type, HostP->Mode, HostP->Ivec);
473 416
474 rio_start_card_running(HostP); 417 rio_start_card_running(HostP);
475 418
476 rio_dprintk (RIO_DEBUG_BOOT, "Set control port\n"); 419 rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
477 420
478 /* 421 /*
479 ** Now, wait for upto five seconds for the Tp to setup the parmmap 422 ** Now, wait for upto five seconds for the Tp to setup the parmmap
480 ** pointer: 423 ** pointer:
481 */ 424 */
482 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime)&& 425 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
483 (RWORD(HostP->__ParmMapR)==OldParmMap); wait_count++ ) { 426 rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
484 rio_dprintk (RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n",wait_count,RWORD(HostP->__ParmMapR)); 427 mdelay(100);
485 delay(HostP, HUNDRED_MS);
486 428
487 } 429 }
488 430
489 /* 431 /*
490 ** If the parmmap pointer is unchanged, then the host code 432 ** If the parmmap pointer is unchanged, then the host code
491 ** has crashed & burned in a really spectacular way 433 ** has crashed & burned in a really spectacular way
492 */ 434 */
493 if ( RWORD(HostP->__ParmMapR) == OldParmMap ) { 435 if (readw(&HostP->__ParmMapR) == OldParmMap) {
494 rio_dprintk (RIO_DEBUG_BOOT, "parmmap 0x%x\n", RWORD(HostP->__ParmMapR)); 436 rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
495 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); 437 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
496 438 HostP->Flags &= ~RUN_STATE;
497#define HOST_DISABLE \ 439 HostP->Flags |= RC_STUFFED;
498 HostP->Flags &= ~RUN_STATE; \ 440 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
499 HostP->Flags |= RC_STUFFED; \ 441 continue;
500 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );\
501 continue
502
503 HOST_DISABLE;
504 } 442 }
505 443
506 rio_dprintk (RIO_DEBUG_BOOT, "Running 0x%x\n", RWORD(HostP->__ParmMapR)); 444 rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
507 445
508 /* 446 /*
509 ** Well, the board thought it was OK, and setup its parmmap 447 ** Well, the board thought it was OK, and setup its parmmap
510 ** pointer. For the time being, we will pretend that this 448 ** pointer. For the time being, we will pretend that this
511 ** board is running, and check out what the error flag says. 449 ** board is running, and check out what the error flag says.
512 */ 450 */
513 451
514 /* 452 /*
515 ** Grab a 32 bit pointer to the parmmap structure 453 ** Grab a 32 bit pointer to the parmmap structure
516 */ 454 */
517 ParmMapP = (PARM_MAP *)RIO_PTR(Cad,RWORD(HostP->__ParmMapR)); 455 ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
518 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP); 456 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
519 ParmMapP = (PARM_MAP *)((unsigned long)Cad + 457 ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR));
520 (unsigned long)((RWORD((HostP->__ParmMapR))) & 0xFFFF)); 458 rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
521 rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP);
522 459
523 /* 460 /*
524 ** The links entry should be 0xFFFF; we set it up 461 ** The links entry should be 0xFFFF; we set it up
525 ** with a mask to say how many PHBs to use, and 462 ** with a mask to say how many PHBs to use, and
526 ** which links to use. 463 ** which links to use.
527 */ 464 */
528 if ( (RWORD(ParmMapP->links) & 0xFFFF) != 0xFFFF ) { 465 if (readw(&ParmMapP->links) != 0xFFFF) {
529 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 466 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
530 rio_dprintk (RIO_DEBUG_BOOT, "Links = 0x%x\n",RWORD(ParmMapP->links)); 467 rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
531 HOST_DISABLE; 468 HostP->Flags &= ~RUN_STATE;
469 HostP->Flags |= RC_STUFFED;
470 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
471 continue;
532 } 472 }
533 473
534 WWORD(ParmMapP->links , RIO_LINK_ENABLE); 474 writew(RIO_LINK_ENABLE, &ParmMapP->links);
535 475
536 /* 476 /*
537 ** now wait for the card to set all the parmmap->XXX stuff 477 ** now wait for the card to set all the parmmap->XXX stuff
538 ** this is a wait of upto two seconds.... 478 ** this is a wait of upto two seconds....
539 */ 479 */
540 rio_dprintk (RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n",p->RIOConf.StartupTime); 480 rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
541 HostP->timeout_id = 0; 481 HostP->timeout_id = 0;
542 for ( wait_count=0; (wait_count<p->RIOConf.StartupTime) && 482 for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
543 !RWORD(ParmMapP->init_done); wait_count++ ) { 483 rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
544 rio_dprintk (RIO_DEBUG_BOOT, "Waiting for init_done\n"); 484 mdelay(100);
545 delay(HostP, HUNDRED_MS);
546 } 485 }
547 rio_dprintk (RIO_DEBUG_BOOT, "OK! init_done!\n"); 486 rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
548 487
549 if (RWORD(ParmMapP->error) != E_NO_ERROR || 488 if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
550 !RWORD(ParmMapP->init_done) ) { 489 rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
551 rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); 490 rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
552 rio_dprintk (RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); 491 HostP->Flags &= ~RUN_STATE;
553 HOST_DISABLE; 492 HostP->Flags |= RC_STUFFED;
493 RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
494 continue;
554 } 495 }
555 496
556 rio_dprintk (RIO_DEBUG_BOOT, "Got init_done\n"); 497 rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
557 498
558 /* 499 /*
559 ** It runs! It runs! 500 ** It runs! It runs!
560 */ 501 */
561 rio_dprintk (RIO_DEBUG_BOOT, "Host ID %x Running\n",HostP->UniqueNum); 502 rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
562 503
563 /* 504 /*
564 ** set the time period between interrupts. 505 ** set the time period between interrupts.
565 */ 506 */
566 WWORD(ParmMapP->timer, (short)p->RIOConf.Timer ); 507 writew(p->RIOConf.Timer, &ParmMapP->timer);
567 508
568 /* 509 /*
569 ** Translate all the 16 bit pointers in the __ParmMapR into 510 ** Translate all the 16 bit pointers in the __ParmMapR into
570 ** 32 bit pointers for the driver. 511 ** 32 bit pointers for the driver in ioremap space.
571 */ 512 */
572 HostP->ParmMapP = ParmMapP; 513 HostP->ParmMapP = ParmMapP;
573 HostP->PhbP = (PHB*)RIO_PTR(Cad,RWORD(ParmMapP->phb_ptr)); 514 HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
574 HostP->RupP = (RUP*)RIO_PTR(Cad,RWORD(ParmMapP->rups)); 515 HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups));
575 HostP->PhbNumP = (ushort*)RIO_PTR(Cad,RWORD(ParmMapP->phb_num_ptr)); 516 HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
576 HostP->LinkStrP = (LPB*)RIO_PTR(Cad,RWORD(ParmMapP->link_str_ptr)); 517 HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
577 518
578 /* 519 /*
579 ** point the UnixRups at the real Rups 520 ** point the UnixRups at the real Rups
580 */ 521 */
581 for ( RupN = 0; RupN<MAX_RUP; RupN++ ) { 522 for (RupN = 0; RupN < MAX_RUP; RupN++) {
582 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN]; 523 HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
583 HostP->UnixRups[RupN].Id = RupN+1; 524 HostP->UnixRups[RupN].Id = RupN + 1;
584 HostP->UnixRups[RupN].BaseSysPort = NO_PORT; 525 HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
585 spin_lock_init(&HostP->UnixRups[RupN].RupLock); 526 spin_lock_init(&HostP->UnixRups[RupN].RupLock);
586 } 527 }
587 528
588 for ( RupN = 0; RupN<LINKS_PER_UNIT; RupN++ ) { 529 for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
589 HostP->UnixRups[RupN+MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup; 530 HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
590 HostP->UnixRups[RupN+MAX_RUP].Id = 0; 531 HostP->UnixRups[RupN + MAX_RUP].Id = 0;
591 HostP->UnixRups[RupN+MAX_RUP].BaseSysPort = NO_PORT; 532 HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
592 spin_lock_init(&HostP->UnixRups[RupN+MAX_RUP].RupLock); 533 spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
593 } 534 }
594 535
595 /* 536 /*
596 ** point the PortP->Phbs at the real Phbs 537 ** point the PortP->Phbs at the real Phbs
597 */ 538 */
598 for ( PortN=p->RIOFirstPortsMapped; 539 for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
599 PortN<p->RIOLastPortsMapped+PORTS_PER_RTA; PortN++ ) { 540 if (p->RIOPortp[PortN]->HostP == HostP) {
600 if ( p->RIOPortp[PortN]->HostP == HostP ) {
601 struct Port *PortP = p->RIOPortp[PortN]; 541 struct Port *PortP = p->RIOPortp[PortN];
602 struct PHB *PhbP; 542 struct PHB *PhbP;
603 /* int oldspl; */ 543 /* int oldspl; */
604 544
605 if ( !PortP->Mapped ) 545 if (!PortP->Mapped)
606 continue; 546 continue;
607 547
608 PhbP = &HostP->PhbP[PortP->HostPort]; 548 PhbP = &HostP->PhbP[PortP->HostPort];
@@ -610,641 +550,522 @@ register struct DownLoad *rbp;
610 550
611 PortP->PhbP = PhbP; 551 PortP->PhbP = PhbP;
612 552
613 PortP->TxAdd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_add)); 553 PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add));
614 PortP->TxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_start)); 554 PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start));
615 PortP->TxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_end)); 555 PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end));
616 PortP->RxRemove = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_remove)); 556 PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
617 PortP->RxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_start)); 557 PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start));
618 PortP->RxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_end)); 558 PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end));
619 559
620 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 560 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
621 /* 561 /*
622 ** point the UnixRup at the base SysPort 562 ** point the UnixRup at the base SysPort
623 */ 563 */
624 if ( !(PortN % PORTS_PER_RTA) ) 564 if (!(PortN % PORTS_PER_RTA))
625 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN; 565 HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
626 } 566 }
627 } 567 }
628 568
629 rio_dprintk (RIO_DEBUG_BOOT, "Set the card running... \n"); 569 rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
630 /* 570 /*
631 ** last thing - show the world that everything is in place 571 ** last thing - show the world that everything is in place
632 */ 572 */
633 HostP->Flags &= ~RUN_STATE; 573 HostP->Flags &= ~RUN_STATE;
634 HostP->Flags |= RC_RUNNING; 574 HostP->Flags |= RC_RUNNING;
635 } 575 }
636 /* 576 /*
637 ** MPX always uses a poller. This is actually patched into the system 577 ** MPX always uses a poller. This is actually patched into the system
638 ** configuration and called directly from each clock tick. 578 ** configuration and called directly from each clock tick.
639 ** 579 **
640 */ 580 */
641 p->RIOPolling = 1; 581 p->RIOPolling = 1;
642 582
643 p->RIOSystemUp++; 583 p->RIOSystemUp++;
644 584
645 rio_dprintk (RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec); 585 rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
646 func_exit (); 586 func_exit();
647 return 0; 587 return 0;
648} 588}
649 589
650 590
651 591
652/* 592/**
653** Boot an RTA. If we have successfully processed this boot, then 593 * RIOBootRup - Boot an RTA
654** return 1. If we havent, then return 0. 594 * @p: rio we are working with
655*/ 595 * @Rup: Rup number
656int 596 * @HostP: host object
657RIOBootRup( p, Rup, HostP, PacketP) 597 * @PacketP: packet to use
658struct rio_info * p; 598 *
659uint Rup; 599 * If we have successfully processed this boot, then
660struct Host *HostP; 600 * return 1. If we havent, then return 0.
661struct PKT *PacketP; 601 */
602
603int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP)
662{ 604{
663 struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data; 605 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
664 struct PktCmd_M *PktReplyP; 606 struct PktCmd_M *PktReplyP;
665 struct CmdBlk *CmdBlkP; 607 struct CmdBlk *CmdBlkP;
666 uint sequence; 608 unsigned int sequence;
667 609
668 /* 610 /*
669 ** If we haven't been told what to boot, we can't boot it. 611 ** If we haven't been told what to boot, we can't boot it.
670 */ 612 */
671 if ( p->RIONumBootPkts == 0 ) { 613 if (p->RIONumBootPkts == 0) {
672 rio_dprintk (RIO_DEBUG_BOOT, "No RTA code to download yet\n"); 614 rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
673 return 0; 615 return 0;
674 } 616 }
675 617
676 /* rio_dprint(RIO_DEBUG_BOOT, NULL,DBG_BOOT,"Incoming command packet\n"); */
677 /* ShowPacket( DBG_BOOT, PacketP ); */
678
679 /* 618 /*
680 ** Special case of boot completed - if we get one of these then we 619 ** Special case of boot completed - if we get one of these then we
681 ** don't need a command block. For all other cases we do, so handle 620 ** don't need a command block. For all other cases we do, so handle
682 ** this first and then get a command block, then handle every other 621 ** this first and then get a command block, then handle every other
683 ** case, relinquishing the command block if disaster strikes! 622 ** case, relinquishing the command block if disaster strikes!
684 */ 623 */
685 if ( (RBYTE(PacketP->len) & PKT_CMD_BIT) && 624 if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
686 (RBYTE(PktCmdP->Command)==BOOT_COMPLETED) ) 625 return RIOBootComplete(p, HostP, Rup, PktCmdP);
687 return RIOBootComplete(p, HostP, Rup, PktCmdP );
688 626
689 /* 627 /*
690 ** try to unhook a command block from the command free list. 628 ** Try to allocate a command block. This is in kernel space
691 */ 629 */
692 if ( !(CmdBlkP = RIOGetCmdBlk()) ) { 630 if (!(CmdBlkP = RIOGetCmdBlk())) {
693 rio_dprintk (RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n"); 631 rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
694 return 0; 632 return 0;
695 } 633 }
696 634
697 /* 635 /*
698 ** Fill in the default info on the command block 636 ** Fill in the default info on the command block
699 */ 637 */
700 CmdBlkP->Packet.dest_unit = Rup < (ushort)MAX_RUP ? Rup : 0; 638 CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
701 CmdBlkP->Packet.dest_port = BOOT_RUP; 639 CmdBlkP->Packet.dest_port = BOOT_RUP;
702 CmdBlkP->Packet.src_unit = 0; 640 CmdBlkP->Packet.src_unit = 0;
703 CmdBlkP->Packet.src_port = BOOT_RUP; 641 CmdBlkP->Packet.src_port = BOOT_RUP;
704 642
705 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL; 643 CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
706 PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data; 644 PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
707 645
708 /* 646 /*
709 ** process COMMANDS on the boot rup! 647 ** process COMMANDS on the boot rup!
710 */ 648 */
711 if ( RBYTE(PacketP->len) & PKT_CMD_BIT ) { 649 if (readb(&PacketP->len) & PKT_CMD_BIT) {
712 /* 650 /*
713 ** We only expect one type of command - a BOOT_REQUEST! 651 ** We only expect one type of command - a BOOT_REQUEST!
714 */ 652 */
715 if ( RBYTE(PktCmdP->Command) != BOOT_REQUEST ) { 653 if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
716 rio_dprintk (RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %d\n", 654 rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
717 PktCmdP->Command,Rup,HostP-p->RIOHosts); 655 RIOFreeCmdBlk(CmdBlkP);
718 ShowPacket( DBG_BOOT, PacketP );
719 RIOFreeCmdBlk( CmdBlkP );
720 return 1; 656 return 1;
721 } 657 }
722 658
723 /* 659 /*
724 ** Build a Boot Sequence command block 660 ** Build a Boot Sequence command block
725 ** 661 **
726 ** 02.03.1999 ARG - ESIL 0820 fix 662 ** We no longer need to use "Boot Mode", we'll always allow
727 ** We no longer need to use "Boot Mode", we'll always allow 663 ** boot requests - the boot will not complete if the device
728 ** boot requests - the boot will not complete if the device 664 ** appears in the bindings table.
729 ** appears in the bindings table. 665 **
730 ** So, this conditional is not required ... 666 ** We'll just (always) set the command field in packet reply
731 ** 667 ** to allow an attempted boot sequence :
732 if (p->RIOBootMode == RC_BOOT_NONE) 668 */
733 **
734 ** If the system is in slave mode, and a boot request is
735 ** received, set command to BOOT_ABORT so that the boot
736 ** will not complete.
737 **
738 PktReplyP->Command = BOOT_ABORT;
739 else
740 **
741 ** We'll just (always) set the command field in packet reply
742 ** to allow an attempted boot sequence :
743 */
744 PktReplyP->Command = BOOT_SEQUENCE; 669 PktReplyP->Command = BOOT_SEQUENCE;
745 670
746 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts; 671 PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
747 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase; 672 PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
748 PktReplyP->BootSequence.CodeSize = p->RIOBootCount; 673 PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
749 674
750 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT; 675 CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
751 676
752 bcopy("BOOT",(void *)&CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN],4); 677 memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
753 678
754 rio_dprintk (RIO_DEBUG_BOOT, "Boot RTA on Host %d Rup %d - %d (0x%x) packets to 0x%x\n", 679 rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
755 HostP-p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts,
756 p->RIOConf.RtaLoadBase);
757 680
758 /* 681 /*
759 ** If this host is in slave mode, send the RTA an invalid boot 682 ** If this host is in slave mode, send the RTA an invalid boot
760 ** sequence command block to force it to kill the boot. We wait 683 ** sequence command block to force it to kill the boot. We wait
761 ** for half a second before sending this packet to prevent the RTA 684 ** for half a second before sending this packet to prevent the RTA
762 ** attempting to boot too often. The master host should then grab 685 ** attempting to boot too often. The master host should then grab
763 ** the RTA and make it its own. 686 ** the RTA and make it its own.
764 */ 687 */
765 p->RIOBooting++; 688 p->RIOBooting++;
766 RIOQueueCmdBlk( HostP, Rup, CmdBlkP ); 689 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
767 return 1; 690 return 1;
768 } 691 }
769 692
770 /* 693 /*
771 ** It is a request for boot data. 694 ** It is a request for boot data.
772 */ 695 */
773 sequence = RWORD(PktCmdP->Sequence); 696 sequence = readw(&PktCmdP->Sequence);
774 697
775 rio_dprintk (RIO_DEBUG_BOOT, "Boot block %d on Host %d Rup%d\n",sequence,HostP-p->RIOHosts,Rup); 698 rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
776 699
777 if ( sequence >= p->RIONumBootPkts ) { 700 if (sequence >= p->RIONumBootPkts) {
778 rio_dprintk (RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, 701 rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
779 p->RIONumBootPkts);
780 ShowPacket( DBG_BOOT, PacketP );
781 } 702 }
782 703
783 PktReplyP->Sequence = sequence; 704 PktReplyP->Sequence = sequence;
784 705 memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
785 bcopy( p->RIOBootPackets[ p->RIONumBootPkts - sequence - 1 ],
786 PktReplyP->BootData, RTA_BOOT_DATA_SIZE );
787
788 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN; 706 CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
789 ShowPacket( DBG_BOOT, &CmdBlkP->Packet ); 707 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
790 RIOQueueCmdBlk( HostP, Rup, CmdBlkP );
791 return 1; 708 return 1;
792} 709}
793 710
794/* 711/**
795** This function is called when an RTA been booted. 712 * RIOBootComplete - RTA boot is done
796** If booted by a host, HostP->HostUniqueNum is the booting host. 713 * @p: RIO we are working with
797** If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA. 714 * @HostP: Host structure
798** RtaUniq is the booted RTA. 715 * @Rup: RUP being used
799*/ 716 * @PktCmdP: Packet command that was used
800static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP ) 717 *
718 * This function is called when an RTA been booted.
719 * If booted by a host, HostP->HostUniqueNum is the booting host.
720 * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
721 * RtaUniq is the booted RTA.
722 */
723
724static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP)
801{ 725{
802 struct Map *MapP = NULL; 726 struct Map *MapP = NULL;
803 struct Map *MapP2 = NULL; 727 struct Map *MapP2 = NULL;
804 int Flag; 728 int Flag;
805 int found; 729 int found;
806 int host, rta; 730 int host, rta;
807 int EmptySlot = -1; 731 int EmptySlot = -1;
808 int entry, entry2; 732 int entry, entry2;
809 char *MyType, *MyName; 733 char *MyType, *MyName;
810 uint MyLink; 734 unsigned int MyLink;
811 ushort RtaType; 735 unsigned short RtaType;
812 uint RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + 736 u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
813 (RBYTE(PktCmdP->UniqNum[1]) << 8) + 737
814 (RBYTE(PktCmdP->UniqNum[2]) << 16) +
815 (RBYTE(PktCmdP->UniqNum[3]) << 24);
816
817 /* Was RIOBooting-- . That's bad. If an RTA sends two of them, the
818 driver will never think that the RTA has booted... -- REW */
819 p->RIOBooting = 0; 738 p->RIOBooting = 0;
820 739
821 rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting); 740 rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
822 741
823 /* 742 /*
824 ** Determine type of unit (16/8 port RTA). 743 ** Determine type of unit (16/8 port RTA).
825 */ 744 */
745
826 RtaType = GetUnitType(RtaUniq); 746 RtaType = GetUnitType(RtaUniq);
827 if ( Rup >= (ushort)MAX_RUP ) { 747 if (Rup >= (unsigned short) MAX_RUP)
828 rio_dprintk (RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", 748 rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
829 HostP->Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum)+'A'); 749 else
830 } else { 750 rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
831 rio_dprintk (RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n",
832 HostP->Mapping[Rup].Name, 8 * RtaType,
833 RBYTE(PktCmdP->LinkNum)+'A');
834 }
835 751
836 rio_dprintk (RIO_DEBUG_BOOT, "UniqNum is 0x%x\n",RtaUniq); 752 rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
837 753
838 if ( ( RtaUniq == 0x00000000 ) || ( RtaUniq == 0xffffffff ) ) 754 if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
839 { 755 rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
840 rio_dprintk (RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); 756 return 1;
841 return TRUE;
842 } 757 }
843 758
844 /* 759 /*
845 ** If this RTA has just booted an RTA which doesn't belong to this 760 ** If this RTA has just booted an RTA which doesn't belong to this
846 ** system, or the system is in slave mode, do not attempt to create 761 ** system, or the system is in slave mode, do not attempt to create
847 ** a new table entry for it. 762 ** a new table entry for it.
848 */ 763 */
849 if (!RIOBootOk(p, HostP, RtaUniq)) 764
850 { 765 if (!RIOBootOk(p, HostP, RtaUniq)) {
851 MyLink = RBYTE(PktCmdP->LinkNum); 766 MyLink = readb(&PktCmdP->LinkNum);
852 if (Rup < (ushort) MAX_RUP) 767 if (Rup < (unsigned short) MAX_RUP) {
853 { 768 /*
854 /* 769 ** RtaUniq was clone booted (by this RTA). Instruct this RTA
855 ** RtaUniq was clone booted (by this RTA). Instruct this RTA 770 ** to hold off further attempts to boot on this link for 30
856 ** to hold off further attempts to boot on this link for 30 771 ** seconds.
857 ** seconds. 772 */
858 */ 773 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
859 if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) 774 rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
860 { 775 }
861 rio_dprintk (RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 776 } else
862 'A' + MyLink); 777 /*
863 } 778 ** RtaUniq was booted by this host. Set the booting link
864 } 779 ** to hold off for 30 seconds to give another unit a
865 else 780 ** chance to boot it.
866 { 781 */
867 /* 782 writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
868 ** RtaUniq was booted by this host. Set the booting link 783 rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
869 ** to hold off for 30 seconds to give another unit a 784 return 1;
870 ** chance to boot it.
871 */
872 WWORD(HostP->LinkStrP[MyLink].WaitNoBoot, 30);
873 }
874 rio_dprintk (RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n",
875 RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
876 return TRUE;
877 } 785 }
878 786
879 /* 787 /*
880 ** Check for a SLOT_IN_USE entry for this RTA attached to the 788 ** Check for a SLOT_IN_USE entry for this RTA attached to the
881 ** current host card in the driver table. 789 ** current host card in the driver table.
882 ** 790 **
883 ** If it exists, make a note that we have booted it. Other parts of 791 ** If it exists, make a note that we have booted it. Other parts of
884 ** the driver are interested in this information at a later date, 792 ** the driver are interested in this information at a later date,
885 ** in particular when the booting RTA asks for an ID for this unit, 793 ** in particular when the booting RTA asks for an ID for this unit,
886 ** we must have set the BOOTED flag, and the NEWBOOT flag is used 794 ** we must have set the BOOTED flag, and the NEWBOOT flag is used
887 ** to force an open on any ports that where previously open on this 795 ** to force an open on any ports that where previously open on this
888 ** unit. 796 ** unit.
889 */ 797 */
890 for ( entry=0; entry<MAX_RUP; entry++ ) 798 for (entry = 0; entry < MAX_RUP; entry++) {
891 { 799 unsigned int sysport;
892 uint sysport; 800
893 801 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
894 if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && 802 HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
895 (HostP->Mapping[entry].RtaUniqueNum==RtaUniq)) 803 if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
896 { 804 if (sysport < p->RIOFirstPortsBooted)
897 HostP->Mapping[entry].Flags |= RTA_BOOTED|RTA_NEWBOOT; 805 p->RIOFirstPortsBooted = sysport;
898#ifdef NEED_TO_FIX 806 if (sysport > p->RIOLastPortsBooted)
899 RIO_SV_BROADCAST(HostP->svFlags[entry]); 807 p->RIOLastPortsBooted = sysport;
900#endif 808 /*
901 if ( (sysport=HostP->Mapping[entry].SysPort) != NO_PORT ) 809 ** For a 16 port RTA, check the second bank of 8 ports
902 { 810 */
903 if ( sysport < p->RIOFirstPortsBooted ) 811 if (RtaType == TYPE_RTA16) {
904 p->RIOFirstPortsBooted = sysport; 812 entry2 = HostP->Mapping[entry].ID2 - 1;
905 if ( sysport > p->RIOLastPortsBooted ) 813 HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
906 p->RIOLastPortsBooted = sysport; 814 sysport = HostP->Mapping[entry2].SysPort;
907 /* 815 if (sysport < p->RIOFirstPortsBooted)
908 ** For a 16 port RTA, check the second bank of 8 ports 816 p->RIOFirstPortsBooted = sysport;
909 */ 817 if (sysport > p->RIOLastPortsBooted)
910 if (RtaType == TYPE_RTA16) 818 p->RIOLastPortsBooted = sysport;
911 { 819 }
912 entry2 = HostP->Mapping[entry].ID2 - 1; 820 }
913 HostP->Mapping[entry2].Flags |= RTA_BOOTED|RTA_NEWBOOT; 821 if (RtaType == TYPE_RTA16)
914#ifdef NEED_TO_FIX 822 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
915 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 823 else
916#endif 824 rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
917 sysport = HostP->Mapping[entry2].SysPort; 825 return 1;
918 if ( sysport < p->RIOFirstPortsBooted )
919 p->RIOFirstPortsBooted = sysport;
920 if ( sysport > p->RIOLastPortsBooted )
921 p->RIOLastPortsBooted = sysport;
922 }
923 }
924 if (RtaType == TYPE_RTA16) {
925 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n",
926 entry+1, entry2+1);
927 } else {
928 rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given ID %d\n",entry+1);
929 } 826 }
930 return TRUE;
931 }
932 } 827 }
933 828
934 rio_dprintk (RIO_DEBUG_BOOT, "RTA not configured for this host\n"); 829 rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
935 830
936 if ( Rup >= (ushort)MAX_RUP ) 831 if (Rup >= (unsigned short) MAX_RUP) {
937 { 832 /*
938 /* 833 ** It was a host that did the booting
939 ** It was a host that did the booting 834 */
940 */ 835 MyType = "Host";
941 MyType = "Host"; 836 MyName = HostP->Name;
942 MyName = HostP->Name; 837 } else {
943 } 838 /*
944 else 839 ** It was an RTA that did the booting
945 { 840 */
946 /* 841 MyType = "RTA";
947 ** It was an RTA that did the booting 842 MyName = HostP->Mapping[Rup].Name;
948 */
949 MyType = "RTA";
950 MyName = HostP->Mapping[Rup].Name;
951 } 843 }
952 MyLink = RBYTE(PktCmdP->LinkNum); 844 MyLink = readb(&PktCmdP->LinkNum);
953 845
954 /* 846 /*
955 ** There is no SLOT_IN_USE entry for this RTA attached to the current 847 ** There is no SLOT_IN_USE entry for this RTA attached to the current
956 ** host card in the driver table. 848 ** host card in the driver table.
957 ** 849 **
958 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the 850 ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
959 ** current host card in the driver table. 851 ** current host card in the driver table.
960 ** 852 **
961 ** If we find one, then we re-use that slot. 853 ** If we find one, then we re-use that slot.
962 */ 854 */
963 for ( entry=0; entry<MAX_RUP; entry++ ) 855 for (entry = 0; entry < MAX_RUP; entry++) {
964 { 856 if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
965 if ( (HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && 857 if (RtaType == TYPE_RTA16) {
966 (HostP->Mapping[entry].RtaUniqueNum == RtaUniq) ) 858 entry2 = HostP->Mapping[entry].ID2 - 1;
967 { 859 if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
968 if (RtaType == TYPE_RTA16) 860 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
969 { 861 else
970 entry2 = HostP->Mapping[entry].ID2 - 1; 862 continue;
971 if ( (HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && 863 } else
972 (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq) ) 864 rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
973 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", 865 if (!p->RIONoMessage)
974 entry, entry2); 866 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
975 else 867 return 1;
976 continue;
977 } 868 }
978 else
979 rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n",entry);
980 if (! p->RIONoMessage)
981 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
982 return TRUE;
983 }
984 } 869 }
985 870
986 /* 871 /*
987 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 872 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
988 ** attached to the current host card in the driver table. 873 ** attached to the current host card in the driver table.
989 ** 874 **
990 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another 875 ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
991 ** host for this RTA in the driver table. 876 ** host for this RTA in the driver table.
992 ** 877 **
993 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA 878 ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
994 ** entry from the other host and add it to this host (using some of 879 ** entry from the other host and add it to this host (using some of
995 ** the functions from table.c which do this). 880 ** the functions from table.c which do this).
996 ** For a SLOT_TENTATIVE entry on another host, we must cope with the 881 ** For a SLOT_TENTATIVE entry on another host, we must cope with the
997 ** following scenario: 882 ** following scenario:
998 ** 883 **
999 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry 884 ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
1000 ** in table) 885 ** in table)
1001 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE 886 ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
1002 ** entries) 887 ** entries)
1003 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) 888 ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
1004 ** + Unplug RTA and plug back into host A. 889 ** + Unplug RTA and plug back into host A.
1005 ** + Configure RTA on host A. We now have the same RTA configured 890 ** + Configure RTA on host A. We now have the same RTA configured
1006 ** with different ports on two different hosts. 891 ** with different ports on two different hosts.
1007 */ 892 */
1008 rio_dprintk (RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq ); 893 rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
1009 found = 0; 894 found = 0;
1010 Flag = 0; /* Convince the compiler this variable is initialized */ 895 Flag = 0; /* Convince the compiler this variable is initialized */
1011 for ( host = 0; !found && (host < p->RIONumHosts); host++ ) 896 for (host = 0; !found && (host < p->RIONumHosts); host++) {
1012 { 897 for (rta = 0; rta < MAX_RUP; rta++) {
1013 for ( rta=0; rta<MAX_RUP; rta++ ) 898 if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
1014 { 899 Flag = p->RIOHosts[host].Mapping[rta].Flags;
1015 if ((p->RIOHosts[host].Mapping[rta].Flags & 900 MapP = &p->RIOHosts[host].Mapping[rta];
1016 (SLOT_IN_USE | SLOT_TENTATIVE)) && 901 if (RtaType == TYPE_RTA16) {
1017 (p->RIOHosts[host].Mapping[rta].RtaUniqueNum==RtaUniq)) 902 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
1018 { 903 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
1019 Flag = p->RIOHosts[host].Mapping[rta].Flags; 904 } else
1020 MapP = &p->RIOHosts[host].Mapping[rta]; 905 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
1021 if (RtaType == TYPE_RTA16) 906 found = 1;
1022 { 907 break;
1023 MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; 908 }
1024 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n",
1025 rta+1, MapP->ID2, p->RIOHosts[host].Name);
1026 }
1027 else
1028 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n",
1029 rta+1, p->RIOHosts[host].Name);
1030 found = 1;
1031 break;
1032 } 909 }
1033 }
1034 } 910 }
1035 911
1036 /* 912 /*
1037 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 913 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1038 ** attached to the current host card in the driver table. 914 ** attached to the current host card in the driver table.
1039 ** 915 **
1040 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on 916 ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
1041 ** another host for this RTA in the driver table... 917 ** another host for this RTA in the driver table...
1042 ** 918 **
1043 ** Check for a SLOT_IN_USE entry for this RTA in the config table. 919 ** Check for a SLOT_IN_USE entry for this RTA in the config table.
1044 */ 920 */
1045 if ( !MapP ) 921 if (!MapP) {
1046 { 922 rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
1047 rio_dprintk (RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n",RtaUniq); 923 for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
1048 for ( rta=0; rta < TOTAL_MAP_ENTRIES; rta++ ) 924 rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
1049 { 925
1050 rio_dprintk (RIO_DEBUG_BOOT, "Check table entry %d (%x)", 926 if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
1051 rta, 927 MapP = &p->RIOSavedTable[rta];
1052 p->RIOSavedTable[rta].RtaUniqueNum); 928 Flag = p->RIOSavedTable[rta].Flags;
1053 929 if (RtaType == TYPE_RTA16) {
1054 if ( (p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && 930 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
1055 (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq) ) 931 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1056 { 932 break;
1057 MapP = &p->RIOSavedTable[rta]; 933 }
1058 Flag = p->RIOSavedTable[rta].Flags; 934 MapP2 = &p->RIOSavedTable[entry2];
1059 if (RtaType == TYPE_RTA16) 935 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
1060 { 936 } else
1061 for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; 937 rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1062 entry2++) 938 break;
1063 { 939 }
1064 if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
1065 break;
1066 }
1067 MapP2 = &p->RIOSavedTable[entry2];
1068 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n",
1069 rta, entry2);
1070 }
1071 else
1072 rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
1073 break;
1074 } 940 }
1075 }
1076 } 941 }
1077 942
1078 /* 943 /*
1079 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 944 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1080 ** attached to the current host card in the driver table. 945 ** attached to the current host card in the driver table.
1081 ** 946 **
1082 ** We may have found a SLOT_IN_USE entry on another host for this 947 ** We may have found a SLOT_IN_USE entry on another host for this
1083 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry 948 ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
1084 ** on another host for this RTA in the driver table. 949 ** on another host for this RTA in the driver table.
1085 ** 950 **
1086 ** Check the driver table for room to fit this newly discovered RTA. 951 ** Check the driver table for room to fit this newly discovered RTA.
1087 ** RIOFindFreeID() first looks for free slots and if it does not 952 ** RIOFindFreeID() first looks for free slots and if it does not
1088 ** find any free slots it will then attempt to oust any 953 ** find any free slots it will then attempt to oust any
1089 ** tentative entry in the table. 954 ** tentative entry in the table.
1090 */ 955 */
1091 EmptySlot = 1; 956 EmptySlot = 1;
1092 if (RtaType == TYPE_RTA16) 957 if (RtaType == TYPE_RTA16) {
1093 { 958 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
1094 if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) 959 RIODefaultName(p, HostP, entry);
1095 { 960 rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
1096 RIODefaultName(p, HostP, entry); 961 EmptySlot = 0;
1097 FillSlot(entry, entry2, RtaUniq, HostP); 962 }
1098 EmptySlot = 0; 963 } else {
1099 } 964 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
1100 } 965 RIODefaultName(p, HostP, entry);
1101 else 966 rio_fill_host_slot(entry, 0, RtaUniq, HostP);
1102 { 967 EmptySlot = 0;
1103 if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) 968 }
1104 {
1105 RIODefaultName(p, HostP, entry);
1106 FillSlot(entry, 0, RtaUniq, HostP);
1107 EmptySlot = 0;
1108 }
1109 } 969 }
1110 970
1111 /* 971 /*
1112 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA 972 ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
1113 ** attached to the current host card in the driver table. 973 ** attached to the current host card in the driver table.
1114 ** 974 **
1115 ** If we found a SLOT_IN_USE entry on another host for this 975 ** If we found a SLOT_IN_USE entry on another host for this
1116 ** RTA in the config or driver table, and there are enough free 976 ** RTA in the config or driver table, and there are enough free
1117 ** slots in the driver table, then we need to move it over and 977 ** slots in the driver table, then we need to move it over and
1118 ** delete it from the other host. 978 ** delete it from the other host.
1119 ** If we found a SLOT_TENTATIVE entry on another host for this 979 ** If we found a SLOT_TENTATIVE entry on another host for this
1120 ** RTA in the driver table, just delete the other host entry. 980 ** RTA in the driver table, just delete the other host entry.
1121 */ 981 */
1122 if (EmptySlot == 0) 982 if (EmptySlot == 0) {
1123 { 983 if (MapP) {
1124 if ( MapP ) 984 if (Flag & SLOT_IN_USE) {
1125 { 985 rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
1126 if (Flag & SLOT_IN_USE) 986 HostP->Mapping[entry].SysPort = MapP->SysPort;
1127 { 987 memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
1128 rio_dprintk (RIO_DEBUG_BOOT, 988 HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
1129 "This RTA configured on another host - move entry to current host (1)\n"); 989 RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
1130 HostP->Mapping[entry].SysPort = MapP->SysPort; 990 if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
1131 CCOPY( MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN ); 991 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
1132 HostP->Mapping[entry].Flags = 992 if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
1133 SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; 993 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
1134#ifdef NEED_TO_FIX 994 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
1135 RIO_SV_BROADCAST(HostP->svFlags[entry]); 995 } else {
1136#endif 996 rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
1137 RIOReMapPorts( p, HostP, &HostP->Mapping[entry] ); 997 HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
1138 if ( HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted ) 998 }
1139 p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; 999 if (RtaType == TYPE_RTA16) {
1140 if ( HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted ) 1000 if (Flag & SLOT_IN_USE) {
1141 p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; 1001 HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1142 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",(int)MapP->SysPort,MapP->Name); 1002 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1143 } 1003 /*
1144 else 1004 ** Map second block of ttys for 16 port RTA
1145 { 1005 */
1146 rio_dprintk (RIO_DEBUG_BOOT, 1006 RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
1147 "This RTA has a tentative entry on another host - delete that entry (1)\n"); 1007 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1148 HostP->Mapping[entry].Flags = 1008 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1149 SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; 1009 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1150#ifdef NEED_TO_FIX 1010 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1151 RIO_SV_BROADCAST(HostP->svFlags[entry]); 1011 rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
1152#endif 1012 } else
1153 } 1013 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1154 if (RtaType == TYPE_RTA16) 1014 memset(MapP2, 0, sizeof(struct Map));
1155 { 1015 }
1156 if (Flag & SLOT_IN_USE) 1016 memset(MapP, 0, sizeof(struct Map));
1157 { 1017 if (!p->RIONoMessage)
1158 HostP->Mapping[entry2].Flags = SLOT_IN_USE | 1018 printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
1159 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; 1019 } else if (!p->RIONoMessage)
1160#ifdef NEED_TO_FIX 1020 printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
1161 RIO_SV_BROADCAST(HostP->svFlags[entry2]); 1021 RIOSetChange(p);
1162#endif 1022 return 1;
1163 HostP->Mapping[entry2].SysPort = MapP2->SysPort;
1164 /*
1165 ** Map second block of ttys for 16 port RTA
1166 */
1167 RIOReMapPorts( p, HostP, &HostP->Mapping[entry2] );
1168 if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
1169 p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
1170 if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
1171 p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
1172 rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",
1173 (int)HostP->Mapping[entry2].SysPort,
1174 HostP->Mapping[entry].Name);
1175 }
1176 else
1177 HostP->Mapping[entry2].Flags = SLOT_TENTATIVE |
1178 RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
1179#ifdef NEED_TO_FIX
1180 RIO_SV_BROADCAST(HostP->svFlags[entry2]);
1181#endif
1182 bzero( (caddr_t)MapP2, sizeof(struct Map) );
1183 }
1184 bzero( (caddr_t)MapP, sizeof(struct Map) );
1185 if (! p->RIONoMessage)
1186 cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n",MyType,MyName,MyLink+'A');
1187 }
1188 else if (! p->RIONoMessage)
1189 cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
1190 RIOSetChange(p);
1191 return TRUE;
1192 } 1023 }
1193 1024
1194 /* 1025 /*
1195 ** There is no room in the driver table to make an entry for the 1026 ** There is no room in the driver table to make an entry for the
1196 ** booted RTA. Keep a note of its Uniq Num in the overflow table, 1027 ** booted RTA. Keep a note of its Uniq Num in the overflow table,
1197 ** so we can ignore it's ID requests. 1028 ** so we can ignore it's ID requests.
1198 */ 1029 */
1199 if (! p->RIONoMessage) 1030 if (!p->RIONoMessage)
1200 cprintf("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n",MyType,MyName,MyLink+'A'); 1031 printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A');
1201 for ( entry=0; entry<HostP->NumExtraBooted; entry++ ) 1032 for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
1202 { 1033 if (HostP->ExtraUnits[entry] == RtaUniq) {
1203 if ( HostP->ExtraUnits[entry] == RtaUniq ) 1034 /*
1204 { 1035 ** already got it!
1205 /* 1036 */
1206 ** already got it! 1037 return 1;
1207 */ 1038 }
1208 return TRUE;
1209 }
1210 } 1039 }
1211 /* 1040 /*
1212 ** If there is room, add the unit to the list of extras 1041 ** If there is room, add the unit to the list of extras
1213 */ 1042 */
1214 if ( HostP->NumExtraBooted < MAX_EXTRA_UNITS ) 1043 if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
1215 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; 1044 HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
1216 return TRUE; 1045 return 1;
1217} 1046}
1218 1047
1219 1048
1220/* 1049/*
1221** If the RTA or its host appears in the RIOBindTab[] structure then 1050** If the RTA or its host appears in the RIOBindTab[] structure then
1222** we mustn't boot the RTA and should return FALSE. 1051** we mustn't boot the RTA and should return 0.
1223** This operation is slightly different from the other drivers for RIO 1052** This operation is slightly different from the other drivers for RIO
1224** in that this is designed to work with the new utilities 1053** in that this is designed to work with the new utilities
1225** not config.rio and is FAR SIMPLER. 1054** not config.rio and is FAR SIMPLER.
1226** We no longer support the RIOBootMode variable. It is all done from the 1055** We no longer support the RIOBootMode variable. It is all done from the
1227** "boot/noboot" field in the rio.cf file. 1056** "boot/noboot" field in the rio.cf file.
1228*/ 1057*/
1229int 1058int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
1230RIOBootOk(p, HostP, RtaUniq)
1231struct rio_info * p;
1232struct Host * HostP;
1233ulong RtaUniq;
1234{ 1059{
1235 int Entry; 1060 int Entry;
1236 uint HostUniq = HostP->UniqueNum; 1061 unsigned int HostUniq = HostP->UniqueNum;
1237 1062
1238 /* 1063 /*
1239 ** Search bindings table for RTA or its parent. 1064 ** Search bindings table for RTA or its parent.
1240 ** If it exists, return 0, else 1. 1065 ** If it exists, return 0, else 1.
1241 */ 1066 */
1242 for (Entry = 0; 1067 for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
1243 ( Entry < MAX_RTA_BINDINGS ) && ( p->RIOBindTab[Entry] != 0 ); 1068 if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
1244 Entry++)
1245 {
1246 if ( (p->RIOBindTab[Entry] == HostUniq) ||
1247 (p->RIOBindTab[Entry] == RtaUniq) )
1248 return 0; 1069 return 0;
1249 } 1070 }
1250 return 1; 1071 return 1;
@@ -1255,45 +1076,38 @@ ulong RtaUniq;
1255** slots tentative, and the second one RTA_SECOND_SLOT as well. 1076** slots tentative, and the second one RTA_SECOND_SLOT as well.
1256*/ 1077*/
1257 1078
1258void 1079void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
1259FillSlot(entry, entry2, RtaUniq, HostP)
1260int entry;
1261int entry2;
1262uint RtaUniq;
1263struct Host *HostP;
1264{ 1080{
1265 int link; 1081 int link;
1266 1082
1267 rio_dprintk (RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq); 1083 rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
1268 1084
1269 HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); 1085 host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
1270 HostP->Mapping[entry].SysPort = NO_PORT; 1086 host->Mapping[entry].SysPort = NO_PORT;
1271 HostP->Mapping[entry].RtaUniqueNum = RtaUniq; 1087 host->Mapping[entry].RtaUniqueNum = rta_uniq;
1272 HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum; 1088 host->Mapping[entry].HostUniqueNum = host->UniqueNum;
1273 HostP->Mapping[entry].ID = entry + 1; 1089 host->Mapping[entry].ID = entry + 1;
1274 HostP->Mapping[entry].ID2 = 0; 1090 host->Mapping[entry].ID2 = 0;
1275 if (entry2) { 1091 if (entry2) {
1276 HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | 1092 host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
1277 SLOT_TENTATIVE | RTA16_SECOND_SLOT); 1093 host->Mapping[entry2].SysPort = NO_PORT;
1278 HostP->Mapping[entry2].SysPort = NO_PORT; 1094 host->Mapping[entry2].RtaUniqueNum = rta_uniq;
1279 HostP->Mapping[entry2].RtaUniqueNum = RtaUniq; 1095 host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
1280 HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum; 1096 host->Mapping[entry2].Name[0] = '\0';
1281 HostP->Mapping[entry2].Name[0] = '\0'; 1097 host->Mapping[entry2].ID = entry2 + 1;
1282 HostP->Mapping[entry2].ID = entry2 + 1; 1098 host->Mapping[entry2].ID2 = entry + 1;
1283 HostP->Mapping[entry2].ID2 = entry + 1; 1099 host->Mapping[entry].ID2 = entry2 + 1;
1284 HostP->Mapping[entry].ID2 = entry2 + 1;
1285 } 1100 }
1286 /* 1101 /*
1287 ** Must set these up, so that utilities show 1102 ** Must set these up, so that utilities show
1288 ** topology of 16 port RTAs correctly 1103 ** topology of 16 port RTAs correctly
1289 */ 1104 */
1290 for ( link=0; link<LINKS_PER_UNIT; link++ ) { 1105 for (link = 0; link < LINKS_PER_UNIT; link++) {
1291 HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; 1106 host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
1292 HostP->Mapping[entry].Topology[link].Link = NO_LINK; 1107 host->Mapping[entry].Topology[link].Link = NO_LINK;
1293 if (entry2) { 1108 if (entry2) {
1294 HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; 1109 host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
1295 HostP->Mapping[entry2].Topology[link].Link = NO_LINK; 1110 host->Mapping[entry2].Topology[link].Link = NO_LINK;
1296 } 1111 }
1297 } 1112 }
1298} 1113}
1299
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 694bfb9d9378..e6d2b14b5e65 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -42,6 +42,7 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/string.h> 43#include <asm/string.h>
44#include <asm/semaphore.h> 44#include <asm/semaphore.h>
45#include <asm/uaccess.h>
45 46
46#include <linux/termios.h> 47#include <linux/termios.h>
47#include <linux/serial.h> 48#include <linux/serial.h>
@@ -50,15 +51,12 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
50 51
51#include "linux_compat.h" 52#include "linux_compat.h"
52#include "rio_linux.h" 53#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 54#include "pkt.h"
55#include "daemon.h" 55#include "daemon.h"
56#include "rio.h" 56#include "rio.h"
57#include "riospace.h" 57#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 58#include "cmdpkt.h"
60#include "map.h" 59#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 60#include "rup.h"
63#include "port.h" 61#include "port.h"
64#include "riodrvr.h" 62#include "riodrvr.h"
@@ -71,12 +69,10 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
71#include "unixrup.h" 69#include "unixrup.h"
72#include "board.h" 70#include "board.h"
73#include "host.h" 71#include "host.h"
74#include "error.h"
75#include "phb.h" 72#include "phb.h"
76#include "link.h" 73#include "link.h"
77#include "cmdblk.h" 74#include "cmdblk.h"
78#include "route.h" 75#include "route.h"
79#include "control.h"
80#include "cirrus.h" 76#include "cirrus.h"
81 77
82 78
@@ -143,17 +139,17 @@ int RIOZombieRta(struct Host *HostP, struct Map *MapP)
143 return 0; 139 return 0;
144} 140}
145 141
146int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP)) 142int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
147{ 143{
148 uint Host; 144 unsigned int Host;
149 145
150 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func); 146 rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
151 147
152 if (!RtaUnique) 148 if (!RtaUnique)
153 return (0); 149 return (0);
154 150
155 for (Host = 0; Host < p->RIONumHosts; Host++) { 151 for (Host = 0; Host < p->RIONumHosts; Host++) {
156 uint Rta; 152 unsigned int Rta;
157 struct Host *HostP = &p->RIOHosts[Host]; 153 struct Host *HostP = &p->RIOHosts[Host];
158 154
159 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 155 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -170,7 +166,7 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
170 ** any connections, we can get to it. 166 ** any connections, we can get to it.
171 */ 167 */
172 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 168 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
173 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 169 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
174 /* 170 /*
175 ** Its worth trying the operation... 171 ** Its worth trying the operation...
176 */ 172 */
@@ -184,18 +180,18 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
184} 180}
185 181
186 182
187int RIOIdentifyRta(struct rio_info *p, caddr_t arg) 183int RIOIdentifyRta(struct rio_info *p, void * arg)
188{ 184{
189 uint Host; 185 unsigned int Host;
190 186
191 if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) { 187 if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
192 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n"); 188 rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
193 p->RIOError.Error = COPYIN_FAILED; 189 p->RIOError.Error = COPYIN_FAILED;
194 return -EFAULT; 190 return -EFAULT;
195 } 191 }
196 192
197 for (Host = 0; Host < p->RIONumHosts; Host++) { 193 for (Host = 0; Host < p->RIONumHosts; Host++) {
198 uint Rta; 194 unsigned int Rta;
199 struct Host *HostP = &p->RIOHosts[Host]; 195 struct Host *HostP = &p->RIOHosts[Host];
200 196
201 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) { 197 for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -211,7 +207,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
211 ** any connections, we can get to it. 207 ** any connections, we can get to it.
212 */ 208 */
213 for (Link = 0; Link < LINKS_PER_UNIT; Link++) { 209 for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
214 if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) { 210 if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
215 /* 211 /*
216 ** Its worth trying the operation... 212 ** Its worth trying the operation...
217 */ 213 */
@@ -249,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
249} 245}
250 246
251 247
252int RIOKillNeighbour(struct rio_info *p, caddr_t arg) 248int RIOKillNeighbour(struct rio_info *p, void * arg)
253{ 249{
254 uint Host; 250 uint Host;
255 uint ID; 251 uint ID;
@@ -258,7 +254,7 @@ int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
258 254
259 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n"); 255 rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
260 256
261 if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) { 257 if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
262 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n"); 258 rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
263 p->RIOError.Error = COPYIN_FAILED; 259 p->RIOError.Error = COPYIN_FAILED;
264 return -EFAULT; 260 return -EFAULT;
@@ -344,7 +340,7 @@ int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
344int RIOFoadWakeup(struct rio_info *p) 340int RIOFoadWakeup(struct rio_info *p)
345{ 341{
346 int port; 342 int port;
347 register struct Port *PortP; 343 struct Port *PortP;
348 unsigned long flags; 344 unsigned long flags;
349 345
350 for (port = 0; port < RIO_PORTS; port++) { 346 for (port = 0; port < RIO_PORTS; port++) {
@@ -374,15 +370,15 @@ int RIOFoadWakeup(struct rio_info *p)
374/* 370/*
375** Incoming command on the COMMAND_RUP to be processed. 371** Incoming command on the COMMAND_RUP to be processed.
376*/ 372*/
377static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 373static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP)
378{ 374{
379 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 375 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
380 struct Port *PortP; 376 struct Port *PortP;
381 struct UnixRup *UnixRupP; 377 struct UnixRup *UnixRupP;
382 ushort SysPort; 378 unsigned short SysPort;
383 ushort ReportedModemStatus; 379 unsigned short ReportedModemStatus;
384 ushort rup; 380 unsigned short rup;
385 ushort subCommand; 381 unsigned short subCommand;
386 unsigned long flags; 382 unsigned long flags;
387 383
388 func_enter(); 384 func_enter();
@@ -395,18 +391,18 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
395 ** we can use PhbNum to get the rup number for the appropriate 8 port 391 ** we can use PhbNum to get the rup number for the appropriate 8 port
396 ** block (for the first block, this should be equal to 'Rup'). 392 ** block (for the first block, this should be equal to 'Rup').
397 */ 393 */
398 rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA; 394 rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA;
399 UnixRupP = &HostP->UnixRups[rup]; 395 UnixRupP = &HostP->UnixRups[rup];
400 SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA); 396 SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA);
401 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort); 397 rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
402 398
403 if (UnixRupP->BaseSysPort == NO_PORT) { 399 if (UnixRupP->BaseSysPort == NO_PORT) {
404 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n"); 400 rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
405 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n"); 401 rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); 402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
407 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); 403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
408 404
409 if (Rup >= (ushort) MAX_RUP) { 405 if (Rup >= (unsigned short) MAX_RUP) {
410 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); 406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
411 } else 407 } else
412 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);
@@ -417,16 +413,16 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
417 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", PacketP->control, PacketP->control);
418 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", PacketP->csum, PacketP->csum);
419 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", PktCmdP->PhbNum, PktCmdP->Command);
420 return TRUE; 416 return 1;
421 } 417 }
422 PortP = p->RIOPortp[SysPort]; 418 PortP = p->RIOPortp[SysPort];
423 rio_spin_lock_irqsave(&PortP->portSem, flags); 419 rio_spin_lock_irqsave(&PortP->portSem, flags);
424 switch (RBYTE(PktCmdP->Command)) { 420 switch (readb(&PktCmdP->Command)) {
425 case BREAK_RECEIVED: 421 case BREAK_RECEIVED:
426 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); 422 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
427 /* If the current line disc. is not multi-threading and 423 /* If the current line disc. is not multi-threading and
428 the current processor is not the default, reset rup_intr 424 the current processor is not the default, reset rup_intr
429 and return FALSE to ensure that the command packet is 425 and return 0 to ensure that the command packet is
430 not freed. */ 426 not freed. */
431 /* Call tmgr HANGUP HERE */ 427 /* Call tmgr HANGUP HERE */
432 /* Fix this later when every thing works !!!! RAMRAJ */ 428 /* Fix this later when every thing works !!!! RAMRAJ */
@@ -434,15 +430,15 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
434 break; 430 break;
435 431
436 case COMPLETE: 432 case COMPLETE:
437 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts); 433 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
438 subCommand = 1; 434 subCommand = 1;
439 switch (RBYTE(PktCmdP->SubCommand)) { 435 switch (readb(&PktCmdP->SubCommand)) {
440 case MEMDUMP: 436 case MEMDUMP:
441 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr)); 437 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
442 break; 438 break;
443 case READ_REGISTER: 439 case READ_REGISTER:
444 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr)); 440 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
445 p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST); 441 p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST);
446 break; 442 break;
447 default: 443 default:
448 subCommand = 0; 444 subCommand = 0;
@@ -450,10 +446,10 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
450 } 446 }
451 if (subCommand) 447 if (subCommand)
452 break; 448 break;
453 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState); 449 rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState);
454 if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) { 450 if (PortP->PortState != readb(&PktCmdP->PortStatus)) {
455 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n"); 451 rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
456 PortP->PortState = RBYTE(PktCmdP->PortStatus); 452 PortP->PortState = readb(&PktCmdP->PortStatus);
457 /* What should we do here ... 453 /* What should we do here ...
458 wakeup( &PortP->PortState ); 454 wakeup( &PortP->PortState );
459 */ 455 */
@@ -467,7 +463,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
467 ** to the check for modem status change (they're just there because 463 ** to the check for modem status change (they're just there because
468 ** it's a convenient place to put them!). 464 ** it's a convenient place to put them!).
469 */ 465 */
470 ReportedModemStatus = RBYTE(PktCmdP->ModemStatus); 466 ReportedModemStatus = readb(&PktCmdP->ModemStatus);
471 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) { 467 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
472 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); 468 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
473 /* 469 /*
@@ -514,9 +510,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
514 */ 510 */
515 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN)) 511 if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
516 wake_up_interruptible(&PortP->gs.open_wait); 512 wake_up_interruptible(&PortP->gs.open_wait);
517#ifdef STATS
518 PortP->Stat.ModemOnCnt++;
519#endif
520 } 513 }
521 } else { 514 } else {
522 /* 515 /*
@@ -527,9 +520,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
527 tty_hangup(PortP->gs.tty); 520 tty_hangup(PortP->gs.tty);
528 PortP->State &= ~RIO_CARR_ON; 521 PortP->State &= ~RIO_CARR_ON;
529 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n"); 522 rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
530#ifdef STATS
531 PortP->Stat.ModemOffCnt++;
532#endif
533 } 523 }
534 } 524 }
535 } 525 }
@@ -539,14 +529,14 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
539 break; 529 break;
540 530
541 default: 531 default:
542 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts); 532 rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts);
543 break; 533 break;
544 } 534 }
545 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 535 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
546 536
547 func_exit(); 537 func_exit();
548 538
549 return TRUE; 539 return 1;
550} 540}
551 541
552/* 542/*
@@ -566,10 +556,9 @@ struct CmdBlk *RIOGetCmdBlk(void)
566{ 556{
567 struct CmdBlk *CmdBlkP; 557 struct CmdBlk *CmdBlkP;
568 558
569 CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk)); 559 CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
570 if (CmdBlkP) 560 if (CmdBlkP)
571 bzero(CmdBlkP, sizeof(struct CmdBlk)); 561 memset(CmdBlkP, 0, sizeof(struct CmdBlk));
572
573 return CmdBlkP; 562 return CmdBlkP;
574} 563}
575 564
@@ -578,7 +567,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
578*/ 567*/
579void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP) 568void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
580{ 569{
581 sysfree((void *) CmdBlkP, sizeof(struct CmdBlk)); 570 kfree(CmdBlkP);
582} 571}
583 572
584/* 573/*
@@ -591,7 +580,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
591 struct UnixRup *UnixRupP; 580 struct UnixRup *UnixRupP;
592 unsigned long flags; 581 unsigned long flags;
593 582
594 if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) { 583 if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
595 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup); 584 rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
596 RIOFreeCmdBlk(CmdBlkP); 585 RIOFreeCmdBlk(CmdBlkP);
597 return RIO_FAIL; 586 return RIO_FAIL;
@@ -605,14 +594,14 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
605 ** If the RUP is currently inactive, then put the request 594 ** If the RUP is currently inactive, then put the request
606 ** straight on the RUP.... 595 ** straight on the RUP....
607 */ 596 */
608 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) 597 if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
609 : TRUE)) { 598 : 1)) {
610 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]); 599 rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
611 600
612 /* 601 /*
613 ** Whammy! blat that pack! 602 ** Whammy! blat that pack!
614 */ 603 */
615 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 604 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
616 605
617 /* 606 /*
618 ** place command packet on the pending position. 607 ** place command packet on the pending position.
@@ -622,11 +611,11 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
622 /* 611 /*
623 ** set the command register 612 ** set the command register
624 */ 613 */
625 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 614 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
626 615
627 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 616 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
628 617
629 return RIO_SUCCESS; 618 return 0;
630 } 619 }
631 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n"); 620 rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
632 621
@@ -634,20 +623,20 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
634 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n"); 623 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
635 if (UnixRupP->CmdPendingP != NULL) 624 if (UnixRupP->CmdPendingP != NULL)
636 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n"); 625 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
637 if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE) 626 if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
638 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n"); 627 rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
639 628
640 Base = &UnixRupP->CmdsWaitingP; 629 Base = &UnixRupP->CmdsWaitingP;
641 630
642 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 631 rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
643 632
644 while (*Base) { 633 while (*Base) {
645 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base)); 634 rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
646 Base = &((*Base)->NextP); 635 Base = &((*Base)->NextP);
647 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 636 rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
648 } 637 }
649 638
650 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base); 639 rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
651 640
652 *Base = CmdBlkP; 641 *Base = CmdBlkP;
653 642
@@ -655,7 +644,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
655 644
656 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 645 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
657 646
658 return RIO_SUCCESS; 647 return 0;
659} 648}
660 649
661/* 650/*
@@ -664,10 +653,10 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
664*/ 653*/
665void RIOPollHostCommands(struct rio_info *p, struct Host *HostP) 654void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
666{ 655{
667 register struct CmdBlk *CmdBlkP; 656 struct CmdBlk *CmdBlkP;
668 register struct UnixRup *UnixRupP; 657 struct UnixRup *UnixRupP;
669 struct PKT *PacketP; 658 struct PKT *PacketP;
670 ushort Rup; 659 unsigned short Rup;
671 unsigned long flags; 660 unsigned long flags;
672 661
673 662
@@ -684,16 +673,14 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
684 /* 673 /*
685 ** First check for incoming commands: 674 ** First check for incoming commands:
686 */ 675 */
687 if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) { 676 if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
688 int FreeMe; 677 int FreeMe;
689 678
690 PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt)); 679 PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
691 680
692 ShowPacket(DBG_CMD, PacketP); 681 switch (readb(&PacketP->dest_port)) {
693
694 switch (RBYTE(PacketP->dest_port)) {
695 case BOOT_RUP: 682 case BOOT_RUP:
696 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0])); 683 rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
697 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 684 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
698 FreeMe = RIOBootRup(p, Rup, HostP, PacketP); 685 FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
699 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 686 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -708,7 +695,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
708 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 695 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
709 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 696 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
710 if (PacketP->data[5] == MEMDUMP) { 697 if (PacketP->data[5] == MEMDUMP) {
711 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6])); 698 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6]));
712 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32); 699 HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
713 } 700 }
714 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags); 701 rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -721,7 +708,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
721 break; 708 break;
722 709
723 default: 710 default:
724 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port)); 711 rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
725 FreeMe = 1; 712 FreeMe = 1;
726 break; 713 break;
727 } 714 }
@@ -730,11 +717,11 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
730 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n"); 717 rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
731 put_free_end(HostP, PacketP); 718 put_free_end(HostP, PacketP);
732 719
733 WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE); 720 writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
734 721
735 if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) { 722 if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
736 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup); 723 rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
737 WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 724 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
738 } 725 }
739 } 726 }
740 } 727 }
@@ -744,7 +731,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
744 ** and it has completed, then tidy it up. 731 ** and it has completed, then tidy it up.
745 */ 732 */
746 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */ 733 if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
747 (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 734 (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
748 /* 735 /*
749 ** we are idle. 736 ** we are idle.
750 ** there is a command in pending. 737 ** there is a command in pending.
@@ -755,7 +742,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
755 if (CmdBlkP->Packet.dest_port == BOOT_RUP) 742 if (CmdBlkP->Packet.dest_port == BOOT_RUP)
756 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]); 743 rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
757 744
758 rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP); 745 rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
759 746
760 /* 747 /*
761 ** Clear the Rup lock to prevent mutual exclusion. 748 ** Clear the Rup lock to prevent mutual exclusion.
@@ -782,20 +769,20 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
782 ** is idle, then process the command 769 ** is idle, then process the command
783 */ 770 */
784 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */ 771 if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
785 (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) { 772 (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
786 /* 773 /*
787 ** if the pre-function is non-zero, call it. 774 ** if the pre-function is non-zero, call it.
788 ** If it returns RIO_FAIL then don't 775 ** If it returns RIO_FAIL then don't
789 ** send this command yet! 776 ** send this command yet!
790 */ 777 */
791 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) { 778 if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) {
792 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP); 779 rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP);
793 } else { 780 } else {
794 rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]); 781 rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]);
795 /* 782 /*
796 ** Whammy! blat that pack! 783 ** Whammy! blat that pack!
797 */ 784 */
798 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT)); 785 HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
799 786
800 /* 787 /*
801 ** remove the command from the rup command queue... 788 ** remove the command from the rup command queue...
@@ -810,7 +797,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
810 /* 797 /*
811 ** set the command register 798 ** set the command register
812 */ 799 */
813 WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY); 800 writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
814 801
815 /* 802 /*
816 ** the command block will be freed 803 ** the command block will be freed
@@ -822,7 +809,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
822 } while (Rup); 809 } while (Rup);
823} 810}
824 811
825int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP) 812int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
826{ 813{
827 struct Port *PortP = (struct Port *) iPortP; 814 struct Port *PortP = (struct Port *) iPortP;
828 unsigned long flags; 815 unsigned long flags;
@@ -834,33 +821,32 @@ int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
834 return RIOUnUse(iPortP, CmdBlkP); 821 return RIOUnUse(iPortP, CmdBlkP);
835} 822}
836 823
837int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP) 824int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
838{ 825{
839 struct Port *PortP = (struct Port *) iPortP; 826 struct Port *PortP = (struct Port *) iPortP;
840 PKT *PacketP; 827 struct PKT *PacketP;
841 unsigned long flags; 828 unsigned long flags;
842 829
843 rio_spin_lock_irqsave(&PortP->portSem, flags); 830 rio_spin_lock_irqsave(&PortP->portSem, flags);
844 831
845 while (can_remove_receive(&PacketP, PortP)) { 832 while (can_remove_receive(&PacketP, PortP)) {
846 remove_receive(PortP); 833 remove_receive(PortP);
847 ShowPacket(DBG_PROC, PacketP);
848 put_free_end(PortP->HostP, PacketP); 834 put_free_end(PortP->HostP, PacketP);
849 } 835 }
850 836
851 if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) { 837 if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
852 /* 838 /*
853 ** MAGIC! (Basically, handshake the RX buffer, so that 839 ** MAGIC! (Basically, handshake the RX buffer, so that
854 ** the RTAs upstream can be re-enabled.) 840 ** the RTAs upstream can be re-enabled.)
855 */ 841 */
856 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n"); 842 rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
857 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 843 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
858 } 844 }
859 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 845 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
860 return RIOUnUse(iPortP, CmdBlkP); 846 return RIOUnUse(iPortP, CmdBlkP);
861} 847}
862 848
863int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP) 849int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
864{ 850{
865 struct Port *PortP = (struct Port *) iPortP; 851 struct Port *PortP = (struct Port *) iPortP;
866 unsigned long flags; 852 unsigned long flags;
@@ -890,7 +876,7 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
890 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data 876 ** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
891 ** hanging around in the transmit buffer is sent immediately. 877 ** hanging around in the transmit buffer is sent immediately.
892 */ 878 */
893 WWORD(PortP->HostP->ParmMapP->tx_intr, 1); 879 writew(1, &PortP->HostP->ParmMapP->tx_intr);
894 /* What to do here .. 880 /* What to do here ..
895 wakeup( (caddr_t)&(PortP->InUse) ); 881 wakeup( (caddr_t)&(PortP->InUse) );
896 */ 882 */
@@ -898,10 +884,6 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
898 return 0; 884 return 0;
899} 885}
900 886
901void ShowPacket(uint Flags, struct PKT *PacketP)
902{
903}
904
905/* 887/*
906** 888**
907** How to use this file: 889** How to use this file:
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index fcf18a061228..d31aba62bb7f 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -51,15 +51,12 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
51 51
52#include "linux_compat.h" 52#include "linux_compat.h"
53#include "rio_linux.h" 53#include "rio_linux.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,12 +69,10 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83 78
@@ -131,30 +126,6 @@ static int
131 126
132#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))
133 128
134int copyin(int arg, caddr_t dp, int siz)
135{
136 int rv;
137
138 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *) arg, dp);
139 rv = copy_from_user(dp, (void *) arg, siz);
140 if (rv)
141 return COPYFAIL;
142 else
143 return rv;
144}
145
146static int copyout(caddr_t dp, int arg, int siz)
147{
148 int rv;
149
150 rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *) arg, dp);
151 rv = copy_to_user((void *) arg, dp, siz);
152 if (rv)
153 return COPYFAIL;
154 else
155 return rv;
156}
157
158int riocontrol(p, dev, cmd, arg, su) 129int riocontrol(p, dev, cmd, arg, su)
159struct rio_info *p; 130struct rio_info *p;
160dev_t dev; 131dev_t dev;
@@ -168,7 +139,7 @@ int su;
168 ushort loop; 139 ushort loop;
169 int Entry; 140 int Entry;
170 struct Port *PortP; 141 struct Port *PortP;
171 PKT *PacketP; 142 struct PKT *PacketP;
172 int retval = 0; 143 int retval = 0;
173 unsigned long flags; 144 unsigned long flags;
174 145
@@ -178,7 +149,7 @@ int su;
178 Host = 0; 149 Host = 0;
179 PortP = NULL; 150 PortP = NULL;
180 151
181 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int) arg); 152 rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg);
182 153
183 switch (cmd) { 154 switch (cmd) {
184 /* 155 /*
@@ -189,90 +160,34 @@ int su;
189 ** otherwise just the specified host card will be changed. 160 ** otherwise just the specified host card will be changed.
190 */ 161 */
191 case RIO_SET_TIMER: 162 case RIO_SET_TIMER:
192 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint) arg); 163 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg);
193 { 164 {
194 int host, value; 165 int host, value;
195 host = (uint) arg >> 16; 166 host = ((unsigned long) arg >> 16) & 0x0000FFFF;
196 value = (uint) arg & 0x0000ffff; 167 value = (unsigned long) arg & 0x0000ffff;
197 if (host == -1) { 168 if (host == -1) {
198 for (host = 0; host < p->RIONumHosts; host++) { 169 for (host = 0; host < p->RIONumHosts; host++) {
199 if (p->RIOHosts[host].Flags == RC_RUNNING) { 170 if (p->RIOHosts[host].Flags == RC_RUNNING) {
200 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 171 writew(value, &p->RIOHosts[host].ParmMapP->timer);
201 } 172 }
202 } 173 }
203 } else if (host >= p->RIONumHosts) { 174 } else if (host >= p->RIONumHosts) {
204 return -EINVAL; 175 return -EINVAL;
205 } else { 176 } else {
206 if (p->RIOHosts[host].Flags == RC_RUNNING) { 177 if (p->RIOHosts[host].Flags == RC_RUNNING) {
207 WWORD(p->RIOHosts[host].ParmMapP->timer, value); 178 writew(value, &p->RIOHosts[host].ParmMapP->timer);
208 } 179 }
209 } 180 }
210 } 181 }
211 return 0; 182 return 0;
212 183
213 case RIO_IDENTIFY_DRIVER:
214 /*
215 ** 15.10.1998 ARG - ESIL 0760 part fix
216 ** Added driver ident string output.
217 **
218 #ifndef __THIS_RELEASE__
219 #warning Driver Version string not defined !
220 #endif
221 cprintf("%s %s %s %s\n",
222 RIO_DRV_STR,
223 __THIS_RELEASE__,
224 __DATE__, __TIME__ );
225
226 return 0;
227
228 case RIO_DISPLAY_HOST_CFG:
229 **
230 ** 15.10.1998 ARG - ESIL 0760 part fix
231 ** Added driver host card ident string output.
232 **
233 ** Note that the only types currently supported
234 ** are ISA and PCI. Also this driver does not
235 ** (yet) distinguish between the Old PCI card
236 ** and the Jet PCI card. In fact I think this
237 ** driver only supports JET PCI !
238 **
239
240 for (Host = 0; Host < p->RIONumHosts; Host++)
241 {
242 HostP = &(p->RIOHosts[Host]);
243
244 switch ( HostP->Type )
245 {
246 case RIO_AT :
247 strcpy( host_type, RIO_AT_HOST_STR );
248 break;
249
250 case RIO_PCI :
251 strcpy( host_type, RIO_PCI_HOST_STR );
252 break;
253
254 default :
255 strcpy( host_type, "Unknown" );
256 break;
257 }
258
259 cprintf(
260 "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
261 Host, host_type,
262 (uint)HostP->PaddrP,
263 (int)HostP->Ivec - 32 );
264 }
265 return 0;
266 **
267 */
268
269 case RIO_FOAD_RTA: 184 case RIO_FOAD_RTA:
270 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n"); 185 rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
271 return RIOCommandRta(p, (uint) arg, RIOFoadRta); 186 return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta);
272 187
273 case RIO_ZOMBIE_RTA: 188 case RIO_ZOMBIE_RTA:
274 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n"); 189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
275 return RIOCommandRta(p, (uint) arg, RIOZombieRta); 190 return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta);
276 191
277 case RIO_IDENTIFY_RTA: 192 case RIO_IDENTIFY_RTA:
278 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n"); 193 rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
@@ -287,7 +202,7 @@ int su;
287 struct CmdBlk *CmdBlkP; 202 struct CmdBlk *CmdBlkP;
288 203
289 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n"); 204 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
290 if (copyin((int) arg, (caddr_t) & SpecialRupCmd, sizeof(SpecialRupCmd)) == COPYFAIL) { 205 if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) {
291 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n"); 206 rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
292 p->RIOError.Error = COPYIN_FAILED; 207 p->RIOError.Error = COPYIN_FAILED;
293 return -EFAULT; 208 return -EFAULT;
@@ -302,7 +217,7 @@ int su;
302 SpecialRupCmd.Host = 0; 217 SpecialRupCmd.Host = 0;
303 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum); 218 rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum);
304 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) { 219 if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
305 cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n"); 220 printk(KERN_WARNING "rio: FAILED TO QUEUE SPECIAL RUP COMMAND\n");
306 } 221 }
307 return 0; 222 return 0;
308 } 223 }
@@ -324,7 +239,7 @@ int su;
324 if ((retval = RIOApel(p)) != 0) 239 if ((retval = RIOApel(p)) != 0)
325 return retval; 240 return retval;
326 241
327 if (copyout((caddr_t) p->RIOConnectTable, (int) arg, TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 242 if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n"); 243 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
329 p->RIOError.Error = COPYOUT_FAILED; 244 p->RIOError.Error = COPYOUT_FAILED;
330 return -EFAULT; 245 return -EFAULT;
@@ -369,7 +284,7 @@ int su;
369 p->RIOError.Error = NOT_SUPER_USER; 284 p->RIOError.Error = NOT_SUPER_USER;
370 return -EPERM; 285 return -EPERM;
371 } 286 }
372 if (copyin((int) arg, (caddr_t) & p->RIOConnectTable[0], TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) { 287 if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
373 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n"); 288 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
374 p->RIOError.Error = COPYIN_FAILED; 289 p->RIOError.Error = COPYIN_FAILED;
375 return -EFAULT; 290 return -EFAULT;
@@ -415,7 +330,7 @@ int su;
415 p->RIOError.Error = NOT_SUPER_USER; 330 p->RIOError.Error = NOT_SUPER_USER;
416 return -EPERM; 331 return -EPERM;
417 } 332 }
418 if (copyout((caddr_t) p->RIOBindTab, (int) arg, (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 333 if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
419 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n"); 334 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
420 p->RIOError.Error = COPYOUT_FAILED; 335 p->RIOError.Error = COPYOUT_FAILED;
421 return -EFAULT; 336 return -EFAULT;
@@ -434,7 +349,7 @@ int su;
434 p->RIOError.Error = NOT_SUPER_USER; 349 p->RIOError.Error = NOT_SUPER_USER;
435 return -EPERM; 350 return -EPERM;
436 } 351 }
437 if (copyin((int) arg, (caddr_t) & p->RIOBindTab[0], (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) { 352 if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
438 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n"); 353 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
439 p->RIOError.Error = COPYIN_FAILED; 354 p->RIOError.Error = COPYIN_FAILED;
440 return -EFAULT; 355 return -EFAULT;
@@ -458,12 +373,12 @@ int su;
458 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) { 373 for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
459 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L)) 374 if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
460 EmptySlot = Entry; 375 EmptySlot = Entry;
461 else if (p->RIOBindTab[Entry] == (int) arg) { 376 else if (p->RIOBindTab[Entry] == (long)arg) {
462 /* 377 /*
463 ** Already exists - delete 378 ** Already exists - delete
464 */ 379 */
465 p->RIOBindTab[Entry] = 0L; 380 p->RIOBindTab[Entry] = 0L;
466 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n", (int) arg); 381 rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg);
467 return 0; 382 return 0;
468 } 383 }
469 } 384 }
@@ -471,10 +386,10 @@ int su;
471 ** Dosen't exist - add 386 ** Dosen't exist - add
472 */ 387 */
473 if (EmptySlot != -1) { 388 if (EmptySlot != -1) {
474 p->RIOBindTab[EmptySlot] = (int) arg; 389 p->RIOBindTab[EmptySlot] = (unsigned long)arg;
475 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n", (int) arg); 390 rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg);
476 } else { 391 } else {
477 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n", (int) arg); 392 rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg);
478 return -ENOMEM; 393 return -ENOMEM;
479 } 394 }
480 return 0; 395 return 0;
@@ -482,7 +397,7 @@ int su;
482 397
483 case RIO_RESUME: 398 case RIO_RESUME:
484 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n"); 399 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
485 port = (uint) arg; 400 port = (unsigned long) arg;
486 if ((port < 0) || (port > 511)) { 401 if ((port < 0) || (port > 511)) {
487 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port); 402 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
488 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 403 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -518,8 +433,7 @@ int su;
518 p->RIOError.Error = NOT_SUPER_USER; 433 p->RIOError.Error = NOT_SUPER_USER;
519 return -EPERM; 434 return -EPERM;
520 } 435 }
521 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 436 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
522 == COPYFAIL) {
523 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 437 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
524 p->RIOError.Error = COPYIN_FAILED; 438 p->RIOError.Error = COPYIN_FAILED;
525 return -EFAULT; 439 return -EFAULT;
@@ -533,8 +447,7 @@ int su;
533 p->RIOError.Error = NOT_SUPER_USER; 447 p->RIOError.Error = NOT_SUPER_USER;
534 return -EPERM; 448 return -EPERM;
535 } 449 }
536 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 450 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
537 == COPYFAIL) {
538 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n"); 451 rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
539 p->RIOError.Error = COPYIN_FAILED; 452 p->RIOError.Error = COPYIN_FAILED;
540 return -EFAULT; 453 return -EFAULT;
@@ -548,8 +461,7 @@ int su;
548 p->RIOError.Error = NOT_SUPER_USER; 461 p->RIOError.Error = NOT_SUPER_USER;
549 return -EPERM; 462 return -EPERM;
550 } 463 }
551 if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt)) 464 if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
552 == COPYFAIL) {
553 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n"); 465 rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
554 p->RIOError.Error = COPYIN_FAILED; 466 p->RIOError.Error = COPYIN_FAILED;
555 return -EFAULT; 467 return -EFAULT;
@@ -557,30 +469,14 @@ int su;
557 return RIODeleteRta(p, &MapEnt); 469 return RIODeleteRta(p, &MapEnt);
558 470
559 case RIO_QUICK_CHECK: 471 case RIO_QUICK_CHECK:
560 /* 472 if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) {
561 ** 09.12.1998 ARG - ESIL 0776 part fix
562 ** A customer was using this to get the RTAs
563 ** connect/disconnect status.
564 ** RIOConCon() had been botched use RIOHalted
565 ** to keep track of RTA connections and
566 ** disconnections. That has been changed and
567 ** RIORtaDisCons in the rio_info struct now
568 ** does the job. So we need to return the value
569 ** of RIORtaCons instead of RIOHalted.
570 **
571 if (copyout((caddr_t)&p->RIOHalted,(int)arg,
572 sizeof(uint))==COPYFAIL) {
573 **
574 */
575
576 if (copyout((caddr_t) & p->RIORtaDisCons, (int) arg, sizeof(uint)) == COPYFAIL) {
577 p->RIOError.Error = COPYOUT_FAILED; 473 p->RIOError.Error = COPYOUT_FAILED;
578 return -EFAULT; 474 return -EFAULT;
579 } 475 }
580 return 0; 476 return 0;
581 477
582 case RIO_LAST_ERROR: 478 case RIO_LAST_ERROR:
583 if (copyout((caddr_t) & p->RIOError, (int) arg, sizeof(struct Error)) == COPYFAIL) 479 if (copy_to_user(arg, &p->RIOError, sizeof(struct Error)))
584 return -EFAULT; 480 return -EFAULT;
585 return 0; 481 return 0;
586 482
@@ -589,7 +485,7 @@ int su;
589 return -EINVAL; 485 return -EINVAL;
590 486
591 case RIO_GET_MODTYPE: 487 case RIO_GET_MODTYPE:
592 if (copyin((int) arg, (caddr_t) & port, sizeof(uint)) == COPYFAIL) { 488 if (copy_from_user(&port, arg, sizeof(unsigned int))) {
593 p->RIOError.Error = COPYIN_FAILED; 489 p->RIOError.Error = COPYIN_FAILED;
594 return -EFAULT; 490 return -EFAULT;
595 } 491 }
@@ -609,36 +505,11 @@ int su;
609 ** Return module type of port 505 ** Return module type of port
610 */ 506 */
611 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes; 507 port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
612 if (copyout((caddr_t) & port, (int) arg, sizeof(uint)) == COPYFAIL) { 508 if (copy_to_user(arg, &port, sizeof(unsigned int))) {
613 p->RIOError.Error = COPYOUT_FAILED; 509 p->RIOError.Error = COPYOUT_FAILED;
614 return -EFAULT; 510 return -EFAULT;
615 } 511 }
616 return (0); 512 return (0);
617 /*
618 ** 02.03.1999 ARG - ESIL 0820 fix
619 ** We are no longer using "Boot Mode", so these ioctls
620 ** are not required :
621 **
622 case RIO_GET_BOOT_MODE :
623 rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
624 **
625 ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
626 **
627 if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
628 sizeof(p->RIOBootMode)) == COPYFAIL) {
629 p->RIOError.Error = COPYOUT_FAILED;
630 return -EFAULT;
631 }
632 return(0);
633
634 case RIO_SET_BOOT_MODE :
635 p->RIOBootMode = (uint) arg;
636 rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
637 return(0);
638 **
639 ** End ESIL 0820 fix
640 */
641
642 case RIO_BLOCK_OPENS: 513 case RIO_BLOCK_OPENS:
643 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n"); 514 rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n");
644 for (Entry = 0; Entry < RIO_PORTS; Entry++) { 515 for (Entry = 0; Entry < RIO_PORTS; Entry++) {
@@ -650,8 +521,7 @@ int su;
650 521
651 case RIO_SETUP_PORTS: 522 case RIO_SETUP_PORTS:
652 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n"); 523 rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
653 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 524 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
654 == COPYFAIL) {
655 p->RIOError.Error = COPYIN_FAILED; 525 p->RIOError.Error = COPYIN_FAILED;
656 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT"); 526 rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
657 return -EFAULT; 527 return -EFAULT;
@@ -667,7 +537,7 @@ int su;
667 return -EINVAL; 537 return -EINVAL;
668 } 538 }
669 if (!p->RIOPortp) { 539 if (!p->RIOPortp) {
670 cprintf("No p->RIOPortp array!\n"); 540 printk(KERN_ERR "rio: No p->RIOPortp array!\n");
671 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n"); 541 rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
672 return -EIO; 542 return -EIO;
673 } 543 }
@@ -681,8 +551,7 @@ int su;
681 551
682 case RIO_GET_PORT_SETUP: 552 case RIO_GET_PORT_SETUP:
683 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n"); 553 rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
684 if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup)) 554 if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
685 == COPYFAIL) {
686 p->RIOError.Error = COPYIN_FAILED; 555 p->RIOError.Error = COPYIN_FAILED;
687 return -EFAULT; 556 return -EFAULT;
688 } 557 }
@@ -698,13 +567,12 @@ int su;
698 PortSetup.Store = p->RIOPortp[port]->Store; 567 PortSetup.Store = p->RIOPortp[port]->Store;
699 PortSetup.Lock = p->RIOPortp[port]->Lock; 568 PortSetup.Lock = p->RIOPortp[port]->Lock;
700 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps; 569 PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
701 bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn, MAX_XP_CTRL_LEN); 570 memcpy(PortSetup.XpOn, p->RIOPortp[port]->Xprint.XpOn, MAX_XP_CTRL_LEN);
702 bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff, MAX_XP_CTRL_LEN); 571 memcpy(PortSetup.XpOff, p->RIOPortp[port]->Xprint.XpOff, MAX_XP_CTRL_LEN);
703 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0'; 572 PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
704 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0'; 573 PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
705 574
706 if (copyout((caddr_t) & PortSetup, (int) arg, sizeof(PortSetup)) 575 if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) {
707 == COPYFAIL) {
708 p->RIOError.Error = COPYOUT_FAILED; 576 p->RIOError.Error = COPYOUT_FAILED;
709 return -EFAULT; 577 return -EFAULT;
710 } 578 }
@@ -712,7 +580,7 @@ int su;
712 580
713 case RIO_GET_PORT_PARAMS: 581 case RIO_GET_PORT_PARAMS:
714 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n"); 582 rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
715 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(struct PortParams)) == COPYFAIL) { 583 if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) {
716 p->RIOError.Error = COPYIN_FAILED; 584 p->RIOError.Error = COPYIN_FAILED;
717 return -EFAULT; 585 return -EFAULT;
718 } 586 }
@@ -725,7 +593,7 @@ int su;
725 PortParams.State = PortP->State; 593 PortParams.State = PortP->State;
726 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port); 594 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
727 595
728 if (copyout((caddr_t) & PortParams, (int) arg, sizeof(struct PortParams)) == COPYFAIL) { 596 if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) {
729 p->RIOError.Error = COPYOUT_FAILED; 597 p->RIOError.Error = COPYOUT_FAILED;
730 return -EFAULT; 598 return -EFAULT;
731 } 599 }
@@ -733,8 +601,7 @@ int su;
733 601
734 case RIO_GET_PORT_TTY: 602 case RIO_GET_PORT_TTY:
735 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n"); 603 rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
736 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) 604 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
737 == COPYFAIL) {
738 p->RIOError.Error = COPYIN_FAILED; 605 p->RIOError.Error = COPYIN_FAILED;
739 return -EFAULT; 606 return -EFAULT;
740 } 607 }
@@ -745,14 +612,14 @@ int su;
745 612
746 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port); 613 rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
747 PortP = (p->RIOPortp[PortTty.port]); 614 PortP = (p->RIOPortp[PortTty.port]);
748 if (copyout((caddr_t) & PortTty, (int) arg, sizeof(struct PortTty)) == COPYFAIL) { 615 if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) {
749 p->RIOError.Error = COPYOUT_FAILED; 616 p->RIOError.Error = COPYOUT_FAILED;
750 return -EFAULT; 617 return -EFAULT;
751 } 618 }
752 return retval; 619 return retval;
753 620
754 case RIO_SET_PORT_TTY: 621 case RIO_SET_PORT_TTY:
755 if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) == COPYFAIL) { 622 if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
756 p->RIOError.Error = COPYIN_FAILED; 623 p->RIOError.Error = COPYIN_FAILED;
757 return -EFAULT; 624 return -EFAULT;
758 } 625 }
@@ -767,8 +634,7 @@ int su;
767 634
768 case RIO_SET_PORT_PARAMS: 635 case RIO_SET_PORT_PARAMS:
769 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n"); 636 rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
770 if (copyin((int) arg, (caddr_t) & PortParams, sizeof(PortParams)) 637 if (copy_from_user(&PortParams, arg, sizeof(PortParams))) {
771 == COPYFAIL) {
772 p->RIOError.Error = COPYIN_FAILED; 638 p->RIOError.Error = COPYIN_FAILED;
773 return -EFAULT; 639 return -EFAULT;
774 } 640 }
@@ -784,7 +650,7 @@ int su;
784 650
785 case RIO_GET_PORT_STATS: 651 case RIO_GET_PORT_STATS:
786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n"); 652 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
787 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 653 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
788 p->RIOError.Error = COPYIN_FAILED; 654 p->RIOError.Error = COPYIN_FAILED;
789 return -EFAULT; 655 return -EFAULT;
790 } 656 }
@@ -799,14 +665,14 @@ int su;
799 portStats.opens = PortP->opens; 665 portStats.opens = PortP->opens;
800 portStats.closes = PortP->closes; 666 portStats.closes = PortP->closes;
801 portStats.ioctls = PortP->ioctls; 667 portStats.ioctls = PortP->ioctls;
802 if (copyout((caddr_t) & portStats, (int) arg, sizeof(struct portStats)) == COPYFAIL) { 668 if (copy_to_user(arg, &portStats, sizeof(struct portStats))) {
803 p->RIOError.Error = COPYOUT_FAILED; 669 p->RIOError.Error = COPYOUT_FAILED;
804 return -EFAULT; 670 return -EFAULT;
805 } 671 }
806 return retval; 672 return retval;
807 673
808 case RIO_RESET_PORT_STATS: 674 case RIO_RESET_PORT_STATS:
809 port = (uint) arg; 675 port = (unsigned long) arg;
810 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n"); 676 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
811 if (port >= RIO_PORTS) { 677 if (port >= RIO_PORTS) {
812 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 678 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -824,7 +690,7 @@ int su;
824 690
825 case RIO_GATHER_PORT_STATS: 691 case RIO_GATHER_PORT_STATS:
826 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n"); 692 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
827 if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) { 693 if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
828 p->RIOError.Error = COPYIN_FAILED; 694 p->RIOError.Error = COPYIN_FAILED;
829 return -EFAULT; 695 return -EFAULT;
830 } 696 }
@@ -840,7 +706,7 @@ int su;
840 706
841 case RIO_READ_CONFIG: 707 case RIO_READ_CONFIG:
842 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n"); 708 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
843 if (copyout((caddr_t) & p->RIOConf, (int) arg, sizeof(struct Conf)) == COPYFAIL) { 709 if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) {
844 p->RIOError.Error = COPYOUT_FAILED; 710 p->RIOError.Error = COPYOUT_FAILED;
845 return -EFAULT; 711 return -EFAULT;
846 } 712 }
@@ -852,8 +718,7 @@ int su;
852 p->RIOError.Error = NOT_SUPER_USER; 718 p->RIOError.Error = NOT_SUPER_USER;
853 return -EPERM; 719 return -EPERM;
854 } 720 }
855 if (copyin((int) arg, (caddr_t) & p->RIOConf, sizeof(struct Conf)) 721 if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) {
856 == COPYFAIL) {
857 p->RIOError.Error = COPYIN_FAILED; 722 p->RIOError.Error = COPYIN_FAILED;
858 return -EFAULT; 723 return -EFAULT;
859 } 724 }
@@ -862,7 +727,7 @@ int su;
862 */ 727 */
863 for (Host = 0; Host < p->RIONumHosts; Host++) 728 for (Host = 0; Host < p->RIONumHosts; Host++)
864 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING) 729 if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING)
865 WWORD(p->RIOHosts[Host].ParmMapP->timer, p->RIOConf.Timer); 730 writew(p->RIOConf.Timer, &p->RIOHosts[Host].ParmMapP->timer);
866 return retval; 731 return retval;
867 732
868 case RIO_START_POLLER: 733 case RIO_START_POLLER:
@@ -881,8 +746,7 @@ int su;
881 case RIO_SETDEBUG: 746 case RIO_SETDEBUG:
882 case RIO_GETDEBUG: 747 case RIO_GETDEBUG:
883 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n"); 748 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
884 if (copyin((int) arg, (caddr_t) & DebugCtrl, sizeof(DebugCtrl)) 749 if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) {
885 == COPYFAIL) {
886 p->RIOError.Error = COPYIN_FAILED; 750 p->RIOError.Error = COPYIN_FAILED;
887 return -EFAULT; 751 return -EFAULT;
888 } 752 }
@@ -899,7 +763,7 @@ int su;
899 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait); 763 rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
900 DebugCtrl.Debug = p->rio_debug; 764 DebugCtrl.Debug = p->rio_debug;
901 DebugCtrl.Wait = p->RIODebugWait; 765 DebugCtrl.Wait = p->RIODebugWait;
902 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 766 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
903 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort); 767 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
904 p->RIOError.Error = COPYOUT_FAILED; 768 p->RIOError.Error = COPYOUT_FAILED;
905 return -EFAULT; 769 return -EFAULT;
@@ -921,7 +785,7 @@ int su;
921 } else { 785 } else {
922 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug); 786 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
923 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug; 787 DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
924 if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) { 788 if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
925 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n"); 789 rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
926 p->RIOError.Error = COPYOUT_FAILED; 790 p->RIOError.Error = COPYOUT_FAILED;
927 return -EFAULT; 791 return -EFAULT;
@@ -936,43 +800,20 @@ int su;
936 ** textual null terminated string. 800 ** textual null terminated string.
937 */ 801 */
938 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n"); 802 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
939 if (copyout((caddr_t) RIOVersid(), (int) arg, sizeof(struct rioVersion)) == COPYFAIL) { 803 if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) {
940 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host); 804 rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
941 p->RIOError.Error = COPYOUT_FAILED; 805 p->RIOError.Error = COPYOUT_FAILED;
942 return -EFAULT; 806 return -EFAULT;
943 } 807 }
944 return retval; 808 return retval;
945 809
946 /*
947 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
948 ** !! commented out previous 'RIO_VERSID' functionality !!
949 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
950 **
951 case RIO_VERSID:
952 **
953 ** Enquire about the release and version.
954 ** We return MAX_VERSION_LEN bytes, being a textual null
955 ** terminated string.
956 **
957 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
958 if (copyout((caddr_t)RIOVersid(),
959 (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
960 rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
961 p->RIOError.Error = COPYOUT_FAILED;
962 return -EFAULT;
963 }
964 return retval;
965 **
966 ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
967 */
968
969 case RIO_NUM_HOSTS: 810 case RIO_NUM_HOSTS:
970 /* 811 /*
971 ** Enquire as to the number of hosts located 812 ** Enquire as to the number of hosts located
972 ** at init time. 813 ** at init time.
973 */ 814 */
974 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n"); 815 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
975 if (copyout((caddr_t) & p->RIONumHosts, (int) arg, sizeof(p->RIONumHosts)) == COPYFAIL) { 816 if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) {
976 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n"); 817 rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
977 p->RIOError.Error = COPYOUT_FAILED; 818 p->RIOError.Error = COPYOUT_FAILED;
978 return -EFAULT; 819 return -EFAULT;
@@ -983,7 +824,7 @@ int su;
983 /* 824 /*
984 ** Kill host. This may not be in the final version... 825 ** Kill host. This may not be in the final version...
985 */ 826 */
986 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int) arg); 827 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg);
987 if (!su) { 828 if (!su) {
988 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n"); 829 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
989 p->RIOError.Error = NOT_SUPER_USER; 830 p->RIOError.Error = NOT_SUPER_USER;
@@ -994,7 +835,7 @@ int su;
994 835
995 for (Host = 0; Host < p->RIONumHosts; Host++) { 836 for (Host = 0; Host < p->RIONumHosts; Host++) {
996 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot); 837 (void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot);
997 bzero((caddr_t) & p->RIOHosts[Host].Flags, ((int) &p->RIOHosts[Host].____end_marker____) - ((int) &p->RIOHosts[Host].Flags)); 838 memset(&p->RIOHosts[Host].Flags, 0, ((char *) &p->RIOHosts[Host].____end_marker____) - ((char *) &p->RIOHosts[Host].Flags));
998 p->RIOHosts[Host].Flags = RC_WAITING; 839 p->RIOHosts[Host].Flags = RC_WAITING;
999 } 840 }
1000 RIOFoadWakeup(p); 841 RIOFoadWakeup(p);
@@ -1017,7 +858,7 @@ int su;
1017 p->RIOError.Error = NOT_SUPER_USER; 858 p->RIOError.Error = NOT_SUPER_USER;
1018 return -EPERM; 859 return -EPERM;
1019 } 860 }
1020 if (copyin((int) arg, (caddr_t) & DownLoad, sizeof(DownLoad)) == COPYFAIL) { 861 if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) {
1021 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n"); 862 rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
1022 p->RIOError.Error = COPYIN_FAILED; 863 p->RIOError.Error = COPYIN_FAILED;
1023 return -EFAULT; 864 return -EFAULT;
@@ -1045,9 +886,9 @@ int su;
1045 886
1046 case RIO_PARMS: 887 case RIO_PARMS:
1047 { 888 {
1048 uint host; 889 unsigned int host;
1049 890
1050 if (copyin((int) arg, (caddr_t) & host, sizeof(host)) == COPYFAIL) { 891 if (copy_from_user(&host, arg, sizeof(host))) {
1051 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 892 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1052 p->RIOError.Error = COPYIN_FAILED; 893 p->RIOError.Error = COPYIN_FAILED;
1053 return -EFAULT; 894 return -EFAULT;
@@ -1056,7 +897,7 @@ int su;
1056 ** Fetch the parmmap 897 ** Fetch the parmmap
1057 */ 898 */
1058 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n"); 899 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
1059 if (copyout((caddr_t) p->RIOHosts[host].ParmMapP, (int) arg, sizeof(PARM_MAP)) == COPYFAIL) { 900 if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) {
1060 p->RIOError.Error = COPYOUT_FAILED; 901 p->RIOError.Error = COPYOUT_FAILED;
1061 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n"); 902 rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
1062 return -EFAULT; 903 return -EFAULT;
@@ -1066,7 +907,7 @@ int su;
1066 907
1067 case RIO_HOST_REQ: 908 case RIO_HOST_REQ:
1068 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n"); 909 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
1069 if (copyin((int) arg, (caddr_t) & HostReq, sizeof(HostReq)) == COPYFAIL) { 910 if (copy_from_user(&HostReq, arg, sizeof(HostReq))) {
1070 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n"); 911 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
1071 p->RIOError.Error = COPYIN_FAILED; 912 p->RIOError.Error = COPYIN_FAILED;
1072 return -EFAULT; 913 return -EFAULT;
@@ -1078,7 +919,7 @@ int su;
1078 } 919 }
1079 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum); 920 rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
1080 921
1081 if (copyout((caddr_t) & p->RIOHosts[HostReq.HostNum], (int) HostReq.HostP, sizeof(struct Host)) == COPYFAIL) { 922 if (copy_to_user(HostReq.HostP, &p->RIOHosts[HostReq.HostNum], sizeof(struct Host))) {
1082 p->RIOError.Error = COPYOUT_FAILED; 923 p->RIOError.Error = COPYOUT_FAILED;
1083 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n"); 924 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
1084 return -EFAULT; 925 return -EFAULT;
@@ -1087,7 +928,7 @@ int su;
1087 928
1088 case RIO_HOST_DPRAM: 929 case RIO_HOST_DPRAM:
1089 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n"); 930 rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
1090 if (copyin((int) arg, (caddr_t) & HostDpRam, sizeof(HostDpRam)) == COPYFAIL) { 931 if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) {
1091 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n"); 932 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
1092 p->RIOError.Error = COPYIN_FAILED; 933 p->RIOError.Error = COPYIN_FAILED;
1093 return -EFAULT; 934 return -EFAULT;
@@ -1104,13 +945,13 @@ int su;
1104 /* It's hardware like this that really gets on my tits. */ 945 /* It's hardware like this that really gets on my tits. */
1105 static unsigned char copy[sizeof(struct DpRam)]; 946 static unsigned char copy[sizeof(struct DpRam)];
1106 for (off = 0; off < sizeof(struct DpRam); off++) 947 for (off = 0; off < sizeof(struct DpRam); off++)
1107 copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off]; 948 copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]);
1108 if (copyout((caddr_t) copy, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 949 if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) {
1109 p->RIOError.Error = COPYOUT_FAILED; 950 p->RIOError.Error = COPYOUT_FAILED;
1110 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 951 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1111 return -EFAULT; 952 return -EFAULT;
1112 } 953 }
1113 } else if (copyout((caddr_t) p->RIOHosts[HostDpRam.HostNum].Caddr, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) { 954 } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) {
1114 p->RIOError.Error = COPYOUT_FAILED; 955 p->RIOError.Error = COPYOUT_FAILED;
1115 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n"); 956 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
1116 return -EFAULT; 957 return -EFAULT;
@@ -1119,13 +960,13 @@ int su;
1119 960
1120 case RIO_SET_BUSY: 961 case RIO_SET_BUSY:
1121 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n"); 962 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
1122 if ((int) arg < 0 || (int) arg > 511) { 963 if ((unsigned long) arg > 511) {
1123 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n", (int) arg); 964 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg);
1124 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 965 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
1125 return -EINVAL; 966 return -EINVAL;
1126 } 967 }
1127 rio_spin_lock_irqsave(&PortP->portSem, flags); 968 rio_spin_lock_irqsave(&PortP->portSem, flags);
1128 p->RIOPortp[(int) arg]->State |= RIO_BUSY; 969 p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY;
1129 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 970 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1130 return retval; 971 return retval;
1131 972
@@ -1135,7 +976,7 @@ int su;
1135 ** (probably for debug reasons) 976 ** (probably for debug reasons)
1136 */ 977 */
1137 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n"); 978 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
1138 if (copyin((int) arg, (caddr_t) & PortReq, sizeof(PortReq)) == COPYFAIL) { 979 if (copy_from_user(&PortReq, arg, sizeof(PortReq))) {
1139 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n"); 980 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
1140 p->RIOError.Error = COPYIN_FAILED; 981 p->RIOError.Error = COPYIN_FAILED;
1141 return -EFAULT; 982 return -EFAULT;
@@ -1147,7 +988,7 @@ int su;
1147 return -ENXIO; 988 return -ENXIO;
1148 } 989 }
1149 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort); 990 rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
1150 if (copyout((caddr_t) p->RIOPortp[PortReq.SysPort], (int) PortReq.PortP, sizeof(struct Port)) == COPYFAIL) { 991 if (copy_to_user(PortReq.PortP, p->RIOPortp[PortReq.SysPort], sizeof(struct Port))) {
1151 p->RIOError.Error = COPYOUT_FAILED; 992 p->RIOError.Error = COPYOUT_FAILED;
1152 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n"); 993 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
1153 return -EFAULT; 994 return -EFAULT;
@@ -1160,7 +1001,7 @@ int su;
1160 ** (probably for debug reasons) 1001 ** (probably for debug reasons)
1161 */ 1002 */
1162 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n"); 1003 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
1163 if (copyin((int) arg, (caddr_t) & RupReq, sizeof(RupReq)) == COPYFAIL) { 1004 if (copy_from_user(&RupReq, arg, sizeof(RupReq))) {
1164 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n"); 1005 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
1165 p->RIOError.Error = COPYIN_FAILED; 1006 p->RIOError.Error = COPYIN_FAILED;
1166 return -EFAULT; 1007 return -EFAULT;
@@ -1184,7 +1025,7 @@ int su;
1184 } 1025 }
1185 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum); 1026 rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
1186 1027
1187 if (copyout((caddr_t) HostP->UnixRups[RupReq.RupNum].RupP, (int) RupReq.RupP, sizeof(struct RUP)) == COPYFAIL) { 1028 if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) {
1188 p->RIOError.Error = COPYOUT_FAILED; 1029 p->RIOError.Error = COPYOUT_FAILED;
1189 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n"); 1030 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
1190 return -EFAULT; 1031 return -EFAULT;
@@ -1197,7 +1038,7 @@ int su;
1197 ** (probably for debug reasons) 1038 ** (probably for debug reasons)
1198 */ 1039 */
1199 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n"); 1040 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
1200 if (copyin((int) arg, (caddr_t) & LpbReq, sizeof(LpbReq)) == COPYFAIL) { 1041 if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) {
1201 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n"); 1042 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
1202 p->RIOError.Error = COPYIN_FAILED; 1043 p->RIOError.Error = COPYIN_FAILED;
1203 return -EFAULT; 1044 return -EFAULT;
@@ -1221,7 +1062,7 @@ int su;
1221 } 1062 }
1222 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host); 1063 rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
1223 1064
1224 if (copyout((caddr_t) & HostP->LinkStrP[LpbReq.Link], (int) LpbReq.LpbP, sizeof(struct LPB)) == COPYFAIL) { 1065 if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) {
1225 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n"); 1066 rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
1226 p->RIOError.Error = COPYOUT_FAILED; 1067 p->RIOError.Error = COPYOUT_FAILED;
1227 return -EFAULT; 1068 return -EFAULT;
@@ -1252,12 +1093,13 @@ int su;
1252 p->RIOError.Error = SIGNALS_ALREADY_SET; 1093 p->RIOError.Error = SIGNALS_ALREADY_SET;
1253 return -EBUSY; 1094 return -EBUSY;
1254 } 1095 }
1255 p->RIOSignalProcess = getpid(); 1096 /* FIXME: PID tracking */
1097 p->RIOSignalProcess = current->pid;
1256 p->RIOPrintDisabled = DONT_PRINT; 1098 p->RIOPrintDisabled = DONT_PRINT;
1257 return retval; 1099 return retval;
1258 1100
1259 case RIO_SIGNALS_OFF: 1101 case RIO_SIGNALS_OFF:
1260 if (p->RIOSignalProcess != getpid()) { 1102 if (p->RIOSignalProcess != current->pid) {
1261 p->RIOError.Error = NOT_RECEIVING_PROCESS; 1103 p->RIOError.Error = NOT_RECEIVING_PROCESS;
1262 return -EPERM; 1104 return -EPERM;
1263 } 1105 }
@@ -1294,7 +1136,7 @@ int su;
1294 case RIO_MAP_B110_TO_110: 1136 case RIO_MAP_B110_TO_110:
1295 case RIO_MAP_B110_TO_115200: 1137 case RIO_MAP_B110_TO_115200:
1296 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n"); 1138 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
1297 port = (uint) arg; 1139 port = (unsigned long) arg;
1298 if (port < 0 || port > 511) { 1140 if (port < 0 || port > 511) {
1299 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port); 1141 rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
1300 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 1142 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -1324,7 +1166,7 @@ int su;
1324 1166
1325 case RIO_SEND_PACKET: 1167 case RIO_SEND_PACKET:
1326 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n"); 1168 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
1327 if (copyin((int) arg, (caddr_t) & SendPack, sizeof(SendPack)) == COPYFAIL) { 1169 if (copy_from_user(&SendPack, arg, sizeof(SendPack))) {
1328 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n"); 1170 rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
1329 p->RIOError.Error = COPYIN_FAILED; 1171 p->RIOError.Error = COPYIN_FAILED;
1330 return -EFAULT; 1172 return -EFAULT;
@@ -1344,9 +1186,9 @@ int su;
1344 } 1186 }
1345 1187
1346 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++) 1188 for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++)
1347 WBYTE(PacketP->data[loop], SendPack.Data[loop]); 1189 writeb(SendPack.Data[loop], &PacketP->data[loop]);
1348 1190
1349 WBYTE(PacketP->len, SendPack.Len); 1191 writeb(SendPack.Len, &PacketP->len);
1350 1192
1351 add_transmit(PortP); 1193 add_transmit(PortP);
1352 /* 1194 /*
@@ -1368,7 +1210,7 @@ int su;
1368 return su ? 0 : -EPERM; 1210 return su ? 0 : -EPERM;
1369 1211
1370 case RIO_WHAT_MESG: 1212 case RIO_WHAT_MESG:
1371 if (copyout((caddr_t) & p->RIONoMessage, (int) arg, sizeof(p->RIONoMessage)) == COPYFAIL) { 1213 if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) {
1372 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n"); 1214 rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
1373 p->RIOError.Error = COPYOUT_FAILED; 1215 p->RIOError.Error = COPYOUT_FAILED;
1374 return -EFAULT; 1216 return -EFAULT;
@@ -1376,7 +1218,7 @@ int su;
1376 return 0; 1218 return 0;
1377 1219
1378 case RIO_MEM_DUMP: 1220 case RIO_MEM_DUMP:
1379 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1221 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1380 p->RIOError.Error = COPYIN_FAILED; 1222 p->RIOError.Error = COPYIN_FAILED;
1381 return -EFAULT; 1223 return -EFAULT;
1382 } 1224 }
@@ -1406,7 +1248,7 @@ int su;
1406 PortP->State |= RIO_BUSY; 1248 PortP->State |= RIO_BUSY;
1407 1249
1408 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1250 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1409 if (copyout((caddr_t) p->RIOMemDump, (int) arg, MEMDUMP_SIZE) == COPYFAIL) { 1251 if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) {
1410 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n"); 1252 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
1411 p->RIOError.Error = COPYOUT_FAILED; 1253 p->RIOError.Error = COPYOUT_FAILED;
1412 return -EFAULT; 1254 return -EFAULT;
@@ -1414,30 +1256,30 @@ int su;
1414 return 0; 1256 return 0;
1415 1257
1416 case RIO_TICK: 1258 case RIO_TICK:
1417 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1259 if ((unsigned long) arg >= p->RIONumHosts)
1418 return -EINVAL; 1260 return -EINVAL;
1419 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int) arg); 1261 rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg);
1420 WBYTE(p->RIOHosts[(int) arg].SetInt, 0xff); 1262 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt);
1421 return 0; 1263 return 0;
1422 1264
1423 case RIO_TOCK: 1265 case RIO_TOCK:
1424 if ((int) arg < 0 || (int) arg >= p->RIONumHosts) 1266 if ((unsigned long) arg >= p->RIONumHosts)
1425 return -EINVAL; 1267 return -EINVAL;
1426 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int) arg); 1268 rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg);
1427 WBYTE((p->RIOHosts[(int) arg].ResetInt), 0xff); 1269 writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt);
1428 return 0; 1270 return 0;
1429 1271
1430 case RIO_READ_CHECK: 1272 case RIO_READ_CHECK:
1431 /* Check reads for pkts with data[0] the same */ 1273 /* Check reads for pkts with data[0] the same */
1432 p->RIOReadCheck = !p->RIOReadCheck; 1274 p->RIOReadCheck = !p->RIOReadCheck;
1433 if (copyout((caddr_t) & p->RIOReadCheck, (int) arg, sizeof(uint)) == COPYFAIL) { 1275 if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) {
1434 p->RIOError.Error = COPYOUT_FAILED; 1276 p->RIOError.Error = COPYOUT_FAILED;
1435 return -EFAULT; 1277 return -EFAULT;
1436 } 1278 }
1437 return 0; 1279 return 0;
1438 1280
1439 case RIO_READ_REGISTER: 1281 case RIO_READ_REGISTER:
1440 if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) { 1282 if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
1441 p->RIOError.Error = COPYIN_FAILED; 1283 p->RIOError.Error = COPYIN_FAILED;
1442 return -EFAULT; 1284 return -EFAULT;
1443 } 1285 }
@@ -1472,7 +1314,7 @@ int su;
1472 PortP->State |= RIO_BUSY; 1314 PortP->State |= RIO_BUSY;
1473 1315
1474 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1316 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1475 if (copyout((caddr_t) & p->CdRegister, (int) arg, sizeof(uint)) == COPYFAIL) { 1317 if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) {
1476 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n"); 1318 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
1477 p->RIOError.Error = COPYOUT_FAILED; 1319 p->RIOError.Error = COPYOUT_FAILED;
1478 return -EFAULT; 1320 return -EFAULT;
@@ -1485,21 +1327,22 @@ int su;
1485 */ 1327 */
1486 case RIO_MAKE_DEV: 1328 case RIO_MAKE_DEV:
1487 { 1329 {
1488 uint port = (uint) arg & RIO_MODEM_MASK; 1330 unsigned int port = (unsigned long) arg & RIO_MODEM_MASK;
1331 unsigned int ret;
1489 1332
1490 switch ((uint) arg & RIO_DEV_MASK) { 1333 switch ((unsigned long) arg & RIO_DEV_MASK) {
1491 case RIO_DEV_DIRECT: 1334 case RIO_DEV_DIRECT:
1492 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1335 ret = drv_makedev(MAJOR(dev), port);
1493 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, (int) arg); 1336 rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret);
1494 return (int) arg; 1337 return ret;
1495 case RIO_DEV_MODEM: 1338 case RIO_DEV_MODEM:
1496 arg = (caddr_t) drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT)); 1339 ret = drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
1497 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, (int) arg); 1340 rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, ret);
1498 return (int) arg; 1341 return ret;
1499 case RIO_DEV_XPRINT: 1342 case RIO_DEV_XPRINT:
1500 arg = (caddr_t) drv_makedev(MAJOR(dev), port); 1343 ret = drv_makedev(MAJOR(dev), port);
1501 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, (int) arg); 1344 rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, ret);
1502 return (int) arg; 1345 return ret;
1503 } 1346 }
1504 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n"); 1347 rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n");
1505 return -EINVAL; 1348 return -EINVAL;
@@ -1513,18 +1356,19 @@ int su;
1513 { 1356 {
1514 dev_t dv; 1357 dev_t dv;
1515 int mino; 1358 int mino;
1359 unsigned long ret;
1516 1360
1517 dv = (dev_t) ((int) arg); 1361 dv = (dev_t) ((unsigned long) arg);
1518 mino = RIO_UNMODEM(dv); 1362 mino = RIO_UNMODEM(dv);
1519 1363
1520 if (RIO_ISMODEM(dv)) { 1364 if (RIO_ISMODEM(dv)) {
1521 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino); 1365 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
1522 arg = (caddr_t) (mino | RIO_DEV_MODEM); 1366 ret = mino | RIO_DEV_MODEM;
1523 } else { 1367 } else {
1524 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino); 1368 rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
1525 arg = (caddr_t) (mino | RIO_DEV_DIRECT); 1369 ret = mino | RIO_DEV_DIRECT;
1526 } 1370 }
1527 return (int) arg; 1371 return ret;
1528 } 1372 }
1529 } 1373 }
1530 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd); 1374 rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd);
@@ -1537,10 +1381,7 @@ int su;
1537/* 1381/*
1538** Pre-emptive commands go on RUPs and are only one byte long. 1382** Pre-emptive commands go on RUPs and are only one byte long.
1539*/ 1383*/
1540int RIOPreemptiveCmd(p, PortP, Cmd) 1384int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
1541struct rio_info *p;
1542struct Port *PortP;
1543uchar Cmd;
1544{ 1385{
1545 struct CmdBlk *CmdBlkP; 1386 struct CmdBlk *CmdBlkP;
1546 struct PktCmd_M *PktCmdP; 1387 struct PktCmd_M *PktCmdP;
@@ -1558,7 +1399,7 @@ uchar Cmd;
1558 return RIO_FAIL; 1399 return RIO_FAIL;
1559 } 1400 }
1560 1401
1561 rio_dprintk(RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", (int) CmdBlkP, PortP->InUse); 1402 rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse);
1562 1403
1563 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0]; 1404 PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
1564 1405
@@ -1572,7 +1413,7 @@ uchar Cmd;
1572 CmdBlkP->Packet.dest_port = COMMAND_RUP; 1413 CmdBlkP->Packet.dest_port = COMMAND_RUP;
1573 CmdBlkP->Packet.len = PKT_CMD_BIT | 2; 1414 CmdBlkP->Packet.len = PKT_CMD_BIT | 2;
1574 CmdBlkP->PostFuncP = RIOUnUse; 1415 CmdBlkP->PostFuncP = RIOUnUse;
1575 CmdBlkP->PostArg = (int) PortP; 1416 CmdBlkP->PostArg = (unsigned long) PortP;
1576 PktCmdP->Command = Cmd; 1417 PktCmdP->Command = Cmd;
1577 port = PortP->HostPort % (ushort) PORTS_PER_RTA; 1418 port = PortP->HostPort % (ushort) PORTS_PER_RTA;
1578 /* 1419 /*
@@ -1584,38 +1425,38 @@ uchar Cmd;
1584 1425
1585 switch (Cmd) { 1426 switch (Cmd) {
1586 case MEMDUMP: 1427 case MEMDUMP:
1587 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n", (int) CmdBlkP, (int) SubCmd.Addr); 1428 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
1588 PktCmdP->SubCommand = MEMDUMP; 1429 PktCmdP->SubCommand = MEMDUMP;
1589 PktCmdP->SubAddr = SubCmd.Addr; 1430 PktCmdP->SubAddr = SubCmd.Addr;
1590 break; 1431 break;
1591 case FCLOSE: 1432 case FCLOSE:
1592 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n", (int) CmdBlkP); 1433 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP);
1593 break; 1434 break;
1594 case READ_REGISTER: 1435 case READ_REGISTER:
1595 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n", (int) SubCmd.Addr, (int) CmdBlkP); 1436 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
1596 PktCmdP->SubCommand = READ_REGISTER; 1437 PktCmdP->SubCommand = READ_REGISTER;
1597 PktCmdP->SubAddr = SubCmd.Addr; 1438 PktCmdP->SubAddr = SubCmd.Addr;
1598 break; 1439 break;
1599 case RESUME: 1440 case RESUME:
1600 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n", (int) CmdBlkP); 1441 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP);
1601 break; 1442 break;
1602 case RFLUSH: 1443 case RFLUSH:
1603 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n", (int) CmdBlkP); 1444 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP);
1604 CmdBlkP->PostFuncP = RIORFlushEnable; 1445 CmdBlkP->PostFuncP = RIORFlushEnable;
1605 break; 1446 break;
1606 case SUSPEND: 1447 case SUSPEND:
1607 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n", (int) CmdBlkP); 1448 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP);
1608 break; 1449 break;
1609 1450
1610 case MGET: 1451 case MGET:
1611 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int) CmdBlkP); 1452 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP);
1612 break; 1453 break;
1613 1454
1614 case MSET: 1455 case MSET:
1615 case MBIC: 1456 case MBIC:
1616 case MBIS: 1457 case MBIS:
1617 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; 1458 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
1618 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int) CmdBlkP); 1459 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP);
1619 break; 1460 break;
1620 1461
1621 case WFLUSH: 1462 case WFLUSH:
@@ -1629,7 +1470,7 @@ uchar Cmd;
1629 RIOFreeCmdBlk(CmdBlkP); 1470 RIOFreeCmdBlk(CmdBlkP);
1630 return (RIO_FAIL); 1471 return (RIO_FAIL);
1631 } else { 1472 } else {
1632 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n", (int) CmdBlkP); 1473 rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP);
1633 CmdBlkP->PostFuncP = RIOWFlushMark; 1474 CmdBlkP->PostFuncP = RIOWFlushMark;
1634 } 1475 }
1635 break; 1476 break;
diff --git a/drivers/char/rio/riodrvr.h b/drivers/char/rio/riodrvr.h
index 663ee0914ed7..3cffe275f216 100644
--- a/drivers/char/rio/riodrvr.h
+++ b/drivers/char/rio/riodrvr.h
@@ -72,42 +72,42 @@ struct rio_info {
72*/ 72*/
73 int RIOHalted; /* halted ? */ 73 int RIOHalted; /* halted ? */
74 int RIORtaDisCons; /* RTA connections/disconnections */ 74 int RIORtaDisCons; /* RTA connections/disconnections */
75 uint RIOReadCheck; /* Rio read check */ 75 unsigned int RIOReadCheck; /* Rio read check */
76 uint RIONoMessage; /* To display message or not */ 76 unsigned int RIONoMessage; /* To display message or not */
77 uint RIONumBootPkts; /* how many packets for an RTA */ 77 unsigned int RIONumBootPkts; /* how many packets for an RTA */
78 uint RIOBootCount; /* size of RTA code */ 78 unsigned int RIOBootCount; /* size of RTA code */
79 uint RIOBooting; /* count of outstanding boots */ 79 unsigned int RIOBooting; /* count of outstanding boots */
80 uint RIOSystemUp; /* Booted ?? */ 80 unsigned int RIOSystemUp; /* Booted ?? */
81 uint RIOCounting; /* for counting interrupts */ 81 unsigned int RIOCounting; /* for counting interrupts */
82 uint RIOIntCount; /* # of intr since last check */ 82 unsigned int RIOIntCount; /* # of intr since last check */
83 uint RIOTxCount; /* number of xmit intrs */ 83 unsigned int RIOTxCount; /* number of xmit intrs */
84 uint RIORxCount; /* number of rx intrs */ 84 unsigned int RIORxCount; /* number of rx intrs */
85 uint RIORupCount; /* number of rup intrs */ 85 unsigned int RIORupCount; /* number of rup intrs */
86 int RIXTimer; 86 int RIXTimer;
87 int RIOBufferSize; /* Buffersize */ 87 int RIOBufferSize; /* Buffersize */
88 int RIOBufferMask; /* Buffersize */ 88 int RIOBufferMask; /* Buffersize */
89 89
90 int RIOFirstMajor; /* First host card's major no */ 90 int RIOFirstMajor; /* First host card's major no */
91 91
92 uint RIOLastPortsMapped; /* highest port number known */ 92 unsigned int RIOLastPortsMapped; /* highest port number known */
93 uint RIOFirstPortsMapped; /* lowest port number known */ 93 unsigned int RIOFirstPortsMapped; /* lowest port number known */
94 94
95 uint RIOLastPortsBooted; /* highest port number running */ 95 unsigned int RIOLastPortsBooted; /* highest port number running */
96 uint RIOFirstPortsBooted; /* lowest port number running */ 96 unsigned int RIOFirstPortsBooted; /* lowest port number running */
97 97
98 uint RIOLastPortsOpened; /* highest port number running */ 98 unsigned int RIOLastPortsOpened; /* highest port number running */
99 uint RIOFirstPortsOpened; /* lowest port number running */ 99 unsigned int RIOFirstPortsOpened; /* lowest port number running */
100 100
101 /* Flag to say that the topology information has been changed. */ 101 /* Flag to say that the topology information has been changed. */
102 uint RIOQuickCheck; 102 unsigned int RIOQuickCheck;
103 uint CdRegister; /* ??? */ 103 unsigned int CdRegister; /* ??? */
104 int RIOSignalProcess; /* Signalling process */ 104 int RIOSignalProcess; /* Signalling process */
105 int rio_debug; /* To debug ... */ 105 int rio_debug; /* To debug ... */
106 int RIODebugWait; /* For what ??? */ 106 int RIODebugWait; /* For what ??? */
107 int tpri; /* Thread prio */ 107 int tpri; /* Thread prio */
108 int tid; /* Thread id */ 108 int tid; /* Thread id */
109 uint _RIO_Polled; /* Counter for polling */ 109 unsigned int _RIO_Polled; /* Counter for polling */
110 uint _RIO_Interrupted; /* Counter for interrupt */ 110 unsigned int _RIO_Interrupted; /* Counter for interrupt */
111 int intr_tid; /* iointset return value */ 111 int intr_tid; /* iointset return value */
112 int TxEnSem; /* TxEnable Semaphore */ 112 int TxEnSem; /* TxEnable Semaphore */
113 113
@@ -121,9 +121,9 @@ struct rio_info {
121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES]; 121 struct Map RIOSavedTable[TOTAL_MAP_ENTRIES];
122 122
123 /* RTA to host binding table for master/slave operation */ 123 /* RTA to host binding table for master/slave operation */
124 ulong RIOBindTab[MAX_RTA_BINDINGS]; 124 unsigned long RIOBindTab[MAX_RTA_BINDINGS];
125 /* RTA memory dump variable */ 125 /* RTA memory dump variable */
126 uchar RIOMemDump[MEMDUMP_SIZE]; 126 unsigned char RIOMemDump[MEMDUMP_SIZE];
127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES]; 127 struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES];
128 128
129}; 129};
@@ -138,7 +138,5 @@ struct rio_info {
138 138
139 139
140#define RIO_RESET_INT 0x7d80 140#define RIO_RESET_INT 0x7d80
141#define WRBYTE(x,y) *(volatile unsigned char *)((x)) = \
142 (unsigned char)(y)
143 141
144#endif /* __riodrvr.h */ 142#endif /* __riodrvr.h */
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0d44ef464e6b..24d2992154cc 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -51,15 +51,12 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
51 51
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "typdef.h"
55#include "pkt.h" 54#include "pkt.h"
56#include "daemon.h" 55#include "daemon.h"
57#include "rio.h" 56#include "rio.h"
58#include "riospace.h" 57#include "riospace.h"
59#include "top.h"
60#include "cmdpkt.h" 58#include "cmdpkt.h"
61#include "map.h" 59#include "map.h"
62#include "riotypes.h"
63#include "rup.h" 60#include "rup.h"
64#include "port.h" 61#include "port.h"
65#include "riodrvr.h" 62#include "riodrvr.h"
@@ -72,22 +69,17 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
72#include "unixrup.h" 69#include "unixrup.h"
73#include "board.h" 70#include "board.h"
74#include "host.h" 71#include "host.h"
75#include "error.h"
76#include "phb.h" 72#include "phb.h"
77#include "link.h" 73#include "link.h"
78#include "cmdblk.h" 74#include "cmdblk.h"
79#include "route.h" 75#include "route.h"
80#include "control.h"
81#include "cirrus.h" 76#include "cirrus.h"
82#include "rioioctl.h" 77#include "rioioctl.h"
83#include "rio_linux.h" 78#include "rio_linux.h"
84 79
85#undef bcopy
86#define bcopy rio_pcicopy
87
88int RIOPCIinit(struct rio_info *p, int Mode); 80int RIOPCIinit(struct rio_info *p, int Mode);
89 81
90static int RIOScrub(int, BYTE *, int); 82static int RIOScrub(int, u8 *, int);
91 83
92 84
93/** 85/**
@@ -99,12 +91,8 @@ static int RIOScrub(int, BYTE *, int);
99** bits < 0 indicates 8 bit operation requested, 91** bits < 0 indicates 8 bit operation requested,
100** bits > 0 indicates 16 bit operation. 92** bits > 0 indicates 16 bit operation.
101*/ 93*/
102int 94
103RIOAssignAT(p, Base, virtAddr, mode) 95int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode)
104struct rio_info * p;
105int Base;
106caddr_t virtAddr;
107int mode;
108{ 96{
109 int bits; 97 int bits;
110 struct DpRam *cardp = (struct DpRam *)virtAddr; 98 struct DpRam *cardp = (struct DpRam *)virtAddr;
@@ -124,29 +112,25 @@ int mode;
124 /* 112 /*
125 ** Revision 01 AT host cards don't support WORD operations, 113 ** Revision 01 AT host cards don't support WORD operations,
126 */ 114 */
127 if ( RBYTE(cardp->DpRevision) == 01 ) 115 if (readb(&cardp->DpRevision) == 01)
128 bits = BYTE_OPERATION; 116 bits = BYTE_OPERATION;
129 117
130 p->RIOHosts[p->RIONumHosts].Type = RIO_AT; 118 p->RIOHosts[p->RIONumHosts].Type = RIO_AT;
131 p->RIOHosts[p->RIONumHosts].Copy = bcopy; 119 p->RIOHosts[p->RIONumHosts].Copy = rio_copy_to_card;
132 /* set this later */ 120 /* set this later */
133 p->RIOHosts[p->RIONumHosts].Slot = -1; 121 p->RIOHosts[p->RIONumHosts].Slot = -1;
134 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits; 122 p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits;
135 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 123 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE ,
136 BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 124 &p->RIOHosts[p->RIONumHosts].Control);
137 p->RIOHosts[p->RIONumHosts].Mode | 125 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
138 INTERRUPT_DISABLE ); 126 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE,
139 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff); 127 &p->RIOHosts[p->RIONumHosts].Control);
140 WBYTE(p->RIOHosts[p->RIONumHosts].Control, 128 writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
141 BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
142 p->RIOHosts[p->RIONumHosts].Mode |
143 INTERRUPT_DISABLE );
144 WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);
145 p->RIOHosts[p->RIONumHosts].UniqueNum = 129 p->RIOHosts[p->RIONumHosts].UniqueNum =
146 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)| 130 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|
147 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)| 131 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|
148 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)| 132 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|
149 ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24); 133 ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);
150 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum); 134 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum);
151 135
152 p->RIONumHosts++; 136 p->RIONumHosts++;
@@ -154,7 +138,7 @@ int mode;
154 return(1); 138 return(1);
155} 139}
156 140
157static uchar val[] = { 141static u8 val[] = {
158#ifdef VERY_LONG_TEST 142#ifdef VERY_LONG_TEST
159 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 143 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
160 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36, 144 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36,
@@ -167,12 +151,7 @@ static uchar val[] = {
167** RAM test a board. 151** RAM test a board.
168** Nothing too complicated, just enough to check it out. 152** Nothing too complicated, just enough to check it out.
169*/ 153*/
170int 154int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot)
171RIOBoardTest(paddr, caddr, type, slot)
172paddr_t paddr;
173caddr_t caddr;
174uchar type;
175int slot;
176{ 155{
177 struct DpRam *DpRam = (struct DpRam *)caddr; 156 struct DpRam *DpRam = (struct DpRam *)caddr;
178 char *ram[4]; 157 char *ram[4];
@@ -180,8 +159,8 @@ int slot;
180 int op, bank; 159 int op, bank;
181 int nbanks; 160 int nbanks;
182 161
183 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=0x%x, slot=%d\n", 162 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=%p, slot=%d\n",
184 type,(int)DpRam, slot); 163 type, DpRam, slot);
185 164
186 RIOHostReset(type, DpRam, slot); 165 RIOHostReset(type, DpRam, slot);
187 166
@@ -209,12 +188,11 @@ int slot;
209 188
210 189
211 if (nbanks == 3) { 190 if (nbanks == 3) {
212 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 191 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: %p(0x%x), %p(0x%x), %p(0x%x)\n",
213 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2]); 192 ram[0], size[0], ram[1], size[1], ram[2], size[2]);
214 } else { 193 } else {
215 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n", 194 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: %p(0x%x), %p(0x%x), %p(0x%x), %p(0x%x)\n",
216 (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2], (int)ram[3], 195 ram[0], size[0], ram[1], size[1], ram[2], size[2], ram[3], size[3]);
217 size[3]);
218 } 196 }
219 197
220 /* 198 /*
@@ -224,7 +202,7 @@ int slot;
224 */ 202 */
225 for (op=0; op<TEST_END; op++) { 203 for (op=0; op<TEST_END; op++) {
226 for (bank=0; bank<nbanks; bank++) { 204 for (bank=0; bank<nbanks; bank++) {
227 if (RIOScrub(op, (BYTE *)ram[bank], size[bank]) == RIO_FAIL) { 205 if (RIOScrub(op, (u8 *)ram[bank], size[bank]) == RIO_FAIL) {
228 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",
229 bank, op); 207 bank, op);
230 return RIO_FAIL; 208 return RIO_FAIL;
@@ -233,7 +211,7 @@ int slot;
233 } 211 }
234 212
235 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n"); 213 rio_dprintk (RIO_DEBUG_INIT, "Test completed\n");
236 return RIO_SUCCESS; 214 return 0;
237} 215}
238 216
239 217
@@ -248,13 +226,10 @@ int slot;
248** Call with op not zero, and the RAM will be read and compated with val[op-1] 226** Call with op not zero, and the RAM will be read and compated with val[op-1]
249** to check that the data from the previous phase was retained. 227** to check that the data from the previous phase was retained.
250*/ 228*/
251static int 229
252RIOScrub(op, ram, size) 230static int RIOScrub(int op, u8 *ram, int size)
253int op;
254BYTE * ram;
255int size;
256{ 231{
257 int off; 232 int off;
258 unsigned char oldbyte; 233 unsigned char oldbyte;
259 unsigned char newbyte; 234 unsigned char newbyte;
260 unsigned char invbyte; 235 unsigned char invbyte;
@@ -279,15 +254,15 @@ int size;
279 */ 254 */
280 if (op) { 255 if (op) {
281 for (off=0; off<size; off++) { 256 for (off=0; off<size; off++) {
282 if (RBYTE(ram[off]) != oldbyte) { 257 if (readb(ram + off) != oldbyte) {
283 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off])); 258 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
284 return RIO_FAIL; 259 return RIO_FAIL;
285 } 260 }
286 } 261 }
287 for (off=0; off<size; off+=2) { 262 for (off=0; off<size; off+=2) {
288 if (*(ushort *)&ram[off] != oldword) { 263 if (readw(ram + off) != oldword) {
289 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword,*(ushort *)&ram[off]); 264 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword, readw(ram + off));
290 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 265 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
291 return RIO_FAIL; 266 return RIO_FAIL;
292 } 267 }
293 } 268 }
@@ -301,13 +276,13 @@ int size;
301 ** the BYTE read/write test. 276 ** the BYTE read/write test.
302 */ 277 */
303 for (off=0; off<size; off++) { 278 for (off=0; off<size; off++) {
304 if (op && (RBYTE(ram[off]) != oldbyte)) { 279 if (op && (readb(ram + off) != oldbyte)) {
305 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off])); 280 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
306 return RIO_FAIL; 281 return RIO_FAIL;
307 } 282 }
308 WBYTE(ram[off],invbyte); 283 writeb(invbyte, ram + off);
309 if (RBYTE(ram[off]) != invbyte) { 284 if (readb(ram + off) != invbyte) {
310 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, RBYTE(ram[off])); 285 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, readb(ram + off));
311 return RIO_FAIL; 286 return RIO_FAIL;
312 } 287 }
313 } 288 }
@@ -320,16 +295,16 @@ int size;
320 ** This is the WORD operation test. 295 ** This is the WORD operation test.
321 */ 296 */
322 for (off=0; off<size; off+=2) { 297 for (off=0; off<size; off+=2) {
323 if (*(ushort *)&ram[off] != invword) { 298 if (readw(ram + off) != invword) {
324 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, *(ushort *)&ram[off]); 299 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, readw(ram + off));
325 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 300 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
326 return RIO_FAIL; 301 return RIO_FAIL;
327 } 302 }
328 303
329 *(ushort *)&ram[off] = newword; 304 writew(newword, ram + off);
330 if ( *(ushort *)&ram[off] != newword ) { 305 if ( readw(ram + off) != newword ) {
331 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]); 306 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
332 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 307 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
333 return RIO_FAIL; 308 return RIO_FAIL;
334 } 309 }
335 } 310 }
@@ -340,16 +315,16 @@ int size;
340 ** required test data. 315 ** required test data.
341 */ 316 */
342 for (off=0; off<size; off++) { 317 for (off=0; off<size; off++) {
343 if (RBYTE(ram[off]) != newbyte) { 318 if (readb(ram + off) != newbyte) {
344 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off])); 319 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
345 return RIO_FAIL; 320 return RIO_FAIL;
346 } 321 }
347 } 322 }
348 323
349 for (off=0; off<size; off+=2) { 324 for (off=0; off<size; off+=2) {
350 if ( *(ushort *)&ram[off] != newword ) { 325 if (readw(ram + off) != newword ) {
351 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]); 326 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
352 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 327 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
353 return RIO_FAIL; 328 return RIO_FAIL;
354 } 329 }
355 } 330 }
@@ -360,41 +335,37 @@ int size;
360 swapword = invbyte | (newbyte << 8); 335 swapword = invbyte | (newbyte << 8);
361 336
362 for (off=0; off<size; off+=2) { 337 for (off=0; off<size; off+=2) {
363 WBYTE(ram[off],invbyte); 338 writeb(invbyte, &ram[off]);
364 WBYTE(ram[off+1],newbyte); 339 writeb(newbyte, &ram[off+1]);
365 } 340 }
366 341
367 for ( off=0; off<size; off+=2 ) { 342 for ( off=0; off<size; off+=2 ) {
368 if (*(ushort *)&ram[off] != swapword) { 343 if (readw(ram + off) != swapword) {
369 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, *((ushort *)&ram[off])); 344 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, readw(ram + off));
370 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1])); 345 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
371 return RIO_FAIL; 346 return RIO_FAIL;
372 } 347 }
373 *((ushort *)&ram[off]) = ~swapword; 348 writew(~swapword, ram + off);
374 } 349 }
375 350
376 for (off=0; off<size; off+=2) { 351 for (off=0; off<size; off+=2) {
377 if (RBYTE(ram[off]) != newbyte) { 352 if (readb(ram + off) != newbyte) {
378 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off])); 353 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
379 return RIO_FAIL; 354 return RIO_FAIL;
380 } 355 }
381 if (RBYTE(ram[off+1]) != invbyte) { 356 if (readb(ram + off + 1) != invbyte) {
382 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, RBYTE(ram[off+1])); 357 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, readb(ram + off + 1));
383 return RIO_FAIL; 358 return RIO_FAIL;
384 } 359 }
385 *((ushort *)&ram[off]) = newword; 360 writew(newword, ram + off);
386 } 361 }
387 return RIO_SUCCESS; 362 return 0;
388} 363}
389 364
390 365
391int 366int RIODefaultName(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
392RIODefaultName(p, HostP, UnitId)
393struct rio_info * p;
394struct Host * HostP;
395uint UnitId;
396{ 367{
397 bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17); 368 memcpy(HostP->Mapping[UnitId].Name, "UNKNOWN RTA X-XX", 17);
398 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts); 369 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);
399 if ((UnitId+1) > 9) { 370 if ((UnitId+1) > 9) {
400 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10); 371 HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10);
@@ -412,8 +383,7 @@ uint UnitId;
412 383
413static struct rioVersion stVersion; 384static struct rioVersion stVersion;
414 385
415struct rioVersion * 386struct rioVersion *RIOVersid(void)
416RIOVersid(void)
417{ 387{
418 strlcpy(stVersion.version, "RIO driver for linux V1.0", 388 strlcpy(stVersion.version, "RIO driver for linux V1.0",
419 sizeof(stVersion.version)); 389 sizeof(stVersion.version));
@@ -423,40 +393,31 @@ RIOVersid(void)
423 return &stVersion; 393 return &stVersion;
424} 394}
425 395
426void 396void RIOHostReset(unsigned int Type, struct DpRam *DpRamP, unsigned int Slot)
427RIOHostReset(Type, DpRamP, Slot)
428uint Type;
429volatile struct DpRam *DpRamP;
430uint Slot;
431{ 397{
432 /* 398 /*
433 ** Reset the Tpu 399 ** Reset the Tpu
434 */ 400 */
435 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type); 401 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type);
436 switch ( Type ) { 402 switch ( Type ) {
437 case RIO_AT: 403 case RIO_AT:
438 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n"); 404 rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n");
439 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 405 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | BYTE_OPERATION |
440 INTERRUPT_DISABLE | BYTE_OPERATION | 406 SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
441 SLOW_LINKS | SLOW_AT_BUS); 407 writeb(0xFF, &DpRamP->DpResetTpu);
442 WBYTE(DpRamP->DpResetTpu, 0xFF); 408 udelay(3);
443 udelay(3);
444
445 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n"); 409 rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n");
446 WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 410 writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE |
447 INTERRUPT_DISABLE | BYTE_OPERATION | 411 BYTE_OPERATION | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
448 SLOW_LINKS | SLOW_AT_BUS); 412 writeb(0xFF, &DpRamP->DpResetTpu);
449 WBYTE(DpRamP->DpResetTpu, 0xFF); 413 udelay(3);
450 udelay(3); 414 break;
451 break;
452 case RIO_PCI: 415 case RIO_PCI:
453 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n"); 416 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");
454 DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM; 417 writeb(RIO_PCI_BOOT_FROM_RAM, &DpRamP->DpControl);
455 DpRamP->DpResetInt = 0xFF; 418 writeb(0xFF, &DpRamP->DpResetInt);
456 DpRamP->DpResetTpu = 0xFF; 419 writeb(0xFF, &DpRamP->DpResetTpu);
457 udelay(100); 420 udelay(100);
458 /* for (i=0; i<6000; i++); */
459 /* suspend( 3 ); */
460 break; 421 break;
461 default: 422 default:
462 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n"); 423 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 34d8787557a1..97f0fa550652 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -54,15 +54,12 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
54 54
55#include "linux_compat.h" 55#include "linux_compat.h"
56#include "rio_linux.h" 56#include "rio_linux.h"
57#include "typdef.h"
58#include "pkt.h" 57#include "pkt.h"
59#include "daemon.h" 58#include "daemon.h"
60#include "rio.h" 59#include "rio.h"
61#include "riospace.h" 60#include "riospace.h"
62#include "top.h"
63#include "cmdpkt.h" 61#include "cmdpkt.h"
64#include "map.h" 62#include "map.h"
65#include "riotypes.h"
66#include "rup.h" 63#include "rup.h"
67#include "port.h" 64#include "port.h"
68#include "riodrvr.h" 65#include "riodrvr.h"
@@ -75,12 +72,10 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
75#include "unixrup.h" 72#include "unixrup.h"
76#include "board.h" 73#include "board.h"
77#include "host.h" 74#include "host.h"
78#include "error.h"
79#include "phb.h" 75#include "phb.h"
80#include "link.h" 76#include "link.h"
81#include "cmdblk.h" 77#include "cmdblk.h"
82#include "route.h" 78#include "route.h"
83#include "control.h"
84#include "cirrus.h" 79#include "cirrus.h"
85#include "rioioctl.h" 80#include "rioioctl.h"
86 81
@@ -101,8 +96,7 @@ static char *firstchars(char *p, int nch)
101 96
102#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask)) 97#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
103/* Enable and start the transmission of packets */ 98/* Enable and start the transmission of packets */
104void RIOTxEnable(en) 99void RIOTxEnable(char *en)
105char *en;
106{ 100{
107 struct Port *PortP; 101 struct Port *PortP;
108 struct rio_info *p; 102 struct rio_info *p;
@@ -186,10 +180,8 @@ char *en;
186static int RupIntr; 180static int RupIntr;
187static int RxIntr; 181static int RxIntr;
188static int TxIntr; 182static int TxIntr;
189void RIOServiceHost(p, HostP, From) 183
190struct rio_info *p; 184void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
191struct Host *HostP;
192int From;
193{ 185{
194 rio_spin_lock(&HostP->HostLock); 186 rio_spin_lock(&HostP->HostLock);
195 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) { 187 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
@@ -201,22 +193,22 @@ int From;
201 } 193 }
202 rio_spin_unlock(&HostP->HostLock); 194 rio_spin_unlock(&HostP->HostLock);
203 195
204 if (RWORD(HostP->ParmMapP->rup_intr)) { 196 if (readw(&HostP->ParmMapP->rup_intr)) {
205 WWORD(HostP->ParmMapP->rup_intr, 0); 197 writew(0, &HostP->ParmMapP->rup_intr);
206 p->RIORupCount++; 198 p->RIORupCount++;
207 RupIntr++; 199 RupIntr++;
208 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts); 200 rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
209 RIOPollHostCommands(p, HostP); 201 RIOPollHostCommands(p, HostP);
210 } 202 }
211 203
212 if (RWORD(HostP->ParmMapP->rx_intr)) { 204 if (readw(&HostP->ParmMapP->rx_intr)) {
213 int port; 205 int port;
214 206
215 WWORD(HostP->ParmMapP->rx_intr, 0); 207 writew(0, &HostP->ParmMapP->rx_intr);
216 p->RIORxCount++; 208 p->RIORxCount++;
217 RxIntr++; 209 RxIntr++;
218 210
219 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts); 211 rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
220 /* 212 /*
221 ** Loop through every port. If the port is mapped into 213 ** Loop through every port. If the port is mapped into
222 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is 214 ** the system ( i.e. has /dev/ttyXXXX associated ) then it is
@@ -277,26 +269,26 @@ int From;
277 ** it's handshake bit is set, then we must clear the handshake, 269 ** it's handshake bit is set, then we must clear the handshake,
278 ** so that that downstream RTA is re-enabled. 270 ** so that that downstream RTA is re-enabled.
279 */ 271 */
280 if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) { 272 if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
281 /* 273 /*
282 ** MAGIC! ( Basically, handshake the RX buffer, so that 274 ** MAGIC! ( Basically, handshake the RX buffer, so that
283 ** the RTAs upstream can be re-enabled. ) 275 ** the RTAs upstream can be re-enabled. )
284 */ 276 */
285 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n"); 277 rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
286 WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET); 278 writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
287 } 279 }
288 rio_spin_unlock(&PortP->portSem); 280 rio_spin_unlock(&PortP->portSem);
289 } 281 }
290 } 282 }
291 283
292 if (RWORD(HostP->ParmMapP->tx_intr)) { 284 if (readw(&HostP->ParmMapP->tx_intr)) {
293 int port; 285 int port;
294 286
295 WWORD(HostP->ParmMapP->tx_intr, 0); 287 writew(0, &HostP->ParmMapP->tx_intr);
296 288
297 p->RIOTxCount++; 289 p->RIOTxCount++;
298 TxIntr++; 290 TxIntr++;
299 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts); 291 rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts);
300 292
301 /* 293 /*
302 ** Loop through every port. 294 ** Loop through every port.
@@ -399,7 +391,6 @@ int From;
399 /* For now don't handle RTA reboots. -- REW. 391 /* For now don't handle RTA reboots. -- REW.
400 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */ 392 Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
401 if (PortP->MagicFlags) { 393 if (PortP->MagicFlags) {
402#if 1
403 if (PortP->MagicFlags & MAGIC_REBOOT) { 394 if (PortP->MagicFlags & MAGIC_REBOOT) {
404 /* 395 /*
405 ** well, the RTA has been rebooted, and there is room 396 ** well, the RTA has been rebooted, and there is room
@@ -416,13 +407,12 @@ int From;
416 PortP->InUse = NOT_INUSE; 407 PortP->InUse = NOT_INUSE;
417 408
418 rio_spin_unlock(&PortP->portSem); 409 rio_spin_unlock(&PortP->portSem);
419 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? TRUE : FALSE, DONT_SLEEP) == RIO_FAIL) { 410 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) {
420 continue; /* with next port */ 411 continue; /* with next port */
421 } 412 }
422 rio_spin_lock(&PortP->portSem); 413 rio_spin_lock(&PortP->portSem);
423 PortP->MagicFlags &= ~MAGIC_REBOOT; 414 PortP->MagicFlags &= ~MAGIC_REBOOT;
424 } 415 }
425#endif
426 416
427 /* 417 /*
428 ** As mentioned above, this is a tacky hack to cope 418 ** As mentioned above, this is a tacky hack to cope
@@ -445,9 +435,9 @@ int From;
445 */ 435 */
446 PktCmdP = (struct PktCmd *) &PacketP->data[0]; 436 PktCmdP = (struct PktCmd *) &PacketP->data[0];
447 437
448 WBYTE(PktCmdP->Command, WFLUSH); 438 writeb(WFLUSH, &PktCmdP->Command);
449 439
450 p = PortP->HostPort % (ushort) PORTS_PER_RTA; 440 p = PortP->HostPort % (u16) PORTS_PER_RTA;
451 441
452 /* 442 /*
453 ** If second block of ports for 16 port RTA, add 8 443 ** If second block of ports for 16 port RTA, add 8
@@ -456,27 +446,27 @@ int From;
456 if (PortP->SecondBlock) 446 if (PortP->SecondBlock)
457 p += PORTS_PER_RTA; 447 p += PORTS_PER_RTA;
458 448
459 WBYTE(PktCmdP->PhbNum, p); 449 writeb(p, &PktCmdP->PhbNum);
460 450
461 /* 451 /*
462 ** to make debuggery easier 452 ** to make debuggery easier
463 */ 453 */
464 WBYTE(PacketP->data[2], 'W'); 454 writeb('W', &PacketP->data[2]);
465 WBYTE(PacketP->data[3], 'F'); 455 writeb('F', &PacketP->data[3]);
466 WBYTE(PacketP->data[4], 'L'); 456 writeb('L', &PacketP->data[4]);
467 WBYTE(PacketP->data[5], 'U'); 457 writeb('U', &PacketP->data[5]);
468 WBYTE(PacketP->data[6], 'S'); 458 writeb('S', &PacketP->data[6]);
469 WBYTE(PacketP->data[7], 'H'); 459 writeb('H', &PacketP->data[7]);
470 WBYTE(PacketP->data[8], ' '); 460 writeb(' ', &PacketP->data[8]);
471 WBYTE(PacketP->data[9], '0' + PortP->WflushFlag); 461 writeb('0' + PortP->WflushFlag, &PacketP->data[9]);
472 WBYTE(PacketP->data[10], ' '); 462 writeb(' ', &PacketP->data[10]);
473 WBYTE(PacketP->data[11], ' '); 463 writeb(' ', &PacketP->data[11]);
474 WBYTE(PacketP->data[12], '\0'); 464 writeb('\0', &PacketP->data[12]);
475 465
476 /* 466 /*
477 ** its two bytes long! 467 ** its two bytes long!
478 */ 468 */
479 WBYTE(PacketP->len, PKT_CMD_BIT | 2); 469 writeb(PKT_CMD_BIT | 2, &PacketP->len);
480 470
481 /* 471 /*
482 ** queue it! 472 ** queue it!
@@ -529,19 +519,15 @@ int From;
529} 519}
530 520
531/* 521/*
532** Routine for handling received data for clist drivers. 522** Routine for handling received data for tty drivers
533** NB: Called with the tty locked. The spl from the lockb( ) is passed.
534** we return the ttySpl level that we re-locked at.
535*/ 523*/
536static void RIOReceive(p, PortP) 524static void RIOReceive(struct rio_info *p, struct Port *PortP)
537struct rio_info *p;
538struct Port *PortP;
539{ 525{
540 struct tty_struct *TtyP; 526 struct tty_struct *TtyP;
541 register ushort transCount; 527 unsigned short transCount;
542 struct PKT *PacketP; 528 struct PKT *PacketP;
543 register uint DataCnt; 529 register unsigned int DataCnt;
544 uchar *ptr; 530 unsigned char *ptr;
545 unsigned char *buf; 531 unsigned char *buf;
546 int copied = 0; 532 int copied = 0;
547 533
@@ -594,9 +580,6 @@ struct Port *PortP;
594 transCount = 1; 580 transCount = 1;
595 while (can_remove_receive(&PacketP, PortP) 581 while (can_remove_receive(&PacketP, PortP)
596 && transCount) { 582 && transCount) {
597#ifdef STATS
598 PortP->Stat.RxIntCnt++;
599#endif /* STATS */
600 RxIntCnt++; 583 RxIntCnt++;
601 584
602 /* 585 /*
@@ -642,28 +625,15 @@ struct Port *PortP;
642 ** 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
643 ** driver). 626 ** driver).
644 */ 627 */
645#undef ___DEBUG_IT___ 628 ptr = (unsigned char *) PacketP->data + PortP->RxDataStart;
646#ifdef ___DEBUG_IT___
647 kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
648#endif
649 ptr = (uchar *) PacketP->data + PortP->RxDataStart;
650 629
651 tty_prepare_flip_string(TtyP, &buf, transCount); 630 tty_prepare_flip_string(TtyP, &buf, transCount);
652 rio_memcpy_fromio(buf, ptr, transCount); 631 rio_memcpy_fromio(buf, ptr, transCount);
653#ifdef STATS
654 /*
655 ** keep a count for statistical purposes
656 */
657 PortP->Stat.RxCharCnt += transCount;
658#endif
659 PortP->RxDataStart += transCount; 632 PortP->RxDataStart += transCount;
660 PacketP->len -= transCount; 633 PacketP->len -= transCount;
661 copied += transCount; 634 copied += transCount;
662 635
663 636
664#ifdef ___DEBUG_IT___
665 kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
666#endif
667 637
668 if (PacketP->len == 0) { 638 if (PacketP->len == 0) {
669 /* 639 /*
@@ -674,12 +644,6 @@ struct Port *PortP;
674 remove_receive(PortP); 644 remove_receive(PortP);
675 put_free_end(PortP->HostP, PacketP); 645 put_free_end(PortP->HostP, PacketP);
676 PortP->RxDataStart = 0; 646 PortP->RxDataStart = 0;
677#ifdef STATS
678 /*
679 ** more lies ( oops, I mean statistics )
680 */
681 PortP->Stat.RxPktCnt++;
682#endif /* STATS */
683 } 647 }
684 } 648 }
685 } 649 }
@@ -691,215 +655,3 @@ struct Port *PortP;
691 return; 655 return;
692} 656}
693 657
694#ifdef FUTURE_RELEASE
695/*
696** The proc routine called by the line discipline to do the work for it.
697** The proc routine works hand in hand with the interrupt routine.
698*/
699int riotproc(p, tp, cmd, port)
700struct rio_info *p;
701register struct ttystatics *tp;
702int cmd;
703int port;
704{
705 register struct Port *PortP;
706 int SysPort;
707 struct PKT *PacketP;
708
709 SysPort = port; /* Believe me, it works. */
710
711 if (SysPort < 0 || SysPort >= RIO_PORTS) {
712 rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
713 return 0;
714 }
715 PortP = p->RIOPortp[SysPort];
716
717 if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
718 rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
719 rio_dprintk(RIO_DEBUG_INTR, " PortP = 0x%x\n", PortP);
720 rio_dprintk(RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n", PortP->PhbP);
721 rio_dprintk(RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n", PortP->PhbP);
722 rio_dprintk(RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n", PortP->HostPort);
723 return 0;
724 }
725
726 switch (cmd) {
727 case T_WFLUSH:
728 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
729 /*
730 ** Because of the spooky way the RIO works, we don't need
731 ** to issue a flush command on any of the SET*F commands,
732 ** as that causes trouble with getty and login, which issue
733 ** these commands to incur a READ flush, and rely on the fact
734 ** that the line discipline does a wait for drain for them.
735 ** As the rio doesn't wait for drain, the write flush would
736 ** destroy the Password: prompt. This isn't very friendly, so
737 ** here we only issue a WFLUSH command if we are in the interrupt
738 ** routine, or we aren't executing a SET*F command.
739 */
740 if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
741 /*
742 ** form a wflush packet - 1 byte long, no data
743 */
744 if (PortP->State & RIO_DELETED) {
745 rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
746 } else {
747 if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
748 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
749 } else
750 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
751 }
752 /*
753 ** WFLUSH operation - flush the data!
754 */
755 PortP->TxBufferIn = PortP->TxBufferOut = 0;
756 } else {
757 rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
758 }
759 /*
760 ** sort out the line discipline
761 */
762 if (PortP->CookMode == COOK_WELL)
763 goto start;
764 break;
765
766 case T_RESUME:
767 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
768 /*
769 ** send pre-emptive resume packet
770 */
771 if (PortP->State & RIO_DELETED) {
772 rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
773 } else {
774 if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
775 rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
776 }
777 }
778 /*
779 ** and re-start the sender software!
780 */
781 if (PortP->CookMode == COOK_WELL)
782 goto start;
783 break;
784
785 case T_TIME:
786 rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
787 /*
788 ** T_TIME is called when xDLY is set in oflags and
789 ** the line discipline timeout has expired. It's
790 ** function in life is to clear the TIMEOUT flag
791 ** and to re-start output to the port.
792 */
793 /*
794 ** Fall through and re-start output
795 */
796 case T_OUTPUT:
797 start:
798 if (PortP->MagicFlags & MAGIC_FLUSH) {
799 PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
800 return 0;
801 }
802 RIOTxEnable((char *) PortP);
803 PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
804 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
805 break;
806
807 case T_SUSPEND:
808 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
809 /*
810 ** send a suspend pre-emptive packet.
811 */
812 if (PortP->State & RIO_DELETED) {
813 rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
814 } else {
815 if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
816 rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
817 }
818 }
819 /*
820 ** done!
821 */
822 break;
823
824 case T_BLOCK:
825 rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
826 break;
827
828 case T_RFLUSH:
829 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
830 if (PortP->State & RIO_DELETED) {
831 rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
832 PortP->RxDataStart = 0;
833 } else {
834 if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
835 rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
836 return 0;
837 }
838 PortP->RxDataStart = 0;
839 while (can_remove_receive(&PacketP, PortP)) {
840 remove_receive(PortP);
841 ShowPacket(DBG_PROC, PacketP);
842 put_free_end(PortP->HostP, PacketP);
843 }
844 if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
845 /*
846 ** MAGIC!
847 */
848 rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
849 PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
850 }
851 }
852 break;
853 /* FALLTHROUGH */
854 case T_UNBLOCK:
855 rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
856 /*
857 ** If there is any data to receive set a timeout to service it.
858 */
859 RIOReceive(p, PortP);
860 break;
861
862 case T_BREAK:
863 rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
864 /*
865 ** Send a break command. For Sys V
866 ** this is a timed break, so we
867 ** send a SBREAK[time] packet
868 */
869 /*
870 ** Build a BREAK command
871 */
872 if (PortP->State & RIO_DELETED) {
873 rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
874 } else {
875 if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
876 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
877 }
878 }
879
880 /*
881 ** done!
882 */
883 break;
884
885 case T_INPUT:
886 rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
887 break;
888 case T_PARM:
889 rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
890 break;
891
892 case T_SWTCH:
893 rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
894 break;
895
896 default:
897 rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
898 }
899 /*
900 ** T_OUTPUT returns without passing through this point!
901 */
902 /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
903 return (0);
904}
905#endif
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index c622f46d6d77..d2e8092cdb29 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -52,15 +52,12 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
52 52
53#include "linux_compat.h" 53#include "linux_compat.h"
54#include "rio_linux.h" 54#include "rio_linux.h"
55#include "typdef.h"
56#include "pkt.h" 55#include "pkt.h"
57#include "daemon.h" 56#include "daemon.h"
58#include "rio.h" 57#include "rio.h"
59#include "riospace.h" 58#include "riospace.h"
60#include "top.h"
61#include "cmdpkt.h" 59#include "cmdpkt.h"
62#include "map.h" 60#include "map.h"
63#include "riotypes.h"
64#include "rup.h" 61#include "rup.h"
65#include "port.h" 62#include "port.h"
66#include "riodrvr.h" 63#include "riodrvr.h"
@@ -73,17 +70,13 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
73#include "unixrup.h" 70#include "unixrup.h"
74#include "board.h" 71#include "board.h"
75#include "host.h" 72#include "host.h"
76#include "error.h"
77#include "phb.h" 73#include "phb.h"
78#include "link.h" 74#include "link.h"
79#include "cmdblk.h" 75#include "cmdblk.h"
80#include "route.h" 76#include "route.h"
81#include "control.h"
82#include "cirrus.h" 77#include "cirrus.h"
83#include "rioioctl.h" 78#include "rioioctl.h"
84#include "param.h" 79#include "param.h"
85#include "list.h"
86#include "sam.h"
87 80
88 81
89 82
@@ -157,20 +150,16 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
157** NB. for MPX 150** NB. for MPX
158** tty lock must NOT have been previously acquired. 151** tty lock must NOT have been previously acquired.
159*/ 152*/
160int RIOParam(PortP, cmd, Modem, SleepFlag) 153int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
161struct Port *PortP;
162int cmd;
163int Modem;
164int SleepFlag;
165{ 154{
166 register struct tty_struct *TtyP; 155 struct tty_struct *TtyP;
167 int retval; 156 int retval;
168 register struct phb_param *phb_param_ptr; 157 struct phb_param *phb_param_ptr;
169 PKT *PacketP; 158 struct PKT *PacketP;
170 int res; 159 int res;
171 uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0; 160 u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
172 uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0; 161 u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
173 uchar LNext = 0, TxBaud = 0, RxBaud = 0; 162 u8 LNext = 0, TxBaud = 0, RxBaud = 0;
174 int retries = 0xff; 163 int retries = 0xff;
175 unsigned long flags; 164 unsigned long flags;
176 165
@@ -226,16 +215,13 @@ int SleepFlag;
226 if (retval == RIO_FAIL) { 215 if (retval == RIO_FAIL) {
227 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n"); 216 rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
228 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 217 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
229 pseterr(EINTR);
230 func_exit(); 218 func_exit();
231 219 return -EINTR;
232 return RIO_FAIL;
233 } 220 }
234 if (PortP->State & RIO_DELETED) { 221 if (PortP->State & RIO_DELETED) {
235 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 222 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
236 func_exit(); 223 func_exit();
237 224 return 0;
238 return RIO_SUCCESS;
239 } 225 }
240 } 226 }
241 227
@@ -247,7 +233,7 @@ int SleepFlag;
247 } 233 }
248 234
249 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);
250 rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP); 236 rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP);
251 237
252 phb_param_ptr = (struct phb_param *) PacketP->data; 238 phb_param_ptr = (struct phb_param *) PacketP->data;
253 239
@@ -474,9 +460,6 @@ int SleepFlag;
474 e(115200); /* e(230400);e(460800); e(921600); */ 460 e(115200); /* e(230400);e(460800); e(921600); */
475 } 461 }
476 462
477 /* XXX MIssing conversion table. XXX */
478 /* (TtyP->termios->c_cflag & V_CBAUD); */
479
480 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud); 463 rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
481 464
482 465
@@ -552,23 +535,23 @@ int SleepFlag;
552 /* 535 /*
553 ** Actually write the info into the packet to be sent 536 ** Actually write the info into the packet to be sent
554 */ 537 */
555 WBYTE(phb_param_ptr->Cmd, cmd); 538 writeb(cmd, &phb_param_ptr->Cmd);
556 WBYTE(phb_param_ptr->Cor1, Cor1); 539 writeb(Cor1, &phb_param_ptr->Cor1);
557 WBYTE(phb_param_ptr->Cor2, Cor2); 540 writeb(Cor2, &phb_param_ptr->Cor2);
558 WBYTE(phb_param_ptr->Cor4, Cor4); 541 writeb(Cor4, &phb_param_ptr->Cor4);
559 WBYTE(phb_param_ptr->Cor5, Cor5); 542 writeb(Cor5, &phb_param_ptr->Cor5);
560 WBYTE(phb_param_ptr->TxXon, TxXon); 543 writeb(TxXon, &phb_param_ptr->TxXon);
561 WBYTE(phb_param_ptr->RxXon, RxXon); 544 writeb(RxXon, &phb_param_ptr->RxXon);
562 WBYTE(phb_param_ptr->TxXoff, TxXoff); 545 writeb(TxXoff, &phb_param_ptr->TxXoff);
563 WBYTE(phb_param_ptr->RxXoff, RxXoff); 546 writeb(RxXoff, &phb_param_ptr->RxXoff);
564 WBYTE(phb_param_ptr->LNext, LNext); 547 writeb(LNext, &phb_param_ptr->LNext);
565 WBYTE(phb_param_ptr->TxBaud, TxBaud); 548 writeb(TxBaud, &phb_param_ptr->TxBaud);
566 WBYTE(phb_param_ptr->RxBaud, RxBaud); 549 writeb(RxBaud, &phb_param_ptr->RxBaud);
567 550
568 /* 551 /*
569 ** Set the length/command field 552 ** Set the length/command field
570 */ 553 */
571 WBYTE(PacketP->len, 12 | PKT_CMD_BIT); 554 writeb(12 | PKT_CMD_BIT, &PacketP->len);
572 555
573 /* 556 /*
574 ** The packet is formed - now, whack it off 557 ** The packet is formed - now, whack it off
@@ -589,7 +572,7 @@ int SleepFlag;
589 */ 572 */
590 func_exit(); 573 func_exit();
591 574
592 return RIO_SUCCESS; 575 return 0;
593} 576}
594 577
595 578
@@ -597,15 +580,13 @@ int SleepFlag;
597** 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
598** 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.
599*/ 582*/
600int can_add_transmit(PktP, PortP) 583int can_add_transmit(struct PKT **PktP, struct Port *PortP)
601PKT **PktP;
602struct Port *PortP;
603{ 584{
604 register PKT *tp; 585 struct PKT *tp;
605 586
606 *PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd)); 587 *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
607 588
608 return !((uint) tp & PKT_IN_USE); 589 return !((unsigned long) tp & PKT_IN_USE);
609} 590}
610 591
611/* 592/*
@@ -613,27 +594,24 @@ struct Port *PortP;
613** and then move the TxAdd pointer along one position to point to the next 594** and then move the TxAdd pointer along one position to point to the next
614** packet pointer. You must wrap the pointer from the end back to the start. 595** packet pointer. You must wrap the pointer from the end back to the start.
615*/ 596*/
616void add_transmit(PortP) 597void add_transmit(struct Port *PortP)
617struct Port *PortP;
618{ 598{
619 if (RWORD(*PortP->TxAdd) & PKT_IN_USE) { 599 if (readw(PortP->TxAdd) & PKT_IN_USE) {
620 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!"); 600 rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
621 } 601 }
622 WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE); 602 writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
623 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1; 603 PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
624 WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd)); 604 writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
625} 605}
626 606
627/**************************************** 607/****************************************
628 * Put a packet onto the end of the 608 * Put a packet onto the end of the
629 * free list 609 * free list
630 ****************************************/ 610 ****************************************/
631void put_free_end(HostP, PktP) 611void put_free_end(struct Host *HostP, struct PKT *PktP)
632struct Host *HostP;
633PKT *PktP;
634{ 612{
635 FREE_LIST *tmp_pointer; 613 struct rio_free_list *tmp_pointer;
636 ushort old_end, new_end; 614 unsigned short old_end, new_end;
637 unsigned long flags; 615 unsigned long flags;
638 616
639 rio_spin_lock_irqsave(&HostP->HostLock, flags); 617 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -643,21 +621,21 @@ PKT *PktP;
643 * 621 *
644 ************************************************/ 622 ************************************************/
645 623
646 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP); 624 rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
647 625
648 if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) { 626 if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
649 new_end = RIO_OFF(HostP->Caddr, PktP); 627 new_end = RIO_OFF(HostP->Caddr, PktP);
650 tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end); 628 tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end);
651 WWORD(tmp_pointer->next, new_end); 629 writew(new_end, &tmp_pointer->next);
652 WWORD(((FREE_LIST *) PktP)->prev, old_end); 630 writew(old_end, &((struct rio_free_list *) PktP)->prev);
653 WWORD(((FREE_LIST *) PktP)->next, TPNULL); 631 writew(TPNULL, &((struct rio_free_list *) PktP)->next);
654 WWORD(HostP->ParmMapP->free_list_end, new_end); 632 writew(new_end, &HostP->ParmMapP->free_list_end);
655 } else { /* First packet on the free list this should never happen! */ 633 } else { /* First packet on the free list this should never happen! */
656 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");
657 WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP)); 635 writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
658 tmp_pointer = (FREE_LIST *) PktP; 636 tmp_pointer = (struct rio_free_list *) PktP;
659 WWORD(tmp_pointer->prev, TPNULL); 637 writew(TPNULL, &tmp_pointer->prev);
660 WWORD(tmp_pointer->next, TPNULL); 638 writew(TPNULL, &tmp_pointer->next);
661 } 639 }
662 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock); 640 rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
663 rio_spin_unlock_irqrestore(&HostP->HostLock, flags); 641 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
@@ -669,12 +647,10 @@ PKT *PktP;
669** 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,
670** then can_remove_receive() returns 0. 648** then can_remove_receive() returns 0.
671*/ 649*/
672int can_remove_receive(PktP, PortP) 650int can_remove_receive(struct PKT **PktP, struct Port *PortP)
673PKT **PktP;
674struct Port *PortP;
675{ 651{
676 if (RWORD(*PortP->RxRemove) & PKT_IN_USE) { 652 if (readw(PortP->RxRemove) & PKT_IN_USE) {
677 *PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 653 *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
678 return 1; 654 return 1;
679 } 655 }
680 return 0; 656 return 0;
@@ -685,10 +661,9 @@ struct Port *PortP;
685** and then bump the pointers. Once the pointers get to the end, they must 661** and then bump the pointers. Once the pointers get to the end, they must
686** be wrapped back to the start. 662** be wrapped back to the start.
687*/ 663*/
688void remove_receive(PortP) 664void remove_receive(struct Port *PortP)
689struct Port *PortP;
690{ 665{
691 WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE); 666 writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);
692 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1; 667 PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
693 WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove)); 668 writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);
694} 669}
diff --git a/drivers/char/rio/riopcicopy.c b/drivers/char/rio/riopcicopy.c
deleted file mode 100644
index 535afaa51ca5..000000000000
--- a/drivers/char/rio/riopcicopy.c
+++ /dev/null
@@ -1,8 +0,0 @@
1
2/* Yeah. We have copyright on this one. Sure. */
3
4void rio_pcicopy(char *from, char *to, int amount)
5{
6 while (amount--)
7 *to++ = *from++;
8}
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index f98888f52659..357085337942 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -50,15 +50,12 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
50 50
51#include "linux_compat.h" 51#include "linux_compat.h"
52#include "rio_linux.h" 52#include "rio_linux.h"
53#include "typdef.h"
54#include "pkt.h" 53#include "pkt.h"
55#include "daemon.h" 54#include "daemon.h"
56#include "rio.h" 55#include "rio.h"
57#include "riospace.h" 56#include "riospace.h"
58#include "top.h"
59#include "cmdpkt.h" 57#include "cmdpkt.h"
60#include "map.h" 58#include "map.h"
61#include "riotypes.h"
62#include "rup.h" 59#include "rup.h"
63#include "port.h" 60#include "port.h"
64#include "riodrvr.h" 61#include "riodrvr.h"
@@ -71,29 +68,25 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
71#include "unixrup.h" 68#include "unixrup.h"
72#include "board.h" 69#include "board.h"
73#include "host.h" 70#include "host.h"
74#include "error.h"
75#include "phb.h" 71#include "phb.h"
76#include "link.h" 72#include "link.h"
77#include "cmdblk.h" 73#include "cmdblk.h"
78#include "route.h" 74#include "route.h"
79#include "control.h"
80#include "cirrus.h" 75#include "cirrus.h"
81#include "rioioctl.h" 76#include "rioioctl.h"
82#include "param.h" 77#include "param.h"
83#include "list.h"
84#include "sam.h"
85 78
86static int RIOCheckIsolated(struct rio_info *, struct Host *, uint); 79static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
87static int RIOIsolate(struct rio_info *, struct Host *, uint); 80static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
88static int RIOCheck(struct Host *, uint); 81static int RIOCheck(struct Host *, unsigned int);
89static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int); 82static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
90 83
91 84
92/* 85/*
93** Incoming on the ROUTE_RUP 86** Incoming on the ROUTE_RUP
94** I wrote this while I was tired. Forgive me. 87** I wrote this while I was tired. Forgive me.
95*/ 88*/
96int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP) 89int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP)
97{ 90{
98 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; 91 struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
99 struct PktCmd_M *PktReplyP; 92 struct PktCmd_M *PktReplyP;
@@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
104 int ThisLink, ThisLinkMin, ThisLinkMax; 97 int ThisLink, ThisLinkMin, ThisLinkMax;
105 int port; 98 int port;
106 int Mod, Mod1, Mod2; 99 int Mod, Mod1, Mod2;
107 ushort RtaType; 100 unsigned short RtaType;
108 uint RtaUniq; 101 unsigned int RtaUniq;
109 uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */ 102 unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
110 uint OldUnit, NewUnit, OldLink, NewLink; 103 unsigned int OldUnit, NewUnit, OldLink, NewLink;
111 char *MyType, *MyName; 104 char *MyType, *MyName;
112 int Lies; 105 int Lies;
113 unsigned long flags; 106 unsigned long flags;
@@ -115,7 +108,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
115 /* 108 /*
116 ** Is this unit telling us it's current link topology? 109 ** Is this unit telling us it's current link topology?
117 */ 110 */
118 if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) { 111 if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
119 MapP = HostP->Mapping; 112 MapP = HostP->Mapping;
120 113
121 /* 114 /*
@@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
125 ** from an RTA then we need to fill in the Mapping structure's 118 ** from an RTA then we need to fill in the Mapping structure's
126 ** Topology array for the unit. 119 ** Topology array for the unit.
127 */ 120 */
128 if (Rup >= (ushort) MAX_RUP) { 121 if (Rup >= (unsigned short) MAX_RUP) {
129 ThisUnit = HOST_ID; 122 ThisUnit = HOST_ID;
130 TopP = HostP->Topology; 123 TopP = HostP->Topology;
131 MyType = "Host"; 124 MyType = "Host";
@@ -151,11 +144,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
151 ** it won't lie about network interconnect, total disconnects 144 ** it won't lie about network interconnect, total disconnects
152 ** and no-IDs. (or at least, it doesn't *matter* if it does) 145 ** and no-IDs. (or at least, it doesn't *matter* if it does)
153 */ 146 */
154 if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP) 147 if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
155 continue; 148 continue;
156 149
157 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) { 150 for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
158 if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) { 151 if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
159 Lies++; 152 Lies++;
160 } 153 }
161 } 154 }
@@ -164,11 +157,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
164 if (Lies) { 157 if (Lies) {
165 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies); 158 rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
166 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n", 159 rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
167 RBYTE(PktCmdP->RouteTopology[0].Unit), 160 readb(&PktCmdP->RouteTopology[0].Unit),
168 'A' + RBYTE(PktCmdP->RouteTopology[0].Link), 161 'A' + readb(&PktCmdP->RouteTopology[0].Link),
169 RBYTE(PktCmdP->RouteTopology[1].Unit), 162 readb(&PktCmdP->RouteTopology[1].Unit),
170 'A' + RBYTE(PktCmdP->RouteTopology[1].Link), RBYTE(PktCmdP->RouteTopology[2].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[2].Link), RBYTE(PktCmdP->RouteTopology[3].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[3].Link)); 163 'A' + readb(&PktCmdP->RouteTopology[1].Link), readb(&PktCmdP->RouteTopology[2].Unit), 'A' + readb(&PktCmdP->RouteTopology[2].Link), readb(&PktCmdP->RouteTopology[3].Unit), 'A' + readb(&PktCmdP->RouteTopology[3].Link));
171 return TRUE; 164 return 1;
172 } 165 }
173 166
174 /* 167 /*
@@ -184,8 +177,8 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
184 /* 177 /*
185 ** this is what it is now connected to 178 ** this is what it is now connected to
186 */ 179 */
187 NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit); 180 NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
188 NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link); 181 NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);
189 182
190 if (OldUnit != NewUnit || OldLink != NewLink) { 183 if (OldUnit != NewUnit || OldLink != NewLink) {
191 /* 184 /*
@@ -219,7 +212,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
219 212
220 if (NewUnit == ROUTE_INTERCONNECT) { 213 if (NewUnit == ROUTE_INTERCONNECT) {
221 if (!p->RIONoMessage) 214 if (!p->RIONoMessage)
222 cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink); 215 printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
223 } 216 }
224 217
225 /* 218 /*
@@ -258,18 +251,18 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
258 RIOCheckIsolated(p, HostP, OldUnit); 251 RIOCheckIsolated(p, HostP, OldUnit);
259 } 252 }
260 } 253 }
261 return TRUE; 254 return 1;
262 } 255 }
263 256
264 /* 257 /*
265 ** The only other command we recognise is a route_request command 258 ** The only other command we recognise is a route_request command
266 */ 259 */
267 if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) { 260 if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
268 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP); 261 rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
269 return TRUE; 262 return 1;
270 } 263 }
271 264
272 RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24); 265 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
273 266
274 /* 267 /*
275 ** Determine if 8 or 16 port RTA 268 ** Determine if 8 or 16 port RTA
@@ -278,7 +271,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
278 271
279 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq); 272 rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
280 273
281 Mod = RBYTE(PktCmdP->ModuleTypes); 274 Mod = readb(&PktCmdP->ModuleTypes);
282 Mod1 = LONYBLE(Mod); 275 Mod1 = LONYBLE(Mod);
283 if (RtaType == TYPE_RTA16) { 276 if (RtaType == TYPE_RTA16) {
284 /* 277 /*
@@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
292 rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name); 285 rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
293 } 286 }
294 287
295 if (RtaUniq == 0xffffffff) {
296 ShowPacket(DBG_SPECIAL, PacketP);
297 }
298
299 /* 288 /*
300 ** try to unhook a command block from the command free list. 289 ** try to unhook a command block from the command free list.
301 */ 290 */
@@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
320 PktReplyP->Command = ROUTE_FOAD; 309 PktReplyP->Command = ROUTE_FOAD;
321 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 310 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
322 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 311 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
323 return TRUE; 312 return 1;
324 } 313 }
325 314
326 /* 315 /*
@@ -348,13 +337,13 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
348 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) { 337 if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
349 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) { 338 if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
350 if (!p->RIONoMessage) 339 if (!p->RIONoMessage)
351 cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name); 340 printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
352 HostP->Mapping[ThisUnit].Flags |= MSG_DONE; 341 HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
353 } 342 }
354 PktReplyP->Command = ROUTE_FOAD; 343 PktReplyP->Command = ROUTE_FOAD;
355 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7); 344 HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
356 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 345 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
357 return TRUE; 346 return 1;
358 } 347 }
359 348
360 /* 349 /*
@@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
447 /* 436 /*
448 ** Job done, get on with the interrupts! 437 ** Job done, get on with the interrupts!
449 */ 438 */
450 return TRUE; 439 return 1;
451 } 440 }
452 } 441 }
453 /* 442 /*
@@ -475,7 +464,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
475 464
476 if (!UnknownMesgDone) { 465 if (!UnknownMesgDone) {
477 if (!p->RIONoMessage) 466 if (!p->RIONoMessage)
478 cprintf("One or more unknown RTAs are being updated.\n"); 467 printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
479 UnknownMesgDone = 1; 468 UnknownMesgDone = 1;
480 } 469 }
481 470
@@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
491 if (RtaType == TYPE_RTA16) { 480 if (RtaType == TYPE_RTA16) {
492 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) { 481 if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
493 RIODefaultName(p, HostP, ThisUnit); 482 RIODefaultName(p, HostP, ThisUnit);
494 FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP); 483 rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
495 } 484 }
496 } else { 485 } else {
497 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) { 486 if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
498 RIODefaultName(p, HostP, ThisUnit); 487 RIODefaultName(p, HostP, ThisUnit);
499 FillSlot(ThisUnit, 0, RtaUniq, HostP); 488 rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
500 } 489 }
501 } 490 }
502 PktReplyP->Command = ROUTE_USED; 491 PktReplyP->Command = ROUTE_USED;
503 HostP->Copy("RT_USED", PktReplyP->CommandText, 7); 492 HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
504 } 493 }
505 RIOQueueCmdBlk(HostP, Rup, CmdBlkP); 494 RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
506 return TRUE; 495 return 1;
507} 496}
508 497
509 498
510void RIOFixPhbs(p, HostP, unit) 499void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
511struct rio_info *p;
512struct Host *HostP;
513uint unit;
514{ 500{
515 ushort link, port; 501 unsigned short link, port;
516 struct Port *PortP; 502 struct Port *PortP;
517 unsigned long flags; 503 unsigned long flags;
518 int PortN = HostP->Mapping[unit].SysPort; 504 int PortN = HostP->Mapping[unit].SysPort;
@@ -520,19 +506,19 @@ uint unit;
520 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN); 506 rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
521 507
522 if (PortN != -1) { 508 if (PortN != -1) {
523 ushort dest_unit = HostP->Mapping[unit].ID2; 509 unsigned short dest_unit = HostP->Mapping[unit].ID2;
524 510
525 /* 511 /*
526 ** Get the link number used for the 1st 8 phbs on this unit. 512 ** Get the link number used for the 1st 8 phbs on this unit.
527 */ 513 */
528 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort]; 514 PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
529 515
530 link = RWORD(PortP->PhbP->link); 516 link = readw(&PortP->PhbP->link);
531 517
532 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) { 518 for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
533 ushort dest_port = port + 8; 519 unsigned short dest_port = port + 8;
534 WORD *TxPktP; 520 u16 *TxPktP;
535 PKT *Pkt; 521 struct PKT *Pkt;
536 522
537 PortP = p->RIOPortp[PortN]; 523 PortP = p->RIOPortp[PortN];
538 524
@@ -569,18 +555,18 @@ uint unit;
569 ** card. This needs to be translated into a 32 bit pointer 555 ** card. This needs to be translated into a 32 bit pointer
570 ** so it can be accessed from the driver. 556 ** so it can be accessed from the driver.
571 */ 557 */
572 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP)); 558 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP));
573 559
574 /* 560 /*
575 ** If the packet is used, reset it. 561 ** If the packet is used, reset it.
576 */ 562 */
577 Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE); 563 Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE);
578 WBYTE(Pkt->dest_unit, dest_unit); 564 writeb(dest_unit, &Pkt->dest_unit);
579 WBYTE(Pkt->dest_port, dest_port); 565 writeb(dest_port, &Pkt->dest_port);
580 } 566 }
581 rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", RWORD(PortP->PhbP->destination) & 0xff, (RWORD(PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port); 567 rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", readw(&PortP->PhbP->destination) & 0xff, (readw(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
582 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 568 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
583 WWORD(PortP->PhbP->link, link); 569 writew(link, &PortP->PhbP->link);
584 570
585 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 571 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
586 } 572 }
@@ -590,9 +576,9 @@ uint unit;
590 */ 576 */
591 if (link > 3) 577 if (link > 3)
592 return; 578 return;
593 if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) { 579 if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
594 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7); 580 rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
595 WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7); 581 writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
596 } 582 }
597 } 583 }
598} 584}
@@ -603,10 +589,7 @@ uint unit;
603** the world about it. This is done to ensure that the configurator 589** the world about it. This is done to ensure that the configurator
604** only gets up-to-date information about what is going on. 590** only gets up-to-date information about what is going on.
605*/ 591*/
606static int RIOCheckIsolated(p, HostP, UnitId) 592static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
607struct rio_info *p;
608struct Host *HostP;
609uint UnitId;
610{ 593{
611 unsigned long flags; 594 unsigned long flags;
612 rio_spin_lock_irqsave(&HostP->HostLock, flags); 595 rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -628,12 +611,9 @@ uint UnitId;
628** all the units attached to it. This will mean that the entire 611** all the units attached to it. This will mean that the entire
629** subnet will re-introduce itself. 612** subnet will re-introduce itself.
630*/ 613*/
631static int RIOIsolate(p, HostP, UnitId) 614static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
632struct rio_info *p;
633struct Host *HostP;
634uint UnitId;
635{ 615{
636 uint link, unit; 616 unsigned int link, unit;
637 617
638 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */ 618 UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
639 619
@@ -658,9 +638,7 @@ uint UnitId;
658 return 1; 638 return 1;
659} 639}
660 640
661static int RIOCheck(HostP, UnitId) 641static int RIOCheck(struct Host *HostP, unsigned int UnitId)
662struct Host *HostP;
663uint UnitId;
664{ 642{
665 unsigned char link; 643 unsigned char link;
666 644
@@ -714,8 +692,7 @@ uint UnitId;
714** Returns the type of unit (host, 16/8 port RTA) 692** Returns the type of unit (host, 16/8 port RTA)
715*/ 693*/
716 694
717uint GetUnitType(Uniq) 695unsigned int GetUnitType(unsigned int Uniq)
718uint Uniq;
719{ 696{
720 switch ((Uniq >> 28) & 0xf) { 697 switch ((Uniq >> 28) & 0xf) {
721 case RIO_AT: 698 case RIO_AT:
@@ -736,8 +713,7 @@ uint Uniq;
736 } 713 }
737} 714}
738 715
739int RIOSetChange(p) 716int RIOSetChange(struct rio_info *p)
740struct rio_info *p;
741{ 717{
742 if (p->RIOQuickCheck != NOT_CHANGED) 718 if (p->RIOQuickCheck != NOT_CHANGED)
743 return (0); 719 return (0);
@@ -751,14 +727,13 @@ struct rio_info *p;
751 return (0); 727 return (0);
752} 728}
753 729
754static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change) 730static void RIOConCon(struct rio_info *p,
755struct rio_info *p; 731 struct Host *HostP,
756struct Host *HostP; 732 unsigned int FromId,
757uint FromId; 733 unsigned int FromLink,
758uint FromLink; 734 unsigned int ToId,
759uint ToId; 735 unsigned int ToLink,
760uint ToLink; 736 int Change)
761int Change;
762{ 737{
763 char *FromName; 738 char *FromName;
764 char *FromType; 739 char *FromType;
@@ -818,7 +793,7 @@ int Change;
818 ToType = ToId ? "RTA" : "HOST"; 793 ToType = ToId ? "RTA" : "HOST";
819 794
820 rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); 795 rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
821 cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected"); 796 printk(KERN_DEBUG "rio: Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
822} 797}
823 798
824/* 799/*
@@ -838,7 +813,7 @@ static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
838 */ 813 */
839 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 814 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
840 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) { 815 if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
841 bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map)); 816 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
842 } 817 }
843 } 818 }
844 return 0; 819 return 0;
@@ -898,7 +873,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
898 int nOther = (HostP->Mapping[unit].ID2) - 1; 873 int nOther = (HostP->Mapping[unit].ID2) - 1;
899 874
900 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther); 875 rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
901 bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map)); 876 memset(&HostP->Mapping[nOther], 0, sizeof(struct Map));
902 } 877 }
903 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]); 878 RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
904 879
@@ -912,7 +887,8 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
912** This function scans the given host table for either one 887** This function scans the given host table for either one
913** or two free unit ID's. 888** or two free unit ID's.
914*/ 889*/
915int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2) 890
891int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
916{ 892{
917 int unit, tempID; 893 int unit, tempID;
918 894
@@ -997,7 +973,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
997 /* 973 /*
998 ** Clear out this slot now that we intend to use it. 974 ** Clear out this slot now that we intend to use it.
999 */ 975 */
1000 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 976 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1001 977
1002 /* 978 /*
1003 ** If the second ID is not needed then we can return 979 ** If the second ID is not needed then we can return
@@ -1015,7 +991,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
1015 /* 991 /*
1016 ** Clear out this slot now that we intend to use it. 992 ** Clear out this slot now that we intend to use it.
1017 */ 993 */
1018 bzero(&HostP->Mapping[unit], sizeof(struct Map)); 994 memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
1019 995
1020 /* At this point under the right(wrong?) conditions 996 /* At this point under the right(wrong?) conditions
1021 ** we may have a first unit ID being higher than the 997 ** we may have a first unit ID being higher than the
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index a86b216ab653..d3abe0d37d64 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -53,15 +53,12 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
53 53
54#include "linux_compat.h" 54#include "linux_compat.h"
55#include "rio_linux.h" 55#include "rio_linux.h"
56#include "typdef.h"
57#include "pkt.h" 56#include "pkt.h"
58#include "daemon.h" 57#include "daemon.h"
59#include "rio.h" 58#include "rio.h"
60#include "riospace.h" 59#include "riospace.h"
61#include "top.h"
62#include "cmdpkt.h" 60#include "cmdpkt.h"
63#include "map.h" 61#include "map.h"
64#include "riotypes.h"
65#include "rup.h" 62#include "rup.h"
66#include "port.h" 63#include "port.h"
67#include "riodrvr.h" 64#include "riodrvr.h"
@@ -74,25 +71,20 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
74#include "unixrup.h" 71#include "unixrup.h"
75#include "board.h" 72#include "board.h"
76#include "host.h" 73#include "host.h"
77#include "error.h"
78#include "phb.h" 74#include "phb.h"
79#include "link.h" 75#include "link.h"
80#include "cmdblk.h" 76#include "cmdblk.h"
81#include "route.h" 77#include "route.h"
82#include "control.h"
83#include "cirrus.h" 78#include "cirrus.h"
84#include "rioioctl.h" 79#include "rioioctl.h"
85#include "param.h" 80#include "param.h"
86#include "list.h"
87#include "sam.h"
88#include "protsts.h" 81#include "protsts.h"
89 82
90/* 83/*
91** A configuration table has been loaded. It is now up to us 84** A configuration table has been loaded. It is now up to us
92** to sort it out and use the information contained therein. 85** to sort it out and use the information contained therein.
93*/ 86*/
94int RIONewTable(p) 87int RIONewTable(struct rio_info *p)
95struct rio_info *p;
96{ 88{
97 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt; 89 int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
98 struct Map *MapP; 90 struct Map *MapP;
@@ -137,7 +129,7 @@ struct rio_info *p;
137 cptr = MapP->Name; /* (2) */ 129 cptr = MapP->Name; /* (2) */
138 cptr[MAX_NAME_LEN - 1] = '\0'; 130 cptr[MAX_NAME_LEN - 1] = '\0';
139 if (cptr[0] == '\0') { 131 if (cptr[0] == '\0') {
140 bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8); 132 memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
141 MapP->Name[5] = '0' + Entry / 10; 133 MapP->Name[5] = '0' + Entry / 10;
142 MapP->Name[6] = '0' + Entry % 10; 134 MapP->Name[6] = '0' + Entry % 10;
143 } 135 }
@@ -298,9 +290,9 @@ struct rio_info *p;
298 */ 290 */
299 for (Host = 0; Host < RIO_HOSTS; Host++) { 291 for (Host = 0; Host < RIO_HOSTS; Host++) {
300 for (Entry = 0; Entry < MAX_RUP; Entry++) { 292 for (Entry = 0; Entry < MAX_RUP; Entry++) {
301 bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map)); 293 memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map));
302 } 294 }
303 bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name)); 295 memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name));
304 } 296 }
305 297
306 /* 298 /*
@@ -326,7 +318,7 @@ struct rio_info *p;
326 */ 318 */
327 if (MapP->ID == 0) { 319 if (MapP->ID == 0) {
328 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name); 320 rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
329 bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN); 321 memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN);
330 continue; 322 continue;
331 } 323 }
332 324
@@ -370,7 +362,7 @@ struct rio_info *p;
370 } 362 }
371 } 363 }
372 if (!p->RIOHosts[Host].Name[0]) { 364 if (!p->RIOHosts[Host].Name[0]) {
373 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 365 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
374 p->RIOHosts[Host].Name[5] += Host; 366 p->RIOHosts[Host].Name[5] += Host;
375 } 367 }
376 /* 368 /*
@@ -398,7 +390,7 @@ struct rio_info *p;
398 */ 390 */
399 if (Host1 != Host) { 391 if (Host1 != Host) {
400 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name); 392 rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
401 bcopy("HOST 1", p->RIOHosts[Host].Name, 7); 393 memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
402 p->RIOHosts[Host].Name[5] += Host1; 394 p->RIOHosts[Host].Name[5] += Host1;
403 } 395 }
404 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name); 396 rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
@@ -409,9 +401,10 @@ struct rio_info *p;
409/* 401/*
410** User process needs the config table - build it from first 402** User process needs the config table - build it from first
411** principles. 403** principles.
404**
405* FIXME: SMP locking
412*/ 406*/
413int RIOApel(p) 407int RIOApel(struct rio_info *p)
414struct rio_info *p;
415{ 408{
416 int Host; 409 int Host;
417 int link; 410 int link;
@@ -419,17 +412,17 @@ struct rio_info *p;
419 int Next = 0; 412 int Next = 0;
420 struct Map *MapP; 413 struct Map *MapP;
421 struct Host *HostP; 414 struct Host *HostP;
422 long oldspl; 415 unsigned long flags;
423
424 disable(oldspl); /* strange but true! */
425 416
426 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n"); 417 rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
427 418
428 bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES); 419 memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES);
429 420
430 for (Host = 0; Host < RIO_HOSTS; Host++) { 421 for (Host = 0; Host < RIO_HOSTS; Host++) {
431 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host); 422 rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
432 HostP = &p->RIOHosts[Host]; 423 HostP = &p->RIOHosts[Host];
424 rio_spin_lock_irqsave(&HostP->HostLock, flags);
425
433 MapP = &p->RIOConnectTable[Next++]; 426 MapP = &p->RIOConnectTable[Next++];
434 MapP->HostUniqueNum = HostP->UniqueNum; 427 MapP->HostUniqueNum = HostP->UniqueNum;
435 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) 428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
@@ -440,7 +433,7 @@ struct rio_info *p;
440 MapP->SysPort = NO_PORT; 433 MapP->SysPort = NO_PORT;
441 for (link = 0; link < LINKS_PER_UNIT; link++) 434 for (link = 0; link < LINKS_PER_UNIT; link++)
442 MapP->Topology[link] = HostP->Topology[link]; 435 MapP->Topology[link] = HostP->Topology[link];
443 bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN); 436 memcpy(MapP->Name, HostP->Name, MAX_NAME_LEN);
444 for (Rup = 0; Rup < MAX_RUP; Rup++) { 437 for (Rup = 0; Rup < MAX_RUP; Rup++) {
445 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) { 438 if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
446 p->RIOConnectTable[Next] = HostP->Mapping[Rup]; 439 p->RIOConnectTable[Next] = HostP->Mapping[Rup];
@@ -453,8 +446,8 @@ struct rio_info *p;
453 Next++; 446 Next++;
454 } 447 }
455 } 448 }
449 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
456 } 450 }
457 restore(oldspl);
458 return 0; 451 return 0;
459} 452}
460 453
@@ -463,9 +456,7 @@ struct rio_info *p;
463** if the entry is suitably inactive, then we can gob on it and remove 456** if the entry is suitably inactive, then we can gob on it and remove
464** it from the table. 457** it from the table.
465*/ 458*/
466int RIODeleteRta(p, MapP) 459int RIODeleteRta(struct rio_info *p, struct Map *MapP)
467struct rio_info *p;
468struct Map *MapP;
469{ 460{
470 int host, entry, port, link; 461 int host, entry, port, link;
471 int SysPort; 462 int SysPort;
@@ -541,10 +532,10 @@ struct Map *MapP;
541 ** the phb to port mappings in RIORouteRup. 532 ** the phb to port mappings in RIORouteRup.
542 */ 533 */
543 if (PortP->SecondBlock) { 534 if (PortP->SecondBlock) {
544 ushort dest_unit = HostMapP->ID; 535 u16 dest_unit = HostMapP->ID;
545 ushort dest_port = port - SysPort; 536 u16 dest_port = port - SysPort;
546 WORD *TxPktP; 537 u16 *TxPktP;
547 PKT *Pkt; 538 struct PKT *Pkt;
548 539
549 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) { 540 for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
550 /* 541 /*
@@ -554,19 +545,19 @@ struct Map *MapP;
554 ** a 32 bit pointer so it can be 545 ** a 32 bit pointer so it can be
555 ** accessed from the driver. 546 ** accessed from the driver.
556 */ 547 */
557 Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP)); 548 Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP));
558 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", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port);
559 WWORD(Pkt->dest_unit, dest_unit); 550 writew(dest_unit, &Pkt->dest_unit);
560 WWORD(Pkt->dest_port, dest_port); 551 writew(dest_port, &Pkt->dest_port);
561 } 552 }
562 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, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port);
563 WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8)); 554 writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
564 } 555 }
565 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags); 556 rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
566 } 557 }
567 } 558 }
568 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n"); 559 rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
569 bzero((char *) HostMapP, sizeof(struct Map)); 560 memset(HostMapP, 0, sizeof(struct Map));
570 work_done++; 561 work_done++;
571 } 562 }
572 } 563 }
@@ -576,11 +567,11 @@ struct Map *MapP;
576 /* XXXXX lock me up */ 567 /* XXXXX lock me up */
577 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) { 568 for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
578 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 569 if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
579 bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map)); 570 memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
580 work_done++; 571 work_done++;
581 } 572 }
582 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) { 573 if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
583 bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map)); 574 memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map));
584 work_done++; 575 work_done++;
585 } 576 }
586 } 577 }
@@ -602,7 +593,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
602 593
603 rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort); 594 rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
604 595
605 if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) { 596 if ((MapP->ID != (u16) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
606 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n"); 597 rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
607 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE; 598 p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
608 return -EINVAL; 599 return -EINVAL;
@@ -648,7 +639,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
648 ** Now we have a host we need to allocate an ID 639 ** Now we have a host we need to allocate an ID
649 ** if the entry does not already have one. 640 ** if the entry does not already have one.
650 */ 641 */
651 if (MapP->ID == (ushort) - 1) { 642 if (MapP->ID == (u16) - 1) {
652 int nNewID; 643 int nNewID;
653 644
654 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name); 645 rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
@@ -667,7 +658,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
667 p->RIOError.Error = COULDNT_FIND_ENTRY; 658 p->RIOError.Error = COULDNT_FIND_ENTRY;
668 return -EBUSY; 659 return -EBUSY;
669 } 660 }
670 MapP->ID = (ushort) nNewID + 1; 661 MapP->ID = (u16) nNewID + 1;
671 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID); 662 rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
672 HostMapP = &p->RIOHosts[host].Mapping[nNewID]; 663 HostMapP = &p->RIOHosts[host].Mapping[nNewID];
673 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum; 664 HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
@@ -708,7 +699,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
708 */ 699 */
709 HostMapP->SysPort = MapP->SysPort; 700 HostMapP->SysPort = MapP->SysPort;
710 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0) 701 if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
711 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 702 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
712 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED; 703 HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
713#ifdef NEED_TO_FIX 704#ifdef NEED_TO_FIX
714 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]); 705 RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
@@ -742,16 +733,13 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
742} 733}
743 734
744 735
745int RIOReMapPorts(p, HostP, HostMapP) 736int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
746struct rio_info *p;
747struct Host *HostP;
748struct Map *HostMapP;
749{ 737{
750 register struct Port *PortP; 738 struct Port *PortP;
751 uint SubEnt; 739 unsigned int SubEnt;
752 uint HostPort; 740 unsigned int HostPort;
753 uint SysPort; 741 unsigned int SysPort;
754 ushort RtaType; 742 u16 RtaType;
755 unsigned long flags; 743 unsigned long flags;
756 744
757 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID); 745 rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
@@ -794,12 +782,12 @@ struct Map *HostMapP;
794 */ 782 */
795 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) { 783 if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
796 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort]; 784 struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
797 PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add)); 785 PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
798 PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start)); 786 PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
799 PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end)); 787 PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
800 PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove)); 788 PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
801 PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start)); 789 PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
802 PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end)); 790 PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
803 } else 791 } else
804 PortP->PhbP = NULL; 792 PortP->PhbP = NULL;
805 793
@@ -813,10 +801,10 @@ struct Map *HostMapP;
813 PortP->RupNum = HostMapP->ID - 1; 801 PortP->RupNum = HostMapP->ID - 1;
814 if (HostMapP->Flags & RTA16_SECOND_SLOT) { 802 if (HostMapP->Flags & RTA16_SECOND_SLOT) {
815 PortP->ID2 = HostMapP->ID2 - 1; 803 PortP->ID2 = HostMapP->ID2 - 1;
816 PortP->SecondBlock = TRUE; 804 PortP->SecondBlock = 1;
817 } else { 805 } else {
818 PortP->ID2 = 0; 806 PortP->ID2 = 0;
819 PortP->SecondBlock = FALSE; 807 PortP->SecondBlock = 0;
820 } 808 }
821 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum; 809 PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
822 810
@@ -866,9 +854,6 @@ struct Map *HostMapP;
866 PortP->RxDataStart = 0; 854 PortP->RxDataStart = 0;
867 PortP->Cor2Copy = 0; 855 PortP->Cor2Copy = 0;
868 PortP->Name = &HostMapP->Name[0]; 856 PortP->Name = &HostMapP->Name[0];
869#ifdef STATS
870 bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
871#endif
872 PortP->statsGather = 0; 857 PortP->statsGather = 0;
873 PortP->txchars = 0; 858 PortP->txchars = 0;
874 PortP->rxchars = 0; 859 PortP->rxchars = 0;
@@ -876,10 +861,10 @@ struct Map *HostMapP;
876 PortP->closes = 0; 861 PortP->closes = 0;
877 PortP->ioctls = 0; 862 PortP->ioctls = 0;
878 if (PortP->TxRingBuffer) 863 if (PortP->TxRingBuffer)
879 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 864 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
880 else if (p->RIOBufferSize) { 865 else if (p->RIOBufferSize) {
881 PortP->TxRingBuffer = sysbrk(p->RIOBufferSize); 866 PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL);
882 bzero(PortP->TxRingBuffer, p->RIOBufferSize); 867 memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
883 } 868 }
884 PortP->TxBufferOut = 0; 869 PortP->TxBufferOut = 0;
885 PortP->TxBufferIn = 0; 870 PortP->TxBufferIn = 0;
@@ -890,7 +875,7 @@ struct Map *HostMapP;
890 ** If the same, we have received the same rx pkt from the RTA 875 ** If the same, we have received the same rx pkt from the RTA
891 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0. 876 ** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
892 */ 877 */
893 PortP->LastRxTgl = ~(uchar) PHB_RX_TGL; 878 PortP->LastRxTgl = ~(u8) PHB_RX_TGL;
894 879
895 /* 880 /*
896 ** and mark the port as usable 881 ** and mark the port as usable
@@ -906,9 +891,7 @@ struct Map *HostMapP;
906 return 0; 891 return 0;
907} 892}
908 893
909int RIOChangeName(p, MapP) 894int RIOChangeName(struct rio_info *p, struct Map *MapP)
910struct rio_info *p;
911struct Map *MapP;
912{ 895{
913 int host; 896 int host;
914 struct Map *HostMapP; 897 struct Map *HostMapP;
@@ -941,7 +924,7 @@ struct Map *MapP;
941 return -ENXIO; 924 return -ENXIO;
942 } 925 }
943 if (MapP->ID == 0) { 926 if (MapP->ID == 0) {
944 CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN); 927 memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN);
945 return 0; 928 return 0;
946 } 929 }
947 930
@@ -951,7 +934,7 @@ struct Map *MapP;
951 p->RIOError.Error = RTA_NUMBER_WRONG; 934 p->RIOError.Error = RTA_NUMBER_WRONG;
952 return -ENXIO; 935 return -ENXIO;
953 } 936 }
954 CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN); 937 memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
955 return 0; 938 return 0;
956 } 939 }
957 } 940 }
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 6379816ed173..204267613c9c 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -56,15 +56,12 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
56 56
57#include "linux_compat.h" 57#include "linux_compat.h"
58#include "rio_linux.h" 58#include "rio_linux.h"
59#include "typdef.h"
60#include "pkt.h" 59#include "pkt.h"
61#include "daemon.h" 60#include "daemon.h"
62#include "rio.h" 61#include "rio.h"
63#include "riospace.h" 62#include "riospace.h"
64#include "top.h"
65#include "cmdpkt.h" 63#include "cmdpkt.h"
66#include "map.h" 64#include "map.h"
67#include "riotypes.h"
68#include "rup.h" 65#include "rup.h"
69#include "port.h" 66#include "port.h"
70#include "riodrvr.h" 67#include "riodrvr.h"
@@ -77,58 +74,18 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
77#include "unixrup.h" 74#include "unixrup.h"
78#include "board.h" 75#include "board.h"
79#include "host.h" 76#include "host.h"
80#include "error.h"
81#include "phb.h" 77#include "phb.h"
82#include "link.h" 78#include "link.h"
83#include "cmdblk.h" 79#include "cmdblk.h"
84#include "route.h" 80#include "route.h"
85#include "control.h"
86#include "cirrus.h" 81#include "cirrus.h"
87#include "rioioctl.h" 82#include "rioioctl.h"
88#include "param.h" 83#include "param.h"
89#include "list.h"
90#include "sam.h"
91 84
92static void RIOClearUp(struct Port *PortP); 85static void RIOClearUp(struct Port *PortP);
93int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
94
95
96extern int conv_vb[]; /* now defined in ttymgr.c */
97extern int conv_bv[]; /* now defined in ttymgr.c */
98 86
99/* 87/* Below belongs in func.h */
100** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support 88int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
101**
102** ep.def.h is necessary for Modular Kernel Support
103** DO NOT place any kernel 'extern's after this line
104** or this source file will not build riotty.k.o
105*/
106#ifdef uLYNX
107#include <ep.def.h>
108#endif
109
110#ifdef NEED_THIS2
111static struct old_sgttyb default_sg = {
112 B19200, B19200, /* input and output speed */
113 'H' - '@', /* erase char */
114 -1, /* 2nd erase char */
115 'U' - '@', /* kill char */
116 ECHO | CRMOD, /* mode */
117 'C' - '@', /* interrupt character */
118 '\\' - '@', /* quit char */
119 'Q' - '@', /* start char */
120 'S' - '@', /* stop char */
121 'D' - '@', /* EOF */
122 -1, /* brk */
123 (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */
124 'Z' - '@', /* process stop */
125 'Y' - '@', /* delayed stop */
126 'R' - '@', /* reprint line */
127 'O' - '@', /* flush output */
128 'W' - '@', /* word erase */
129 'V' - '@' /* literal next char */
130};
131#endif
132 89
133 90
134extern struct rio_info *p; 91extern struct rio_info *p;
@@ -136,8 +93,7 @@ extern struct rio_info *p;
136 93
137int riotopen(struct tty_struct *tty, struct file *filp) 94int riotopen(struct tty_struct *tty, struct file *filp)
138{ 95{
139 register uint SysPort; 96 unsigned int SysPort;
140 int Modem;
141 int repeat_this = 250; 97 int repeat_this = 250;
142 struct Port *PortP; /* pointer to the port structure */ 98 struct Port *PortP; /* pointer to the port structure */
143 unsigned long flags; 99 unsigned long flags;
@@ -151,16 +107,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)
151 tty->driver_data = NULL; 107 tty->driver_data = NULL;
152 108
153 SysPort = rio_minor(tty); 109 SysPort = rio_minor(tty);
154 Modem = rio_ismodem(tty);
155 110
156 if (p->RIOFailed) { 111 if (p->RIOFailed) {
157 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n"); 112 rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
158 pseterr(ENXIO);
159 func_exit(); 113 func_exit();
160 return -ENXIO; 114 return -ENXIO;
161 } 115 }
162 116
163 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped); 117 rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped);
164 118
165 /* 119 /*
166 ** Validate that we have received a legitimate request. 120 ** Validate that we have received a legitimate request.
@@ -170,7 +124,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
170 */ 124 */
171 if (SysPort >= RIO_PORTS) { /* out of range ? */ 125 if (SysPort >= RIO_PORTS) { /* out of range ? */
172 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort); 126 rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
173 pseterr(ENXIO);
174 func_exit(); 127 func_exit();
175 return -ENXIO; 128 return -ENXIO;
176 } 129 }
@@ -187,7 +140,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
187 */ 140 */
188 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n"); 141 rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
189 func_exit(); 142 func_exit();
190 pseterr(ENXIO);
191 return -ENXIO; 143 return -ENXIO;
192 } 144 }
193 145
@@ -209,7 +161,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
209 */ 161 */
210 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) { 162 if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
211 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n"); 163 rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
212 pseterr(ENXIO);
213 func_exit(); 164 func_exit();
214 return -ENXIO; 165 return -ENXIO;
215 } 166 }
@@ -309,15 +260,12 @@ int riotopen(struct tty_struct *tty, struct file *filp)
309 /* PortP->gs.xmit_cnt = 0; */ 260 /* PortP->gs.xmit_cnt = 0; */
310 261
311 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 262 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
312#ifdef NEED_THIS
313 ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
314#endif
315 263
316 /* Someone explain to me why this delay/config is 264 /* Someone explain to me why this delay/config is
317 here. If I read the docs correctly the "open" 265 here. If I read the docs correctly the "open"
318 command piggybacks the parameters immediately. 266 command piggybacks the parameters immediately.
319 -- REW */ 267 -- REW */
320 RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */ 268 RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */
321 rio_spin_lock_irqsave(&PortP->portSem, flags); 269 rio_spin_lock_irqsave(&PortP->portSem, flags);
322 270
323 /* 271 /*
@@ -325,20 +273,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
325 */ 273 */
326 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) { 274 while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
327 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState); 275 rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
328/*
329** 15.10.1998 ARG - ESIL 0759
330** (Part) fix for port being trashed when opened whilst RTA "disconnected"
331** Take out the limited wait - now wait for ever or until user
332** bangs us out.
333**
334 if (repeat_this -- <= 0) {
335 rio_dprint(RIO_DEBUG_TTY, ("Waiting for open to finish timed out.\n"));
336 RIOPreemptiveCmd(p, PortP, FCLOSE );
337 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
338 return -EINTR;
339 }
340**
341*/
342 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 276 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
343 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 277 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
344 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); 278 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
@@ -358,80 +292,61 @@ int riotopen(struct tty_struct *tty, struct file *filp)
358 } 292 }
359 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n"); 293 rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
360 } 294 }
361#ifdef MODEM_SUPPORT 295 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
362 if (Modem) { 296 /*
363 rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n"); 297 ** ACTION
298 ** insert test for carrier here. -- ???
299 ** I already see that test here. What's the deal? -- REW
300 */
301 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
302 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
364 /* 303 /*
365 ** ACTION 304 tp->tm.c_state |= CARR_ON;
366 ** insert test for carrier here. -- ??? 305 wakeup((caddr_t) &tp->tm.c_canq);
367 ** I already see that test here. What's the deal? -- REW
368 */ 306 */
369 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { 307 PortP->State |= RIO_CARR_ON;
370 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); 308 wake_up_interruptible(&PortP->gs.open_wait);
309 } else { /* no carrier - wait for DCD */
371 /* 310 /*
372 tp->tm.c_state |= CARR_ON; 311 while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
373 wakeup((caddr_t) &tp->tm.c_canq); 312 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
374 */ 313 */
375 PortP->State |= RIO_CARR_ON; 314 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
376 wake_up_interruptible(&PortP->gs.open_wait); 315 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
377 } else { /* no carrier - wait for DCD */
378
379 /* 316 /*
380 while (!(PortP->gs.tty->termios->c_state & CARR_ON) && 317 PortP->gs.tty->termios->c_state |= WOPEN;
381 !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
382 */ 318 */
383 while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) { 319 PortP->State |= RIO_WOPEN;
384 320 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
385 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort); 321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
386 /* 322 /*
387 PortP->gs.tty->termios->c_state |= WOPEN; 323 ** ACTION: verify that this is a good thing
324 ** to do here. -- ???
325 ** I think it's OK. -- REW
388 */ 326 */
389 PortP->State |= RIO_WOPEN; 327 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
328 RIOPreemptiveCmd(p, PortP, FCLOSE);
329 /*
330 tp->tm.c_state &= ~WOPEN;
331 */
332 PortP->State &= ~RIO_WOPEN;
390 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 333 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
391 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) 334 func_exit();
392 { 335 return -EINTR;
393 /*
394 ** ACTION: verify that this is a good thing
395 ** to do here. -- ???
396 ** I think it's OK. -- REW
397 */
398 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
399 RIOPreemptiveCmd(p, PortP, FCLOSE);
400 /*
401 tp->tm.c_state &= ~WOPEN;
402 */
403 PortP->State &= ~RIO_WOPEN;
404 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
405 func_exit();
406 return -EINTR;
407 }
408 } 336 }
409 PortP->State &= ~RIO_WOPEN;
410 } 337 }
411 if (p->RIOHalted) 338 PortP->State &= ~RIO_WOPEN;
412 goto bombout;
413 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
414 PortP->State |= RIO_MOPEN;
415 } else
416#endif
417 {
418 /*
419 ** ACTION
420 ** Direct line open - force carrier (will probably mean
421 ** that sleeping Modem line fubar)
422 */
423 PortP->State |= RIO_LOPEN;
424 } 339 }
340 if (p->RIOHalted)
341 goto bombout;
342 rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
343 PortP->State |= RIO_MOPEN;
425 344
426 if (p->RIOHalted) { 345 if (p->RIOHalted)
427 goto bombout; 346 goto bombout;
428 }
429 347
430 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n"); 348 rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
431 349
432#ifdef STATS
433 PortP->Stat.OpenCnt++;
434#endif
435 /* 350 /*
436 ** Count opens for port statistics reporting 351 ** Count opens for port statistics reporting
437 */ 352 */
@@ -460,23 +375,21 @@ int riotclose(void *ptr)
460 unsigned long end_time; 375 unsigned long end_time;
461 struct tty_struct *tty; 376 struct tty_struct *tty;
462 unsigned long flags; 377 unsigned long flags;
463 int Modem;
464 int rv = 0; 378 int rv = 0;
465 379
466 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum); 380 rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
467 381
468 /* PortP = p->RIOPortp[SysPort]; */ 382 /* PortP = p->RIOPortp[SysPort]; */
469 rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP); 383 rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
470 /* tp = PortP->TtyP; *//* Get tty */ 384 /* tp = PortP->TtyP; *//* Get tty */
471 tty = PortP->gs.tty; 385 tty = PortP->gs.tty;
472 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty); 386 rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);
473 387
474 if (PortP->gs.closing_wait) 388 if (PortP->gs.closing_wait)
475 end_time = jiffies + PortP->gs.closing_wait; 389 end_time = jiffies + PortP->gs.closing_wait;
476 else 390 else
477 end_time = jiffies + MAX_SCHEDULE_TIMEOUT; 391 end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
478 392
479 Modem = rio_ismodem(tty);
480 rio_spin_lock_irqsave(&PortP->portSem, flags); 393 rio_spin_lock_irqsave(&PortP->portSem, flags);
481 394
482 /* 395 /*
@@ -500,7 +413,7 @@ int riotclose(void *ptr)
500 /* 413 /*
501 ** clear the open bits for this device 414 ** clear the open bits for this device
502 */ 415 */
503 PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN); 416 PortP->State &= ~RIO_MOPEN;
504 PortP->State &= ~RIO_CARR_ON; 417 PortP->State &= ~RIO_CARR_ON;
505 PortP->ModemState &= ~MSVR1_CD; 418 PortP->ModemState &= ~MSVR1_CD;
506 /* 419 /*
@@ -536,7 +449,6 @@ int riotclose(void *ptr)
536 449
537 if (!deleted) 450 if (!deleted)
538 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) { 451 while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
539 cprintf("Need to flush the ttyport\n");
540 if (repeat_this-- <= 0) { 452 if (repeat_this-- <= 0) {
541 rv = -EINTR; 453 rv = -EINTR;
542 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 454 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
@@ -615,16 +527,13 @@ int riotclose(void *ptr)
615*/ 527*/
616 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW); 528 PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
617 529
618#ifdef STATS
619 PortP->Stat.CloseCnt++;
620#endif
621 /* 530 /*
622 ** Count opens for port statistics reporting 531 ** Count opens for port statistics reporting
623 */ 532 */
624 if (PortP->statsGather) 533 if (PortP->statsGather)
625 PortP->closes++; 534 PortP->closes++;
626 535
627 close_end: 536close_end:
628 /* XXX: Why would a "DELETED" flag be reset here? I'd have 537 /* XXX: Why would a "DELETED" flag be reset here? I'd have
629 thought that a "deleted" flag means that the port was 538 thought that a "deleted" flag means that the port was
630 permanently gone, but here we can make it reappear by it 539 permanently gone, but here we can make it reappear by it
@@ -640,8 +549,7 @@ int riotclose(void *ptr)
640 549
641 550
642 551
643static void RIOClearUp(PortP) 552static void RIOClearUp(struct Port *PortP)
644struct Port *PortP;
645{ 553{
646 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n"); 554 rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
647 PortP->Config = 0; /* Direct semaphore */ 555 PortP->Config = 0; /* Direct semaphore */
@@ -668,7 +576,7 @@ struct Port *PortP;
668*/ 576*/
669int 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)
670{ 578{
671 PKT *PacketP; 579 struct PKT *PacketP;
672 int retries = 20; /* at 10 per second -> 2 seconds */ 580 int retries = 20; /* at 10 per second -> 2 seconds */
673 unsigned long flags; 581 unsigned long flags;
674 582
@@ -722,15 +630,15 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len
722 /* 630 /*
723 ** set the command byte and the argument byte 631 ** set the command byte and the argument byte
724 */ 632 */
725 WBYTE(PacketP->data[0], command); 633 writeb(command, &PacketP->data[0]);
726 634
727 if (len == 2) 635 if (len == 2)
728 WBYTE(PacketP->data[1], arg); 636 writeb(arg, &PacketP->data[1]);
729 637
730 /* 638 /*
731 ** set the length of the packet and set the command bit. 639 ** set the length of the packet and set the command bit.
732 */ 640 */
733 WBYTE(PacketP->len, PKT_CMD_BIT | len); 641 writeb(PKT_CMD_BIT | len, &PacketP->len);
734 642
735 add_transmit(PortP); 643 add_transmit(PortP);
736 /* 644 /*
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
deleted file mode 100644
index 46084d5c7e98..000000000000
--- a/drivers/char/rio/riotypes.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R I O T Y P E S
4 ******* *******
5 ****************************************************************************
6
7 Author : Jon Brawn
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _riotypes_h
38#define _riotypes_h 1
39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_riotypes_h_sccs = "@(#)riotypes.h 1.10"; */
43#endif
44#endif
45
46typedef unsigned short NUMBER_ptr;
47typedef unsigned short WORD_ptr;
48typedef unsigned short BYTE_ptr;
49typedef unsigned short char_ptr;
50typedef unsigned short Channel_ptr;
51typedef unsigned short FREE_LIST_ptr_ptr;
52typedef unsigned short FREE_LIST_ptr;
53typedef unsigned short LPB_ptr;
54typedef unsigned short Process_ptr;
55typedef unsigned short PHB_ptr;
56typedef unsigned short PKT_ptr;
57typedef unsigned short PKT_ptr_ptr;
58typedef unsigned short Q_BUF_ptr;
59typedef unsigned short Q_BUF_ptr_ptr;
60typedef unsigned short ROUTE_STR_ptr;
61typedef unsigned short RUP_ptr;
62typedef unsigned short short_ptr;
63typedef unsigned short u_short_ptr;
64typedef unsigned short ushort_ptr;
65
66#endif /* __riotypes__ */
67
68/*********** end of file ***********/
diff --git a/drivers/char/rio/rom.h b/drivers/char/rio/rom.h
deleted file mode 100644
index 58a7843625ff..000000000000
--- a/drivers/char/rio/rom.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* R O M
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36
37#ifndef _rom_h
38#define _rom_h 1
39
40#ifndef lint
41#ifdef SCCS
42static char *_rio_rom_h_sccs = "@(#)rom.h 1.1";
43#endif
44#endif
45
46typedef struct ROM ROM;
47struct ROM {
48 u_short slx;
49 char pcb_letter_rev;
50 char pcb_number_rev;
51 char serial[4];
52 char year;
53 char week;
54};
55
56#endif
57
58#define HOST_ROM (ROM *) 0x7c00
59#define RTA_ROM (ROM *) 0x7801
60#define ROM_LENGTH 0x20
61
62/*********** end of file ***********/
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index f74f67c6f702..4ae90cb207a9 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -37,14 +37,7 @@
37#ifndef _rup_h 37#ifndef _rup_h
38#define _rup_h 1 38#define _rup_h 1
39 39
40#ifdef SCCS_LABELS
41#ifndef lint
42/* static char *_rio_rup_h_sccs = "@(#)rup.h 1.5"; */
43#endif
44#endif
45
46#define MAX_RUP ((short) 16) 40#define MAX_RUP ((short) 16)
47
48#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */ 41#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
49 42
50/************************************************* 43/*************************************************
@@ -60,15 +53,15 @@
60#define RUP_NO_OWNER 0xff /* RUP not owned by any process */ 53#define RUP_NO_OWNER 0xff /* RUP not owned by any process */
61 54
62struct RUP { 55struct RUP {
63 PKT_ptr txpkt; /* Outgoing packet */ 56 u16 txpkt; /* Outgoing packet */
64 PKT_ptr rxpkt; /* Incoming packet */ 57 u16 rxpkt; /* Incoming packet */
65 WORD link; /* Which link to send down? */ 58 u16 link; /* Which link to send down? */
66 BYTE rup_dest_unit[2]; /* Destination unit */ 59 u8 rup_dest_unit[2]; /* Destination unit */
67 WORD handshake; /* For handshaking */ 60 u16 handshake; /* For handshaking */
68 WORD timeout; /* Timeout */ 61 u16 timeout; /* Timeout */
69 WORD status; /* Status */ 62 u16 status; /* Status */
70 WORD txcontrol; /* Transmit control */ 63 u16 txcontrol; /* Transmit control */
71 WORD rxcontrol; /* Receive control */ 64 u16 rxcontrol; /* Receive control */
72}; 65};
73 66
74#endif 67#endif
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
deleted file mode 100644
index 6f754e19015d..000000000000
--- a/drivers/char/rio/sam.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/****************************************************************************
2 ******* *******
3 ******* S A M . H
4 ******* *******
5 ****************************************************************************
6
7 Author : Ian Nandhra
8 Date :
9
10 *
11 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 Version : 0.01
28
29
30 Mods
31 ----------------------------------------------------------------------------
32 Date By Description
33 ----------------------------------------------------------------------------
34
35 ***************************************************************************/
36#ifndef _sam_h
37#define _sam_h 1
38
39#ifdef SCCS_LABELS
40#ifndef lint
41/* static char *_rio_sam_h_sccs = "@(#)sam.h 1.3"; */
42#endif
43#endif
44
45
46#define NUM_FREE_LIST_UNITS 500
47
48#ifndef FALSE
49#define FALSE (short) 0x00
50#endif
51#ifndef TRUE
52#define TRUE (short) !FALSE
53#endif
54
55#define TX TRUE
56#define RX FALSE
57
58
59typedef struct FREE_LIST FREE_LIST;
60struct FREE_LIST {
61 FREE_LIST_ptr next;
62 FREE_LIST_ptr prev;
63};
64
65
66#endif
67/*********** end of file ***********/
diff --git a/drivers/char/rio/space.h b/drivers/char/rio/space.h
deleted file mode 100644
index 1f12690f9d1f..000000000000
--- a/drivers/char/rio/space.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
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
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : space.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)space.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_space_h__
34#define __rio_space_h__
35
36#ifdef SCCS_LABELS
37static char *_space_h_sccs_ = "@(#)space.h 1.2";
38#endif
39
40extern int rio_cntls;
41extern int rio_bases[];
42extern int rio_limits[];
43extern int rio_vects[];
44
45#endif /* __rio_space_h__ */
diff --git a/drivers/char/rio/top.h b/drivers/char/rio/top.h
deleted file mode 100644
index d15a11dc4f73..000000000000
--- a/drivers/char/rio/top.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
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
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : top.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:19
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)top.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_top_h__
34#define __rio_top_h__
35
36#ifdef SCCS_LABELS
37static char *_top_h_sccs_ = "@(#)top.h 1.2";
38#endif
39
40/*
41** Topology information
42*/
43struct Top {
44 uchar Unit;
45 uchar Link;
46};
47
48#endif /* __rio_top_h__ */
diff --git a/drivers/char/rio/typdef.h b/drivers/char/rio/typdef.h
deleted file mode 100644
index 185b889e1510..000000000000
--- a/drivers/char/rio/typdef.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2** -----------------------------------------------------------------------------
3**
4** Perle Specialix driver for Linux
5** Ported from existing RIO Driver for SCO sources.
6 *
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
8 *
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
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22**
23** Module : typdef.h
24** SID : 1.2
25** Last Modified : 11/6/98 11:34:20
26** Retrieved : 11/6/98 11:34:22
27**
28** ident @(#)typdef.h 1.2
29**
30** -----------------------------------------------------------------------------
31*/
32
33#ifndef __rio_typdef_h__
34#define __rio_typdef_h__
35
36#ifdef SCCS_LABELS
37static char *_typdef_h_sccs_ = "@(#)typdef.h 1.2";
38#endif
39
40#undef VPIX
41
42/*
43** IT IS REALLY, REALLY, IMPORTANT THAT BYTES ARE UNSIGNED!
44**
45** These types are ONLY to be used for refering to data structures
46** on the RIO Host card!
47*/
48typedef volatile unsigned char BYTE;
49typedef volatile unsigned short WORD;
50typedef volatile unsigned int DWORD;
51typedef volatile unsigned short RIOP;
52typedef volatile short NUMBER;
53
54
55/*
56** 27.01.199 ARG - mods to compile 'newutils' on LyxnOS -
57** These #defines are for the benefit of the 'libfuncs' library
58** only. They are not necessarily correct type mappings and
59** are here only to make the source compile.
60*/
61/* typedef unsigned int uint; */
62typedef unsigned long ulong_t;
63typedef unsigned short ushort_t;
64typedef unsigned char uchar_t;
65typedef unsigned char queue_t;
66typedef unsigned char mblk_t;
67typedef unsigned int paddr_t;
68typedef unsigned char uchar;
69
70#define TPNULL ((ushort)(0x8000))
71
72
73/*
74** RIO structures defined in other include files.
75*/
76typedef struct PKT PKT;
77typedef struct LPB LPB;
78typedef struct RUP RUP;
79typedef struct Port Port;
80typedef struct DpRam DpRam;
81
82#endif /* __rio_typdef_h__ */
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index a126c7cabac6..4306e01dbf01 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -45,9 +45,9 @@ struct 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 *RupP; /* the Rup to send it to */
48 uint Id; /* Id number */ 48 unsigned int Id; /* Id number */
49 uint BaseSysPort; /* SysPort of first tty on this RTA */ 49 unsigned int BaseSysPort; /* SysPort of first tty on this RTA */
50 uint ModTypes; /* Modules on this RTA */ 50 unsigned int ModTypes; /* Modules on this RTA */
51 spinlock_t RupLock; /* Lock structure for MPX */ 51 spinlock_t RupLock; /* Lock structure for MPX */
52 /* struct lockb RupLock; *//* Lock structure for MPX */ 52 /* struct lockb RupLock; *//* Lock structure for MPX */
53}; 53};
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 119e629656b7..657c0d88f48c 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1743,10 +1743,10 @@ static int iobase;
1743static int iobase1; 1743static int iobase1;
1744static int iobase2; 1744static int iobase2;
1745static int iobase3; 1745static int iobase3;
1746MODULE_PARM(iobase, "i"); 1746module_param(iobase, int, 0);
1747MODULE_PARM(iobase1, "i"); 1747module_param(iobase1, int, 0);
1748MODULE_PARM(iobase2, "i"); 1748module_param(iobase2, int, 0);
1749MODULE_PARM(iobase3, "i"); 1749module_param(iobase3, int, 0);
1750 1750
1751MODULE_LICENSE("GPL"); 1751MODULE_LICENSE("GPL");
1752#endif /* MODULE */ 1752#endif /* MODULE */
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index fee68cc895f8..510bd3e0e88b 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -97,7 +97,7 @@
97#include <asm/amigahw.h> 97#include <asm/amigahw.h>
98#include <linux/zorro.h> 98#include <linux/zorro.h>
99#include <asm/irq.h> 99#include <asm/irq.h>
100#include <asm/semaphore.h> 100#include <linux/mutex.h>
101 101
102#include <linux/delay.h> 102#include <linux/delay.h>
103 103
@@ -654,7 +654,7 @@ static void a2232_init_portstructs(void)
654 port->gs.closing_wait = 30 * HZ; 654 port->gs.closing_wait = 30 * HZ;
655 port->gs.rd = &a2232_real_driver; 655 port->gs.rd = &a2232_real_driver;
656#ifdef NEW_WRITE_LOCKING 656#ifdef NEW_WRITE_LOCKING
657 init_MUTEX(&(port->gs.port_write_sem)); 657 init_MUTEX(&(port->gs.port_write_mutex));
658#endif 658#endif
659 init_waitqueue_head(&port->gs.open_wait); 659 init_waitqueue_head(&port->gs.open_wait);
660 init_waitqueue_head(&port->gs.close_wait); 660 init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 0e7d216e7eb0..b543821d8cb4 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -5,7 +5,7 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10 10
11/* 11/*
@@ -77,7 +77,7 @@ scdrv_open(struct inode *inode, struct file *file)
77 scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev); 77 scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev);
78 78
79 /* allocate memory for subchannel data */ 79 /* allocate memory for subchannel data */
80 sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); 80 sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
81 if (sd == NULL) { 81 if (sd == NULL) {
82 printk("%s: couldn't allocate subchannel data\n", 82 printk("%s: couldn't allocate subchannel data\n",
83 __FUNCTION__); 83 __FUNCTION__);
@@ -85,7 +85,6 @@ scdrv_open(struct inode *inode, struct file *file)
85 } 85 }
86 86
87 /* initialize subch_data_s fields */ 87 /* initialize subch_data_s fields */
88 memset(sd, 0, sizeof (struct subch_data_s));
89 sd->sd_nasid = scd->scd_nasid; 88 sd->sd_nasid = scd->scd_nasid;
90 sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid); 89 sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid);
91 90
@@ -394,7 +393,7 @@ scdrv_init(void)
394 sprintf(devnamep, "#%d", geo_slab(geoid)); 393 sprintf(devnamep, "#%d", geo_slab(geoid));
395 394
396 /* allocate sysctl device data */ 395 /* allocate sysctl device data */
397 scd = kmalloc(sizeof (struct sysctl_data_s), 396 scd = kzalloc(sizeof (struct sysctl_data_s),
398 GFP_KERNEL); 397 GFP_KERNEL);
399 if (!scd) { 398 if (!scd) {
400 printk("%s: failed to allocate device info" 399 printk("%s: failed to allocate device info"
@@ -402,7 +401,6 @@ scdrv_init(void)
402 SYSCTL_BASENAME, devname); 401 SYSCTL_BASENAME, devname);
403 continue; 402 continue;
404 } 403 }
405 memset(scd, 0, sizeof (struct sysctl_data_s));
406 404
407 /* initialize sysctl device data fields */ 405 /* initialize sysctl device data fields */
408 scd->scd_nasid = cnodeid_to_nasid(cnode); 406 scd->scd_nasid = cnodeid_to_nasid(cnode);
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index a4fa507eed9e..e234d50e142a 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -287,7 +287,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
287{ 287{
288 int rv; 288 int rv;
289 289
290 event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL); 290 event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
291 if (event_sd == NULL) { 291 if (event_sd == NULL) {
292 printk(KERN_WARNING "%s: couldn't allocate subchannel info" 292 printk(KERN_WARNING "%s: couldn't allocate subchannel info"
293 " for event monitoring\n", __FUNCTION__); 293 " for event monitoring\n", __FUNCTION__);
@@ -295,7 +295,6 @@ scdrv_event_init(struct sysctl_data_s *scd)
295 } 295 }
296 296
297 /* initialize subch_data_s fields */ 297 /* initialize subch_data_s fields */
298 memset(event_sd, 0, sizeof (struct subch_data_s));
299 event_sd->sd_nasid = scd->scd_nasid; 298 event_sd->sd_nasid = scd->scd_nasid;
300 spin_lock_init(&event_sd->sd_rlock); 299 spin_lock_init(&event_sd->sd_rlock);
301 300
@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd)
321 return; 320 return;
322 } 321 }
323} 322}
324
325
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index bdaab6992109..3f5d6077f39c 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -148,7 +148,6 @@ static struct tty_driver *stl_serial;
148 * is already swapping a shared buffer won't make things any worse. 148 * is already swapping a shared buffer won't make things any worse.
149 */ 149 */
150static char *stl_tmpwritebuf; 150static char *stl_tmpwritebuf;
151static DECLARE_MUTEX(stl_tmpwritesem);
152 151
153/* 152/*
154 * Define a local default termios struct. All ports will be created 153 * Define a local default termios struct. All ports will be created
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index a6b4f02bdceb..3b4747230270 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2318,7 +2318,7 @@ static int sx_init_portstructs (int nboards, int nports)
2318 port->board = board; 2318 port->board = board;
2319 port->gs.rd = &sx_real_driver; 2319 port->gs.rd = &sx_real_driver;
2320#ifdef NEW_WRITE_LOCKING 2320#ifdef NEW_WRITE_LOCKING
2321 port->gs.port_write_sem = MUTEX; 2321 port->gs.port_write_mutex = MUTEX;
2322#endif 2322#endif
2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED; 2323 port->gs.driver_lock = SPIN_LOCK_UNLOCKED;
2324 /* 2324 /*
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index ede688a4e141..fee2aca3f6a5 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -941,17 +941,6 @@ static void* mgsl_get_text_ptr(void)
941 return mgsl_get_text_ptr; 941 return mgsl_get_text_ptr;
942} 942}
943 943
944/*
945 * tmp_buf is used as a temporary buffer by mgsl_write. We need to
946 * lock it in case the COPY_FROM_USER blocks while swapping in a page,
947 * and some other program tries to do a serial write at the same time.
948 * Since the lock will only come under contention when the system is
949 * swapping and available memory is low, it makes sense to share one
950 * buffer across all the serial ioports, since it significantly saves
951 * memory if large numbers of serial ports are open.
952 */
953static unsigned char *tmp_buf;
954
955static inline int mgsl_paranoia_check(struct mgsl_struct *info, 944static inline int mgsl_paranoia_check(struct mgsl_struct *info,
956 char *name, const char *routine) 945 char *name, const char *routine)
957{ 946{
@@ -2150,7 +2139,7 @@ static int mgsl_write(struct tty_struct * tty,
2150 if (mgsl_paranoia_check(info, tty->name, "mgsl_write")) 2139 if (mgsl_paranoia_check(info, tty->name, "mgsl_write"))
2151 goto cleanup; 2140 goto cleanup;
2152 2141
2153 if (!tty || !info->xmit_buf || !tmp_buf) 2142 if (!tty || !info->xmit_buf)
2154 goto cleanup; 2143 goto cleanup;
2155 2144
2156 if ( info->params.mode == MGSL_MODE_HDLC || 2145 if ( info->params.mode == MGSL_MODE_HDLC ||
@@ -3438,7 +3427,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3438{ 3427{
3439 struct mgsl_struct *info; 3428 struct mgsl_struct *info;
3440 int retval, line; 3429 int retval, line;
3441 unsigned long page;
3442 unsigned long flags; 3430 unsigned long flags;
3443 3431
3444 /* verify range of specified line number */ 3432 /* verify range of specified line number */
@@ -3472,18 +3460,6 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
3472 goto cleanup; 3460 goto cleanup;
3473 } 3461 }
3474 3462
3475 if (!tmp_buf) {
3476 page = get_zeroed_page(GFP_KERNEL);
3477 if (!page) {
3478 retval = -ENOMEM;
3479 goto cleanup;
3480 }
3481 if (tmp_buf)
3482 free_page(page);
3483 else
3484 tmp_buf = (unsigned char *) page;
3485 }
3486
3487 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 3463 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
3488 3464
3489 spin_lock_irqsave(&info->netlock, flags); 3465 spin_lock_irqsave(&info->netlock, flags);
@@ -4502,11 +4478,6 @@ static void synclink_cleanup(void)
4502 kfree(tmp); 4478 kfree(tmp);
4503 } 4479 }
4504 4480
4505 if (tmp_buf) {
4506 free_page((unsigned long) tmp_buf);
4507 tmp_buf = NULL;
4508 }
4509
4510 if (pci_registered) 4481 if (pci_registered)
4511 pci_unregister_driver(&synclink_pci_driver); 4482 pci_unregister_driver(&synclink_pci_driver);
4512} 4483}
@@ -6025,7 +5996,7 @@ static void usc_set_async_mode( struct mgsl_struct *info )
6025 * <15..8> ? RxFIFO IRQ Request Level 5996 * <15..8> ? RxFIFO IRQ Request Level
6026 * 5997 *
6027 * Note: For async mode the receive FIFO level must be set 5998 * Note: For async mode the receive FIFO level must be set
6028 * to 0 to aviod the situation where the FIFO contains fewer bytes 5999 * to 0 to avoid the situation where the FIFO contains fewer bytes
6029 * than the trigger level and no more data is expected. 6000 * than the trigger level and no more data is expected.
6030 * 6001 *
6031 * <7> 0 Exited Hunt IA (Interrupt Arm) 6002 * <7> 0 Exited Hunt IA (Interrupt Arm)
@@ -7770,7 +7741,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
7770 } 7741 }
7771 7742
7772 info->params.encoding = new_encoding; 7743 info->params.encoding = new_encoding;
7773 info->params.crc_type = new_crctype;; 7744 info->params.crc_type = new_crctype;
7774 7745
7775 /* if network interface up, reprogram hardware */ 7746 /* if network interface up, reprogram hardware */
7776 if (info->netcount) 7747 if (info->netcount)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index b046390cd256..b4d1f4eea435 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: synclink_gt.c,v 4.22 2006/01/09 20:16:06 paulkf Exp $ 2 * $Id: synclink_gt.c,v 4.25 2006/02/06 21:20:33 paulkf Exp $
3 * 3 *
4 * Device driver for Microgate SyncLink GT serial adapters. 4 * Device driver for Microgate SyncLink GT serial adapters.
5 * 5 *
@@ -92,7 +92,7 @@
92 * module identification 92 * module identification
93 */ 93 */
94static char *driver_name = "SyncLink GT"; 94static char *driver_name = "SyncLink GT";
95static char *driver_version = "$Revision: 4.22 $"; 95static char *driver_version = "$Revision: 4.25 $";
96static char *tty_driver_name = "synclink_gt"; 96static char *tty_driver_name = "synclink_gt";
97static char *tty_dev_prefix = "ttySLG"; 97static char *tty_dev_prefix = "ttySLG";
98MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL");
@@ -188,6 +188,20 @@ static void hdlcdev_exit(struct slgt_info *info);
188#define SLGT_REG_SIZE 256 188#define SLGT_REG_SIZE 256
189 189
190/* 190/*
191 * conditional wait facility
192 */
193struct cond_wait {
194 struct cond_wait *next;
195 wait_queue_head_t q;
196 wait_queue_t wait;
197 unsigned int data;
198};
199static void init_cond_wait(struct cond_wait *w, unsigned int data);
200static void add_cond_wait(struct cond_wait **head, struct cond_wait *w);
201static void remove_cond_wait(struct cond_wait **head, struct cond_wait *w);
202static void flush_cond_wait(struct cond_wait **head);
203
204/*
191 * DMA buffer descriptor and access macros 205 * DMA buffer descriptor and access macros
192 */ 206 */
193struct slgt_desc 207struct slgt_desc
@@ -269,6 +283,9 @@ struct slgt_info {
269 struct timer_list tx_timer; 283 struct timer_list tx_timer;
270 struct timer_list rx_timer; 284 struct timer_list rx_timer;
271 285
286 unsigned int gpio_present;
287 struct cond_wait *gpio_wait_q;
288
272 spinlock_t lock; /* spinlock for synchronizing with ISR */ 289 spinlock_t lock; /* spinlock for synchronizing with ISR */
273 290
274 struct work_struct task; 291 struct work_struct task;
@@ -379,6 +396,11 @@ static MGSL_PARAMS default_params = {
379#define MASK_OVERRUN BIT4 396#define MASK_OVERRUN BIT4
380 397
381#define GSR 0x00 /* global status */ 398#define GSR 0x00 /* global status */
399#define JCR 0x04 /* JTAG control */
400#define IODR 0x08 /* GPIO direction */
401#define IOER 0x0c /* GPIO interrupt enable */
402#define IOVR 0x10 /* GPIO value */
403#define IOSR 0x14 /* GPIO interrupt status */
382#define TDR 0x80 /* tx data */ 404#define TDR 0x80 /* tx data */
383#define RDR 0x80 /* rx data */ 405#define RDR 0x80 /* rx data */
384#define TCR 0x82 /* tx control */ 406#define TCR 0x82 /* tx control */
@@ -503,6 +525,9 @@ static int tiocmset(struct tty_struct *tty, struct file *file,
503static void set_break(struct tty_struct *tty, int break_state); 525static void set_break(struct tty_struct *tty, int break_state);
504static int get_interface(struct slgt_info *info, int __user *if_mode); 526static int get_interface(struct slgt_info *info, int __user *if_mode);
505static int set_interface(struct slgt_info *info, int if_mode); 527static int set_interface(struct slgt_info *info, int if_mode);
528static int set_gpio(struct slgt_info *info, struct gpio_desc __user *gpio);
529static int get_gpio(struct slgt_info *info, struct gpio_desc __user *gpio);
530static int wait_gpio(struct slgt_info *info, struct gpio_desc __user *gpio);
506 531
507/* 532/*
508 * driver functions 533 * driver functions
@@ -1112,6 +1137,12 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1112 return get_interface(info, argp); 1137 return get_interface(info, argp);
1113 case MGSL_IOCSIF: 1138 case MGSL_IOCSIF:
1114 return set_interface(info,(int)arg); 1139 return set_interface(info,(int)arg);
1140 case MGSL_IOCSGPIO:
1141 return set_gpio(info, argp);
1142 case MGSL_IOCGGPIO:
1143 return get_gpio(info, argp);
1144 case MGSL_IOCWAITGPIO:
1145 return wait_gpio(info, argp);
1115 case TIOCGICOUNT: 1146 case TIOCGICOUNT:
1116 spin_lock_irqsave(&info->lock,flags); 1147 spin_lock_irqsave(&info->lock,flags);
1117 cnow = info->icount; 1148 cnow = info->icount;
@@ -1365,7 +1396,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1365 } 1396 }
1366 1397
1367 info->params.encoding = new_encoding; 1398 info->params.encoding = new_encoding;
1368 info->params.crc_type = new_crctype;; 1399 info->params.crc_type = new_crctype;
1369 1400
1370 /* if network interface up, reprogram hardware */ 1401 /* if network interface up, reprogram hardware */
1371 if (info->netcount) 1402 if (info->netcount)
@@ -1762,10 +1793,6 @@ static void rx_async(struct slgt_info *info)
1762 DBGDATA(info, p, count, "rx"); 1793 DBGDATA(info, p, count, "rx");
1763 1794
1764 for(i=0 ; i < count; i+=2, p+=2) { 1795 for(i=0 ; i < count; i+=2, p+=2) {
1765 if (tty && chars) {
1766 tty_flip_buffer_push(tty);
1767 chars = 0;
1768 }
1769 ch = *p; 1796 ch = *p;
1770 icount->rx++; 1797 icount->rx++;
1771 1798
@@ -2158,6 +2185,24 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2158 } 2185 }
2159} 2186}
2160 2187
2188static void isr_gpio(struct slgt_info *info, unsigned int changed, unsigned int state)
2189{
2190 struct cond_wait *w, *prev;
2191
2192 /* wake processes waiting for specific transitions */
2193 for (w = info->gpio_wait_q, prev = NULL ; w != NULL ; w = w->next) {
2194 if (w->data & changed) {
2195 w->data = state;
2196 wake_up_interruptible(&w->q);
2197 if (prev != NULL)
2198 prev->next = w->next;
2199 else
2200 info->gpio_wait_q = w->next;
2201 } else
2202 prev = w;
2203 }
2204}
2205
2161/* interrupt service routine 2206/* interrupt service routine
2162 * 2207 *
2163 * irq interrupt number 2208 * irq interrupt number
@@ -2193,6 +2238,22 @@ static irqreturn_t slgt_interrupt(int irq, void *dev_id, struct pt_regs * regs)
2193 } 2238 }
2194 } 2239 }
2195 2240
2241 if (info->gpio_present) {
2242 unsigned int state;
2243 unsigned int changed;
2244 while ((changed = rd_reg32(info, IOSR)) != 0) {
2245 DBGISR(("%s iosr=%08x\n", info->device_name, changed));
2246 /* read latched state of GPIO signals */
2247 state = rd_reg32(info, IOVR);
2248 /* clear pending GPIO interrupt bits */
2249 wr_reg32(info, IOSR, changed);
2250 for (i=0 ; i < info->port_count ; i++) {
2251 if (info->port_array[i] != NULL)
2252 isr_gpio(info->port_array[i], changed, state);
2253 }
2254 }
2255 }
2256
2196 for(i=0; i < info->port_count ; i++) { 2257 for(i=0; i < info->port_count ; i++) {
2197 struct slgt_info *port = info->port_array[i]; 2258 struct slgt_info *port = info->port_array[i];
2198 2259
@@ -2276,6 +2337,8 @@ static void shutdown(struct slgt_info *info)
2276 set_signals(info); 2337 set_signals(info);
2277 } 2338 }
2278 2339
2340 flush_cond_wait(&info->gpio_wait_q);
2341
2279 spin_unlock_irqrestore(&info->lock,flags); 2342 spin_unlock_irqrestore(&info->lock,flags);
2280 2343
2281 if (info->tty) 2344 if (info->tty)
@@ -2650,6 +2713,175 @@ static int set_interface(struct slgt_info *info, int if_mode)
2650 return 0; 2713 return 0;
2651} 2714}
2652 2715
2716/*
2717 * set general purpose IO pin state and direction
2718 *
2719 * user_gpio fields:
2720 * state each bit indicates a pin state
2721 * smask set bit indicates pin state to set
2722 * dir each bit indicates a pin direction (0=input, 1=output)
2723 * dmask set bit indicates pin direction to set
2724 */
2725static int set_gpio(struct slgt_info *info, struct gpio_desc __user *user_gpio)
2726{
2727 unsigned long flags;
2728 struct gpio_desc gpio;
2729 __u32 data;
2730
2731 if (!info->gpio_present)
2732 return -EINVAL;
2733 if (copy_from_user(&gpio, user_gpio, sizeof(gpio)))
2734 return -EFAULT;
2735 DBGINFO(("%s set_gpio state=%08x smask=%08x dir=%08x dmask=%08x\n",
2736 info->device_name, gpio.state, gpio.smask,
2737 gpio.dir, gpio.dmask));
2738
2739 spin_lock_irqsave(&info->lock,flags);
2740 if (gpio.dmask) {
2741 data = rd_reg32(info, IODR);
2742 data |= gpio.dmask & gpio.dir;
2743 data &= ~(gpio.dmask & ~gpio.dir);
2744 wr_reg32(info, IODR, data);
2745 }
2746 if (gpio.smask) {
2747 data = rd_reg32(info, IOVR);
2748 data |= gpio.smask & gpio.state;
2749 data &= ~(gpio.smask & ~gpio.state);
2750 wr_reg32(info, IOVR, data);
2751 }
2752 spin_unlock_irqrestore(&info->lock,flags);
2753
2754 return 0;
2755}
2756
2757/*
2758 * get general purpose IO pin state and direction
2759 */
2760static int get_gpio(struct slgt_info *info, struct gpio_desc __user *user_gpio)
2761{
2762 struct gpio_desc gpio;
2763 if (!info->gpio_present)
2764 return -EINVAL;
2765 gpio.state = rd_reg32(info, IOVR);
2766 gpio.smask = 0xffffffff;
2767 gpio.dir = rd_reg32(info, IODR);
2768 gpio.dmask = 0xffffffff;
2769 if (copy_to_user(user_gpio, &gpio, sizeof(gpio)))
2770 return -EFAULT;
2771 DBGINFO(("%s get_gpio state=%08x dir=%08x\n",
2772 info->device_name, gpio.state, gpio.dir));
2773 return 0;
2774}
2775
2776/*
2777 * conditional wait facility
2778 */
2779static void init_cond_wait(struct cond_wait *w, unsigned int data)
2780{
2781 init_waitqueue_head(&w->q);
2782 init_waitqueue_entry(&w->wait, current);
2783 w->data = data;
2784}
2785
2786static void add_cond_wait(struct cond_wait **head, struct cond_wait *w)
2787{
2788 set_current_state(TASK_INTERRUPTIBLE);
2789 add_wait_queue(&w->q, &w->wait);
2790 w->next = *head;
2791 *head = w;
2792}
2793
2794static void remove_cond_wait(struct cond_wait **head, struct cond_wait *cw)
2795{
2796 struct cond_wait *w, *prev;
2797 remove_wait_queue(&cw->q, &cw->wait);
2798 set_current_state(TASK_RUNNING);
2799 for (w = *head, prev = NULL ; w != NULL ; prev = w, w = w->next) {
2800 if (w == cw) {
2801 if (prev != NULL)
2802 prev->next = w->next;
2803 else
2804 *head = w->next;
2805 break;
2806 }
2807 }
2808}
2809
2810static void flush_cond_wait(struct cond_wait **head)
2811{
2812 while (*head != NULL) {
2813 wake_up_interruptible(&(*head)->q);
2814 *head = (*head)->next;
2815 }
2816}
2817
2818/*
2819 * wait for general purpose I/O pin(s) to enter specified state
2820 *
2821 * user_gpio fields:
2822 * state - bit indicates target pin state
2823 * smask - set bit indicates watched pin
2824 *
2825 * The wait ends when at least one watched pin enters the specified
2826 * state. When 0 (no error) is returned, user_gpio->state is set to the
2827 * state of all GPIO pins when the wait ends.
2828 *
2829 * Note: Each pin may be a dedicated input, dedicated output, or
2830 * configurable input/output. The number and configuration of pins
2831 * varies with the specific adapter model. Only input pins (dedicated
2832 * or configured) can be monitored with this function.
2833 */
2834static int wait_gpio(struct slgt_info *info, struct gpio_desc __user *user_gpio)
2835{
2836 unsigned long flags;
2837 int rc = 0;
2838 struct gpio_desc gpio;
2839 struct cond_wait wait;
2840 u32 state;
2841
2842 if (!info->gpio_present)
2843 return -EINVAL;
2844 if (copy_from_user(&gpio, user_gpio, sizeof(gpio)))
2845 return -EFAULT;
2846 DBGINFO(("%s wait_gpio() state=%08x smask=%08x\n",
2847 info->device_name, gpio.state, gpio.smask));
2848 /* ignore output pins identified by set IODR bit */
2849 if ((gpio.smask &= ~rd_reg32(info, IODR)) == 0)
2850 return -EINVAL;
2851 init_cond_wait(&wait, gpio.smask);
2852
2853 spin_lock_irqsave(&info->lock, flags);
2854 /* enable interrupts for watched pins */
2855 wr_reg32(info, IOER, rd_reg32(info, IOER) | gpio.smask);
2856 /* get current pin states */
2857 state = rd_reg32(info, IOVR);
2858
2859 if (gpio.smask & ~(state ^ gpio.state)) {
2860 /* already in target state */
2861 gpio.state = state;
2862 } else {
2863 /* wait for target state */
2864 add_cond_wait(&info->gpio_wait_q, &wait);
2865 spin_unlock_irqrestore(&info->lock, flags);
2866 schedule();
2867 if (signal_pending(current))
2868 rc = -ERESTARTSYS;
2869 else
2870 gpio.state = wait.data;
2871 spin_lock_irqsave(&info->lock, flags);
2872 remove_cond_wait(&info->gpio_wait_q, &wait);
2873 }
2874
2875 /* disable all GPIO interrupts if no waiting processes */
2876 if (info->gpio_wait_q == NULL)
2877 wr_reg32(info, IOER, 0);
2878 spin_unlock_irqrestore(&info->lock,flags);
2879
2880 if ((rc == 0) && copy_to_user(user_gpio, &gpio, sizeof(gpio)))
2881 rc = -EFAULT;
2882 return rc;
2883}
2884
2653static int modem_input_wait(struct slgt_info *info,int arg) 2885static int modem_input_wait(struct slgt_info *info,int arg)
2654{ 2886{
2655 unsigned long flags; 2887 unsigned long flags;
@@ -3166,8 +3398,10 @@ static void device_init(int adapter_num, struct pci_dev *pdev)
3166 } else { 3398 } else {
3167 port_array[0]->irq_requested = 1; 3399 port_array[0]->irq_requested = 1;
3168 adapter_test(port_array[0]); 3400 adapter_test(port_array[0]);
3169 for (i=1 ; i < port_count ; i++) 3401 for (i=1 ; i < port_count ; i++) {
3170 port_array[i]->init_error = port_array[0]->init_error; 3402 port_array[i]->init_error = port_array[0]->init_error;
3403 port_array[i]->gpio_present = port_array[0]->gpio_present;
3404 }
3171 } 3405 }
3172 } 3406 }
3173} 3407}
@@ -4301,7 +4535,7 @@ static int register_test(struct slgt_info *info)
4301 break; 4535 break;
4302 } 4536 }
4303 } 4537 }
4304 4538 info->gpio_present = (rd_reg32(info, JCR) & BIT5) ? 1 : 0;
4305 info->init_error = rc ? 0 : DiagStatus_AddressFailure; 4539 info->init_error = rc ? 0 : DiagStatus_AddressFailure;
4306 return rc; 4540 return rc;
4307} 4541}
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 960adb256fbb..858740131115 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -1650,7 +1650,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
1650 } 1650 }
1651 1651
1652 info->params.encoding = new_encoding; 1652 info->params.encoding = new_encoding;
1653 info->params.crc_type = new_crctype;; 1653 info->params.crc_type = new_crctype;
1654 1654
1655 /* if network interface up, reprogram hardware */ 1655 /* if network interface up, reprogram hardware */
1656 if (info->netcount) 1656 if (info->netcount)
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index d58f82318853..35082dc12eae 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -42,16 +42,15 @@
42/* Whether we react on sysrq keys or just ignore them */ 42/* Whether we react on sysrq keys or just ignore them */
43int sysrq_enabled = 1; 43int sysrq_enabled = 1;
44 44
45/* Loglevel sysrq handler */
46static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs, 45static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs,
47 struct tty_struct *tty) 46 struct tty_struct *tty)
48{ 47{
49 int i; 48 int i;
50 i = key - '0'; 49 i = key - '0';
51 console_loglevel = 7; 50 console_loglevel = 7;
52 printk("Loglevel set to %d\n", i); 51 printk("Loglevel set to %d\n", i);
53 console_loglevel = i; 52 console_loglevel = i;
54} 53}
55static struct sysrq_key_op sysrq_loglevel_op = { 54static struct sysrq_key_op sysrq_loglevel_op = {
56 .handler = sysrq_handle_loglevel, 55 .handler = sysrq_handle_loglevel,
57 .help_msg = "loglevel0-8", 56 .help_msg = "loglevel0-8",
@@ -59,11 +58,9 @@ static struct sysrq_key_op sysrq_loglevel_op = {
59 .enable_mask = SYSRQ_ENABLE_LOG, 58 .enable_mask = SYSRQ_ENABLE_LOG,
60}; 59};
61 60
62
63/* SAK sysrq handler */
64#ifdef CONFIG_VT 61#ifdef CONFIG_VT
65static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs, 62static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs,
66 struct tty_struct *tty) 63 struct tty_struct *tty)
67{ 64{
68 if (tty) 65 if (tty)
69 do_SAK(tty); 66 do_SAK(tty);
@@ -75,12 +72,13 @@ static struct sysrq_key_op sysrq_SAK_op = {
75 .action_msg = "SAK", 72 .action_msg = "SAK",
76 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 73 .enable_mask = SYSRQ_ENABLE_KEYBOARD,
77}; 74};
75#else
76#define sysrq_SAK_op (*(struct sysrq_key_op *)0)
78#endif 77#endif
79 78
80#ifdef CONFIG_VT 79#ifdef CONFIG_VT
81/* unraw sysrq handler */
82static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs, 80static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs,
83 struct tty_struct *tty) 81 struct tty_struct *tty)
84{ 82{
85 struct kbd_struct *kbd = &kbd_table[fg_console]; 83 struct kbd_struct *kbd = &kbd_table[fg_console];
86 84
@@ -93,10 +91,11 @@ static struct sysrq_key_op sysrq_unraw_op = {
93 .action_msg = "Keyboard mode set to XLATE", 91 .action_msg = "Keyboard mode set to XLATE",
94 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 92 .enable_mask = SYSRQ_ENABLE_KEYBOARD,
95}; 93};
94#else
95#define sysrq_unraw_op (*(struct sysrq_key_op *)0)
96#endif /* CONFIG_VT */ 96#endif /* CONFIG_VT */
97 97
98#ifdef CONFIG_KEXEC 98#ifdef CONFIG_KEXEC
99/* crashdump sysrq handler */
100static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, 99static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs,
101 struct tty_struct *tty) 100 struct tty_struct *tty)
102{ 101{
@@ -108,16 +107,16 @@ static struct sysrq_key_op sysrq_crashdump_op = {
108 .action_msg = "Trigger a crashdump", 107 .action_msg = "Trigger a crashdump",
109 .enable_mask = SYSRQ_ENABLE_DUMP, 108 .enable_mask = SYSRQ_ENABLE_DUMP,
110}; 109};
110#else
111#define sysrq_crashdump_op (*(struct sysrq_key_op *)0)
111#endif 112#endif
112 113
113/* reboot sysrq handler */
114static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, 114static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs,
115 struct tty_struct *tty) 115 struct tty_struct *tty)
116{ 116{
117 local_irq_enable(); 117 local_irq_enable();
118 emergency_restart(); 118 emergency_restart();
119} 119}
120
121static struct sysrq_key_op sysrq_reboot_op = { 120static struct sysrq_key_op sysrq_reboot_op = {
122 .handler = sysrq_handle_reboot, 121 .handler = sysrq_handle_reboot,
123 .help_msg = "reBoot", 122 .help_msg = "reBoot",
@@ -126,11 +125,10 @@ static struct sysrq_key_op sysrq_reboot_op = {
126}; 125};
127 126
128static void sysrq_handle_sync(int key, struct pt_regs *pt_regs, 127static void sysrq_handle_sync(int key, struct pt_regs *pt_regs,
129 struct tty_struct *tty) 128 struct tty_struct *tty)
130{ 129{
131 emergency_sync(); 130 emergency_sync();
132} 131}
133
134static struct sysrq_key_op sysrq_sync_op = { 132static struct sysrq_key_op sysrq_sync_op = {
135 .handler = sysrq_handle_sync, 133 .handler = sysrq_handle_sync,
136 .help_msg = "Sync", 134 .help_msg = "Sync",
@@ -139,11 +137,10 @@ static struct sysrq_key_op sysrq_sync_op = {
139}; 137};
140 138
141static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs, 139static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs,
142 struct tty_struct *tty) 140 struct tty_struct *tty)
143{ 141{
144 emergency_remount(); 142 emergency_remount();
145} 143}
146
147static struct sysrq_key_op sysrq_mountro_op = { 144static struct sysrq_key_op sysrq_mountro_op = {
148 .handler = sysrq_handle_mountro, 145 .handler = sysrq_handle_mountro,
149 .help_msg = "Unmount", 146 .help_msg = "Unmount",
@@ -151,28 +148,23 @@ static struct sysrq_key_op sysrq_mountro_op = {
151 .enable_mask = SYSRQ_ENABLE_REMOUNT, 148 .enable_mask = SYSRQ_ENABLE_REMOUNT,
152}; 149};
153 150
154/* END SYNC SYSRQ HANDLERS BLOCK */
155
156#ifdef CONFIG_DEBUG_MUTEXES 151#ifdef CONFIG_DEBUG_MUTEXES
157 152static void sysrq_handle_showlocks(int key, struct pt_regs *pt_regs,
158static void 153 struct tty_struct *tty)
159sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
160{ 154{
161 mutex_debug_show_all_locks(); 155 mutex_debug_show_all_locks();
162} 156}
163
164static struct sysrq_key_op sysrq_showlocks_op = { 157static struct sysrq_key_op sysrq_showlocks_op = {
165 .handler = sysrq_handle_showlocks, 158 .handler = sysrq_handle_showlocks,
166 .help_msg = "show-all-locks(D)", 159 .help_msg = "show-all-locks(D)",
167 .action_msg = "Show Locks Held", 160 .action_msg = "Show Locks Held",
168}; 161};
169 162#else
163#define sysrq_showlocks_op (*(struct sysrq_key_op *)0)
170#endif 164#endif
171 165
172/* SHOW SYSRQ HANDLERS BLOCK */
173
174static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs, 166static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs,
175 struct tty_struct *tty) 167 struct tty_struct *tty)
176{ 168{
177 if (pt_regs) 169 if (pt_regs)
178 show_regs(pt_regs); 170 show_regs(pt_regs);
@@ -184,9 +176,8 @@ static struct sysrq_key_op sysrq_showregs_op = {
184 .enable_mask = SYSRQ_ENABLE_DUMP, 176 .enable_mask = SYSRQ_ENABLE_DUMP,
185}; 177};
186 178
187
188static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs, 179static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs,
189 struct tty_struct *tty) 180 struct tty_struct *tty)
190{ 181{
191 show_state(); 182 show_state();
192} 183}
@@ -197,9 +188,8 @@ static struct sysrq_key_op sysrq_showstate_op = {
197 .enable_mask = SYSRQ_ENABLE_DUMP, 188 .enable_mask = SYSRQ_ENABLE_DUMP,
198}; 189};
199 190
200
201static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs, 191static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs,
202 struct tty_struct *tty) 192 struct tty_struct *tty)
203{ 193{
204 show_mem(); 194 show_mem();
205} 195}
@@ -210,13 +200,9 @@ static struct sysrq_key_op sysrq_showmem_op = {
210 .enable_mask = SYSRQ_ENABLE_DUMP, 200 .enable_mask = SYSRQ_ENABLE_DUMP,
211}; 201};
212 202
213/* SHOW SYSRQ HANDLERS BLOCK */ 203/*
214 204 * Signal sysrq helper function. Sends a signal to all user processes.
215 205 */
216/* SIGNAL SYSRQ HANDLERS BLOCK */
217
218/* signal sysrq helper function
219 * Sends a signal to all user processes */
220static void send_sig_all(int sig) 206static void send_sig_all(int sig)
221{ 207{
222 struct task_struct *p; 208 struct task_struct *p;
@@ -229,7 +215,7 @@ static void send_sig_all(int sig)
229} 215}
230 216
231static void sysrq_handle_term(int key, struct pt_regs *pt_regs, 217static void sysrq_handle_term(int key, struct pt_regs *pt_regs,
232 struct tty_struct *tty) 218 struct tty_struct *tty)
233{ 219{
234 send_sig_all(SIGTERM); 220 send_sig_all(SIGTERM);
235 console_loglevel = 8; 221 console_loglevel = 8;
@@ -243,7 +229,8 @@ static struct sysrq_key_op sysrq_term_op = {
243 229
244static void moom_callback(void *ignored) 230static void moom_callback(void *ignored)
245{ 231{
246 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], GFP_KERNEL, 0); 232 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
233 GFP_KERNEL, 0);
247} 234}
248 235
249static DECLARE_WORK(moom_work, moom_callback, NULL); 236static DECLARE_WORK(moom_work, moom_callback, NULL);
@@ -260,7 +247,7 @@ static struct sysrq_key_op sysrq_moom_op = {
260}; 247};
261 248
262static void sysrq_handle_kill(int key, struct pt_regs *pt_regs, 249static void sysrq_handle_kill(int key, struct pt_regs *pt_regs,
263 struct tty_struct *tty) 250 struct tty_struct *tty)
264{ 251{
265 send_sig_all(SIGKILL); 252 send_sig_all(SIGKILL);
266 console_loglevel = 8; 253 console_loglevel = 8;
@@ -272,8 +259,6 @@ static struct sysrq_key_op sysrq_kill_op = {
272 .enable_mask = SYSRQ_ENABLE_SIGNAL, 259 .enable_mask = SYSRQ_ENABLE_SIGNAL,
273}; 260};
274 261
275/* END SIGNAL SYSRQ HANDLERS BLOCK */
276
277static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs, 262static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs,
278 struct tty_struct *tty) 263 struct tty_struct *tty)
279{ 264{
@@ -288,110 +273,99 @@ static struct sysrq_key_op sysrq_unrt_op = {
288 273
289/* Key Operations table and lock */ 274/* Key Operations table and lock */
290static DEFINE_SPINLOCK(sysrq_key_table_lock); 275static DEFINE_SPINLOCK(sysrq_key_table_lock);
291#define SYSRQ_KEY_TABLE_LENGTH 36 276
292static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = { 277static struct sysrq_key_op *sysrq_key_table[36] = {
293/* 0 */ &sysrq_loglevel_op, 278 &sysrq_loglevel_op, /* 0 */
294/* 1 */ &sysrq_loglevel_op, 279 &sysrq_loglevel_op, /* 1 */
295/* 2 */ &sysrq_loglevel_op, 280 &sysrq_loglevel_op, /* 2 */
296/* 3 */ &sysrq_loglevel_op, 281 &sysrq_loglevel_op, /* 3 */
297/* 4 */ &sysrq_loglevel_op, 282 &sysrq_loglevel_op, /* 4 */
298/* 5 */ &sysrq_loglevel_op, 283 &sysrq_loglevel_op, /* 5 */
299/* 6 */ &sysrq_loglevel_op, 284 &sysrq_loglevel_op, /* 6 */
300/* 7 */ &sysrq_loglevel_op, 285 &sysrq_loglevel_op, /* 7 */
301/* 8 */ &sysrq_loglevel_op, 286 &sysrq_loglevel_op, /* 8 */
302/* 9 */ &sysrq_loglevel_op, 287 &sysrq_loglevel_op, /* 9 */
303/* a */ NULL, /* Don't use for system provided sysrqs, 288
304 it is handled specially on the sparc 289 /*
305 and will never arrive */ 290 * Don't use for system provided sysrqs, it is handled specially on
306/* b */ &sysrq_reboot_op, 291 * sparc and will never arrive
307#ifdef CONFIG_KEXEC 292 */
308/* c */ &sysrq_crashdump_op, 293 NULL, /* a */
309#else 294 &sysrq_reboot_op, /* b */
310/* c */ NULL, 295 &sysrq_crashdump_op, /* c */
311#endif 296 &sysrq_showlocks_op, /* d */
312#ifdef CONFIG_DEBUG_MUTEXES 297 &sysrq_term_op, /* e */
313/* d */ &sysrq_showlocks_op, 298 &sysrq_moom_op, /* f */
314#else 299 NULL, /* g */
315/* d */ NULL, 300 NULL, /* h */
316#endif 301 &sysrq_kill_op, /* i */
317/* e */ &sysrq_term_op, 302 NULL, /* j */
318/* f */ &sysrq_moom_op, 303 &sysrq_SAK_op, /* k */
319/* g */ NULL, 304 NULL, /* l */
320/* h */ NULL, 305 &sysrq_showmem_op, /* m */
321/* i */ &sysrq_kill_op, 306 &sysrq_unrt_op, /* n */
322/* j */ NULL, 307 /* This will often be registered as 'Off' at init time */
323#ifdef CONFIG_VT 308 NULL, /* o */
324/* k */ &sysrq_SAK_op, 309 &sysrq_showregs_op, /* p */
325#else 310 NULL, /* q */
326/* k */ NULL, 311 &sysrq_unraw_op, /* r */
327#endif 312 &sysrq_sync_op, /* s */
328/* l */ NULL, 313 &sysrq_showstate_op, /* t */
329/* m */ &sysrq_showmem_op, 314 &sysrq_mountro_op, /* u */
330/* n */ &sysrq_unrt_op, 315 /* May be assigned at init time by SMP VOYAGER */
331/* o */ NULL, /* This will often be registered 316 NULL, /* v */
332 as 'Off' at init time */ 317 NULL, /* w */
333/* p */ &sysrq_showregs_op, 318 NULL, /* x */
334/* q */ NULL, 319 NULL, /* y */
335#ifdef CONFIG_VT 320 NULL /* z */
336/* r */ &sysrq_unraw_op,
337#else
338/* r */ NULL,
339#endif
340/* s */ &sysrq_sync_op,
341/* t */ &sysrq_showstate_op,
342/* u */ &sysrq_mountro_op,
343/* v */ NULL, /* May be assigned at init time by SMP VOYAGER */
344/* w */ NULL,
345/* x */ NULL,
346/* y */ NULL,
347/* z */ NULL
348}; 321};
349 322
350/* key2index calculation, -1 on invalid index */ 323/* key2index calculation, -1 on invalid index */
351static int sysrq_key_table_key2index(int key) { 324static int sysrq_key_table_key2index(int key)
325{
352 int retval; 326 int retval;
353 if ((key >= '0') && (key <= '9')) { 327
328 if ((key >= '0') && (key <= '9'))
354 retval = key - '0'; 329 retval = key - '0';
355 } else if ((key >= 'a') && (key <= 'z')) { 330 else if ((key >= 'a') && (key <= 'z'))
356 retval = key + 10 - 'a'; 331 retval = key + 10 - 'a';
357 } else { 332 else
358 retval = -1; 333 retval = -1;
359 }
360 return retval; 334 return retval;
361} 335}
362 336
363/* 337/*
364 * get and put functions for the table, exposed to modules. 338 * get and put functions for the table, exposed to modules.
365 */ 339 */
366 340struct sysrq_key_op *__sysrq_get_key_op(int key)
367struct sysrq_key_op *__sysrq_get_key_op (int key) { 341{
368 struct sysrq_key_op *op_p; 342 struct sysrq_key_op *op_p = NULL;
369 int i; 343 int i;
370 344
371 i = sysrq_key_table_key2index(key); 345 i = sysrq_key_table_key2index(key);
372 op_p = (i == -1) ? NULL : sysrq_key_table[i]; 346 if (i != -1)
347 op_p = sysrq_key_table[i];
373 return op_p; 348 return op_p;
374} 349}
375 350
376static void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p) { 351static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
377 int i; 352{
353 int i = sysrq_key_table_key2index(key);
378 354
379 i = sysrq_key_table_key2index(key);
380 if (i != -1) 355 if (i != -1)
381 sysrq_key_table[i] = op_p; 356 sysrq_key_table[i] = op_p;
382} 357}
383 358
384/* 359/*
385 * This is the non-locking version of handle_sysrq 360 * This is the non-locking version of handle_sysrq. It must/can only be called
386 * It must/can only be called by sysrq key handlers, 361 * by sysrq key handlers, as they are inside of the lock
387 * as they are inside of the lock
388 */ 362 */
389 363void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
390void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, int check_mask) 364 int check_mask)
391{ 365{
392 struct sysrq_key_op *op_p; 366 struct sysrq_key_op *op_p;
393 int orig_log_level; 367 int orig_log_level;
394 int i, j; 368 int i;
395 unsigned long flags; 369 unsigned long flags;
396 370
397 spin_lock_irqsave(&sysrq_key_table_lock, flags); 371 spin_lock_irqsave(&sysrq_key_table_lock, flags);
@@ -401,26 +375,34 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, in
401 375
402 op_p = __sysrq_get_key_op(key); 376 op_p = __sysrq_get_key_op(key);
403 if (op_p) { 377 if (op_p) {
404 /* Should we check for enabled operations (/proc/sysrq-trigger should not) 378 /*
405 * and is the invoked operation enabled? */ 379 * Should we check for enabled operations (/proc/sysrq-trigger
380 * should not) and is the invoked operation enabled?
381 */
406 if (!check_mask || sysrq_enabled == 1 || 382 if (!check_mask || sysrq_enabled == 1 ||
407 (sysrq_enabled & op_p->enable_mask)) { 383 (sysrq_enabled & op_p->enable_mask)) {
408 printk ("%s\n", op_p->action_msg); 384 printk("%s\n", op_p->action_msg);
409 console_loglevel = orig_log_level; 385 console_loglevel = orig_log_level;
410 op_p->handler(key, pt_regs, tty); 386 op_p->handler(key, pt_regs, tty);
411 } 387 } else {
412 else
413 printk("This sysrq operation is disabled.\n"); 388 printk("This sysrq operation is disabled.\n");
389 }
414 } else { 390 } else {
415 printk("HELP : "); 391 printk("HELP : ");
416 /* Only print the help msg once per handler */ 392 /* Only print the help msg once per handler */
417 for (i=0; i<SYSRQ_KEY_TABLE_LENGTH; i++) 393 for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) {
418 if (sysrq_key_table[i]) { 394 if (sysrq_key_table[i]) {
419 for (j=0; sysrq_key_table[i] != sysrq_key_table[j]; j++); 395 int j;
420 if (j == i) 396
421 printk ("%s ", sysrq_key_table[i]->help_msg); 397 for (j = 0; sysrq_key_table[i] !=
398 sysrq_key_table[j]; j++)
399 ;
400 if (j != i)
401 continue;
402 printk("%s ", sysrq_key_table[i]->help_msg);
403 }
422 } 404 }
423 printk ("\n"); 405 printk("\n");
424 console_loglevel = orig_log_level; 406 console_loglevel = orig_log_level;
425 } 407 }
426 spin_unlock_irqrestore(&sysrq_key_table_lock, flags); 408 spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
@@ -430,16 +412,17 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, in
430 * This function is called by the keyboard handler when SysRq is pressed 412 * This function is called by the keyboard handler when SysRq is pressed
431 * and any other keycode arrives. 413 * and any other keycode arrives.
432 */ 414 */
433
434void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) 415void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
435{ 416{
436 if (!sysrq_enabled) 417 if (!sysrq_enabled)
437 return; 418 return;
438 __handle_sysrq(key, pt_regs, tty, 1); 419 __handle_sysrq(key, pt_regs, tty, 1);
439} 420}
421EXPORT_SYMBOL(handle_sysrq);
440 422
441static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, 423static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
442 struct sysrq_key_op *remove_op_p) { 424 struct sysrq_key_op *remove_op_p)
425{
443 426
444 int retval; 427 int retval;
445 unsigned long flags; 428 unsigned long flags;
@@ -452,7 +435,6 @@ static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
452 retval = -1; 435 retval = -1;
453 } 436 }
454 spin_unlock_irqrestore(&sysrq_key_table_lock, flags); 437 spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
455
456 return retval; 438 return retval;
457} 439}
458 440
@@ -460,12 +442,10 @@ int register_sysrq_key(int key, struct sysrq_key_op *op_p)
460{ 442{
461 return __sysrq_swap_key_ops(key, op_p, NULL); 443 return __sysrq_swap_key_ops(key, op_p, NULL);
462} 444}
445EXPORT_SYMBOL(register_sysrq_key);
463 446
464int unregister_sysrq_key(int key, struct sysrq_key_op *op_p) 447int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
465{ 448{
466 return __sysrq_swap_key_ops(key, NULL, op_p); 449 return __sysrq_swap_key_ops(key, NULL, op_p);
467} 450}
468
469EXPORT_SYMBOL(handle_sysrq);
470EXPORT_SYMBOL(register_sysrq_key);
471EXPORT_SYMBOL(unregister_sysrq_key); 451EXPORT_SYMBOL(unregister_sysrq_key);
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index ac2a297ce37c..a80c83210872 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -283,7 +283,7 @@ static void tb0219_pci_irq_init(void)
283 vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW); 283 vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW);
284} 284}
285 285
286static int tb0219_probe(struct platform_device *dev) 286static int __devinit tb0219_probe(struct platform_device *dev)
287{ 287{
288 int retval; 288 int retval;
289 289
@@ -319,7 +319,7 @@ static int tb0219_probe(struct platform_device *dev)
319 return 0; 319 return 0;
320} 320}
321 321
322static int tb0219_remove(struct platform_device *dev) 322static int __devexit tb0219_remove(struct platform_device *dev)
323{ 323{
324 _machine_restart = old_machine_restart; 324 _machine_restart = old_machine_restart;
325 325
@@ -335,19 +335,26 @@ static struct platform_device *tb0219_platform_device;
335 335
336static struct platform_driver tb0219_device_driver = { 336static struct platform_driver tb0219_device_driver = {
337 .probe = tb0219_probe, 337 .probe = tb0219_probe,
338 .remove = tb0219_remove, 338 .remove = __devexit_p(tb0219_remove),
339 .driver = { 339 .driver = {
340 .name = "TB0219", 340 .name = "TB0219",
341 .owner = THIS_MODULE,
341 }, 342 },
342}; 343};
343 344
344static int __devinit tanbac_tb0219_init(void) 345static int __init tanbac_tb0219_init(void)
345{ 346{
346 int retval; 347 int retval;
347 348
348 tb0219_platform_device = platform_device_register_simple("TB0219", -1, NULL, 0); 349 tb0219_platform_device = platform_device_alloc("TB0219", -1);
349 if (IS_ERR(tb0219_platform_device)) 350 if (!tb0219_platform_device)
350 return PTR_ERR(tb0219_platform_device); 351 return -ENOMEM;
352
353 retval = platform_device_add(tb0219_platform_device);
354 if (retval < 0) {
355 platform_device_put(tb0219_platform_device);
356 return retval;
357 }
351 358
352 retval = platform_driver_register(&tb0219_device_driver); 359 retval = platform_driver_register(&tb0219_device_driver);
353 if (retval < 0) 360 if (retval < 0)
@@ -356,10 +363,9 @@ static int __devinit tanbac_tb0219_init(void)
356 return retval; 363 return retval;
357} 364}
358 365
359static void __devexit tanbac_tb0219_exit(void) 366static void __exit tanbac_tb0219_exit(void)
360{ 367{
361 platform_driver_unregister(&tb0219_device_driver); 368 platform_driver_unregister(&tb0219_device_driver);
362
363 platform_device_unregister(tb0219_platform_device); 369 platform_device_unregister(tb0219_platform_device);
364} 370}
365 371
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 4c272189cd42..2546637a55c0 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -767,6 +767,7 @@ static int __init tlclk_init(void)
767 printk(KERN_ERR "tlclk: can't get major %d.\n", tlclk_major); 767 printk(KERN_ERR "tlclk: can't get major %d.\n", tlclk_major);
768 return ret; 768 return ret;
769 } 769 }
770 tlclk_major = ret;
770 alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL); 771 alarm_events = kzalloc( sizeof(struct tlclk_alarms), GFP_KERNEL);
771 if (!alarm_events) 772 if (!alarm_events)
772 goto out1; 773 goto out1;
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index 0c6f521abd0e..e2fb234dee40 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -355,14 +355,14 @@ static void tosh_set_fn_port(void)
355/* 355/*
356 * Get the machine identification number of the current model 356 * Get the machine identification number of the current model
357 */ 357 */
358static int tosh_get_machine_id(void) 358static int tosh_get_machine_id(void __iomem *bios)
359{ 359{
360 int id; 360 int id;
361 SMMRegisters regs; 361 SMMRegisters regs;
362 unsigned short bx,cx; 362 unsigned short bx,cx;
363 unsigned long address; 363 unsigned long address;
364 364
365 id = (0x100*(int) isa_readb(0xffffe))+((int) isa_readb(0xffffa)); 365 id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
366 366
367 /* do we have a SCTTable machine identication number on our hands */ 367 /* do we have a SCTTable machine identication number on our hands */
368 368
@@ -388,12 +388,12 @@ static int tosh_get_machine_id(void)
388 388
389 /* now twiddle with our pointer a bit */ 389 /* now twiddle with our pointer a bit */
390 390
391 address = 0x000f0000+bx; 391 address = bx;
392 cx = isa_readw(address); 392 cx = readw(bios + address);
393 address = 0x000f0009+bx+cx; 393 address = 9+bx+cx;
394 cx = isa_readw(address); 394 cx = readw(bios + address);
395 address = 0x000f000a+cx; 395 address = 0xa+cx;
396 cx = isa_readw(address); 396 cx = readw(bios + address);
397 397
398 /* now construct our machine identification number */ 398 /* now construct our machine identification number */
399 399
@@ -416,13 +416,18 @@ static int tosh_probe(void)
416 int i,major,minor,day,year,month,flag; 416 int i,major,minor,day,year,month,flag;
417 unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 }; 417 unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
418 SMMRegisters regs; 418 SMMRegisters regs;
419 void __iomem *bios = ioremap(0xf0000, 0x10000);
420
421 if (!bios)
422 return -ENOMEM;
419 423
420 /* extra sanity check for the string "TOSHIBA" in the BIOS because 424 /* extra sanity check for the string "TOSHIBA" in the BIOS because
421 some machines that are not Toshiba's pass the next test */ 425 some machines that are not Toshiba's pass the next test */
422 426
423 for (i=0;i<7;i++) { 427 for (i=0;i<7;i++) {
424 if (isa_readb(0xfe010+i)!=signature[i]) { 428 if (readb(bios+0xe010+i)!=signature[i]) {
425 printk("toshiba: not a supported Toshiba laptop\n"); 429 printk("toshiba: not a supported Toshiba laptop\n");
430 iounmap(bios);
426 return -ENODEV; 431 return -ENODEV;
427 } 432 }
428 } 433 }
@@ -438,6 +443,7 @@ static int tosh_probe(void)
438 443
439 if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) { 444 if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) {
440 printk("toshiba: not a supported Toshiba laptop\n"); 445 printk("toshiba: not a supported Toshiba laptop\n");
446 iounmap(bios);
441 return -ENODEV; 447 return -ENODEV;
442 } 448 }
443 449
@@ -447,19 +453,19 @@ static int tosh_probe(void)
447 453
448 /* next get the machine ID of the current laptop */ 454 /* next get the machine ID of the current laptop */
449 455
450 tosh_id = tosh_get_machine_id(); 456 tosh_id = tosh_get_machine_id(bios);
451 457
452 /* get the BIOS version */ 458 /* get the BIOS version */
453 459
454 major = isa_readb(0xfe009)-'0'; 460 major = readb(bios+0xe009)-'0';
455 minor = ((isa_readb(0xfe00b)-'0')*10)+(isa_readb(0xfe00c)-'0'); 461 minor = ((readb(bios+0xe00b)-'0')*10)+(readb(bios+0xe00c)-'0');
456 tosh_bios = (major*0x100)+minor; 462 tosh_bios = (major*0x100)+minor;
457 463
458 /* get the BIOS date */ 464 /* get the BIOS date */
459 465
460 day = ((isa_readb(0xffff5)-'0')*10)+(isa_readb(0xffff6)-'0'); 466 day = ((readb(bios+0xfff5)-'0')*10)+(readb(bios+0xfff6)-'0');
461 month = ((isa_readb(0xffff8)-'0')*10)+(isa_readb(0xffff9)-'0'); 467 month = ((readb(bios+0xfff8)-'0')*10)+(readb(bios+0xfff9)-'0');
462 year = ((isa_readb(0xffffb)-'0')*10)+(isa_readb(0xffffc)-'0'); 468 year = ((readb(bios+0xfffb)-'0')*10)+(readb(bios+0xfffc)-'0');
463 tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6) 469 tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
464 | ((day & 0x1f)<<1); 470 | ((day & 0x1f)<<1);
465 471
@@ -476,6 +482,8 @@ static int tosh_probe(void)
476 if ((tosh_id==0xfccb) || (tosh_id==0xfccc)) 482 if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
477 tosh_fan = 1; 483 tosh_fan = 1;
478 484
485 iounmap(bios);
486
479 return 0; 487 return 0;
480} 488}
481 489
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index fd3a4beaa53d..dec0224b4478 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -24,6 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/miscdevice.h> 25#include <linux/miscdevice.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/io.h>
27 28
28enum tpm_timeout { 29enum tpm_timeout {
29 TPM_TIMEOUT = 5, /* msecs */ 30 TPM_TIMEOUT = 5, /* msecs */
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 53d3d066554e..0bfd1b63662e 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
130 130
131/* Semaphore to protect creating and releasing a tty. This is shared with 131/* Semaphore to protect creating and releasing a tty. This is shared with
132 vt.c for deeply disgusting hack reasons */ 132 vt.c for deeply disgusting hack reasons */
133DECLARE_MUTEX(tty_sem); 133DEFINE_MUTEX(tty_mutex);
134 134
135#ifdef CONFIG_UNIX98_PTYS 135#ifdef CONFIG_UNIX98_PTYS
136extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ 136extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */
@@ -354,7 +354,7 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
354 354
355EXPORT_SYMBOL_GPL(tty_buffer_request_room); 355EXPORT_SYMBOL_GPL(tty_buffer_request_room);
356 356
357int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size) 357int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
358{ 358{
359 int copied = 0; 359 int copied = 0;
360 do { 360 do {
@@ -378,7 +378,7 @@ int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t
378 378
379EXPORT_SYMBOL_GPL(tty_insert_flip_string); 379EXPORT_SYMBOL_GPL(tty_insert_flip_string);
380 380
381int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size) 381int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size)
382{ 382{
383 int copied = 0; 383 int copied = 0;
384 do { 384 do {
@@ -543,14 +543,12 @@ void tty_ldisc_put(int disc)
543 struct tty_ldisc *ld; 543 struct tty_ldisc *ld;
544 unsigned long flags; 544 unsigned long flags;
545 545
546 if (disc < N_TTY || disc >= NR_LDISCS) 546 BUG_ON(disc < N_TTY || disc >= NR_LDISCS);
547 BUG();
548 547
549 spin_lock_irqsave(&tty_ldisc_lock, flags); 548 spin_lock_irqsave(&tty_ldisc_lock, flags);
550 ld = &tty_ldiscs[disc]; 549 ld = &tty_ldiscs[disc];
551 if(ld->refcount == 0) 550 BUG_ON(ld->refcount == 0);
552 BUG(); 551 ld->refcount--;
553 ld->refcount --;
554 module_put(ld->owner); 552 module_put(ld->owner);
555 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 553 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
556} 554}
@@ -645,8 +643,7 @@ void tty_ldisc_deref(struct tty_ldisc *ld)
645{ 643{
646 unsigned long flags; 644 unsigned long flags;
647 645
648 if(ld == NULL) 646 BUG_ON(ld == NULL);
649 BUG();
650 647
651 spin_lock_irqsave(&tty_ldisc_lock, flags); 648 spin_lock_irqsave(&tty_ldisc_lock, flags);
652 if(ld->refcount == 0) 649 if(ld->refcount == 0)
@@ -1097,8 +1094,8 @@ static void do_tty_hangup(void *data)
1097 p->signal->tty = NULL; 1094 p->signal->tty = NULL;
1098 if (!p->signal->leader) 1095 if (!p->signal->leader)
1099 continue; 1096 continue;
1100 send_group_sig_info(SIGHUP, SEND_SIG_PRIV, p); 1097 group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
1101 send_group_sig_info(SIGCONT, SEND_SIG_PRIV, p); 1098 group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
1102 if (tty->pgrp > 0) 1099 if (tty->pgrp > 0)
1103 p->signal->tty_old_pgrp = tty->pgrp; 1100 p->signal->tty_old_pgrp = tty->pgrp;
1104 } while_each_task_pid(tty->session, PIDTYPE_SID, p); 1101 } while_each_task_pid(tty->session, PIDTYPE_SID, p);
@@ -1188,11 +1185,11 @@ void disassociate_ctty(int on_exit)
1188 1185
1189 lock_kernel(); 1186 lock_kernel();
1190 1187
1191 down(&tty_sem); 1188 mutex_lock(&tty_mutex);
1192 tty = current->signal->tty; 1189 tty = current->signal->tty;
1193 if (tty) { 1190 if (tty) {
1194 tty_pgrp = tty->pgrp; 1191 tty_pgrp = tty->pgrp;
1195 up(&tty_sem); 1192 mutex_unlock(&tty_mutex);
1196 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) 1193 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
1197 tty_vhangup(tty); 1194 tty_vhangup(tty);
1198 } else { 1195 } else {
@@ -1200,7 +1197,7 @@ void disassociate_ctty(int on_exit)
1200 kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); 1197 kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit);
1201 kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); 1198 kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit);
1202 } 1199 }
1203 up(&tty_sem); 1200 mutex_unlock(&tty_mutex);
1204 unlock_kernel(); 1201 unlock_kernel();
1205 return; 1202 return;
1206 } 1203 }
@@ -1211,7 +1208,7 @@ void disassociate_ctty(int on_exit)
1211 } 1208 }
1212 1209
1213 /* Must lock changes to tty_old_pgrp */ 1210 /* Must lock changes to tty_old_pgrp */
1214 down(&tty_sem); 1211 mutex_lock(&tty_mutex);
1215 current->signal->tty_old_pgrp = 0; 1212 current->signal->tty_old_pgrp = 0;
1216 tty->session = 0; 1213 tty->session = 0;
1217 tty->pgrp = -1; 1214 tty->pgrp = -1;
@@ -1222,7 +1219,7 @@ void disassociate_ctty(int on_exit)
1222 p->signal->tty = NULL; 1219 p->signal->tty = NULL;
1223 } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); 1220 } while_each_task_pid(current->signal->session, PIDTYPE_SID, p);
1224 read_unlock(&tasklist_lock); 1221 read_unlock(&tasklist_lock);
1225 up(&tty_sem); 1222 mutex_unlock(&tty_mutex);
1226 unlock_kernel(); 1223 unlock_kernel();
1227} 1224}
1228 1225
@@ -1306,7 +1303,7 @@ static inline ssize_t do_tty_write(
1306 ssize_t ret = 0, written = 0; 1303 ssize_t ret = 0, written = 0;
1307 unsigned int chunk; 1304 unsigned int chunk;
1308 1305
1309 if (down_interruptible(&tty->atomic_write)) { 1306 if (mutex_lock_interruptible(&tty->atomic_write_lock)) {
1310 return -ERESTARTSYS; 1307 return -ERESTARTSYS;
1311 } 1308 }
1312 1309
@@ -1329,7 +1326,7 @@ static inline ssize_t do_tty_write(
1329 if (count < chunk) 1326 if (count < chunk)
1330 chunk = count; 1327 chunk = count;
1331 1328
1332 /* write_buf/write_cnt is protected by the atomic_write semaphore */ 1329 /* write_buf/write_cnt is protected by the atomic_write_lock mutex */
1333 if (tty->write_cnt < chunk) { 1330 if (tty->write_cnt < chunk) {
1334 unsigned char *buf; 1331 unsigned char *buf;
1335 1332
@@ -1338,7 +1335,7 @@ static inline ssize_t do_tty_write(
1338 1335
1339 buf = kmalloc(chunk, GFP_KERNEL); 1336 buf = kmalloc(chunk, GFP_KERNEL);
1340 if (!buf) { 1337 if (!buf) {
1341 up(&tty->atomic_write); 1338 mutex_unlock(&tty->atomic_write_lock);
1342 return -ENOMEM; 1339 return -ENOMEM;
1343 } 1340 }
1344 kfree(tty->write_buf); 1341 kfree(tty->write_buf);
@@ -1374,7 +1371,7 @@ static inline ssize_t do_tty_write(
1374 inode->i_mtime = current_fs_time(inode->i_sb); 1371 inode->i_mtime = current_fs_time(inode->i_sb);
1375 ret = written; 1372 ret = written;
1376 } 1373 }
1377 up(&tty->atomic_write); 1374 mutex_unlock(&tty->atomic_write_lock);
1378 return ret; 1375 return ret;
1379} 1376}
1380 1377
@@ -1442,8 +1439,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p)
1442 1439
1443/* 1440/*
1444 * WSH 06/09/97: Rewritten to remove races and properly clean up after a 1441 * WSH 06/09/97: Rewritten to remove races and properly clean up after a
1445 * failed open. The new code protects the open with a semaphore, so it's 1442 * failed open. The new code protects the open with a mutex, so it's
1446 * really quite straightforward. The semaphore locking can probably be 1443 * really quite straightforward. The mutex locking can probably be
1447 * relaxed for the (most common) case of reopening a tty. 1444 * relaxed for the (most common) case of reopening a tty.
1448 */ 1445 */
1449static int init_dev(struct tty_driver *driver, int idx, 1446static int init_dev(struct tty_driver *driver, int idx,
@@ -1640,7 +1637,7 @@ fast_track:
1640success: 1637success:
1641 *ret_tty = tty; 1638 *ret_tty = tty;
1642 1639
1643 /* All paths come through here to release the semaphore */ 1640 /* All paths come through here to release the mutex */
1644end_init: 1641end_init:
1645 return retval; 1642 return retval;
1646 1643
@@ -1837,7 +1834,7 @@ static void release_dev(struct file * filp)
1837 /* Guard against races with tty->count changes elsewhere and 1834 /* Guard against races with tty->count changes elsewhere and
1838 opens on /dev/tty */ 1835 opens on /dev/tty */
1839 1836
1840 down(&tty_sem); 1837 mutex_lock(&tty_mutex);
1841 tty_closing = tty->count <= 1; 1838 tty_closing = tty->count <= 1;
1842 o_tty_closing = o_tty && 1839 o_tty_closing = o_tty &&
1843 (o_tty->count <= (pty_master ? 1 : 0)); 1840 (o_tty->count <= (pty_master ? 1 : 0));
@@ -1868,7 +1865,7 @@ static void release_dev(struct file * filp)
1868 1865
1869 printk(KERN_WARNING "release_dev: %s: read/write wait queue " 1866 printk(KERN_WARNING "release_dev: %s: read/write wait queue "
1870 "active!\n", tty_name(tty, buf)); 1867 "active!\n", tty_name(tty, buf));
1871 up(&tty_sem); 1868 mutex_unlock(&tty_mutex);
1872 schedule(); 1869 schedule();
1873 } 1870 }
1874 1871
@@ -1934,7 +1931,7 @@ static void release_dev(struct file * filp)
1934 read_unlock(&tasklist_lock); 1931 read_unlock(&tasklist_lock);
1935 } 1932 }
1936 1933
1937 up(&tty_sem); 1934 mutex_unlock(&tty_mutex);
1938 1935
1939 /* check whether both sides are closing ... */ 1936 /* check whether both sides are closing ... */
1940 if (!tty_closing || (o_tty && !o_tty_closing)) 1937 if (!tty_closing || (o_tty && !o_tty_closing))
@@ -2040,11 +2037,11 @@ retry_open:
2040 index = -1; 2037 index = -1;
2041 retval = 0; 2038 retval = 0;
2042 2039
2043 down(&tty_sem); 2040 mutex_lock(&tty_mutex);
2044 2041
2045 if (device == MKDEV(TTYAUX_MAJOR,0)) { 2042 if (device == MKDEV(TTYAUX_MAJOR,0)) {
2046 if (!current->signal->tty) { 2043 if (!current->signal->tty) {
2047 up(&tty_sem); 2044 mutex_unlock(&tty_mutex);
2048 return -ENXIO; 2045 return -ENXIO;
2049 } 2046 }
2050 driver = current->signal->tty->driver; 2047 driver = current->signal->tty->driver;
@@ -2070,18 +2067,18 @@ retry_open:
2070 noctty = 1; 2067 noctty = 1;
2071 goto got_driver; 2068 goto got_driver;
2072 } 2069 }
2073 up(&tty_sem); 2070 mutex_unlock(&tty_mutex);
2074 return -ENODEV; 2071 return -ENODEV;
2075 } 2072 }
2076 2073
2077 driver = get_tty_driver(device, &index); 2074 driver = get_tty_driver(device, &index);
2078 if (!driver) { 2075 if (!driver) {
2079 up(&tty_sem); 2076 mutex_unlock(&tty_mutex);
2080 return -ENODEV; 2077 return -ENODEV;
2081 } 2078 }
2082got_driver: 2079got_driver:
2083 retval = init_dev(driver, index, &tty); 2080 retval = init_dev(driver, index, &tty);
2084 up(&tty_sem); 2081 mutex_unlock(&tty_mutex);
2085 if (retval) 2082 if (retval)
2086 return retval; 2083 return retval;
2087 2084
@@ -2167,9 +2164,9 @@ static int ptmx_open(struct inode * inode, struct file * filp)
2167 } 2164 }
2168 up(&allocated_ptys_lock); 2165 up(&allocated_ptys_lock);
2169 2166
2170 down(&tty_sem); 2167 mutex_lock(&tty_mutex);
2171 retval = init_dev(ptm_driver, index, &tty); 2168 retval = init_dev(ptm_driver, index, &tty);
2172 up(&tty_sem); 2169 mutex_unlock(&tty_mutex);
2173 2170
2174 if (retval) 2171 if (retval)
2175 goto out; 2172 goto out;
@@ -2675,7 +2672,7 @@ static void __do_SAK(void *arg)
2675 tty_hangup(tty); 2672 tty_hangup(tty);
2676#else 2673#else
2677 struct tty_struct *tty = arg; 2674 struct tty_struct *tty = arg;
2678 struct task_struct *p; 2675 struct task_struct *g, *p;
2679 int session; 2676 int session;
2680 int i; 2677 int i;
2681 struct file *filp; 2678 struct file *filp;
@@ -2696,8 +2693,18 @@ static void __do_SAK(void *arg)
2696 tty->driver->flush_buffer(tty); 2693 tty->driver->flush_buffer(tty);
2697 2694
2698 read_lock(&tasklist_lock); 2695 read_lock(&tasklist_lock);
2696 /* Kill the entire session */
2699 do_each_task_pid(session, PIDTYPE_SID, p) { 2697 do_each_task_pid(session, PIDTYPE_SID, p) {
2700 if (p->signal->tty == tty || session > 0) { 2698 printk(KERN_NOTICE "SAK: killed process %d"
2699 " (%s): p->signal->session==tty->session\n",
2700 p->pid, p->comm);
2701 send_sig(SIGKILL, p, 1);
2702 } while_each_task_pid(session, PIDTYPE_SID, p);
2703 /* Now kill any processes that happen to have the
2704 * tty open.
2705 */
2706 do_each_thread(g, p) {
2707 if (p->signal->tty == tty) {
2701 printk(KERN_NOTICE "SAK: killed process %d" 2708 printk(KERN_NOTICE "SAK: killed process %d"
2702 " (%s): p->signal->session==tty->session\n", 2709 " (%s): p->signal->session==tty->session\n",
2703 p->pid, p->comm); 2710 p->pid, p->comm);
@@ -2724,7 +2731,7 @@ static void __do_SAK(void *arg)
2724 rcu_read_unlock(); 2731 rcu_read_unlock();
2725 } 2732 }
2726 task_unlock(p); 2733 task_unlock(p);
2727 } while_each_task_pid(session, PIDTYPE_SID, p); 2734 } while_each_thread(g, p);
2728 read_unlock(&tasklist_lock); 2735 read_unlock(&tasklist_lock);
2729#endif 2736#endif
2730} 2737}
@@ -2915,8 +2922,8 @@ static void initialize_tty_struct(struct tty_struct *tty)
2915 init_waitqueue_head(&tty->write_wait); 2922 init_waitqueue_head(&tty->write_wait);
2916 init_waitqueue_head(&tty->read_wait); 2923 init_waitqueue_head(&tty->read_wait);
2917 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); 2924 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty);
2918 sema_init(&tty->atomic_read, 1); 2925 mutex_init(&tty->atomic_read_lock);
2919 sema_init(&tty->atomic_write, 1); 2926 mutex_init(&tty->atomic_write_lock);
2920 spin_lock_init(&tty->read_lock); 2927 spin_lock_init(&tty->read_lock);
2921 INIT_LIST_HEAD(&tty->tty_files); 2928 INIT_LIST_HEAD(&tty->tty_files);
2922 INIT_WORK(&tty->SAK_work, NULL, NULL); 2929 INIT_WORK(&tty->SAK_work, NULL, NULL);
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index d9325281e482..fd00822ac145 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void)
184 port->gs.closing_wait = 30 * HZ; 184 port->gs.closing_wait = 30 * HZ;
185 port->gs.rd = &scc_real_driver; 185 port->gs.rd = &scc_real_driver;
186#ifdef NEW_WRITE_LOCKING 186#ifdef NEW_WRITE_LOCKING
187 port->gs.port_write_sem = MUTEX; 187 port->gs.port_write_mutex = MUTEX;
188#endif 188#endif
189 init_waitqueue_head(&port->gs.open_wait); 189 init_waitqueue_head(&port->gs.open_wait);
190 init_waitqueue_head(&port->gs.close_wait); 190 init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 2267c7b81799..05e6e814d86f 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -613,7 +613,7 @@ static struct file_operations gpio_fops = {
613 .release = gpio_release, 613 .release = gpio_release,
614}; 614};
615 615
616static int giu_probe(struct platform_device *dev) 616static int __devinit giu_probe(struct platform_device *dev)
617{ 617{
618 unsigned long start, size, flags = 0; 618 unsigned long start, size, flags = 0;
619 unsigned int nr_pins = 0; 619 unsigned int nr_pins = 0;
@@ -697,7 +697,7 @@ static int giu_probe(struct platform_device *dev)
697 return cascade_irq(GIUINT_IRQ, giu_get_irq); 697 return cascade_irq(GIUINT_IRQ, giu_get_irq);
698} 698}
699 699
700static int giu_remove(struct platform_device *dev) 700static int __devexit giu_remove(struct platform_device *dev)
701{ 701{
702 iounmap(giu_base); 702 iounmap(giu_base);
703 703
@@ -712,9 +712,10 @@ static struct platform_device *giu_platform_device;
712 712
713static struct platform_driver giu_device_driver = { 713static struct platform_driver giu_device_driver = {
714 .probe = giu_probe, 714 .probe = giu_probe,
715 .remove = giu_remove, 715 .remove = __devexit_p(giu_remove),
716 .driver = { 716 .driver = {
717 .name = "GIU", 717 .name = "GIU",
718 .owner = THIS_MODULE,
718 }, 719 },
719}; 720};
720 721
@@ -722,9 +723,15 @@ static int __init vr41xx_giu_init(void)
722{ 723{
723 int retval; 724 int retval;
724 725
725 giu_platform_device = platform_device_register_simple("GIU", -1, NULL, 0); 726 giu_platform_device = platform_device_alloc("GIU", -1);
726 if (IS_ERR(giu_platform_device)) 727 if (!giu_platform_device)
727 return PTR_ERR(giu_platform_device); 728 return -ENOMEM;
729
730 retval = platform_device_add(giu_platform_device);
731 if (retval < 0) {
732 platform_device_put(giu_platform_device);
733 return retval;
734 }
728 735
729 retval = platform_driver_register(&giu_device_driver); 736 retval = platform_driver_register(&giu_device_driver);
730 if (retval < 0) 737 if (retval < 0)
diff --git a/drivers/char/vr41xx_rtc.c b/drivers/char/vr41xx_rtc.c
index bc1b4a15212c..b109d9a502d6 100644
--- a/drivers/char/vr41xx_rtc.c
+++ b/drivers/char/vr41xx_rtc.c
@@ -558,7 +558,7 @@ static struct miscdevice rtc_miscdevice = {
558 .fops = &rtc_fops, 558 .fops = &rtc_fops,
559}; 559};
560 560
561static int rtc_probe(struct platform_device *pdev) 561static int __devinit rtc_probe(struct platform_device *pdev)
562{ 562{
563 unsigned int irq; 563 unsigned int irq;
564 int retval; 564 int retval;
@@ -631,7 +631,7 @@ static int rtc_probe(struct platform_device *pdev)
631 return 0; 631 return 0;
632} 632}
633 633
634static int rtc_remove(struct platform_device *dev) 634static int __devexit rtc_remove(struct platform_device *dev)
635{ 635{
636 int retval; 636 int retval;
637 637
@@ -653,13 +653,14 @@ static struct platform_device *rtc_platform_device;
653 653
654static struct platform_driver rtc_device_driver = { 654static struct platform_driver rtc_device_driver = {
655 .probe = rtc_probe, 655 .probe = rtc_probe,
656 .remove = rtc_remove, 656 .remove = __devexit_p(rtc_remove),
657 .driver = { 657 .driver = {
658 .name = rtc_name, 658 .name = rtc_name,
659 .owner = THIS_MODULE,
659 }, 660 },
660}; 661};
661 662
662static int __devinit vr41xx_rtc_init(void) 663static int __init vr41xx_rtc_init(void)
663{ 664{
664 int retval; 665 int retval;
665 666
@@ -684,10 +685,20 @@ static int __devinit vr41xx_rtc_init(void)
684 break; 685 break;
685 } 686 }
686 687
687 rtc_platform_device = platform_device_register_simple("RTC", -1, 688 rtc_platform_device = platform_device_alloc("RTC", -1);
688 rtc_resource, ARRAY_SIZE(rtc_resource)); 689 if (!rtc_platform_device)
689 if (IS_ERR(rtc_platform_device)) 690 return -ENOMEM;
690 return PTR_ERR(rtc_platform_device); 691
692 retval = platform_device_add_resources(rtc_platform_device,
693 rtc_resource, ARRAY_SIZE(rtc_resource));
694
695 if (retval == 0)
696 retval = platform_device_add(rtc_platform_device);
697
698 if (retval < 0) {
699 platform_device_put(rtc_platform_device);
700 return retval;
701 }
691 702
692 retval = platform_driver_register(&rtc_device_driver); 703 retval = platform_driver_register(&rtc_device_driver);
693 if (retval < 0) 704 if (retval < 0)
@@ -696,10 +707,9 @@ static int __devinit vr41xx_rtc_init(void)
696 return retval; 707 return retval;
697} 708}
698 709
699static void __devexit vr41xx_rtc_exit(void) 710static void __exit vr41xx_rtc_exit(void)
700{ 711{
701 platform_driver_unregister(&rtc_device_driver); 712 platform_driver_unregister(&rtc_device_driver);
702
703 platform_device_unregister(rtc_platform_device); 713 platform_device_unregister(rtc_platform_device);
704} 714}
705 715
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 0900d1dbee59..ca4844c527da 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2489} 2489}
2490 2490
2491/* 2491/*
2492 * We take tty_sem in here to prevent another thread from coming in via init_dev 2492 * We take tty_mutex in here to prevent another thread from coming in via init_dev
2493 * and taking a ref against the tty while we're in the process of forgetting 2493 * and taking a ref against the tty while we're in the process of forgetting
2494 * about it and cleaning things up. 2494 * about it and cleaning things up.
2495 * 2495 *
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2497 */ 2497 */
2498static void con_close(struct tty_struct *tty, struct file *filp) 2498static void con_close(struct tty_struct *tty, struct file *filp)
2499{ 2499{
2500 down(&tty_sem); 2500 mutex_lock(&tty_mutex);
2501 acquire_console_sem(); 2501 acquire_console_sem();
2502 if (tty && tty->count == 1) { 2502 if (tty && tty->count == 1) {
2503 struct vc_data *vc = tty->driver_data; 2503 struct vc_data *vc = tty->driver_data;
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp)
2507 tty->driver_data = NULL; 2507 tty->driver_data = NULL;
2508 release_console_sem(); 2508 release_console_sem();
2509 vcs_remove_devfs(tty); 2509 vcs_remove_devfs(tty);
2510 up(&tty_sem); 2510 mutex_unlock(&tty_mutex);
2511 /* 2511 /*
2512 * tty_sem is released, but we still hold BKL, so there is 2512 * tty_mutex is released, but we still hold BKL, so there is
2513 * still exclusion against init_dev() 2513 * still exclusion against init_dev()
2514 */ 2514 */
2515 return; 2515 return;
2516 } 2516 }
2517 release_console_sem(); 2517 release_console_sem();
2518 up(&tty_sem); 2518 mutex_unlock(&tty_mutex);
2519} 2519}
2520 2520
2521static void vc_init(struct vc_data *vc, unsigned int rows, 2521static void vc_init(struct vc_data *vc, unsigned int rows,
@@ -2869,9 +2869,9 @@ void unblank_screen(void)
2869} 2869}
2870 2870
2871/* 2871/*
2872 * We defer the timer blanking to work queue so it can take the console semaphore 2872 * We defer the timer blanking to work queue so it can take the console mutex
2873 * (console operations can still happen at irq time, but only from printk which 2873 * (console operations can still happen at irq time, but only from printk which
2874 * has the console semaphore. Not perfect yet, but better than no locking 2874 * has the console mutex. Not perfect yet, but better than no locking
2875 */ 2875 */
2876static void blank_screen_t(unsigned long dummy) 2876static void blank_screen_t(unsigned long dummy)
2877{ 2877{
@@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
3234 } 3234 }
3235} 3235}
3236 3236
3237int is_console_suspend_safe(void)
3238{
3239 /* It is unsafe to suspend devices while X has control of the
3240 * hardware. Make sure we are running on a kernel-controlled console.
3241 */
3242 return vc_cons[fg_console].d->vc_mode == KD_TEXT;
3243}
3244
3237/* 3245/*
3238 * Visible symbols for modules 3246 * Visible symbols for modules
3239 */ 3247 */
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index c0dfcf273f0a..16e99db2e12d 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -148,6 +148,16 @@ config MPCORE_WATCHDOG
148 To compile this driver as a module, choose M here: the 148 To compile this driver as a module, choose M here: the
149 module will be called mpcore_wdt. 149 module will be called mpcore_wdt.
150 150
151config EP93XX_WATCHDOG
152 tristate "EP93xx Watchdog"
153 depends on WATCHDOG && ARCH_EP93XX
154 help
155 Say Y here if to include support for the watchdog timer
156 embedded in the Cirrus Logic EP93xx family of devices.
157
158 To compile this driver as a module, choose M here: the
159 module will be called ep93xx_wdt.
160
151# X86 (i386 + ia64 + x86_64) Architecture 161# X86 (i386 + ia64 + x86_64) Architecture
152 162
153config ACQUIRE_WDT 163config ACQUIRE_WDT
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 36c0b282b8ba..d6f27fde9905 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 30obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 31obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
32obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 32obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
33obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
33 34
34# X86 (i386 + ia64 + x86_64) Architecture 35# X86 (i386 + ia64 + x86_64) Architecture
35obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o 36obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
diff --git a/drivers/char/watchdog/ep93xx_wdt.c b/drivers/char/watchdog/ep93xx_wdt.c
new file mode 100644
index 000000000000..9021dbb78299
--- /dev/null
+++ b/drivers/char/watchdog/ep93xx_wdt.c
@@ -0,0 +1,257 @@
1/*
2 * Watchdog driver for Cirrus Logic EP93xx family of devices.
3 *
4 * Copyright (c) 2004 Ray Lehtiniemi
5 * Copyright (c) 2006 Tower Technologies
6 * Based on ep93xx driver, bits from alim7101_wdt.c
7 *
8 * Authors: Ray Lehtiniemi <rayl@mail.com>,
9 * Alessandro Zummo <a.zummo@towertech.it>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 *
15 * This watchdog fires after 250msec, which is a too short interval
16 * for us to rely on the user space daemon alone. So we ping the
17 * wdt each ~200msec and eventually stop doing it if the user space
18 * daemon dies.
19 *
20 * TODO:
21 *
22 * - Test last reset from watchdog status
23 * - Add a few missing ioctls
24 */
25
26#include <linux/module.h>
27#include <linux/fs.h>
28#include <linux/miscdevice.h>
29#include <linux/watchdog.h>
30#include <linux/timer.h>
31
32#include <asm/hardware.h>
33#include <asm/uaccess.h>
34
35#define WDT_VERSION "0.3"
36#define PFX "ep93xx_wdt: "
37
38/* default timeout (secs) */
39#define WDT_TIMEOUT 30
40
41static int nowayout = WATCHDOG_NOWAYOUT;
42static int timeout = WDT_TIMEOUT;
43
44static struct timer_list timer;
45static unsigned long next_heartbeat;
46static unsigned long wdt_status;
47static unsigned long boot_status;
48
49#define WDT_IN_USE 0
50#define WDT_OK_TO_CLOSE 1
51
52#define EP93XX_WDT_REG(x) (EP93XX_WATCHDOG_BASE + (x))
53#define EP93XX_WDT_WATCHDOG EP93XX_WDT_REG(0x00)
54#define EP93XX_WDT_WDSTATUS EP93XX_WDT_REG(0x04)
55
56/* reset the wdt every ~200ms */
57#define WDT_INTERVAL (HZ/5)
58
59static void wdt_enable(void)
60{
61 __raw_writew(0xaaaa, EP93XX_WDT_WATCHDOG);
62}
63
64static void wdt_disable(void)
65{
66 __raw_writew(0xaa55, EP93XX_WDT_WATCHDOG);
67}
68
69static inline void wdt_ping(void)
70{
71 __raw_writew(0x5555, EP93XX_WDT_WATCHDOG);
72}
73
74static void wdt_startup(void)
75{
76 next_heartbeat = jiffies + (timeout * HZ);
77
78 wdt_enable();
79 mod_timer(&timer, jiffies + WDT_INTERVAL);
80}
81
82static void wdt_shutdown(void)
83{
84 del_timer_sync(&timer);
85 wdt_disable();
86}
87
88static void wdt_keepalive(void)
89{
90 /* user land ping */
91 next_heartbeat = jiffies + (timeout * HZ);
92}
93
94static int ep93xx_wdt_open(struct inode *inode, struct file *file)
95{
96 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
97 return -EBUSY;
98
99 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
100
101 wdt_startup();
102
103 return nonseekable_open(inode, file);
104}
105
106static ssize_t
107ep93xx_wdt_write(struct file *file, const char __user *data, size_t len,
108 loff_t *ppos)
109{
110 /* Can't seek (pwrite) on this device */
111 if (*ppos != file->f_pos)
112 return -ESPIPE;
113
114 if (len) {
115 if (!nowayout) {
116 size_t i;
117
118 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
119
120 for (i = 0; i != len; i++) {
121 char c;
122
123 if (get_user(c, data + i))
124 return -EFAULT;
125
126 if (c == 'V')
127 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
128 else
129 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
130 }
131 }
132 wdt_keepalive();
133 }
134
135 return len;
136}
137
138static struct watchdog_info ident = {
139 .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE,
140 .identity = "EP93xx Watchdog",
141};
142
143static int
144ep93xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
145 unsigned long arg)
146{
147 int ret = -ENOIOCTLCMD;
148
149 switch (cmd) {
150 case WDIOC_GETSUPPORT:
151 ret = copy_to_user((struct watchdog_info __user *)arg, &ident,
152 sizeof(ident)) ? -EFAULT : 0;
153 break;
154
155 case WDIOC_GETSTATUS:
156 ret = put_user(0, (int __user *)arg);
157 break;
158
159 case WDIOC_GETBOOTSTATUS:
160 ret = put_user(boot_status, (int __user *)arg);
161 break;
162
163 case WDIOC_GETTIMEOUT:
164 /* actually, it is 0.250 seconds.... */
165 ret = put_user(1, (int __user *)arg);
166 break;
167
168 case WDIOC_KEEPALIVE:
169 wdt_keepalive();
170 ret = 0;
171 break;
172 }
173 return ret;
174}
175
176static int ep93xx_wdt_release(struct inode *inode, struct file *file)
177{
178 if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
179 wdt_shutdown();
180 else
181 printk(KERN_CRIT PFX "Device closed unexpectedly - "
182 "timer will not stop\n");
183
184 clear_bit(WDT_IN_USE, &wdt_status);
185 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
186
187 return 0;
188}
189
190static struct file_operations ep93xx_wdt_fops = {
191 .owner = THIS_MODULE,
192 .write = ep93xx_wdt_write,
193 .ioctl = ep93xx_wdt_ioctl,
194 .open = ep93xx_wdt_open,
195 .release = ep93xx_wdt_release,
196};
197
198static struct miscdevice ep93xx_wdt_miscdev = {
199 .minor = WATCHDOG_MINOR,
200 .name = "watchdog",
201 .fops = &ep93xx_wdt_fops,
202};
203
204static void ep93xx_timer_ping(unsigned long data)
205{
206 if (time_before(jiffies, next_heartbeat))
207 wdt_ping();
208
209 /* Re-set the timer interval */
210 mod_timer(&timer, jiffies + WDT_INTERVAL);
211}
212
213static int __init ep93xx_wdt_init(void)
214{
215 int err;
216
217 err = misc_register(&ep93xx_wdt_miscdev);
218
219 boot_status = __raw_readl(EP93XX_WDT_WATCHDOG) & 0x01 ? 1 : 0;
220
221 printk(KERN_INFO PFX "EP93XX watchdog, driver version "
222 WDT_VERSION "%s\n",
223 (__raw_readl(EP93XX_WDT_WATCHDOG) & 0x08)
224 ? " (nCS1 disable detected)" : "");
225
226 if (timeout < 1 || timeout > 3600) {
227 timeout = WDT_TIMEOUT;
228 printk(KERN_INFO PFX
229 "timeout value must be 1<=x<=3600, using %d\n",
230 timeout);
231 }
232
233 setup_timer(&timer, ep93xx_timer_ping, 1);
234 return err;
235}
236
237static void __exit ep93xx_wdt_exit(void)
238{
239 wdt_shutdown();
240 misc_deregister(&ep93xx_wdt_miscdev);
241}
242
243module_init(ep93xx_wdt_init);
244module_exit(ep93xx_wdt_exit);
245
246module_param(nowayout, int, 0);
247MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
248
249module_param(timeout, int, 0);
250MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
251
252MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
253 "Alessandro Zummo <a.zummo@towertech.it>");
254MODULE_DESCRIPTION("EP93xx Watchdog");
255MODULE_LICENSE("GPL");
256MODULE_VERSION(WDT_VERSION);
257MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
index 00d9ef04a369..f1b9cf89f153 100644
--- a/drivers/char/watchdog/mv64x60_wdt.c
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -228,15 +228,25 @@ static int __init mv64x60_wdt_init(void)
228 228
229 printk(KERN_INFO "MV64x60 watchdog driver\n"); 229 printk(KERN_INFO "MV64x60 watchdog driver\n");
230 230
231 mv64x60_wdt_dev = platform_device_register_simple(MV64x60_WDT_NAME, 231 mv64x60_wdt_dev = platform_device_alloc(MV64x60_WDT_NAME, -1);
232 -1, NULL, 0); 232 if (!mv64x60_wdt_dev) {
233 if (IS_ERR(mv64x60_wdt_dev)) { 233 ret = -ENOMEM;
234 ret = PTR_ERR(mv64x60_wdt_dev); 234 goto out;
235 }
236
237 ret = platform_device_add(mv64x60_wdt_dev);
238 if (ret) {
239 platform_device_put(mv64x60_wdt_dev);
235 goto out; 240 goto out;
236 } 241 }
237 242
238 ret = platform_driver_register(&mv64x60_wdt_driver); 243 ret = platform_driver_register(&mv64x60_wdt_driver);
239 out: 244 if (ret) {
245 platform_device_unregister(mv64x60_wdt_dev);
246 goto out;
247 }
248
249 out:
240 return ret; 250 return ret;
241} 251}
242 252
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 1533f56baa42..2700c5c45b8a 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -42,6 +42,7 @@
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <linux/usb.h> 44#include <linux/usb.h>
45#include <linux/mutex.h>
45 46
46 47
47#ifdef CONFIG_USB_DEBUG 48#ifdef CONFIG_USB_DEBUG
@@ -143,7 +144,7 @@ struct usb_pcwd_private {
143static struct usb_pcwd_private *usb_pcwd_device; 144static struct usb_pcwd_private *usb_pcwd_device;
144 145
145/* prevent races between open() and disconnect() */ 146/* prevent races between open() and disconnect() */
146static DECLARE_MUTEX (disconnect_sem); 147static DEFINE_MUTEX(disconnect_mutex);
147 148
148/* local function prototypes */ 149/* local function prototypes */
149static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id); 150static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id);
@@ -723,7 +724,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
723 struct usb_pcwd_private *usb_pcwd; 724 struct usb_pcwd_private *usb_pcwd;
724 725
725 /* prevent races with open() */ 726 /* prevent races with open() */
726 down (&disconnect_sem); 727 mutex_lock(&disconnect_mutex);
727 728
728 usb_pcwd = usb_get_intfdata (interface); 729 usb_pcwd = usb_get_intfdata (interface);
729 usb_set_intfdata (interface, NULL); 730 usb_set_intfdata (interface, NULL);
@@ -749,7 +750,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
749 750
750 cards_found--; 751 cards_found--;
751 752
752 up (&disconnect_sem); 753 mutex_unlock(&disconnect_mutex);
753 754
754 printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); 755 printk(KERN_INFO PFX "USB PC Watchdog disconnected\n");
755} 756}